pixelkiln 0.146.0 → 0.148.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
@@ -73,14 +73,13 @@ function proTierCost(width, height) {
73
73
  if (px <= 102400) return PRO_TIER_PRICES[1];
74
74
  return PRO_TIER_PRICES[2];
75
75
  }
76
+ var PIXMINIMAX_STEPS = [1, 1, 2, 2, 3, 3, 4, 5, 5, 6];
76
77
  function pixMiniMaxCost(width, height, frames, enhancePrompt = false) {
77
- const f = width * height * Math.max(1, frames) / 4096;
78
- let units;
79
- if (f <= 8) units = 1;
80
- else if (f <= 16) units = 1 + (f - 8) / 8;
81
- else if (f <= 40) units = 2 + (f - 16) / 6;
82
- else units = 6 + (f - 40) / 6;
83
- const base = Math.max(1, Math.ceil(units - 1e-9));
78
+ const side = Math.max(1, width, height);
79
+ const upscaled = side * (side <= 64 ? 4 : side <= 128 ? 2 : 1);
80
+ const reference = Math.max(1, frames) * upscaled * upscaled / 65536;
81
+ const step = Math.max(1, Math.ceil(reference / 4 - 1e-9));
82
+ const base = PIXMINIMAX_STEPS[Math.min(step, PIXMINIMAX_STEPS.length) - 1];
84
83
  return enhancePrompt ? base + 0.05 : base;
85
84
  }
86
85
  function tilesCost(tileSize, variations) {
@@ -175,7 +174,7 @@ var CharacterProportionsSchema = z.union([
175
174
  hipWidth: z.number().min(0.5).max(2).optional()
176
175
  }).strict()
177
176
  ]);
