@koda-sl/baker-cli 0.361.0-dev.d766dc120 → 0.361.0
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 +4 -16
- package/canvas/avocado-tutorial.json +1 -1
- package/canvas/hello-world-overlay.json +1 -1
- package/dist/{chunk-K2IKLMCM.js → chunk-AI4HWQVN.js} +4 -4
- package/dist/chunk-AI4HWQVN.js.map +1 -0
- package/dist/cli.js +155 -279
- package/dist/cli.js.map +1 -1
- package/dist/engine/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-K2IKLMCM.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
validateCanvasDeep,
|
|
70
70
|
withoutCastName,
|
|
71
71
|
ytDlpBlockSignal
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-AI4HWQVN.js";
|
|
73
73
|
import {
|
|
74
74
|
csvOrJson,
|
|
75
75
|
daysAgoIso,
|
|
@@ -36641,9 +36641,134 @@ var critiqueCommand = defineCommand109({
|
|
|
36641
36641
|
// src/commands/canvas/inspect.ts
|
|
36642
36642
|
import { execFile } from "child_process";
|
|
36643
36643
|
import { readdir as readdir2, readFile as readFile4, stat } from "fs/promises";
|
|
36644
|
-
import
|
|
36644
|
+
import path6 from "path";
|
|
36645
36645
|
import { promisify } from "util";
|
|
36646
36646
|
import { defineCommand as defineCommand110 } from "citty";
|
|
36647
|
+
|
|
36648
|
+
// src/commands/canvas/normalize-paths.ts
|
|
36649
|
+
import { existsSync as existsSync4, realpathSync } from "fs";
|
|
36650
|
+
import { writeFile as writeFile2 } from "fs/promises";
|
|
36651
|
+
import path5 from "path";
|
|
36652
|
+
|
|
36653
|
+
// src/commands/canvas/resolve-paths.ts
|
|
36654
|
+
import path4 from "path";
|
|
36655
|
+
function resolveRelativeCanvasPaths(canvas, baseDir) {
|
|
36656
|
+
if (!canvas || typeof canvas !== "object") return canvas;
|
|
36657
|
+
const c = canvas;
|
|
36658
|
+
if (!Array.isArray(c.nodes)) return canvas;
|
|
36659
|
+
return { ...canvas, nodes: c.nodes.map((n) => resolveNode(n, baseDir)) };
|
|
36660
|
+
}
|
|
36661
|
+
function localPathParam(node) {
|
|
36662
|
+
if (node.type === "ingest") return node.params?.source === "path" ? "path" : null;
|
|
36663
|
+
if (node.type === "hyperframe_render" || node.type === "hyperframe_snapshot") return "composition";
|
|
36664
|
+
return null;
|
|
36665
|
+
}
|
|
36666
|
+
function resolveNode(node, baseDir) {
|
|
36667
|
+
if (!node || typeof node !== "object") return node;
|
|
36668
|
+
const n = node;
|
|
36669
|
+
const params = n.params;
|
|
36670
|
+
if (!params || typeof params !== "object") return node;
|
|
36671
|
+
const key = localPathParam(n);
|
|
36672
|
+
if (key && isResolvableRelative(params[key])) {
|
|
36673
|
+
return { ...node, params: { ...params, [key]: path4.resolve(baseDir, params[key]) } };
|
|
36674
|
+
}
|
|
36675
|
+
return node;
|
|
36676
|
+
}
|
|
36677
|
+
function isResolvableRelative(value) {
|
|
36678
|
+
return typeof value === "string" && value.length > 0 && !value.includes("[TODO") && !looksLikeHttpUrl(value) && !path4.isAbsolute(value);
|
|
36679
|
+
}
|
|
36680
|
+
|
|
36681
|
+
// src/commands/canvas/normalize-paths.ts
|
|
36682
|
+
function findWorkspaceRoot(startDir, exists2 = existsSync4, maxDepth = 12) {
|
|
36683
|
+
let dir = path5.resolve(startDir);
|
|
36684
|
+
for (let i = 0; i < maxDepth; i++) {
|
|
36685
|
+
if (exists2(path5.join(dir, "package.json"))) return dir;
|
|
36686
|
+
const parent = path5.dirname(dir);
|
|
36687
|
+
if (parent === dir) break;
|
|
36688
|
+
dir = parent;
|
|
36689
|
+
}
|
|
36690
|
+
return null;
|
|
36691
|
+
}
|
|
36692
|
+
function canvasOutputsRoot(canvasFile, cwd = process.cwd(), exists2 = existsSync4) {
|
|
36693
|
+
const root = findWorkspaceRoot(path5.dirname(path5.resolve(cwd, canvasFile)), exists2) ?? cwd;
|
|
36694
|
+
return path5.join(root, "canvas");
|
|
36695
|
+
}
|
|
36696
|
+
function canonicalize(target2) {
|
|
36697
|
+
const abs = path5.resolve(target2);
|
|
36698
|
+
let dir = abs;
|
|
36699
|
+
for (; ; ) {
|
|
36700
|
+
try {
|
|
36701
|
+
const real = realpathSync(dir);
|
|
36702
|
+
return dir === abs ? real : path5.join(real, path5.relative(dir, abs));
|
|
36703
|
+
} catch {
|
|
36704
|
+
const parent = path5.dirname(dir);
|
|
36705
|
+
if (parent === dir) return abs;
|
|
36706
|
+
dir = parent;
|
|
36707
|
+
}
|
|
36708
|
+
}
|
|
36709
|
+
}
|
|
36710
|
+
function isInside(root, target2) {
|
|
36711
|
+
const rel = path5.relative(root, target2);
|
|
36712
|
+
return rel !== "" && !rel.startsWith("..") && !path5.isAbsolute(rel);
|
|
36713
|
+
}
|
|
36714
|
+
function toCanvasRelative(canvasDir, target2) {
|
|
36715
|
+
return path5.relative(canvasDir, target2).split(path5.sep).join("/");
|
|
36716
|
+
}
|
|
36717
|
+
var RUNTIME_WORKSPACE_ROOT = "/home/user/repo";
|
|
36718
|
+
function rewriteTarget(value, workspaceRoot) {
|
|
36719
|
+
if (typeof value !== "string" || value.length === 0) return null;
|
|
36720
|
+
if (value.includes("[TODO") || looksLikeHttpUrl(value) || !path5.isAbsolute(value)) return null;
|
|
36721
|
+
const target2 = canonicalize(value);
|
|
36722
|
+
if (isInside(workspaceRoot, target2)) return target2;
|
|
36723
|
+
const fromRuntime = path5.relative(RUNTIME_WORKSPACE_ROOT, path5.normalize(value));
|
|
36724
|
+
if (fromRuntime !== "" && !fromRuntime.startsWith("..") && !path5.isAbsolute(fromRuntime)) {
|
|
36725
|
+
return path5.join(workspaceRoot, fromRuntime);
|
|
36726
|
+
}
|
|
36727
|
+
return null;
|
|
36728
|
+
}
|
|
36729
|
+
function normalizeCanvasPaths(canvas, canvasDir, workspaceRoot) {
|
|
36730
|
+
if (!canvas || typeof canvas !== "object") return { canvas, rewrites: [] };
|
|
36731
|
+
const c = canvas;
|
|
36732
|
+
if (!Array.isArray(c.nodes)) return { canvas, rewrites: [] };
|
|
36733
|
+
const root = canonicalize(workspaceRoot);
|
|
36734
|
+
const dir = canonicalize(canvasDir);
|
|
36735
|
+
const rewrites = [];
|
|
36736
|
+
const nodes = c.nodes.map((node) => {
|
|
36737
|
+
if (!node || typeof node !== "object") return node;
|
|
36738
|
+
const n = node;
|
|
36739
|
+
const params = n.params;
|
|
36740
|
+
if (!params || typeof params !== "object") return node;
|
|
36741
|
+
const nodeId = typeof n.id === "string" ? n.id : "?";
|
|
36742
|
+
if (n.type === "ingest" && params.source === "path" && looksLikeHttpUrl(params.path)) {
|
|
36743
|
+
rewrites.push({ nodeId, param: "source", from: "path", to: "url" });
|
|
36744
|
+
return { ...node, params: coercePathUrlToUrl(params) };
|
|
36745
|
+
}
|
|
36746
|
+
const key = localPathParam(n);
|
|
36747
|
+
if (!key) return node;
|
|
36748
|
+
const target2 = rewriteTarget(params[key], root);
|
|
36749
|
+
if (target2 === null) return node;
|
|
36750
|
+
const to = toCanvasRelative(dir, target2);
|
|
36751
|
+
rewrites.push({ nodeId, param: key, from: params[key], to });
|
|
36752
|
+
return { ...node, params: { ...params, [key]: to } };
|
|
36753
|
+
});
|
|
36754
|
+
return rewrites.length === 0 ? { canvas, rewrites } : { canvas: { ...canvas, nodes }, rewrites };
|
|
36755
|
+
}
|
|
36756
|
+
async function healCanvasPaths(filePath, canvas) {
|
|
36757
|
+
const canvasDir = path5.dirname(filePath);
|
|
36758
|
+
const workspaceRoot = findWorkspaceRoot(canvasDir);
|
|
36759
|
+
if (!workspaceRoot) return { canvas, rewrites: [], text: null };
|
|
36760
|
+
const normalized = normalizeCanvasPaths(canvas, canvasDir, workspaceRoot);
|
|
36761
|
+
if (normalized.rewrites.length === 0) return { ...normalized, text: null };
|
|
36762
|
+
const text2 = `${JSON.stringify(normalized.canvas, null, 2)}
|
|
36763
|
+
`;
|
|
36764
|
+
await writeFile2(filePath, text2, "utf8");
|
|
36765
|
+
return { ...normalized, text: text2 };
|
|
36766
|
+
}
|
|
36767
|
+
function describeRewrites(rewrites) {
|
|
36768
|
+
return rewrites.map((r) => ` ${r.nodeId}.${r.param}: ${r.from} \u2192 ${r.to}`).join("\n");
|
|
36769
|
+
}
|
|
36770
|
+
|
|
36771
|
+
// src/commands/canvas/inspect.ts
|
|
36647
36772
|
var execFileAsync = promisify(execFile);
|
|
36648
36773
|
var inspectCommand = defineCommand110({
|
|
36649
36774
|
meta: {
|
|
@@ -36652,14 +36777,15 @@ var inspectCommand = defineCommand110({
|
|
|
36652
36777
|
},
|
|
36653
36778
|
args: {
|
|
36654
36779
|
run: { type: "positional", required: true, description: "Run id (e.g. r_01K...) or absolute run directory" },
|
|
36655
|
-
"outputs-dir": { type: "string", description: "Per-run outputs root (default
|
|
36780
|
+
"outputs-dir": { type: "string", description: "Per-run outputs root (default <workspace root>/canvas, where `canvas run` writes)" },
|
|
36656
36781
|
thumbnails: {
|
|
36657
36782
|
type: "boolean",
|
|
36658
36783
|
description: "Extract start/middle/end frames from every video output (requires ffmpeg)"
|
|
36659
36784
|
}
|
|
36660
36785
|
},
|
|
36661
36786
|
async run({ args: args5 }) {
|
|
36662
|
-
const
|
|
36787
|
+
const cwd = process.cwd();
|
|
36788
|
+
const outputsDir = args5["outputs-dir"] ? path6.resolve(String(args5["outputs-dir"])) : path6.join(findWorkspaceRoot(cwd) ?? cwd, "canvas");
|
|
36663
36789
|
const runArg = String(args5.run);
|
|
36664
36790
|
const runDir = await resolveRunDir(runArg, outputsDir);
|
|
36665
36791
|
const manifest = await loadManifest(runDir);
|
|
@@ -36671,7 +36797,7 @@ var inspectCommand = defineCommand110({
|
|
|
36671
36797
|
}
|
|
36672
36798
|
const summary = {
|
|
36673
36799
|
ok: true,
|
|
36674
|
-
run_id: manifest.run_id ??
|
|
36800
|
+
run_id: manifest.run_id ?? path6.basename(runDir),
|
|
36675
36801
|
run_dir: runDir,
|
|
36676
36802
|
stats: manifest.stats ?? null,
|
|
36677
36803
|
output: manifest.output ?? null,
|
|
@@ -36684,18 +36810,18 @@ var inspectCommand = defineCommand110({
|
|
|
36684
36810
|
}
|
|
36685
36811
|
});
|
|
36686
36812
|
async function resolveRunDir(run, outputsDir) {
|
|
36687
|
-
if (
|
|
36813
|
+
if (path6.isAbsolute(run)) {
|
|
36688
36814
|
const s2 = await stat(run).catch(() => null);
|
|
36689
36815
|
if (s2?.isDirectory()) return run;
|
|
36690
36816
|
throw new Error(`inspect: ${run} is not a directory`);
|
|
36691
36817
|
}
|
|
36692
|
-
const candidate =
|
|
36818
|
+
const candidate = path6.join(outputsDir, run);
|
|
36693
36819
|
const s = await stat(candidate).catch(() => null);
|
|
36694
36820
|
if (s?.isDirectory()) return candidate;
|
|
36695
36821
|
throw new Error(`inspect: no run directory at ${candidate}`);
|
|
36696
36822
|
}
|
|
36697
36823
|
async function loadManifest(runDir) {
|
|
36698
|
-
const manifestPath =
|
|
36824
|
+
const manifestPath = path6.join(runDir, "manifest.json");
|
|
36699
36825
|
try {
|
|
36700
36826
|
const raw = await readFile4(manifestPath, "utf-8");
|
|
36701
36827
|
return JSON.parse(raw);
|
|
@@ -36707,7 +36833,7 @@ async function listRunFiles(runDir) {
|
|
|
36707
36833
|
const out = [];
|
|
36708
36834
|
const names = await readdir2(runDir);
|
|
36709
36835
|
for (const name of names) {
|
|
36710
|
-
const abs =
|
|
36836
|
+
const abs = path6.join(runDir, name);
|
|
36711
36837
|
const s = await stat(abs).catch(() => null);
|
|
36712
36838
|
if (!s?.isFile()) continue;
|
|
36713
36839
|
out.push({ name, path: abs, size: s.size });
|
|
@@ -36760,95 +36886,6 @@ import { readFile as readFile12 } from "fs/promises";
|
|
|
36760
36886
|
import path16 from "path";
|
|
36761
36887
|
import { defineCommand as defineCommand111 } from "citty";
|
|
36762
36888
|
|
|
36763
|
-
// src/commands/canvas/normalize-paths.ts
|
|
36764
|
-
import { existsSync as existsSync4, realpathSync } from "fs";
|
|
36765
|
-
import { writeFile as writeFile2 } from "fs/promises";
|
|
36766
|
-
import path5 from "path";
|
|
36767
|
-
function findWorkspaceRoot(startDir, exists2 = existsSync4, maxDepth = 12) {
|
|
36768
|
-
let dir = path5.resolve(startDir);
|
|
36769
|
-
for (let i = 0; i < maxDepth; i++) {
|
|
36770
|
-
if (exists2(path5.join(dir, "package.json"))) return dir;
|
|
36771
|
-
const parent = path5.dirname(dir);
|
|
36772
|
-
if (parent === dir) break;
|
|
36773
|
-
dir = parent;
|
|
36774
|
-
}
|
|
36775
|
-
return null;
|
|
36776
|
-
}
|
|
36777
|
-
function canonicalize(target2) {
|
|
36778
|
-
const abs = path5.resolve(target2);
|
|
36779
|
-
let dir = abs;
|
|
36780
|
-
for (; ; ) {
|
|
36781
|
-
try {
|
|
36782
|
-
const real = realpathSync(dir);
|
|
36783
|
-
return dir === abs ? real : path5.join(real, path5.relative(dir, abs));
|
|
36784
|
-
} catch {
|
|
36785
|
-
const parent = path5.dirname(dir);
|
|
36786
|
-
if (parent === dir) return abs;
|
|
36787
|
-
dir = parent;
|
|
36788
|
-
}
|
|
36789
|
-
}
|
|
36790
|
-
}
|
|
36791
|
-
function isInside(root, target2) {
|
|
36792
|
-
const rel = path5.relative(root, target2);
|
|
36793
|
-
return rel !== "" && !rel.startsWith("..") && !path5.isAbsolute(rel);
|
|
36794
|
-
}
|
|
36795
|
-
function toCanvasRelative(canvasDir, target2) {
|
|
36796
|
-
return path5.relative(canvasDir, target2).split(path5.sep).join("/");
|
|
36797
|
-
}
|
|
36798
|
-
var RUNTIME_WORKSPACE_ROOT = "/home/user/repo";
|
|
36799
|
-
function rewriteTarget(value, workspaceRoot) {
|
|
36800
|
-
if (typeof value !== "string" || value.length === 0) return null;
|
|
36801
|
-
if (value.includes("[TODO") || looksLikeHttpUrl(value) || !path5.isAbsolute(value)) return null;
|
|
36802
|
-
const target2 = canonicalize(value);
|
|
36803
|
-
if (isInside(workspaceRoot, target2)) return target2;
|
|
36804
|
-
const fromRuntime = path5.relative(RUNTIME_WORKSPACE_ROOT, path5.normalize(value));
|
|
36805
|
-
if (fromRuntime !== "" && !fromRuntime.startsWith("..") && !path5.isAbsolute(fromRuntime)) {
|
|
36806
|
-
return path5.join(workspaceRoot, fromRuntime);
|
|
36807
|
-
}
|
|
36808
|
-
return null;
|
|
36809
|
-
}
|
|
36810
|
-
function normalizeCanvasPaths(canvas, canvasDir, workspaceRoot) {
|
|
36811
|
-
if (!canvas || typeof canvas !== "object") return { canvas, rewrites: [] };
|
|
36812
|
-
const c = canvas;
|
|
36813
|
-
if (!Array.isArray(c.nodes)) return { canvas, rewrites: [] };
|
|
36814
|
-
const root = canonicalize(workspaceRoot);
|
|
36815
|
-
const dir = canonicalize(canvasDir);
|
|
36816
|
-
const rewrites = [];
|
|
36817
|
-
const nodes = c.nodes.map((node) => {
|
|
36818
|
-
if (!node || typeof node !== "object") return node;
|
|
36819
|
-
const n = node;
|
|
36820
|
-
const params = n.params;
|
|
36821
|
-
if (!params || typeof params !== "object") return node;
|
|
36822
|
-
const nodeId = typeof n.id === "string" ? n.id : "?";
|
|
36823
|
-
if (n.type === "ingest" && params.source === "path" && looksLikeHttpUrl(params.path)) {
|
|
36824
|
-
rewrites.push({ nodeId, param: "source", from: "path", to: "url" });
|
|
36825
|
-
return { ...node, params: coercePathUrlToUrl(params) };
|
|
36826
|
-
}
|
|
36827
|
-
const key = n.type === "ingest" && params.source === "path" ? "path" : n.type === "hyperframe_render" ? "composition" : null;
|
|
36828
|
-
if (!key) return node;
|
|
36829
|
-
const target2 = rewriteTarget(params[key], root);
|
|
36830
|
-
if (target2 === null) return node;
|
|
36831
|
-
const to = toCanvasRelative(dir, target2);
|
|
36832
|
-
rewrites.push({ nodeId, param: key, from: params[key], to });
|
|
36833
|
-
return { ...node, params: { ...params, [key]: to } };
|
|
36834
|
-
});
|
|
36835
|
-
return rewrites.length === 0 ? { canvas, rewrites } : { canvas: { ...canvas, nodes }, rewrites };
|
|
36836
|
-
}
|
|
36837
|
-
async function healCanvasPaths(filePath, canvas) {
|
|
36838
|
-
const canvasDir = path5.dirname(filePath);
|
|
36839
|
-
const workspaceRoot = findWorkspaceRoot(canvasDir);
|
|
36840
|
-
if (!workspaceRoot) return { canvas, rewrites: [], text: null };
|
|
36841
|
-
const normalized = normalizeCanvasPaths(canvas, canvasDir, workspaceRoot);
|
|
36842
|
-
if (normalized.rewrites.length === 0) return { ...normalized, text: null };
|
|
36843
|
-
const text2 = `${JSON.stringify(normalized.canvas, null, 2)}
|
|
36844
|
-
`;
|
|
36845
|
-
await writeFile2(filePath, text2, "utf8");
|
|
36846
|
-
return { ...normalized, text: text2 };
|
|
36847
|
-
}
|
|
36848
|
-
function describeRewrites(rewrites) {
|
|
36849
|
-
return rewrites.map((r) => ` ${r.nodeId}.${r.param}: ${r.from} \u2192 ${r.to}`).join("\n");
|
|
36850
|
-
}
|
|
36851
|
-
|
|
36852
36889
|
// src/commands/canvas/placeholders.ts
|
|
36853
36890
|
function unsuppliedPlaceholderAssets(canvas) {
|
|
36854
36891
|
const nodes = canvas?.nodes;
|
|
@@ -36865,31 +36902,6 @@ function unsuppliedPlaceholderAssets(canvas) {
|
|
|
36865
36902
|
return out;
|
|
36866
36903
|
}
|
|
36867
36904
|
|
|
36868
|
-
// src/commands/canvas/resolve-paths.ts
|
|
36869
|
-
import path6 from "path";
|
|
36870
|
-
function resolveRelativeCanvasPaths(canvas, baseDir) {
|
|
36871
|
-
if (!canvas || typeof canvas !== "object") return canvas;
|
|
36872
|
-
const c = canvas;
|
|
36873
|
-
if (!Array.isArray(c.nodes)) return canvas;
|
|
36874
|
-
return { ...canvas, nodes: c.nodes.map((n) => resolveNode(n, baseDir)) };
|
|
36875
|
-
}
|
|
36876
|
-
function resolveNode(node, baseDir) {
|
|
36877
|
-
if (!node || typeof node !== "object") return node;
|
|
36878
|
-
const n = node;
|
|
36879
|
-
const params = n.params;
|
|
36880
|
-
if (!params || typeof params !== "object") return node;
|
|
36881
|
-
if (n.type === "ingest" && params.source === "path" && isResolvableRelative(params.path)) {
|
|
36882
|
-
return { ...node, params: { ...params, path: path6.resolve(baseDir, params.path) } };
|
|
36883
|
-
}
|
|
36884
|
-
if (n.type === "hyperframe_render" && isResolvableRelative(params.composition)) {
|
|
36885
|
-
return { ...node, params: { ...params, composition: path6.resolve(baseDir, params.composition) } };
|
|
36886
|
-
}
|
|
36887
|
-
return node;
|
|
36888
|
-
}
|
|
36889
|
-
function isResolvableRelative(value) {
|
|
36890
|
-
return typeof value === "string" && value.length > 0 && !value.includes("[TODO") && !looksLikeHttpUrl(value) && !path6.isAbsolute(value);
|
|
36891
|
-
}
|
|
36892
|
-
|
|
36893
36905
|
// src/commands/canvas/source-version.ts
|
|
36894
36906
|
import { readFile as readFile6 } from "fs/promises";
|
|
36895
36907
|
import path8 from "path";
|
|
@@ -40999,12 +41011,9 @@ function localPathRefsFromCanvas(parsed) {
|
|
|
40999
41011
|
const n = node;
|
|
41000
41012
|
const params = n.params;
|
|
41001
41013
|
if (!params || typeof params !== "object") continue;
|
|
41002
|
-
|
|
41003
|
-
|
|
41004
|
-
|
|
41005
|
-
if (n.type === "hyperframe_render" && isSnapshotablePath(params.composition)) {
|
|
41006
|
-
refs.add(params.composition);
|
|
41007
|
-
}
|
|
41014
|
+
const key = localPathParam(n);
|
|
41015
|
+
const value = key ? params[key] : void 0;
|
|
41016
|
+
if (isSnapshotablePath(value)) refs.add(value);
|
|
41008
41017
|
}
|
|
41009
41018
|
return [...refs];
|
|
41010
41019
|
}
|
|
@@ -41689,8 +41698,8 @@ var runCommand = defineCommand111({
|
|
|
41689
41698
|
type: "string",
|
|
41690
41699
|
description: "What the person asked for, IN THEIR OWN WORDS \u2014 paste their message, do not summarise it. The review compares the finished video against this and reports what they asked for that is missing or contradicted. Without it the review can only say whether the video is well made, not whether it is the one they wanted: every other check grades the render against the spec, and a spec that misread the request agrees with itself."
|
|
41691
41700
|
},
|
|
41692
|
-
"cache-dir": { type: "string", description: "Cache root (default
|
|
41693
|
-
"outputs-dir": { type: "string", description: "Per-run outputs root (default
|
|
41701
|
+
"cache-dir": { type: "string", description: "Cache root (default <workspace root>/canvas/.cache, whatever directory you run from)" },
|
|
41702
|
+
"outputs-dir": { type: "string", description: "Per-run outputs root (default <workspace root>/canvas, whatever directory you run from)" },
|
|
41694
41703
|
"run-id": { type: "string", description: "Override run id (also resumes that run, re-attaching its in-flight jobs)" },
|
|
41695
41704
|
fresh: {
|
|
41696
41705
|
type: "boolean",
|
|
@@ -41768,6 +41777,7 @@ function stopBeforeKinds(until) {
|
|
|
41768
41777
|
}
|
|
41769
41778
|
async function executeCanvasRun(opts) {
|
|
41770
41779
|
const filePath = path16.resolve(opts.file);
|
|
41780
|
+
const canvasRoot = canvasOutputsRoot(filePath);
|
|
41771
41781
|
const raw = await readFile12(filePath, "utf8");
|
|
41772
41782
|
let parsed;
|
|
41773
41783
|
try {
|
|
@@ -41779,7 +41789,7 @@ async function executeCanvasRun(opts) {
|
|
|
41779
41789
|
process.exit(2);
|
|
41780
41790
|
}
|
|
41781
41791
|
const attemptedSlug = creativeSlugFromCanvasPath(filePath);
|
|
41782
|
-
if (attemptedSlug) await clearCreativeDirty(attemptedSlug);
|
|
41792
|
+
if (attemptedSlug) await clearCreativeDirty(attemptedSlug, path16.join(canvasRoot, ".dirty"));
|
|
41783
41793
|
const healed = await healCanvasPaths(filePath, parsed);
|
|
41784
41794
|
parsed = healed.canvas;
|
|
41785
41795
|
const canvasText = healed.text ?? raw;
|
|
@@ -41875,8 +41885,8 @@ ${describeRewrites(healed.rewrites)}
|
|
|
41875
41885
|
}
|
|
41876
41886
|
}
|
|
41877
41887
|
const engine = createEngineFromEnv({
|
|
41878
|
-
cacheDir: opts.cacheDir,
|
|
41879
|
-
outputsDir: opts.outputsDir,
|
|
41888
|
+
cacheDir: opts.cacheDir ?? path16.join(canvasRoot, ".cache"),
|
|
41889
|
+
outputsDir: opts.outputsDir ?? canvasRoot,
|
|
41880
41890
|
log: (line) => process.stdout.write(`${line}
|
|
41881
41891
|
`),
|
|
41882
41892
|
remoteCache: opts.remoteCache
|
|
@@ -41896,7 +41906,7 @@ ${describeRewrites(healed.rewrites)}
|
|
|
41896
41906
|
const canvasSha = sha256Hex(Buffer.from(canvasText));
|
|
41897
41907
|
const creativeSlug = creativeSlugFromCanvasPath(filePath) ?? void 0;
|
|
41898
41908
|
const client = opts.record === false ? null : buildBackendClient();
|
|
41899
|
-
const outputsDir = opts.outputsDir ? path16.resolve(opts.outputsDir) :
|
|
41909
|
+
const outputsDir = opts.outputsDir ? path16.resolve(opts.outputsDir) : canvasRoot;
|
|
41900
41910
|
const { runId, resumed, source, concurrentRunId } = await resolveRunId({
|
|
41901
41911
|
explicitRunId: opts.runId,
|
|
41902
41912
|
fresh: opts.fresh === true,
|
|
@@ -41930,7 +41940,7 @@ ${describeRewrites(healed.rewrites)}
|
|
|
41930
41940
|
const canvasSnapshotUrl = client && creativeSlug ? await uploadRunSnapshot(client, { canvasPath: filePath, raw: canvasText, creativeSlug, parsed }) ?? void 0 : void 0;
|
|
41931
41941
|
const recordMeta = {
|
|
41932
41942
|
creativeSlug,
|
|
41933
|
-
canvasPath: path16.relative(
|
|
41943
|
+
canvasPath: path16.relative(path16.dirname(canvasRoot), filePath) || void 0,
|
|
41934
41944
|
canvasSha,
|
|
41935
41945
|
// The fingerprint the dashboard compares against the current source to flag
|
|
41936
41946
|
// "edited since last render". Computed from the on-disk canvas.json +
|
|
@@ -42841,12 +42851,12 @@ function fail3(code, message) {
|
|
|
42841
42851
|
process.exit(2);
|
|
42842
42852
|
}
|
|
42843
42853
|
function resolveModels(args5) {
|
|
42844
|
-
const
|
|
42854
|
+
const pick = (flag, kind, fallback) => args5[flag] ? String(args5[flag]) : resolveModel(kind, fallback);
|
|
42845
42855
|
return {
|
|
42846
|
-
describeModel:
|
|
42847
|
-
selectModel:
|
|
42848
|
-
layoutModel:
|
|
42849
|
-
genModel:
|
|
42856
|
+
describeModel: pick("describe-model", "image_describe", "~google/gemini-pro-latest"),
|
|
42857
|
+
selectModel: pick("select-model", "text_generate", "~google/gemini-flash-latest"),
|
|
42858
|
+
layoutModel: pick("layout-model", "text_generate", "~google/gemini-flash-latest"),
|
|
42859
|
+
genModel: pick("gen-model", "image_generate", "openai/gpt-image-2")
|
|
42850
42860
|
};
|
|
42851
42861
|
}
|
|
42852
42862
|
var PLATFORM_PLACEMENTS = {
|
|
@@ -44866,18 +44876,18 @@ function parseBudget(raw) {
|
|
|
44866
44876
|
throw new Error(`--budget must be one of ${VIDEO_BUDGETS.join(", ")} (got "${v}")`);
|
|
44867
44877
|
}
|
|
44868
44878
|
function resolveModels2(args5) {
|
|
44869
|
-
const
|
|
44879
|
+
const pick = (flag, kind, fallback) => args5[flag] ? String(args5[flag]) : resolveModel2(kind, fallback);
|
|
44870
44880
|
return {
|
|
44871
44881
|
// Flash by default: ~2-3× faster per call than Pro, which keeps each
|
|
44872
44882
|
// per-scene deconstruct step well inside the action time budget and turns a
|
|
44873
44883
|
// ~9 min run into ~3-4 min. Override with --deconstruct-model
|
|
44874
44884
|
// ~google/gemini-pro-latest for the densest extraction when speed matters less.
|
|
44875
|
-
deconstructModel:
|
|
44876
|
-
selectModel:
|
|
44885
|
+
deconstructModel: pick("deconstruct-model", "video_deconstruct", "~google/gemini-flash-latest"),
|
|
44886
|
+
selectModel: pick("select-model", "text_generate", "~google/gemini-flash-latest"),
|
|
44877
44887
|
// Default to the strongest image model (matches the static-ad scaffold); the
|
|
44878
44888
|
// frame generators need the most faithful text/identity reproduction. Override
|
|
44879
44889
|
// with --image-model for a cheaper/faster pass.
|
|
44880
|
-
imageModel:
|
|
44890
|
+
imageModel: pick("image-model", "image_generate", "openai/gpt-image-2.5-sunburst")
|
|
44881
44891
|
};
|
|
44882
44892
|
}
|
|
44883
44893
|
function hasPhotorealCast(elements) {
|
|
@@ -69065,134 +69075,6 @@ function outputFlagForCommand(root, argv) {
|
|
|
69065
69075
|
});
|
|
69066
69076
|
}
|
|
69067
69077
|
|
|
69068
|
-
// src/field-mask.ts
|
|
69069
|
-
var FLAG2 = "--fields";
|
|
69070
|
-
function parseFields(value) {
|
|
69071
|
-
return value.split(",").map((field) => field.trim()).filter((field) => field.length > 0);
|
|
69072
|
-
}
|
|
69073
|
-
function takeFieldsFlag(root, argv) {
|
|
69074
|
-
const end = argv.indexOf("--");
|
|
69075
|
-
const limit = end === -1 ? argv.length : end;
|
|
69076
|
-
const taken = /* @__PURE__ */ new Set();
|
|
69077
|
-
const fields = [];
|
|
69078
|
-
for (let index = 0; index < limit; index++) {
|
|
69079
|
-
const token = argv[index] ?? "";
|
|
69080
|
-
if (token.startsWith(`${FLAG2}=`)) {
|
|
69081
|
-
taken.add(index);
|
|
69082
|
-
fields.push(...parseFields(token.slice(FLAG2.length + 1)));
|
|
69083
|
-
} else if (token === FLAG2) {
|
|
69084
|
-
const value = argv[index + 1];
|
|
69085
|
-
if (value === void 0 || index + 1 >= limit || value.startsWith("-")) {
|
|
69086
|
-
return { argv, fields: null };
|
|
69087
|
-
}
|
|
69088
|
-
taken.add(index).add(index + 1);
|
|
69089
|
-
fields.push(...parseFields(value));
|
|
69090
|
-
index++;
|
|
69091
|
-
}
|
|
69092
|
-
}
|
|
69093
|
-
if (taken.size === 0 || fields.length === 0) {
|
|
69094
|
-
return { argv, fields: null };
|
|
69095
|
-
}
|
|
69096
|
-
const command = commandFor(root, argv);
|
|
69097
|
-
if (!command || declaredArg(command, "fields") || PRINTS_NO_ENVELOPE.has(commandPathOf(root, argv))) {
|
|
69098
|
-
return { argv, fields: null };
|
|
69099
|
-
}
|
|
69100
|
-
return { argv: argv.filter((_, index) => !taken.has(index)), fields };
|
|
69101
|
-
}
|
|
69102
|
-
function isRecord3(value) {
|
|
69103
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
69104
|
-
}
|
|
69105
|
-
function pick(record, fields) {
|
|
69106
|
-
return Object.fromEntries(fields.filter((field) => field in record).map((field) => [field, record[field]]));
|
|
69107
|
-
}
|
|
69108
|
-
function wrappedList(data, fields) {
|
|
69109
|
-
if (fields.some((field) => field in data)) {
|
|
69110
|
-
return null;
|
|
69111
|
-
}
|
|
69112
|
-
const lists = Object.entries(data).filter(
|
|
69113
|
-
([, value]) => Array.isArray(value) && value.every((item) => isRecord3(item))
|
|
69114
|
-
);
|
|
69115
|
-
return lists.length === 1 ? lists[0]?.[0] ?? null : null;
|
|
69116
|
-
}
|
|
69117
|
-
function recordsOf(data, fields) {
|
|
69118
|
-
if (Array.isArray(data)) {
|
|
69119
|
-
return data;
|
|
69120
|
-
}
|
|
69121
|
-
if (!isRecord3(data)) {
|
|
69122
|
-
return [];
|
|
69123
|
-
}
|
|
69124
|
-
const list = wrappedList(data, fields);
|
|
69125
|
-
return list === null ? [data] : data[list];
|
|
69126
|
-
}
|
|
69127
|
-
function maskData(data, fields) {
|
|
69128
|
-
const mask = (item) => isRecord3(item) ? pick(item, fields) : item;
|
|
69129
|
-
if (Array.isArray(data)) {
|
|
69130
|
-
return data.map(mask);
|
|
69131
|
-
}
|
|
69132
|
-
if (!isRecord3(data)) {
|
|
69133
|
-
return data;
|
|
69134
|
-
}
|
|
69135
|
-
const list = wrappedList(data, fields);
|
|
69136
|
-
return list === null ? pick(data, fields) : { ...data, [list]: recordsOf(data, fields).map(mask) };
|
|
69137
|
-
}
|
|
69138
|
-
function unmatchedHint(data, fields) {
|
|
69139
|
-
const records = recordsOf(data, fields).filter(isRecord3);
|
|
69140
|
-
if (records.length === 0) {
|
|
69141
|
-
return null;
|
|
69142
|
-
}
|
|
69143
|
-
const carried = new Set(records.flatMap((record) => Object.keys(record)));
|
|
69144
|
-
const unmatched = fields.filter((field) => !carried.has(field));
|
|
69145
|
-
if (unmatched.length === 0) {
|
|
69146
|
-
return null;
|
|
69147
|
-
}
|
|
69148
|
-
return `--fields matched nothing for: ${unmatched.join(", ")}. The keys data carries are: ${[...carried].join(", ")}.`;
|
|
69149
|
-
}
|
|
69150
|
-
function maskPrintedEnvelope(text2, fields) {
|
|
69151
|
-
let parsed;
|
|
69152
|
-
try {
|
|
69153
|
-
parsed = JSON.parse(text2);
|
|
69154
|
-
} catch {
|
|
69155
|
-
return null;
|
|
69156
|
-
}
|
|
69157
|
-
if (!isRecord3(parsed) || typeof parsed.ok !== "boolean") {
|
|
69158
|
-
return null;
|
|
69159
|
-
}
|
|
69160
|
-
if (parsed.ok !== true || !("data" in parsed) || "dryRun" in parsed) {
|
|
69161
|
-
return text2;
|
|
69162
|
-
}
|
|
69163
|
-
const masked = { ...parsed, data: maskData(parsed.data, fields) };
|
|
69164
|
-
const miss = unmatchedHint(parsed.data, fields);
|
|
69165
|
-
if (miss) {
|
|
69166
|
-
masked.hints = [...Array.isArray(parsed.hints) ? parsed.hints : [], miss];
|
|
69167
|
-
}
|
|
69168
|
-
const indent = text2.trimStart().startsWith("{\n") ? 2 : void 0;
|
|
69169
|
-
return `${JSON.stringify(masked, null, indent)}${text2.endsWith("\n") ? "\n" : ""}`;
|
|
69170
|
-
}
|
|
69171
|
-
function maskWrites(stream, fields) {
|
|
69172
|
-
let applied = false;
|
|
69173
|
-
const write = stream.write.bind(stream);
|
|
69174
|
-
stream.write = (chunk, ...rest) => {
|
|
69175
|
-
const masked = typeof chunk === "string" ? maskPrintedEnvelope(chunk, fields) : null;
|
|
69176
|
-
if (masked === null) {
|
|
69177
|
-
return write(chunk, ...rest);
|
|
69178
|
-
}
|
|
69179
|
-
applied = true;
|
|
69180
|
-
return write(masked, ...rest);
|
|
69181
|
-
};
|
|
69182
|
-
return { sawEnvelope: () => applied };
|
|
69183
|
-
}
|
|
69184
|
-
function installFieldMask(fields, commandPath) {
|
|
69185
|
-
const mask = maskWrites(process.stdout, fields);
|
|
69186
|
-
process.on("exit", () => {
|
|
69187
|
-
if (!mask.sawEnvelope()) {
|
|
69188
|
-
process.stderr.write(
|
|
69189
|
-
`--fields was not applied: \`baker ${commandPath}\` printed no JSON envelope to narrow. Add --output json to get the envelope, or drop --fields.
|
|
69190
|
-
`
|
|
69191
|
-
);
|
|
69192
|
-
}
|
|
69193
|
-
});
|
|
69194
|
-
}
|
|
69195
|
-
|
|
69196
69078
|
// src/version.ts
|
|
69197
69079
|
import { readFileSync as readFileSync21 } from "fs";
|
|
69198
69080
|
function packageJsonUrl() {
|
|
@@ -69219,7 +69101,6 @@ var main = defineCommand248({
|
|
|
69219
69101
|
Auth: Set BAKER_API_KEY (starts with bk_) and BAKER_API_URL environment variables.
|
|
69220
69102
|
Chat: Set BAKER_CHAT_ID for action and scheduled-agent commands that stage changes against a chat.
|
|
69221
69103
|
Output: All commands return JSON envelopes: { ok: true, data: ... } or { ok: false, error: { code, message } }.
|
|
69222
|
-
Fields: --fields a,b,c keeps only those keys of each record in data, on every command that prints the envelope.
|
|
69223
69104
|
Formats: --output json works on every command that prints the envelope. --output md|files only where 'baker schema <command>' lists output. (The research commands additionally accept csv and jsonl.)
|
|
69224
69105
|
Introspection: Run 'baker schema <command>' to inspect argument schemas.`
|
|
69225
69106
|
},
|
|
@@ -69259,11 +69140,6 @@ installStreamTaps();
|
|
|
69259
69140
|
logInvocation(process.argv.slice(2));
|
|
69260
69141
|
installExitRecord();
|
|
69261
69142
|
process.argv = [...process.argv.slice(0, 2), ...outputFlagForCommand(main, process.argv.slice(2))];
|
|
69262
|
-
var fieldsFlag = takeFieldsFlag(main, process.argv.slice(2));
|
|
69263
|
-
if (fieldsFlag.fields) {
|
|
69264
|
-
process.argv = [...process.argv.slice(0, 2), ...fieldsFlag.argv];
|
|
69265
|
-
installFieldMask(fieldsFlag.fields, commandPathOf(main, fieldsFlag.argv));
|
|
69266
|
-
}
|
|
69267
69143
|
refuseUnknownFlags(main, process.argv.slice(2));
|
|
69268
69144
|
process.argv = [...process.argv.slice(0, 2), ...cacheFlagForParser(process.argv.slice(2))];
|
|
69269
69145
|
runMain(main);
|