@koda-sl/baker-cli 0.434.0-dev.b788a58e0 → 0.434.0-dev.ec5c827fe
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
|
@@ -202,7 +202,7 @@ import {
|
|
|
202
202
|
withoutCastName,
|
|
203
203
|
wordCount,
|
|
204
204
|
ytDlpBlockSignal
|
|
205
|
-
} from "./chunk-
|
|
205
|
+
} from "./chunk-7I73A72J.js";
|
|
206
206
|
import {
|
|
207
207
|
NAME_CONTAINS_ARG,
|
|
208
208
|
csvOrJson,
|
|
@@ -70716,12 +70716,7 @@ function seriesMemberAd(input, lead) {
|
|
|
70716
70716
|
...canvas.metadata,
|
|
70717
70717
|
name: "static ad of a series",
|
|
70718
70718
|
description: `The next ad of the series led by \`${lead.slug}\`: the lead's finished picture (\`lead_ad\`) with only its words changed to the copy in this ad's \`prompt.json\`, every other size the lead's own size with the same words changed. Edit only the copy in \`prompt.json\`, then \`baker canvas run\`. Change the lead to change the design of the whole series.`,
|
|
70719
|
-
series: {
|
|
70720
|
-
lead: lead.slug,
|
|
70721
|
-
run_id: lead.runId,
|
|
70722
|
-
copy: lead.copy.map((l) => ({ ...l })),
|
|
70723
|
-
...lead.design ? { design: lead.design } : {}
|
|
70724
|
-
}
|
|
70719
|
+
series: { lead: lead.slug, run_id: lead.runId, copy: lead.copy.map((l) => ({ ...l })) }
|
|
70725
70720
|
},
|
|
70726
70721
|
nodes
|
|
70727
70722
|
};
|
|
@@ -75621,8 +75616,7 @@ async function recordRendered(canvasRoot, slug, sourceSha, runId, drawn = {}) {
|
|
|
75621
75616
|
rendered: { sourceSha, runId, at: Date.now() },
|
|
75622
75617
|
...drawn.prompt !== void 0 ? { prompt: drawn.prompt } : {},
|
|
75623
75618
|
lastFix: drawn.lastFix,
|
|
75624
|
-
picture: drawn.picture
|
|
75625
|
-
...drawn.seriesLeadRun ? { seriesLeadRun: drawn.seriesLeadRun } : {}
|
|
75619
|
+
picture: drawn.picture
|
|
75626
75620
|
});
|
|
75627
75621
|
}
|
|
75628
75622
|
async function recordReviewOutcome(canvasRoot, slug, outcome2) {
|
|
@@ -77146,33 +77140,6 @@ function rebaseLeadPaths(canvas, leadDir, memberDir) {
|
|
|
77146
77140
|
}
|
|
77147
77141
|
return out;
|
|
77148
77142
|
}
|
|
77149
|
-
var DESIGN_FIELDS = [
|
|
77150
|
-
"scene",
|
|
77151
|
-
"brand",
|
|
77152
|
-
"colors",
|
|
77153
|
-
"references",
|
|
77154
|
-
"logo",
|
|
77155
|
-
"logo_position",
|
|
77156
|
-
"third_party_brands",
|
|
77157
|
-
"formats",
|
|
77158
|
-
"direction"
|
|
77159
|
-
];
|
|
77160
|
-
function seriesDesignOf(spec) {
|
|
77161
|
-
try {
|
|
77162
|
-
const read = readAdSpec(spec);
|
|
77163
|
-
return JSON.stringify(DESIGN_FIELDS.map((key) => read[key] ?? null));
|
|
77164
|
-
} catch {
|
|
77165
|
-
return null;
|
|
77166
|
-
}
|
|
77167
|
-
}
|
|
77168
|
-
function withLeadDesign(memberSpec, leadSpec) {
|
|
77169
|
-
const out = { ...memberSpec };
|
|
77170
|
-
for (const key of DESIGN_FIELDS) {
|
|
77171
|
-
if (key in leadSpec) out[key] = leadSpec[key];
|
|
77172
|
-
else delete out[key];
|
|
77173
|
-
}
|
|
77174
|
-
return out;
|
|
77175
|
-
}
|
|
77176
77143
|
function unchangedCopyRefusal(lead, memberSpec) {
|
|
77177
77144
|
const words2 = (copy2) => copy2.map((l) => l.text.trim()).join("\n");
|
|
77178
77145
|
let copy;
|
|
@@ -77194,51 +77161,16 @@ async function writeSeriesMemberCanvas(root, slug, opts = {}) {
|
|
|
77194
77161
|
const version = await leadVersion(root, lead, opts.fetchRecord);
|
|
77195
77162
|
if ("refused" in version) return version;
|
|
77196
77163
|
const dir = creativeDir(root, slug);
|
|
77197
|
-
const
|
|
77198
|
-
let memberSpec = JSON.parse(await readFile20(promptPath, "utf8").catch(() => "null"));
|
|
77164
|
+
const memberSpec = JSON.parse(await readFile20(path26.join(dir, "prompt.json"), "utf8").catch(() => "null"));
|
|
77199
77165
|
const unchanged = opts.leadWords ? null : unchangedCopyRefusal(version.lead, memberSpec);
|
|
77200
77166
|
if (unchanged) return unchanged;
|
|
77201
|
-
const
|
|
77202
|
-
const before = await readFile20(file, "utf8").catch(() => null);
|
|
77203
|
-
const leadDesign = seriesDesignOf(version.spec);
|
|
77204
|
-
const ownDesign = seriesDesignOf(memberSpec);
|
|
77205
|
-
const previous = before ? JSON.parse(before).metadata?.series : void 0;
|
|
77206
|
-
const synced = previous?.design;
|
|
77207
|
-
let designFromLead = false;
|
|
77208
|
-
if (leadDesign !== null && ownDesign !== null && ownDesign !== leadDesign) {
|
|
77209
|
-
if (!opts.takeLeadDesign && ownDesign !== synced) {
|
|
77210
|
-
return refusal(
|
|
77211
|
-
"series_design_changed",
|
|
77212
|
-
`This ad's design (its scene, colours, pictures or logo in prompt.json) was changed on the ad itself, but every ad of the series has the design of its lead "${lead}".`,
|
|
77213
|
-
`Make the change once, on the lead: edit src/creatives/${lead}/prompt.json (or baker canvas run --slug ${lead} --fix "<the change>"), then baker canvas run --series ${lead}: every ad takes the lead's new design, its own words kept. Only this ad's copy belongs in its own prompt.json.`
|
|
77214
|
-
);
|
|
77215
|
-
}
|
|
77216
|
-
memberSpec = withLeadDesign(memberSpec, version.spec);
|
|
77217
|
-
await writeFile11(promptPath, `${JSON.stringify(memberSpec, null, 2)}
|
|
77218
|
-
`, "utf8");
|
|
77219
|
-
designFromLead = true;
|
|
77220
|
-
}
|
|
77221
|
-
const canvas = seriesMemberAd(rebaseLeadPaths(version.canvas, creativeDir(root, lead), dir), {
|
|
77222
|
-
...version.lead,
|
|
77223
|
-
...leadDesign !== null ? { design: leadDesign } : {}
|
|
77224
|
-
});
|
|
77167
|
+
const canvas = seriesMemberAd(rebaseLeadPaths(version.canvas, creativeDir(root, lead), dir), version.lead);
|
|
77225
77168
|
const text4 = `${JSON.stringify(canvas, null, 2)}
|
|
77226
77169
|
`;
|
|
77170
|
+
const file = canvasFile(root, slug);
|
|
77171
|
+
const before = await readFile20(file, "utf8").catch(() => null);
|
|
77227
77172
|
if (before !== text4) await writeFile11(file, text4, "utf8");
|
|
77228
|
-
|
|
77229
|
-
const newLeadVersion = madeFrom !== void 0 && madeFrom !== version.lead.runId;
|
|
77230
|
-
return { lead, leadRunId: version.lead.runId, canvasPath: file, written: before !== text4, designFromLead, newLeadVersion };
|
|
77231
|
-
}
|
|
77232
|
-
function seriesRunHints(slug, series) {
|
|
77233
|
-
if (series.lead) {
|
|
77234
|
-
return [
|
|
77235
|
-
`This ad is one of the series led by ${series.lead}: its picture is the lead's with its own words. A change to what every ad shares (the picture, colours, layout, logo) is made once, on the lead (src/creatives/${series.lead}/prompt.json, or baker canvas run --slug ${series.lead} --fix "<the change>"), then baker canvas run --series ${series.lead}. Correct only this ad's own words or its own defect here.`
|
|
77236
|
-
];
|
|
77237
|
-
}
|
|
77238
|
-
if (series.members.length === 0) return [];
|
|
77239
|
-
return [
|
|
77240
|
-
`This ad leads a series of ${series.members.length + 1}: baker canvas run --series ${slug} makes ${series.members.join(", ")} again from this version, each with its own words. Until then they show the lead's earlier version.`
|
|
77241
|
-
];
|
|
77173
|
+
return { lead, leadRunId: version.lead.runId, canvasPath: file, written: before !== text4 };
|
|
77242
77174
|
}
|
|
77243
77175
|
|
|
77244
77176
|
// src/commands/canvas/series-run.ts
|
|
@@ -79205,11 +79137,9 @@ async function executeSeriesRun(lead) {
|
|
|
79205
79137
|
`);
|
|
79206
79138
|
const results = await runSeries(members, {
|
|
79207
79139
|
plan: async (slug) => {
|
|
79208
|
-
const made = await writeSeriesMemberCanvas(root, slug
|
|
79140
|
+
const made = await writeSeriesMemberCanvas(root, slug);
|
|
79209
79141
|
if (made === null) return { refused: { code: "not_in_series", message: `${slug} is no ad of this series.`, fix: "" } };
|
|
79210
79142
|
if ("refused" in made) return made;
|
|
79211
|
-
if (made.designFromLead) process.stdout.write(`[series] ${slug} takes the lead's design, its own words kept
|
|
79212
|
-
`);
|
|
79213
79143
|
try {
|
|
79214
79144
|
const prepared = await prepareCanvas(made.canvasPath, { write: false });
|
|
79215
79145
|
const state = await readRenderState(canvasRoot, slug);
|
|
@@ -79233,22 +79163,21 @@ async function executeSeriesRun(lead) {
|
|
|
79233
79163
|
}
|
|
79234
79164
|
async function refreshSeriesAd(opts) {
|
|
79235
79165
|
const slug = opts.slug ?? (opts.file ? creativeSlugFromCanvasPath(path32.resolve(opts.file)) : null);
|
|
79236
|
-
if (!slug) return
|
|
79166
|
+
if (!slug) return;
|
|
79237
79167
|
const root = findWorkspaceRoot(opts.file ? path32.dirname(path32.resolve(opts.file)) : process.cwd());
|
|
79238
|
-
if (!root) return
|
|
79168
|
+
if (!root) return;
|
|
79239
79169
|
const made = await writeSeriesMemberCanvas(root, slug);
|
|
79240
|
-
if (made === null) return
|
|
79170
|
+
if (made === null) return;
|
|
79241
79171
|
if ("refused" in made) failPreflight3(made.refused.code, made.refused.message, made.refused.fix);
|
|
79242
79172
|
process.stdout.write(
|
|
79243
79173
|
`[series] ${slug} is the lead ${made.lead}'s version ${made.leadRunId} with this ad's words${made.written ? " (canvas written)" : ""}
|
|
79244
79174
|
`
|
|
79245
79175
|
);
|
|
79246
|
-
return made.newLeadVersion;
|
|
79247
79176
|
}
|
|
79248
79177
|
var canvasHeld = false;
|
|
79249
79178
|
async function executeCanvasRun(opts) {
|
|
79250
79179
|
const startedAt = opts.autoFixStartedAt ?? Date.now();
|
|
79251
|
-
|
|
79180
|
+
if ((opts.autoFixRound ?? 0) === 0) await refreshSeriesAd(opts);
|
|
79252
79181
|
const { canvasPath: filePath, adoptRunId } = await canvasFileFor(opts);
|
|
79253
79182
|
const canvasRoot = canvasOutputsRoot(filePath);
|
|
79254
79183
|
const creativeSlug = creativeSlugFromCanvasPath(filePath) ?? void 0;
|
|
@@ -79602,8 +79531,7 @@ ${describeRewrites(prepared.rewrites)}
|
|
|
79602
79531
|
// taken after the preflight wrote the projected graph, so the two are comparable.
|
|
79603
79532
|
sourceSha,
|
|
79604
79533
|
chatId: optionalChatId(),
|
|
79605
|
-
canvasSnapshotUrl: snapshot?.url
|
|
79606
|
-
...newAsk ? { newAsk: true } : {}
|
|
79534
|
+
canvasSnapshotUrl: snapshot?.url
|
|
79607
79535
|
};
|
|
79608
79536
|
if (client) {
|
|
79609
79537
|
const registered = await postInitialRunRecord(client, buildInitialRunRecord(runId, recordMeta));
|
|
@@ -79660,7 +79588,6 @@ ${describeRewrites(prepared.rewrites)}
|
|
|
79660
79588
|
if (creativeSlug) {
|
|
79661
79589
|
await recordRendered(canvasRoot, creativeSlug, sourceSha, result.run_id, {
|
|
79662
79590
|
...promptNow ? { prompt: promptNow } : {},
|
|
79663
|
-
...seriesOf(parsed)?.run_id ? { seriesLeadRun: seriesOf(parsed)?.run_id } : {},
|
|
79664
79591
|
picture: pictureRecord(result.run_id, {
|
|
79665
79592
|
chose: opts.useVariant !== void 0,
|
|
79666
79593
|
of: shown.picture,
|
|
@@ -79720,18 +79647,12 @@ ${describeRewrites(prepared.rewrites)}
|
|
|
79720
79647
|
}
|
|
79721
79648
|
const costHint = staticReview ? runCostHint(result.stats, paidFor(runShape)) : null;
|
|
79722
79649
|
const corrected = opts.autoFixed ?? [];
|
|
79723
|
-
const seriesRoot = creativeSlug && staticReview ? findWorkspaceRoot(path32.dirname(filePath)) : null;
|
|
79724
|
-
const seriesHints = seriesRoot && creativeSlug ? seriesRunHints(creativeSlug, {
|
|
79725
|
-
lead: await seriesLeadOf(seriesRoot, creativeSlug),
|
|
79726
|
-
members: await seriesMembers(seriesRoot, creativeSlug)
|
|
79727
|
-
}) : [];
|
|
79728
79650
|
const hints2 = staticReview ? [
|
|
79729
79651
|
...corrected.length > 0 ? [
|
|
79730
79652
|
`Corrected automatically before this result, ${corrected.length} more render${corrected.length === 1 ? "" : "s"}: ${corrected.join(" Then ")} What follows is the review of the corrected version.`
|
|
79731
79653
|
] : [],
|
|
79732
79654
|
...staticReview.hints,
|
|
79733
79655
|
...costHint ? [costHint] : [],
|
|
79734
|
-
...seriesHints,
|
|
79735
79656
|
...stillThere.length > 0 ? [
|
|
79736
79657
|
`The fix did not remove ${stillThere.length === 1 ? "this" : "these"}: ${stillThere.join(" | ")}. The same instruction will not run again; change the approach (edit prompt.json so it cannot happen, or re-lay out only that size).`
|
|
79737
79658
|
] : []
|