178
- var CharacterAnimationModeSchema = z.enum(["template", "skeleton-v3", "v3", "pro"]);
177
+ var CharacterAnimationModeSchema = z.enum(["template", "skeleton-v3", "v3", "pixminimax", "pro"]);
179
178
  var UiPieceSchema = z.discriminatedUnion("kind", [
180
179
  z.object({
181
180
  id: z.string().min(1),
@@ -499,12 +498,13 @@ var CharacterAnimationSchema = z.object({
499
498
  motionFrom: z.string().min(1).optional(),
500
499
  /**
501
500
  * Frames to generate without a template. A v3 loop takes an even 4 to 16;
502
- * a sentence loop (`mode: "skeleton-v3"` with no `template`) takes 3 to 15.
501
+ * a pixminimax loop a multiple of 4 from 4 to 40; a sentence loop
502
+ * (`mode: "skeleton-v3"` with no `template`) takes 3 to 15.
503
503
  */
504
- frames: z.number().int().min(3).max(16).optional(),
504
+ frames: z.number().int().min(3).max(40).optional(),
505
505
  /** Playback rate recorded with the frames; PixelLab does not store one. */
506
506
  fps: z.number().int().min(1).max(60).default(8),
507
- /** v3 only: keep the resting pose as frame 0, so `frames` generated frames land as `frames + 1` files. */
507
+ /** v3 and pixminimax: keep the resting pose as frame 0, so `frames` generated frames land as `frames + 1` files. */
508
508
  keepFirstFrame: z.boolean().default(true),
509
509
  /**
510
510
  * `character` loops: strip the ghost pixels an animation model leaves
@@ -518,28 +518,41 @@ var CharacterAnimationSchema = z.object({
518
518
  * `template` when a template is named, otherwise `v3`; `skeleton-v3`
519
519
  * poses a template with PixelLab's skeleton model instead, or, with no
520
520
  * template, animates the asset's prompt as a sentence written into one 3D
521
- * motion (a v3 base; 3-15 `frames`); `pro` for the sequential
522
- * high-quality engine.
521
+ * motion (a v3 base; 3-15 `frames`); `pixminimax` draws from the
522
+ * prompt on PixelLab's PixMiniMax engine (4 to 40 `frames`, a multiple
523
+ * of 4); `pro` for the sequential high-quality engine.
523
524
  */
524
525
  mode: CharacterAnimationModeSchema.optional(),
525
526
  /**
526
- * v3 only: a manifest-relative image of the pose to start from, instead
527
- * of the character's rotation for this direction. Up to 256px.
527
+ * v3 and pixminimax: a manifest-relative image of the pose to start from,
528
+ * instead of the character's rotation for this direction. Up to 256px.
528
529
  */
529
530
  startFrame: z.string().min(1).optional(),
530
531
  /**
531
- * v3 only: a pose to animate toward. The loop then interpolates from the
532
- * start frame (the rotation, or `startFrame`) to this image, which must
533
- * be the same size as the start frame.
532
+ * v3 and pixminimax: a pose to animate toward. The loop then interpolates
533
+ * from the start frame (the rotation, or `startFrame`) to this image,
534
+ * which must be the same size as the start frame. The same image as
535
+ * `startFrame` closes a loop.
534
536
  */
535
537
  endFrame: z.string().min(1).optional(),
536
- /** What is being animated, when the character's own description would mislead the model. */
538
+ /**
539
+ * What is being animated, when the character's own description would
540
+ * mislead the model. On a pixminimax loop it is PixelLab's
541
+ * `subject_description`, one noun phrase of up to 300 characters; left
542
+ * out, PixelLab reads it off the start frame.
543
+ */
537
544
  subject: z.string().min(1).optional(),
545
+ /**
546
+ * pixminimax only: the pose the start frame shows, up to 300 characters
547
+ * ("standing beside the pole, one hand on it"). Left out, PixelLab reads
548
+ * it off the image.
549
+ */
550
+ initialPose: z.string().min(1).max(300).optional(),
538
551
  /** Template mode only: style hints for this loop, over the character's own. */
539
552
  outline: z.string().min(1).optional(),
540
553
  shading: z.string().min(1).optional(),
541
554
  detail: z.string().min(1).optional(),
542
- /** v3 text loops only: let PixelLab expand the action into a fuller motion description first. */
555
+ /** v3 and pixminimax text loops only: let PixelLab expand the action into a fuller motion description first. */
543
556
  enhancePrompt: z.boolean().optional()
544
557
  }).strict().superRefine((animation, context) => {
545
558
  if (animation.directions !== void 0) {
@@ -550,22 +563,29 @@ var CharacterAnimationSchema = z.object({
550
563
  });
551
564
  }
552
565
  const sentence = animation.mode === "skeleton-v3" && !animation.template;
553
- if (animation.frames !== void 0 && !sentence && animation.mode !== "pro") {
566
+ const pixminimax = animation.mode === "pixminimax";
567
+ if (animation.frames !== void 0 && pixminimax) {
568
+ if (animation.frames % 4 !== 0 || animation.frames < 4) {
569
+ context.addIssue({ code: z.ZodIssueCode.custom, message: "a pixminimax loop takes a multiple of 4 frames, 4 to 40", path: ["frames"] });
570
+ }
571
+ } else if (animation.frames !== void 0 && !sentence && animation.mode !== "pro") {
554
572
  if (animation.frames % 2 !== 0) {
555
573
  context.addIssue({ code: z.ZodIssueCode.custom, message: "frames must be even", path: ["frames"] });
556
- } else if (animation.frames < 4) {
557
- context.addIssue({ code: z.ZodIssueCode.custom, message: "frames must be 4 to 16", path: ["frames"] });
574
+ } else if (animation.frames < 4 || animation.frames > 16) {
575
+ context.addIssue({ code: z.ZodIssueCode.custom, message: "frames must be 4 to 16 (a pixminimax loop takes up to 40)", path: ["frames"] });
558
576
  }
577
+ } else if (animation.frames !== void 0 && animation.mode === "pro" && animation.frames > 16) {
578
+ context.addIssue({ code: z.ZodIssueCode.custom, message: "frames must be 16 or fewer", path: ["frames"] });
559
579
  }
560
580
  if (animation.frames !== void 0 && sentence && animation.frames > 15) {
561
581
  context.addIssue({ code: z.ZodIssueCode.custom, message: "a skeleton-v3 loop from a sentence takes 3 to 15 frames", path: ["frames"] });
562
582
  }
563
583
  const mode2 = animation.mode ?? (animation.template ? "template" : "v3");
564
584
  for (const key3 of ["startFrame", "endFrame", "enhancePrompt"]) {
565
- if (animation[key3] !== void 0 && mode2 !== "v3") {
585
+ if (animation[key3] !== void 0 && mode2 !== "v3" && mode2 !== "pixminimax") {
566
586
  context.addIssue({
567
587
  code: z.ZodIssueCode.custom,
568
- 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"}`,
588
+ 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"}`,
569
589
  path: [key3]
570
590
  });
571
591
  }
@@ -575,6 +595,12 @@ var CharacterAnimationSchema = z.object({
575
595
  context.addIssue({ code: z.ZodIssueCode.custom, message: `${key3} overrides apply to template loops only`, path: [key3] });
576
596
  }
577
597
  }
598
+ if (animation.initialPose !== void 0 && mode2 !== "pixminimax") {
599
+ context.addIssue({ code: z.ZodIssueCode.custom, message: `initialPose is for pixminimax loops; PixelLab's ${mode2} engine takes no pose caption`, path: ["initialPose"] });
600
+ }
601
+ if (pixminimax && animation.subject !== void 0 && animation.subject.length > 300) {
602
+ context.addIssue({ code: z.ZodIssueCode.custom, message: "a pixminimax loop's subject is one noun phrase of up to 300 characters", path: ["subject"] });
603
+ }
578
604
  if (animation.template && animation.mode && animation.mode !== "template" && animation.mode !== "skeleton-v3") {
579
605
  context.addIssue({
580
606
  code: z.ZodIssueCode.custom,
@@ -3687,8 +3713,11 @@ var PixelLabClient = class {
3687
3713
  * One animation of one character. Template mode costs a generation per
3688
3714
  * direction and fixes the frame count; skeleton-v3 poses the same template
3689
3715
  * with the skeleton video model (2-4 generations per direction); v3 draws
3690
- * `frameCount` frames from the action text; pro is the sequential engine.
3691
- * One job per direction.
3716
+ * `frameCount` frames from the action text; pixminimax does the same on
3717
+ * PixelLab's PixMiniMax engine (a multiple of 4 frames up to 40, the same
3718
+ * start/end frames, `keep_first_frame` and `enhance_prompt`, plus its own
3719
+ * `subject_description` and `initial_pose` captions); pro is the
3720
+ * sequential engine. One job per direction.
3692
3721
  *
3693
3722
  * Every mode but skeleton-v3 goes to `/animate-character`, the path whose
3694
3723
  * shapes were measured live. skeleton-v3 is documented only on
@@ -3704,6 +3733,7 @@ var PixelLabClient = class {
3704
3733
  async animateCharacter(args) {
3705
3734
  const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
3706
3735
  const endpoint = args.mode === "skeleton-v3" ? "/characters/animations" : "/animate-character";
3736
+ const custom = args.mode === "v3" || args.mode === "pixminimax";
3707
3737
  const raw = await this.request(endpoint, {
3708
3738
  method: "POST",
3709
3739
  body: JSON.stringify({
@@ -3715,12 +3745,14 @@ var PixelLabClient = class {
3715
3745
  ...args.template ? { template_animation_id: args.template } : {},
3716
3746
  ...args.actionDescription ? { action_description: args.actionDescription } : {},
3717
3747
  ...args.description ? { description: args.description } : {},
3718
- // A template fixes its own frame count; v3 and a skeleton-v3 sentence take one.
3719
- ...(args.mode === "v3" || args.mode === "skeleton-v3" && !args.template) && args.frameCount ? { frame_count: args.frameCount } : {},
3720
- ...args.mode === "v3" && args.keepFirstFrame === false ? { keep_first_frame: false } : {},
3721
- ...args.mode === "v3" && args.startFrame ? { custom_start_frame: encode(args.startFrame) } : {},
3722
- ...args.mode === "v3" && args.endFrame ? { end_frame: encode(args.endFrame) } : {},
3723
- ...args.mode === "v3" && args.enhancePrompt ? { enhance_prompt: true } : {},
3748
+ // A template fixes its own frame count; v3, pixminimax and a skeleton-v3 sentence take one.
3749
+ ...(custom || args.mode === "skeleton-v3" && !args.template) && args.frameCount ? { frame_count: args.frameCount } : {},
3750
+ ...custom && args.keepFirstFrame === false ? { keep_first_frame: false } : {},
3751
+ ...custom && args.startFrame ? { custom_start_frame: encode(args.startFrame) } : {},
3752
+ ...custom && args.endFrame ? { end_frame: encode(args.endFrame) } : {},
3753
+ ...custom && args.enhancePrompt ? { enhance_prompt: true } : {},
3754
+ ...args.mode === "pixminimax" && args.subjectDescription ? { subject_description: args.subjectDescription } : {},
3755
+ ...args.mode === "pixminimax" && args.initialPose ? { initial_pose: args.initialPose } : {},
3724
3756
  ...args.mode === "template" && args.textGuidanceScale !== void 0 ? { text_guidance_scale: args.textGuidanceScale } : {},
3725
3757
  ...args.mode === "template" && args.outline ? { outline: args.outline } : {},
3726
3758
  ...args.mode === "template" && args.shading ? { shading: args.shading } : {},
@@ -8073,6 +8105,13 @@ function characterCost(spec) {
8073
8105
  if (animation.mode === "template") return 1;
8074
8106
  if (animation.mode === "skeleton-v3") return 4;
8075
8107
  if (animation.mode === "v3") return Math.max(1, Math.ceil(px * animation.frames / 65536));
8108
+ if (animation.mode === "pixminimax") {
8109
+ const start = animation.startFrame;
8110
+ return Math.max(
8111
+ pixMiniMaxCost(spec.width, spec.height, animation.frames, animation.enhancePrompt),
8112
+ start ? pixMiniMaxCost(start.width, start.height, animation.frames, animation.enhancePrompt) : 0
8113
+ );
8114
+ }
8076
8115
  return proCharacterTierCost(spec.width, spec.height);
8077
8116
  }
8078
8117
  if (character.kind === "state" || character.kind === "portrait") return proCharacterTierCost(spec.width, spec.height);
@@ -8814,7 +8853,7 @@ var PixelLabProvider = class _PixelLabProvider {
8814
8853
  const { startFrame, endFrame } = character.animation;
8815
8854
  for (const [name, image] of [["start frame", startFrame], ["end frame", endFrame]]) {
8816
8855
  if (image && (image.width > 256 || image.height > 256)) {
8817
- throw new Error(`${label}: ${name} is ${image.width}x${image.height}; PixelLab v3 takes up to 256px`);
8856
+ throw new Error(`${label}: ${name} is ${image.width}x${image.height}; PixelLab ${character.animation.mode} takes up to 256px`);
8818
8857
  }
8819
8858
  }
8820
8859
  if (endFrame) {
@@ -8929,6 +8968,9 @@ var PixelLabProvider = class _PixelLabProvider {
8929
8968
  `${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")' : "")
8930
8969
  );
8931
8970
  }
8971
+ if (character.animation.mode === "pixminimax" && (character.animation.frames % 4 !== 0 || character.animation.frames < 4 || character.animation.frames > 40)) {
8972
+ 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`);
8973
+ }
8932
8974
  if (sentence && (character.animation.frames < 3 || character.animation.frames > 15)) {
8933
8975
  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`);
8934
8976
  }
@@ -9240,7 +9282,9 @@ var PixelLabProvider = class _PixelLabProvider {
9240
9282
  isometric: character.isometric,
9241
9283
  startFrame: animation.startFrame ? readPose(spec, "start frame", animation.startFrame) : void 0,
9242
9284
  endFrame: animation.endFrame ? readPose(spec, "end frame", animation.endFrame) : void 0,
9243
- description: animation.subject,
9285
+ // PixMiniMax captions its start frame with its own two fields; the
9286
+ // other engines take `subject` as the general `description`.
9287
+ ...animation.mode === "pixminimax" ? { subjectDescription: animation.subject, initialPose: animation.initialPose } : { description: animation.subject },
9244
9288
  outline: animation.outline,
9245
9289
  shading: animation.shading,
9246
9290
  detail: animation.detail,
@@ -15219,6 +15263,8 @@ async function resolveCharacterShape(asset, style, kind, files) {
15219
15263
  ...asset.animation.startFrame ? { startFrame: await pose(asset.animation.startFrame, "Animation start frame") } : {},
15220
15264
  ...asset.animation.endFrame ? { endFrame: await pose(asset.animation.endFrame, "Animation end frame") } : {},
15221
15265
  ...asset.animation.subject ? { subject: asset.animation.subject } : {},
15266
+ // Set only on a pixminimax loop (the schema refuses it elsewhere), so no other spec's hash moves.
15267
+ ...asset.animation.initialPose ? { initialPose: asset.animation.initialPose } : {},
15222
15268
  ...asset.animation.outline ? { outline: asset.animation.outline } : {},
15223
15269
  ...asset.animation.shading ? { shading: asset.animation.shading } : {},
15224
15270
  ...asset.animation.detail ? { detail: asset.animation.detail } : {},
@@ -15257,6 +15303,7 @@ async function resolveObjectProShape(assetId, asset, style, kind, files) {
15257
15303
  for (const [field, value] of Object.entries({
15258
15304
  template: asset.animation.template,
15259
15305
  subject: asset.animation.subject,
15306
+ initialPose: asset.animation.initialPose,
15260
15307
  outline: asset.animation.outline,
15261
15308
  shading: asset.animation.shading,
15262
15309
  detail: asset.animation.detail
@@ -15270,7 +15317,7 @@ async function resolveObjectProShape(assetId, asset, style, kind, files) {
15270
15317
  if (asset.animation.clean !== void 0) {
15271
15318
  throw new Error(`assets.${assetId}: animation.clean applies to character loops; objectPro loops are not cleaned`);
15272
15319
  }
15273
- if (asset.animation.mode === "template" || asset.animation.mode === "skeleton-v3") {
15320
+ if (asset.animation.mode === "template" || asset.animation.mode === "skeleton-v3" || asset.animation.mode === "pixminimax") {
15274
15321
  throw new Error(`assets.${assetId}: objectPro animations have no "${asset.animation.mode}" mode; use "v3" or "pro"`);
15275
15322
  }
15276
15323
  const pose = async (rel, what) => {
@@ -22763,12 +22810,12 @@ async function adopt(provider, specs, lock, lockPath, opts = {}) {
22763
22810
  provider: provider.id
22764
22811
  });
22765
22812
  matched++;
22766
- log(` adopted ${key3} \u2190 ${obj.id}`);
22813
+ log(` ${opts.dryRun ? "would adopt" : "adopted"} ${key3} \u2190 ${obj.id}`);
22767
22814
  }
22768
22815
  }
22769
22816
  }
22770
22817
  await Promise.all(Array.from({ length: Math.min(concurrency, remote.length || 1) }, worker));
22771
- await saveLock(lockPath, lock);
22818
+ if (!opts.dryRun) await saveLock(lockPath, lock);
22772
22819
  if (!opts.noCache) {
22773
22820
  pruneCache(cache, new Set(remote.map((o) => o.id)));
22774
22821
  await saveCache(cachePath, cache);
@@ -22803,10 +22850,11 @@ async function tagAdopted(provider, specs, lock, opts = {}) {
22803
22850
 
22804
22851
  // src/pipeline/import.ts
22805
22852
  import { existsSync as existsSync32 } from "fs";
22806
- import { readFile as readFile22 } from "fs/promises";
22853
+ import { readdir as readdir4, readFile as readFile22 } from "fs/promises";
22807
22854
  import path37 from "path";
22808
- function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Date()) {
22855
+ function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Date(), frames) {
22809
22856
  const png = decodePng(bytes);
22857
+ for (const frame of frames ?? []) decodePng(frame.bytes);
22810
22858
  const at2 = now.toISOString();
22811
22859
  const origin = {
22812
22860
  ...opts.tool ? { tool: opts.tool } : {},
@@ -22831,7 +22879,14 @@ function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Da
22831
22879
  error: null,
22832
22880
  sourceUrl: null,
22833
22881
  sourceUrls: [],
22834
- outputs: [{ path: portableOutputPath(spec.outFile, spec.root), sha256: sha256(bytes) }],
22882
+ // A frame set is recorded the way fetch records one: an output per frame,
22883
+ // in order, each with its `frame-NN` role, so `plan` resolves the same paths.
22884
+ outputs: frames?.length ? frames.map((frame) => ({
22885
+ path: portableOutputPath(frame.file, spec.root),
22886
+ sha256: sha256(frame.bytes),
22887
+ role: frame.role,
22888
+ mediaType: MediaType.PNG
22889
+ })) : [{ path: portableOutputPath(spec.outFile, spec.root), sha256: sha256(bytes) }],
22835
22890
  submittedAt: null,
22836
22891
  downloadedAt: at2,
22837
22892
  cost: opts.cost ?? 0,
@@ -22846,6 +22901,32 @@ function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Da
22846
22901
  }
22847
22902
  };
22848
22903
  }
22904
+ var frameRole2 = (index) => `frame-${String(index).padStart(2, "0")}`;
22905
+ async function findFrames(spec) {
22906
+ const at2 = (index) => memberPath(spec.outFile, frameRole2(index), 0, 2, MediaType.PNG);
22907
+ const base = path37.basename(at2(0)).replace(/00\.png$/, "");
22908
+ let names = [];
22909
+ try {
22910
+ names = await readdir4(path37.dirname(spec.outFile));
22911
+ } catch {
22912
+ names = [];
22913
+ }
22914
+ const found = /* @__PURE__ */ new Set();
22915
+ for (const name of names) {
22916
+ if (!name.startsWith(base)) continue;
22917
+ const match = /^(\d+)\.png$/i.exec(name.slice(base.length));
22918
+ if (match) found.add(Number(match[1]));
22919
+ }
22920
+ const expected = spec.revision?.frames;
22921
+ const expectsFrames = expected !== void 0 || spec.generator === "frames";
22922
+ if (!found.size && !expectsFrames) return null;
22923
+ const highest = found.size ? Math.max(...found) : -1;
22924
+ const upTo = Math.max(highest + 1, expected ?? 0, expectsFrames ? 1 : 0);
22925
+ const missing = [];
22926
+ for (let index = 0; index < upTo; index++) if (!found.has(index)) missing.push(at2(index));
22927
+ if (missing.length) return { missing };
22928
+ return { files: Array.from({ length: upTo }, (_, index) => ({ role: frameRole2(index), file: at2(index) })) };
22929
+ }
22849
22930
  function unimportable(spec) {
22850
22931
  if (spec.character) return "a character is several files; import it with account adopt";
22851
22932
  if (spec.vfx) return "an effect is rendered from its recipe, not imported";
@@ -22878,9 +22959,18 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
22878
22959
  skipped.push({ key: key3, reason });
22879
22960
  continue;
22880
22961
  }
22962
+ let frameFiles;
22881
22963
  if (!existsSync32(spec.outFile)) {
22882
- skipped.push({ key: key3, reason: `no file at ${spec.outFile}` });
22883
- continue;
22964
+ const frames2 = await findFrames(spec);
22965
+ if (!frames2) {
22966
+ skipped.push({ key: key3, reason: `no file at ${spec.outFile}` });
22967
+ continue;
22968
+ }
22969
+ if ("missing" in frames2) {
22970
+ skipped.push({ key: key3, reason: `frame set is missing ${frames2.missing.map((file) => path37.basename(file)).join(", ")} (in ${path37.dirname(spec.outFile)})` });
22971
+ continue;
22972
+ }
22973
+ frameFiles = frames2.files;
22884
22974
  }
22885
22975
  if (lock.entries[key3] && !opts.force) {
22886
22976
  skipped.push({ key: key3, reason: "already in the lockfile (use --force to replace it)" });
@@ -22888,9 +22978,11 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
22888
22978
  }
22889
22979
  let patch;
22890
22980
  let bytes;
22981
+ let frames;
22891
22982
  try {
22892
- bytes = await readFile22(spec.outFile);
22893
- patch = buildImportedEntry(spec, bytes, { ...opts, rawSha256 }, /* @__PURE__ */ new Date());
22983
+ frames = frameFiles ? await Promise.all(frameFiles.map(async (frame) => ({ ...frame, bytes: await readFile22(frame.file) }))) : void 0;
22984
+ bytes = frames ? frames[0].bytes : await readFile22(spec.outFile);
22985
+ patch = buildImportedEntry(spec, bytes, { ...opts, rawSha256 }, /* @__PURE__ */ new Date(), frames);
22894
22986
  } catch (error) {
22895
22987
  skipped.push({ key: key3, reason: `invalid PNG: ${error instanceof Error ? error.message : String(error)}` });
22896
22988
  continue;
@@ -22900,9 +22992,10 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
22900
22992
  continue;
22901
22993
  }
22902
22994
  const existing = lock.entries[key3];
22903
- const history = existing?.outputs[0]?.sha256 === sha256(bytes) ? existing.history : historyAfterReplacing(existing, opts.historyLimit ?? DEFAULT_HISTORY_LIMIT, patch.downloadedAt ?? (/* @__PURE__ */ new Date()).toISOString());
22995
+ const sameBytes = existing !== void 0 && existing.outputs.length === patch.outputs.length && existing.outputs.every((output, index) => output.sha256 === patch.outputs[index].sha256);
22996
+ const history = sameBytes ? existing.history : historyAfterReplacing(existing, opts.historyLimit ?? DEFAULT_HISTORY_LIMIT, patch.downloadedAt ?? (/* @__PURE__ */ new Date()).toISOString());
22904
22997
  if (cacheDir) {
22905
- await cacheMedia(cacheDir, bytes, MediaType.PNG);
22998
+ for (const member of frames ?? [{ bytes }]) await cacheMedia(cacheDir, member.bytes, MediaType.PNG);
22906
22999
  if (rawBytes) await cacheMedia(cacheDir, rawBytes, MediaType.PNG);
22907
23000
  }
22908
23001
  imported.push({ key: key3, entry: upsert(lock, key3, {
@@ -22954,7 +23047,7 @@ import { existsSync as existsSync34 } from "fs";
22954
23047
  import { readFile as readFile25 } from "fs/promises";
22955
23048
 
22956
23049
  // src/pipeline/init.ts
22957
- import { readdir as readdir4, readFile as readFile23, writeFile as writeFile16 } from "fs/promises";
23050
+ import { readdir as readdir5, readFile as readFile23, writeFile as writeFile16 } from "fs/promises";
22958
23051
  import { existsSync as existsSync33 } from "fs";
22959
23052
  import path38 from "path";
22960
23053
  function pngSize(buf) {
@@ -22969,7 +23062,7 @@ function slugify(value) {
22969
23062
  }
22970
23063
  async function walk(dir, exclude) {
22971
23064
  const out = [];
22972
- for (const entry of await readdir4(dir, { withFileTypes: true })) {
23065
+ for (const entry of await readdir5(dir, { withFileTypes: true })) {
22973
23066
  const full = path38.join(dir, entry.name);
22974
23067
  if (exclude.some((x) => full.includes(x))) continue;
22975
23068
  if (entry.isDirectory()) out.push(...await walk(full, exclude));
@@ -24455,12 +24548,12 @@ async function runPicker(provider, lock, lockPath, opts = {}) {
24455
24548
  });
24456
24549
  if (!session) return { selected: 0, skipped: 0 };
24457
24550
  let autoSelected = 0;
24458
- if (opts.autoAcceptSingle) {
24459
- const singles = session.groups.filter((g) => g.mode === "frame-set" || g.frameUrls.length === 1);
24551
+ if (opts.acceptFirst || opts.autoAcceptSingle) {
24552
+ const singles = opts.acceptFirst ? session.groups : session.groups.filter((g) => g.mode === "frame-set" || g.frameUrls.length === 1);
24460
24553
  if (singles.length) {
24461
24554
  const res = await session.apply({ selections: singles.map((g) => ({ key: g.key, index: 0 })) }, lockPath);
24462
24555
  autoSelected = res.selected;
24463
- log(` --yes: accepted ${res.selected} single-candidate asset(s)`);
24556
+ log(opts.acceptFirst ? ` --accept-first: accepted the first candidate of ${res.selected} asset(s)` : ` --yes: accepted ${res.selected} single-candidate asset(s)`);
24464
24557
  const rest = session.groups.filter((g) => !singles.includes(g)).map((g) => g.key);
24465
24558
  session = rest.length ? await prepareReview(provider, lock, { onProgress: log, keys: rest, specs: opts.specs, lockPath }) : null;
24466
24559
  if (!session) return { selected: autoSelected, skipped: 0 };
@@ -24868,7 +24961,8 @@ var NewAnimationSchema = z9.object({
24868
24961
  /** A PixelLab template id (`character` only; `objectPro` has no template concept). */
24869
24962
  template: z9.string().min(1).optional(),
24870
24963
  direction: CharacterDirectionSchema.optional(),
24871
- frames: z9.number().int().min(4).max(16).optional(),
24964
+ /** 4 to 16; a pixminimax loop takes a multiple of 4 up to 40. The manifest's own schema checks the rest. */
24965
+ frames: z9.number().int().min(4).max(40).optional(),
24872
24966
  fps: z9.number().int().min(1).max(60).optional(),
24873
24967
  /** One loop per named direction, plus free mirrors; expanded when the manifest loads. */
24874
24968
  directions: z9.array(CharacterDirectionSchema).min(1).optional(),
@@ -25576,7 +25670,7 @@ function openInEditor(file, editor = process.env.PIXELKILN_EDITOR) {
25576
25670
  // src/pipeline/model-edit.ts
25577
25671
  import { spawn as spawn2 } from "child_process";
25578
25672
  import { existsSync as existsSync36, readdirSync as readdirSync2 } from "fs";
25579
- import { mkdir as mkdir16, readdir as readdir5, readFile as readFile28, rename as rename11, rm as rm10, writeFile as writeFile19 } from "fs/promises";
25673
+ import { mkdir as mkdir16, readdir as readdir6, readFile as readFile28, rename as rename11, rm as rm10, writeFile as writeFile19 } from "fs/promises";
25580
25674
  import path41 from "path";
25581
25675
  import { z as z11 } from "zod";
25582
25676
 
@@ -25966,7 +26060,7 @@ async function discoverModels(loaded, opts = {}) {
25966
26060
  if (depth > MAX_DEPTH || models.length >= MAX_MODELS) return;
25967
26061
  let entries;
25968
26062
  try {
25969
- entries = await readdir5(dir, { withFileTypes: true });
26063
+ entries = await readdir6(dir, { withFileTypes: true });
25970
26064
  } catch {
25971
26065
  return;
25972
26066
  }
@@ -26264,7 +26358,7 @@ function openInBlender(model, opts = {}) {
26264
26358
  // src/pipeline/model-normals.ts
26265
26359
  import { createHash as createHash7 } from "crypto";
26266
26360
  import { existsSync as existsSync37 } from "fs";
26267
- import { mkdir as mkdir17, readdir as readdir6, readFile as readFile29, writeFile as writeFile20 } from "fs/promises";
26361
+ import { mkdir as mkdir17, readdir as readdir7, readFile as readFile29, writeFile as writeFile20 } from "fs/promises";
26268
26362
  import path42 from "path";
26269
26363
  var MODEL_NORMAL_SOURCES = ["texture", "views", "sprites"];
26270
26364
  var TILE_MAX = 512;
@@ -26995,7 +27089,7 @@ function modelSpritesDir(modelFile) {
26995
27089
  }
26996
27090
  async function readSpriteFolder(dir) {
26997
27091
  const folder = existsSync37(path42.join(dir, "rotations")) ? path42.join(dir, "rotations") : dir;
26998
- const names = (await readdir6(folder)).filter((name) => name.toLowerCase().endsWith(".png") && VIEW_TURNS[name.slice(0, -4).toLowerCase()] !== void 0).sort();
27092
+ const names = (await readdir7(folder)).filter((name) => name.toLowerCase().endsWith(".png") && VIEW_TURNS[name.slice(0, -4).toLowerCase()] !== void 0).sort();
26999
27093
  return Promise.all(names.map(async (name) => ({ direction: name.slice(0, -4).toLowerCase(), png: await readFile29(path42.join(folder, name)), file: path42.join(folder, name) })));
27000
27094
  }
27001
27095
  function modelNormalDir(editFile) {