pixelkiln 0.93.0 → 0.94.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
@@ -67,7 +67,7 @@ function exitCodeFor(err) {
67
67
  }
68
68
 
69
69
  // src/cli/main.ts
70
- import { existsSync as existsSync41 } from "fs";
70
+ import { existsSync as existsSync42 } from "fs";
71
71
  import { readFile as readFile37 } from "fs/promises";
72
72
 
73
73
  // src/cli/args.ts
@@ -138,7 +138,8 @@ var BOOL_FLAGS = [
138
138
  "--refresh",
139
139
  "--no-editor",
140
140
  "--game-pack",
141
- "--local"
141
+ "--local",
142
+ "--strict"
142
143
  ];
143
144
  var COMMANDS = [
144
145
  "init",
@@ -420,6 +421,7 @@ function parseArgs(argv) {
420
421
  noEditor: rest.includes("--no-editor"),
421
422
  refresh: rest.includes("--refresh"),
422
423
  local: rest.includes("--local"),
424
+ strict: rest.includes("--strict"),
423
425
  source: get("--source"),
424
426
  objectId: get("--object-id"),
425
427
  from: get("--from"),
@@ -620,6 +622,7 @@ Options
620
622
  and switches gallery to every registered project.
621
623
  --from <path> Source for init/path-mode refine, or baseline for quality check
622
624
  --write-prompts adopt: recover prompts into the manifest
625
+ --strict plan/hash/doctor: fail on any invalid manifest entry instead of listing it and continuing
623
626
 
624
627
  Examples
625
628
  pixelkiln plan
@@ -734,10 +737,10 @@ import { createReadStream } from "fs";
734
737
  function sha256(data) {
735
738
  return createHash("sha256").update(data).digest("hex");
736
739
  }
737
- async function sha256File(path53) {
740
+ async function sha256File(path54) {
738
741
  return new Promise((resolve, reject) => {
739
742
  const hash = createHash("sha256");
740
- const stream = createReadStream(path53);
743
+ const stream = createReadStream(path54);
741
744
  stream.on("data", (chunk2) => hash.update(chunk2));
742
745
  stream.on("error", reject);
743
746
  stream.on("end", () => resolve(hash.digest("hex")));
@@ -5299,7 +5302,12 @@ function announceGalleryReady(url, count, stdout = process.stdout, stderr = proc
5299
5302
  ` : " (read-only; add --edit to change prompts or edit sprites, --budget <n> to generate; Ctrl+C to stop)\n\n")
5300
5303
  );
5301
5304
  }
5302
- function printPlan(plan) {
5305
+ function selectInvalid(invalid, selection) {
5306
+ if (!selection.assets.length && !selection.styles.length) return { shown: invalid, hidden: 0 };
5307
+ const shown = invalid.filter((entry) => entry.kind === "asset" ? selection.assets.includes(entry.id) : selection.styles.includes(entry.id));
5308
+ return { shown, hidden: invalid.length - shown.length };
5309
+ }
5310
+ function printPlan(plan, invalid = [], hiddenInvalid = 0) {
5303
5311
  const counts = summarize(plan);
5304
5312
  const order = [
5305
5313
  "blocked",
@@ -5322,9 +5330,21 @@ function printPlan(plan) {
5322
5330
  }
5323
5331
  if (items.length > 40) log(` \u2026 and ${items.length - 40} more`);
5324
5332
  }
5333
+ if (invalid.length) {
5334
+ log(`
5335
+ invalid (${invalid.length}) not planned; fix the entry or pass --strict to stop here`);
5336
+ for (const entry of invalid.slice(0, 40)) {
5337
+ const clip = (text) => text.length > 160 ? `${text.slice(0, 157)}\u2026` : text;
5338
+ log(` ${`${entry.kind === "style" ? "styles" : "assets"}.${entry.id}`.padEnd(42)} ${clip(entry.issues[0] ?? "")}`);
5339
+ for (const extra of entry.issues.slice(1, 3)) log(` ${"".padEnd(42)} ${clip(extra)}`);
5340
+ }
5341
+ if (invalid.length > 40) log(` \u2026 and ${invalid.length - 40} more`);
5342
+ }
5343
+ if (hiddenInvalid) log(`
5344
+ ${hiddenInvalid} other invalid entr${hiddenInvalid === 1 ? "y" : "ies"} outside this selection; run without --only/--style to see them`);
5325
5345
  log(
5326
5346
  `
5327
- totals: ${counts.ok} ok \xB7 ${counts.blocked} blocked \xB7 ${counts.missing} missing \xB7 ${counts.untracked} untracked \xB7 ${counts.stale} stale \xB7 ${counts["in-flight"]} in-flight \xB7 ${counts.orphaned} orphaned \xB7 ${counts.recoverable} recoverable \xB7 ${counts.failed} failed`
5347
+ totals: ${counts.ok} ok \xB7 ${counts.blocked} blocked \xB7 ${counts.missing} missing \xB7 ${counts.untracked} untracked \xB7 ${counts.stale} stale \xB7 ${counts["in-flight"]} in-flight \xB7 ${counts.orphaned} orphaned \xB7 ${counts.recoverable} recoverable \xB7 ${counts.failed} failed` + (invalid.length ? ` \xB7 ${invalid.length} invalid` : "")
5328
5348
  );
5329
5349
  if (plan.actionable.length) {
5330
5350
  for (const group of plan.groups) {
@@ -6837,9 +6857,9 @@ var PixelLabClient = class {
6837
6857
  apiKey;
6838
6858
  http;
6839
6859
  /** Retries transport failures, 429, and 5xx; see http.ts for the policy. */
6840
- async request(path53, init) {
6860
+ async request(path54, init) {
6841
6861
  const auth = this.apiKey.startsWith("Bearer ") ? this.apiKey : `Bearer ${this.apiKey}`;
6842
- const res = await this.http(`${BASE}${path53}`, {
6862
+ const res = await this.http(`${BASE}${path54}`, {
6843
6863
  ...init,
6844
6864
  headers: {
6845
6865
  Authorization: auth,
@@ -6850,13 +6870,13 @@ var PixelLabClient = class {
6850
6870
  const text = await res.text();
6851
6871
  if (!res.ok) {
6852
6872
  const hint = res.status === 500 && text.includes("Failed to start any animation jobs") ? '; a skeleton-v3 loop needs a character with a stored 3D skeleton (a v3 base), use mode: "template" on a standard one' : "";
6853
- throw new PixelLabError(`${init?.method ?? "GET"} ${path53} \u2192 ${res.status}${hint}`, res.status, text);
6873
+ throw new PixelLabError(`${init?.method ?? "GET"} ${path54} \u2192 ${res.status}${hint}`, res.status, text);
6854
6874
  }
6855
6875
  if (!text) return {};
6856
6876
  try {
6857
6877
  return JSON.parse(text);
6858
6878
  } catch {
6859
- throw new Error(`${init?.method ?? "GET"} ${path53} returned invalid JSON`);
6879
+ throw new Error(`${init?.method ?? "GET"} ${path54} returned invalid JSON`);
6860
6880
  }
6861
6881
  }
6862
6882
  async balance() {
@@ -7309,10 +7329,10 @@ var PixelLabClient = class {
7309
7329
  const palette = args.paletteSwatchBase64 ? { color_image: { type: "base64", base64: args.paletteSwatchBase64, format: "png" }, force_colors: true } : {};
7310
7330
  const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
7311
7331
  const south = args.reference?.south;
7312
- let path53;
7332
+ let path54;
7313
7333
  let body;
7314
7334
  if (args.mode === "v3") {
7315
- path53 = "/create-character-v3";
7335
+ path54 = "/create-character-v3";
7316
7336
  body = {
7317
7337
  description: args.description,
7318
7338
  image_size: imageSize,
@@ -7326,7 +7346,7 @@ var PixelLabClient = class {
7326
7346
  ...args.enhancePrompt ? { enhance_prompt: true } : {}
7327
7347
  };
7328
7348
  } else if (args.mode === "pro-flash") {
7329
- path53 = "/create-character-pro-flash";
7349
+ path54 = "/create-character-pro-flash";
7330
7350
  const traits = args.styleTraits;
7331
7351
  body = {
7332
7352
  description: args.description,
@@ -7350,7 +7370,7 @@ var PixelLabClient = class {
7350
7370
  } : {}
7351
7371
  };
7352
7372
  } else if (args.mode === "pro") {
7353
- path53 = "/create-character-pro";
7373
+ path54 = "/create-character-pro";
7354
7374
  body = {
7355
7375
  description: args.description,
7356
7376
  image_size: imageSize,
@@ -7364,7 +7384,7 @@ var PixelLabClient = class {
7364
7384
  ...!south && args.styleCharacterId ? { style_character_id: args.styleCharacterId } : {}
7365
7385
  };
7366
7386
  } else {
7367
- path53 = args.directions === 4 ? "/create-character-with-4-directions" : "/create-character-with-8-directions";
7387
+ path54 = args.directions === 4 ? "/create-character-with-4-directions" : "/create-character-with-8-directions";
7368
7388
  body = {
7369
7389
  description: args.description,
7370
7390
  image_size: imageSize,
@@ -7382,8 +7402,8 @@ var PixelLabClient = class {
7382
7402
  };
7383
7403
  }
7384
7404
  if (args.mode === "pro" || args.mode === "pro-flash") Object.assign(body, targetPaletteBody(args.targetPalette));
7385
- const raw = await this.request(path53, { method: "POST", body: JSON.stringify(body) });
7386
- return validateResponse(CharacterSubmitSchema, raw, path53.slice(1));
7405
+ const raw = await this.request(path54, { method: "POST", body: JSON.stringify(body) });
7406
+ return validateResponse(CharacterSubmitSchema, raw, path54.slice(1));
7387
7407
  }
7388
7408
  /** A text edit of an existing character, applied to every direction and stored as a sibling. */
7389
7409
  async createCharacterState(args) {
@@ -11806,9 +11826,9 @@ var RetroDiffusionClient = class {
11806
11826
  if (!response.ok) throw new ProviderError("retrodiffusion", `Retro Diffusion download failed (${response.status})`, { status: response.status });
11807
11827
  return Buffer.from(await response.arrayBuffer());
11808
11828
  }
11809
- async call(path53, init = {}) {
11829
+ async call(path54, init = {}) {
11810
11830
  if (!this.token) throw new Error("RD_API_KEY is not set");
11811
- const response = await this.request(`${this.baseUrl}${path53}`, {
11831
+ const response = await this.request(`${this.baseUrl}${path54}`, {
11812
11832
  ...init,
11813
11833
  headers: {
11814
11834
  "Content-Type": "application/json",
@@ -12900,7 +12920,7 @@ function pixelkilnVersion() {
12900
12920
  }
12901
12921
 
12902
12922
  // src/manifest.ts
12903
- async function loadManifest(manifestPath) {
12923
+ async function loadManifest(manifestPath, opts = {}) {
12904
12924
  const abs = path16.resolve(manifestPath);
12905
12925
  if (!existsSync11(abs)) throw new ProjectError(`No manifest at ${abs}`);
12906
12926
  const expansion = expandLoopDirections(JSON.parse(await readFile8(abs, "utf8")));
@@ -12908,6 +12928,63 @@ async function loadManifest(manifestPath) {
12908
12928
  throw new ProjectError(`Manifest at ${abs} is invalid:
12909
12929
  ${expansion.issues.map((i) => ` ${i}`).join("\n")}`);
12910
12930
  }
12931
+ if (!opts.lenient) return loadExpanded(abs, expansion);
12932
+ const invalid = [];
12933
+ const raw = pruneInvalidEntries(expansion.raw, invalid);
12934
+ for (let round2 = 0; ; round2++) {
12935
+ try {
12936
+ const loaded = await loadExpanded(abs, { ...expansion, raw });
12937
+ return invalid.length ? { ...loaded, invalid } : loaded;
12938
+ } catch (error) {
12939
+ const culprits = round2 < 50 && error instanceof ProjectError ? culpritEntries(error.message) : [];
12940
+ const fresh = culprits.filter((entry) => dropEntry(raw, entry));
12941
+ if (!fresh.length) throw error;
12942
+ invalid.push(...fresh);
12943
+ }
12944
+ }
12945
+ }
12946
+ function entryRecord(raw, kind) {
12947
+ const record = raw?.[kind === "style" ? "styles" : "assets"];
12948
+ return record && typeof record === "object" && !Array.isArray(record) ? record : null;
12949
+ }
12950
+ function dropEntry(raw, entry) {
12951
+ const record = entryRecord(raw, entry.kind);
12952
+ if (!record || !(entry.id in record)) return false;
12953
+ delete record[entry.id];
12954
+ return true;
12955
+ }
12956
+ function pruneInvalidEntries(raw, invalid) {
12957
+ for (const [kind, schema] of [["style", StyleInputSchema], ["asset", AssetSchema]]) {
12958
+ const record = entryRecord(raw, kind);
12959
+ if (!record) continue;
12960
+ for (const [id, value] of Object.entries(record)) {
12961
+ const parsed = schema.safeParse(value);
12962
+ if (parsed.success) continue;
12963
+ const prefix = `${kind === "style" ? "styles" : "assets"}.${id}`;
12964
+ const lines = flattenManifestIssues(parsed.error.issues).lines.map((line) => {
12965
+ const [fieldPath, ...rest] = line.trim().split(": ");
12966
+ return `${prefix}${fieldPath === "(manifest)" || !fieldPath ? "" : `.${fieldPath}`}: ${rest.join(": ")}`;
12967
+ });
12968
+ invalid.push({ kind, id, issues: lines.length ? lines : [`${prefix}: invalid`] });
12969
+ delete record[id];
12970
+ }
12971
+ }
12972
+ return raw;
12973
+ }
12974
+ function culpritEntries(message6) {
12975
+ const found = /* @__PURE__ */ new Map();
12976
+ for (const line of message6.split("\n")) {
12977
+ const match = /^ {2}(assets|styles)\.([^.:\s]+)[.:]/.exec(line);
12978
+ if (!match) continue;
12979
+ const kind = match[1] === "styles" ? "style" : "asset";
12980
+ const key = `${kind}:${match[2]}`;
12981
+ const entry = found.get(key) ?? { kind, id: match[2], issues: [] };
12982
+ entry.issues.push(line.trim());
12983
+ found.set(key, entry);
12984
+ }
12985
+ return [...found.values()];
12986
+ }
12987
+ async function loadExpanded(abs, expansion) {
12911
12988
  const input = ManifestInputSchema.safeParse(expansion.raw);
12912
12989
  if (!input.success) {
12913
12990
  const issues = formatManifestIssues(input.error.issues);
@@ -13842,7 +13919,16 @@ async function resolveSpecs(loaded, filter) {
13842
13919
  if (!emitStyles.has(styleId)) continue;
13843
13920
  for (const assetId of Object.keys(manifest.assets)) {
13844
13921
  if (!requestedAssetIds.has(assetId) || !styleSpecs.has(assetId)) continue;
13845
- specs.push(await finalize(assetId));
13922
+ if (!filter?.onInvalid) {
13923
+ specs.push(await finalize(assetId));
13924
+ continue;
13925
+ }
13926
+ try {
13927
+ specs.push(await finalize(assetId));
13928
+ } catch (error) {
13929
+ const message6 = error instanceof Error ? error.message : String(error);
13930
+ filter.onInvalid({ kind: "asset", id: assetId, issues: [message6] });
13931
+ }
13846
13932
  }
13847
13933
  }
13848
13934
  const byOutput = /* @__PURE__ */ new Map();
@@ -14582,10 +14668,10 @@ function isSha256Hash(value) {
14582
14668
  function parseCache(value) {
14583
14669
  return HashCacheSchema.parse(value);
14584
14670
  }
14585
- async function loadCache(path53) {
14586
- if (!existsSync14(path53)) return { version: 1, hashes: {} };
14671
+ async function loadCache(path54) {
14672
+ if (!existsSync14(path54)) return { version: 1, hashes: {} };
14587
14673
  try {
14588
- const parsed = HashCacheSchema.safeParse(JSON.parse(await readFile11(path53, "utf8")));
14674
+ const parsed = HashCacheSchema.safeParse(JSON.parse(await readFile11(path54, "utf8")));
14589
14675
  if (!parsed.success) return { version: 1, hashes: {} };
14590
14676
  return {
14591
14677
  version: 1,
@@ -14597,18 +14683,18 @@ async function loadCache(path53) {
14597
14683
  return { version: 1, hashes: {} };
14598
14684
  }
14599
14685
  }
14600
- async function saveCache(path53, cache) {
14686
+ async function saveCache(path54, cache) {
14601
14687
  const sorted = {};
14602
14688
  for (const key of Object.keys(cache.hashes).sort()) {
14603
14689
  const hash = cache.hashes[key];
14604
14690
  if (!isSha256Hash(hash)) throw new Error(`Refusing to cache invalid SHA-256 for ${key}`);
14605
14691
  sorted[key] = hash;
14606
14692
  }
14607
- await mkdir7(pathModule.dirname(pathModule.resolve(path53)), { recursive: true });
14608
- const tmp = `${path53}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
14693
+ await mkdir7(pathModule.dirname(pathModule.resolve(path54)), { recursive: true });
14694
+ const tmp = `${path54}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
14609
14695
  try {
14610
14696
  await writeFile7(tmp, JSON.stringify({ version: 1, hashes: sorted }, null, 2) + "\n");
14611
- await rename5(tmp, path53);
14697
+ await rename5(tmp, path54);
14612
14698
  } finally {
14613
14699
  await rm5(tmp, { force: true });
14614
14700
  }
@@ -15901,8 +15987,14 @@ async function openProject(manifestPath = "pixelkiln.manifest.json", opts = {})
15901
15987
  if (path23.resolve(process.cwd()) !== root) loadEnvFiles(process.cwd());
15902
15988
  }
15903
15989
  const lockPath = path23.resolve(opts.lockPath ?? path23.join(root, "pixelkiln.lock.json"));
15904
- const loaded = await loadManifest(absolute);
15905
- const specs = await resolveSpecs(loaded, { styles: opts.styles ?? [], assets: opts.assets ?? [] });
15990
+ let loaded = await loadManifest(absolute, { lenient: opts.lenient });
15991
+ const unresolved = [];
15992
+ const specs = await resolveSpecs(loaded, {
15993
+ styles: opts.styles ?? [],
15994
+ assets: opts.assets ?? [],
15995
+ ...opts.lenient ? { onInvalid: (entry) => unresolved.push(entry) } : {}
15996
+ });
15997
+ if (unresolved.length) loaded = { ...loaded, invalid: [...loaded.invalid ?? [], ...unresolved] };
15906
15998
  const lock = await loadLock(lockPath);
15907
15999
  normalizeLockOutputPaths(lock, specs);
15908
16000
  const adapters = /* @__PURE__ */ new Map();
@@ -16138,7 +16230,8 @@ async function open(args) {
16138
16230
  `No manifest at ${path24.resolve(args.manifest)}. Pass --manifest, or run \`pixelkiln init --from <dir>\`.`
16139
16231
  );
16140
16232
  }
16141
- const project = await openProject(args.manifest, { lockPath: args.lock, styles: args.styles, assets: args.assets });
16233
+ const lenient = (args.command === "plan" || args.command === "hash" || args.command === "doctor") && !args.strict;
16234
+ const project = await openProject(args.manifest, { lockPath: args.lock, styles: args.styles, assets: args.assets, lenient });
16142
16235
  const { loaded, lock } = project;
16143
16236
  let specs = project.specs;
16144
16237
  const accountProvider = ACCOUNT_COMMANDS.has(args.command) && !args.local ? accountProviderId(loaded.manifest, args.provider, args.command) : void 0;
@@ -21686,9 +21779,81 @@ async function runInit(args) {
21686
21779
  }
21687
21780
 
21688
21781
  // src/pipeline/doctor.ts
21689
- import { constants, existsSync as existsSync35 } from "fs";
21782
+ import { constants, existsSync as existsSync36 } from "fs";
21690
21783
  import { access, stat as stat4 } from "fs/promises";
21784
+ import path42 from "path";
21785
+
21786
+ // src/pipeline/install-check.ts
21787
+ import { existsSync as existsSync35, readFileSync as readFileSync7 } from "fs";
21691
21788
  import path41 from "path";
21789
+ function readJson(file) {
21790
+ try {
21791
+ return JSON.parse(readFileSync7(file, "utf8"));
21792
+ } catch {
21793
+ return null;
21794
+ }
21795
+ }
21796
+ function readInstallFacts(manifestDir, running) {
21797
+ let dir = path41.resolve(manifestDir);
21798
+ for (let depth = 0; depth < 4; depth++) {
21799
+ const pkg = readJson(path41.join(dir, "package.json"));
21800
+ if (pkg) {
21801
+ const pinned = ["dependencies", "devDependencies", "optionalDependencies"].map((field) => pkg[field]?.pixelkiln).find((spec) => typeof spec === "string");
21802
+ if (pinned) {
21803
+ const installedPkg = readJson(path41.join(dir, "node_modules", "pixelkiln", "package.json"));
21804
+ const installed = typeof installedPkg?.version === "string" ? installedPkg.version : void 0;
21805
+ return { pinned, installed, running };
21806
+ }
21807
+ }
21808
+ const parent = path41.dirname(dir);
21809
+ if (parent === dir || !existsSync35(parent)) break;
21810
+ dir = parent;
21811
+ }
21812
+ return null;
21813
+ }
21814
+ function parse(version) {
21815
+ const match = /(\d+)\.(\d+)\.(\d+)/.exec(version);
21816
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
21817
+ }
21818
+ function compare(a, b) {
21819
+ return a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
21820
+ }
21821
+ function checkInstall(facts) {
21822
+ const findings = [];
21823
+ const pin = parse(facts.pinned ?? "");
21824
+ const installed = facts.installed ? parse(facts.installed) : null;
21825
+ const running = facts.running ? parse(facts.running) : null;
21826
+ const exact = /^[=v]*\d+\.\d+\.\d+$/.test((facts.pinned ?? "").trim());
21827
+ if (pin && facts.installed && installed) {
21828
+ const behind = exact ? compare(installed, pin) !== 0 : compare(installed, pin) < 0;
21829
+ if (behind) {
21830
+ findings.push({
21831
+ level: "warning",
21832
+ message: `package.json asks for pixelkiln ${facts.pinned} but node_modules has ${facts.installed}; run \`npm install\` so the CLI matches the manifest.`
21833
+ });
21834
+ }
21835
+ } else if (pin && !facts.installed) {
21836
+ findings.push({
21837
+ level: "warning",
21838
+ message: `package.json asks for pixelkiln ${facts.pinned} but it is not installed in node_modules; run \`npm install\`.`
21839
+ });
21840
+ }
21841
+ if (running && installed && compare(running, installed) !== 0) {
21842
+ findings.push({
21843
+ level: "warning",
21844
+ message: `running pixelkiln ${facts.running}, but this project's node_modules has ${facts.installed}. Another install is first on your PATH; use \`npx pixelkiln\` or remove the global one.`
21845
+ });
21846
+ }
21847
+ if (!findings.length) {
21848
+ findings.push({
21849
+ level: "ok",
21850
+ message: `pixelkiln ${facts.running ?? facts.installed ?? "?"} matches package.json (${facts.pinned})`
21851
+ });
21852
+ }
21853
+ return findings;
21854
+ }
21855
+
21856
+ // src/pipeline/doctor.ts
21692
21857
  async function doctor(loaded, specs, lock, lockPath, opts = {}) {
21693
21858
  const checks = [];
21694
21859
  const add = (id, level, message6) => checks.push({ id, level, message: message6 });
@@ -21697,10 +21862,19 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
21697
21862
  "ok",
21698
21863
  `${Object.keys(loaded.manifest.styles).length} style(s), ${Object.keys(loaded.manifest.assets).length} asset(s), ${specs.length} resolved spec(s)`
21699
21864
  );
21865
+ for (const entry of loaded.invalid ?? []) {
21866
+ add(
21867
+ "invalid-entry",
21868
+ "error",
21869
+ `${entry.kind === "style" ? "styles" : "assets"}.${entry.id} was left out: ${entry.issues.join("; ")}`
21870
+ );
21871
+ }
21872
+ const facts = readInstallFacts(path42.dirname(loaded.path), opts.runningVersion !== void 0 ? opts.runningVersion : pixelkilnVersion());
21873
+ if (facts) for (const finding of checkInstall(facts)) add("install", finding.level, finding.message);
21700
21874
  add("lock", "ok", `${Object.keys(lock.entries).length} valid v2 lock entr(ies)`);
21701
21875
  const dirs = [...new Set(specs.flatMap((spec) => [
21702
- path41.dirname(spec.outFile),
21703
- ...spec.quality ? [path41.dirname(spec.quality.outFile)] : []
21876
+ path42.dirname(spec.outFile),
21877
+ ...spec.quality ? [path42.dirname(spec.quality.outFile)] : []
21704
21878
  ]))];
21705
21879
  const unwritable = [];
21706
21880
  for (const dir of dirs) {
@@ -21723,7 +21897,7 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
21723
21897
  for (let index = 0; index < entry.outputs.length; index++) {
21724
21898
  const output = entry.outputs[index];
21725
21899
  const spec = specByKey.get(key);
21726
- const absolute = spec ? currentEntryOutputPath(entry, spec, index) : resolveOutputPath(output.path, path41.dirname(lockPath));
21900
+ const absolute = spec ? currentEntryOutputPath(entry, spec, index) : resolveOutputPath(output.path, path42.dirname(lockPath));
21727
21901
  const owner = outputOwners.get(absolute);
21728
21902
  if (owner && owner !== key) duplicateOutputs.push(`${output.path} (${owner}, ${key})`);
21729
21903
  outputOwners.set(absolute, key);
@@ -21738,7 +21912,7 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
21738
21912
  } else {
21739
21913
  add("lock-outputs", "ok", `${outputOwners.size} recorded output path(s) are uniquely owned`);
21740
21914
  }
21741
- const cacheDir = path41.join(path41.dirname(lockPath), ".pixelkiln", "cache");
21915
+ const cacheDir = path42.join(path42.dirname(lockPath), ".pixelkiln", "cache");
21742
21916
  const stranded = [];
21743
21917
  const invalidState = [];
21744
21918
  const staleMapUrls = [];
@@ -21754,11 +21928,11 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
21754
21928
  const hasSource = Boolean(entry.sourceUrl || entry.sourceUrls?.length);
21755
21929
  let hasCache = false;
21756
21930
  for (const output of entry.outputs) {
21757
- const cached2 = path41.join(
21931
+ const cached2 = path42.join(
21758
21932
  cacheDir,
21759
21933
  cacheFileName(output.sha256, output.mediaType ?? MediaType.PNG)
21760
21934
  );
21761
- if (existsSync35(cached2) && await sha256File(cached2) === output.sha256) {
21935
+ if (existsSync36(cached2) && await sha256File(cached2) === output.sha256) {
21762
21936
  hasCache = true;
21763
21937
  break;
21764
21938
  }
@@ -21854,7 +22028,7 @@ async function nearestExistingDirectory(start) {
21854
22028
  if ((await stat4(current)).isDirectory()) return current;
21855
22029
  } catch {
21856
22030
  }
21857
- const parent = path41.dirname(current);
22031
+ const parent = path42.dirname(current);
21858
22032
  if (parent === current) return current;
21859
22033
  current = parent;
21860
22034
  }
@@ -21862,8 +22036,8 @@ async function nearestExistingDirectory(start) {
21862
22036
 
21863
22037
  // src/pipeline/audit.ts
21864
22038
  import { readFile as readFile30 } from "fs/promises";
21865
- import { existsSync as existsSync36 } from "fs";
21866
- import path42 from "path";
22039
+ import { existsSync as existsSync37 } from "fs";
22040
+ import path43 from "path";
21867
22041
  function paletteDistance(asset, reference) {
21868
22042
  if (!asset.length || !reference.length) return 0;
21869
22043
  let total = 0;
@@ -21899,7 +22073,7 @@ async function auditStyle(loaded, specs, styleId, lock) {
21899
22073
  const unreadable = [];
21900
22074
  for (const spec of mine) {
21901
22075
  for (const output of resolveSpecOutputs(spec, lock, loaded.root)) {
21902
- if (!existsSync36(output.absolutePath)) {
22076
+ if (!existsSync37(output.absolutePath)) {
21903
22077
  missing.push(output.id);
21904
22078
  continue;
21905
22079
  }
@@ -21928,8 +22102,8 @@ async function auditStyle(loaded, specs, styleId, lock) {
21928
22102
  let referenceFromStyleImages = false;
21929
22103
  const refPalettes = [];
21930
22104
  for (const img of style.styleImages) {
21931
- const abs = path42.resolve(loaded.root, img.path);
21932
- if (!existsSync36(abs)) continue;
22105
+ const abs = path43.resolve(loaded.root, img.path);
22106
+ if (!existsSync37(abs)) continue;
21933
22107
  try {
21934
22108
  refPalettes.push(extractPalette(decodePng(await readFile30(abs)), 12));
21935
22109
  } catch {
@@ -22061,11 +22235,14 @@ async function runDoctor(args) {
22061
22235
  if (!report.ok) process.exitCode = 1;
22062
22236
  }
22063
22237
  async function runPlan(args) {
22064
- const { specs, lock } = await openProject2(args);
22238
+ const { loaded, specs, lock } = await openProject2(args);
22239
+ const { shown: invalid, hidden: hiddenInvalid } = selectInvalid(loaded.invalid ?? [], args);
22065
22240
  const plan = await buildPlan(specs, lock, { force: args.force });
22066
22241
  if (args.json) {
22067
22242
  log(JSON.stringify({
22068
22243
  totals: summarize(plan),
22244
+ invalid,
22245
+ hiddenInvalid,
22069
22246
  cost: plan.cost,
22070
22247
  costUnit: plan.costUnit,
22071
22248
  candidates: plan.candidates,
@@ -22102,11 +22279,11 @@ async function runPlan(args) {
22102
22279
  })
22103
22280
  }, null, 2));
22104
22281
  } else {
22105
- printPlan(plan);
22282
+ printPlan(plan, invalid, hiddenInvalid);
22106
22283
  }
22107
- if (args.check && plan.items.some(
22284
+ if (args.check && (invalid.length > 0 || plan.items.some(
22108
22285
  (item) => item.state !== "ok" || item.quality && item.quality.state !== "approved"
22109
- )) process.exitCode = 1;
22286
+ ))) process.exitCode = 1;
22110
22287
  }
22111
22288
  async function runAudit(args) {
22112
22289
  const { loaded, specs, lock } = await openProject2(args);
@@ -22158,15 +22335,18 @@ async function runAudit(args) {
22158
22335
  if (args.check && reports.some((report) => !report.evaluation.safe)) process.exitCode = 1;
22159
22336
  }
22160
22337
  async function runHash(args) {
22161
- const { specs, lock } = await openProject2(args);
22338
+ const { loaded, specs, lock } = await openProject2(args);
22162
22339
  if (!args.assets.length && !args.styles.length && !args.all) {
22163
22340
  throw new UsageError("hash needs --only <asset>, --style <style>, or --all.");
22164
22341
  }
22165
22342
  const reports = await reportSpecHashes(specs, lock);
22166
22343
  if (args.json) {
22167
- log(JSON.stringify({ items: reports }, null, 2));
22344
+ log(JSON.stringify({ items: reports, invalid: selectInvalid(loaded.invalid ?? [], args).shown }, null, 2));
22168
22345
  return;
22169
22346
  }
22347
+ for (const entry of selectInvalid(loaded.invalid ?? [], args).shown) {
22348
+ log(` invalid ${entry.kind === "style" ? "styles" : "assets"}.${entry.id}: ${entry.issues[0] ?? ""}`);
22349
+ }
22170
22350
  for (const report of reports) {
22171
22351
  const state = !report.lock ? "no lock entry" : report.lock.matches ? "lock matches" : "lock differs";
22172
22352
  log(` ${report.key}`);
@@ -22179,24 +22359,24 @@ async function runHash(args) {
22179
22359
  }
22180
22360
 
22181
22361
  // src/cli/commands/pack.ts
22182
- import path44 from "path";
22362
+ import path45 from "path";
22183
22363
  import { readFile as readFile31 } from "fs/promises";
22184
22364
 
22185
22365
  // src/pipeline/pack.ts
22186
- import { readFileSync as readFileSync7 } from "fs";
22187
- import path43 from "path";
22366
+ import { readFileSync as readFileSync8 } from "fs";
22367
+ import path44 from "path";
22188
22368
  var DEFAULT_FRAME_SET_FPS = 12;
22189
22369
  function resolvePackInputs(raw, inputsFilePath) {
22190
22370
  if (!Array.isArray(raw) || !raw.length) {
22191
22371
  throw new Error("--inputs must be a non-empty JSON array of { id, path }");
22192
22372
  }
22193
- const baseDir = path43.dirname(path43.resolve(inputsFilePath));
22373
+ const baseDir = path44.dirname(path44.resolve(inputsFilePath));
22194
22374
  return raw.map((entry, i) => {
22195
22375
  const e = entry;
22196
22376
  if (typeof e.id !== "string" || typeof e.path !== "string") {
22197
22377
  throw new Error(`--inputs[${i}] needs string "id" and "path"`);
22198
22378
  }
22199
- return { id: e.id, path: path43.resolve(baseDir, e.path) };
22379
+ return { id: e.id, path: path44.resolve(baseDir, e.path) };
22200
22380
  });
22201
22381
  }
22202
22382
  function packSprites(inputs, options = {}) {
@@ -22217,7 +22397,7 @@ function packSprites(inputs, options = {}) {
22217
22397
  for (const input of ordered) {
22218
22398
  let sourceHash = null;
22219
22399
  try {
22220
- const bytes = readFileSync7(input.path);
22400
+ const bytes = readFileSync8(input.path);
22221
22401
  sourceHash = sha256(bytes);
22222
22402
  const png = decodePng(bytes);
22223
22403
  sprites.push({ id: input.id, width: png.width, height: png.height, pixels: png.pixels });
@@ -22280,7 +22460,7 @@ function packStyle(lock, styleId, manifestDir, options = {}) {
22280
22460
  }
22281
22461
  const inputs2 = Object.entries(options.sourceOverrides).map(([id, source]) => ({
22282
22462
  id,
22283
- path: path43.resolve(source)
22463
+ path: path44.resolve(source)
22284
22464
  }));
22285
22465
  if (!inputs2.length) throw new Error(`No approved quality outputs for style "${styleId}".`);
22286
22466
  const packed2 = packSprites(inputs2, options);
@@ -22304,7 +22484,7 @@ function packStyle(lock, styleId, manifestDir, options = {}) {
22304
22484
  let outputs = resolveEntryOutputs(entry, id, manifestDir);
22305
22485
  const source = sources[id];
22306
22486
  if (source && outputs.length <= 1) {
22307
- inputs.push({ id, path: path43.resolve(manifestDir, source) });
22487
+ inputs.push({ id, path: path44.resolve(manifestDir, source) });
22308
22488
  continue;
22309
22489
  }
22310
22490
  if (source && sourceIsStem(source, entry, manifestDir)) {
@@ -22339,7 +22519,7 @@ function packStyle(lock, styleId, manifestDir, options = {}) {
22339
22519
  }
22340
22520
  }
22341
22521
  for (const [id, source] of Object.entries(sources)) {
22342
- if (!locked.has(id)) inputs.push({ id, path: path43.resolve(manifestDir, source) });
22522
+ if (!locked.has(id)) inputs.push({ id, path: path44.resolve(manifestDir, source) });
22343
22523
  }
22344
22524
  if (!inputs.length) {
22345
22525
  throw new Error(`No readable sprites for style "${styleId}"; ${noOutput.length} skipped.`);
@@ -22376,7 +22556,7 @@ function mountSprites(placements, options) {
22376
22556
  for (const p of placements) {
22377
22557
  let sourceHash = null;
22378
22558
  try {
22379
- const bytes = readFileSync7(p.path);
22559
+ const bytes = readFileSync8(p.path);
22380
22560
  sourceHash = sha256(bytes);
22381
22561
  const png = decodePng(bytes);
22382
22562
  if (png.width > cellWidth || png.height > cellHeight) {
@@ -22447,7 +22627,7 @@ function mountStyle(lock, styleId, manifestDir, mount, cells, sources = {}, outp
22447
22627
  const source = sources[id];
22448
22628
  const entry = lock.entries[`${styleId}/${id}`];
22449
22629
  if (source && !(entry && sourceIsStem(source, entry, manifestDir))) {
22450
- placements.push({ id, path: path43.resolve(manifestDir, source), cell });
22630
+ placements.push({ id, path: path44.resolve(manifestDir, source), cell });
22451
22631
  continue;
22452
22632
  }
22453
22633
  if (source && entry) {
@@ -22480,7 +22660,7 @@ function mountStyle(lock, styleId, manifestDir, mount, cells, sources = {}, outp
22480
22660
  `Nothing to mount for style "${styleId}": ${ids.length} asset(s) declare a cell, but none has generated output or a \`source\`. Run \`pixelkiln gen --style ${styleId}\`, or point each at a file.${detail}`
22481
22661
  );
22482
22662
  }
22483
- const basePng = mount.base ? readFileSync7(path43.resolve(manifestDir, mount.base)) : void 0;
22663
+ const basePng = mount.base ? readFileSync8(path44.resolve(manifestDir, mount.base)) : void 0;
22484
22664
  const mounted = mountSprites(placements, {
22485
22665
  cellWidth: mount.cellWidth,
22486
22666
  cellHeight: mount.cellHeight,
@@ -22490,7 +22670,7 @@ function mountStyle(lock, styleId, manifestDir, mount, cells, sources = {}, outp
22490
22670
  ...mounted,
22491
22671
  sources: mount.base ? [{
22492
22672
  id: "$base",
22493
- path: path43.resolve(manifestDir, mount.base),
22673
+ path: path44.resolve(manifestDir, mount.base),
22494
22674
  sha256: sha256(basePng),
22495
22675
  included: true
22496
22676
  }, ...mounted.sources] : mounted.sources,
@@ -22894,12 +23074,12 @@ async function runPack(args) {
22894
23074
  if (args.primaryOnly || args.outputRoles.length) {
22895
23075
  throw new Error("--primary-only and --output-role require manifest-driven pack");
22896
23076
  }
22897
- const raw = JSON.parse(await readFile31(path44.resolve(args.inputs), "utf8"));
23077
+ const raw = JSON.parse(await readFile31(path45.resolve(args.inputs), "utf8"));
22898
23078
  const inputs = resolvePackInputs(raw, args.inputs);
22899
23079
  const { png, atlas, skipped, sources } = packSprites(inputs, { columns: args.columns });
22900
23080
  const format = sheetFormat(args);
22901
- const base = path44.resolve(args.out.replace(/\.(?:png|json|tres)$/i, ""));
22902
- const { extension, document } = renderSheetDocument(format, atlas, { imageName: path44.basename(`${base}.png`) });
23081
+ const base = path45.resolve(args.out.replace(/\.(?:png|json|tres)$/i, ""));
23082
+ const { extension, document } = renderSheetDocument(format, atlas, { imageName: path45.basename(`${base}.png`) });
22903
23083
  const outputs = [
22904
23084
  { path: `${base}.png`, data: png },
22905
23085
  { path: `${base}${extension}`, data: document }
@@ -22912,7 +23092,7 @@ async function runPack(args) {
22912
23092
  log(
22913
23093
  ` ${atlas.frames.length} sprite(s), ${atlas.sheet.width}x${atlas.sheet.height} in ${atlas.columns} column(s), ${(png.length / 1024).toFixed(1)} KB (${format})`
22914
23094
  );
22915
- log(` ${path44.relative(process.cwd(), base)}.png + ${extension} + .pixelkiln.json`);
23095
+ log(` ${path45.relative(process.cwd(), base)}.png + ${extension} + .pixelkiln.json`);
22916
23096
  for (const s of skipped) log(` skipped ${s.id}: ${s.reason}`);
22917
23097
  return;
22918
23098
  }
@@ -22920,7 +23100,7 @@ async function runPack(args) {
22920
23100
  if (args.primaryOnly && args.outputRoles.length) {
22921
23101
  throw new Error("pack accepts either --primary-only or --output-role, not both");
22922
23102
  }
22923
- const manifestDir = path44.dirname(path44.resolve(args.manifest));
23103
+ const manifestDir = path45.dirname(path45.resolve(args.manifest));
22924
23104
  const styleIds = args.styles.length ? args.styles : Object.keys(loaded.manifest.styles);
22925
23105
  for (const styleId of styleIds) {
22926
23106
  const style = loaded.manifest.styles[styleId];
@@ -22935,9 +23115,9 @@ async function runPack(args) {
22935
23115
  sourceOverrides: qualitySources,
22936
23116
  sources: manifestSources(loaded.manifest, styleId)
22937
23117
  });
22938
- const base = args.out ? path44.resolve(args.out.replace(/\.(?:png|json|tres)$/i, "")) : path44.resolve(manifestDir, style.outDir, `${styleId}-sheet`);
23118
+ const base = args.out ? path45.resolve(args.out.replace(/\.(?:png|json|tres)$/i, "")) : path45.resolve(manifestDir, style.outDir, `${styleId}-sheet`);
22939
23119
  const format = sheetFormat(args);
22940
- const { extension, document } = renderSheetDocument(format, atlas, { imageName: path44.basename(`${base}.png`) });
23120
+ const { extension, document } = renderSheetDocument(format, atlas, { imageName: path45.basename(`${base}.png`) });
22941
23121
  const outputs = [
22942
23122
  { path: `${base}.png`, data: png },
22943
23123
  { path: `${base}${extension}`, data: document }
@@ -22969,13 +23149,13 @@ async function runPack(args) {
22969
23149
  log(
22970
23150
  ` ${styleId}: ${atlas.frames.length} sprite(s), ${atlas.sheet.width}x${atlas.sheet.height} in ${atlas.columns} column(s)` + (atlas.sets?.length ? `, ${atlas.sets.length} set(s)` : "") + ` (${format})`
22971
23151
  );
22972
- log(` ${path44.relative(process.cwd(), base)}.png + ${extension} + .pixelkiln.json`);
23152
+ log(` ${path45.relative(process.cwd(), base)}.png + ${extension} + .pixelkiln.json`);
22973
23153
  for (const s of skipped) log(` skipped ${s.id}: ${s.reason}`);
22974
23154
  }
22975
23155
  }
22976
23156
  async function runMount(args) {
22977
23157
  const { loaded, lock } = await openProject2(args);
22978
- const manifestDir = path44.dirname(path44.resolve(args.manifest));
23158
+ const manifestDir = path45.dirname(path45.resolve(args.manifest));
22979
23159
  const styleIds = args.styles.length ? args.styles : Object.keys(loaded.manifest.styles);
22980
23160
  for (const styleId of styleIds) {
22981
23161
  const style = loaded.manifest.styles[styleId];
@@ -23014,9 +23194,9 @@ async function runMount(args) {
23014
23194
  sources,
23015
23195
  outputRoles
23016
23196
  );
23017
- const out = path44.resolve(manifestDir, style.mount.out);
23197
+ const out = path45.resolve(manifestDir, style.mount.out);
23018
23198
  const format = sheetFormat(args);
23019
- const { extension, document } = renderSheetDocument(format, atlas, { imageName: path44.basename(out) });
23199
+ const { extension, document } = renderSheetDocument(format, atlas, { imageName: path45.basename(out) });
23020
23200
  const metadata = out.replace(/\.png$/, "") + extension;
23021
23201
  const companion = out.replace(/\.png$/, "") + ".pixelkiln.json";
23022
23202
  const outputs = [
@@ -23036,7 +23216,7 @@ async function runMount(args) {
23036
23216
  await provenanceFile("$lock", args.lock),
23037
23217
  ...qualityRecords,
23038
23218
  ...artifactSources.filter(
23039
- (source) => source.id !== "$base" || path44.resolve(source.path) !== out
23219
+ (source) => source.id !== "$base" || path45.resolve(source.path) !== out
23040
23220
  )
23041
23221
  ],
23042
23222
  options: {
@@ -23050,14 +23230,14 @@ async function runMount(args) {
23050
23230
  log(
23051
23231
  ` ${styleId}: ${atlas.frames.length} cell(s) into ${atlas.sheet.width}x${atlas.sheet.height}` + (overBase ? ` over ${style.mount.base}` : " (new sheet)")
23052
23232
  );
23053
- log(` ${path44.relative(process.cwd(), out)} + atlas/provenance JSON`);
23233
+ log(` ${path45.relative(process.cwd(), out)} + atlas/provenance JSON`);
23054
23234
  for (const s of skipped) log(` skipped ${s.id}: ${s.reason}`);
23055
23235
  }
23056
23236
  }
23057
23237
  async function runExport(args) {
23058
23238
  const { loaded, specs, lock } = await openProject2(args);
23059
23239
  const format = args.format ?? "generic";
23060
- const manifestDir = path44.dirname(path44.resolve(args.manifest));
23240
+ const manifestDir = path45.dirname(path45.resolve(args.manifest));
23061
23241
  const selected = specs.filter((spec) => {
23062
23242
  if (spec.generator !== "tiles" && spec.generator !== "terrain") return false;
23063
23243
  if (args.styles.length && !args.styles.includes(spec.styleId)) return false;
@@ -23073,12 +23253,12 @@ async function runExport(args) {
23073
23253
  for (const spec of selected) {
23074
23254
  const entry = lock.entries[lockKey(spec.styleId, spec.assetId)];
23075
23255
  const style = loaded.manifest.styles[spec.styleId];
23076
- const defaultBase = path44.resolve(manifestDir, style.outDir, `${spec.assetId}-tileset`);
23077
- const base = args.out ? path44.resolve(args.out.replace(/\.(?:png|json|tsj|tres)$/i, "")) : defaultBase;
23256
+ const defaultBase = path45.resolve(manifestDir, style.outDir, `${spec.assetId}-tileset`);
23257
+ const base = args.out ? path45.resolve(args.out.replace(/\.(?:png|json|tsj|tres)$/i, "")) : defaultBase;
23078
23258
  const result = exportTileset(entry, spec, {
23079
23259
  format,
23080
23260
  manifestDir,
23081
- imageName: path44.basename(`${base}.png`),
23261
+ imageName: path45.basename(`${base}.png`),
23082
23262
  columns: args.columns
23083
23263
  });
23084
23264
  const outputs = [
@@ -23096,7 +23276,7 @@ async function runExport(args) {
23096
23276
  asset: spec.assetId,
23097
23277
  columns: args.columns ?? null,
23098
23278
  format,
23099
- image: path44.basename(`${base}.png`),
23279
+ image: path45.basename(`${base}.png`),
23100
23280
  providerRules: result.generic.providerRules,
23101
23281
  style: spec.styleId,
23102
23282
  tileType: spec.tileType ?? null
@@ -23106,7 +23286,7 @@ async function runExport(args) {
23106
23286
  ` ${spec.styleId}/${spec.assetId}: ${result.generic.tiles.length} tile(s), ${result.generic.sheet.width}x${result.generic.sheet.height} (${format})`
23107
23287
  );
23108
23288
  log(
23109
- ` ${path44.relative(process.cwd(), base)}.png + ${path44.basename(base)}${result.extension} + .pixelkiln.json`
23289
+ ` ${path45.relative(process.cwd(), base)}.png + ${path45.basename(base)}${result.extension} + .pixelkiln.json`
23110
23290
  );
23111
23291
  }
23112
23292
  }
@@ -23120,9 +23300,9 @@ function sheetFormat(args) {
23120
23300
 
23121
23301
  // src/cli/commands/pixellab-utils.ts
23122
23302
  import { readFile as readFile32 } from "fs/promises";
23123
- import path45 from "path";
23303
+ import path46 from "path";
23124
23304
  function loadKeys(args) {
23125
- loadEnvFiles(path45.dirname(path45.resolve(args.manifest)));
23305
+ loadEnvFiles(path46.dirname(path46.resolve(args.manifest)));
23126
23306
  loadEnvFiles(process.cwd());
23127
23307
  }
23128
23308
  async function runUnzoom(args) {
@@ -23279,7 +23459,7 @@ async function runVfx(args) {
23279
23459
  const fromRecipe = args.recipe ? await readVfxRecipe(args.recipe) : void 0;
23280
23460
  const sprite = args.sprite ?? fromRecipe?.sprite;
23281
23461
  const recipeName = typeof fromRecipe?.recipe.name === "string" ? fromRecipe.recipe.name : void 0;
23282
- const name = args.name ?? (args.effect ? void 0 : recipeName ?? args.preset ?? path45.basename(paths.sheet, ".png"));
23462
+ const name = args.name ?? (args.effect ? void 0 : recipeName ?? args.preset ?? path46.basename(paths.sheet, ".png"));
23283
23463
  const from = args.preset ? `preset ${args.preset}` : args.recipe ? `recipe ${args.recipe}` : args.effect ? `saved effect ${args.effect}` : "nothing";
23284
23464
  log(
23285
23465
  ` vfx ${name ? `"${name}"` : "(keeping its saved name)"} from ${from}${args.parts.length ? ` + ${args.parts.join(", ")}` : ""}${sprite ? ` around ${sprite}` : ""} \u2192 ${paths.sheet} (+ .gif, .json, .vfx.json${args.gamePack ? ", -game.zip" : ""})`
@@ -23346,7 +23526,7 @@ async function runVfxArtist(args, out) {
23346
23526
  );
23347
23527
  if (args.effect) {
23348
23528
  log(
23349
- ` changes saved effect ${args.effect} in place` + (conversation ? `, priced as a change (its conversation is in ${path45.basename(paths.provenance)})` : `; ${path45.basename(paths.provenance)} holds no conversation for it, so PixelLab prices it as a new effect`)
23529
+ ` changes saved effect ${args.effect} in place` + (conversation ? `, priced as a change (its conversation is in ${path46.basename(paths.provenance)})` : `; ${path46.basename(paths.provenance)} holds no conversation for it, so PixelLab prices it as a new effect`)
23350
23530
  );
23351
23531
  }
23352
23532
  log(` cost: about ${quote} generations by PixelLab's table, billed on delivery; at most ${ceiling} if the effect runs long`);
@@ -23394,19 +23574,19 @@ async function runVfxArtist(args, out) {
23394
23574
  }
23395
23575
 
23396
23576
  // src/cli/commands/quality.ts
23397
- import path47 from "path";
23577
+ import path48 from "path";
23398
23578
  import { readFile as readFile34 } from "fs/promises";
23399
23579
 
23400
23580
  // src/pipeline/quality-regression.ts
23401
- import path46 from "path";
23402
- import { existsSync as existsSync37 } from "fs";
23581
+ import path47 from "path";
23582
+ import { existsSync as existsSync38 } from "fs";
23403
23583
  import { readFile as readFile33 } from "fs/promises";
23404
23584
  import { z as z13 } from "zod";
23405
23585
  var SHA256_RE = /^[0-9a-f]{64}$/;
23406
23586
  var HEX_RE = /^#[0-9a-f]{6}$/;
23407
23587
  var MAX_REDMEAN_DISTANCE = 765;
23408
23588
  var QualityPathSchema = z13.string().min(1).refine(
23409
- (value) => !path46.posix.isAbsolute(value) && !value.includes("\\"),
23589
+ (value) => !path47.posix.isAbsolute(value) && !value.includes("\\"),
23410
23590
  "expected a portable relative path"
23411
23591
  );
23412
23592
  var DEFAULT_QUALITY_TOLERANCES = {
@@ -23553,7 +23733,7 @@ function measureDecodedImageQuality(png, digest2) {
23553
23733
  };
23554
23734
  }
23555
23735
  async function measureImageQuality(file) {
23556
- const absolute = path46.resolve(file);
23736
+ const absolute = path47.resolve(file);
23557
23737
  let bytes;
23558
23738
  try {
23559
23739
  bytes = await readFile33(absolute);
@@ -23575,11 +23755,11 @@ function resolveQualityInputs(raw, inputsFilePath) {
23575
23755
  }
23576
23756
  const ids = parsed.data.map((entry) => entry.id);
23577
23757
  if (new Set(ids).size !== ids.length) throw new Error("--inputs contains a duplicate quality case id.");
23578
- const root = path46.dirname(path46.resolve(inputsFilePath));
23758
+ const root = path47.dirname(path47.resolve(inputsFilePath));
23579
23759
  return parsed.data.map((entry) => ({
23580
23760
  id: entry.id,
23581
- file: path46.resolve(root, entry.path),
23582
- ...entry.record ? { record: path46.resolve(root, entry.record) } : {},
23761
+ file: path47.resolve(root, entry.path),
23762
+ ...entry.record ? { record: path47.resolve(root, entry.record) } : {},
23583
23763
  tolerances: QualityToleranceSchema.parse({
23584
23764
  ...DEFAULT_QUALITY_TOLERANCES,
23585
23765
  ...entry.tolerances
@@ -23587,7 +23767,7 @@ function resolveQualityInputs(raw, inputsFilePath) {
23587
23767
  }));
23588
23768
  }
23589
23769
  function portableRelative2(from, to) {
23590
- return path46.relative(from, path46.resolve(to)).split(path46.sep).join("/") || ".";
23770
+ return path47.relative(from, path47.resolve(to)).split(path47.sep).join("/") || ".";
23591
23771
  }
23592
23772
  async function verifyRecordForImage(recordPath, imagePath) {
23593
23773
  const verification = await verifyArtifactBundle(recordPath);
@@ -23602,20 +23782,20 @@ async function verifyRecordForImage(recordPath, imagePath) {
23602
23782
  if (record.kind !== "refine" || options === null || typeof options !== "object" || options.schema !== "pixelkiln-quality") {
23603
23783
  throw new Error(`Quality record ${recordPath} is not a PixelKiln refinement record.`);
23604
23784
  }
23605
- const outputs = record.outputs.map((output) => path46.resolve(path46.dirname(recordPath), output.path));
23606
- if (!outputs.includes(path46.resolve(imagePath))) {
23785
+ const outputs = record.outputs.map((output) => path47.resolve(path47.dirname(recordPath), output.path));
23786
+ if (!outputs.includes(path47.resolve(imagePath))) {
23607
23787
  throw new Error(`Quality record ${recordPath} does not own ${imagePath}.`);
23608
23788
  }
23609
23789
  }
23610
23790
  async function snapshotQualityBaseline(inputs, baselinePath, options = {}) {
23611
23791
  if (!inputs.length) throw new Error("Cannot snapshot an empty quality baseline.");
23612
- const absolute = path46.resolve(baselinePath);
23792
+ const absolute = path47.resolve(baselinePath);
23613
23793
  for (const input of inputs) {
23614
- if (path46.resolve(input.file) === absolute || input.record && path46.resolve(input.record) === absolute) {
23794
+ if (path47.resolve(input.file) === absolute || input.record && path47.resolve(input.record) === absolute) {
23615
23795
  throw new Error(`Quality baseline output would overwrite an input: ${absolute}.`);
23616
23796
  }
23617
23797
  }
23618
- const root = path46.dirname(absolute);
23798
+ const root = path47.dirname(absolute);
23619
23799
  const cases = [];
23620
23800
  for (const input of [...inputs].sort((a, b) => a.id.localeCompare(b.id))) {
23621
23801
  const expected = await measureImageQuality(input.file);
@@ -23642,7 +23822,7 @@ async function snapshotQualityBaseline(inputs, baselinePath, options = {}) {
23642
23822
  cases
23643
23823
  });
23644
23824
  const data = Buffer.from(JSON.stringify(baseline, null, 2) + "\n");
23645
- if (existsSync37(absolute) && !options.force) {
23825
+ if (existsSync38(absolute) && !options.force) {
23646
23826
  const current = await readFile33(absolute);
23647
23827
  if (!current.equals(data)) {
23648
23828
  throw new OverwriteRefusedError(
@@ -23655,8 +23835,8 @@ async function snapshotQualityBaseline(inputs, baselinePath, options = {}) {
23655
23835
  return { baseline, path: absolute, changed: result.changed.length > 0 };
23656
23836
  }
23657
23837
  async function snapshotQualityCases(inputs, baselinePath, only, options = {}) {
23658
- const absolute = path46.resolve(baselinePath);
23659
- if (!existsSync37(absolute)) {
23838
+ const absolute = path47.resolve(baselinePath);
23839
+ if (!existsSync38(absolute)) {
23660
23840
  throw new Error(`quality snapshot --only updates an existing baseline; ${absolute} does not exist. Run a full snapshot first.`);
23661
23841
  }
23662
23842
  let raw;
@@ -23671,12 +23851,12 @@ async function snapshotQualityCases(inputs, baselinePath, only, options = {}) {
23671
23851
  if (unknown.length) {
23672
23852
  throw new Error(`--only names ${unknown.join(", ")}, which the quality inputs do not list. Known: ${[...byId.keys()].sort().join(", ")}`);
23673
23853
  }
23674
- const root = path46.dirname(absolute);
23854
+ const root = path47.dirname(absolute);
23675
23855
  const cases = [...raw.cases];
23676
23856
  const report = [];
23677
23857
  for (const id of only) {
23678
23858
  const input = byId.get(id);
23679
- if (path46.resolve(input.file) === absolute || input.record && path46.resolve(input.record) === absolute) {
23859
+ if (path47.resolve(input.file) === absolute || input.record && path47.resolve(input.record) === absolute) {
23680
23860
  throw new Error(`Quality baseline output would overwrite an input: ${absolute}.`);
23681
23861
  }
23682
23862
  const expected = await measureImageQuality(input.file);
@@ -23712,7 +23892,7 @@ async function snapshotQualityCases(inputs, baselinePath, only, options = {}) {
23712
23892
  return { baseline, path: absolute, changed, cases: report };
23713
23893
  }
23714
23894
  async function readQualityBaseline(baselinePath) {
23715
- const absolute = path46.resolve(baselinePath);
23895
+ const absolute = path47.resolve(baselinePath);
23716
23896
  let raw;
23717
23897
  try {
23718
23898
  raw = JSON.parse(await readFile33(absolute, "utf8"));
@@ -23737,7 +23917,7 @@ async function readQualityBaseline(baselinePath) {
23737
23917
  throw new Error(
23738
23918
  `Invalid quality baseline ${absolute}:
23739
23919
  ` + parsed.error.issues.map((issue) => ` ${where(issue.path)}: ${issue.message}`).join("\n") + (missing.length ? `
23740
- Entries missing fields: re-measure them with \`pixelkiln quality snapshot --inputs <inputs> --out ${path46.basename(absolute)} --only ${missing.join(",")}\` rather than editing the JSON by hand.` : "")
23920
+ Entries missing fields: re-measure them with \`pixelkiln quality snapshot --inputs <inputs> --out ${path47.basename(absolute)} --only ${missing.join(",")}\` rather than editing the JSON by hand.` : "")
23741
23921
  );
23742
23922
  }
23743
23923
  return parsed.data;
@@ -23799,12 +23979,12 @@ function regressionViolations(expected, actual, tolerances) {
23799
23979
  return { violations, warnings };
23800
23980
  }
23801
23981
  async function checkQualityBaseline(baselinePath) {
23802
- const absolute = path46.resolve(baselinePath);
23982
+ const absolute = path47.resolve(baselinePath);
23803
23983
  const baseline = await readQualityBaseline(absolute);
23804
- const root = path46.dirname(absolute);
23984
+ const root = path47.dirname(absolute);
23805
23985
  const cases = [];
23806
23986
  for (const entry of baseline.cases) {
23807
- const file = path46.resolve(root, entry.file);
23987
+ const file = path47.resolve(root, entry.file);
23808
23988
  let actual = null;
23809
23989
  const violations = [];
23810
23990
  const warnings = [];
@@ -23817,7 +23997,7 @@ async function checkQualityBaseline(baselinePath) {
23817
23997
  violations.push(message4(error));
23818
23998
  }
23819
23999
  if (entry.record) {
23820
- const recordPath = path46.resolve(root, entry.record.path);
24000
+ const recordPath = path47.resolve(root, entry.record.path);
23821
24001
  try {
23822
24002
  const recordHash = await sha256File(recordPath);
23823
24003
  if (recordHash !== entry.record.sha256) violations.push("quality record hash changed");
@@ -23859,15 +24039,15 @@ async function runQuality(args) {
23859
24039
  if (!args.out) throw new Error("quality snapshot needs --out <pixelkiln.quality.json>.");
23860
24040
  let raw;
23861
24041
  try {
23862
- raw = JSON.parse(await readFile34(path47.resolve(args.inputs), "utf8"));
24042
+ raw = JSON.parse(await readFile34(path48.resolve(args.inputs), "utf8"));
23863
24043
  } catch (error) {
23864
24044
  throw new Error(
23865
- `Could not read quality inputs ${path47.resolve(args.inputs)}: ${error instanceof Error ? error.message : String(error)}`,
24045
+ `Could not read quality inputs ${path48.resolve(args.inputs)}: ${error instanceof Error ? error.message : String(error)}`,
23866
24046
  { cause: error }
23867
24047
  );
23868
24048
  }
23869
24049
  const inputs = resolveQualityInputs(raw, args.inputs);
23870
- if (path47.resolve(args.inputs) === path47.resolve(args.out)) {
24050
+ if (path48.resolve(args.inputs) === path48.resolve(args.out)) {
23871
24051
  throw new Error("quality snapshot --out must not overwrite its --inputs file.");
23872
24052
  }
23873
24053
  if (args.assets.length) {
@@ -23882,7 +24062,7 @@ async function runQuality(args) {
23882
24062
  }
23883
24063
  log(
23884
24064
  `
23885
- ${result2.changed ? args.dryRun ? "would write" : "wrote" : "no changes to"} ${path47.relative(process.cwd(), result2.path)}; other cases left as they were.`
24065
+ ${result2.changed ? args.dryRun ? "would write" : "wrote" : "no changes to"} ${path48.relative(process.cwd(), result2.path)}; other cases left as they were.`
23886
24066
  );
23887
24067
  return;
23888
24068
  }
@@ -23897,7 +24077,7 @@ async function runQuality(args) {
23897
24077
  }, null, 2));
23898
24078
  } else {
23899
24079
  log(
23900
- ` ${result.changed ? "wrote" : "unchanged"} ${path47.relative(process.cwd(), result.path)} (${result.baseline.cases.length} case(s))`
24080
+ ` ${result.changed ? "wrote" : "unchanged"} ${path48.relative(process.cwd(), result.path)} (${result.baseline.cases.length} case(s))`
23901
24081
  );
23902
24082
  log(` Review the tolerances, commit the baseline, then run quality check in CI.`);
23903
24083
  }
@@ -23923,11 +24103,11 @@ async function runQuality(args) {
23923
24103
  }
23924
24104
 
23925
24105
  // src/cli/commands/recipe.ts
23926
- import path49 from "path";
24106
+ import path50 from "path";
23927
24107
 
23928
24108
  // src/recipes.ts
23929
- import path48 from "path";
23930
- import { existsSync as existsSync38 } from "fs";
24109
+ import path49 from "path";
24110
+ import { existsSync as existsSync39 } from "fs";
23931
24111
  import { readdir as readdir3, readFile as readFile35 } from "fs/promises";
23932
24112
  import { fileURLToPath as fileURLToPath2 } from "url";
23933
24113
  import { z as z14 } from "zod";
@@ -23937,7 +24117,7 @@ var VERSION_RE = /^\d+\.\d+\.\d+$/;
23937
24117
  var RECIPE_FILE = "pixelkiln.recipe.json";
23938
24118
  var RECIPE_DIR_TOKEN = "{{recipeDir}}";
23939
24119
  var PortablePathSchema = z14.string().min(1).refine((value) => {
23940
- if (value.includes("\\") || path48.posix.isAbsolute(value)) return false;
24120
+ if (value.includes("\\") || path49.posix.isAbsolute(value)) return false;
23941
24121
  const parts = value.split("/");
23942
24122
  return !parts.includes("") && !parts.includes(".") && !parts.includes("..");
23943
24123
  }, "expected a portable relative path without '.', '..', or backslashes");
@@ -24113,7 +24293,7 @@ function message5(error) {
24113
24293
  return error instanceof Error ? error.message : String(error);
24114
24294
  }
24115
24295
  async function readRecipeFile(recipePath, bundled) {
24116
- const absolute = path48.resolve(recipePath);
24296
+ const absolute = path49.resolve(recipePath);
24117
24297
  let raw;
24118
24298
  try {
24119
24299
  raw = JSON.parse(await readFile35(absolute, "utf8"));
@@ -24127,13 +24307,13 @@ async function readRecipeFile(recipePath, bundled) {
24127
24307
  ` + parsed.error.issues.map((issue) => ` ${issue.path.join(".") || "$"}: ${issue.message}`).join("\n")
24128
24308
  );
24129
24309
  }
24130
- return { recipe: parsed.data, authored: raw, path: absolute, dir: path48.dirname(absolute), bundled };
24310
+ return { recipe: parsed.data, authored: raw, path: absolute, dir: path49.dirname(absolute), bundled };
24131
24311
  }
24132
24312
  async function walkRecipeFiles(root) {
24133
- if (!existsSync38(root)) return [];
24313
+ if (!existsSync39(root)) return [];
24134
24314
  const out = [];
24135
24315
  for (const entry of await readdir3(root, { withFileTypes: true })) {
24136
- const resolved = path48.join(root, entry.name);
24316
+ const resolved = path49.join(root, entry.name);
24137
24317
  if (entry.isDirectory()) out.push(...await walkRecipeFiles(resolved));
24138
24318
  else if (entry.isFile() && entry.name === RECIPE_FILE) out.push(resolved);
24139
24319
  }
@@ -24144,7 +24324,7 @@ function bundledRecipeRoot() {
24144
24324
  }
24145
24325
  async function listBundledRecipes(root = bundledRecipeRoot()) {
24146
24326
  const recipes = await Promise.all(
24147
- (await walkRecipeFiles(path48.resolve(root))).map((file) => readRecipeFile(file, true))
24327
+ (await walkRecipeFiles(path49.resolve(root))).map((file) => readRecipeFile(file, true))
24148
24328
  );
24149
24329
  return recipes.sort(
24150
24330
  (a, b) => a.recipe.id.localeCompare(b.recipe.id) || compareVersions(b.recipe.version, a.recipe.version)
@@ -24167,9 +24347,9 @@ function parseSelector(selector) {
24167
24347
  return { id: match[1], version: match[2] };
24168
24348
  }
24169
24349
  async function resolveRecipe(target, bundledRoot = bundledRecipeRoot()) {
24170
- const local = path48.resolve(target);
24171
- if (existsSync38(local)) {
24172
- const recipePath = path48.basename(local) === RECIPE_FILE ? local : path48.join(local, RECIPE_FILE);
24350
+ const local = path49.resolve(target);
24351
+ if (existsSync39(local)) {
24352
+ const recipePath = path49.basename(local) === RECIPE_FILE ? local : path49.join(local, RECIPE_FILE);
24173
24353
  return readRecipeFile(recipePath, false);
24174
24354
  }
24175
24355
  if (target.startsWith(".") || target.startsWith("/") || target.includes("\\")) {
@@ -24183,8 +24363,8 @@ async function resolveRecipe(target, bundledRoot = bundledRecipeRoot()) {
24183
24363
  return matches[0];
24184
24364
  }
24185
24365
  async function verifyFile(root, file) {
24186
- const absolute = path48.resolve(root, ...file.path.split("/"));
24187
- if (!existsSync38(absolute)) {
24366
+ const absolute = path49.resolve(root, ...file.path.split("/"));
24367
+ if (!existsSync39(absolute)) {
24188
24368
  return { path: file.path, expectedSha256: file.sha256, actualSha256: null, status: "missing" };
24189
24369
  }
24190
24370
  const actualSha256 = await sha256File(absolute);
@@ -24199,7 +24379,7 @@ async function verifyRecipe(target, options = {}) {
24199
24379
  const loaded = await resolveRecipe(target, options.bundledRoot);
24200
24380
  const actualIntegrity = recipeDigest(loaded.authored);
24201
24381
  const files = await Promise.all(loaded.recipe.files.map((file) => verifyFile(loaded.dir, file)));
24202
- const modelRoot = options.modelRoot ? path48.resolve(options.modelRoot) : null;
24382
+ const modelRoot = options.modelRoot ? path49.resolve(options.modelRoot) : null;
24203
24383
  const models = modelRoot ? await Promise.all(loaded.recipe.models.map(async (model) => ({
24204
24384
  ...await verifyFile(modelRoot, model),
24205
24385
  source: model.source,
@@ -24233,7 +24413,7 @@ async function verifyRecipe(target, options = {}) {
24233
24413
  };
24234
24414
  }
24235
24415
  function renderStyle(style, destination, cwd) {
24236
- const portableDir = path48.relative(cwd, destination).split(path48.sep).join("/") || ".";
24416
+ const portableDir = path49.relative(cwd, destination).split(path49.sep).join("/") || ".";
24237
24417
  const replace = (value) => {
24238
24418
  if (typeof value === "string") return value.replaceAll(RECIPE_DIR_TOKEN, portableDir);
24239
24419
  if (Array.isArray(value)) return value.map(replace);
@@ -24245,24 +24425,24 @@ function renderStyle(style, destination, cwd) {
24245
24425
  return replace(style);
24246
24426
  }
24247
24427
  async function installRecipe(target, options = {}) {
24248
- const cwd = path48.resolve(options.cwd ?? process.cwd());
24428
+ const cwd = path49.resolve(options.cwd ?? process.cwd());
24249
24429
  const loaded = await resolveRecipe(target, options.bundledRoot);
24250
24430
  const verification = await verifyRecipe(loaded.path);
24251
24431
  if (!verification.ok) {
24252
24432
  throw new Error(`Recipe ${loaded.recipe.id}@${loaded.recipe.version} failed integrity verification.`);
24253
24433
  }
24254
- const destination = options.out ? path48.resolve(cwd, options.out) : path48.join(cwd, "pixelkiln-recipes", ...loaded.recipe.id.split("/"), loaded.recipe.version);
24434
+ const destination = options.out ? path49.resolve(cwd, options.out) : path49.join(cwd, "pixelkiln-recipes", ...loaded.recipe.id.split("/"), loaded.recipe.version);
24255
24435
  const sources = [
24256
24436
  { path: RECIPE_FILE, source: loaded.path },
24257
- ...loaded.recipe.files.map((file) => ({ path: file.path, source: path48.join(loaded.dir, ...file.path.split("/")) }))
24437
+ ...loaded.recipe.files.map((file) => ({ path: file.path, source: path49.join(loaded.dir, ...file.path.split("/")) }))
24258
24438
  ];
24259
24439
  const files = await Promise.all(sources.map(async (file) => ({
24260
- path: path48.join(destination, ...file.path.split("/")),
24440
+ path: path49.join(destination, ...file.path.split("/")),
24261
24441
  data: await readFile35(file.source)
24262
24442
  })));
24263
24443
  if (!options.force) {
24264
24444
  for (const file of files) {
24265
- if (!existsSync38(file.path)) continue;
24445
+ if (!existsSync39(file.path)) continue;
24266
24446
  const current = await readFile35(file.path);
24267
24447
  if (!current.equals(file.data)) {
24268
24448
  throw new OverwriteRefusedError(
@@ -24357,14 +24537,14 @@ async function runRecipe(args) {
24357
24537
  }, null, 2));
24358
24538
  } else {
24359
24539
  log(` installed ${result.recipe.id}@${result.recipe.version}`);
24360
- log(` ${path49.relative(process.cwd(), result.destination) || "."}`);
24540
+ log(` ${path50.relative(process.cwd(), result.destination) || "."}`);
24361
24541
  log(`
24362
24542
  Add this entry under your manifest's styles object:`);
24363
24543
  log(JSON.stringify({ [result.styleId]: result.style }, null, 2));
24364
24544
  if (result.recipe.models.length) {
24365
24545
  log(`
24366
24546
  Models are not downloaded automatically. Verify them with:`);
24367
- log(` pixelkiln recipe verify ${path49.relative(process.cwd(), result.destination)} --model-root <ComfyUI/models>`);
24547
+ log(` pixelkiln recipe verify ${path50.relative(process.cwd(), result.destination)} --model-root <ComfyUI/models>`);
24368
24548
  }
24369
24549
  }
24370
24550
  return;
@@ -24372,7 +24552,7 @@ async function runRecipe(args) {
24372
24552
  }
24373
24553
 
24374
24554
  // src/cli/commands/refine.ts
24375
- import path50 from "path";
24555
+ import path51 from "path";
24376
24556
  async function runRefine(args) {
24377
24557
  if (args.from || args.subcommand === "approve") {
24378
24558
  if (!args.from) {
@@ -24402,12 +24582,12 @@ async function runRefine(args) {
24402
24582
  ` recovered ${result3.detection.columns}x${result3.detection.rows} native grid (${result3.detection.confidence}: ${result3.detection.consensus})`
24403
24583
  );
24404
24584
  log(` enforced ${result3.palette.length}-color palette without dithering`);
24405
- log(` wrote ${path50.relative(process.cwd(), result3.output)}`);
24406
- log(` quality record: ${path50.relative(process.cwd(), result3.record)}`);
24585
+ log(` wrote ${path51.relative(process.cwd(), result3.output)}`);
24586
+ log(` quality record: ${path51.relative(process.cwd(), result3.record)}`);
24407
24587
  log(`
24408
24588
  Automated checks passed. Human 1\xD7 review is still required:`);
24409
24589
  log(
24410
- ` pixelkiln refine approve --from ${path50.relative(process.cwd(), result3.record)} --reviewer "Your Name"`
24590
+ ` pixelkiln refine approve --from ${path51.relative(process.cwd(), result3.record)} --reviewer "Your Name"`
24411
24591
  );
24412
24592
  }
24413
24593
  return;
@@ -24435,7 +24615,7 @@ async function runRefine(args) {
24435
24615
  if (args.json) log(JSON.stringify(result3, null, 2));
24436
24616
  else {
24437
24617
  log(
24438
- result3.options.frameSet ? ` approved ${result3.outputs.length} frames in ${path50.relative(process.cwd(), result3.record)} by ${args.reviewer.trim()}` : ` approved ${path50.relative(process.cwd(), result3.output)} by ${args.reviewer.trim()}`
24618
+ result3.options.frameSet ? ` approved ${result3.outputs.length} frames in ${path51.relative(process.cwd(), result3.record)} by ${args.reviewer.trim()}` : ` approved ${path51.relative(process.cwd(), result3.output)} by ${args.reviewer.trim()}`
24439
24619
  );
24440
24620
  }
24441
24621
  return;
@@ -24444,7 +24624,7 @@ async function runRefine(args) {
24444
24624
  if (args.json) {
24445
24625
  log(JSON.stringify(result2, null, 2));
24446
24626
  } else {
24447
- log(` ${result2.safe ? "release-ready" : "not release-ready"}: ${path50.relative(process.cwd(), result2.output || result2.record)}`);
24627
+ log(` ${result2.safe ? "release-ready" : "not release-ready"}: ${path51.relative(process.cwd(), result2.output || result2.record)}`);
24448
24628
  for (const reason of result2.reasons) log(` ${reason}`);
24449
24629
  }
24450
24630
  if (!result2.safe) process.exitCode = 1;
@@ -24490,7 +24670,7 @@ async function runRefine(args) {
24490
24670
  log(` ${item.state.padEnd(16)} ${item.key} ${item.reason}`);
24491
24671
  if (item.state === "needs-approval") {
24492
24672
  log(
24493
- ` pixelkiln refine approve --from ${path50.relative(process.cwd(), item.record)} --reviewer "Your Name"`
24673
+ ` pixelkiln refine approve --from ${path51.relative(process.cwd(), item.record)} --reviewer "Your Name"`
24494
24674
  );
24495
24675
  }
24496
24676
  }
@@ -24501,8 +24681,8 @@ async function runRefine(args) {
24501
24681
  }
24502
24682
 
24503
24683
  // src/cli/commands/skeleton.ts
24504
- import path51 from "path";
24505
- import { existsSync as existsSync39 } from "fs";
24684
+ import path52 from "path";
24685
+ import { existsSync as existsSync40 } from "fs";
24506
24686
  import { readFile as readFile36, writeFile as writeFile20 } from "fs/promises";
24507
24687
 
24508
24688
  // src/skeleton-preview.ts
@@ -24614,12 +24794,12 @@ var Canvas = class {
24614
24794
  async function runEstimateSkeleton(args) {
24615
24795
  const image = args.target;
24616
24796
  if (!image) throw new UsageError("estimate-skeleton needs an image path: pixelkiln estimate-skeleton <image> [--out keypoints.json]");
24617
- if (args.out && existsSync39(path51.resolve(args.out)) && !args.force) {
24797
+ if (args.out && existsSync40(path52.resolve(args.out)) && !args.force) {
24618
24798
  throw new UsageError(`${args.out} already exists; pass --force to replace it`);
24619
24799
  }
24620
- loadEnvFiles(path51.dirname(path51.resolve(args.manifest)));
24800
+ loadEnvFiles(path52.dirname(path52.resolve(args.manifest)));
24621
24801
  loadEnvFiles(process.cwd());
24622
- const bytes = await readFile36(path51.resolve(image));
24802
+ const bytes = await readFile36(path52.resolve(image));
24623
24803
  const metadata = imageMetadata(bytes);
24624
24804
  if (!metadata) throw new UsageError(`${image} is not a readable PNG or JPEG`);
24625
24805
  const sizeProblem = estimateSkeletonSizeProblem(metadata.width, metadata.height);
@@ -24631,7 +24811,7 @@ async function runEstimateSkeleton(args) {
24631
24811
  const frames = args.frames ?? DEFAULT_SCAFFOLD_FRAMES;
24632
24812
  const json = JSON.stringify(scaffoldSkeletonSet(res.keypoints, frames), null, 2);
24633
24813
  if (args.out) {
24634
- await writeFile20(path51.resolve(args.out), json + "\n");
24814
+ await writeFile20(path52.resolve(args.out), json + "\n");
24635
24815
  log(` wrote ${args.out}: the estimated pose and ${frames} frames to edit`);
24636
24816
  log(` preview it with: pixelkiln skeleton-preview ${args.out} --from ${image}`);
24637
24817
  } else {
@@ -24644,8 +24824,8 @@ async function runSkeletonPreview(args) {
24644
24824
  let sourceFile;
24645
24825
  let label;
24646
24826
  if (target.endsWith(".json")) {
24647
- keypointsFile = path51.resolve(target);
24648
- sourceFile = args.from ? path51.resolve(args.from) : void 0;
24827
+ keypointsFile = path52.resolve(target);
24828
+ sourceFile = args.from ? path52.resolve(args.from) : void 0;
24649
24829
  label = target;
24650
24830
  } else {
24651
24831
  const loaded = await loadManifest(args.manifest);
@@ -24657,10 +24837,10 @@ async function runSkeletonPreview(args) {
24657
24837
  );
24658
24838
  }
24659
24839
  keypointsFile = spec.revision.keypointsFile;
24660
- sourceFile = args.from ? path51.resolve(args.from) : spec.revision.sourceFile;
24840
+ sourceFile = args.from ? path52.resolve(args.from) : spec.revision.sourceFile;
24661
24841
  label = `${spec.styleId}/${spec.assetId}`;
24662
24842
  }
24663
- if (!existsSync39(keypointsFile)) throw new UsageError(`Keypoints file does not exist yet: ${keypointsFile}`);
24843
+ if (!existsSync40(keypointsFile)) throw new UsageError(`Keypoints file does not exist yet: ${keypointsFile}`);
24664
24844
  let json;
24665
24845
  try {
24666
24846
  json = JSON.parse(await readFile36(keypointsFile, "utf8"));
@@ -24670,7 +24850,7 @@ async function runSkeletonPreview(args) {
24670
24850
  const set = parseSkeletonSet(json, keypointsFile);
24671
24851
  let source;
24672
24852
  if (sourceFile) {
24673
- if (!existsSync39(sourceFile)) {
24853
+ if (!existsSync40(sourceFile)) {
24674
24854
  log(` source image does not exist yet, drawing on a plain ground: ${sourceFile}`);
24675
24855
  } else {
24676
24856
  const bytes = await readFile36(sourceFile);
@@ -24678,10 +24858,10 @@ async function runSkeletonPreview(args) {
24678
24858
  source = decodePng(bytes);
24679
24859
  }
24680
24860
  }
24681
- const out = path51.resolve(args.out ?? keypointsFile.replace(/\.json$/, "") + ".preview.png");
24861
+ const out = path52.resolve(args.out ?? keypointsFile.replace(/\.json$/, "") + ".preview.png");
24682
24862
  await writeFile20(out, renderSkeletonSheet(set, { source }));
24683
24863
  log(` ${label}: ${set.frames.length} frames after the starting pose`);
24684
- const shown = path51.relative(process.cwd(), out);
24864
+ const shown = path52.relative(process.cwd(), out);
24685
24865
  log(` wrote ${shown.startsWith("..") ? out : shown}`);
24686
24866
  }
24687
24867
 
@@ -24727,15 +24907,15 @@ async function runTools(args) {
24727
24907
  }
24728
24908
 
24729
24909
  // src/cli/commands/workspace.ts
24730
- import path52 from "path";
24731
- import { existsSync as existsSync40 } from "fs";
24910
+ import path53 from "path";
24911
+ import { existsSync as existsSync41 } from "fs";
24732
24912
  async function runWorkspace(args) {
24733
- const workspacePath = path52.resolve(args.workspace ?? "pixelkiln.workspace.json");
24734
- const dir = path52.dirname(workspacePath);
24913
+ const workspacePath = path53.resolve(args.workspace ?? "pixelkiln.workspace.json");
24914
+ const dir = path53.dirname(workspacePath);
24735
24915
  if (args.subcommand === "add") {
24736
- const manifestPath = path52.resolve(args.target);
24916
+ const manifestPath = path53.resolve(args.target);
24737
24917
  const loadedTarget = await loadManifest(manifestPath);
24738
- const lockPath = args.explicitLock ? path52.resolve(args.explicitLock) : path52.join(path52.dirname(manifestPath), "pixelkiln.lock.json");
24918
+ const lockPath = args.explicitLock ? path53.resolve(args.explicitLock) : path53.join(path53.dirname(manifestPath), "pixelkiln.lock.json");
24739
24919
  const ws = await loadWorkspace(workspacePath);
24740
24920
  const id = args.name ?? loadedTarget.manifest.name;
24741
24921
  if (ws.projects.some((p) => p.id === id)) {
@@ -24755,10 +24935,10 @@ async function runWorkspace(args) {
24755
24935
  ...args.account ? { account: args.account } : {}
24756
24936
  };
24757
24937
  await saveWorkspace(workspacePath, { version: 1, projects: [...ws.projects, project] });
24758
- log(` registered "${id}" in ${path52.relative(process.cwd(), workspacePath)}`);
24938
+ log(` registered "${id}" in ${path53.relative(process.cwd(), workspacePath)}`);
24759
24939
  log(` manifest: ${project.manifest}`);
24760
24940
  log(` lock: ${project.lock}`);
24761
- if (!existsSync40(lockPath)) {
24941
+ if (!existsSync41(lockPath)) {
24762
24942
  log(
24763
24943
  ` warning: no lockfile there yet; this project contributes no claims until one is generated`
24764
24944
  );
@@ -24767,7 +24947,7 @@ async function runWorkspace(args) {
24767
24947
  }
24768
24948
  if (args.subcommand === "remove") {
24769
24949
  const ws = await loadWorkspace(workspacePath);
24770
- const resolvedTarget = path52.resolve(args.target);
24950
+ const resolvedTarget = path53.resolve(args.target);
24771
24951
  const match = ws.projects.find(
24772
24952
  (p) => p.id === args.target || resolveProject(dir, p).manifestPath === resolvedTarget
24773
24953
  );
@@ -24778,11 +24958,11 @@ async function runWorkspace(args) {
24778
24958
  version: 1,
24779
24959
  projects: ws.projects.filter((p) => p !== match)
24780
24960
  });
24781
- log(` removed "${match.id}" from ${path52.relative(process.cwd(), workspacePath)}`);
24961
+ log(` removed "${match.id}" from ${path53.relative(process.cwd(), workspacePath)}`);
24782
24962
  return;
24783
24963
  }
24784
24964
  if (args.subcommand === "list") {
24785
- if (!existsSync40(workspacePath)) {
24965
+ if (!existsSync41(workspacePath)) {
24786
24966
  throw new Error(`Workspace catalog not found: ${workspacePath}`);
24787
24967
  }
24788
24968
  const ws = await loadWorkspace(workspacePath);
@@ -24790,9 +24970,9 @@ async function runWorkspace(args) {
24790
24970
  if (args.json) {
24791
24971
  log(JSON.stringify({ version: 1, workspace: workspacePath, projects: ws.projects, diagnostics }, null, 2));
24792
24972
  } else if (!ws.projects.length) {
24793
- log(` no projects registered in ${path52.relative(process.cwd(), workspacePath)}`);
24973
+ log(` no projects registered in ${path53.relative(process.cwd(), workspacePath)}`);
24794
24974
  } else {
24795
- log(` ${ws.projects.length} project(s) in ${path52.relative(process.cwd(), workspacePath)}:`);
24975
+ log(` ${ws.projects.length} project(s) in ${path53.relative(process.cwd(), workspacePath)}:`);
24796
24976
  for (const p of ws.projects) {
24797
24977
  log(` ${p.id.padEnd(24)} ${p.manifest.padEnd(40)} (${p.provider}${p.account ? `, ${p.account}` : ""})`);
24798
24978
  }
@@ -24802,7 +24982,7 @@ async function runWorkspace(args) {
24802
24982
  return;
24803
24983
  }
24804
24984
  if (args.subcommand === "status") {
24805
- if (!existsSync40(workspacePath)) {
24985
+ if (!existsSync41(workspacePath)) {
24806
24986
  throw new Error(`Workspace catalog not found: ${workspacePath}`);
24807
24987
  }
24808
24988
  const ws = await loadWorkspace(workspacePath);
@@ -24810,7 +24990,7 @@ async function runWorkspace(args) {
24810
24990
  if (args.json) {
24811
24991
  log(JSON.stringify({ ...report, workspace: workspacePath }, null, 2));
24812
24992
  } else {
24813
- log(` workspace: ${path52.relative(process.cwd(), workspacePath)}`);
24993
+ log(` workspace: ${path53.relative(process.cwd(), workspacePath)}`);
24814
24994
  for (const p of report.projects) {
24815
24995
  if (p.error) {
24816
24996
  log(`
@@ -24864,7 +25044,7 @@ async function runHelp() {
24864
25044
  async function runVersion() {
24865
25045
  for (const up of ["../package.json", "../../package.json"]) {
24866
25046
  const url = new URL(up, import.meta.url);
24867
- if (!existsSync41(url)) continue;
25047
+ if (!existsSync42(url)) continue;
24868
25048
  const pkg = JSON.parse(await readFile37(url, "utf8"));
24869
25049
  if (pkg.name === "pixelkiln") {
24870
25050
  log(`${pkg.name} ${pkg.version}`);