pixelkiln 0.147.0 → 0.148.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1853,14 +1853,13 @@ function proTierCost(width, height) {
1853
1853
  if (px <= 102400) return PRO_TIER_PRICES[1];
1854
1854
  return PRO_TIER_PRICES[2];
1855
1855
  }
1856
+ var PIXMINIMAX_STEPS = [1, 1, 2, 2, 3, 3, 4, 5, 5, 6];
1856
1857
  function pixMiniMaxCost(width, height, frames, enhancePrompt = false) {
1857
- const f = width * height * Math.max(1, frames) / 4096;
1858
- let units;
1859
- if (f <= 8) units = 1;
1860
- else if (f <= 16) units = 1 + (f - 8) / 8;
1861
- else if (f <= 40) units = 2 + (f - 16) / 6;
1862
- else units = 6 + (f - 40) / 6;
1863
- const base = Math.max(1, Math.ceil(units - 1e-9));
1858
+ const side = Math.max(1, width, height);
1859
+ const upscaled = side * (side <= 64 ? 4 : side <= 128 ? 2 : 1);
1860
+ const reference = Math.max(1, frames) * upscaled * upscaled / 65536;
1861
+ const step = Math.max(1, Math.ceil(reference / 4 - 1e-9));
1862
+ const base = PIXMINIMAX_STEPS[Math.min(step, PIXMINIMAX_STEPS.length) - 1];
1864
1863
  return enhancePrompt ? base + 0.05 : base;
1865
1864
  }
1866
1865
  function tilesCost(tileSize, variations) {
@@ -1955,7 +1954,7 @@ var CharacterProportionsSchema = z.union([
1955
1954
  hipWidth: z.number().min(0.5).max(2).optional()
1956
1955
  }).strict()
1957
1956
  ]);
