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/index.cjs CHANGED
@@ -2530,9 +2530,9 @@ var PixelLabClient = class {
2530
2530
  apiKey;
2531
2531
  http;
2532
2532
  /** Retries transport failures, 429, and 5xx; see http.ts for the policy. */
2533
- async request(path39, init) {
2533
+ async request(path40, init) {
2534
2534
  const auth = this.apiKey.startsWith("Bearer ") ? this.apiKey : `Bearer ${this.apiKey}`;
2535
- const res = await this.http(`${BASE}${path39}`, {
2535
+ const res = await this.http(`${BASE}${path40}`, {
2536
2536
  ...init,
2537
2537
  headers: {
2538
2538
  Authorization: auth,
@@ -2543,13 +2543,13 @@ var PixelLabClient = class {
2543
2543
  const text = await res.text();
2544
2544
  if (!res.ok) {
2545
2545
  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' : "";
2546
- throw new PixelLabError(`${init?.method ?? "GET"} ${path39} \u2192 ${res.status}${hint}`, res.status, text);
2546
+ throw new PixelLabError(`${init?.method ?? "GET"} ${path40} \u2192 ${res.status}${hint}`, res.status, text);
2547
2547
  }
2548
2548
  if (!text) return {};
2549
2549
  try {
2550
2550
  return JSON.parse(text);
2551
2551
  } catch {
2552
- throw new Error(`${init?.method ?? "GET"} ${path39} returned invalid JSON`);
2552
+ throw new Error(`${init?.method ?? "GET"} ${path40} returned invalid JSON`);
2553
2553
  }
2554
2554
  }
2555
2555
  async balance() {
@@ -3002,10 +3002,10 @@ var PixelLabClient = class {
3002
3002
  const palette = args.paletteSwatchBase64 ? { color_image: { type: "base64", base64: args.paletteSwatchBase64, format: "png" }, force_colors: true } : {};
3003
3003
  const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
3004
3004
  const south = args.reference?.south;
3005
- let path39;
3005
+ let path40;
3006
3006
  let body;
3007
3007
  if (args.mode === "v3") {
3008
- path39 = "/create-character-v3";
3008
+ path40 = "/create-character-v3";
3009
3009
  body = {
3010
3010
  description: args.description,
3011
3011
  image_size: imageSize,
@@ -3019,7 +3019,7 @@ var PixelLabClient = class {
3019
3019
  ...args.enhancePrompt ? { enhance_prompt: true } : {}
3020
3020
  };
3021
3021
  } else if (args.mode === "pro-flash") {
3022
- path39 = "/create-character-pro-flash";
3022
+ path40 = "/create-character-pro-flash";
3023
3023
  const traits = args.styleTraits;
3024
3024
  body = {
3025
3025
  description: args.description,
@@ -3043,7 +3043,7 @@ var PixelLabClient = class {
3043
3043
  } : {}
3044
3044
  };
3045
3045
  } else if (args.mode === "pro") {
3046
- path39 = "/create-character-pro";
3046
+ path40 = "/create-character-pro";
3047
3047
  body = {
3048
3048
  description: args.description,
3049
3049
  image_size: imageSize,
@@ -3057,7 +3057,7 @@ var PixelLabClient = class {
3057
3057
  ...!south && args.styleCharacterId ? { style_character_id: args.styleCharacterId } : {}
3058
3058
  };
3059
3059
  } else {
3060
- path39 = args.directions === 4 ? "/create-character-with-4-directions" : "/create-character-with-8-directions";
3060
+ path40 = args.directions === 4 ? "/create-character-with-4-directions" : "/create-character-with-8-directions";
3061
3061
  body = {
3062
3062
  description: args.description,
3063
3063
  image_size: imageSize,
@@ -3075,8 +3075,8 @@ var PixelLabClient = class {
3075
3075
  };
3076
3076
  }
3077
3077
  if (args.mode === "pro" || args.mode === "pro-flash") Object.assign(body, targetPaletteBody(args.targetPalette));
3078
- const raw = await this.request(path39, { method: "POST", body: JSON.stringify(body) });
3079
- return validateResponse(CharacterSubmitSchema, raw, path39.slice(1));
3078
+ const raw = await this.request(path40, { method: "POST", body: JSON.stringify(body) });
3079
+ return validateResponse(CharacterSubmitSchema, raw, path40.slice(1));
3080
3080
  }
3081
3081
  /** A text edit of an existing character, applied to every direction and stored as a sibling. */
3082
3082
  async createCharacterState(args) {
@@ -4413,10 +4413,10 @@ var import_node_fs = require("fs");
4413
4413
  function sha256(data) {
4414
4414
  return (0, import_node_crypto.createHash)("sha256").update(data).digest("hex");
4415
4415
  }
4416
- async function sha256File(path39) {
4416
+ async function sha256File(path40) {
4417
4417
  return new Promise((resolve, reject) => {
4418
4418
  const hash = (0, import_node_crypto.createHash)("sha256");
4419
- const stream = (0, import_node_fs.createReadStream)(path39);
4419
+ const stream = (0, import_node_fs.createReadStream)(path40);
4420
4420
  stream.on("data", (chunk2) => hash.update(chunk2));
4421
4421
  stream.on("error", reject);
4422
4422
  stream.on("end", () => resolve(hash.digest("hex")));
@@ -8235,9 +8235,9 @@ var RetroDiffusionClient = class {
8235
8235
  if (!response.ok) throw new ProviderError("retrodiffusion", `Retro Diffusion download failed (${response.status})`, { status: response.status });
8236
8236
  return Buffer.from(await response.arrayBuffer());
8237
8237
  }
8238
- async call(path39, init = {}) {
8238
+ async call(path40, init = {}) {
8239
8239
  if (!this.token) throw new Error("RD_API_KEY is not set");
8240
- const response = await this.request(`${this.baseUrl}${path39}`, {
8240
+ const response = await this.request(`${this.baseUrl}${path40}`, {
8241
8241
  ...init,
8242
8242
  headers: {
8243
8243
  "Content-Type": "application/json",
@@ -10747,7 +10747,7 @@ function pixelkilnVersion() {
10747
10747
  }
10748
10748
 
10749
10749
  // src/manifest.ts
10750
- async function loadManifest(manifestPath) {
10750
+ async function loadManifest(manifestPath, opts = {}) {
10751
10751
  const abs = import_node_path8.default.resolve(manifestPath);
10752
10752
  if (!(0, import_node_fs9.existsSync)(abs)) throw new ProjectError(`No manifest at ${abs}`);
10753
10753
  const expansion = expandLoopDirections(JSON.parse(await (0, import_promises5.readFile)(abs, "utf8")));
@@ -10755,6 +10755,63 @@ async function loadManifest(manifestPath) {
10755
10755
  throw new ProjectError(`Manifest at ${abs} is invalid:
10756
10756
  ${expansion.issues.map((i) => ` ${i}`).join("\n")}`);
10757
10757
  }
10758
+ if (!opts.lenient) return loadExpanded(abs, expansion);
10759
+ const invalid = [];
10760
+ const raw = pruneInvalidEntries(expansion.raw, invalid);
10761
+ for (let round2 = 0; ; round2++) {
10762
+ try {
10763
+ const loaded = await loadExpanded(abs, { ...expansion, raw });
10764
+ return invalid.length ? { ...loaded, invalid } : loaded;
10765
+ } catch (error) {
10766
+ const culprits = round2 < 50 && error instanceof ProjectError ? culpritEntries(error.message) : [];
10767
+ const fresh = culprits.filter((entry) => dropEntry(raw, entry));
10768
+ if (!fresh.length) throw error;
10769
+ invalid.push(...fresh);
10770
+ }
10771
+ }
10772
+ }
10773
+ function entryRecord(raw, kind) {
10774
+ const record = raw?.[kind === "style" ? "styles" : "assets"];
10775
+ return record && typeof record === "object" && !Array.isArray(record) ? record : null;
10776
+ }
10777
+ function dropEntry(raw, entry) {
10778
+ const record = entryRecord(raw, entry.kind);
10779
+ if (!record || !(entry.id in record)) return false;
10780
+ delete record[entry.id];
10781
+ return true;
10782
+ }
10783
+ function pruneInvalidEntries(raw, invalid) {
10784
+ for (const [kind, schema] of [["style", StyleInputSchema], ["asset", AssetSchema]]) {
10785
+ const record = entryRecord(raw, kind);
10786
+ if (!record) continue;
10787
+ for (const [id, value] of Object.entries(record)) {
10788
+ const parsed = schema.safeParse(value);
10789
+ if (parsed.success) continue;
10790
+ const prefix = `${kind === "style" ? "styles" : "assets"}.${id}`;
10791
+ const lines = flattenManifestIssues(parsed.error.issues).lines.map((line) => {
10792
+ const [fieldPath, ...rest] = line.trim().split(": ");
10793
+ return `${prefix}${fieldPath === "(manifest)" || !fieldPath ? "" : `.${fieldPath}`}: ${rest.join(": ")}`;
10794
+ });
10795
+ invalid.push({ kind, id, issues: lines.length ? lines : [`${prefix}: invalid`] });
10796
+ delete record[id];
10797
+ }
10798
+ }
10799
+ return raw;
10800
+ }
10801
+ function culpritEntries(message6) {
10802
+ const found = /* @__PURE__ */ new Map();
10803
+ for (const line of message6.split("\n")) {
10804
+ const match = /^ {2}(assets|styles)\.([^.:\s]+)[.:]/.exec(line);
10805
+ if (!match) continue;
10806
+ const kind = match[1] === "styles" ? "style" : "asset";
10807
+ const key = `${kind}:${match[2]}`;
10808
+ const entry = found.get(key) ?? { kind, id: match[2], issues: [] };
10809
+ entry.issues.push(line.trim());
10810
+ found.set(key, entry);
10811
+ }
10812
+ return [...found.values()];
10813
+ }
10814
+ async function loadExpanded(abs, expansion) {
10758
10815
  const input = ManifestInputSchema.safeParse(expansion.raw);
10759
10816
  if (!input.success) {
10760
10817
  const issues = formatManifestIssues(input.error.issues);
@@ -11689,7 +11746,16 @@ async function resolveSpecs(loaded, filter) {
11689
11746
  if (!emitStyles.has(styleId)) continue;
11690
11747
  for (const assetId of Object.keys(manifest.assets)) {
11691
11748
  if (!requestedAssetIds.has(assetId) || !styleSpecs.has(assetId)) continue;
11692
- specs.push(await finalize(assetId));
11749
+ if (!filter?.onInvalid) {
11750
+ specs.push(await finalize(assetId));
11751
+ continue;
11752
+ }
11753
+ try {
11754
+ specs.push(await finalize(assetId));
11755
+ } catch (error) {
11756
+ const message6 = error instanceof Error ? error.message : String(error);
11757
+ filter.onInvalid({ kind: "asset", id: assetId, issues: [message6] });
11758
+ }
11693
11759
  }
11694
11760
  }
11695
11761
  const byOutput = /* @__PURE__ */ new Map();
@@ -13962,8 +14028,14 @@ async function openProject(manifestPath = "pixelkiln.manifest.json", opts = {})
13962
14028
  if (import_node_path16.default.resolve(process.cwd()) !== root) loadEnvFiles(process.cwd());
13963
14029
  }
13964
14030
  const lockPath = import_node_path16.default.resolve(opts.lockPath ?? import_node_path16.default.join(root, "pixelkiln.lock.json"));
13965
- const loaded = await loadManifest(absolute);
13966
- const specs = await resolveSpecs(loaded, { styles: opts.styles ?? [], assets: opts.assets ?? [] });
14031
+ let loaded = await loadManifest(absolute, { lenient: opts.lenient });
14032
+ const unresolved = [];
14033
+ const specs = await resolveSpecs(loaded, {
14034
+ styles: opts.styles ?? [],
14035
+ assets: opts.assets ?? [],
14036
+ ...opts.lenient ? { onInvalid: (entry) => unresolved.push(entry) } : {}
14037
+ });
14038
+ if (unresolved.length) loaded = { ...loaded, invalid: [...loaded.invalid ?? [], ...unresolved] };
13967
14039
  const lock = await loadLock(lockPath);
13968
14040
  normalizeLockOutputPaths(lock, specs);
13969
14041
  const adapters = /* @__PURE__ */ new Map();
@@ -14974,10 +15046,10 @@ function isSha256Hash(value) {
14974
15046
  function parseCache(value) {
14975
15047
  return HashCacheSchema.parse(value);
14976
15048
  }
14977
- async function loadCache(path39) {
14978
- if (!(0, import_node_fs17.existsSync)(path39)) return { version: 1, hashes: {} };
15049
+ async function loadCache(path40) {
15050
+ if (!(0, import_node_fs17.existsSync)(path40)) return { version: 1, hashes: {} };
14979
15051
  try {
14980
- const parsed = HashCacheSchema.safeParse(JSON.parse(await (0, import_promises12.readFile)(path39, "utf8")));
15052
+ const parsed = HashCacheSchema.safeParse(JSON.parse(await (0, import_promises12.readFile)(path40, "utf8")));
14981
15053
  if (!parsed.success) return { version: 1, hashes: {} };
14982
15054
  return {
14983
15055
  version: 1,
@@ -14989,18 +15061,18 @@ async function loadCache(path39) {
14989
15061
  return { version: 1, hashes: {} };
14990
15062
  }
14991
15063
  }
14992
- async function saveCache(path39, cache) {
15064
+ async function saveCache(path40, cache) {
14993
15065
  const sorted = {};
14994
15066
  for (const key of Object.keys(cache.hashes).sort()) {
14995
15067
  const hash = cache.hashes[key];
14996
15068
  if (!isSha256Hash(hash)) throw new Error(`Refusing to cache invalid SHA-256 for ${key}`);
14997
15069
  sorted[key] = hash;
14998
15070
  }
14999
- await (0, import_promises12.mkdir)(import_node_path20.default.dirname(import_node_path20.default.resolve(path39)), { recursive: true });
15000
- const tmp = `${path39}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
15071
+ await (0, import_promises12.mkdir)(import_node_path20.default.dirname(import_node_path20.default.resolve(path40)), { recursive: true });
15072
+ const tmp = `${path40}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
15001
15073
  try {
15002
15074
  await (0, import_promises12.writeFile)(tmp, JSON.stringify({ version: 1, hashes: sorted }, null, 2) + "\n");
15003
- await (0, import_promises12.rename)(tmp, path39);
15075
+ await (0, import_promises12.rename)(tmp, path40);
15004
15076
  } finally {
15005
15077
  await (0, import_promises12.rm)(tmp, { force: true });
15006
15078
  }
@@ -16780,9 +16852,81 @@ async function poll(provider, lock, lockPath, opts = {}) {
16780
16852
  }
16781
16853
 
16782
16854
  // src/pipeline/doctor.ts
16783
- var import_node_fs22 = require("fs");
16855
+ var import_node_fs23 = require("fs");
16784
16856
  var import_promises15 = require("fs/promises");
16857
+ var import_node_path26 = __toESM(require("path"), 1);
16858
+
16859
+ // src/pipeline/install-check.ts
16860
+ var import_node_fs22 = require("fs");
16785
16861
  var import_node_path25 = __toESM(require("path"), 1);
16862
+ function readJson(file) {
16863
+ try {
16864
+ return JSON.parse((0, import_node_fs22.readFileSync)(file, "utf8"));
16865
+ } catch {
16866
+ return null;
16867
+ }
16868
+ }
16869
+ function readInstallFacts(manifestDir, running) {
16870
+ let dir = import_node_path25.default.resolve(manifestDir);
16871
+ for (let depth = 0; depth < 4; depth++) {
16872
+ const pkg = readJson(import_node_path25.default.join(dir, "package.json"));
16873
+ if (pkg) {
16874
+ const pinned = ["dependencies", "devDependencies", "optionalDependencies"].map((field) => pkg[field]?.pixelkiln).find((spec) => typeof spec === "string");
16875
+ if (pinned) {
16876
+ const installedPkg = readJson(import_node_path25.default.join(dir, "node_modules", "pixelkiln", "package.json"));
16877
+ const installed = typeof installedPkg?.version === "string" ? installedPkg.version : void 0;
16878
+ return { pinned, installed, running };
16879
+ }
16880
+ }
16881
+ const parent = import_node_path25.default.dirname(dir);
16882
+ if (parent === dir || !(0, import_node_fs22.existsSync)(parent)) break;
16883
+ dir = parent;
16884
+ }
16885
+ return null;
16886
+ }
16887
+ function parse(version) {
16888
+ const match = /(\d+)\.(\d+)\.(\d+)/.exec(version);
16889
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
16890
+ }
16891
+ function compare(a, b) {
16892
+ return a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
16893
+ }
16894
+ function checkInstall(facts) {
16895
+ const findings = [];
16896
+ const pin = parse(facts.pinned ?? "");
16897
+ const installed = facts.installed ? parse(facts.installed) : null;
16898
+ const running = facts.running ? parse(facts.running) : null;
16899
+ const exact = /^[=v]*\d+\.\d+\.\d+$/.test((facts.pinned ?? "").trim());
16900
+ if (pin && facts.installed && installed) {
16901
+ const behind = exact ? compare(installed, pin) !== 0 : compare(installed, pin) < 0;
16902
+ if (behind) {
16903
+ findings.push({
16904
+ level: "warning",
16905
+ message: `package.json asks for pixelkiln ${facts.pinned} but node_modules has ${facts.installed}; run \`npm install\` so the CLI matches the manifest.`
16906
+ });
16907
+ }
16908
+ } else if (pin && !facts.installed) {
16909
+ findings.push({
16910
+ level: "warning",
16911
+ message: `package.json asks for pixelkiln ${facts.pinned} but it is not installed in node_modules; run \`npm install\`.`
16912
+ });
16913
+ }
16914
+ if (running && installed && compare(running, installed) !== 0) {
16915
+ findings.push({
16916
+ level: "warning",
16917
+ 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.`
16918
+ });
16919
+ }
16920
+ if (!findings.length) {
16921
+ findings.push({
16922
+ level: "ok",
16923
+ message: `pixelkiln ${facts.running ?? facts.installed ?? "?"} matches package.json (${facts.pinned})`
16924
+ });
16925
+ }
16926
+ return findings;
16927
+ }
16928
+
16929
+ // src/pipeline/doctor.ts
16786
16930
  async function doctor(loaded, specs, lock, lockPath, opts = {}) {
16787
16931
  const checks = [];
16788
16932
  const add = (id, level, message6) => checks.push({ id, level, message: message6 });
@@ -16791,16 +16935,25 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
16791
16935
  "ok",
16792
16936
  `${Object.keys(loaded.manifest.styles).length} style(s), ${Object.keys(loaded.manifest.assets).length} asset(s), ${specs.length} resolved spec(s)`
16793
16937
  );
16938
+ for (const entry of loaded.invalid ?? []) {
16939
+ add(
16940
+ "invalid-entry",
16941
+ "error",
16942
+ `${entry.kind === "style" ? "styles" : "assets"}.${entry.id} was left out: ${entry.issues.join("; ")}`
16943
+ );
16944
+ }
16945
+ const facts = readInstallFacts(import_node_path26.default.dirname(loaded.path), opts.runningVersion !== void 0 ? opts.runningVersion : pixelkilnVersion());
16946
+ if (facts) for (const finding of checkInstall(facts)) add("install", finding.level, finding.message);
16794
16947
  add("lock", "ok", `${Object.keys(lock.entries).length} valid v2 lock entr(ies)`);
16795
16948
  const dirs = [...new Set(specs.flatMap((spec) => [
16796
- import_node_path25.default.dirname(spec.outFile),
16797
- ...spec.quality ? [import_node_path25.default.dirname(spec.quality.outFile)] : []
16949
+ import_node_path26.default.dirname(spec.outFile),
16950
+ ...spec.quality ? [import_node_path26.default.dirname(spec.quality.outFile)] : []
16798
16951
  ]))];
16799
16952
  const unwritable = [];
16800
16953
  for (const dir of dirs) {
16801
16954
  const ancestor = await nearestExistingDirectory(dir);
16802
16955
  try {
16803
- await (0, import_promises15.access)(ancestor, import_node_fs22.constants.W_OK);
16956
+ await (0, import_promises15.access)(ancestor, import_node_fs23.constants.W_OK);
16804
16957
  } catch {
16805
16958
  unwritable.push(dir);
16806
16959
  }
@@ -16817,7 +16970,7 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
16817
16970
  for (let index = 0; index < entry.outputs.length; index++) {
16818
16971
  const output = entry.outputs[index];
16819
16972
  const spec = specByKey.get(key);
16820
- const absolute = spec ? currentEntryOutputPath(entry, spec, index) : resolveOutputPath(output.path, import_node_path25.default.dirname(lockPath));
16973
+ const absolute = spec ? currentEntryOutputPath(entry, spec, index) : resolveOutputPath(output.path, import_node_path26.default.dirname(lockPath));
16821
16974
  const owner = outputOwners.get(absolute);
16822
16975
  if (owner && owner !== key) duplicateOutputs.push(`${output.path} (${owner}, ${key})`);
16823
16976
  outputOwners.set(absolute, key);
@@ -16832,7 +16985,7 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
16832
16985
  } else {
16833
16986
  add("lock-outputs", "ok", `${outputOwners.size} recorded output path(s) are uniquely owned`);
16834
16987
  }
16835
- const cacheDir = import_node_path25.default.join(import_node_path25.default.dirname(lockPath), ".pixelkiln", "cache");
16988
+ const cacheDir = import_node_path26.default.join(import_node_path26.default.dirname(lockPath), ".pixelkiln", "cache");
16836
16989
  const stranded = [];
16837
16990
  const invalidState = [];
16838
16991
  const staleMapUrls = [];
@@ -16848,11 +17001,11 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
16848
17001
  const hasSource = Boolean(entry.sourceUrl || entry.sourceUrls?.length);
16849
17002
  let hasCache = false;
16850
17003
  for (const output of entry.outputs) {
16851
- const cached2 = import_node_path25.default.join(
17004
+ const cached2 = import_node_path26.default.join(
16852
17005
  cacheDir,
16853
17006
  cacheFileName(output.sha256, output.mediaType ?? MediaType.PNG)
16854
17007
  );
16855
- if ((0, import_node_fs22.existsSync)(cached2) && await sha256File(cached2) === output.sha256) {
17008
+ if ((0, import_node_fs23.existsSync)(cached2) && await sha256File(cached2) === output.sha256) {
16856
17009
  hasCache = true;
16857
17010
  break;
16858
17011
  }
@@ -16948,16 +17101,16 @@ async function nearestExistingDirectory(start) {
16948
17101
  if ((await (0, import_promises15.stat)(current)).isDirectory()) return current;
16949
17102
  } catch {
16950
17103
  }
16951
- const parent = import_node_path25.default.dirname(current);
17104
+ const parent = import_node_path26.default.dirname(current);
16952
17105
  if (parent === current) return current;
16953
17106
  current = parent;
16954
17107
  }
16955
17108
  }
16956
17109
 
16957
17110
  // src/pipeline/adopt.ts
16958
- var import_node_fs23 = require("fs");
17111
+ var import_node_fs24 = require("fs");
16959
17112
  var import_promises16 = require("fs/promises");
16960
- var import_node_path26 = __toESM(require("path"), 1);
17113
+ var import_node_path27 = __toESM(require("path"), 1);
16961
17114
  async function adopt(provider, specs, lock, lockPath, opts = {}) {
16962
17115
  const log = opts.onProgress ?? (() => {
16963
17116
  });
@@ -16968,7 +17121,7 @@ async function adopt(provider, specs, lock, lockPath, opts = {}) {
16968
17121
  const localByHash = /* @__PURE__ */ new Map();
16969
17122
  const unmatchedLocal = [];
16970
17123
  for (const spec of specs) {
16971
- if (!(0, import_node_fs23.existsSync)(spec.outFile)) {
17124
+ if (!(0, import_node_fs24.existsSync)(spec.outFile)) {
16972
17125
  unmatchedLocal.push(`${spec.styleId}/${spec.assetId} (no file at ${spec.outFile})`);
16973
17126
  continue;
16974
17127
  }
@@ -17090,7 +17243,7 @@ async function tagAdopted(provider, specs, lock, opts = {}) {
17090
17243
  }
17091
17244
 
17092
17245
  // src/pipeline/import.ts
17093
- var import_node_fs24 = require("fs");
17246
+ var import_node_fs25 = require("fs");
17094
17247
  var import_promises17 = require("fs/promises");
17095
17248
  function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Date()) {
17096
17249
  const png = decodePng(bytes);
@@ -17143,7 +17296,7 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
17143
17296
  skipped.push({ key, reason });
17144
17297
  continue;
17145
17298
  }
17146
- if (!(0, import_node_fs24.existsSync)(spec.outFile)) {
17299
+ if (!(0, import_node_fs25.existsSync)(spec.outFile)) {
17147
17300
  skipped.push({ key, reason: `no file at ${spec.outFile}` });
17148
17301
  continue;
17149
17302
  }
@@ -17172,7 +17325,7 @@ async function reportSpecHashes(specs, lock) {
17172
17325
  for (const spec of specs) {
17173
17326
  const key = lockKey(spec.styleId, spec.assetId);
17174
17327
  let bytes = null;
17175
- if ((0, import_node_fs24.existsSync)(spec.outFile)) bytes = await (0, import_promises17.readFile)(spec.outFile);
17328
+ if ((0, import_node_fs25.existsSync)(spec.outFile)) bytes = await (0, import_promises17.readFile)(spec.outFile);
17176
17329
  let wouldImport = null;
17177
17330
  if (bytes && !unimportable(spec)) {
17178
17331
  try {
@@ -17201,13 +17354,13 @@ async function reportSpecHashes(specs, lock) {
17201
17354
  }
17202
17355
 
17203
17356
  // src/pick/server.ts
17204
- var import_node_fs26 = require("fs");
17357
+ var import_node_fs27 = require("fs");
17205
17358
  var import_promises20 = require("fs/promises");
17206
17359
 
17207
17360
  // src/pipeline/init.ts
17208
17361
  var import_promises18 = require("fs/promises");
17209
- var import_node_fs25 = require("fs");
17210
- var import_node_path27 = __toESM(require("path"), 1);
17362
+ var import_node_fs26 = require("fs");
17363
+ var import_node_path28 = __toESM(require("path"), 1);
17211
17364
  function pngSize(buf) {
17212
17365
  if (buf.length < 24) return null;
17213
17366
  const isPng = buf.readUInt32BE(0) === 2303741511 && buf.readUInt32BE(4) === 218765834;
@@ -17221,7 +17374,7 @@ function slugify(value) {
17221
17374
  async function walk(dir, exclude) {
17222
17375
  const out = [];
17223
17376
  for (const entry of await (0, import_promises18.readdir)(dir, { withFileTypes: true })) {
17224
- const full = import_node_path27.default.join(dir, entry.name);
17377
+ const full = import_node_path28.default.join(dir, entry.name);
17225
17378
  if (exclude.some((x) => full.includes(x))) continue;
17226
17379
  if (entry.isDirectory()) out.push(...await walk(full, exclude));
17227
17380
  else if (entry.name.toLowerCase().endsWith(".png")) out.push(full);
@@ -17240,9 +17393,9 @@ async function scanAssets(root, opts = {}) {
17240
17393
  skipped.push(`${file} (not a readable PNG)`);
17241
17394
  continue;
17242
17395
  }
17243
- const rel = import_node_path27.default.relative(root, file);
17244
- const category = import_node_path27.default.dirname(rel) === "." ? "" : import_node_path27.default.dirname(rel);
17245
- let id = slugify(import_node_path27.default.basename(rel));
17396
+ const rel = import_node_path28.default.relative(root, file);
17397
+ const category = import_node_path28.default.dirname(rel) === "." ? "" : import_node_path28.default.dirname(rel);
17398
+ let id = slugify(import_node_path28.default.basename(rel));
17246
17399
  if (seen.has(id)) {
17247
17400
  const n = seen.get(id) + 1;
17248
17401
  seen.set(id, n);
@@ -17801,7 +17954,7 @@ async function currentArt(entry, spec) {
17801
17954
  const previous = primaryOutput({ ...entry, outputs: entry.supersededOutputs });
17802
17955
  if (!previous) return null;
17803
17956
  const file = resolveOutputPath(previous.path, spec.root);
17804
- if (!(0, import_node_fs26.existsSync)(file)) return null;
17957
+ if (!(0, import_node_fs27.existsSync)(file)) return null;
17805
17958
  const contentType = previous.mediaType ?? mediaTypeFromExtension(file);
17806
17959
  if (!contentType) return null;
17807
17960
  let width = entry.width;
@@ -18001,14 +18154,14 @@ async function runPicker(provider, lock, lockPath, opts = {}) {
18001
18154
 
18002
18155
  // src/gallery/snapshot.ts
18003
18156
  var import_node_crypto7 = require("crypto");
18004
- var import_node_fs32 = require("fs");
18157
+ var import_node_fs33 = require("fs");
18005
18158
  var import_promises28 = require("fs/promises");
18006
- var import_node_path35 = __toESM(require("path"), 1);
18159
+ var import_node_path36 = __toESM(require("path"), 1);
18007
18160
 
18008
18161
  // src/workspace.ts
18009
18162
  var import_promises21 = require("fs/promises");
18010
- var import_node_fs27 = require("fs");
18011
- var import_node_path28 = __toESM(require("path"), 1);
18163
+ var import_node_fs28 = require("fs");
18164
+ var import_node_path29 = __toESM(require("path"), 1);
18012
18165
  var import_zod7 = require("zod");
18013
18166
  var WorkspaceProjectSchema = import_zod7.z.object({
18014
18167
  id: import_zod7.z.string().min(1),
@@ -18033,7 +18186,7 @@ ${parsed.error.issues.slice(0, 5).map((i) => ` ${i.path.join(".")}: ${i.message
18033
18186
  );
18034
18187
  }
18035
18188
  async function loadWorkspace(workspacePath) {
18036
- if (!(0, import_node_fs27.existsSync)(workspacePath)) return { version: 1, projects: [] };
18189
+ if (!(0, import_node_fs28.existsSync)(workspacePath)) return { version: 1, projects: [] };
18037
18190
  let raw;
18038
18191
  try {
18039
18192
  raw = JSON.parse(await (0, import_promises21.readFile)(workspacePath, "utf8"));
@@ -18050,7 +18203,7 @@ async function saveWorkspace(workspacePath, ws) {
18050
18203
  version: 1,
18051
18204
  projects: [...ws.projects].sort((a, b) => a.id.localeCompare(b.id))
18052
18205
  };
18053
- await (0, import_promises21.mkdir)(import_node_path28.default.dirname(import_node_path28.default.resolve(workspacePath)), { recursive: true });
18206
+ await (0, import_promises21.mkdir)(import_node_path29.default.dirname(import_node_path29.default.resolve(workspacePath)), { recursive: true });
18054
18207
  const tmp = `${workspacePath}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
18055
18208
  try {
18056
18209
  await (0, import_promises21.writeFile)(tmp, JSON.stringify(sorted, null, 2) + "\n");
@@ -18060,12 +18213,12 @@ async function saveWorkspace(workspacePath, ws) {
18060
18213
  }
18061
18214
  }
18062
18215
  function toPortablePath(dir, absolute) {
18063
- return import_node_path28.default.relative(dir, absolute).split(import_node_path28.default.sep).join("/");
18216
+ return import_node_path29.default.relative(dir, absolute).split(import_node_path29.default.sep).join("/");
18064
18217
  }
18065
18218
  function resolveProject(dir, project) {
18066
18219
  return {
18067
- manifestPath: import_node_path28.default.resolve(dir, project.manifest.split("/").join(import_node_path28.default.sep)),
18068
- lockPath: import_node_path28.default.resolve(dir, project.lock.split("/").join(import_node_path28.default.sep))
18220
+ manifestPath: import_node_path29.default.resolve(dir, project.manifest.split("/").join(import_node_path29.default.sep)),
18221
+ lockPath: import_node_path29.default.resolve(dir, project.lock.split("/").join(import_node_path29.default.sep))
18069
18222
  };
18070
18223
  }
18071
18224
  function validateWorkspace(ws, dir) {
@@ -18078,21 +18231,21 @@ function validateWorkspace(ws, dir) {
18078
18231
  const { manifestPath, lockPath } = resolveProject(dir, project);
18079
18232
  lockOwners.set(lockPath, [...lockOwners.get(lockPath) ?? [], project.id]);
18080
18233
  manifestOwners.set(manifestPath, [...manifestOwners.get(manifestPath) ?? [], project.id]);
18081
- if (import_node_path28.default.isAbsolute(project.manifest) || import_node_path28.default.isAbsolute(project.lock)) {
18234
+ if (import_node_path29.default.isAbsolute(project.manifest) || import_node_path29.default.isAbsolute(project.lock)) {
18082
18235
  diagnostics.push({
18083
18236
  id: "absolute-path",
18084
18237
  level: "warning",
18085
18238
  message: `project "${project.id}" stores an absolute path; the catalog will not resolve correctly if this tree is cloned or moved elsewhere`
18086
18239
  });
18087
18240
  }
18088
- if (!(0, import_node_fs27.existsSync)(manifestPath)) {
18241
+ if (!(0, import_node_fs28.existsSync)(manifestPath)) {
18089
18242
  diagnostics.push({
18090
18243
  id: "missing-manifest",
18091
18244
  level: "error",
18092
18245
  message: `project "${project.id}" manifest not found: ${manifestPath}`
18093
18246
  });
18094
18247
  }
18095
- if (!(0, import_node_fs27.existsSync)(lockPath)) {
18248
+ if (!(0, import_node_fs28.existsSync)(lockPath)) {
18096
18249
  diagnostics.push({
18097
18250
  id: "missing-lock",
18098
18251
  level: "error",
@@ -18140,15 +18293,15 @@ function validateWorkspace(ws, dir) {
18140
18293
 
18141
18294
  // src/gallery/edit.ts
18142
18295
  var import_promises27 = require("fs/promises");
18143
- var import_node_path34 = __toESM(require("path"), 1);
18296
+ var import_node_path35 = __toESM(require("path"), 1);
18144
18297
  var import_zod13 = require("zod");
18145
18298
 
18146
18299
  // src/manifest-edit.ts
18147
18300
  var import_promises22 = require("fs/promises");
18148
- var import_node_path29 = __toESM(require("path"), 1);
18301
+ var import_node_path30 = __toESM(require("path"), 1);
18149
18302
  var import_zod8 = require("zod");
18150
18303
  var HexSha = import_zod8.z.string().regex(/^[0-9a-f]{64}$/);
18151
- var ProjectFileSchema = import_zod8.z.string().min(1).refine((file) => !import_node_path29.default.isAbsolute(file) && !file.split(/[\\/]/).includes(".."), "must be a path inside the project");
18304
+ var ProjectFileSchema = import_zod8.z.string().min(1).refine((file) => !import_node_path30.default.isAbsolute(file) && !file.split(/[\\/]/).includes(".."), "must be a path inside the project");
18152
18305
  var AssetPatchSchema = import_zod8.z.object({
18153
18306
  prompt: import_zod8.z.string().optional(),
18154
18307
  /** Per-style override for the style being viewed; null removes it. */
@@ -18568,7 +18721,7 @@ function applyEdit(raw, edit) {
18568
18721
  }
18569
18722
  }
18570
18723
  async function withCandidate(manifestPath, edit, use, unchanged) {
18571
- const absolute = import_node_path29.default.resolve(manifestPath);
18724
+ const absolute = import_node_path30.default.resolve(manifestPath);
18572
18725
  const original = await (0, import_promises22.readFile)(absolute, "utf8");
18573
18726
  if (sha256(original) !== edit.expectedSha256) throw new ManifestDriftError(absolute);
18574
18727
  let raw;
@@ -18582,9 +18735,9 @@ async function withCandidate(manifestPath, edit, use, unchanged) {
18582
18735
  applyEdit(raw, edit);
18583
18736
  const next = serializeLike(original, raw);
18584
18737
  if (next === original) return unchanged(absolute, original);
18585
- const tmp = import_node_path29.default.join(
18586
- import_node_path29.default.dirname(absolute),
18587
- `.${import_node_path29.default.basename(absolute)}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`
18738
+ const tmp = import_node_path30.default.join(
18739
+ import_node_path30.default.dirname(absolute),
18740
+ `.${import_node_path30.default.basename(absolute)}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`
18588
18741
  );
18589
18742
  try {
18590
18743
  await (0, import_promises22.writeFile)(tmp, next);
@@ -18613,18 +18766,18 @@ async function applyManifestEdit(manifestPath, edit) {
18613
18766
  }
18614
18767
 
18615
18768
  // src/pipeline/hand-edit.ts
18616
- var import_node_fs28 = require("fs");
18769
+ var import_node_fs29 = require("fs");
18617
18770
  var import_promises23 = require("fs/promises");
18618
- var import_node_path30 = __toESM(require("path"), 1);
18771
+ var import_node_path31 = __toESM(require("path"), 1);
18619
18772
  var import_zod9 = require("zod");
18620
18773
  var HAND_EDIT_DIR = "edits";
18621
18774
  function handEditPath(loaded, spec) {
18622
18775
  const style = loaded.manifest.styles[spec.styleId];
18623
- const outDir = import_node_path30.default.resolve(loaded.root, style?.outDir ?? ".");
18624
- const relative = import_node_path30.default.relative(outDir, spec.outFile);
18625
- const inside = relative && !relative.startsWith("..") && !import_node_path30.default.isAbsolute(relative);
18626
- const file = inside ? relative : import_node_path30.default.basename(spec.outFile);
18627
- return import_node_path30.default.join(outDir, HAND_EDIT_DIR, file.replace(/\.gif$/i, ".png"));
18776
+ const outDir = import_node_path31.default.resolve(loaded.root, style?.outDir ?? ".");
18777
+ const relative = import_node_path31.default.relative(outDir, spec.outFile);
18778
+ const inside = relative && !relative.startsWith("..") && !import_node_path31.default.isAbsolute(relative);
18779
+ const file = inside ? relative : import_node_path31.default.basename(spec.outFile);
18780
+ return import_node_path31.default.join(outDir, HAND_EDIT_DIR, file.replace(/\.gif$/i, ".png"));
18628
18781
  }
18629
18782
  function handEditBases(spec, lock) {
18630
18783
  const entry = lock.entries[lockKey(spec.styleId, spec.assetId)];
@@ -18637,10 +18790,10 @@ function handEditBases(spec, lock) {
18637
18790
  }));
18638
18791
  if (members.some((member) => member.mediaType && member.mediaType !== "image/png")) return null;
18639
18792
  if (entry.outputs.length === 1 && !primaryOutput(entry)) return null;
18640
- if (!members.every((member) => (0, import_node_fs28.existsSync)(member.path))) return null;
18793
+ if (!members.every((member) => (0, import_node_fs29.existsSync)(member.path))) return null;
18641
18794
  return members.map(({ role, path: file }) => ({ role, path: file }));
18642
18795
  }
18643
- return (0, import_node_fs28.existsSync)(spec.outFile) ? [{ role: null, path: spec.outFile }] : null;
18796
+ return (0, import_node_fs29.existsSync)(spec.outFile) ? [{ role: null, path: spec.outFile }] : null;
18644
18797
  }
18645
18798
  function handEditBase(spec, lock) {
18646
18799
  const bases = handEditBases(spec, lock);
@@ -18670,18 +18823,18 @@ async function startHandEdit(loaded, lock, spec, opts = {}) {
18670
18823
  `${spec.styleId}/${spec.assetId} declares ${spec.source}, one committed file placed for the whole set; clear that source (pixelkiln edit detach) to hand-edit the members one by one`
18671
18824
  );
18672
18825
  }
18673
- const existing = spec.source ? import_node_path30.default.resolve(loaded.root, spec.source) : null;
18826
+ const existing = spec.source ? import_node_path31.default.resolve(loaded.root, spec.source) : null;
18674
18827
  const editPath = existing ?? handEditPath(loaded, spec);
18675
18828
  const members = handEditMembers(loaded, spec, lock, editPath);
18676
18829
  let created = false;
18677
18830
  for (const member of members) {
18678
- if ((0, import_node_fs28.existsSync)(member.path)) continue;
18831
+ if ((0, import_node_fs29.existsSync)(member.path)) continue;
18679
18832
  if (!member.base) {
18680
18833
  throw new ManifestEditError(
18681
18834
  `${spec.styleId}/${spec.assetId} has no generated PNG on disk to start from; generate or restore it first`
18682
18835
  );
18683
18836
  }
18684
- await (0, import_promises23.mkdir)(import_node_path30.default.dirname(member.path), { recursive: true });
18837
+ await (0, import_promises23.mkdir)(import_node_path31.default.dirname(member.path), { recursive: true });
18685
18838
  await (0, import_promises23.copyFile)(member.base, member.path);
18686
18839
  created = true;
18687
18840
  }
@@ -18819,7 +18972,7 @@ async function saveHandEdit(loaded, lock, spec, input) {
18819
18972
  editor: input.editor,
18820
18973
  protocol: input.protocol,
18821
18974
  savedAt: (input.now ?? /* @__PURE__ */ new Date()).toISOString(),
18822
- project: projectPath ? import_node_path30.default.basename(projectPath) : null,
18975
+ project: projectPath ? import_node_path31.default.basename(projectPath) : null,
18823
18976
  outputs: incoming.map((frame, index) => ({
18824
18977
  role: frame.role,
18825
18978
  basedOn: basedOnHash(entry, index),
@@ -18861,9 +19014,9 @@ function openInEditor(file, editor = process.env.PIXELKILN_EDITOR) {
18861
19014
  }
18862
19015
 
18863
19016
  // src/gallery/upload.ts
18864
- var import_node_fs29 = require("fs");
19017
+ var import_node_fs30 = require("fs");
18865
19018
  var import_promises24 = require("fs/promises");
18866
- var import_node_path31 = __toESM(require("path"), 1);
19019
+ var import_node_path32 = __toESM(require("path"), 1);
18867
19020
  var import_zod10 = require("zod");
18868
19021
  var MAX_UPLOAD_BYTES = 8 * 1024 * 1024;
18869
19022
  var UploadImageSchema = import_zod10.z.object({
@@ -18876,12 +19029,12 @@ var UploadImageSchema = import_zod10.z.object({
18876
19029
  overwrite: import_zod10.z.boolean().optional()
18877
19030
  }).strict();
18878
19031
  async function saveProjectImage(root, request) {
18879
- const file = import_node_path31.default.resolve(root, request.path);
18880
- const relative = import_node_path31.default.relative(root, file);
18881
- if (relative.startsWith("..") || import_node_path31.default.isAbsolute(relative)) {
19032
+ const file = import_node_path32.default.resolve(root, request.path);
19033
+ const relative = import_node_path32.default.relative(root, file);
19034
+ if (relative.startsWith("..") || import_node_path32.default.isAbsolute(relative)) {
18882
19035
  throw new ManifestEditError("an upload must stay inside the project");
18883
19036
  }
18884
- const extension = import_node_path31.default.extname(file).toLowerCase();
19037
+ const extension = import_node_path32.default.extname(file).toLowerCase();
18885
19038
  const expected = extension === ".png" ? "png" : extension === ".jpg" || extension === ".jpeg" ? "jpeg" : null;
18886
19039
  if (!expected) throw new ManifestEditError("an upload must be a .png, .jpg, or .jpeg path");
18887
19040
  const bytes = Buffer.from(request.base64, "base64");
@@ -18893,18 +19046,18 @@ async function saveProjectImage(root, request) {
18893
19046
  if (metadata.format !== expected) {
18894
19047
  throw new ManifestEditError(`the upload is a ${metadata.format.toUpperCase()}; name it ${metadata.format === "png" ? ".png" : ".jpg"}`);
18895
19048
  }
18896
- if ((0, import_node_fs29.existsSync)(file) && !request.overwrite) {
18897
- throw new ManifestEditError(`${relative.split(import_node_path31.default.sep).join("/")} already exists; choose another name, or replace it`);
19049
+ if ((0, import_node_fs30.existsSync)(file) && !request.overwrite) {
19050
+ throw new ManifestEditError(`${relative.split(import_node_path32.default.sep).join("/")} already exists; choose another name, or replace it`);
18898
19051
  }
18899
- await (0, import_promises24.mkdir)(import_node_path31.default.dirname(file), { recursive: true });
19052
+ await (0, import_promises24.mkdir)(import_node_path32.default.dirname(file), { recursive: true });
18900
19053
  await (0, import_promises24.writeFile)(file, bytes);
18901
- return relative.split(import_node_path31.default.sep).join("/");
19054
+ return relative.split(import_node_path32.default.sep).join("/");
18902
19055
  }
18903
19056
 
18904
19057
  // src/gallery/image-revision.ts
18905
- var import_node_fs30 = require("fs");
19058
+ var import_node_fs31 = require("fs");
18906
19059
  var import_promises25 = require("fs/promises");
18907
- var import_node_path32 = __toESM(require("path"), 1);
19060
+ var import_node_path33 = __toESM(require("path"), 1);
18908
19061
  var import_zod11 = require("zod");
18909
19062
  var InpaintRevisionRequestSchema = import_zod11.z.object({
18910
19063
  action: import_zod11.z.literal("create-inpaint-revision"),
@@ -18923,15 +19076,15 @@ var InpaintRevisionRequestSchema = import_zod11.z.object({
18923
19076
  overwrite: import_zod11.z.boolean().optional()
18924
19077
  }).strict();
18925
19078
  async function createInpaintRevision(manifestPath, request) {
18926
- const root = import_node_path32.default.dirname(import_node_path32.default.resolve(manifestPath));
18927
- if (import_node_path32.default.extname(request.maskPath).toLowerCase() !== ".png") {
19079
+ const root = import_node_path33.default.dirname(import_node_path33.default.resolve(manifestPath));
19080
+ if (import_node_path33.default.extname(request.maskPath).toLowerCase() !== ".png") {
18928
19081
  throw new ManifestEditError("the mask must be a .png path inside the project");
18929
19082
  }
18930
19083
  const bytes = Buffer.from(request.maskBase64, "base64");
18931
19084
  const metadata = imageMetadata(bytes);
18932
19085
  if (!metadata || metadata.format !== "png") throw new ManifestEditError("the mask is not a readable PNG");
18933
- const file = import_node_path32.default.resolve(root, request.maskPath);
18934
- const previous = (0, import_node_fs30.existsSync)(file) ? await (0, import_promises25.readFile)(file) : null;
19086
+ const file = import_node_path33.default.resolve(root, request.maskPath);
19087
+ const previous = (0, import_node_fs31.existsSync)(file) ? await (0, import_promises25.readFile)(file) : null;
18935
19088
  const mask = await saveProjectImage(root, {
18936
19089
  action: "upload-image",
18937
19090
  path: request.maskPath,
@@ -18958,9 +19111,9 @@ async function createInpaintRevision(manifestPath, request) {
18958
19111
  }
18959
19112
 
18960
19113
  // src/gallery/skeleton.ts
18961
- var import_node_fs31 = require("fs");
19114
+ var import_node_fs32 = require("fs");
18962
19115
  var import_promises26 = require("fs/promises");
18963
- var import_node_path33 = __toESM(require("path"), 1);
19116
+ var import_node_path34 = __toESM(require("path"), 1);
18964
19117
  var import_zod12 = require("zod");
18965
19118
  var SkeletonEstimateRequestSchema = import_zod12.z.object({
18966
19119
  project: import_zod12.z.string().min(1).optional(),
@@ -18999,20 +19152,20 @@ var SkeletonKeypointsUpdateSchema = import_zod12.z.object({
18999
19152
  set: SkeletonSetSchema
19000
19153
  }).strict();
19001
19154
  async function createSkeletonAnimation(manifestPath, request) {
19002
- const root = import_node_path33.default.dirname(import_node_path33.default.resolve(manifestPath));
19003
- const file = import_node_path33.default.resolve(root, request.keypointsFile);
19004
- const relative = import_node_path33.default.relative(root, file);
19005
- if (!request.keypointsFile.endsWith(".json") || relative.startsWith("..") || import_node_path33.default.isAbsolute(relative)) {
19155
+ const root = import_node_path34.default.dirname(import_node_path34.default.resolve(manifestPath));
19156
+ const file = import_node_path34.default.resolve(root, request.keypointsFile);
19157
+ const relative = import_node_path34.default.relative(root, file);
19158
+ if (!request.keypointsFile.endsWith(".json") || relative.startsWith("..") || import_node_path34.default.isAbsolute(relative)) {
19006
19159
  throw new ManifestEditError("the keypoints file must be a .json path inside the project");
19007
19160
  }
19008
- const existed = (0, import_node_fs31.existsSync)(file);
19161
+ const existed = (0, import_node_fs32.existsSync)(file);
19009
19162
  let previous = null;
19010
19163
  if (request.set) {
19011
19164
  if (existed && !request.overwrite) {
19012
19165
  throw new ManifestEditError(`${request.keypointsFile} already exists; choose another path, or replace it`);
19013
19166
  }
19014
19167
  if (existed) previous = await (0, import_promises26.readFile)(file);
19015
- await (0, import_promises26.mkdir)(import_node_path33.default.dirname(file), { recursive: true });
19168
+ await (0, import_promises26.mkdir)(import_node_path34.default.dirname(file), { recursive: true });
19016
19169
  await (0, import_promises26.writeFile)(file, JSON.stringify(request.set, null, 2) + "\n");
19017
19170
  } else if (!existed) {
19018
19171
  throw new ManifestEditError(`${request.keypointsFile} does not exist; paste poses or estimate them from the sprite`);
@@ -19028,7 +19181,7 @@ async function createSkeletonAnimation(manifestPath, request) {
19028
19181
  revision: {
19029
19182
  mode: "animate-skeleton",
19030
19183
  from: request.from,
19031
- keypointsFile: relative.split(import_node_path33.default.sep).join("/"),
19184
+ keypointsFile: relative.split(import_node_path34.default.sep).join("/"),
19032
19185
  direction: request.direction,
19033
19186
  description: request.description,
19034
19187
  ...request.skeletonTemplate ? { skeletonTemplate: request.skeletonTemplate } : {}
@@ -19049,19 +19202,19 @@ async function updateSkeletonKeypoints(ctx, request) {
19049
19202
  if (!spec) throw new ManifestEditError(`"${key}" is not declared by the manifest`);
19050
19203
  const file = spec.revision?.mode === "animate-skeleton" ? spec.revision.keypointsFile : void 0;
19051
19204
  if (!file) throw new ManifestEditError(`${key} is not an animate-skeleton revision`);
19052
- const relative = import_node_path33.default.relative(ctx.loaded.root, file);
19053
- if (relative.startsWith("..") || import_node_path33.default.isAbsolute(relative)) {
19205
+ const relative = import_node_path34.default.relative(ctx.loaded.root, file);
19206
+ if (relative.startsWith("..") || import_node_path34.default.isAbsolute(relative)) {
19054
19207
  throw new ManifestEditError(`${key}'s keypoints file is outside the project; edit it by hand`);
19055
19208
  }
19056
- const current = (0, import_node_fs31.existsSync)(file) ? sha256(await (0, import_promises26.readFile)(file)) : null;
19209
+ const current = (0, import_node_fs32.existsSync)(file) ? sha256(await (0, import_promises26.readFile)(file)) : null;
19057
19210
  if (current !== request.expectedSha256) {
19058
19211
  throw Object.assign(
19059
- new Error(`${relative.split(import_node_path33.default.sep).join("/")} changed on disk since this page loaded it; press Refresh and edit again`),
19212
+ new Error(`${relative.split(import_node_path34.default.sep).join("/")} changed on disk since this page loaded it; press Refresh and edit again`),
19060
19213
  { status: 409 }
19061
19214
  );
19062
19215
  }
19063
19216
  await (0, import_promises26.writeFile)(file, JSON.stringify(request.set, null, 2) + "\n");
19064
- return relative.split(import_node_path33.default.sep).join("/");
19217
+ return relative.split(import_node_path34.default.sep).join("/");
19065
19218
  }
19066
19219
 
19067
19220
  // src/gallery/edit.ts
@@ -19115,7 +19268,7 @@ function createGalleryEditHandler(opts) {
19115
19268
  const history = /* @__PURE__ */ new Map();
19116
19269
  const manifestOf = async (project) => {
19117
19270
  try {
19118
- return import_node_path34.default.resolve(await opts.manifestFor(typeof project === "string" ? project : void 0));
19271
+ return import_node_path35.default.resolve(await opts.manifestFor(typeof project === "string" ? project : void 0));
19119
19272
  } catch {
19120
19273
  return null;
19121
19274
  }
@@ -19138,7 +19291,7 @@ function createGalleryEditHandler(opts) {
19138
19291
  await (0, import_promises27.writeFile)(tmp, last.before);
19139
19292
  await (0, import_promises27.rename)(tmp, manifestPath2);
19140
19293
  stack.pop();
19141
- log(` manifest edit undone in ${import_node_path34.default.relative(process.cwd(), manifestPath2) || manifestPath2}`);
19294
+ log(` manifest edit undone in ${import_node_path35.default.relative(process.cwd(), manifestPath2) || manifestPath2}`);
19142
19295
  return opts.reload();
19143
19296
  }
19144
19297
  const manifestPath = await manifestOf(body?.project);
@@ -19200,7 +19353,7 @@ function createEditApplier(opts, log) {
19200
19353
  } catch (error) {
19201
19354
  throw new ManifestEditError(error instanceof Error ? error.message : String(error));
19202
19355
  }
19203
- const written = await saveProjectImage(import_node_path34.default.dirname(import_node_path34.default.resolve(manifestPath2)), upload.data);
19356
+ const written = await saveProjectImage(import_node_path35.default.dirname(import_node_path35.default.resolve(manifestPath2)), upload.data);
19204
19357
  log(` image added: ${written}`);
19205
19358
  return opts.reload();
19206
19359
  }
@@ -19267,7 +19420,7 @@ function createEditApplier(opts, log) {
19267
19420
  }
19268
19421
  const result = await applyManifestEdit(manifestPath, parsed.data);
19269
19422
  if (result.changed) {
19270
- const relative = import_node_path34.default.relative(process.cwd(), result.manifestPath);
19423
+ const relative = import_node_path35.default.relative(process.cwd(), result.manifestPath);
19271
19424
  const shown = !relative || relative.startsWith("..") ? result.manifestPath : relative;
19272
19425
  log(` manifest edited: ${describeEdit(parsed.data)} in ${shown}`);
19273
19426
  }
@@ -19295,7 +19448,7 @@ function describeEdit(edit) {
19295
19448
  // src/gallery/snapshot.ts
19296
19449
  var PROJECT_FILE_TYPE = "application/octet-stream";
19297
19450
  function galleryMediaId(absolutePath) {
19298
- return (0, import_node_crypto7.createHash)("sha256").update(import_node_path35.default.resolve(absolutePath)).digest("hex").slice(0, 24);
19451
+ return (0, import_node_crypto7.createHash)("sha256").update(import_node_path36.default.resolve(absolutePath)).digest("hex").slice(0, 24);
19299
19452
  }
19300
19453
  function galleryMediaRoute(id) {
19301
19454
  return `/media/${id}`;
@@ -19319,9 +19472,9 @@ function describeHistory(media, entry, cacheDir) {
19319
19472
  return (entry.history ?? []).map((generation, i) => {
19320
19473
  const outputs = generation.outputs.map((output) => {
19321
19474
  const mediaType = output.mediaType ?? MediaType.PNG;
19322
- const file = import_node_path35.default.join(cacheDir, cacheFileName(output.sha256, mediaType));
19475
+ const file = import_node_path36.default.join(cacheDir, cacheFileName(output.sha256, mediaType));
19323
19476
  let url = null;
19324
- if ((0, import_node_fs32.existsSync)(file)) {
19477
+ if ((0, import_node_fs33.existsSync)(file)) {
19325
19478
  const id = galleryMediaId(file);
19326
19479
  media.set(id, { path: file, contentType: mediaType });
19327
19480
  url = `${galleryMediaRoute(id)}?v=${output.sha256.slice(0, 24)}`;
@@ -19451,10 +19604,10 @@ async function describeOutput(media, root, absolutePath, recorded = {}) {
19451
19604
  async function describeQuality(media, root, inspection) {
19452
19605
  const outputPaths = inspection.outputs ?? [inspection.output];
19453
19606
  const outputs = await Promise.all(
19454
- outputPaths.map((file) => describeOutput(media, root, import_node_path35.default.resolve(root, file)))
19607
+ outputPaths.map((file) => describeOutput(media, root, import_node_path36.default.resolve(root, file)))
19455
19608
  );
19456
- const recordPath = import_node_path35.default.resolve(root, inspection.record);
19457
- const recordExists = (0, import_node_fs32.existsSync)(recordPath);
19609
+ const recordPath = import_node_path36.default.resolve(root, inspection.record);
19610
+ const recordExists = (0, import_node_fs33.existsSync)(recordPath);
19458
19611
  let options = null;
19459
19612
  let check = null;
19460
19613
  if (recordExists) {
@@ -19473,7 +19626,7 @@ async function describeQuality(media, root, inspection) {
19473
19626
  return {
19474
19627
  state: inspection.state,
19475
19628
  reason: inspection.reason,
19476
- output: portableOutputPath(import_node_path35.default.resolve(root, inspection.output), root),
19629
+ output: portableOutputPath(import_node_path36.default.resolve(root, inspection.output), root),
19477
19630
  record: portableOutputPath(recordPath, root),
19478
19631
  recordExists,
19479
19632
  outputs,
@@ -19513,7 +19666,7 @@ async function buildGallerySnapshot(opts) {
19513
19666
  const items = [];
19514
19667
  const manifestText = await (0, import_promises28.readFile)(loaded.path, "utf8");
19515
19668
  const manifestSha256 = sha256(manifestText);
19516
- const cacheDir = import_node_path35.default.resolve(import_node_path35.default.dirname(opts.lockPath), ".pixelkiln", "cache");
19669
+ const cacheDir = import_node_path36.default.resolve(import_node_path36.default.dirname(opts.lockPath), ".pixelkiln", "cache");
19517
19670
  let rawStyles = {};
19518
19671
  try {
19519
19672
  const raw = JSON.parse(manifestText);
@@ -19537,12 +19690,12 @@ async function buildGallerySnapshot(opts) {
19537
19690
  )
19538
19691
  );
19539
19692
  if (spec.source) {
19540
- const editPath = import_node_path35.default.resolve(root, spec.source);
19693
+ const editPath = import_node_path36.default.resolve(root, spec.source);
19541
19694
  const memberCount = sourceIsStem(spec.source, entry, root) ? entry.outputs.length : 1;
19542
19695
  const editShas = await Promise.all(
19543
19696
  Array.from({ length: memberCount }, async (_, index) => {
19544
19697
  const file = sourceOutputPath(spec.source, entry, index, root);
19545
- return { file, sha256: (0, import_node_fs32.existsSync)(file) ? await sha256File(file) : null };
19698
+ return { file, sha256: (0, import_node_fs33.existsSync)(file) ? await sha256File(file) : null };
19546
19699
  })
19547
19700
  );
19548
19701
  edits = await Promise.all(editShas.map(({ file, sha256: editSha }) => describeOutput(media, root, file, { sha256: editSha })));
@@ -19550,7 +19703,7 @@ async function buildGallerySnapshot(opts) {
19550
19703
  const companion = await readHandEditCompanion(editPath);
19551
19704
  if (companion) {
19552
19705
  const projectPath = handEditProjectPath(editPath);
19553
- const project = companion.project && (0, import_node_fs32.existsSync)(projectPath) ? await fileInfo(projectPath) : null;
19706
+ const project = companion.project && (0, import_node_fs33.existsSync)(projectPath) ? await fileInfo(projectPath) : null;
19554
19707
  let projectUrl = null;
19555
19708
  if (project) {
19556
19709
  const id = galleryMediaId(projectPath);
@@ -19586,8 +19739,8 @@ async function buildGallerySnapshot(opts) {
19586
19739
  editStatus = edits.some((member) => !member.exists) ? "missing" : editChanged.every((changed) => !changed) ? "same" : regenerated ? "regenerated-since" : "edited";
19587
19740
  }
19588
19741
  } else if (spec.source) {
19589
- outputs = [await describeOutput(media, root, import_node_path35.default.resolve(root, spec.source))];
19590
- } else if (!entry && (0, import_node_fs32.existsSync)(spec.outFile)) {
19742
+ outputs = [await describeOutput(media, root, import_node_path36.default.resolve(root, spec.source))];
19743
+ } else if (!entry && (0, import_node_fs33.existsSync)(spec.outFile)) {
19591
19744
  outputs = [await describeOutput(media, root, spec.outFile)];
19592
19745
  } else {
19593
19746
  outputs = [];
@@ -19791,7 +19944,7 @@ async function buildGallerySnapshot(opts) {
19791
19944
  id: loaded.manifest.name,
19792
19945
  name: loaded.manifest.name,
19793
19946
  manifest: loaded.path,
19794
- lock: import_node_path35.default.resolve(opts.lockPath),
19947
+ lock: import_node_path36.default.resolve(opts.lockPath),
19795
19948
  root,
19796
19949
  provider: loaded.manifest.provider,
19797
19950
  account: null,
@@ -19817,7 +19970,7 @@ async function buildGallerySnapshot(opts) {
19817
19970
  return { snapshot, media };
19818
19971
  }
19819
19972
  async function buildWorkspaceGallerySnapshot(opts) {
19820
- const dir = import_node_path35.default.dirname(import_node_path35.default.resolve(opts.workspacePath));
19973
+ const dir = import_node_path36.default.dirname(import_node_path36.default.resolve(opts.workspacePath));
19821
19974
  const media = /* @__PURE__ */ new Map();
19822
19975
  const projects = [];
19823
19976
  const items = [];
@@ -19860,7 +20013,7 @@ async function buildWorkspaceGallerySnapshot(opts) {
19860
20013
  id: project.id,
19861
20014
  name: loaded.manifest.name,
19862
20015
  manifest: manifestPath,
19863
- lock: import_node_path35.default.resolve(lockPath),
20016
+ lock: import_node_path36.default.resolve(lockPath),
19864
20017
  root: loaded.root,
19865
20018
  provider: loaded.manifest.provider,
19866
20019
  account: project.account ?? null,
@@ -19876,8 +20029,8 @@ async function buildWorkspaceGallerySnapshot(opts) {
19876
20029
  id: project.id,
19877
20030
  name: project.id,
19878
20031
  manifest: manifestPath,
19879
- lock: import_node_path35.default.resolve(lockPath),
19880
- root: import_node_path35.default.dirname(manifestPath),
20032
+ lock: import_node_path36.default.resolve(lockPath),
20033
+ root: import_node_path36.default.dirname(manifestPath),
19881
20034
  provider: project.provider,
19882
20035
  account: project.account ?? null,
19883
20036
  manifestSha256: null,
@@ -19904,7 +20057,7 @@ async function buildWorkspaceGallerySnapshot(opts) {
19904
20057
  version: 1,
19905
20058
  generatedAt: (opts.now ?? (() => /* @__PURE__ */ new Date()))().toISOString(),
19906
20059
  project: null,
19907
- workspace: { path: import_node_path35.default.resolve(opts.workspacePath), dir, projects },
20060
+ workspace: { path: import_node_path36.default.resolve(opts.workspacePath), dir, projects },
19908
20061
  filter,
19909
20062
  totals: {
19910
20063
  entries: projects.reduce((sum, project) => sum + project.entries, 0),
@@ -19921,7 +20074,7 @@ async function buildWorkspaceGallerySnapshot(opts) {
19921
20074
  }
19922
20075
 
19923
20076
  // src/gallery/page.ts
19924
- var import_node_fs33 = require("fs");
20077
+ var import_node_fs34 = require("fs");
19925
20078
 
19926
20079
  // src/gallery/client-bundle.ts
19927
20080
  var import_node_module = require("module");
@@ -19961,8 +20114,8 @@ var client;
19961
20114
  function clientAssets() {
19962
20115
  const prebuilt = new URL("gallery.js", CLIENT_DIR);
19963
20116
  client ??= {
19964
- css: (0, import_node_fs33.readFileSync)(new URL("gallery.css", CLIENT_DIR), "utf8"),
19965
- js: (0, import_node_fs33.existsSync)(prebuilt) ? (0, import_node_fs33.readFileSync)(prebuilt, "utf8") : bundleGalleryClient()
20117
+ css: (0, import_node_fs34.readFileSync)(new URL("gallery.css", CLIENT_DIR), "utf8"),
20118
+ js: (0, import_node_fs34.existsSync)(prebuilt) ? (0, import_node_fs34.readFileSync)(prebuilt, "utf8") : bundleGalleryClient()
19966
20119
  };
19967
20120
  return client;
19968
20121
  }
@@ -20105,10 +20258,10 @@ var EDITOR_RELEASE_BASE = "https://github.com/gfargo/pixelkiln/releases/download
20105
20258
 
20106
20259
  // src/editor/install.ts
20107
20260
  var import_node_crypto8 = require("crypto");
20108
- var import_node_fs34 = require("fs");
20261
+ var import_node_fs35 = require("fs");
20109
20262
  var import_promises29 = require("fs/promises");
20110
20263
  var import_node_os4 = __toESM(require("os"), 1);
20111
- var import_node_path36 = __toESM(require("path"), 1);
20264
+ var import_node_path37 = __toESM(require("path"), 1);
20112
20265
  var EditorInstallError = class extends Error {
20113
20266
  constructor(message6, file) {
20114
20267
  super(message6);
@@ -20119,15 +20272,15 @@ var EditorInstallError = class extends Error {
20119
20272
  };
20120
20273
  function editorToolsRoot() {
20121
20274
  const override = process.env.PIXELKILN_TOOLS_DIR?.trim();
20122
- if (override) return import_node_path36.default.resolve(override);
20123
- if (process.platform === "darwin") return import_node_path36.default.join(import_node_os4.default.homedir(), "Library", "Caches", "pixelkiln", "tools");
20275
+ if (override) return import_node_path37.default.resolve(override);
20276
+ if (process.platform === "darwin") return import_node_path37.default.join(import_node_os4.default.homedir(), "Library", "Caches", "pixelkiln", "tools");
20124
20277
  if (process.platform === "win32") {
20125
- return import_node_path36.default.join(process.env.LOCALAPPDATA ?? import_node_path36.default.join(import_node_os4.default.homedir(), "AppData", "Local"), "pixelkiln", "tools");
20278
+ return import_node_path37.default.join(process.env.LOCALAPPDATA ?? import_node_path37.default.join(import_node_os4.default.homedir(), "AppData", "Local"), "pixelkiln", "tools");
20126
20279
  }
20127
- return import_node_path36.default.join(process.env.XDG_CACHE_HOME ?? import_node_path36.default.join(import_node_os4.default.homedir(), ".cache"), "pixelkiln", "tools");
20280
+ return import_node_path37.default.join(process.env.XDG_CACHE_HOME ?? import_node_path37.default.join(import_node_os4.default.homedir(), ".cache"), "pixelkiln", "tools");
20128
20281
  }
20129
20282
  function editorDir(pin = EDITOR_PIN, root = editorToolsRoot()) {
20130
- return import_node_path36.default.join(root, "pixelorama", pin.release ?? "unpublished");
20283
+ return import_node_path37.default.join(root, "pixelorama", pin.release ?? "unpublished");
20131
20284
  }
20132
20285
  function editorBaseUrl(pin = EDITOR_PIN) {
20133
20286
  const override = process.env.PIXELKILN_EDITOR_URL?.trim();
@@ -20150,8 +20303,8 @@ async function editorStatus(opts = {}) {
20150
20303
  let totalBytes = 0;
20151
20304
  for (const [name, expected] of Object.entries(pin.files)) {
20152
20305
  totalBytes += expected.bytes;
20153
- const file = import_node_path36.default.join(dir, name);
20154
- const info = (0, import_node_fs34.existsSync)(file) ? await (0, import_promises29.stat)(file).catch(() => null) : null;
20306
+ const file = import_node_path37.default.join(dir, name);
20307
+ const info = (0, import_node_fs35.existsSync)(file) ? await (0, import_promises29.stat)(file).catch(() => null) : null;
20155
20308
  if (info && info.size === expected.bytes && await sha256Of(file) === expected.sha256) {
20156
20309
  installedBytes += expected.bytes;
20157
20310
  } else {
@@ -20208,7 +20361,7 @@ async function installEditor(opts = {}) {
20208
20361
  if (digest2 !== expected.sha256) {
20209
20362
  throw new EditorInstallError(`${name}: sha256 ${digest2.slice(0, 12)}\u2026 does not match the pinned ${expected.sha256.slice(0, 12)}\u2026`, name);
20210
20363
  }
20211
- const final = import_node_path36.default.join(dir, name);
20364
+ const final = import_node_path37.default.join(dir, name);
20212
20365
  const tmp = `${final}.${process.pid}.part`;
20213
20366
  try {
20214
20367
  await (0, import_promises29.writeFile)(tmp, bytes);
@@ -20254,12 +20407,12 @@ var EDITOR_CONTENT_TYPES = {
20254
20407
  ".json": "application/json; charset=utf-8"
20255
20408
  };
20256
20409
  function editorContentType(name) {
20257
- return EDITOR_CONTENT_TYPES[import_node_path36.default.extname(name).toLowerCase()] ?? null;
20410
+ return EDITOR_CONTENT_TYPES[import_node_path37.default.extname(name).toLowerCase()] ?? null;
20258
20411
  }
20259
20412
 
20260
20413
  // src/gallery/editor.ts
20261
20414
  var import_promises30 = require("fs/promises");
20262
- var import_node_path37 = __toESM(require("path"), 1);
20415
+ var import_node_path38 = __toESM(require("path"), 1);
20263
20416
  function editorRoute(release, name = "index.html") {
20264
20417
  return `/editor/${encodeURIComponent(release)}/${encodeURIComponent(name)}`;
20265
20418
  }
@@ -20332,7 +20485,7 @@ function createGalleryEditorHandlers(opts = {}) {
20332
20485
  if (!status.installed) return null;
20333
20486
  let bytes;
20334
20487
  try {
20335
- bytes = await (0, import_promises30.readFile)(import_node_path37.default.join(dir, name));
20488
+ bytes = await (0, import_promises30.readFile)(import_node_path38.default.join(dir, name));
20336
20489
  } catch {
20337
20490
  verified = null;
20338
20491
  return null;
@@ -21024,15 +21177,15 @@ function createGenerateHandlers(opts) {
21024
21177
 
21025
21178
  // src/pipeline/salvage.ts
21026
21179
  var import_promises32 = require("fs/promises");
21027
- var import_node_fs35 = require("fs");
21028
- var import_node_path38 = __toESM(require("path"), 1);
21180
+ var import_node_fs36 = require("fs");
21181
+ var import_node_path39 = __toESM(require("path"), 1);
21029
21182
  function providerClaimId(provider, objectId) {
21030
21183
  return `${encodeURIComponent(provider)}:${encodeURIComponent(objectId)}`;
21031
21184
  }
21032
21185
  async function loadClaims(lockPaths, opts = {}) {
21033
21186
  const claimed = /* @__PURE__ */ new Set();
21034
21187
  for (const p of lockPaths) {
21035
- if (!(0, import_node_fs35.existsSync)(p)) throw new Error(`Claim lockfile not found: ${p}`);
21188
+ if (!(0, import_node_fs36.existsSync)(p)) throw new Error(`Claim lockfile not found: ${p}`);
21036
21189
  let parsed;
21037
21190
  try {
21038
21191
  parsed = parseLock(JSON.parse(await (0, import_promises32.readFile)(p, "utf8")));
@@ -21139,20 +21292,20 @@ function matchOrphanStyle(prompt, manifest) {
21139
21292
  return matchStyleByPattern(prompt, manifest);
21140
21293
  }
21141
21294
  async function loadSiblingManifests(ownManifestPath, workspaceManifestPaths, claimPaths) {
21142
- const own = import_node_path38.default.resolve(ownManifestPath);
21295
+ const own = import_node_path39.default.resolve(ownManifestPath);
21143
21296
  const siblingManifestPaths = [
21144
21297
  .../* @__PURE__ */ new Set([
21145
21298
  ...workspaceManifestPaths,
21146
- ...claimPaths.map((c) => import_node_path38.default.join(import_node_path38.default.dirname(import_node_path38.default.resolve(c)), "pixelkiln.manifest.json"))
21299
+ ...claimPaths.map((c) => import_node_path39.default.join(import_node_path39.default.dirname(import_node_path39.default.resolve(c)), "pixelkiln.manifest.json"))
21147
21300
  ])
21148
21301
  ];
21149
21302
  const siblings = [];
21150
21303
  for (const siblingManifestPath of siblingManifestPaths) {
21151
- if (import_node_path38.default.resolve(siblingManifestPath) === own) continue;
21152
- if (!(0, import_node_fs35.existsSync)(siblingManifestPath)) continue;
21304
+ if (import_node_path39.default.resolve(siblingManifestPath) === own) continue;
21305
+ if (!(0, import_node_fs36.existsSync)(siblingManifestPath)) continue;
21153
21306
  try {
21154
21307
  const { manifest } = await loadManifest(siblingManifestPath);
21155
- siblings.push({ label: import_node_path38.default.basename(import_node_path38.default.dirname(siblingManifestPath)), manifest });
21308
+ siblings.push({ label: import_node_path39.default.basename(import_node_path39.default.dirname(siblingManifestPath)), manifest });
21156
21309
  } catch {
21157
21310
  }
21158
21311
  }
@@ -21273,7 +21426,7 @@ async function applyTags(provider, decisions, existing, opts = {}) {
21273
21426
 
21274
21427
  // src/pick/salvage-server.ts
21275
21428
  var import_promises33 = require("fs/promises");
21276
- var import_node_path39 = __toESM(require("path"), 1);
21429
+ var import_node_path40 = __toESM(require("path"), 1);
21277
21430
 
21278
21431
  // src/pick/salvage-sheet.ts
21279
21432
  var escapeHtml3 = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
@@ -21439,7 +21592,7 @@ async function runSalvage(provider, orphans, ctx, opts = {}) {
21439
21592
  });
21440
21593
  const html = renderSalvageSheet(orphans, {
21441
21594
  styleId: ctx.styleId,
21442
- importDir: import_node_path39.default.relative(process.cwd(), ctx.importDir) || "."
21595
+ importDir: import_node_path40.default.relative(process.cwd(), ctx.importDir) || "."
21443
21596
  });
21444
21597
  const byId = new Map(orphans.map((o) => [o.id, o]));
21445
21598
  const existingTags = new Map(orphans.map((o) => [o.id, o.tags]));
@@ -21495,9 +21648,9 @@ async function runSalvage(provider, orphans, ctx, opts = {}) {
21495
21648
  if (!buf.subarray(0, 8).equals(PNG_SIGNATURE2)) throw new Error("not a PNG");
21496
21649
  decodePng(buf);
21497
21650
  const assetId = idFromPrompt(orphan.prompt, taken);
21498
- const rel = import_node_path39.default.join("_salvaged", `${assetId}.png`);
21499
- const outFile = import_node_path39.default.resolve(ctx.importDir, rel);
21500
- await (0, import_promises33.mkdir)(import_node_path39.default.dirname(outFile), { recursive: true });
21651
+ const rel = import_node_path40.default.join("_salvaged", `${assetId}.png`);
21652
+ const outFile = import_node_path40.default.resolve(ctx.importDir, rel);
21653
+ await (0, import_promises33.mkdir)(import_node_path40.default.dirname(outFile), { recursive: true });
21501
21654
  await (0, import_promises33.writeFile)(outFile, buf);
21502
21655
  ctx.manifest.assets[assetId] = {
21503
21656
  prompt: orphan.prompt,
@@ -21530,7 +21683,7 @@ async function runSalvage(provider, orphans, ctx, opts = {}) {
21530
21683
  sourceUrl: durableSource,
21531
21684
  sourceUrls: durableSource ? [{ url: durableSource }] : [],
21532
21685
  outputs: [{
21533
- path: portableOutputPath(outFile, import_node_path39.default.dirname(ctx.manifestPath)),
21686
+ path: portableOutputPath(outFile, import_node_path40.default.dirname(ctx.manifestPath)),
21534
21687
  sha256: sha256(buf)
21535
21688
  }],
21536
21689
  submittedAt: orphan.createdAt,