@koda-sl/baker-cli 0.359.0-dev.5dbf6338c → 0.359.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/dist/cli.js CHANGED
@@ -69,7 +69,7 @@ import {
69
69
  validateCanvasDeep,
70
70
  withoutCastName,
71
71
  ytDlpBlockSignal
72
- } from "./chunk-K2IKLMCM.js";
72
+ } from "./chunk-AI4HWQVN.js";
73
73
  import {
74
74
  csvOrJson,
75
75
  daysAgoIso,
@@ -8052,7 +8052,6 @@ var testimonialDocSchema = z28.object({
8052
8052
  sourceType: testimonialSourceTypeSchema,
8053
8053
  reviewText: z28.string(),
8054
8054
  reviewTitle: z28.string().optional(),
8055
- searchText: z28.string().optional(),
8056
8055
  reviewerName: z28.string().optional(),
8057
8056
  reviewerImageUrl: z28.string().optional(),
8058
8057
  reviewerImageId: z28.string().optional(),
@@ -8064,13 +8063,11 @@ var testimonialDocSchema = z28.object({
8064
8063
  imageIds: z28.array(z28.string()).optional(),
8065
8064
  videoIds: z28.array(z28.string()).optional(),
8066
8065
  sourceUrl: z28.string().optional(),
8067
- rawData: z28.unknown().optional(),
8068
8066
  tags: z28.array(z28.string()),
8069
8067
  highlight: z28.string().optional(),
8070
8068
  language: z28.string().optional(),
8071
8069
  summary: z28.string().optional(),
8072
8070
  sentiment: testimonialSentimentSchema.optional(),
8073
- textEmbedding: z28.array(z28.number()).optional(),
8074
8071
  externalId: z28.string().optional(),
8075
8072
  contentHash: z28.string().optional(),
8076
8073
  status: testimonialStatusSchema,
@@ -36644,134 +36641,9 @@ var critiqueCommand = defineCommand109({
36644
36641
  // src/commands/canvas/inspect.ts
36645
36642
  import { execFile } from "child_process";
36646
36643
  import { readdir as readdir2, readFile as readFile4, stat } from "fs/promises";
36647
- import path6 from "path";
36644
+ import path4 from "path";
36648
36645
  import { promisify } from "util";
36649
36646
  import { defineCommand as defineCommand110 } from "citty";
36650
-
36651
- // src/commands/canvas/normalize-paths.ts
36652
- import { existsSync as existsSync4, realpathSync } from "fs";
36653
- import { writeFile as writeFile2 } from "fs/promises";
36654
- import path5 from "path";
36655
-
36656
- // src/commands/canvas/resolve-paths.ts
36657
- import path4 from "path";
36658
- function resolveRelativeCanvasPaths(canvas, baseDir) {
36659
- if (!canvas || typeof canvas !== "object") return canvas;
36660
- const c = canvas;
36661
- if (!Array.isArray(c.nodes)) return canvas;
36662
- return { ...canvas, nodes: c.nodes.map((n) => resolveNode(n, baseDir)) };
36663
- }
36664
- function localPathParam(node) {
36665
- if (node.type === "ingest") return node.params?.source === "path" ? "path" : null;
36666
- if (node.type === "hyperframe_render" || node.type === "hyperframe_snapshot") return "composition";
36667
- return null;
36668
- }
36669
- function resolveNode(node, baseDir) {
36670
- if (!node || typeof node !== "object") return node;
36671
- const n = node;
36672
- const params = n.params;
36673
- if (!params || typeof params !== "object") return node;
36674
- const key = localPathParam(n);
36675
- if (key && isResolvableRelative(params[key])) {
36676
- return { ...node, params: { ...params, [key]: path4.resolve(baseDir, params[key]) } };
36677
- }
36678
- return node;
36679
- }
36680
- function isResolvableRelative(value) {
36681
- return typeof value === "string" && value.length > 0 && !value.includes("[TODO") && !looksLikeHttpUrl(value) && !path4.isAbsolute(value);
36682
- }
36683
-
36684
- // src/commands/canvas/normalize-paths.ts
36685
- function findWorkspaceRoot(startDir, exists2 = existsSync4, maxDepth = 12) {
36686
- let dir = path5.resolve(startDir);
36687
- for (let i = 0; i < maxDepth; i++) {
36688
- if (exists2(path5.join(dir, "package.json"))) return dir;
36689
- const parent = path5.dirname(dir);
36690
- if (parent === dir) break;
36691
- dir = parent;
36692
- }
36693
- return null;
36694
- }
36695
- function canvasOutputsRoot(canvasFile, cwd = process.cwd(), exists2 = existsSync4) {
36696
- const root = findWorkspaceRoot(path5.dirname(path5.resolve(cwd, canvasFile)), exists2) ?? cwd;
36697
- return path5.join(root, "canvas");
36698
- }
36699
- function canonicalize(target2) {
36700
- const abs = path5.resolve(target2);
36701
- let dir = abs;
36702
- for (; ; ) {
36703
- try {
36704
- const real = realpathSync(dir);
36705
- return dir === abs ? real : path5.join(real, path5.relative(dir, abs));
36706
- } catch {
36707
- const parent = path5.dirname(dir);
36708
- if (parent === dir) return abs;
36709
- dir = parent;
36710
- }
36711
- }
36712
- }
36713
- function isInside(root, target2) {
36714
- const rel = path5.relative(root, target2);
36715
- return rel !== "" && !rel.startsWith("..") && !path5.isAbsolute(rel);
36716
- }
36717
- function toCanvasRelative(canvasDir, target2) {
36718
- return path5.relative(canvasDir, target2).split(path5.sep).join("/");
36719
- }
36720
- var RUNTIME_WORKSPACE_ROOT = "/home/user/repo";
36721
- function rewriteTarget(value, workspaceRoot) {
36722
- if (typeof value !== "string" || value.length === 0) return null;
36723
- if (value.includes("[TODO") || looksLikeHttpUrl(value) || !path5.isAbsolute(value)) return null;
36724
- const target2 = canonicalize(value);
36725
- if (isInside(workspaceRoot, target2)) return target2;
36726
- const fromRuntime = path5.relative(RUNTIME_WORKSPACE_ROOT, path5.normalize(value));
36727
- if (fromRuntime !== "" && !fromRuntime.startsWith("..") && !path5.isAbsolute(fromRuntime)) {
36728
- return path5.join(workspaceRoot, fromRuntime);
36729
- }
36730
- return null;
36731
- }
36732
- function normalizeCanvasPaths(canvas, canvasDir, workspaceRoot) {
36733
- if (!canvas || typeof canvas !== "object") return { canvas, rewrites: [] };
36734
- const c = canvas;
36735
- if (!Array.isArray(c.nodes)) return { canvas, rewrites: [] };
36736
- const root = canonicalize(workspaceRoot);
36737
- const dir = canonicalize(canvasDir);
36738
- const rewrites = [];
36739
- const nodes = c.nodes.map((node) => {
36740
- if (!node || typeof node !== "object") return node;
36741
- const n = node;
36742
- const params = n.params;
36743
- if (!params || typeof params !== "object") return node;
36744
- const nodeId = typeof n.id === "string" ? n.id : "?";
36745
- if (n.type === "ingest" && params.source === "path" && looksLikeHttpUrl(params.path)) {
36746
- rewrites.push({ nodeId, param: "source", from: "path", to: "url" });
36747
- return { ...node, params: coercePathUrlToUrl(params) };
36748
- }
36749
- const key = localPathParam(n);
36750
- if (!key) return node;
36751
- const target2 = rewriteTarget(params[key], root);
36752
- if (target2 === null) return node;
36753
- const to = toCanvasRelative(dir, target2);
36754
- rewrites.push({ nodeId, param: key, from: params[key], to });
36755
- return { ...node, params: { ...params, [key]: to } };
36756
- });
36757
- return rewrites.length === 0 ? { canvas, rewrites } : { canvas: { ...canvas, nodes }, rewrites };
36758
- }
36759
- async function healCanvasPaths(filePath, canvas) {
36760
- const canvasDir = path5.dirname(filePath);
36761
- const workspaceRoot = findWorkspaceRoot(canvasDir);
36762
- if (!workspaceRoot) return { canvas, rewrites: [], text: null };
36763
- const normalized = normalizeCanvasPaths(canvas, canvasDir, workspaceRoot);
36764
- if (normalized.rewrites.length === 0) return { ...normalized, text: null };
36765
- const text2 = `${JSON.stringify(normalized.canvas, null, 2)}
36766
- `;
36767
- await writeFile2(filePath, text2, "utf8");
36768
- return { ...normalized, text: text2 };
36769
- }
36770
- function describeRewrites(rewrites) {
36771
- return rewrites.map((r) => ` ${r.nodeId}.${r.param}: ${r.from} \u2192 ${r.to}`).join("\n");
36772
- }
36773
-
36774
- // src/commands/canvas/inspect.ts
36775
36647
  var execFileAsync = promisify(execFile);
36776
36648
  var inspectCommand = defineCommand110({
36777
36649
  meta: {
@@ -36780,15 +36652,14 @@ var inspectCommand = defineCommand110({
36780
36652
  },
36781
36653
  args: {
36782
36654
  run: { type: "positional", required: true, description: "Run id (e.g. r_01K...) or absolute run directory" },
36783
- "outputs-dir": { type: "string", description: "Per-run outputs root (default <workspace root>/canvas, where `canvas run` writes)" },
36655
+ "outputs-dir": { type: "string", description: "Per-run outputs root (default ./canvas)" },
36784
36656
  thumbnails: {
36785
36657
  type: "boolean",
36786
36658
  description: "Extract start/middle/end frames from every video output (requires ffmpeg)"
36787
36659
  }
36788
36660
  },
36789
36661
  async run({ args: args5 }) {
36790
- const cwd = process.cwd();
36791
- const outputsDir = args5["outputs-dir"] ? path6.resolve(String(args5["outputs-dir"])) : path6.join(findWorkspaceRoot(cwd) ?? cwd, "canvas");
36662
+ const outputsDir = path4.resolve(String(args5["outputs-dir"] ?? "canvas"));
36792
36663
  const runArg = String(args5.run);
36793
36664
  const runDir = await resolveRunDir(runArg, outputsDir);
36794
36665
  const manifest = await loadManifest(runDir);
@@ -36800,7 +36671,7 @@ var inspectCommand = defineCommand110({
36800
36671
  }
36801
36672
  const summary = {
36802
36673
  ok: true,
36803
- run_id: manifest.run_id ?? path6.basename(runDir),
36674
+ run_id: manifest.run_id ?? path4.basename(runDir),
36804
36675
  run_dir: runDir,
36805
36676
  stats: manifest.stats ?? null,
36806
36677
  output: manifest.output ?? null,
@@ -36813,18 +36684,18 @@ var inspectCommand = defineCommand110({
36813
36684
  }
36814
36685
  });
36815
36686
  async function resolveRunDir(run, outputsDir) {
36816
- if (path6.isAbsolute(run)) {
36687
+ if (path4.isAbsolute(run)) {
36817
36688
  const s2 = await stat(run).catch(() => null);
36818
36689
  if (s2?.isDirectory()) return run;
36819
36690
  throw new Error(`inspect: ${run} is not a directory`);
36820
36691
  }
36821
- const candidate = path6.join(outputsDir, run);
36692
+ const candidate = path4.join(outputsDir, run);
36822
36693
  const s = await stat(candidate).catch(() => null);
36823
36694
  if (s?.isDirectory()) return candidate;
36824
36695
  throw new Error(`inspect: no run directory at ${candidate}`);
36825
36696
  }
36826
36697
  async function loadManifest(runDir) {
36827
- const manifestPath = path6.join(runDir, "manifest.json");
36698
+ const manifestPath = path4.join(runDir, "manifest.json");
36828
36699
  try {
36829
36700
  const raw = await readFile4(manifestPath, "utf-8");
36830
36701
  return JSON.parse(raw);
@@ -36836,7 +36707,7 @@ async function listRunFiles(runDir) {
36836
36707
  const out = [];
36837
36708
  const names = await readdir2(runDir);
36838
36709
  for (const name of names) {
36839
- const abs = path6.join(runDir, name);
36710
+ const abs = path4.join(runDir, name);
36840
36711
  const s = await stat(abs).catch(() => null);
36841
36712
  if (!s?.isFile()) continue;
36842
36713
  out.push({ name, path: abs, size: s.size });
@@ -36889,6 +36760,95 @@ import { readFile as readFile12 } from "fs/promises";
36889
36760
  import path16 from "path";
36890
36761
  import { defineCommand as defineCommand111 } from "citty";
36891
36762
 
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
+
36892
36852
  // src/commands/canvas/placeholders.ts
36893
36853
  function unsuppliedPlaceholderAssets(canvas) {
36894
36854
  const nodes = canvas?.nodes;
@@ -36905,6 +36865,31 @@ function unsuppliedPlaceholderAssets(canvas) {
36905
36865
  return out;
36906
36866
  }
36907
36867
 
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
+
36908
36893
  // src/commands/canvas/source-version.ts
36909
36894
  import { readFile as readFile6 } from "fs/promises";
36910
36895
  import path8 from "path";
@@ -41014,9 +40999,12 @@ function localPathRefsFromCanvas(parsed) {
41014
40999
  const n = node;
41015
41000
  const params = n.params;
41016
41001
  if (!params || typeof params !== "object") continue;
41017
- const key = localPathParam(n);
41018
- const value = key ? params[key] : void 0;
41019
- if (isSnapshotablePath(value)) refs.add(value);
41002
+ if (n.type === "ingest" && params.source === "path" && isSnapshotablePath(params.path)) {
41003
+ refs.add(params.path);
41004
+ }
41005
+ if (n.type === "hyperframe_render" && isSnapshotablePath(params.composition)) {
41006
+ refs.add(params.composition);
41007
+ }
41020
41008
  }
41021
41009
  return [...refs];
41022
41010
  }
@@ -41701,8 +41689,8 @@ var runCommand = defineCommand111({
41701
41689
  type: "string",
41702
41690
  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."
41703
41691
  },
41704
- "cache-dir": { type: "string", description: "Cache root (default <workspace root>/canvas/.cache, whatever directory you run from)" },
41705
- "outputs-dir": { type: "string", description: "Per-run outputs root (default <workspace root>/canvas, whatever directory you run from)" },
41692
+ "cache-dir": { type: "string", description: "Cache root (default ./canvas/.cache)" },
41693
+ "outputs-dir": { type: "string", description: "Per-run outputs root (default ./canvas)" },
41706
41694
  "run-id": { type: "string", description: "Override run id (also resumes that run, re-attaching its in-flight jobs)" },
41707
41695
  fresh: {
41708
41696
  type: "boolean",
@@ -41780,7 +41768,6 @@ function stopBeforeKinds(until) {
41780
41768
  }
41781
41769
  async function executeCanvasRun(opts) {
41782
41770
  const filePath = path16.resolve(opts.file);
41783
- const canvasRoot = canvasOutputsRoot(filePath);
41784
41771
  const raw = await readFile12(filePath, "utf8");
41785
41772
  let parsed;
41786
41773
  try {
@@ -41792,7 +41779,7 @@ async function executeCanvasRun(opts) {
41792
41779
  process.exit(2);
41793
41780
  }
41794
41781
  const attemptedSlug = creativeSlugFromCanvasPath(filePath);
41795
- if (attemptedSlug) await clearCreativeDirty(attemptedSlug, path16.join(canvasRoot, ".dirty"));
41782
+ if (attemptedSlug) await clearCreativeDirty(attemptedSlug);
41796
41783
  const healed = await healCanvasPaths(filePath, parsed);
41797
41784
  parsed = healed.canvas;
41798
41785
  const canvasText = healed.text ?? raw;
@@ -41888,8 +41875,8 @@ ${describeRewrites(healed.rewrites)}
41888
41875
  }
41889
41876
  }
41890
41877
  const engine = createEngineFromEnv({
41891
- cacheDir: opts.cacheDir ?? path16.join(canvasRoot, ".cache"),
41892
- outputsDir: opts.outputsDir ?? canvasRoot,
41878
+ cacheDir: opts.cacheDir,
41879
+ outputsDir: opts.outputsDir,
41893
41880
  log: (line) => process.stdout.write(`${line}
41894
41881
  `),
41895
41882
  remoteCache: opts.remoteCache
@@ -41909,7 +41896,7 @@ ${describeRewrites(healed.rewrites)}
41909
41896
  const canvasSha = sha256Hex(Buffer.from(canvasText));
41910
41897
  const creativeSlug = creativeSlugFromCanvasPath(filePath) ?? void 0;
41911
41898
  const client = opts.record === false ? null : buildBackendClient();
41912
- const outputsDir = opts.outputsDir ? path16.resolve(opts.outputsDir) : canvasRoot;
41899
+ const outputsDir = opts.outputsDir ? path16.resolve(opts.outputsDir) : path16.resolve("canvas");
41913
41900
  const { runId, resumed, source, concurrentRunId } = await resolveRunId({
41914
41901
  explicitRunId: opts.runId,
41915
41902
  fresh: opts.fresh === true,
@@ -41943,7 +41930,7 @@ ${describeRewrites(healed.rewrites)}
41943
41930
  const canvasSnapshotUrl = client && creativeSlug ? await uploadRunSnapshot(client, { canvasPath: filePath, raw: canvasText, creativeSlug, parsed }) ?? void 0 : void 0;
41944
41931
  const recordMeta = {
41945
41932
  creativeSlug,
41946
- canvasPath: path16.relative(path16.dirname(canvasRoot), filePath) || void 0,
41933
+ canvasPath: path16.relative(process.cwd(), filePath) || void 0,
41947
41934
  canvasSha,
41948
41935
  // The fingerprint the dashboard compares against the current source to flag
41949
41936
  // "edited since last render". Computed from the on-disk canvas.json +