pixelkiln 0.95.0 → 0.96.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.js CHANGED
@@ -1123,7 +1123,7 @@ var AssetDeriveSchema = z.object({
1123
1123
  /** scale: `nearest` (default) keeps hard edges; `box` averages the covered pixels. */
1124
1124
  mode: z.enum(["nearest", "box"]).optional()
1125
1125
  }).strict().superRefine((derive, context) => {
1126
- const issue = (message6, path42) => context.addIssue({ code: z.ZodIssueCode.custom, message: message6, path: [path42] });
1126
+ const issue = (message6, path43) => context.addIssue({ code: z.ZodIssueCode.custom, message: message6, path: [path43] });
1127
1127
  if (Boolean(derive.from) === Boolean(derive.file)) {
1128
1128
  issue("name exactly one source: `from` (an asset in this style) or `file` (a committed PNG)", derive.from ? "file" : "from");
1129
1129
  }
@@ -1424,6 +1424,18 @@ var PostprocessSchema = z.object({
1424
1424
  distance: z.literal("redmean")
1425
1425
  }).optional()
1426
1426
  });
1427
+ var LockOriginSchema = z.object({
1428
+ tool: z.string().min(1).optional(),
1429
+ prompt: z.string().optional(),
1430
+ seed: z.number().int().optional(),
1431
+ steps: z.array(z.string().min(1)).optional(),
1432
+ raw: z.object({ sha256: z.string().regex(/^[0-9a-f]{64}$/) }).optional()
1433
+ });
1434
+ var LockImportedSchema = z.object({
1435
+ source: z.string().min(1),
1436
+ note: z.string().optional(),
1437
+ importedAt: z.string()
1438
+ }).strict();
1427
1439
  var LockSourceSchema = z.object({
1428
1440
  url: z.string(),
1429
1441
  role: z.string().optional(),
@@ -1474,6 +1486,9 @@ var LockHistoryEntrySchema = z.object({
1474
1486
  motionShare: LockMotionShareSchema.optional(),
1475
1487
  /** A terrain set's settings outside specHash; see LockEntrySchema.terrainSettings. */
1476
1488
  terrainSettings: LockTerrainSettingsSchema.optional(),
1489
+ /** Imported art keeps its provenance when it is replaced and when it comes back. */
1490
+ imported: LockImportedSchema.optional(),
1491
+ origin: LockOriginSchema.optional(),
1477
1492
  /** When the replacement was submitted. */
1478
1493
  retiredAt: z.string()
1479
1494
  });
@@ -1646,11 +1661,9 @@ var LockEntrySchema = z.object({
1646
1661
  * hand edit, another tool) and brought in with `adopt --local`: nothing was
1647
1662
  * submitted, so jobId and cost are empty. Absent on generated entries.
1648
1663
  */
1649
- imported: z.object({
1650
- source: z.string().min(1),
1651
- note: z.string().optional(),
1652
- importedAt: z.string()
1653
- }).strict().optional(),
1664
+ imported: LockImportedSchema.optional(),
1665
+ /** More on imported art: tool, prompt, seed, post-process steps, raw original. See LockOriginSchema. */
1666
+ origin: LockOriginSchema.optional(),
1654
1667
  /**
1655
1668
  * For a derived asset: what it was made from, and a hash of that input when
1656
1669
  * this was made. Compared with the input's current bytes by the plan, so a
@@ -2217,9 +2230,9 @@ var PixelLabClient = class {
2217
2230
  apiKey;
2218
2231
  http;
2219
2232
  /** Retries transport failures, 429, and 5xx; see http.ts for the policy. */
2220
- async request(path42, init) {
2233
+ async request(path43, init) {
2221
2234
  const auth = this.apiKey.startsWith("Bearer ") ? this.apiKey : `Bearer ${this.apiKey}`;
2222
- const res = await this.http(`${BASE}${path42}`, {
2235
+ const res = await this.http(`${BASE}${path43}`, {
2223
2236
  ...init,
2224
2237
  headers: {
2225
2238
  Authorization: auth,
@@ -2230,13 +2243,13 @@ var PixelLabClient = class {
2230
2243
  const text = await res.text();
2231
2244
  if (!res.ok) {
2232
2245
  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' : "";
2233
- throw new PixelLabError(`${init?.method ?? "GET"} ${path42} \u2192 ${res.status}${hint}`, res.status, text);
2246
+ throw new PixelLabError(`${init?.method ?? "GET"} ${path43} \u2192 ${res.status}${hint}`, res.status, text);
2234
2247
  }
2235
2248
  if (!text) return {};
2236
2249
  try {
2237
2250
  return JSON.parse(text);
2238
2251
  } catch {
2239
- throw new Error(`${init?.method ?? "GET"} ${path42} returned invalid JSON`);
2252
+ throw new Error(`${init?.method ?? "GET"} ${path43} returned invalid JSON`);
2240
2253
  }
2241
2254
  }
2242
2255
  async balance() {
@@ -2689,10 +2702,10 @@ var PixelLabClient = class {
2689
2702
  const palette = args.paletteSwatchBase64 ? { color_image: { type: "base64", base64: args.paletteSwatchBase64, format: "png" }, force_colors: true } : {};
2690
2703
  const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
2691
2704
  const south = args.reference?.south;
2692
- let path42;
2705
+ let path43;
2693
2706
  let body;
2694
2707
  if (args.mode === "v3") {
2695
- path42 = "/create-character-v3";
2708
+ path43 = "/create-character-v3";
2696
2709
  body = {
2697
2710
  description: args.description,
2698
2711
  image_size: imageSize,
@@ -2706,7 +2719,7 @@ var PixelLabClient = class {
2706
2719
  ...args.enhancePrompt ? { enhance_prompt: true } : {}
2707
2720
  };
2708
2721
  } else if (args.mode === "pro-flash") {
2709
- path42 = "/create-character-pro-flash";
2722
+ path43 = "/create-character-pro-flash";
2710
2723
  const traits = args.styleTraits;
2711
2724
  body = {
2712
2725
  description: args.description,
@@ -2730,7 +2743,7 @@ var PixelLabClient = class {
2730
2743
  } : {}
2731
2744
  };
2732
2745
  } else if (args.mode === "pro") {
2733
- path42 = "/create-character-pro";
2746
+ path43 = "/create-character-pro";
2734
2747
  body = {
2735
2748
  description: args.description,
2736
2749
  image_size: imageSize,
@@ -2744,7 +2757,7 @@ var PixelLabClient = class {
2744
2757
  ...!south && args.styleCharacterId ? { style_character_id: args.styleCharacterId } : {}
2745
2758
  };
2746
2759
  } else {
2747
- path42 = args.directions === 4 ? "/create-character-with-4-directions" : "/create-character-with-8-directions";
2760
+ path43 = args.directions === 4 ? "/create-character-with-4-directions" : "/create-character-with-8-directions";
2748
2761
  body = {
2749
2762
  description: args.description,
2750
2763
  image_size: imageSize,
@@ -2762,8 +2775,8 @@ var PixelLabClient = class {
2762
2775
  };
2763
2776
  }
2764
2777
  if (args.mode === "pro" || args.mode === "pro-flash") Object.assign(body, targetPaletteBody(args.targetPalette));
2765
- const raw = await this.request(path42, { method: "POST", body: JSON.stringify(body) });
2766
- return validateResponse(CharacterSubmitSchema, raw, path42.slice(1));
2778
+ const raw = await this.request(path43, { method: "POST", body: JSON.stringify(body) });
2779
+ return validateResponse(CharacterSubmitSchema, raw, path43.slice(1));
2767
2780
  }
2768
2781
  /** A text edit of an existing character, applied to every direction and stored as a sibling. */
2769
2782
  async createCharacterState(args) {
@@ -4104,10 +4117,10 @@ function normalizeHex(value) {
4104
4117
  function sha256(data) {
4105
4118
  return createHash("sha256").update(data).digest("hex");
4106
4119
  }
4107
- async function sha256File(path42) {
4120
+ async function sha256File(path43) {
4108
4121
  return new Promise((resolve, reject) => {
4109
4122
  const hash = createHash("sha256");
4110
- const stream = createReadStream(path42);
4123
+ const stream = createReadStream(path43);
4111
4124
  stream.on("data", (chunk2) => hash.update(chunk2));
4112
4125
  stream.on("error", reject);
4113
4126
  stream.on("end", () => resolve(hash.digest("hex")));
@@ -7942,9 +7955,9 @@ var RetroDiffusionClient = class {
7942
7955
  if (!response.ok) throw new ProviderError("retrodiffusion", `Retro Diffusion download failed (${response.status})`, { status: response.status });
7943
7956
  return Buffer.from(await response.arrayBuffer());
7944
7957
  }
7945
- async call(path42, init = {}) {
7958
+ async call(path43, init = {}) {
7946
7959
  if (!this.token) throw new Error("RD_API_KEY is not set");
7947
- const response = await this.request(`${this.baseUrl}${path42}`, {
7960
+ const response = await this.request(`${this.baseUrl}${path43}`, {
7948
7961
  ...init,
7949
7962
  headers: {
7950
7963
  "Content-Type": "application/json",
@@ -13740,6 +13753,15 @@ async function anyOutputModified(entry, spec) {
13740
13753
  }
13741
13754
  return false;
13742
13755
  }
13756
+ async function modifiedReason(entry, spec) {
13757
+ if (!entry.imported) return "output modified since download";
13758
+ const raw = entry.origin?.raw?.sha256;
13759
+ if (raw && existsSync13(currentEntryOutputPath(entry, spec, 0)) && await sha256File(currentEntryOutputPath(entry, spec, 0)) === raw) {
13760
+ const steps = entry.origin?.steps?.length ? ` (${entry.origin.steps.join("; ")})` : "";
13761
+ return `file is the unprocessed original; apply the recorded post-processing again${steps}, or run adopt --local --force to record it as it is`;
13762
+ }
13763
+ return "file changed since it was imported; run adopt --local --force to record the new version";
13764
+ }
13743
13765
  function dependencies(spec) {
13744
13766
  return [
13745
13767
  spec.mirror?.sourceSpec,
@@ -13893,7 +13915,7 @@ async function buildPlan(specs, lock, opts = {}) {
13893
13915
  reason = entry.outputs.length === 0 ? "no recorded output files" : `missing on disk: ${entry.outputs.filter((_output, index) => !existsSync13(currentEntryOutputPath(entry, spec, index))).map((o) => o.role ?? "asset").join(", ")}`;
13894
13916
  } else if (await anyOutputModified(entry, spec)) {
13895
13917
  state = "orphaned";
13896
- reason = "output modified since download";
13918
+ reason = await modifiedReason(entry, spec);
13897
13919
  } else if (spec.derive) {
13898
13920
  state = "ok";
13899
13921
  reason = "up to date";
@@ -15023,10 +15045,10 @@ function isSha256Hash(value) {
15023
15045
  function parseCache(value) {
15024
15046
  return HashCacheSchema.parse(value);
15025
15047
  }
15026
- async function loadCache(path42) {
15027
- if (!existsSync17(path42)) return { version: 1, hashes: {} };
15048
+ async function loadCache(path43) {
15049
+ if (!existsSync17(path43)) return { version: 1, hashes: {} };
15028
15050
  try {
15029
- const parsed = HashCacheSchema.safeParse(JSON.parse(await readFile13(path42, "utf8")));
15051
+ const parsed = HashCacheSchema.safeParse(JSON.parse(await readFile13(path43, "utf8")));
15030
15052
  if (!parsed.success) return { version: 1, hashes: {} };
15031
15053
  return {
15032
15054
  version: 1,
@@ -15038,18 +15060,18 @@ async function loadCache(path42) {
15038
15060
  return { version: 1, hashes: {} };
15039
15061
  }
15040
15062
  }
15041
- async function saveCache(path42, cache) {
15063
+ async function saveCache(path43, cache) {
15042
15064
  const sorted = {};
15043
15065
  for (const key2 of Object.keys(cache.hashes).sort()) {
15044
15066
  const hash = cache.hashes[key2];
15045
15067
  if (!isSha256Hash(hash)) throw new Error(`Refusing to cache invalid SHA-256 for ${key2}`);
15046
15068
  sorted[key2] = hash;
15047
15069
  }
15048
- await mkdir7(pathModule.dirname(pathModule.resolve(path42)), { recursive: true });
15049
- const tmp = `${path42}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
15070
+ await mkdir7(pathModule.dirname(pathModule.resolve(path43)), { recursive: true });
15071
+ const tmp = `${path43}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
15050
15072
  try {
15051
15073
  await writeFile7(tmp, JSON.stringify({ version: 1, hashes: sorted }, null, 2) + "\n");
15052
- await rename5(tmp, path42);
15074
+ await rename5(tmp, path43);
15053
15075
  } finally {
15054
15076
  await rm4(tmp, { force: true });
15055
15077
  }
@@ -15432,6 +15454,8 @@ function retireGeneration(entry, retiredAt) {
15432
15454
  ...entry.terrainConnect ? { terrainConnect: entry.terrainConnect } : {},
15433
15455
  ...entry.motionShare ? { motionShare: entry.motionShare } : {},
15434
15456
  ...entry.terrainSettings ? { terrainSettings: entry.terrainSettings } : {},
15457
+ ...entry.imported ? { imported: entry.imported } : {},
15458
+ ...entry.origin ? { origin: entry.origin } : {},
15435
15459
  retiredAt
15436
15460
  };
15437
15461
  }
@@ -15531,6 +15555,10 @@ async function revertGeneration(provider, spec, lock, lockPath, opts) {
15531
15555
  // Likewise its settings; a generation from before they were recorded
15532
15556
  // comes back with none and is taken as current.
15533
15557
  terrainSettings: generation.terrainSettings,
15558
+ // Imported art comes back as imported, with its provenance; a generated
15559
+ // one clears both, so the plan does not call it imported.
15560
+ imported: generation.imported,
15561
+ origin: generation.origin,
15534
15562
  history
15535
15563
  });
15536
15564
  await saveLock(lockPath, lock);
@@ -17224,15 +17252,23 @@ async function tagAdopted(provider, specs, lock, opts = {}) {
17224
17252
  // src/pipeline/import.ts
17225
17253
  import { existsSync as existsSync24 } from "fs";
17226
17254
  import { readFile as readFile17 } from "fs/promises";
17255
+ import path29 from "path";
17227
17256
  function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Date()) {
17228
17257
  const png = decodePng(bytes);
17229
17258
  const at = now.toISOString();
17259
+ const origin = {
17260
+ ...opts.tool ? { tool: opts.tool } : {},
17261
+ ...opts.prompt ? { prompt: opts.prompt } : {},
17262
+ ...opts.seed !== void 0 ? { seed: opts.seed } : {},
17263
+ ...opts.steps?.length ? { steps: opts.steps } : {},
17264
+ ...opts.rawSha256 ? { raw: { sha256: opts.rawSha256 } } : {}
17265
+ };
17230
17266
  return {
17231
17267
  styleId: spec.styleId,
17232
17268
  assetId: spec.assetId,
17233
17269
  specHash: spec.specHash,
17234
17270
  generator: spec.generator,
17235
- prompt: spec.prompt,
17271
+ prompt: opts.prompt ?? spec.prompt,
17236
17272
  width: png.width,
17237
17273
  height: png.height,
17238
17274
  jobId: opts.objectId ?? null,
@@ -17246,9 +17282,10 @@ function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Da
17246
17282
  outputs: [{ path: portableOutputPath(spec.outFile, spec.root), sha256: sha256(bytes) }],
17247
17283
  submittedAt: null,
17248
17284
  downloadedAt: at,
17249
- cost: 0,
17285
+ cost: opts.cost ?? 0,
17250
17286
  costUnit: spec.costUnit,
17251
17287
  provider: spec.provider,
17288
+ ...Object.keys(origin).length ? { origin } : {},
17252
17289
  ...spec.external ? { external: { builder: spec.external.builder, inputs: spec.external.inputs } } : {},
17253
17290
  imported: {
17254
17291
  source: opts.source ?? "external",
@@ -17267,6 +17304,19 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
17267
17304
  if (opts.objectId && specs.length !== 1) {
17268
17305
  throw new Error(`--object-id names one object; ${specs.length} assets are selected. Narrow with --only and --style.`);
17269
17306
  }
17307
+ const cacheDir = opts.cacheDir === false ? null : path29.resolve(opts.cacheDir ?? path29.join(path29.dirname(lockPath), ".pixelkiln", "cache"));
17308
+ let rawSha256;
17309
+ let rawBytes;
17310
+ if (opts.raw) {
17311
+ if (specs.length !== 1) throw new Error(`--raw names one original; ${specs.length} assets are selected. Narrow with --only and --style.`);
17312
+ try {
17313
+ rawBytes = await readFile17(opts.raw);
17314
+ decodePng(rawBytes);
17315
+ } catch (error) {
17316
+ throw new Error(`--raw ${opts.raw} is not a readable PNG: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
17317
+ }
17318
+ rawSha256 = sha256(rawBytes);
17319
+ }
17270
17320
  const imported = [];
17271
17321
  const skipped = [];
17272
17322
  for (const spec of specs) {
@@ -17285,8 +17335,10 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
17285
17335
  continue;
17286
17336
  }
17287
17337
  let patch;
17338
+ let bytes;
17288
17339
  try {
17289
- patch = buildImportedEntry(spec, await readFile17(spec.outFile), opts);
17340
+ bytes = await readFile17(spec.outFile);
17341
+ patch = buildImportedEntry(spec, bytes, { ...opts, rawSha256 }, /* @__PURE__ */ new Date());
17290
17342
  } catch (error) {
17291
17343
  skipped.push({ key: key2, reason: `invalid PNG: ${error instanceof Error ? error.message : String(error)}` });
17292
17344
  continue;
@@ -17295,7 +17347,19 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
17295
17347
  imported.push({ key: key2, entry: patch });
17296
17348
  continue;
17297
17349
  }
17298
- imported.push({ key: key2, entry: upsert(lock, key2, patch) });
17350
+ const existing = lock.entries[key2];
17351
+ const history = existing?.outputs[0]?.sha256 === sha256(bytes) ? existing.history : historyAfterReplacing(existing, opts.historyLimit ?? DEFAULT_HISTORY_LIMIT, patch.downloadedAt ?? (/* @__PURE__ */ new Date()).toISOString());
17352
+ if (cacheDir) {
17353
+ await cacheMedia(cacheDir, bytes, MediaType.PNG);
17354
+ if (rawBytes) await cacheMedia(cacheDir, rawBytes, MediaType.PNG);
17355
+ }
17356
+ imported.push({ key: key2, entry: upsert(lock, key2, {
17357
+ ...patch,
17358
+ // An import replaces the whole record: clear what the entry held that
17359
+ // an import never has, or a regenerated entry would keep stale links.
17360
+ origin: patch.origin,
17361
+ history
17362
+ }) });
17299
17363
  }
17300
17364
  if (!opts.dryRun && imported.length) await saveLock(lockPath, lock);
17301
17365
  return { imported, skipped };
@@ -17340,7 +17404,7 @@ import { readFile as readFile20 } from "fs/promises";
17340
17404
  // src/pipeline/init.ts
17341
17405
  import { readdir as readdir3, readFile as readFile18, writeFile as writeFile10 } from "fs/promises";
17342
17406
  import { existsSync as existsSync25 } from "fs";
17343
- import path29 from "path";
17407
+ import path30 from "path";
17344
17408
  function pngSize(buf) {
17345
17409
  if (buf.length < 24) return null;
17346
17410
  const isPng = buf.readUInt32BE(0) === 2303741511 && buf.readUInt32BE(4) === 218765834;
@@ -17354,7 +17418,7 @@ function slugify(value) {
17354
17418
  async function walk(dir, exclude) {
17355
17419
  const out = [];
17356
17420
  for (const entry of await readdir3(dir, { withFileTypes: true })) {
17357
- const full = path29.join(dir, entry.name);
17421
+ const full = path30.join(dir, entry.name);
17358
17422
  if (exclude.some((x) => full.includes(x))) continue;
17359
17423
  if (entry.isDirectory()) out.push(...await walk(full, exclude));
17360
17424
  else if (entry.name.toLowerCase().endsWith(".png")) out.push(full);
@@ -17373,9 +17437,9 @@ async function scanAssets(root, opts = {}) {
17373
17437
  skipped.push(`${file} (not a readable PNG)`);
17374
17438
  continue;
17375
17439
  }
17376
- const rel = path29.relative(root, file);
17377
- const category = path29.dirname(rel) === "." ? "" : path29.dirname(rel);
17378
- let id = slugify(path29.basename(rel));
17440
+ const rel = path30.relative(root, file);
17441
+ const category = path30.dirname(rel) === "." ? "" : path30.dirname(rel);
17442
+ let id = slugify(path30.basename(rel));
17379
17443
  if (seen.has(id)) {
17380
17444
  const n = seen.get(id) + 1;
17381
17445
  seen.set(id, n);
@@ -18136,12 +18200,12 @@ async function runPicker(provider, lock, lockPath, opts = {}) {
18136
18200
  import { createHash as createHash5 } from "crypto";
18137
18201
  import { existsSync as existsSync32 } from "fs";
18138
18202
  import { readFile as readFile27, stat as stat3 } from "fs/promises";
18139
- import path37 from "path";
18203
+ import path38 from "path";
18140
18204
 
18141
18205
  // src/workspace.ts
18142
18206
  import { mkdir as mkdir9, readFile as readFile21, rename as rename7, rm as rm7, writeFile as writeFile11 } from "fs/promises";
18143
18207
  import { existsSync as existsSync27 } from "fs";
18144
- import path30 from "path";
18208
+ import path31 from "path";
18145
18209
  import { z as z7 } from "zod";
18146
18210
  var WorkspaceProjectSchema = z7.object({
18147
18211
  id: z7.string().min(1),
@@ -18183,7 +18247,7 @@ async function saveWorkspace(workspacePath, ws) {
18183
18247
  version: 1,
18184
18248
  projects: [...ws.projects].sort((a, b) => a.id.localeCompare(b.id))
18185
18249
  };
18186
- await mkdir9(path30.dirname(path30.resolve(workspacePath)), { recursive: true });
18250
+ await mkdir9(path31.dirname(path31.resolve(workspacePath)), { recursive: true });
18187
18251
  const tmp = `${workspacePath}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
18188
18252
  try {
18189
18253
  await writeFile11(tmp, JSON.stringify(sorted, null, 2) + "\n");
@@ -18193,12 +18257,12 @@ async function saveWorkspace(workspacePath, ws) {
18193
18257
  }
18194
18258
  }
18195
18259
  function toPortablePath(dir, absolute) {
18196
- return path30.relative(dir, absolute).split(path30.sep).join("/");
18260
+ return path31.relative(dir, absolute).split(path31.sep).join("/");
18197
18261
  }
18198
18262
  function resolveProject(dir, project) {
18199
18263
  return {
18200
- manifestPath: path30.resolve(dir, project.manifest.split("/").join(path30.sep)),
18201
- lockPath: path30.resolve(dir, project.lock.split("/").join(path30.sep))
18264
+ manifestPath: path31.resolve(dir, project.manifest.split("/").join(path31.sep)),
18265
+ lockPath: path31.resolve(dir, project.lock.split("/").join(path31.sep))
18202
18266
  };
18203
18267
  }
18204
18268
  function validateWorkspace(ws, dir) {
@@ -18211,7 +18275,7 @@ function validateWorkspace(ws, dir) {
18211
18275
  const { manifestPath, lockPath } = resolveProject(dir, project);
18212
18276
  lockOwners.set(lockPath, [...lockOwners.get(lockPath) ?? [], project.id]);
18213
18277
  manifestOwners.set(manifestPath, [...manifestOwners.get(manifestPath) ?? [], project.id]);
18214
- if (path30.isAbsolute(project.manifest) || path30.isAbsolute(project.lock)) {
18278
+ if (path31.isAbsolute(project.manifest) || path31.isAbsolute(project.lock)) {
18215
18279
  diagnostics.push({
18216
18280
  id: "absolute-path",
18217
18281
  level: "warning",
@@ -18273,15 +18337,15 @@ function validateWorkspace(ws, dir) {
18273
18337
 
18274
18338
  // src/gallery/edit.ts
18275
18339
  import { readFile as readFile26, rename as rename10, writeFile as writeFile17 } from "fs/promises";
18276
- import path36 from "path";
18340
+ import path37 from "path";
18277
18341
  import { z as z13 } from "zod";
18278
18342
 
18279
18343
  // src/manifest-edit.ts
18280
18344
  import { readFile as readFile22, rename as rename8, rm as rm8, writeFile as writeFile12 } from "fs/promises";
18281
- import path31 from "path";
18345
+ import path32 from "path";
18282
18346
  import { z as z8 } from "zod";
18283
18347
  var HexSha = z8.string().regex(/^[0-9a-f]{64}$/);
18284
- var ProjectFileSchema = z8.string().min(1).refine((file) => !path31.isAbsolute(file) && !file.split(/[\\/]/).includes(".."), "must be a path inside the project");
18348
+ var ProjectFileSchema = z8.string().min(1).refine((file) => !path32.isAbsolute(file) && !file.split(/[\\/]/).includes(".."), "must be a path inside the project");
18285
18349
  var AssetPatchSchema = z8.object({
18286
18350
  prompt: z8.string().optional(),
18287
18351
  /** Per-style override for the style being viewed; null removes it. */
@@ -18701,7 +18765,7 @@ function applyEdit(raw, edit) {
18701
18765
  }
18702
18766
  }
18703
18767
  async function withCandidate(manifestPath, edit, use, unchanged) {
18704
- const absolute = path31.resolve(manifestPath);
18768
+ const absolute = path32.resolve(manifestPath);
18705
18769
  const original = await readFile22(absolute, "utf8");
18706
18770
  if (sha256(original) !== edit.expectedSha256) throw new ManifestDriftError(absolute);
18707
18771
  let raw;
@@ -18715,9 +18779,9 @@ async function withCandidate(manifestPath, edit, use, unchanged) {
18715
18779
  applyEdit(raw, edit);
18716
18780
  const next = serializeLike(original, raw);
18717
18781
  if (next === original) return unchanged(absolute, original);
18718
- const tmp = path31.join(
18719
- path31.dirname(absolute),
18720
- `.${path31.basename(absolute)}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`
18782
+ const tmp = path32.join(
18783
+ path32.dirname(absolute),
18784
+ `.${path32.basename(absolute)}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`
18721
18785
  );
18722
18786
  try {
18723
18787
  await writeFile12(tmp, next);
@@ -18748,16 +18812,16 @@ async function applyManifestEdit(manifestPath, edit) {
18748
18812
  // src/pipeline/hand-edit.ts
18749
18813
  import { existsSync as existsSync28 } from "fs";
18750
18814
  import { copyFile, mkdir as mkdir10, readFile as readFile23, rename as rename9, rm as rm9, writeFile as writeFile13 } from "fs/promises";
18751
- import path32 from "path";
18815
+ import path33 from "path";
18752
18816
  import { z as z9 } from "zod";
18753
18817
  var HAND_EDIT_DIR = "edits";
18754
18818
  function handEditPath(loaded, spec) {
18755
18819
  const style = loaded.manifest.styles[spec.styleId];
18756
- const outDir = path32.resolve(loaded.root, style?.outDir ?? ".");
18757
- const relative = path32.relative(outDir, spec.outFile);
18758
- const inside = relative && !relative.startsWith("..") && !path32.isAbsolute(relative);
18759
- const file = inside ? relative : path32.basename(spec.outFile);
18760
- return path32.join(outDir, HAND_EDIT_DIR, file.replace(/\.gif$/i, ".png"));
18820
+ const outDir = path33.resolve(loaded.root, style?.outDir ?? ".");
18821
+ const relative = path33.relative(outDir, spec.outFile);
18822
+ const inside = relative && !relative.startsWith("..") && !path33.isAbsolute(relative);
18823
+ const file = inside ? relative : path33.basename(spec.outFile);
18824
+ return path33.join(outDir, HAND_EDIT_DIR, file.replace(/\.gif$/i, ".png"));
18761
18825
  }
18762
18826
  function handEditBases(spec, lock) {
18763
18827
  const entry = lock.entries[lockKey(spec.styleId, spec.assetId)];
@@ -18803,7 +18867,7 @@ async function startHandEdit(loaded, lock, spec, opts = {}) {
18803
18867
  `${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`
18804
18868
  );
18805
18869
  }
18806
- const existing = spec.source ? path32.resolve(loaded.root, spec.source) : null;
18870
+ const existing = spec.source ? path33.resolve(loaded.root, spec.source) : null;
18807
18871
  const editPath = existing ?? handEditPath(loaded, spec);
18808
18872
  const members = handEditMembers(loaded, spec, lock, editPath);
18809
18873
  let created = false;
@@ -18814,7 +18878,7 @@ async function startHandEdit(loaded, lock, spec, opts = {}) {
18814
18878
  `${spec.styleId}/${spec.assetId} has no generated PNG on disk to start from; generate or restore it first`
18815
18879
  );
18816
18880
  }
18817
- await mkdir10(path32.dirname(member.path), { recursive: true });
18881
+ await mkdir10(path33.dirname(member.path), { recursive: true });
18818
18882
  await copyFile(member.base, member.path);
18819
18883
  created = true;
18820
18884
  }
@@ -18952,7 +19016,7 @@ async function saveHandEdit(loaded, lock, spec, input) {
18952
19016
  editor: input.editor,
18953
19017
  protocol: input.protocol,
18954
19018
  savedAt: (input.now ?? /* @__PURE__ */ new Date()).toISOString(),
18955
- project: projectPath ? path32.basename(projectPath) : null,
19019
+ project: projectPath ? path33.basename(projectPath) : null,
18956
19020
  outputs: incoming.map((frame, index) => ({
18957
19021
  role: frame.role,
18958
19022
  basedOn: basedOnHash(entry, index),
@@ -18996,7 +19060,7 @@ function openInEditor(file, editor = process.env.PIXELKILN_EDITOR) {
18996
19060
  // src/gallery/upload.ts
18997
19061
  import { existsSync as existsSync29 } from "fs";
18998
19062
  import { mkdir as mkdir11, writeFile as writeFile14 } from "fs/promises";
18999
- import path33 from "path";
19063
+ import path34 from "path";
19000
19064
  import { z as z10 } from "zod";
19001
19065
  var MAX_UPLOAD_BYTES = 8 * 1024 * 1024;
19002
19066
  var UploadImageSchema = z10.object({
@@ -19009,12 +19073,12 @@ var UploadImageSchema = z10.object({
19009
19073
  overwrite: z10.boolean().optional()
19010
19074
  }).strict();
19011
19075
  async function saveProjectImage(root, request) {
19012
- const file = path33.resolve(root, request.path);
19013
- const relative = path33.relative(root, file);
19014
- if (relative.startsWith("..") || path33.isAbsolute(relative)) {
19076
+ const file = path34.resolve(root, request.path);
19077
+ const relative = path34.relative(root, file);
19078
+ if (relative.startsWith("..") || path34.isAbsolute(relative)) {
19015
19079
  throw new ManifestEditError("an upload must stay inside the project");
19016
19080
  }
19017
- const extension = path33.extname(file).toLowerCase();
19081
+ const extension = path34.extname(file).toLowerCase();
19018
19082
  const expected = extension === ".png" ? "png" : extension === ".jpg" || extension === ".jpeg" ? "jpeg" : null;
19019
19083
  if (!expected) throw new ManifestEditError("an upload must be a .png, .jpg, or .jpeg path");
19020
19084
  const bytes = Buffer.from(request.base64, "base64");
@@ -19027,17 +19091,17 @@ async function saveProjectImage(root, request) {
19027
19091
  throw new ManifestEditError(`the upload is a ${metadata.format.toUpperCase()}; name it ${metadata.format === "png" ? ".png" : ".jpg"}`);
19028
19092
  }
19029
19093
  if (existsSync29(file) && !request.overwrite) {
19030
- throw new ManifestEditError(`${relative.split(path33.sep).join("/")} already exists; choose another name, or replace it`);
19094
+ throw new ManifestEditError(`${relative.split(path34.sep).join("/")} already exists; choose another name, or replace it`);
19031
19095
  }
19032
- await mkdir11(path33.dirname(file), { recursive: true });
19096
+ await mkdir11(path34.dirname(file), { recursive: true });
19033
19097
  await writeFile14(file, bytes);
19034
- return relative.split(path33.sep).join("/");
19098
+ return relative.split(path34.sep).join("/");
19035
19099
  }
19036
19100
 
19037
19101
  // src/gallery/image-revision.ts
19038
19102
  import { existsSync as existsSync30 } from "fs";
19039
19103
  import { readFile as readFile24, rm as rm10, writeFile as writeFile15 } from "fs/promises";
19040
- import path34 from "path";
19104
+ import path35 from "path";
19041
19105
  import { z as z11 } from "zod";
19042
19106
  var InpaintRevisionRequestSchema = z11.object({
19043
19107
  action: z11.literal("create-inpaint-revision"),
@@ -19056,14 +19120,14 @@ var InpaintRevisionRequestSchema = z11.object({
19056
19120
  overwrite: z11.boolean().optional()
19057
19121
  }).strict();
19058
19122
  async function createInpaintRevision(manifestPath, request) {
19059
- const root = path34.dirname(path34.resolve(manifestPath));
19060
- if (path34.extname(request.maskPath).toLowerCase() !== ".png") {
19123
+ const root = path35.dirname(path35.resolve(manifestPath));
19124
+ if (path35.extname(request.maskPath).toLowerCase() !== ".png") {
19061
19125
  throw new ManifestEditError("the mask must be a .png path inside the project");
19062
19126
  }
19063
19127
  const bytes = Buffer.from(request.maskBase64, "base64");
19064
19128
  const metadata = imageMetadata(bytes);
19065
19129
  if (!metadata || metadata.format !== "png") throw new ManifestEditError("the mask is not a readable PNG");
19066
- const file = path34.resolve(root, request.maskPath);
19130
+ const file = path35.resolve(root, request.maskPath);
19067
19131
  const previous = existsSync30(file) ? await readFile24(file) : null;
19068
19132
  const mask = await saveProjectImage(root, {
19069
19133
  action: "upload-image",
@@ -19093,7 +19157,7 @@ async function createInpaintRevision(manifestPath, request) {
19093
19157
  // src/gallery/skeleton.ts
19094
19158
  import { existsSync as existsSync31 } from "fs";
19095
19159
  import { mkdir as mkdir12, readFile as readFile25, rm as rm11, writeFile as writeFile16 } from "fs/promises";
19096
- import path35 from "path";
19160
+ import path36 from "path";
19097
19161
  import { z as z12 } from "zod";
19098
19162
  var SkeletonEstimateRequestSchema = z12.object({
19099
19163
  project: z12.string().min(1).optional(),
@@ -19132,10 +19196,10 @@ var SkeletonKeypointsUpdateSchema = z12.object({
19132
19196
  set: SkeletonSetSchema
19133
19197
  }).strict();
19134
19198
  async function createSkeletonAnimation(manifestPath, request) {
19135
- const root = path35.dirname(path35.resolve(manifestPath));
19136
- const file = path35.resolve(root, request.keypointsFile);
19137
- const relative = path35.relative(root, file);
19138
- if (!request.keypointsFile.endsWith(".json") || relative.startsWith("..") || path35.isAbsolute(relative)) {
19199
+ const root = path36.dirname(path36.resolve(manifestPath));
19200
+ const file = path36.resolve(root, request.keypointsFile);
19201
+ const relative = path36.relative(root, file);
19202
+ if (!request.keypointsFile.endsWith(".json") || relative.startsWith("..") || path36.isAbsolute(relative)) {
19139
19203
  throw new ManifestEditError("the keypoints file must be a .json path inside the project");
19140
19204
  }
19141
19205
  const existed = existsSync31(file);
@@ -19145,7 +19209,7 @@ async function createSkeletonAnimation(manifestPath, request) {
19145
19209
  throw new ManifestEditError(`${request.keypointsFile} already exists; choose another path, or replace it`);
19146
19210
  }
19147
19211
  if (existed) previous = await readFile25(file);
19148
- await mkdir12(path35.dirname(file), { recursive: true });
19212
+ await mkdir12(path36.dirname(file), { recursive: true });
19149
19213
  await writeFile16(file, JSON.stringify(request.set, null, 2) + "\n");
19150
19214
  } else if (!existed) {
19151
19215
  throw new ManifestEditError(`${request.keypointsFile} does not exist; paste poses or estimate them from the sprite`);
@@ -19161,7 +19225,7 @@ async function createSkeletonAnimation(manifestPath, request) {
19161
19225
  revision: {
19162
19226
  mode: "animate-skeleton",
19163
19227
  from: request.from,
19164
- keypointsFile: relative.split(path35.sep).join("/"),
19228
+ keypointsFile: relative.split(path36.sep).join("/"),
19165
19229
  direction: request.direction,
19166
19230
  description: request.description,
19167
19231
  ...request.skeletonTemplate ? { skeletonTemplate: request.skeletonTemplate } : {}
@@ -19182,19 +19246,19 @@ async function updateSkeletonKeypoints(ctx, request) {
19182
19246
  if (!spec) throw new ManifestEditError(`"${key2}" is not declared by the manifest`);
19183
19247
  const file = spec.revision?.mode === "animate-skeleton" ? spec.revision.keypointsFile : void 0;
19184
19248
  if (!file) throw new ManifestEditError(`${key2} is not an animate-skeleton revision`);
19185
- const relative = path35.relative(ctx.loaded.root, file);
19186
- if (relative.startsWith("..") || path35.isAbsolute(relative)) {
19249
+ const relative = path36.relative(ctx.loaded.root, file);
19250
+ if (relative.startsWith("..") || path36.isAbsolute(relative)) {
19187
19251
  throw new ManifestEditError(`${key2}'s keypoints file is outside the project; edit it by hand`);
19188
19252
  }
19189
19253
  const current = existsSync31(file) ? sha256(await readFile25(file)) : null;
19190
19254
  if (current !== request.expectedSha256) {
19191
19255
  throw Object.assign(
19192
- new Error(`${relative.split(path35.sep).join("/")} changed on disk since this page loaded it; press Refresh and edit again`),
19256
+ new Error(`${relative.split(path36.sep).join("/")} changed on disk since this page loaded it; press Refresh and edit again`),
19193
19257
  { status: 409 }
19194
19258
  );
19195
19259
  }
19196
19260
  await writeFile16(file, JSON.stringify(request.set, null, 2) + "\n");
19197
- return relative.split(path35.sep).join("/");
19261
+ return relative.split(path36.sep).join("/");
19198
19262
  }
19199
19263
 
19200
19264
  // src/gallery/edit.ts
@@ -19248,7 +19312,7 @@ function createGalleryEditHandler(opts) {
19248
19312
  const history = /* @__PURE__ */ new Map();
19249
19313
  const manifestOf = async (project) => {
19250
19314
  try {
19251
- return path36.resolve(await opts.manifestFor(typeof project === "string" ? project : void 0));
19315
+ return path37.resolve(await opts.manifestFor(typeof project === "string" ? project : void 0));
19252
19316
  } catch {
19253
19317
  return null;
19254
19318
  }
@@ -19271,7 +19335,7 @@ function createGalleryEditHandler(opts) {
19271
19335
  await writeFile17(tmp, last.before);
19272
19336
  await rename10(tmp, manifestPath2);
19273
19337
  stack.pop();
19274
- log(` manifest edit undone in ${path36.relative(process.cwd(), manifestPath2) || manifestPath2}`);
19338
+ log(` manifest edit undone in ${path37.relative(process.cwd(), manifestPath2) || manifestPath2}`);
19275
19339
  return opts.reload();
19276
19340
  }
19277
19341
  const manifestPath = await manifestOf(body?.project);
@@ -19333,7 +19397,7 @@ function createEditApplier(opts, log) {
19333
19397
  } catch (error) {
19334
19398
  throw new ManifestEditError(error instanceof Error ? error.message : String(error));
19335
19399
  }
19336
- const written = await saveProjectImage(path36.dirname(path36.resolve(manifestPath2)), upload.data);
19400
+ const written = await saveProjectImage(path37.dirname(path37.resolve(manifestPath2)), upload.data);
19337
19401
  log(` image added: ${written}`);
19338
19402
  return opts.reload();
19339
19403
  }
@@ -19400,7 +19464,7 @@ function createEditApplier(opts, log) {
19400
19464
  }
19401
19465
  const result = await applyManifestEdit(manifestPath, parsed.data);
19402
19466
  if (result.changed) {
19403
- const relative = path36.relative(process.cwd(), result.manifestPath);
19467
+ const relative = path37.relative(process.cwd(), result.manifestPath);
19404
19468
  const shown = !relative || relative.startsWith("..") ? result.manifestPath : relative;
19405
19469
  log(` manifest edited: ${describeEdit(parsed.data)} in ${shown}`);
19406
19470
  }
@@ -19428,7 +19492,7 @@ function describeEdit(edit) {
19428
19492
  // src/gallery/snapshot.ts
19429
19493
  var PROJECT_FILE_TYPE = "application/octet-stream";
19430
19494
  function galleryMediaId(absolutePath) {
19431
- return createHash5("sha256").update(path37.resolve(absolutePath)).digest("hex").slice(0, 24);
19495
+ return createHash5("sha256").update(path38.resolve(absolutePath)).digest("hex").slice(0, 24);
19432
19496
  }
19433
19497
  function galleryMediaRoute(id) {
19434
19498
  return `/media/${id}`;
@@ -19452,7 +19516,7 @@ function describeHistory(media, entry, cacheDir) {
19452
19516
  return (entry.history ?? []).map((generation, i) => {
19453
19517
  const outputs = generation.outputs.map((output) => {
19454
19518
  const mediaType = output.mediaType ?? MediaType.PNG;
19455
- const file = path37.join(cacheDir, cacheFileName(output.sha256, mediaType));
19519
+ const file = path38.join(cacheDir, cacheFileName(output.sha256, mediaType));
19456
19520
  let url = null;
19457
19521
  if (existsSync32(file)) {
19458
19522
  const id = galleryMediaId(file);
@@ -19584,9 +19648,9 @@ async function describeOutput(media, root, absolutePath, recorded = {}) {
19584
19648
  async function describeQuality(media, root, inspection) {
19585
19649
  const outputPaths = inspection.outputs ?? [inspection.output];
19586
19650
  const outputs = await Promise.all(
19587
- outputPaths.map((file) => describeOutput(media, root, path37.resolve(root, file)))
19651
+ outputPaths.map((file) => describeOutput(media, root, path38.resolve(root, file)))
19588
19652
  );
19589
- const recordPath = path37.resolve(root, inspection.record);
19653
+ const recordPath = path38.resolve(root, inspection.record);
19590
19654
  const recordExists = existsSync32(recordPath);
19591
19655
  let options = null;
19592
19656
  let check = null;
@@ -19606,7 +19670,7 @@ async function describeQuality(media, root, inspection) {
19606
19670
  return {
19607
19671
  state: inspection.state,
19608
19672
  reason: inspection.reason,
19609
- output: portableOutputPath(path37.resolve(root, inspection.output), root),
19673
+ output: portableOutputPath(path38.resolve(root, inspection.output), root),
19610
19674
  record: portableOutputPath(recordPath, root),
19611
19675
  recordExists,
19612
19676
  outputs,
@@ -19646,7 +19710,7 @@ async function buildGallerySnapshot(opts) {
19646
19710
  const items = [];
19647
19711
  const manifestText = await readFile27(loaded.path, "utf8");
19648
19712
  const manifestSha256 = sha256(manifestText);
19649
- const cacheDir = path37.resolve(path37.dirname(opts.lockPath), ".pixelkiln", "cache");
19713
+ const cacheDir = path38.resolve(path38.dirname(opts.lockPath), ".pixelkiln", "cache");
19650
19714
  let rawStyles = {};
19651
19715
  try {
19652
19716
  const raw = JSON.parse(manifestText);
@@ -19670,7 +19734,7 @@ async function buildGallerySnapshot(opts) {
19670
19734
  )
19671
19735
  );
19672
19736
  if (spec.source) {
19673
- const editPath = path37.resolve(root, spec.source);
19737
+ const editPath = path38.resolve(root, spec.source);
19674
19738
  const memberCount = sourceIsStem(spec.source, entry, root) ? entry.outputs.length : 1;
19675
19739
  const editShas = await Promise.all(
19676
19740
  Array.from({ length: memberCount }, async (_, index) => {
@@ -19719,7 +19783,7 @@ async function buildGallerySnapshot(opts) {
19719
19783
  editStatus = edits.some((member) => !member.exists) ? "missing" : editChanged.every((changed) => !changed) ? "same" : regenerated ? "regenerated-since" : "edited";
19720
19784
  }
19721
19785
  } else if (spec.source) {
19722
- outputs = [await describeOutput(media, root, path37.resolve(root, spec.source))];
19786
+ outputs = [await describeOutput(media, root, path38.resolve(root, spec.source))];
19723
19787
  } else if (!entry && existsSync32(spec.outFile)) {
19724
19788
  outputs = [await describeOutput(media, root, spec.outFile)];
19725
19789
  } else {
@@ -19924,7 +19988,7 @@ async function buildGallerySnapshot(opts) {
19924
19988
  id: loaded.manifest.name,
19925
19989
  name: loaded.manifest.name,
19926
19990
  manifest: loaded.path,
19927
- lock: path37.resolve(opts.lockPath),
19991
+ lock: path38.resolve(opts.lockPath),
19928
19992
  root,
19929
19993
  provider: loaded.manifest.provider,
19930
19994
  account: null,
@@ -19950,7 +20014,7 @@ async function buildGallerySnapshot(opts) {
19950
20014
  return { snapshot, media };
19951
20015
  }
19952
20016
  async function buildWorkspaceGallerySnapshot(opts) {
19953
- const dir = path37.dirname(path37.resolve(opts.workspacePath));
20017
+ const dir = path38.dirname(path38.resolve(opts.workspacePath));
19954
20018
  const media = /* @__PURE__ */ new Map();
19955
20019
  const projects = [];
19956
20020
  const items = [];
@@ -19993,7 +20057,7 @@ async function buildWorkspaceGallerySnapshot(opts) {
19993
20057
  id: project.id,
19994
20058
  name: loaded.manifest.name,
19995
20059
  manifest: manifestPath,
19996
- lock: path37.resolve(lockPath),
20060
+ lock: path38.resolve(lockPath),
19997
20061
  root: loaded.root,
19998
20062
  provider: loaded.manifest.provider,
19999
20063
  account: project.account ?? null,
@@ -20009,8 +20073,8 @@ async function buildWorkspaceGallerySnapshot(opts) {
20009
20073
  id: project.id,
20010
20074
  name: project.id,
20011
20075
  manifest: manifestPath,
20012
- lock: path37.resolve(lockPath),
20013
- root: path37.dirname(manifestPath),
20076
+ lock: path38.resolve(lockPath),
20077
+ root: path38.dirname(manifestPath),
20014
20078
  provider: project.provider,
20015
20079
  account: project.account ?? null,
20016
20080
  manifestSha256: null,
@@ -20037,7 +20101,7 @@ async function buildWorkspaceGallerySnapshot(opts) {
20037
20101
  version: 1,
20038
20102
  generatedAt: (opts.now ?? (() => /* @__PURE__ */ new Date()))().toISOString(),
20039
20103
  project: null,
20040
- workspace: { path: path37.resolve(opts.workspacePath), dir, projects },
20104
+ workspace: { path: path38.resolve(opts.workspacePath), dir, projects },
20041
20105
  filter,
20042
20106
  totals: {
20043
20107
  entries: projects.reduce((sum, project) => sum + project.entries, 0),
@@ -20241,7 +20305,7 @@ import { createHash as createHash6 } from "crypto";
20241
20305
  import { existsSync as existsSync34 } from "fs";
20242
20306
  import { mkdir as mkdir13, readFile as readFile28, rename as rename11, rm as rm12, stat as stat4, writeFile as writeFile18 } from "fs/promises";
20243
20307
  import os3 from "os";
20244
- import path38 from "path";
20308
+ import path39 from "path";
20245
20309
  var EditorInstallError = class extends Error {
20246
20310
  constructor(message6, file) {
20247
20311
  super(message6);
@@ -20252,15 +20316,15 @@ var EditorInstallError = class extends Error {
20252
20316
  };
20253
20317
  function editorToolsRoot() {
20254
20318
  const override = process.env.PIXELKILN_TOOLS_DIR?.trim();
20255
- if (override) return path38.resolve(override);
20256
- if (process.platform === "darwin") return path38.join(os3.homedir(), "Library", "Caches", "pixelkiln", "tools");
20319
+ if (override) return path39.resolve(override);
20320
+ if (process.platform === "darwin") return path39.join(os3.homedir(), "Library", "Caches", "pixelkiln", "tools");
20257
20321
  if (process.platform === "win32") {
20258
- return path38.join(process.env.LOCALAPPDATA ?? path38.join(os3.homedir(), "AppData", "Local"), "pixelkiln", "tools");
20322
+ return path39.join(process.env.LOCALAPPDATA ?? path39.join(os3.homedir(), "AppData", "Local"), "pixelkiln", "tools");
20259
20323
  }
20260
- return path38.join(process.env.XDG_CACHE_HOME ?? path38.join(os3.homedir(), ".cache"), "pixelkiln", "tools");
20324
+ return path39.join(process.env.XDG_CACHE_HOME ?? path39.join(os3.homedir(), ".cache"), "pixelkiln", "tools");
20261
20325
  }
20262
20326
  function editorDir(pin = EDITOR_PIN, root = editorToolsRoot()) {
20263
- return path38.join(root, "pixelorama", pin.release ?? "unpublished");
20327
+ return path39.join(root, "pixelorama", pin.release ?? "unpublished");
20264
20328
  }
20265
20329
  function editorBaseUrl(pin = EDITOR_PIN) {
20266
20330
  const override = process.env.PIXELKILN_EDITOR_URL?.trim();
@@ -20283,7 +20347,7 @@ async function editorStatus(opts = {}) {
20283
20347
  let totalBytes = 0;
20284
20348
  for (const [name, expected] of Object.entries(pin.files)) {
20285
20349
  totalBytes += expected.bytes;
20286
- const file = path38.join(dir, name);
20350
+ const file = path39.join(dir, name);
20287
20351
  const info = existsSync34(file) ? await stat4(file).catch(() => null) : null;
20288
20352
  if (info && info.size === expected.bytes && await sha256Of(file) === expected.sha256) {
20289
20353
  installedBytes += expected.bytes;
@@ -20341,7 +20405,7 @@ async function installEditor(opts = {}) {
20341
20405
  if (digest2 !== expected.sha256) {
20342
20406
  throw new EditorInstallError(`${name}: sha256 ${digest2.slice(0, 12)}\u2026 does not match the pinned ${expected.sha256.slice(0, 12)}\u2026`, name);
20343
20407
  }
20344
- const final = path38.join(dir, name);
20408
+ const final = path39.join(dir, name);
20345
20409
  const tmp = `${final}.${process.pid}.part`;
20346
20410
  try {
20347
20411
  await writeFile18(tmp, bytes);
@@ -20387,12 +20451,12 @@ var EDITOR_CONTENT_TYPES = {
20387
20451
  ".json": "application/json; charset=utf-8"
20388
20452
  };
20389
20453
  function editorContentType(name) {
20390
- return EDITOR_CONTENT_TYPES[path38.extname(name).toLowerCase()] ?? null;
20454
+ return EDITOR_CONTENT_TYPES[path39.extname(name).toLowerCase()] ?? null;
20391
20455
  }
20392
20456
 
20393
20457
  // src/gallery/editor.ts
20394
20458
  import { readFile as readFile29 } from "fs/promises";
20395
- import path39 from "path";
20459
+ import path40 from "path";
20396
20460
  function editorRoute(release, name = "index.html") {
20397
20461
  return `/editor/${encodeURIComponent(release)}/${encodeURIComponent(name)}`;
20398
20462
  }
@@ -20465,7 +20529,7 @@ function createGalleryEditorHandlers(opts = {}) {
20465
20529
  if (!status.installed) return null;
20466
20530
  let bytes;
20467
20531
  try {
20468
- bytes = await readFile29(path39.join(dir, name));
20532
+ bytes = await readFile29(path40.join(dir, name));
20469
20533
  } catch {
20470
20534
  verified = null;
20471
20535
  return null;
@@ -21158,7 +21222,7 @@ function createGenerateHandlers(opts) {
21158
21222
  // src/pipeline/salvage.ts
21159
21223
  import { readFile as readFile31 } from "fs/promises";
21160
21224
  import { existsSync as existsSync35 } from "fs";
21161
- import path40 from "path";
21225
+ import path41 from "path";
21162
21226
  function providerClaimId(provider, objectId) {
21163
21227
  return `${encodeURIComponent(provider)}:${encodeURIComponent(objectId)}`;
21164
21228
  }
@@ -21272,20 +21336,20 @@ function matchOrphanStyle(prompt, manifest) {
21272
21336
  return matchStyleByPattern(prompt, manifest);
21273
21337
  }
21274
21338
  async function loadSiblingManifests(ownManifestPath, workspaceManifestPaths, claimPaths) {
21275
- const own = path40.resolve(ownManifestPath);
21339
+ const own = path41.resolve(ownManifestPath);
21276
21340
  const siblingManifestPaths = [
21277
21341
  .../* @__PURE__ */ new Set([
21278
21342
  ...workspaceManifestPaths,
21279
- ...claimPaths.map((c) => path40.join(path40.dirname(path40.resolve(c)), "pixelkiln.manifest.json"))
21343
+ ...claimPaths.map((c) => path41.join(path41.dirname(path41.resolve(c)), "pixelkiln.manifest.json"))
21280
21344
  ])
21281
21345
  ];
21282
21346
  const siblings = [];
21283
21347
  for (const siblingManifestPath of siblingManifestPaths) {
21284
- if (path40.resolve(siblingManifestPath) === own) continue;
21348
+ if (path41.resolve(siblingManifestPath) === own) continue;
21285
21349
  if (!existsSync35(siblingManifestPath)) continue;
21286
21350
  try {
21287
21351
  const { manifest } = await loadManifest(siblingManifestPath);
21288
- siblings.push({ label: path40.basename(path40.dirname(siblingManifestPath)), manifest });
21352
+ siblings.push({ label: path41.basename(path41.dirname(siblingManifestPath)), manifest });
21289
21353
  } catch {
21290
21354
  }
21291
21355
  }
@@ -21406,7 +21470,7 @@ async function applyTags(provider, decisions, existing, opts = {}) {
21406
21470
 
21407
21471
  // src/pick/salvage-server.ts
21408
21472
  import { mkdir as mkdir14, writeFile as writeFile19, readFile as readFile32 } from "fs/promises";
21409
- import path41 from "path";
21473
+ import path42 from "path";
21410
21474
 
21411
21475
  // src/pick/salvage-sheet.ts
21412
21476
  var escapeHtml3 = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
@@ -21572,7 +21636,7 @@ async function runSalvage(provider, orphans, ctx, opts = {}) {
21572
21636
  });
21573
21637
  const html = renderSalvageSheet(orphans, {
21574
21638
  styleId: ctx.styleId,
21575
- importDir: path41.relative(process.cwd(), ctx.importDir) || "."
21639
+ importDir: path42.relative(process.cwd(), ctx.importDir) || "."
21576
21640
  });
21577
21641
  const byId = new Map(orphans.map((o) => [o.id, o]));
21578
21642
  const existingTags = new Map(orphans.map((o) => [o.id, o.tags]));
@@ -21628,9 +21692,9 @@ async function runSalvage(provider, orphans, ctx, opts = {}) {
21628
21692
  if (!buf.subarray(0, 8).equals(PNG_SIGNATURE2)) throw new Error("not a PNG");
21629
21693
  decodePng(buf);
21630
21694
  const assetId = idFromPrompt(orphan.prompt, taken);
21631
- const rel = path41.join("_salvaged", `${assetId}.png`);
21632
- const outFile = path41.resolve(ctx.importDir, rel);
21633
- await mkdir14(path41.dirname(outFile), { recursive: true });
21695
+ const rel = path42.join("_salvaged", `${assetId}.png`);
21696
+ const outFile = path42.resolve(ctx.importDir, rel);
21697
+ await mkdir14(path42.dirname(outFile), { recursive: true });
21634
21698
  await writeFile19(outFile, buf);
21635
21699
  ctx.manifest.assets[assetId] = {
21636
21700
  prompt: orphan.prompt,
@@ -21663,7 +21727,7 @@ async function runSalvage(provider, orphans, ctx, opts = {}) {
21663
21727
  sourceUrl: durableSource,
21664
21728
  sourceUrls: durableSource ? [{ url: durableSource }] : [],
21665
21729
  outputs: [{
21666
- path: portableOutputPath(outFile, path41.dirname(ctx.manifestPath)),
21730
+ path: portableOutputPath(outFile, path42.dirname(ctx.manifestPath)),
21667
21731
  sha256: sha256(buf)
21668
21732
  }],
21669
21733
  submittedAt: orphan.createdAt,
@@ -21841,6 +21905,7 @@ export {
21841
21905
  InheritedStyleSchema,
21842
21906
  LockEntrySchema,
21843
21907
  LockHistoryEntrySchema,
21908
+ LockOriginSchema,
21844
21909
  LockSchema,
21845
21910
  LockTerrainSettingsSchema,
21846
21911
  MAX_DOWNLOAD_BYTES,