1958
- var CharacterAnimationModeSchema = z.enum(["template", "skeleton-v3", "v3", "pro"]);
1957
+ var CharacterAnimationModeSchema = z.enum(["template", "skeleton-v3", "v3", "pixminimax", "pro"]);
1959
1958
  var UiPieceSchema = z.discriminatedUnion("kind", [
1960
1959
  z.object({
1961
1960
  id: z.string().min(1),
@@ -2279,12 +2278,13 @@ var CharacterAnimationSchema = z.object({
2279
2278
  motionFrom: z.string().min(1).optional(),
2280
2279
  /**
2281
2280
  * Frames to generate without a template. A v3 loop takes an even 4 to 16;
2282
- * a sentence loop (`mode: "skeleton-v3"` with no `template`) takes 3 to 15.
2281
+ * a pixminimax loop a multiple of 4 from 4 to 40; a sentence loop
2282
+ * (`mode: "skeleton-v3"` with no `template`) takes 3 to 15.
2283
2283
  */
2284
- frames: z.number().int().min(3).max(16).optional(),
2284
+ frames: z.number().int().min(3).max(40).optional(),
2285
2285
  /** Playback rate recorded with the frames; PixelLab does not store one. */
2286
2286
  fps: z.number().int().min(1).max(60).default(8),
2287
- /** v3 only: keep the resting pose as frame 0, so `frames` generated frames land as `frames + 1` files. */
2287
+ /** v3 and pixminimax: keep the resting pose as frame 0, so `frames` generated frames land as `frames + 1` files. */
2288
2288
  keepFirstFrame: z.boolean().default(true),
2289
2289
  /**
2290
2290
  * `character` loops: strip the ghost pixels an animation model leaves
@@ -2298,28 +2298,41 @@ var CharacterAnimationSchema = z.object({
2298
2298
  * `template` when a template is named, otherwise `v3`; `skeleton-v3`
2299
2299
  * poses a template with PixelLab's skeleton model instead, or, with no
2300
2300
  * template, animates the asset's prompt as a sentence written into one 3D
2301
- * motion (a v3 base; 3-15 `frames`); `pro` for the sequential
2302
- * high-quality engine.
2301
+ * motion (a v3 base; 3-15 `frames`); `pixminimax` draws from the
2302
+ * prompt on PixelLab's PixMiniMax engine (4 to 40 `frames`, a multiple
2303
+ * of 4); `pro` for the sequential high-quality engine.
2303
2304
  */
2304
2305
  mode: CharacterAnimationModeSchema.optional(),
2305
2306
  /**
2306
- * v3 only: a manifest-relative image of the pose to start from, instead
2307
- * of the character's rotation for this direction. Up to 256px.
2307
+ * v3 and pixminimax: a manifest-relative image of the pose to start from,
2308
+ * instead of the character's rotation for this direction. Up to 256px.
2308
2309
  */
2309
2310
  startFrame: z.string().min(1).optional(),
2310
2311
  /**
2311
- * v3 only: a pose to animate toward. The loop then interpolates from the
2312
- * start frame (the rotation, or `startFrame`) to this image, which must
2313
- * be the same size as the start frame.
2312
+ * v3 and pixminimax: a pose to animate toward. The loop then interpolates
2313
+ * from the start frame (the rotation, or `startFrame`) to this image,
2314
+ * which must be the same size as the start frame. The same image as
2315
+ * `startFrame` closes a loop.
2314
2316
  */
2315
2317
  endFrame: z.string().min(1).optional(),
2316
- /** What is being animated, when the character's own description would mislead the model. */
2318
+ /**
2319
+ * What is being animated, when the character's own description would
2320
+ * mislead the model. On a pixminimax loop it is PixelLab's
2321
+ * `subject_description`, one noun phrase of up to 300 characters; left
2322
+ * out, PixelLab reads it off the start frame.
2323
+ */
2317
2324
  subject: z.string().min(1).optional(),
2325
+ /**
2326
+ * pixminimax only: the pose the start frame shows, up to 300 characters
2327
+ * ("standing beside the pole, one hand on it"). Left out, PixelLab reads
2328
+ * it off the image.
2329
+ */
2330
+ initialPose: z.string().min(1).max(300).optional(),
2318
2331
  /** Template mode only: style hints for this loop, over the character's own. */
2319
2332
  outline: z.string().min(1).optional(),
2320
2333
  shading: z.string().min(1).optional(),
2321
2334
  detail: z.string().min(1).optional(),
2322
- /** v3 text loops only: let PixelLab expand the action into a fuller motion description first. */
2335
+ /** v3 and pixminimax text loops only: let PixelLab expand the action into a fuller motion description first. */
2323
2336
  enhancePrompt: z.boolean().optional()
2324
2337
  }).strict().superRefine((animation, context) => {
2325
2338
  if (animation.directions !== void 0) {
@@ -2330,22 +2343,29 @@ var CharacterAnimationSchema = z.object({
2330
2343
  });
2331
2344
  }
2332
2345
  const sentence = animation.mode === "skeleton-v3" && !animation.template;
2333
- if (animation.frames !== void 0 && !sentence && animation.mode !== "pro") {
2346
+ const pixminimax = animation.mode === "pixminimax";
2347
+ if (animation.frames !== void 0 && pixminimax) {
2348
+ if (animation.frames % 4 !== 0 || animation.frames < 4) {
2349
+ context.addIssue({ code: z.ZodIssueCode.custom, message: "a pixminimax loop takes a multiple of 4 frames, 4 to 40", path: ["frames"] });
2350
+ }
2351
+ } else if (animation.frames !== void 0 && !sentence && animation.mode !== "pro") {
2334
2352
  if (animation.frames % 2 !== 0) {
2335
2353
  context.addIssue({ code: z.ZodIssueCode.custom, message: "frames must be even", path: ["frames"] });
2336
- } else if (animation.frames < 4) {
2337
- context.addIssue({ code: z.ZodIssueCode.custom, message: "frames must be 4 to 16", path: ["frames"] });
2354
+ } else if (animation.frames < 4 || animation.frames > 16) {
2355
+ context.addIssue({ code: z.ZodIssueCode.custom, message: "frames must be 4 to 16 (a pixminimax loop takes up to 40)", path: ["frames"] });
2338
2356
  }
2357
+ } else if (animation.frames !== void 0 && animation.mode === "pro" && animation.frames > 16) {
2358
+ context.addIssue({ code: z.ZodIssueCode.custom, message: "frames must be 16 or fewer", path: ["frames"] });
2339
2359
  }
2340
2360
  if (animation.frames !== void 0 && sentence && animation.frames > 15) {
2341
2361
  context.addIssue({ code: z.ZodIssueCode.custom, message: "a skeleton-v3 loop from a sentence takes 3 to 15 frames", path: ["frames"] });
2342
2362
  }
2343
2363
  const mode2 = animation.mode ?? (animation.template ? "template" : "v3");
2344
2364
  for (const key3 of ["startFrame", "endFrame", "enhancePrompt"]) {
2345
- if (animation[key3] !== void 0 && mode2 !== "v3") {
2365
+ if (animation[key3] !== void 0 && mode2 !== "v3" && mode2 !== "pixminimax") {
2346
2366
  context.addIssue({
2347
2367
  code: z.ZodIssueCode.custom,
2348
- message: `${key3} is for v3 loops; a ${mode2} loop ${mode2 === "template" || mode2 === "skeleton-v3" ? `starts from the character's rotation and ${animation.template ? "follows its template" : "animates its sentence"}` : "takes neither"}`,
2368
+ message: `${key3} is for v3 and pixminimax loops; a ${mode2} loop ${mode2 === "template" || mode2 === "skeleton-v3" ? `starts from the character's rotation and ${animation.template ? "follows its template" : "animates its sentence"}` : "takes neither"}`,
2349
2369
  path: [key3]
2350
2370
  });
2351
2371
  }
@@ -2355,6 +2375,12 @@ var CharacterAnimationSchema = z.object({
2355
2375
  context.addIssue({ code: z.ZodIssueCode.custom, message: `${key3} overrides apply to template loops only`, path: [key3] });
2356
2376
  }
2357
2377
  }
2378
+ if (animation.initialPose !== void 0 && mode2 !== "pixminimax") {
2379
+ context.addIssue({ code: z.ZodIssueCode.custom, message: `initialPose is for pixminimax loops; PixelLab's ${mode2} engine takes no pose caption`, path: ["initialPose"] });
2380
+ }
2381
+ if (pixminimax && animation.subject !== void 0 && animation.subject.length > 300) {
2382
+ context.addIssue({ code: z.ZodIssueCode.custom, message: "a pixminimax loop's subject is one noun phrase of up to 300 characters", path: ["subject"] });
2383
+ }
2358
2384
  if (animation.template && animation.mode && animation.mode !== "template" && animation.mode !== "skeleton-v3") {
2359
2385
  context.addIssue({
2360
2386
  code: z.ZodIssueCode.custom,
@@ -4651,10 +4677,10 @@ function despeckle(png, options) {
4651
4677
  for (const still of options.reference) {
4652
4678
  const { pixels } = decodePng(still);
4653
4679
  for (let i = 0; i < pixels.length; i += 4) {
4654
- if (pixels[i + 3] === 0 || outline(pixels, i)) continue;
4680
+ if (pixels[i + 3] === 0) continue;
4655
4681
  const rgb = pixels[i] << 16 | pixels[i + 1] << 8 | pixels[i + 2];
4656
4682
  palette.set(rgb, (palette.get(rgb) ?? 0) + 1);
4657
- total++;
4683
+ if (!outline(pixels, i)) total++;
4658
4684
  }
4659
4685
  }
4660
4686
  if (!total) throw new Error("the reference stills have no opaque pixels that are not outline");
@@ -4714,7 +4740,7 @@ function despeckle(png, options) {
4714
4740
  const strange = run.filter(([x, y]) => foreign(at(image, x, y))).length / run.length > 0.5;
4715
4741
  let debris;
4716
4742
  const exposed = run.some(([x, y]) => STEPS.some(([dx, dy]) => open2(x + dx, y + dy)));
4717
- if (strange && !exposed && run.length > limb) {
4743
+ if (strange && run.length > limb) {
4718
4744
  debris = false;
4719
4745
  limbs.add(index);
4720
4746
  } else if (exposed) {
@@ -4749,6 +4775,7 @@ function despeckle(png, options) {
4749
4775
  if (src[at(image, x, y) + 3] > 0 && out[at(image, x, y) + 3] === 0) frontier.push([x, y]);
4750
4776
  }
4751
4777
  }
4778
+ const seeds = frontier.length;
4752
4779
  for (let n = 0; n < frontier.length; n++) {
4753
4780
  const [fx, fy] = frontier[n];
4754
4781
  for (let dy = -1; dy <= 1; dy++) {
@@ -4772,6 +4799,31 @@ function despeckle(png, options) {
4772
4799
  }
4773
4800
  }
4774
4801
  }
4802
+ const chained = new Set(frontier.slice(seeds).map(([x, y]) => local(x, y)));
4803
+ const visited = /* @__PURE__ */ new Set();
4804
+ for (const [sx, sy] of frontier.slice(seeds)) {
4805
+ if (visited.has(local(sx, sy))) continue;
4806
+ const group = [[sx, sy]];
4807
+ visited.add(local(sx, sy));
4808
+ for (let n = 0; n < group.length; n++) {
4809
+ const [gx, gy] = group[n];
4810
+ for (let dy = -1; dy <= 1; dy++) {
4811
+ for (let dx = -1; dx <= 1; dx++) {
4812
+ const x = gx + dx;
4813
+ const y = gy + dy;
4814
+ if (!inside(cell, x, y) || visited.has(local(x, y)) || !chained.has(local(x, y))) continue;
4815
+ visited.add(local(x, y));
4816
+ group.push([x, y]);
4817
+ }
4818
+ }
4819
+ }
4820
+ if (group.length <= limb) continue;
4821
+ for (const [x, y] of group) {
4822
+ const i = at(image, x, y);
4823
+ src.copy(out, i, i, i + 4);
4824
+ removed--;
4825
+ }
4826
+ }
4775
4827
  }
4776
4828
  return { png: encodeRgbaPng(image.width, image.height, out), removed };
4777
4829
  }
@@ -5188,10 +5240,13 @@ function applyPostprocess(bytes, mediaType, record, reference = [], role) {
5188
5240
  if (mediaType !== MediaType.PNG || !record?.palette && !record?.despeckle && !record?.offset) return { bytes, changed: false };
5189
5241
  let out = bytes;
5190
5242
  let removed = 0;
5243
+ let opaque2 = 0;
5191
5244
  if (record.despeckle) {
5192
5245
  if (!reference.length) throw new Error(`cleaning needs the rotations of ${record.despeckle.of}, and none were given`);
5193
5246
  const cleaned = despeckle(out, { reference });
5194
5247
  if (cleaned.removed) {
5248
+ const { pixels } = decodePng(out);
5249
+ for (let i = 3; i < pixels.length; i += 4) if (pixels[i] > 0) opaque2++;
5195
5250
  out = cleaned.png;
5196
5251
  removed = cleaned.removed;
5197
5252
  }
@@ -5215,8 +5270,9 @@ function applyPostprocess(bytes, mediaType, record, reference = [], role) {
5215
5270
  }
5216
5271
  }
5217
5272
  if (!removed && !snapped && !moved) return { bytes, changed: false };
5218
- return { bytes: out, changed: true, ...removed ? { removed } : {}, ...snapped ? { snapped } : {}, ...moved ? { moved } : {} };
5273
+ return { bytes: out, changed: true, ...removed ? { removed, opaque: opaque2 } : {}, ...snapped ? { snapped } : {}, ...moved ? { moved } : {} };
5219
5274
  }
5275
+ var CLEAN_DAMAGE_SHARE = 0.03;
5220
5276
 
5221
5277
  // src/pipeline/mirror.ts
5222
5278
  function mirrorSourceHash(source) {
@@ -7566,10 +7622,15 @@ async function buildPlan(specs, lock, opts = {}) {
7566
7622
  } else if (spec.mirror && entry.status === "downloaded" && entry.outputs.some((_output, index) => !existsSync7(currentEntryOutputPath(entry, spec, index)))) {
7567
7623
  state = "stale";
7568
7624
  reason = "mirror output missing on disk; flip it again (no generation cost)";
7569
- } else if (spec.character?.kind === "outfit" && entry.outfit?.sourceSha256 !== mirrorSourceHash(lock.entries[lockKey(spec.styleId, spec.character.parentAssetId)] ?? { outputs: [] })) {
7625
+ } else if (
7626
+ // A mirror carries its source's character shape, but it is a flip of
7627
+ // the source's files: whether it is current is the check above, never
7628
+ // the outfit or layer rule its source answers to (#418).
7629
+ !spec.mirror && spec.character?.kind === "outfit" && entry.outfit?.sourceSha256 !== mirrorSourceHash(lock.entries[lockKey(spec.styleId, spec.character.parentAssetId)] ?? { outputs: [] })
7630
+ ) {
7570
7631
  state = "stale";
7571
7632
  reason = `outfit source ${spec.character.parentAssetId} changed; re-clothe the loop again`;
7572
- } else if (spec.character?.kind === "layer" && changedLayerSource(spec, entry, lock)) {
7633
+ } else if (!spec.mirror && spec.character?.kind === "layer" && changedLayerSource(spec, entry, lock)) {
7573
7634
  state = "stale";
7574
7635
  reason = isHeldItem(spec) ? `layer source ${changedLayerSource(spec, entry, lock)} changed; place the item again (no generation cost)` : `layer source ${changedLayerSource(spec, entry, lock)} changed; dress the frames again`;
7575
7636
  } else if (isHeldItem(spec) && entry.status === "downloaded" && entry.outputs.some((_output, index) => !existsSync7(currentEntryOutputPath(entry, spec, index)))) {
@@ -7637,6 +7698,7 @@ async function buildPlan(specs, lock, opts = {}) {
7637
7698
  }
7638
7699
  const isActionable = (i) => i.state === "missing" || i.state === "stale" || i.state === "failed";
7639
7700
  const stateOf = new Map(items.map((i) => [i.key, i.state]));
7701
+ const waiting = /* @__PURE__ */ new Set();
7640
7702
  for (const item of items) {
7641
7703
  if (!isActionable(item)) continue;
7642
7704
  for (const parent of dependencies(item.spec)) {
@@ -7645,11 +7707,35 @@ async function buildPlan(specs, lock, opts = {}) {
7645
7707
  if (parentState && isActionable({ state: parentState })) {
7646
7708
  item.state = "blocked";
7647
7709
  item.reason = `parent ${parentKey} is being generated in this run; this follows in the next wave`;
7710
+ waiting.add(item.key);
7648
7711
  break;
7649
7712
  }
7650
7713
  if ((item.spec.mirror || item.spec.derive || isHeldItem(item.spec)) && (parentState === "recoverable" || parentState === "in-flight")) {
7651
7714
  item.state = "blocked";
7652
7715
  item.reason = `mirror source ${parentKey} is ${parentState}; this follows in the next wave`;
7716
+ waiting.add(item.key);
7717
+ break;
7718
+ }
7719
+ }
7720
+ }
7721
+ const byKey = new Map(items.map((i) => [i.key, i]));
7722
+ for (let changed = true; changed; ) {
7723
+ changed = false;
7724
+ for (const item of items) {
7725
+ if (item.state !== "blocked" || waiting.has(item.key)) continue;
7726
+ for (const parent of dependencies(item.spec)) {
7727
+ const parentKey = lockKey(parent.styleId, parent.assetId);
7728
+ const parentItem = byKey.get(parentKey);
7729
+ if (!parentItem || !item.reason.includes(`${parentKey} is not ready`)) continue;
7730
+ if (isActionable(parentItem)) {
7731
+ item.reason = `waits for ${parentKey}, which this run generates first; follows in a later wave (${item.reason})`;
7732
+ } else if (waiting.has(parentKey)) {
7733
+ item.reason = `waits for ${parentKey}, which itself follows in a later wave of this run (${item.reason})`;
7734
+ } else {
7735
+ continue;
7736
+ }
7737
+ waiting.add(item.key);
7738
+ changed = true;
7653
7739
  break;
7654
7740
  }
7655
7741
  }
@@ -10078,8 +10164,11 @@ var PixelLabClient = class {
10078
10164
  * One animation of one character. Template mode costs a generation per
10079
10165
  * direction and fixes the frame count; skeleton-v3 poses the same template
10080
10166
  * with the skeleton video model (2-4 generations per direction); v3 draws
10081
- * `frameCount` frames from the action text; pro is the sequential engine.
10082
- * One job per direction.
10167
+ * `frameCount` frames from the action text; pixminimax does the same on
10168
+ * PixelLab's PixMiniMax engine (a multiple of 4 frames up to 40, the same
10169
+ * start/end frames, `keep_first_frame` and `enhance_prompt`, plus its own
10170
+ * `subject_description` and `initial_pose` captions); pro is the
10171
+ * sequential engine. One job per direction.
10083
10172
  *
10084
10173
  * Every mode but skeleton-v3 goes to `/animate-character`, the path whose
10085
10174
  * shapes were measured live. skeleton-v3 is documented only on
@@ -10095,6 +10184,7 @@ var PixelLabClient = class {
10095
10184
  async animateCharacter(args) {
10096
10185
  const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
10097
10186
  const endpoint = args.mode === "skeleton-v3" ? "/characters/animations" : "/animate-character";
10187
+ const custom = args.mode === "v3" || args.mode === "pixminimax";
10098
10188
  const raw = await this.request(endpoint, {
10099
10189
  method: "POST",
10100
10190
  body: JSON.stringify({
@@ -10106,12 +10196,14 @@ var PixelLabClient = class {
10106
10196
  ...args.template ? { template_animation_id: args.template } : {},
10107
10197
  ...args.actionDescription ? { action_description: args.actionDescription } : {},
10108
10198
  ...args.description ? { description: args.description } : {},
10109
- // A template fixes its own frame count; v3 and a skeleton-v3 sentence take one.
10110
- ...(args.mode === "v3" || args.mode === "skeleton-v3" && !args.template) && args.frameCount ? { frame_count: args.frameCount } : {},
10111
- ...args.mode === "v3" && args.keepFirstFrame === false ? { keep_first_frame: false } : {},
10112
- ...args.mode === "v3" && args.startFrame ? { custom_start_frame: encode(args.startFrame) } : {},
10113
- ...args.mode === "v3" && args.endFrame ? { end_frame: encode(args.endFrame) } : {},
10114
- ...args.mode === "v3" && args.enhancePrompt ? { enhance_prompt: true } : {},
10199
+ // A template fixes its own frame count; v3, pixminimax and a skeleton-v3 sentence take one.
10200
+ ...(custom || args.mode === "skeleton-v3" && !args.template) && args.frameCount ? { frame_count: args.frameCount } : {},
10201
+ ...custom && args.keepFirstFrame === false ? { keep_first_frame: false } : {},
10202
+ ...custom && args.startFrame ? { custom_start_frame: encode(args.startFrame) } : {},
10203
+ ...custom && args.endFrame ? { end_frame: encode(args.endFrame) } : {},
10204
+ ...custom && args.enhancePrompt ? { enhance_prompt: true } : {},
10205
+ ...args.mode === "pixminimax" && args.subjectDescription ? { subject_description: args.subjectDescription } : {},
10206
+ ...args.mode === "pixminimax" && args.initialPose ? { initial_pose: args.initialPose } : {},
10115
10207
  ...args.mode === "template" && args.textGuidanceScale !== void 0 ? { text_guidance_scale: args.textGuidanceScale } : {},
10116
10208
  ...args.mode === "template" && args.outline ? { outline: args.outline } : {},
10117
10209
  ...args.mode === "template" && args.shading ? { shading: args.shading } : {},
@@ -12265,6 +12357,13 @@ function characterCost(spec) {
12265
12357
  if (animation.mode === "template") return 1;
12266
12358
  if (animation.mode === "skeleton-v3") return 4;
12267
12359
  if (animation.mode === "v3") return Math.max(1, Math.ceil(px * animation.frames / 65536));
12360
+ if (animation.mode === "pixminimax") {
12361
+ const start = animation.startFrame;
12362
+ return Math.max(
12363
+ pixMiniMaxCost(spec.width, spec.height, animation.frames, animation.enhancePrompt),
12364
+ start ? pixMiniMaxCost(start.width, start.height, animation.frames, animation.enhancePrompt) : 0
12365
+ );
12366
+ }
12268
12367
  return proCharacterTierCost(spec.width, spec.height);
12269
12368
  }
12270
12369
  if (character.kind === "state" || character.kind === "portrait") return proCharacterTierCost(spec.width, spec.height);
@@ -13065,7 +13164,7 @@ var PixelLabProvider = class _PixelLabProvider {
13065
13164
  const { startFrame, endFrame } = character.animation;
13066
13165
  for (const [name, image] of [["start frame", startFrame], ["end frame", endFrame]]) {
13067
13166
  if (image && (image.width > 256 || image.height > 256)) {
13068
- throw new Error(`${label}: ${name} is ${image.width}x${image.height}; PixelLab v3 takes up to 256px`);
13167
+ throw new Error(`${label}: ${name} is ${image.width}x${image.height}; PixelLab ${character.animation.mode} takes up to 256px`);
13069
13168
  }
13070
13169
  }
13071
13170
  if (endFrame) {
@@ -13180,6 +13279,9 @@ var PixelLabProvider = class _PixelLabProvider {
13180
13279
  `${spec.styleId}/${spec.assetId} needs a prompt describing the motion, or a template` + (sentence ? ' (a skeleton-v3 loop with no template animates its prompt, e.g. "swinging a sword in a wide arc")' : "")
13181
13280
  );
13182
13281
  }
13282
+ if (character.animation.mode === "pixminimax" && (character.animation.frames % 4 !== 0 || character.animation.frames < 4 || character.animation.frames > 40)) {
13283
+ throw new Error(`${spec.styleId}/${spec.assetId}: a pixminimax loop takes a multiple of 4 frames, 4 to 40; ${character.animation.frames} is not one`);
13284
+ }
13183
13285
  if (sentence && (character.animation.frames < 3 || character.animation.frames > 15)) {
13184
13286
  throw new Error(`${spec.styleId}/${spec.assetId}: a skeleton-v3 loop from a sentence takes 3 to 15 frames; ${character.animation.frames} is out of range`);
13185
13287
  }
@@ -13491,7 +13593,9 @@ var PixelLabProvider = class _PixelLabProvider {
13491
13593
  isometric: character.isometric,
13492
13594
  startFrame: animation.startFrame ? readPose(spec, "start frame", animation.startFrame) : void 0,
13493
13595
  endFrame: animation.endFrame ? readPose(spec, "end frame", animation.endFrame) : void 0,
13494
- description: animation.subject,
13596
+ // PixMiniMax captions its start frame with its own two fields; the
13597
+ // other engines take `subject` as the general `description`.
13598
+ ...animation.mode === "pixminimax" ? { subjectDescription: animation.subject, initialPose: animation.initialPose } : { description: animation.subject },
13495
13599
  outline: animation.outline,
13496
13600
  shading: animation.shading,
13497
13601
  detail: animation.detail,
@@ -18138,6 +18242,8 @@ async function resolveCharacterShape(asset, style, kind, files) {
18138
18242
  ...asset.animation.startFrame ? { startFrame: await pose(asset.animation.startFrame, "Animation start frame") } : {},
18139
18243
  ...asset.animation.endFrame ? { endFrame: await pose(asset.animation.endFrame, "Animation end frame") } : {},
18140
18244
  ...asset.animation.subject ? { subject: asset.animation.subject } : {},
18245
+ // Set only on a pixminimax loop (the schema refuses it elsewhere), so no other spec's hash moves.
18246
+ ...asset.animation.initialPose ? { initialPose: asset.animation.initialPose } : {},
18141
18247
  ...asset.animation.outline ? { outline: asset.animation.outline } : {},
18142
18248
  ...asset.animation.shading ? { shading: asset.animation.shading } : {},
18143
18249
  ...asset.animation.detail ? { detail: asset.animation.detail } : {},
@@ -18176,6 +18282,7 @@ async function resolveObjectProShape(assetId, asset, style, kind, files) {
18176
18282
  for (const [field, value] of Object.entries({
18177
18283
  template: asset.animation.template,
18178
18284
  subject: asset.animation.subject,
18285
+ initialPose: asset.animation.initialPose,
18179
18286
  outline: asset.animation.outline,
18180
18287
  shading: asset.animation.shading,
18181
18288
  detail: asset.animation.detail
@@ -18189,7 +18296,7 @@ async function resolveObjectProShape(assetId, asset, style, kind, files) {
18189
18296
  if (asset.animation.clean !== void 0) {
18190
18297
  throw new Error(`assets.${assetId}: animation.clean applies to character loops; objectPro loops are not cleaned`);
18191
18298
  }
18192
- if (asset.animation.mode === "template" || asset.animation.mode === "skeleton-v3") {
18299
+ if (asset.animation.mode === "template" || asset.animation.mode === "skeleton-v3" || asset.animation.mode === "pixminimax") {
18193
18300
  throw new Error(`assets.${assetId}: objectPro animations have no "${asset.animation.mode}" mode; use "v3" or "pro"`);
18194
18301
  }
18195
18302
  const pose = async (rel, what) => {
@@ -18432,6 +18539,9 @@ async function fetchAssets(provider, specs, lock, lockPath, opts = {}) {
18432
18539
  if (processed.changed) rawHash = sha256(raw);
18433
18540
  if (processed.moved?.clipped) log2(` moved ${path20.relative(process.cwd(), target)}: ${processed.moved.clipped} pixels fell off the canvas; raise layer.padding to keep them`);
18434
18541
  if (processed.removed) log2(` cleaned ${path20.relative(process.cwd(), target)} (${processed.removed} ghost pixels)`);
18542
+ if (processed.removed && processed.opaque && processed.removed > processed.opaque * CLEAN_DAMAGE_SHARE) {
18543
+ log2(` warning: cleaning took ${processed.removed} of ${processed.opaque} opaque pixels (${(100 * processed.removed / processed.opaque).toFixed(1)}%) from ${path20.relative(process.cwd(), target)}; check the frame for holes, and set clean: false then fetch to restore the provider's bytes`);
18544
+ }
18435
18545
  if (processed.snapped) log2(` snapped ${path20.relative(process.cwd(), target)} to ${wanted.palette.colors.length} colours`);
18436
18546
  }
18437
18547
  if (cacheDir) await cacheMedia(cacheDir, buf, mediaType);
@@ -18549,7 +18659,7 @@ async function pushTags(provider, specs, lock, opts = {}) {
18549
18659
 
18550
18660
  // src/pipeline/import.ts
18551
18661
  import { existsSync as existsSync17 } from "fs";
18552
- import { readFile as readFile12 } from "fs/promises";
18662
+ import { readdir, readFile as readFile12 } from "fs/promises";
18553
18663
  import path22 from "path";
18554
18664
 
18555
18665
  // src/pipeline/history.ts
@@ -18712,8 +18822,9 @@ async function revertGeneration(provider, spec, lock, lockPath, opts) {
18712
18822
  }
18713
18823
 
18714
18824
  // src/pipeline/import.ts
18715
- function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Date()) {
18825
+ function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Date(), frames) {
18716
18826
  const png = decodePng(bytes);
18827
+ for (const frame of frames ?? []) decodePng(frame.bytes);
18717
18828
  const at2 = now.toISOString();
18718
18829
  const origin = {
18719
18830
  ...opts.tool ? { tool: opts.tool } : {},
@@ -18738,7 +18849,14 @@ function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Da
18738
18849
  error: null,
18739
18850
  sourceUrl: null,
18740
18851
  sourceUrls: [],
18741
- outputs: [{ path: portableOutputPath(spec.outFile, spec.root), sha256: sha256(bytes) }],
18852
+ // A frame set is recorded the way fetch records one: an output per frame,
18853
+ // in order, each with its `frame-NN` role, so `plan` resolves the same paths.
18854
+ outputs: frames?.length ? frames.map((frame) => ({
18855
+ path: portableOutputPath(frame.file, spec.root),
18856
+ sha256: sha256(frame.bytes),
18857
+ role: frame.role,
18858
+ mediaType: MediaType.PNG
18859
+ })) : [{ path: portableOutputPath(spec.outFile, spec.root), sha256: sha256(bytes) }],
18742
18860
  submittedAt: null,
18743
18861
  downloadedAt: at2,
18744
18862
  cost: opts.cost ?? 0,
@@ -18753,6 +18871,32 @@ function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Da
18753
18871
  }
18754
18872
  };
18755
18873
  }
18874
+ var frameRole2 = (index) => `frame-${String(index).padStart(2, "0")}`;
18875
+ async function findFrames(spec) {
18876
+ const at2 = (index) => memberPath(spec.outFile, frameRole2(index), 0, 2, MediaType.PNG);
18877
+ const base = path22.basename(at2(0)).replace(/00\.png$/, "");
18878
+ let names = [];
18879
+ try {
18880
+ names = await readdir(path22.dirname(spec.outFile));
18881
+ } catch {
18882
+ names = [];
18883
+ }
18884
+ const found = /* @__PURE__ */ new Set();
18885
+ for (const name of names) {
18886
+ if (!name.startsWith(base)) continue;
18887
+ const match = /^(\d+)\.png$/i.exec(name.slice(base.length));
18888
+ if (match) found.add(Number(match[1]));
18889
+ }
18890
+ const expected = spec.revision?.frames;
18891
+ const expectsFrames = expected !== void 0 || spec.generator === "frames";
18892
+ if (!found.size && !expectsFrames) return null;
18893
+ const highest = found.size ? Math.max(...found) : -1;
18894
+ const upTo = Math.max(highest + 1, expected ?? 0, expectsFrames ? 1 : 0);
18895
+ const missing = [];
18896
+ for (let index = 0; index < upTo; index++) if (!found.has(index)) missing.push(at2(index));
18897
+ if (missing.length) return { missing };
18898
+ return { files: Array.from({ length: upTo }, (_, index) => ({ role: frameRole2(index), file: at2(index) })) };
18899
+ }
18756
18900
  function unimportable(spec) {
18757
18901
  if (spec.character) return "a character is several files; import it with account adopt";
18758
18902
  if (spec.vfx) return "an effect is rendered from its recipe, not imported";
@@ -18785,9 +18929,18 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
18785
18929
  skipped.push({ key: key3, reason });
18786
18930
  continue;
18787
18931
  }
18932
+ let frameFiles;
18788
18933
  if (!existsSync17(spec.outFile)) {
18789
- skipped.push({ key: key3, reason: `no file at ${spec.outFile}` });
18790
- continue;
18934
+ const frames2 = await findFrames(spec);
18935
+ if (!frames2) {
18936
+ skipped.push({ key: key3, reason: `no file at ${spec.outFile}` });
18937
+ continue;
18938
+ }
18939
+ if ("missing" in frames2) {
18940
+ skipped.push({ key: key3, reason: `frame set is missing ${frames2.missing.map((file) => path22.basename(file)).join(", ")} (in ${path22.dirname(spec.outFile)})` });
18941
+ continue;
18942
+ }
18943
+ frameFiles = frames2.files;
18791
18944
  }
18792
18945
  if (lock.entries[key3] && !opts.force) {
18793
18946
  skipped.push({ key: key3, reason: "already in the lockfile (use --force to replace it)" });
@@ -18795,9 +18948,11 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
18795
18948
  }
18796
18949
  let patch;
18797
18950
  let bytes;
18951
+ let frames;
18798
18952
  try {
18799
- bytes = await readFile12(spec.outFile);
18800
- patch = buildImportedEntry(spec, bytes, { ...opts, rawSha256 }, /* @__PURE__ */ new Date());
18953
+ frames = frameFiles ? await Promise.all(frameFiles.map(async (frame) => ({ ...frame, bytes: await readFile12(frame.file) }))) : void 0;
18954
+ bytes = frames ? frames[0].bytes : await readFile12(spec.outFile);
18955
+ patch = buildImportedEntry(spec, bytes, { ...opts, rawSha256 }, /* @__PURE__ */ new Date(), frames);
18801
18956
  } catch (error) {
18802
18957
  skipped.push({ key: key3, reason: `invalid PNG: ${error instanceof Error ? error.message : String(error)}` });
18803
18958
  continue;
@@ -18807,9 +18962,10 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
18807
18962
  continue;
18808
18963
  }
18809
18964
  const existing = lock.entries[key3];
18810
- const history = existing?.outputs[0]?.sha256 === sha256(bytes) ? existing.history : historyAfterReplacing(existing, opts.historyLimit ?? DEFAULT_HISTORY_LIMIT, patch.downloadedAt ?? (/* @__PURE__ */ new Date()).toISOString());
18965
+ const sameBytes = existing !== void 0 && existing.outputs.length === patch.outputs.length && existing.outputs.every((output, index) => output.sha256 === patch.outputs[index].sha256);
18966
+ const history = sameBytes ? existing.history : historyAfterReplacing(existing, opts.historyLimit ?? DEFAULT_HISTORY_LIMIT, patch.downloadedAt ?? (/* @__PURE__ */ new Date()).toISOString());
18811
18967
  if (cacheDir) {
18812
- await cacheMedia(cacheDir, bytes, MediaType.PNG);
18968
+ for (const member of frames ?? [{ bytes }]) await cacheMedia(cacheDir, member.bytes, MediaType.PNG);
18813
18969
  if (rawBytes) await cacheMedia(cacheDir, rawBytes, MediaType.PNG);
18814
18970
  }
18815
18971
  imported.push({ key: key3, entry: upsert(lock, key3, {
@@ -19021,12 +19177,12 @@ async function adopt(provider, specs, lock, lockPath, opts = {}) {
19021
19177
  provider: provider.id
19022
19178
  });
19023
19179
  matched++;
19024
- log2(` adopted ${key3} \u2190 ${obj.id}`);
19180
+ log2(` ${opts.dryRun ? "would adopt" : "adopted"} ${key3} \u2190 ${obj.id}`);
19025
19181
  }
19026
19182
  }
19027
19183
  }
19028
19184
  await Promise.all(Array.from({ length: Math.min(concurrency, remote.length || 1) }, worker));
19029
- await saveLock(lockPath, lock);
19185
+ if (!opts.dryRun) await saveLock(lockPath, lock);
19030
19186
  if (!opts.noCache) {
19031
19187
  pruneCache(cache, new Set(remote.map((o) => o.id)));
19032
19188
  await saveCache(cachePath, cache);
@@ -19101,7 +19257,7 @@ import path24 from "path";
19101
19257
  async function adoptCharacters(provider, specs, lock, lockPath, opts) {
19102
19258
  const log2 = opts.onProgress ?? (() => {
19103
19259
  });
19104
- const result = { scanned: 0, matched: 0, unmatched: [], remaining: [], written: [], differing: [] };
19260
+ const result = { scanned: 0, matched: 0, unmatched: [], remaining: [], written: [], differing: [], engineMismatches: [] };
19105
19261
  if (!provider.listCharacters || !provider.getCharacter) return result;
19106
19262
  const wanted = specs.filter((spec) => spec.character && !spec.mirror);
19107
19263
  if (!wanted.length) return result;
@@ -19150,6 +19306,8 @@ async function adoptCharacters(provider, specs, lock, lockPath, opts) {
19150
19306
  const file = expectedOutputPath(spec, source.role, index, sources.length);
19151
19307
  if (existsSync20(file)) {
19152
19308
  if (sha256(await readFile15(file)) !== hash) result.differing.push(path24.relative(process.cwd(), file));
19309
+ } else if (opts.dryRun) {
19310
+ result.written.push(path24.relative(process.cwd(), file));
19153
19311
  } else {
19154
19312
  await mkdir10(path24.dirname(file), { recursive: true });
19155
19313
  await writeFile11(file, bytes);
@@ -19179,7 +19337,7 @@ async function adoptCharacters(provider, specs, lock, lockPath, opts) {
19179
19337
  result.unmatched.push(`${key3}: ${err instanceof Error ? err.message : String(err)}`);
19180
19338
  }
19181
19339
  }
19182
- if (adoptedThisWave) {
19340
+ if (adoptedThisWave && !opts.dryRun) {
19183
19341
  await saveLock(lockPath, lock);
19184
19342
  current = await opts.resolve();
19185
19343
  }
@@ -19250,7 +19408,7 @@ async function adoptCharacters(provider, specs, lock, lockPath, opts) {
19250
19408
  });
19251
19409
  claimed.add(full.id);
19252
19410
  result.matched++;
19253
- log2(` adopted ${key3} \u2190 character ${full.id}${full.stateName && full.stateName !== "Idle" ? ` (${full.stateName})` : ""}`);
19411
+ log2(` ${opts.dryRun ? "would adopt" : "adopted"} ${key3} \u2190 character ${full.id}${full.stateName && full.stateName !== "Idle" ? ` (${full.stateName})` : ""}`);
19254
19412
  return true;
19255
19413
  }
19256
19414
  async function adoptAnimation(spec, key3) {
@@ -19292,6 +19450,13 @@ async function adoptCharacters(provider, specs, lock, lockPath, opts) {
19292
19450
  }
19293
19451
  }
19294
19452
  }
19453
+ const declaredCustom = animation.mode !== "template";
19454
+ const remoteCustom = match.type.startsWith("custom");
19455
+ if (animation.mode !== "skeleton-v3" && declaredCustom !== remoteCustom) {
19456
+ result.engineMismatches.push(
19457
+ `${key3}: declared mode "${animation.mode}", but the account's record reads "${match.type}", ` + (remoteCustom ? "a loop drawn from text, not a template" : "a template loop")
19458
+ );
19459
+ }
19295
19460
  const sources = match.frames.map((url, index) => ({ url, role: `frame-${String(index).padStart(2, "0")}` }));
19296
19461
  const outputs = await materialize(spec, sources);
19297
19462
  const durable = sources.filter((source) => shouldPersistSourceUrl(source.url));
@@ -19323,6 +19488,10 @@ async function adoptCharacters(provider, specs, lock, lockPath, opts) {
19323
19488
  animationGroupId: match.groupId,
19324
19489
  animationName: match.name,
19325
19490
  direction: animation.direction,
19491
+ // The engine, taken from the manifest: the provider does not report it.
19492
+ mode: animation.mode,
19493
+ modeFrom: "manifest",
19494
+ animationType: match.type,
19326
19495
  adopted: true
19327
19496
  }
19328
19497
  }
@@ -19334,10 +19503,10 @@ async function adoptCharacters(provider, specs, lock, lockPath, opts) {
19334
19503
  provider: provider.id
19335
19504
  });
19336
19505
  result.matched++;
19337
- log2(` adopted ${key3} \u2190 ${animation.direction} animation ${match.groupId ?? animationId ?? match.type} of ${parentId}`);
19506
+ log2(` ${opts.dryRun ? "would adopt" : "adopted"} ${key3} \u2190 ${animation.direction} animation ${match.groupId ?? animationId ?? match.type} of ${parentId}`);
19338
19507
  return true;
19339
19508
  }
19340
- await saveLock(lockPath, lock);
19509
+ if (!opts.dryRun) await saveLock(lockPath, lock);
19341
19510
  if (!opts.noCache) {
19342
19511
  pruneCache(cache, new Set(remote.map((character) => character.id)), "character:");
19343
19512
  await saveCache(cachePath, cache);
@@ -20571,52 +20740,63 @@ async function runAdopt(args) {
20571
20740
  const { loaded, specs, lock, accountProvider } = await openAccountProject(args);
20572
20741
  const providerFor = providerCache("online");
20573
20742
  const provider = providerFor(accountProvider);
20574
- log(`
20743
+ const dryRun = args.dryRun;
20744
+ const log2 = dryRun && args.json ? (msg = "") => console.error(msg) : log;
20745
+ const verb = dryRun ? "would adopt" : "adopted";
20746
+ log2(`
20575
20747
  Reconciling account objects against files already on disk\u2026`);
20576
- const res = await adopt(provider, specs.filter((spec) => spec.generator !== "character"), lock, args.lock, { onProgress: log });
20577
- log(`
20578
- scanned ${res.scanned} remote object(s), adopted ${res.matched}`);
20748
+ const res = await adopt(provider, specs.filter((spec) => spec.generator !== "character"), lock, args.lock, { onProgress: log2, dryRun });
20749
+ log2(`
20750
+ scanned ${res.scanned} remote object(s), ${verb} ${res.matched}`);
20751
+ let characters = null;
20579
20752
  if (specs.some((spec) => spec.character) && provider.listCharacters) {
20580
- log(`
20753
+ log2(`
20581
20754
  Reconciling account characters against the manifest's character assets\u2026`);
20582
- const characters = await adoptCharacters(provider, specs, lock, args.lock, {
20583
- onProgress: log,
20755
+ characters = await adoptCharacters(provider, specs, lock, args.lock, {
20756
+ onProgress: log2,
20757
+ dryRun,
20584
20758
  resolve: async () => (await resolveSpecs(loaded, { styles: args.styles, assets: args.assets })).filter((spec) => spec.provider === accountProvider)
20585
20759
  });
20586
- log(`
20587
- scanned ${characters.scanned} character(s), adopted ${characters.matched}`);
20588
- if (characters.written.length) log(` wrote ${characters.written.length} file(s) that were not on disk`);
20589
- for (const file of characters.differing) log(` differs from the account, left alone: ${file}`);
20760
+ log2(`
20761
+ scanned ${characters.scanned} character(s), ${verb} ${characters.matched}`);
20762
+ if (characters.written.length) log2(` ${dryRun ? "would write" : "wrote"} ${characters.written.length} file(s) that were not on disk`);
20763
+ if (dryRun) for (const file of characters.written) log2(` ${file}`);
20764
+ for (const file of characters.differing) log2(` differs from the account, left alone: ${file}`);
20765
+ if (characters.engineMismatches.length) {
20766
+ log2(`
20767
+ adopted loops whose record contradicts the declared mode (check animation.mode):`);
20768
+ for (const line of characters.engineMismatches) log2(` ${line}`);
20769
+ }
20590
20770
  if (characters.unmatched.length) {
20591
- log(`
20771
+ log2(`
20592
20772
  character assets not matched (${characters.unmatched.length}):`);
20593
- for (const line of characters.unmatched.slice(0, 15)) log(` ${line}`);
20773
+ for (const line of characters.unmatched.slice(0, 15)) log2(` ${line}`);
20594
20774
  }
20595
20775
  if (characters.remaining.length) {
20596
- log(`
20776
+ log2(`
20597
20777
  characters on the account no entry claims (${characters.remaining.length}):`);
20598
20778
  for (const c of characters.remaining.slice(0, 15)) {
20599
- log(` ${c.id} ${c.name}${c.stateName && c.stateName !== "Idle" ? ` / ${c.stateName}` : ""} ${c.directions}dir ${c.width}x${c.height} ${c.animationCount} animation(s)`);
20779
+ log2(` ${c.id} ${c.name}${c.stateName && c.stateName !== "Idle" ? ` / ${c.stateName}` : ""} ${c.directions}dir ${c.width}x${c.height} ${c.animationCount} animation(s)`);
20600
20780
  }
20601
- if (characters.remaining.length > 15) log(` \u2026 and ${characters.remaining.length - 15} more`);
20602
- log(` Declare one as a character asset with "remoteId" and run adopt again to bring it in.`);
20781
+ if (characters.remaining.length > 15) log2(` \u2026 and ${characters.remaining.length - 15} more`);
20782
+ log2(` Declare one as a character asset with "remoteId" and run adopt again to bring it in.`);
20603
20783
  }
20604
20784
  }
20605
20785
  if (res.ambiguous.length) {
20606
- log(`
20786
+ log2(`
20607
20787
  ambiguous (${res.ambiguous.length}):`);
20608
- for (const a of res.ambiguous.slice(0, 10)) log(` ${a}`);
20788
+ for (const a of res.ambiguous.slice(0, 10)) log2(` ${a}`);
20609
20789
  }
20610
20790
  if (res.unmatchedLocal.length) {
20611
- log(`
20791
+ log2(`
20612
20792
  local files with no matching remote object (${res.unmatchedLocal.length}):`);
20613
- for (const u of res.unmatchedLocal.slice(0, 15)) log(` ${u}`);
20793
+ for (const u of res.unmatchedLocal.slice(0, 15)) log2(` ${u}`);
20614
20794
  }
20615
20795
  if (res.unmatchedRemote.length) {
20616
- log(`
20796
+ log2(`
20617
20797
  remote objects not matched by THIS manifest (${res.unmatchedRemote.length}):`);
20618
- log(formatUnmatchedRemote(res.unmatchedRemote));
20619
- log(
20798
+ log2(formatUnmatchedRemote(res.unmatchedRemote));
20799
+ log2(
20620
20800
  `
20621
20801
  One account is shared across projects, so this list mixes discarded
20622
20802
  candidates with assets belonging to other manifests. Do not bulk-delete
@@ -20624,18 +20804,40 @@ async function runAdopt(args) {
20624
20804
  triage what is left over.`
20625
20805
  );
20626
20806
  }
20807
+ if (dryRun) {
20808
+ if (args.tag) log2(`
20809
+ --tag skipped: --dry-run pushes nothing upstream`);
20810
+ if (args.writePrompts) log2(` --write-prompts skipped: --dry-run leaves the manifest alone`);
20811
+ log2(`
20812
+ dry run: nothing written to disk, lockfile untouched (${args.lock})`);
20813
+ if (args.json) {
20814
+ console.log(JSON.stringify({
20815
+ dryRun: true,
20816
+ objects: { scanned: res.scanned, matched: res.matched, ambiguous: res.ambiguous, unmatchedLocal: res.unmatchedLocal, unmatchedRemote: res.unmatchedRemote.length },
20817
+ characters: characters && {
20818
+ scanned: characters.scanned,
20819
+ matched: characters.matched,
20820
+ wouldWrite: characters.written,
20821
+ differing: characters.differing,
20822
+ unmatched: characters.unmatched,
20823
+ remaining: characters.remaining.map((c) => c.id)
20824
+ }
20825
+ }, null, 2));
20826
+ }
20827
+ return;
20828
+ }
20627
20829
  if (args.tag) {
20628
- const n = await tagAdopted(provider, specs, lock, { onProgress: log });
20629
- log(`
20830
+ const n = await tagAdopted(provider, specs, lock, { onProgress: log2 });
20831
+ log2(`
20630
20832
  tagged ${n} object(s) upstream`);
20631
20833
  }
20632
20834
  if (args.writePrompts) {
20633
20835
  const { filled, stillEmpty } = await writePromptsBack(path30.resolve(args.manifest), lock, {
20634
- onProgress: log,
20836
+ onProgress: log2,
20635
20837
  provider: provider.id,
20636
20838
  assetIds: specs.map((spec) => spec.assetId)
20637
20839
  });
20638
- log(` recovered ${filled} prompt(s) into ${path30.relative(process.cwd(), args.manifest)}`);
20840
+ log2(` recovered ${filled} prompt(s) into ${path30.relative(process.cwd(), args.manifest)}`);
20639
20841
  const reloaded = await loadManifest(args.manifest);
20640
20842
  const rebased = (await resolveSpecs(reloaded, {
20641
20843
  styles: args.styles,
@@ -20649,14 +20851,14 @@ async function runAdopt(args) {
20649
20851
  n++;
20650
20852
  }
20651
20853
  await saveLock(args.lock, lock);
20652
- log(` re-baselined ${n} entr(ies) against the recovered prompts`);
20854
+ log2(` re-baselined ${n} entr(ies) against the recovered prompts`);
20653
20855
  if (stillEmpty.length) {
20654
- log(` ${stillEmpty.length} asset(s) still have no prompt (not matched upstream):`);
20655
- for (const id of stillEmpty.slice(0, 10)) log(` ${id}`);
20656
- if (stillEmpty.length > 10) log(` \u2026 and ${stillEmpty.length - 10} more`);
20856
+ log2(` ${stillEmpty.length} asset(s) still have no prompt (not matched upstream):`);
20857
+ for (const id of stillEmpty.slice(0, 10)) log2(` ${id}`);
20858
+ if (stillEmpty.length > 10) log2(` \u2026 and ${stillEmpty.length - 10} more`);
20657
20859
  }
20658
20860
  }
20659
- log(`
20861
+ log2(`
20660
20862
  lockfile written: ${args.lock}`);
20661
20863
  }
20662
20864
  async function runSalvage2(args) {
@@ -20801,6 +21003,7 @@ async function runSalvage2(args) {
20801
21003
  const adopted = await adoptCharacters(provider, await resolve(), lock, args.lock, { onProgress: log, resolve });
20802
21004
  log(` adopted ${adopted.matched} of ${assetIds.length} imported character asset(s)`);
20803
21005
  for (const line of adopted.unmatched) log(` not adopted: ${line}`);
21006
+ for (const line of adopted.engineMismatches) log(` check mode: ${line}`);
20804
21007
  };
20805
21008
  const runOne = async (styleId, list) => {
20806
21009
  const style = accountManifest.styles[styleId];
@@ -20979,7 +21182,8 @@ var NewAnimationSchema = z7.object({
20979
21182
  /** A PixelLab template id (`character` only; `objectPro` has no template concept). */
20980
21183
  template: z7.string().min(1).optional(),
20981
21184
  direction: CharacterDirectionSchema.optional(),
20982
- frames: z7.number().int().min(4).max(16).optional(),
21185
+ /** 4 to 16; a pixminimax loop takes a multiple of 4 up to 40. The manifest's own schema checks the rest. */
21186
+ frames: z7.number().int().min(4).max(40).optional(),
20983
21187
  fps: z7.number().int().min(1).max(60).optional(),
20984
21188
  /** One loop per named direction, plus free mirrors; expanded when the manifest loads. */
20985
21189
  directions: z7.array(CharacterDirectionSchema).min(1).optional(),
@@ -22301,7 +22505,7 @@ import { z as z10 } from "zod";
22301
22505
  // src/pipeline/model-edit.ts
22302
22506
  import { spawn as spawn2 } from "child_process";
22303
22507
  import { existsSync as existsSync26, readdirSync } from "fs";
22304
- import { mkdir as mkdir14, readdir, readFile as readFile22, rename as rename11, rm as rm9, writeFile as writeFile16 } from "fs/promises";
22508
+ import { mkdir as mkdir14, readdir as readdir2, readFile as readFile22, rename as rename11, rm as rm9, writeFile as writeFile16 } from "fs/promises";
22305
22509
  import path34 from "path";
22306
22510
  import { z as z9 } from "zod";
22307
22511
 
@@ -22691,7 +22895,7 @@ async function discoverModels(loaded, opts = {}) {
22691
22895
  if (depth > MAX_DEPTH || models.length >= MAX_MODELS) return;
22692
22896
  let entries;
22693
22897
  try {
22694
- entries = await readdir(dir, { withFileTypes: true });
22898
+ entries = await readdir2(dir, { withFileTypes: true });
22695
22899
  } catch {
22696
22900
  return;
22697
22901
  }
@@ -23079,7 +23283,7 @@ async function exportModelTexture(model, ref, opts) {
23079
23283
  // src/pipeline/model-normals.ts
23080
23284
  import { createHash as createHash4 } from "crypto";
23081
23285
  import { existsSync as existsSync27 } from "fs";
23082
- import { mkdir as mkdir15, readdir as readdir2, readFile as readFile23, writeFile as writeFile17 } from "fs/promises";
23286
+ import { mkdir as mkdir15, readdir as readdir3, readFile as readFile23, writeFile as writeFile17 } from "fs/promises";
23083
23287
  import path35 from "path";
23084
23288
  var MODEL_NORMAL_SOURCES = ["texture", "views", "sprites"];
23085
23289
  var TILE_MAX = 512;
@@ -23817,7 +24021,7 @@ function modelSpritesDir(modelFile) {
23817
24021
  }
23818
24022
  async function readSpriteFolder(dir) {
23819
24023
  const folder = existsSync27(path35.join(dir, "rotations")) ? path35.join(dir, "rotations") : dir;
23820
- const names = (await readdir2(folder)).filter((name) => name.toLowerCase().endsWith(".png") && VIEW_TURNS[name.slice(0, -4).toLowerCase()] !== void 0).sort();
24024
+ const names = (await readdir3(folder)).filter((name) => name.toLowerCase().endsWith(".png") && VIEW_TURNS[name.slice(0, -4).toLowerCase()] !== void 0).sort();
23821
24025
  return Promise.all(names.map(async (name) => ({ direction: name.slice(0, -4).toLowerCase(), png: await readFile23(path35.join(folder, name)), file: path35.join(folder, name) })));
23822
24026
  }
23823
24027
  function modelNormalDir(editFile) {
@@ -26810,7 +27014,7 @@ import { existsSync as existsSync37 } from "fs";
26810
27014
  import { readFile as readFile33 } from "fs/promises";
26811
27015
 
26812
27016
  // src/pipeline/init.ts
26813
- import { readdir as readdir3, readFile as readFile32, writeFile as writeFile23 } from "fs/promises";
27017
+ import { readdir as readdir4, readFile as readFile32, writeFile as writeFile23 } from "fs/promises";
26814
27018
  import { existsSync as existsSync36 } from "fs";
26815
27019
  import path44 from "path";
26816
27020
  function pngSize(buf) {
@@ -26825,7 +27029,7 @@ function slugify(value) {
26825
27029
  }
26826
27030
  async function walk(dir, exclude) {
26827
27031
  const out = [];
26828
- for (const entry of await readdir3(dir, { withFileTypes: true })) {
27032
+ for (const entry of await readdir4(dir, { withFileTypes: true })) {
26829
27033
  const full = path44.join(dir, entry.name);
26830
27034
  if (exclude.some((x) => full.includes(x))) continue;
26831
27035
  if (entry.isDirectory()) out.push(...await walk(full, exclude));
@@ -29399,7 +29603,7 @@ import { existsSync as existsSync41 } from "fs";
29399
29603
 
29400
29604
  // src/pipeline/cache-health.ts
29401
29605
  import { existsSync as existsSync40 } from "fs";
29402
- import { readFile as readFile36, readdir as readdir4, rm as rm14 } from "fs/promises";
29606
+ import { readFile as readFile36, readdir as readdir5, rm as rm14 } from "fs/promises";
29403
29607
  import path48 from "path";
29404
29608
  async function inspectCaches(lock, lockPath, options = {}) {
29405
29609
  if (options.prune && !existsSync40(lockPath)) {
@@ -29459,7 +29663,7 @@ async function inspectContentCache(contentDir, referenced) {
29459
29663
  return report;
29460
29664
  }
29461
29665
  const present = /* @__PURE__ */ new Set();
29462
- const entries = await readdir4(contentDir, { withFileTypes: true });
29666
+ const entries = await readdir5(contentDir, { withFileTypes: true });
29463
29667
  for (const entry of entries) {
29464
29668
  if (!entry.isFile()) {
29465
29669
  report.invalid.push({ name: entry.name, reason: "not a regular file" });
@@ -33860,7 +34064,7 @@ import path64 from "path";
33860
34064
 
33861
34065
  // src/pixellab-assets.ts
33862
34066
  import { existsSync as existsSync51 } from "fs";
33863
- import { mkdir as mkdir23, readdir as readdir5, readFile as readFile43, stat as stat6, writeFile as writeFile28 } from "fs/promises";
34067
+ import { mkdir as mkdir23, readdir as readdir6, readFile as readFile43, stat as stat6, writeFile as writeFile28 } from "fs/promises";
33864
34068
  import path63 from "path";
33865
34069
  var ASSET_KINDS = ["object", "character"];
33866
34070
  var EXPORT_FORMATS = ["zip", "spritesheet", "aseprite", "gif"];
@@ -34010,7 +34214,7 @@ async function importTilesetFile(client2, file, opts = {}) {
34010
34214
  async function pngFilesAt(from) {
34011
34215
  if (!existsSync51(from)) throw new Error(`${from} does not exist`);
34012
34216
  if (!(await stat6(from)).isDirectory()) return [from];
34013
- const names = (await readdir5(from)).filter((name) => /\.png$/i.test(name)).sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
34217
+ const names = (await readdir6(from)).filter((name) => /\.png$/i.test(name)).sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
34014
34218
  if (names.length === 0) throw new Error(`${from} holds no PNG files`);
34015
34219
  return names.map((name) => path63.join(from, name));
34016
34220
  }
@@ -35227,7 +35431,7 @@ import path70 from "path";
35227
35431
  // src/recipes.ts
35228
35432
  import path69 from "path";
35229
35433
  import { existsSync as existsSync55 } from "fs";
35230
- import { readdir as readdir6, readFile as readFile49 } from "fs/promises";
35434
+ import { readdir as readdir7, readFile as readFile49 } from "fs/promises";
35231
35435
  import { fileURLToPath as fileURLToPath2 } from "url";
35232
35436
  import { z as z18 } from "zod";
35233
35437
  var SHA256_RE2 = /^[0-9a-f]{64}$/;
@@ -35452,7 +35656,7 @@ async function readRecipeFile(recipePath, bundled) {
35452
35656
  async function walkRecipeFiles(root) {
35453
35657
  if (!existsSync55(root)) return [];
35454
35658
  const out = [];
35455
- for (const entry of await readdir6(root, { withFileTypes: true })) {
35659
+ for (const entry of await readdir7(root, { withFileTypes: true })) {
35456
35660
  const resolved = path69.join(root, entry.name);
35457
35661
  if (entry.isDirectory()) out.push(...await walkRecipeFiles(resolved));
35458
35662
  else if (entry.isFile() && entry.name === RECIPE_FILE) out.push(resolved);