@ikijs/mcp 0.17.2 → 0.19.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.
@@ -13,6 +13,8 @@ import {
13
13
  createLayerSetMeasurer,
14
14
  generateIkiFromLayerSet,
15
15
  parseLayerRoles,
16
+ partIdsOfRole,
17
+ LayerGeometryError,
16
18
  TurnTargetError
17
19
  } from "@ikijs/editor";
18
20
 
@@ -26,10 +28,10 @@ import path from "path";
26
28
  var MAX_LAYERS = 64;
27
29
  var MAX_LAYER_DIM = 4096;
28
30
  var MAX_CANVAS_DIM = 4096;
29
- var MAX_ATLAS_AREA = 4096 * 4096;
31
+ var MAX_ATLAS_SIDE = 4096;
30
32
  var MAX_INPUT_PIXELS = 4096 * 4096;
31
- var MAX_TOTAL_PIXELS = 64 * 1024 * 1024;
32
- var MAX_OUTPUT_BYTES = 5 * 1024 * 1024;
33
+ var MAX_TOTAL_PIXELS = 128 * 1024 * 1024;
34
+ var MAX_OUTPUT_BYTES = 12 * 1024 * 1024;
33
35
  var AutoRigInputError = class extends Error {
34
36
  constructor(message) {
35
37
  super(message);
@@ -330,6 +332,18 @@ var STANDARD_PARAMETER_INFO = [
330
332
  id: StandardParameter.AngleZ,
331
333
  description: "Head tilt / roll degrees; positive tilts the top of the head toward the viewer's right (clockwise), as in Live2D."
332
334
  },
335
+ {
336
+ id: StandardParameter.BodyAngleX,
337
+ description: "Body turn, degrees (-10 .. 10); positive turns the body toward the viewer's right, as AngleX does the head."
338
+ },
339
+ {
340
+ id: StandardParameter.BodyAngleY,
341
+ description: "Body lean, degrees (-10 .. 10); positive moves the upper body up, negative bows."
342
+ },
343
+ {
344
+ id: StandardParameter.BodyAngleZ,
345
+ description: "Body tilt, degrees (-10 .. 10); positive tilts the top toward the viewer's right (clockwise), as AngleZ does the head."
346
+ },
333
347
  {
334
348
  id: StandardParameter.Breath,
335
349
  description: "Idle breath (0 .. 1), cycled by the host."
@@ -361,6 +375,22 @@ var STANDARD_PARAMETER_INFO = [
361
375
  {
362
376
  id: StandardParameter.HairSwayZ,
363
377
  description: "Hair-sway driver behind a head tilt. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
378
+ },
379
+ {
380
+ id: StandardParameter.ArmLeft,
381
+ description: "Left shoulder, degrees; positive raises the arm outward (mirrored on the right)."
382
+ },
383
+ {
384
+ id: StandardParameter.ArmRight,
385
+ description: "Right shoulder, degrees; positive raises the arm outward (mirrored on the left)."
386
+ },
387
+ {
388
+ id: StandardParameter.ElbowLeft,
389
+ description: "Left elbow, degrees; positive bends the forearm the way positive ArmLeft raises the arm."
390
+ },
391
+ {
392
+ id: StandardParameter.ElbowRight,
393
+ description: "Right elbow, degrees; positive bends the forearm the way positive ArmRight raises the arm."
364
394
  }
365
395
  ];
366
396
  function listStandardParameters() {
@@ -380,9 +410,13 @@ async function renderAtlasPage(crops, quantizeColors) {
380
410
  const layout = packAtlas(
381
411
  crops.map((c) => ({ id: c.id, width: c.width, height: c.height }))
382
412
  );
383
- if (layout.pageWidth * layout.pageHeight > MAX_ATLAS_AREA) {
413
+ const over = layout.pageWidth > MAX_ATLAS_SIDE ? { side: "width", crop: "widest" } : layout.pageHeight > MAX_ATLAS_SIDE ? { side: "height", crop: "tallest" } : void 0;
414
+ if (over !== void 0) {
415
+ const crop = layout.placements.reduce(
416
+ (a, b) => b[over.side] > a[over.side] ? b : a
417
+ );
384
418
  throw new AutoRigInputError(
385
- `atlas page ${layout.pageWidth}x${layout.pageHeight} exceeds max area ${MAX_ATLAS_AREA}`
419
+ `atlas page ${layout.pageWidth}x${layout.pageHeight} exceeds max side ${MAX_ATLAS_SIDE} (its ${over.crop} crop: "${crop.id}" ${crop.width}x${crop.height})`
386
420
  );
387
421
  }
388
422
  const dataUri = await renderAtlasToDataUri(crops, layout, quantizeColors);
@@ -501,7 +535,9 @@ async function autoRigFromLayers(input) {
501
535
  }
502
536
  );
503
537
  } catch (e) {
504
- if (!(e instanceof TurnTargetError)) throw e;
538
+ if (!(e instanceof TurnTargetError || e instanceof LayerGeometryError)) {
539
+ throw e;
540
+ }
505
541
  throw new AutoRigInputError(e.message);
506
542
  }
507
543
  const doc = new EditorDocument(model);
@@ -520,18 +556,16 @@ async function autoRigFromLayers(input) {
520
556
  );
521
557
  }
522
558
  const partTextureAssignments = pages.flatMap(
523
- ({ crops: pageCrops, layout }) => pageCrops.map((crop) => {
559
+ ({ crops: pageCrops, layout }) => pageCrops.flatMap((crop) => {
524
560
  const placement2 = layout.placements.find((p) => p.id === crop.id);
525
561
  if (placement2 === void 0) {
526
562
  throw new Error(`auto-rig: no atlas placement for "${crop.id}"`);
527
563
  }
528
- return {
529
- partId: crop.id,
530
- uv: uvRectFor(placement2, {
531
- width: layout.pageWidth,
532
- height: layout.pageHeight
533
- })
534
- };
564
+ const uv = uvRectFor(placement2, {
565
+ width: layout.pageWidth,
566
+ height: layout.pageHeight
567
+ });
568
+ return partIdsOfRole(crop.id).map((partId) => ({ partId, uv }));
535
569
  })
536
570
  );
537
571
  doc.applyAtlas({
@@ -542,7 +576,9 @@ async function autoRigFromLayers(input) {
542
576
  if (losslessCrop !== void 0) {
543
577
  patched = structuredClone(patched);
544
578
  patched.textures = pages.map((p) => ({ source: p.dataUri }));
545
- patched.parts.find((p) => p.id === losslessCrop.id).texture.index = 1;
579
+ for (const partId of partIdsOfRole(losslessCrop.id)) {
580
+ patched.parts.find((p) => p.id === partId).texture.index = 1;
581
+ }
546
582
  }
547
583
  const finalModel = parseIkiModel(patched);
548
584
  writeFileAtomic(outPath, JSON.stringify(finalModel));
@@ -930,7 +966,84 @@ function formatTurnReport(result) {
930
966
 
931
967
  // src/measure.ts
932
968
  import fs2 from "fs";
969
+ import path5 from "path";
970
+
971
+ // src/measure-arms.ts
933
972
  import path4 from "path";
973
+ import {
974
+ LayerGeometryError as LayerGeometryError2,
975
+ armGeometry,
976
+ createLayerSetMeasurer as createLayerSetMeasurer2
977
+ } from "@ikijs/editor";
978
+ var ARM_ROLES = ["arm_L", "arm_R"];
979
+ var CAP_OVERLAP = 0.5;
980
+ var px = (v) => `${Number(v.toFixed(1))}`;
981
+ async function measured(measurer, absDir, role) {
982
+ const fileName = `${role}.png`;
983
+ const { rgba } = await decodePng(path4.join(absDir, fileName));
984
+ return measurer.add({ role, fileName, rgba });
985
+ }
986
+ async function armWarnings(absDir, layers) {
987
+ const warnings = [];
988
+ const body = layers.body;
989
+ let set;
990
+ for (const arm of ARM_ROLES) {
991
+ const stats = layers[arm];
992
+ if (stats === void 0) continue;
993
+ if (body === void 0) {
994
+ warnings.push(
995
+ `${arm}: no body layer \u2014 an arm hangs from the body's shoulder, and auto_rig_from_layers refuses it.`
996
+ );
997
+ continue;
998
+ }
999
+ if (stats.canvasW !== body.canvasW || stats.canvasH !== body.canvasH) {
1000
+ warnings.push(
1001
+ `${arm}: its canvas ${stats.canvasW}x${stats.canvasH} differs from body's ${body.canvasW}x${body.canvasH} \u2014 auto_rig_from_layers refuses layers of different sizes; recompose them together.`
1002
+ );
1003
+ continue;
1004
+ }
1005
+ if (set === void 0) {
1006
+ const measurer = createLayerSetMeasurer2({
1007
+ width: body.canvasW,
1008
+ height: body.canvasH
1009
+ });
1010
+ set = { measurer, body: await measured(measurer, absDir, "body") };
1011
+ }
1012
+ let g;
1013
+ try {
1014
+ g = armGeometry(
1015
+ await measured(set.measurer, absDir, arm),
1016
+ set.body.bbox.x + set.body.bbox.w / 2 - body.canvasW / 2
1017
+ );
1018
+ } catch (err) {
1019
+ if (err instanceof LayerGeometryError2) {
1020
+ warnings.push(
1021
+ `${arm}: ${err.message} \u2014 auto_rig_from_layers refuses it. Regenerate arm.png drawn hanging, shoulder at the top. Billed.`
1022
+ );
1023
+ continue;
1024
+ }
1025
+ throw err;
1026
+ }
1027
+ const cap = capWarning(arm, g, set.body);
1028
+ if (cap !== void 0) warnings.push(cap);
1029
+ }
1030
+ return warnings;
1031
+ }
1032
+ function capWarning(arm, g, body) {
1033
+ const pivotX = g.shoulder.x + body.canvasW / 2;
1034
+ const row = Math.floor(body.canvasH / 2 - g.shoulder.y);
1035
+ const runs = body.rowRuns?.[row - body.bbox.y] ?? [];
1036
+ if (runs.length === 0) {
1037
+ return `${arm}: the body has no paint on its shoulder pivot's row (y=${row}) \u2014 the torso shows a gap beside the shoulder once the arm raises. Retune layout.${arm}.cy onto the shoulder (free).`;
1038
+ }
1039
+ const edge = g.side === 1 ? runs[runs.length - 1] : runs[0];
1040
+ const overlap = g.shoulderRadius - g.side * (pivotX - edge);
1041
+ const need = CAP_OVERLAP * g.shoulderRadius;
1042
+ if (overlap >= need) return void 0;
1043
+ return `${arm}: its shoulder cap reaches ${px(overlap)} px under the torso's edge on its pivot row (y=${row}), under half its radius (${px(need)} px) \u2014 a gap opens beside the shoulder once the arm raises. Move layout.${arm}.cx ${Math.ceil(need - overlap)} px toward the body (free).`;
1044
+ }
1045
+
1046
+ // src/measure.ts
934
1047
  var IRIS_RATIO_MIN = 0.45;
935
1048
  var IRIS_RATIO_MAX = 0.72;
936
1049
  var EYE_ASPECT_MIN = 0.5;
@@ -1019,6 +1132,7 @@ async function layerStats(filePath) {
1019
1132
  };
1020
1133
  }
1021
1134
  var pct = (v) => `${(v * 100).toFixed(0)}%`;
1135
+ var isArm = (role) => ARM_ROLES.includes(role);
1022
1136
  function noseSpeckWarning({ core, part }, source) {
1023
1137
  const [found, consequence] = source === "compose" ? [
1024
1138
  `the source part's dense core is ${core.w}x${core.h} in its ${part.w}x${part.h} trimmed part`,
@@ -1045,7 +1159,7 @@ async function lashOffSclera(eyePath, lashPath) {
1045
1159
  return { opaque, off };
1046
1160
  }
1047
1161
  async function measureDir(absDir, noseSpeck) {
1048
- const files = fs2.readdirSync(absDir).filter((f) => f.endsWith(".png") && f !== "preview.png").sort();
1162
+ const files = fs2.readdirSync(absDir).filter((f) => f.endsWith(".png") && !f.startsWith("preview")).sort();
1049
1163
  if (files.length === 0) {
1050
1164
  throw new AutoRigInputError(`no role layers in ${absDir}`);
1051
1165
  }
@@ -1057,8 +1171,8 @@ async function measureDir(absDir, noseSpeck) {
1057
1171
  const layers = {};
1058
1172
  const empty = [];
1059
1173
  for (const f of files) {
1060
- const role = path4.basename(f, ".png");
1061
- const m = await layerStats(path4.join(absDir, f));
1174
+ const role = path5.basename(f, ".png");
1175
+ const m = await layerStats(path5.join(absDir, f));
1062
1176
  if (!m) {
1063
1177
  empty.push(role);
1064
1178
  continue;
@@ -1072,8 +1186,13 @@ async function measureDir(absDir, noseSpeck) {
1072
1186
  ["left", m.edgeLeft, m.h, m.marginLeft],
1073
1187
  ["right", m.edgeRight, m.h, m.marginRight]
1074
1188
  ];
1075
- if (role !== "body")
1189
+ if (role !== "body") {
1076
1190
  edges.push(["bottom", m.edgeBottom, m.w, m.marginBottom]);
1191
+ } else if (m.canvasH > m.canvasW && m.marginBottom === 0) {
1192
+ warnings.push(
1193
+ `body: its bottom row is the canvas's last \u2014 on a tall canvas that cuts the feet off. Free fix: raise canvasHeight (the canvas grows downward, nothing else moves) and remeasure; regenerate body.png only if the drawing itself stops short of the soles.`
1194
+ );
1195
+ }
1077
1196
  for (const [side, v, span, margin] of edges) {
1078
1197
  if (v > EDGE_SOLID_MAX && v * span >= EDGE_RUN_MIN_PX) {
1079
1198
  const remedy = margin === 0 ? (
@@ -1085,7 +1204,7 @@ async function measureDir(absDir, noseSpeck) {
1085
1204
  `it sits flush against the canvas ${side}, which a clipped placement and already-cropped art both produce. Move it inward first \u2014 retune layout.${role}.cx/cy/w, free \u2014 and remeasure; regenerate only if the edge is still opaque with margin to spare.`
1086
1205
  ) : `its own drawing runs to the frame ${margin} px inside the canvas \u2014 regenerate that part with empty margin on that side. Billed.`;
1087
1206
  warnings.push(
1088
- `${role}: ${pct(v)} of its ${side} edge is opaque \u2014 the art is cut off there, which shows as a straight seam once the head turns. Cause: ${remedy}`
1207
+ `${role}: ${pct(v)} of its ${side} edge is opaque \u2014 the art is cut off there, which shows as a straight seam ${isArm(role) ? "once the arm raises" : "once the head turns"}. Cause: ${remedy}`
1089
1208
  );
1090
1209
  }
1091
1210
  }
@@ -1094,10 +1213,11 @@ async function measureDir(absDir, noseSpeck) {
1094
1213
  if (role === "body") continue;
1095
1214
  if (m.flatCutRun > FLAT_CUT_MAX_FRAC * m.w && m.flatCutRun >= FLAT_CUT_MIN_PX) {
1096
1215
  warnings.push(
1097
- `${role}: ${m.flatCutRun}px of straight flat edge at y=${m.flatCutY} (${pct(m.flatCutRun / m.w)} of its width) \u2014 the source art is cut through there. It hides while the head faces front and opens into a seam on turn. Regenerate this part with the whole subject inside the frame.`
1216
+ `${role}: ${m.flatCutRun}px of straight flat edge at y=${m.flatCutY} (${pct(m.flatCutRun / m.w)} of its width) \u2014 the source art is cut through there. ` + (isArm(role) ? `It hides at rest and opens into a seam once the arm raises. ` : `It hides while the head faces front and opens into a seam on turn. `) + `Regenerate this part with the whole subject inside the frame.`
1098
1217
  );
1099
1218
  }
1100
1219
  }
1220
+ warnings.push(...await armWarnings(absDir, layers));
1101
1221
  for (const side of ["L", "R"]) {
1102
1222
  const eye = layers[`eye_${side}`];
1103
1223
  const iris = layers[`iris_${side}`];
@@ -1126,8 +1246,8 @@ async function measureDir(absDir, noseSpeck) {
1126
1246
  }
1127
1247
  if (lash) {
1128
1248
  const { opaque, off } = await lashOffSclera(
1129
- path4.join(absDir, `eye_${side}.png`),
1130
- path4.join(absDir, `lash_${side}.png`)
1249
+ path5.join(absDir, `eye_${side}.png`),
1250
+ path5.join(absDir, `lash_${side}.png`)
1131
1251
  );
1132
1252
  const dTop = lash.marginTop - eye.marginTop;
1133
1253
  const faults = [
@@ -1153,7 +1273,7 @@ async function measureDir(absDir, noseSpeck) {
1153
1273
  if (noseSpeck !== void 0) {
1154
1274
  warnings.push(noseSpeckWarning(noseSpeck, "compose"));
1155
1275
  } else if (layers.nose !== void 0) {
1156
- const nose = await decodePng(path4.join(absDir, "nose.png"));
1276
+ const nose = await decodePng(path5.join(absDir, "nose.png"));
1157
1277
  const core = denseCoreOf(nose.rgba, nose.width, nose.height);
1158
1278
  if (core !== null) {
1159
1279
  const crop = detectAlphaBbox(nose.rgba, nose.width, nose.height);
@@ -1216,10 +1336,62 @@ function formatMeasureReport(result) {
1216
1336
 
1217
1337
  // src/compose.ts
1218
1338
  import fs3 from "fs";
1219
- import path5 from "path";
1220
- import sharp2 from "sharp";
1339
+ import path6 from "path";
1340
+ import sharp3 from "sharp";
1221
1341
  import { ALPHA_OPAQUE as ALPHA_OPAQUE2, detectAlphaBbox as scanAlphaBbox2 } from "@ikijs/editor";
1342
+
1343
+ // src/compose-arms.ts
1344
+ import sharp2 from "sharp";
1345
+ import {
1346
+ LayerGeometryError as LayerGeometryError3,
1347
+ armGeometry as armGeometry2,
1348
+ createLayerSetMeasurer as createLayerSetMeasurer3
1349
+ } from "@ikijs/editor";
1350
+ var ARM_WIDTH = 0.4;
1351
+ var SHOULDER_DROP = 0.12;
1352
+ async function armPlacement(role, cfg, part, body) {
1353
+ const { data } = await sharp2(part.buf).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1354
+ const layer = createLayerSetMeasurer3({ width: part.w, height: part.h }).add({
1355
+ role,
1356
+ fileName: "arm.png",
1357
+ rgba: data
1358
+ });
1359
+ if (layer === null) {
1360
+ throw new AutoRigInputError(
1361
+ `layout.${role}: arm.png is empty after alpha threshold once resized`
1362
+ );
1363
+ }
1364
+ let shoulder;
1365
+ try {
1366
+ ({ shoulder } = armGeometry2(
1367
+ layer,
1368
+ role === "arm_R" ? Infinity : -Infinity
1369
+ ));
1370
+ } catch (err) {
1371
+ if (err instanceof LayerGeometryError3) {
1372
+ throw new AutoRigInputError(`layout.${role}: ${err.message}`);
1373
+ }
1374
+ throw err;
1375
+ }
1376
+ const pivotX = shoulder.x + part.w / 2;
1377
+ const pivotY = part.h / 2 - shoulder.y;
1378
+ const cornerX = role === "arm_R" ? body.left : body.left + body.w;
1379
+ const cornerY = body.top + SHOULDER_DROP * body.h;
1380
+ return {
1381
+ left: Math.round(
1382
+ cfg.cx === void 0 ? cornerX - pivotX : cfg.cx - part.w / 2
1383
+ ),
1384
+ top: Math.round(
1385
+ cfg.cy === void 0 ? cornerY - pivotY : cfg.cy - part.h / 2
1386
+ )
1387
+ };
1388
+ }
1389
+
1390
+ // src/compose.ts
1222
1391
  var CANVAS = 1100;
1392
+ function canvasName(canvas) {
1393
+ return canvas.width === canvas.height ? `${canvas.width}` : `${canvas.width}x${canvas.height}`;
1394
+ }
1223
1395
  var EYE_W = 98;
1224
1396
  var IRIS_W = 50;
1225
1397
  var EYEWHITE_SRC = "eyewhite.png";
@@ -1232,9 +1404,17 @@ var DEFAULT_LAYOUT = {
1232
1404
  // Back hair and body sit behind the face. Both are OPTIONAL: a parts dir
1233
1405
  // without them still composes (head-only character).
1234
1406
  hair_back: { src: "hair_back.png", cx: 550, cy: 523, w: 800, optional: true },
1235
- // The torso, cut off by the canvas bottom, so the character is not a
1236
- // floating head. It rides its own `bodyDeformer`, which only breathes.
1407
+ // The bust's torso, cut off by a square canvas's bottom, so the character is
1408
+ // not a floating head; a full body on a tall canvas sets `layout.body`
1409
+ // itself. It rides the rig's `bodyWarp`, which the head hangs from.
1237
1410
  body: { src: "body.png", cx: 550, cy: 1017, w: 840, optional: true },
1411
+ // The arms, one part for both: arm_R (screen left) takes arm.png as drawn
1412
+ // and arm_L mirrors it, like the blush. They draw over the body and under
1413
+ // the face. They have no cx/cy/w defaults: each is derived from the placed
1414
+ // body (ArmLayout). OPTIONAL and opt-in: a parts dir without arm.png
1415
+ // composes as a bust does, and `skipped` never lists them.
1416
+ arm_L: { src: "arm.png", optional: true, mirror: true },
1417
+ arm_R: { src: "arm.png", optional: true, mirror: false },
1238
1418
  // The face is drawn without a neck, so its box is the skull and centres
1239
1419
  // above the eye row (bob's skull at 437 against his eyes' 475).
1240
1420
  face: { src: "face.png", cx: 550, cy: 437, w: 400 },
@@ -1299,6 +1479,8 @@ var LOWER_LASH_SRC = "eyewhite_lash_lower.png";
1299
1479
  var ORDER = [
1300
1480
  "hair_back",
1301
1481
  "body",
1482
+ "arm_L",
1483
+ "arm_R",
1302
1484
  "face",
1303
1485
  "blush_L",
1304
1486
  "blush_R",
@@ -1337,7 +1519,7 @@ var FACE_FEATURES = [
1337
1519
  "brow_L",
1338
1520
  "brow_R"
1339
1521
  ];
1340
- function resolveLayout(overrides) {
1522
+ function resolveLayout(overrides, canvas) {
1341
1523
  const resolved = { ...DEFAULT_LAYOUT };
1342
1524
  if (overrides === void 0) return resolved;
1343
1525
  const sets = /* @__PURE__ */ new Map();
@@ -1362,9 +1544,10 @@ function resolveLayout(overrides) {
1362
1544
  for (const field of ["w", "h"]) {
1363
1545
  const value = override[field];
1364
1546
  if (value === void 0) continue;
1365
- if (!Number.isInteger(value) || value < 1 || value > CANVAS) {
1547
+ const max = field === "w" ? canvas.width : canvas.height;
1548
+ if (!Number.isInteger(value) || value < 1 || value > max) {
1366
1549
  throw new AutoRigInputError(
1367
- `layout.${role}.${field} must be an integer in 1..${CANVAS}, got ${String(value)}`
1550
+ `layout.${role}.${field} must be an integer in 1..${max}, got ${String(value)}`
1368
1551
  );
1369
1552
  }
1370
1553
  set[field] = value;
@@ -1392,10 +1575,22 @@ function resolveLayout(overrides) {
1392
1575
  for (const [role, set] of sets) {
1393
1576
  if (role === "face" || role === "nose") continue;
1394
1577
  if (FACE_FEATURES.includes(role)) continue;
1395
- resolved[role] = { ...resolved[role], ...set };
1578
+ mergeRole(resolved, role, set);
1396
1579
  }
1397
1580
  return resolved;
1398
1581
  }
1582
+ function mergeRole(resolved, role, set) {
1583
+ resolved[role] = { ...resolved[role], ...set };
1584
+ }
1585
+ function resolveCanvasHeight(value) {
1586
+ if (value === void 0) return CANVAS;
1587
+ if (!Number.isInteger(value) || value % 2 !== 0 || value < CANVAS || value > MAX_CANVAS_DIM) {
1588
+ throw new AutoRigInputError(
1589
+ `canvasHeight must be an even integer in ${CANVAS}..${MAX_CANVAS_DIM}, got ${String(value)}`
1590
+ );
1591
+ }
1592
+ return value;
1593
+ }
1399
1594
  function resolveMirrorParts(names) {
1400
1595
  const mirrored = /* @__PURE__ */ new Set();
1401
1596
  for (const [i, name] of (names ?? []).entries()) {
@@ -1418,14 +1613,14 @@ function keyWhiteToAlpha(rgba) {
1418
1613
  return keyed;
1419
1614
  }
1420
1615
  async function coreAndBoundsOf(png) {
1421
- const { data, info } = await sharp2(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1616
+ const { data, info } = await sharp3(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1422
1617
  return {
1423
1618
  core: denseCoreOf(data, info.width, info.height),
1424
1619
  bounds: { x: 0, y: 0, w: info.width, h: info.height }
1425
1620
  };
1426
1621
  }
1427
1622
  async function hasCoverage(png) {
1428
- const { data, info } = await sharp2(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1623
+ const { data, info } = await sharp3(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1429
1624
  return scanAlphaBbox2(data, info.width, info.height) !== null;
1430
1625
  }
1431
1626
  async function noseSizingOf(png) {
@@ -1443,12 +1638,12 @@ async function noseSizingOf(png) {
1443
1638
  }
1444
1639
  return { box: core, whole: false };
1445
1640
  }
1446
- async function partBuffer(role, cfg, partsDir, inMemory, flipSource) {
1641
+ async function partBuffer(role, cfg, partsDir, inMemory, flipSource, canvas) {
1447
1642
  let img;
1448
1643
  if (inMemory !== void 0) {
1449
- img = sharp2(inMemory);
1644
+ img = sharp3(inMemory);
1450
1645
  } else {
1451
- const srcPath = path5.join(partsDir, cfg.src);
1646
+ const srcPath = path6.join(partsDir, cfg.src);
1452
1647
  if (!fs3.existsSync(srcPath)) {
1453
1648
  if (cfg.optional) return null;
1454
1649
  throw new AutoRigInputError(
@@ -1456,14 +1651,14 @@ async function partBuffer(role, cfg, partsDir, inMemory, flipSource) {
1456
1651
  );
1457
1652
  }
1458
1653
  const png = await decodePng(srcPath);
1459
- img = sharp2(png.hasAlpha ? png.rgba : keyWhiteToAlpha(png.rgba), {
1654
+ img = sharp3(png.hasAlpha ? png.rgba : keyWhiteToAlpha(png.rgba), {
1460
1655
  raw: { width: png.width, height: png.height, channels: 4 }
1461
1656
  });
1462
1657
  }
1463
1658
  if (!cfg.noTrim) {
1464
1659
  const kept = await img.trim({ threshold: TRIM_THRESHOLD }).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1465
1660
  const { width: keptW, height: keptH } = kept.info;
1466
- img = sharp2(kept.data, {
1661
+ img = sharp3(kept.data, {
1467
1662
  raw: { width: keptW, height: keptH, channels: 4 }
1468
1663
  });
1469
1664
  const box = boxWithoutStraySpecks(kept.data, keptW, keptH);
@@ -1476,13 +1671,13 @@ async function partBuffer(role, cfg, partsDir, inMemory, flipSource) {
1476
1671
  const sized = nose?.box ?? { x: 0, y: 0, w: trimmedW, h: trimmedH };
1477
1672
  const width = Math.round(trimmedW * cfg.w / sized.w);
1478
1673
  const height = cfg.h === void 0 ? Math.round(trimmedH * width / trimmedW) : Math.round(trimmedH * cfg.h / sized.h);
1479
- if (width > CANVAS || height > CANVAS) {
1480
- const field = width > CANVAS || cfg.h === void 0 ? "w" : "h";
1674
+ if (width > canvas.width || height > canvas.height) {
1675
+ const field = width > canvas.width || cfg.h === void 0 ? "w" : "h";
1481
1676
  throw new AutoRigInputError(
1482
- `layout.${role}.${field}: resized part ${width}x${height} exceeds the ${CANVAS} canvas`
1677
+ `layout.${role}.${field}: resized part ${width}x${height} exceeds the ${canvasName(canvas)} canvas`
1483
1678
  );
1484
1679
  }
1485
- const resized = await sharp2(trimmed.data).resize(cfg.h === void 0 ? { width } : { width, height, fit: "fill" }).png().toBuffer({ resolveWithObject: true });
1680
+ const resized = await sharp3(trimmed.data).resize(cfg.h === void 0 ? { width } : { width, height, fit: "fill" }).png().toBuffer({ resolveWithObject: true });
1486
1681
  return {
1487
1682
  buf: resized.data,
1488
1683
  w: resized.info.width,
@@ -1490,20 +1685,20 @@ async function partBuffer(role, cfg, partsDir, inMemory, flipSource) {
1490
1685
  nose
1491
1686
  };
1492
1687
  }
1493
- function assertOnCanvas(source, w, h, left, top) {
1494
- if (left + w <= 0 || top + h <= 0 || left >= CANVAS || top >= CANVAS) {
1688
+ function assertOnCanvas(source, w, h, left, top, canvas) {
1689
+ if (left + w <= 0 || top + h <= 0 || left >= canvas.width || top >= canvas.height) {
1495
1690
  throw new AutoRigInputError(
1496
- `${source}: the placed part (${w}x${h} at ${left},${top}) falls entirely outside the ${CANVAS} canvas`
1691
+ `${source}: the placed part (${w}x${h} at ${left},${top}) falls entirely outside the ${canvasName(canvas)} canvas`
1497
1692
  );
1498
1693
  }
1499
1694
  }
1500
- function placement(role, cfg, w, h) {
1695
+ function placement(role, cfg, w, h, canvas) {
1501
1696
  const left = Math.round(cfg.cx - w / 2);
1502
1697
  const top = Math.round(cfg.cy - h / 2);
1503
- assertOnCanvas(`layout.${role}.cx/cy`, w, h, left, top);
1698
+ assertOnCanvas(`layout.${role}.cx/cy`, w, h, left, top, canvas);
1504
1699
  return { left, top };
1505
1700
  }
1506
- function nosePlacement(layout, box, w, h) {
1701
+ function nosePlacement(layout, box, w, h, canvas) {
1507
1702
  const { cx, cy } = layout.nose;
1508
1703
  const left = Math.round(cx - (box.x + box.w / 2));
1509
1704
  let top;
@@ -1521,15 +1716,16 @@ function nosePlacement(layout, box, w, h) {
1521
1716
  w,
1522
1717
  h,
1523
1718
  left,
1524
- top
1719
+ top,
1720
+ canvas
1525
1721
  );
1526
1722
  return { left, top };
1527
1723
  }
1528
- function blankCanvas() {
1529
- return sharp2({
1724
+ function blankCanvas(canvas) {
1725
+ return sharp3({
1530
1726
  create: {
1531
- width: CANVAS,
1532
- height: CANVAS,
1727
+ width: canvas.width,
1728
+ height: canvas.height,
1533
1729
  channels: 4,
1534
1730
  background: { r: 0, g: 0, b: 0, alpha: 0 }
1535
1731
  }
@@ -1562,14 +1758,14 @@ function boxWithoutStraySpecks(rgba, W, H) {
1562
1758
  const p = stack[--depth];
1563
1759
  size++;
1564
1760
  if (rgba[p * 4 + 3] >= ALPHA_OPAQUE2) opaque = true;
1565
- const px = p % W;
1566
- const py = (p - px) / W;
1567
- setLeft = Math.min(setLeft, px);
1761
+ const px2 = p % W;
1762
+ const py = (p - px2) / W;
1763
+ setLeft = Math.min(setLeft, px2);
1568
1764
  setTop = Math.min(setTop, py);
1569
- setRight = Math.max(setRight, px);
1765
+ setRight = Math.max(setRight, px2);
1570
1766
  setBottom = Math.max(setBottom, py);
1571
1767
  for (let y = Math.max(0, py - 1); y <= Math.min(H - 1, py + 1); y++) {
1572
- for (let x = Math.max(0, px - 1); x <= Math.min(W - 1, px + 1); x++) {
1768
+ for (let x = Math.max(0, px2 - 1); x <= Math.min(W - 1, px2 + 1); x++) {
1573
1769
  const q = y * W + x;
1574
1770
  if (!visited[q] && rgba[q * 4 + 3] > TRIM_THRESHOLD) {
1575
1771
  visited[q] = 1;
@@ -1607,10 +1803,10 @@ function detachedAboveWhite(rgba, W, H) {
1607
1803
  const label = new Int32Array(n).fill(-1);
1608
1804
  const stack = new Int32Array(n);
1609
1805
  const near = (p, visit) => {
1610
- const px = p % W;
1611
- const py = (p - px) / W;
1806
+ const px2 = p % W;
1807
+ const py = (p - px2) / W;
1612
1808
  for (let y = Math.max(0, py - 1); y <= Math.min(H - 1, py + 1); y++) {
1613
- for (let x = Math.max(0, px - 1); x <= Math.min(W - 1, px + 1); x++) {
1809
+ for (let x = Math.max(0, px2 - 1); x <= Math.min(W - 1, px2 + 1); x++) {
1614
1810
  visit(y * W + x);
1615
1811
  }
1616
1812
  }
@@ -1682,7 +1878,7 @@ function detachedAboveWhite(rgba, W, H) {
1682
1878
  return detached;
1683
1879
  }
1684
1880
  async function prepEyeSplit(partsDir) {
1685
- const srcPath = path5.join(partsDir, EYEWHITE_SRC);
1881
+ const srcPath = path6.join(partsDir, EYEWHITE_SRC);
1686
1882
  if (!fs3.existsSync(srcPath)) {
1687
1883
  throw new AutoRigInputError(`missing eyewhite source: ${srcPath}`);
1688
1884
  }
@@ -1743,7 +1939,11 @@ async function composeLayersFromParts(input) {
1743
1939
  `partsDir and outDir resolve to the same directory (${outDir}): composing would overwrite the source parts`
1744
1940
  );
1745
1941
  }
1746
- const layout = resolveLayout(input.layout);
1942
+ const canvas = {
1943
+ width: CANVAS,
1944
+ height: resolveCanvasHeight(input.canvasHeight)
1945
+ };
1946
+ const layout = resolveLayout(input.layout, canvas);
1747
1947
  const mirrored = resolveMirrorParts(input.mirrorParts);
1748
1948
  const split = await prepEyeSplit(partsDir);
1749
1949
  const splitSources = /* @__PURE__ */ new Map([
@@ -1763,6 +1963,44 @@ async function composeLayersFromParts(input) {
1763
1963
  skipped.push(role);
1764
1964
  continue;
1765
1965
  }
1966
+ if (key === "arm_L" || key === "arm_R") {
1967
+ const arm = layout[key];
1968
+ if (!fs3.existsSync(path6.join(partsDir, arm.src))) continue;
1969
+ const body = placed.find((p) => p.role === "body");
1970
+ if (body === void 0) {
1971
+ throw new AutoRigInputError(
1972
+ "arm.png: an arm needs body.png \u2014 the composer hangs each arm on the body's shoulder, and auto_rig_from_layers hangs it from the body"
1973
+ );
1974
+ }
1975
+ const w = arm.w ?? Math.max(1, Math.round(ARM_WIDTH * body.part.w));
1976
+ const part2 = await partBuffer(
1977
+ role,
1978
+ { ...arm, w },
1979
+ partsDir,
1980
+ void 0,
1981
+ mirrored.has(arm.src),
1982
+ canvas
1983
+ );
1984
+ const { left: left2, top: top2 } = await armPlacement(key, arm, part2, {
1985
+ left: body.left,
1986
+ top: body.top,
1987
+ w: body.part.w,
1988
+ h: body.part.h
1989
+ });
1990
+ const unset = ["cx", "cy"].filter(
1991
+ (field) => arm[field] === void 0
1992
+ );
1993
+ assertOnCanvas(
1994
+ unset.length === 0 ? `layout.${key}.cx/cy` : `layout.${key}.cx/cy (${unset.join("/")} unset: its shoulder pivot hangs on the shoulder corner of layout.body's box)`,
1995
+ part2.w,
1996
+ part2.h,
1997
+ left2,
1998
+ top2,
1999
+ canvas
2000
+ );
2001
+ placed.push({ role, part: part2, left: left2, top: top2 });
2002
+ continue;
2003
+ }
1766
2004
  const cfg = lower ? { ...layout[key], src: LOWER_LASH_SRC } : layout[key];
1767
2005
  const inMemory = splitSources.get(cfg.src);
1768
2006
  const part = await partBuffer(
@@ -1771,7 +2009,8 @@ async function composeLayersFromParts(input) {
1771
2009
  partsDir,
1772
2010
  inMemory,
1773
2011
  // The split halves are cut from eyewhite.png, the file a caller names.
1774
- mirrored.has(inMemory === void 0 ? cfg.src : EYEWHITE_SRC)
2012
+ mirrored.has(inMemory === void 0 ? cfg.src : EYEWHITE_SRC),
2013
+ canvas
1775
2014
  );
1776
2015
  if (part === null || lower && !await hasCoverage(part.buf)) {
1777
2016
  skipped.push(role);
@@ -1783,9 +2022,9 @@ async function composeLayersFromParts(input) {
1783
2022
  noseSpeck = part.nose?.speck;
1784
2023
  const { core, bounds } = await coreAndBoundsOf(part.buf);
1785
2024
  const box = part.nose?.whole ? bounds : core ?? bounds;
1786
- ({ left, top } = nosePlacement(layout, box, part.w, part.h));
2025
+ ({ left, top } = nosePlacement(layout, box, part.w, part.h, canvas));
1787
2026
  } else {
1788
- ({ left, top } = placement(key, layout[key], part.w, part.h));
2027
+ ({ left, top } = placement(key, layout[key], part.w, part.h, canvas));
1789
2028
  }
1790
2029
  if (role === "lash_L" || role === "lash_R") {
1791
2030
  const eyeRole = role === "lash_L" ? "eye_L" : "eye_R";
@@ -1798,14 +2037,15 @@ async function composeLayersFromParts(input) {
1798
2037
  }
1799
2038
  placed.push({ role, part, left, top });
1800
2039
  }
1801
- for (const role of skipped) {
1802
- fs3.rmSync(path5.join(outDir, `${role}.png`), { force: true });
2040
+ for (const role of ORDER) {
2041
+ if (placed.some((p) => p.role === role)) continue;
2042
+ fs3.rmSync(path6.join(outDir, `${role}.png`), { force: true });
1803
2043
  }
1804
2044
  const layers = [];
1805
2045
  const preview = [];
1806
2046
  for (const { role, part, left, top } of placed) {
1807
- const layer = await blankCanvas().composite([{ input: part.buf, left, top }]).png().toBuffer();
1808
- const outPath = path5.join(outDir, `${role}.png`);
2047
+ const layer = await blankCanvas(canvas).composite([{ input: part.buf, left, top }]).png().toBuffer();
2048
+ const outPath = path6.join(outDir, `${role}.png`);
1809
2049
  writeFileAtomic(outPath, layer);
1810
2050
  layers.push({
1811
2051
  role,
@@ -1817,15 +2057,15 @@ async function composeLayersFromParts(input) {
1817
2057
  });
1818
2058
  preview.push({ input: part.buf, left, top });
1819
2059
  }
1820
- const previewPng = await sharp2({
2060
+ const previewPng = await sharp3({
1821
2061
  create: {
1822
- width: CANVAS,
1823
- height: CANVAS,
2062
+ width: canvas.width,
2063
+ height: canvas.height,
1824
2064
  channels: 4,
1825
2065
  background: { r: 245, g: 245, b: 248, alpha: 1 }
1826
2066
  }
1827
2067
  }).composite(preview).png().toBuffer();
1828
- const previewPath = path5.join(outDir, "preview.png");
2068
+ const previewPath = path6.join(outDir, "preview.png");
1829
2069
  writeFileAtomic(previewPath, previewPng);
1830
2070
  return {
1831
2071
  ok: true,
@@ -1846,7 +2086,7 @@ async function composeLayersFromParts(input) {
1846
2086
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
1847
2087
  import { z } from "zod";
1848
2088
  function createIkiMcpServer() {
1849
- const server = new McpServer({ name: "iki", version: "0.17.2" });
2089
+ const server = new McpServer({ name: "iki", version: "0.19.0" });
1850
2090
  server.registerTool(
1851
2091
  "validate_iki",
1852
2092
  {
@@ -1911,7 +2151,7 @@ function createIkiMcpServer() {
1911
2151
  server.registerTool(
1912
2152
  "auto_rig_from_layers",
1913
2153
  {
1914
- description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R, mouth required; iris_L/R, brow_L/R, hair_front, etc. optional) into a renderable .iki written to disk. Pass full-canvas PNG file paths; returns the output path + summary (the model is NOT inlined). Filenames map to roles unless `fileName` is given.",
2154
+ description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R, mouth required; iris_L/R, brow_L/R, hair_front, body, arm_L/arm_R, etc. optional; an arm needs the body) into a renderable .iki written to disk. Pass full-canvas PNG file paths; returns the output path + summary (the model is NOT inlined). Filenames map to roles unless `fileName` is given.",
1915
2155
  inputSchema: {
1916
2156
  layers: z.array(
1917
2157
  z.object({
@@ -1966,13 +2206,13 @@ function createIkiMcpServer() {
1966
2206
  server.registerTool(
1967
2207
  "compose_layers_from_parts",
1968
2208
  {
1969
- description: "Composes AI-generated part PNGs into canvas-aligned, role-named PNG layers on disk, ready for auto_rig_from_layers (the eyewhite split, alpha-trim/white-key, and placement pipeline the character-generation skill needs), with the same geometry report measure_layers returns standalone included inline. face, mouth, eyewhite, iris, brow, hair_front are required; hair_back, body, mouth_open, blush (one blush.png makes the blush_L/blush_R pair) and nose are optional \u2014 without a nose layer the head still turns on the rig's default profile, but it has no nose to lead the turn, and `auto_rig_from_layers` fits no turn to the art (`turnTargets` is inert, no `turn` report). A nose whose dense core is a speck \u2014 under a quarter of its trimmed part's width or height, such as a lone nostril mark or highlight \u2014 is sized and placed whole, and the inline report warns of it. A light mark drawn detached above the eye white, such as a double-eyelid crease, is dropped from the sclera (the iris's clip); dark strokes there stay lash ink. The eyewhite's dark lower lid \u2014 its line and lashes \u2014 becomes lash_lower_L/lash_lower_R, drawn over the iris; a white with none writes none and lists them in `skipped`.",
2209
+ description: "Composes AI-generated part PNGs into canvas-aligned, role-named PNG layers on disk, ready for auto_rig_from_layers (the eyewhite split, alpha-trim/white-key, and placement pipeline the character-generation skill needs), with the same geometry report measure_layers returns standalone included inline. face, mouth, eyewhite, iris, brow, hair_front are required; hair_back, body, mouth_open, blush (one blush.png makes the blush_L/blush_R pair) and nose are optional \u2014 without a nose layer the head still turns on the rig's default profile, but it has no nose to lead the turn, and `auto_rig_from_layers` fits no turn to the art (`turnTargets` is inert, no `turn` report). One arm.png \u2014 the arm on the screen LEFT, drawn hanging with its shoulder at the top \u2014 makes both arms of a full body: arm_R takes it as drawn and arm_L mirrored. The arms are opt-in: without arm.png the compose is a bust's and `skipped` never lists them. arm.png needs body.png, and each arm is hung on the body's shoulder by default (see `layout`). The inline report carries the full-body checks too: a body whose feet a tall canvas's bottom cuts off, an arm without a body, and an arm whose shoulder cap does not reach under the torso's edge. A nose whose dense core is a speck \u2014 under a quarter of its trimmed part's width or height, such as a lone nostril mark or highlight \u2014 is sized and placed whole, and the inline report warns of it. A light mark drawn detached above the eye white, such as a double-eyelid crease, is dropped from the sclera (the iris's clip); dark strokes there stay lash ink. The eyewhite's dark lower lid \u2014 its line and lashes \u2014 becomes lash_lower_L/lash_lower_R, drawn over the iris; a white with none writes none and lists them in `skipped`.",
1970
2210
  inputSchema: {
1971
2211
  partsDir: z.string().describe(
1972
2212
  "Directory of the source part PNGs (resolved against cwd)."
1973
2213
  ),
1974
2214
  outDir: z.string().describe(
1975
- "Existing directory to write the role layer PNGs + preview.png into (resolved against cwd; must already exist; confined to the working directory). Reused across runs: a role this run skips has its stale PNG from an earlier run deleted."
2215
+ "Existing directory to write the role layer PNGs + preview.png into (resolved against cwd; must already exist; confined to the working directory). Reused across runs: a role this run does not write \u2014 one it skips, or an arm once arm.png is gone \u2014 has its stale PNG from an earlier run deleted."
1976
2216
  ),
1977
2217
  layout: z.record(
1978
2218
  z.string(),
@@ -1983,10 +2223,13 @@ function createIkiMcpServer() {
1983
2223
  h: z.number()
1984
2224
  }).partial()
1985
2225
  ).optional().describe(
1986
- "Per-role override merged over the built-in defaults, keyed by role \u2014 hair_back, body, face, blush_L, blush_R, nose, mouth, mouth_open, eye_L, eye_R, iris_L, iris_R, lash_L, lash_R, brow_L, brow_R, hair_front \u2014 e.g. `{ eye_L: { cx: 660 } }`. `w` and `h` are integers in 1..1100; omit `h` to keep the part's own aspect, set it to stretch. The defaults of the face's features \u2014 blush, nose, mouth, mouth_open, eyes, irises, lashes, brows \u2014 are proportions of the face: an override of face.cx, face.cy or face.w carries them with it (scaled by the width; face.h stretches the face alone), while a feature's own override names canvas px. The nose is sized and placed by its dense core (its pixels at alpha >= 128, the drawing inside a soft nose's feather), not its whole part: `w`/`h` size the core, `cx` centres it, and a set `cy` centres its rows. A nose whose core is a speck \u2014 under a quarter of the trimmed part's width or height, such as a lone nostril mark or highlight \u2014 is sized and placed whole instead, and the report warns of it. Its `cy` defaults to unset, which lands the core's bottom row (the tip) 0.66 of the way from the eye row down to the mouth's, so the nose follows a retuned eye or mouth row. eye_L/lash_L and eye_R/lash_R are cut from one eyewhite into one frame, so each pair must land on the same frame \u2014 a pair set to land apart is rejected. lash_lower_L/lash_lower_R are cut from it too and have no key: they land on their eye's frame."
2226
+ "Per-role override merged over the built-in defaults, keyed by role \u2014 hair_back, body, arm_L, arm_R, face, blush_L, blush_R, nose, mouth, mouth_open, eye_L, eye_R, iris_L, iris_R, lash_L, lash_R, brow_L, brow_R, hair_front \u2014 e.g. `{ eye_L: { cx: 660 } }`. `w` is an integer in 1..1100 (the canvas width) and `h` in 1..canvasHeight; omit `h` to keep the part's own aspect, set it to stretch. The defaults of the face's features \u2014 blush, nose, mouth, mouth_open, eyes, irises, lashes, brows \u2014 are proportions of the face: an override of face.cx, face.cy or face.w carries them with it (scaled by the width; face.h stretches the face alone), while a feature's own override names canvas px. The nose is sized and placed by its dense core (its pixels at alpha >= 128, the drawing inside a soft nose's feather), not its whole part: `w`/`h` size the core, `cx` centres it, and a set `cy` centres its rows. A nose whose core is a speck \u2014 under a quarter of the trimmed part's width or height, such as a lone nostril mark or highlight \u2014 is sized and placed whole instead, and the report warns of it. Its `cy` defaults to unset, which lands the core's bottom row (the tip) 0.66 of the way from the eye row down to the mouth's, so the nose follows a retuned eye or mouth row. eye_L/lash_L and eye_R/lash_R are cut from one eyewhite into one frame, so each pair must land on the same frame \u2014 a pair set to land apart is rejected. lash_lower_L/lash_lower_R are cut from it too and have no key: they land on their eye's frame. arm_L/arm_R have no cx/cy/w defaults: an unset `w` is 0.4 of the placed body's width, and an unset `cx` or `cy` hangs the arm's shoulder pivot \u2014 the one auto_rig_from_layers turns it about \u2014 on the body box's shoulder corner on that axis: its left edge for arm_R, its right edge for arm_L, 0.12 of its height under its top. A set one centres the arm as for every other role."
1987
2227
  ),
1988
2228
  mirrorParts: z.array(z.string()).optional().describe(
1989
- "Part files to flip left-right as they are read, e.g. `[\"eyewhite.png\"]`. The composer reads eyewhite.png as the eye on the screen LEFT (lash wing at the image's left end, lash-free tear duct at its right), brow.png as the brow on the screen RIGHT (thick head at the image's left end, tail at its right), and blush.png as the blush on the screen LEFT (outer end, toward the face's edge, at the image's left end, inner end at its right); a part drawn the other way round is fixed here for free. It flips the source, so every role cut from it flips together and an eye's sclera and lash stay in one frame."
2229
+ "Part files to flip left-right as they are read, e.g. `[\"eyewhite.png\"]`. The composer reads eyewhite.png as the eye on the screen LEFT (lash wing at the image's left end, lash-free tear duct at its right), brow.png as the brow on the screen RIGHT (thick head at the image's left end, tail at its right), blush.png as the blush on the screen LEFT (outer end, toward the face's edge, at the image's left end, inner end at its right), and arm.png as the arm on the screen LEFT (the character's right, hanging, its shoulder at the image's top); a part drawn the other way round is fixed here for free. It flips the source, so every role cut from it flips together and an eye's sclera and lash stay in one frame."
2230
+ ),
2231
+ canvasHeight: z.number().optional().describe(
2232
+ "The canvas's height in px: an even integer in 1100..4096, default 1100 (a square bust canvas; at 1100 every output is byte-identical to leaving it out). The width stays 1100. The canvas grows downward: every default and every override keeps its canvas px from the top-left, so the head lands where it does on a bust and a full body gets room below. An odd height is refused \u2014 model space is centred on the canvas, so it would put the head on a half pixel \u2014 and it is checked before any part decodes."
1990
2233
  )
1991
2234
  }
1992
2235
  },
@@ -2011,7 +2254,7 @@ function createIkiMcpServer() {
2011
2254
  server.registerTool(
2012
2255
  "measure_layers",
2013
2256
  {
2014
- description: "Reports read-only geometry checks over an already-composed layers directory \u2014 the same checks compose_layers_from_parts returns inline (iris ratio/offset, eye aspect, cropped/cut edges, a nose whose dense core is a speck of its crop, missing optional roles). Use to re-check a layers dir without recomposing. Its nose check reads the composed file against its crop, which is what auto_rig_from_layers acts on. Compose's inline report does the same unless the composer found the source part's core a speck, which it reports instead \u2014 so a speck that resampling erased from the layer shows there and not here.",
2257
+ description: "Reports read-only geometry checks over an already-composed layers directory \u2014 the same checks compose_layers_from_parts returns inline (iris ratio/offset, eye aspect, cropped/cut edges, a nose whose dense core is a speck of its crop, missing optional roles, a body whose feet a tall canvas's bottom cuts off, an arm without a body, an arm whose shoulder cap does not reach under the torso's edge on its shoulder pivot's row). Every preview*.png is skipped. Use to re-check a layers dir without recomposing. Its nose check reads the composed file against its crop, which is what auto_rig_from_layers acts on. Compose's inline report does the same unless the composer found the source part's core a speck, which it reports instead \u2014 so a speck that resampling erased from the layer shows there and not here.",
2015
2258
  inputSchema: {
2016
2259
  layersDir: z.string().describe(
2017
2260
  "Directory of role-named layer PNGs (resolved against cwd)."
@@ -2088,4 +2331,4 @@ export {
2088
2331
  composeLayersFromParts,
2089
2332
  createIkiMcpServer
2090
2333
  };
2091
- //# sourceMappingURL=chunk-CUINYKRG.mjs.map
2334
+ //# sourceMappingURL=chunk-E6DLZPCX.mjs.map