@koda-sl/baker-cli 0.434.0-dev.e6bd6f23c → 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
|
};
|
|
@@ -77145,33 +77140,6 @@ function rebaseLeadPaths(canvas, leadDir, memberDir) {
|
|
|
77145
77140
|
}
|
|
77146
77141
|
return out;
|
|
77147
77142
|
}
|
|
77148
|
-
var DESIGN_FIELDS = [
|
|
77149
|
-
"scene",
|
|
77150
|
-
"brand",
|
|
77151
|
-
"colors",
|
|
77152
|
-
"references",
|
|
77153
|
-
"logo",
|
|
77154
|
-
"logo_position",
|
|
77155
|
-
"third_party_brands",
|
|
77156
|
-
"formats",
|
|
77157
|
-
"direction"
|
|
77158
|
-
];
|
|
77159
|
-
function seriesDesignOf(spec) {
|
|
77160
|
-
try {
|
|
77161
|
-
const read = readAdSpec(spec);
|
|
77162
|
-
return JSON.stringify(DESIGN_FIELDS.map((key) => read[key] ?? null));
|
|
77163
|
-
} catch {
|
|
77164
|
-
return null;
|
|
77165
|
-
}
|
|
77166
|
-
}
|
|
77167
|
-
function withLeadDesign(memberSpec, leadSpec) {
|
|
77168
|
-
const out = { ...memberSpec };
|
|
77169
|
-
for (const key of DESIGN_FIELDS) {
|
|
77170
|
-
if (key in leadSpec) out[key] = leadSpec[key];
|
|
77171
|
-
else delete out[key];
|
|
77172
|
-
}
|
|
77173
|
-
return out;
|
|
77174
|
-
}
|
|
77175
77143
|
function unchangedCopyRefusal(lead, memberSpec) {
|
|
77176
77144
|
const words2 = (copy2) => copy2.map((l) => l.text.trim()).join("\n");
|
|
77177
77145
|
let copy;
|
|
@@ -77193,48 +77161,16 @@ async function writeSeriesMemberCanvas(root, slug, opts = {}) {
|
|
|
77193
77161
|
const version = await leadVersion(root, lead, opts.fetchRecord);
|
|
77194
77162
|
if ("refused" in version) return version;
|
|
77195
77163
|
const dir = creativeDir(root, slug);
|
|
77196
|
-
const
|
|
77197
|
-
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"));
|
|
77198
77165
|
const unchanged = opts.leadWords ? null : unchangedCopyRefusal(version.lead, memberSpec);
|
|
77199
77166
|
if (unchanged) return unchanged;
|
|
77200
|
-
const
|
|
77201
|
-
const before = await readFile20(file, "utf8").catch(() => null);
|
|
77202
|
-
const leadDesign = seriesDesignOf(version.spec);
|
|
77203
|
-
const ownDesign = seriesDesignOf(memberSpec);
|
|
77204
|
-
const synced = before ? JSON.parse(before).metadata?.series?.design : void 0;
|
|
77205
|
-
let designFromLead = false;
|
|
77206
|
-
if (leadDesign !== null && ownDesign !== null && ownDesign !== leadDesign) {
|
|
77207
|
-
if (!opts.takeLeadDesign && ownDesign !== synced) {
|
|
77208
|
-
return refusal(
|
|
77209
|
-
"series_design_changed",
|
|
77210
|
-
`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}".`,
|
|
77211
|
-
`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.`
|
|
77212
|
-
);
|
|
77213
|
-
}
|
|
77214
|
-
memberSpec = withLeadDesign(memberSpec, version.spec);
|
|
77215
|
-
await writeFile11(promptPath, `${JSON.stringify(memberSpec, null, 2)}
|
|
77216
|
-
`, "utf8");
|
|
77217
|
-
designFromLead = true;
|
|
77218
|
-
}
|
|
77219
|
-
const canvas = seriesMemberAd(rebaseLeadPaths(version.canvas, creativeDir(root, lead), dir), {
|
|
77220
|
-
...version.lead,
|
|
77221
|
-
...leadDesign !== null ? { design: leadDesign } : {}
|
|
77222
|
-
});
|
|
77167
|
+
const canvas = seriesMemberAd(rebaseLeadPaths(version.canvas, creativeDir(root, lead), dir), version.lead);
|
|
77223
77168
|
const text4 = `${JSON.stringify(canvas, null, 2)}
|
|
77224
77169
|
`;
|
|
77170
|
+
const file = canvasFile(root, slug);
|
|
77171
|
+
const before = await readFile20(file, "utf8").catch(() => null);
|
|
77225
77172
|
if (before !== text4) await writeFile11(file, text4, "utf8");
|
|
77226
|
-
return { lead, leadRunId: version.lead.runId, canvasPath: file, written: before !== text4
|
|
77227
|
-
}
|
|
77228
|
-
function seriesRunHints(slug, series) {
|
|
77229
|
-
if (series.lead) {
|
|
77230
|
-
return [
|
|
77231
|
-
`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.`
|
|
77232
|
-
];
|
|
77233
|
-
}
|
|
77234
|
-
if (series.members.length === 0) return [];
|
|
77235
|
-
return [
|
|
77236
|
-
`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.`
|
|
77237
|
-
];
|
|
77173
|
+
return { lead, leadRunId: version.lead.runId, canvasPath: file, written: before !== text4 };
|
|
77238
77174
|
}
|
|
77239
77175
|
|
|
77240
77176
|
// src/commands/canvas/series-run.ts
|
|
@@ -79201,11 +79137,9 @@ async function executeSeriesRun(lead) {
|
|
|
79201
79137
|
`);
|
|
79202
79138
|
const results = await runSeries(members, {
|
|
79203
79139
|
plan: async (slug) => {
|
|
79204
|
-
const made = await writeSeriesMemberCanvas(root, slug
|
|
79140
|
+
const made = await writeSeriesMemberCanvas(root, slug);
|
|
79205
79141
|
if (made === null) return { refused: { code: "not_in_series", message: `${slug} is no ad of this series.`, fix: "" } };
|
|
79206
79142
|
if ("refused" in made) return made;
|
|
79207
|
-
if (made.designFromLead) process.stdout.write(`[series] ${slug} takes the lead's design, its own words kept
|
|
79208
|
-
`);
|
|
79209
79143
|
try {
|
|
79210
79144
|
const prepared = await prepareCanvas(made.canvasPath, { write: false });
|
|
79211
79145
|
const state = await readRenderState(canvasRoot, slug);
|
|
@@ -79713,18 +79647,12 @@ ${describeRewrites(prepared.rewrites)}
|
|
|
79713
79647
|
}
|
|
79714
79648
|
const costHint = staticReview ? runCostHint(result.stats, paidFor(runShape)) : null;
|
|
79715
79649
|
const corrected = opts.autoFixed ?? [];
|
|
79716
|
-
const seriesRoot = creativeSlug && staticReview ? findWorkspaceRoot(path32.dirname(filePath)) : null;
|
|
79717
|
-
const seriesHints = seriesRoot && creativeSlug ? seriesRunHints(creativeSlug, {
|
|
79718
|
-
lead: await seriesLeadOf(seriesRoot, creativeSlug),
|
|
79719
|
-
members: await seriesMembers(seriesRoot, creativeSlug)
|
|
79720
|
-
}) : [];
|
|
79721
79650
|
const hints2 = staticReview ? [
|
|
79722
79651
|
...corrected.length > 0 ? [
|
|
79723
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.`
|
|
79724
79653
|
] : [],
|
|
79725
79654
|
...staticReview.hints,
|
|
79726
79655
|
...costHint ? [costHint] : [],
|
|
79727
|
-
...seriesHints,
|
|
79728
79656
|
...stillThere.length > 0 ? [
|
|
79729
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).`
|
|
79730
79658
|
] : []
|