@ikijs/mcp 0.10.0 → 0.11.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
@@ -254,6 +254,28 @@ var BG_HUE_MAX = 260;
254
254
  var BG_SAT_MAX = 0.2;
255
255
  var BG_V_MIN = 0.55;
256
256
  var BG_V_BLACK = 0.03;
257
+ function denseCoreOf(rgba, width, height) {
258
+ let minX = width;
259
+ let minY = height;
260
+ let maxX = -1;
261
+ let maxY = -1;
262
+ for (let y = 0; y < height; y++) {
263
+ for (let x = 0; x < width; x++) {
264
+ if (rgba[(y * width + x) * 4 + 3] >= ALPHA_OPAQUE) {
265
+ if (x < minX) minX = x;
266
+ if (x > maxX) maxX = x;
267
+ if (y < minY) minY = y;
268
+ if (y > maxY) maxY = y;
269
+ }
270
+ }
271
+ }
272
+ if (maxX < 0) return null;
273
+ return { x: minX, y: minY, w: maxX - minX + 1, h: maxY - minY + 1 };
274
+ }
275
+ var SPECK_CORE_FRACTION = 0.25;
276
+ function isSpeckCore(core, part) {
277
+ return core.w < SPECK_CORE_FRACTION * part.w || core.h < SPECK_CORE_FRACTION * part.h;
278
+ }
257
279
  function rgbToHsv(r, g, b) {
258
280
  r /= 255;
259
281
  g /= 255;
@@ -775,6 +797,19 @@ function facePlateHalfOf(layers) {
775
797
  return face.cropW / 2;
776
798
  }
777
799
  var STRAND_MIN_RUN_FRACTION = 0.5;
800
+ var LOSSLESS_PAGE_ROLE = "nose";
801
+ async function renderAtlasPage(crops, quantizeColors) {
802
+ const layout = (0, import_editor2.packAtlas)(
803
+ crops.map((c) => ({ id: c.id, width: c.width, height: c.height }))
804
+ );
805
+ if (layout.pageWidth * layout.pageHeight > MAX_ATLAS_AREA) {
806
+ throw new AutoRigInputError(
807
+ `atlas page ${layout.pageWidth}x${layout.pageHeight} exceeds max area ${MAX_ATLAS_AREA}`
808
+ );
809
+ }
810
+ const dataUri = await renderAtlasToDataUri(crops, layout, quantizeColors);
811
+ return { crops, layout, dataUri };
812
+ }
778
813
  async function autoRigFromLayers(input) {
779
814
  try {
780
815
  const layers = input.layers;
@@ -886,10 +921,14 @@ async function autoRigFromLayers(input) {
886
921
  );
887
922
  }
888
923
  layer.rowHalfWidths = rowHalfWidths;
924
+ } else if (role === "nose") {
925
+ const core = denseCoreOf(png.rgba, canvasW, canvasH);
926
+ if (core !== null && !isSpeckCore(core, bbox)) layer.denseCore = core;
889
927
  }
890
928
  layerInputs.push(layer);
891
929
  crops.push({ id: role, buffer, width: bbox.w, height: bbox.h });
892
930
  }
931
+ const noseCore = layerInputs.find((l) => l.role === "nose")?.denseCore;
893
932
  const eyeRow = eyeRowOf(layerInputs);
894
933
  const span = foregroundSpan(
895
934
  opaque,
@@ -999,46 +1038,58 @@ async function autoRigFromLayers(input) {
999
1038
  throw new AutoRigInputError(e.message);
1000
1039
  }
1001
1040
  const doc = new import_editor2.EditorDocument(model);
1002
- const layout = (0, import_editor2.packAtlas)(
1003
- crops.map((c) => ({ id: c.id, width: c.width, height: c.height }))
1004
- );
1005
- if (layout.pageWidth * layout.pageHeight > MAX_ATLAS_AREA) {
1006
- throw new AutoRigInputError(
1007
- `atlas page ${layout.pageWidth}x${layout.pageHeight} exceeds max area ${MAX_ATLAS_AREA}`
1008
- );
1009
- }
1010
- const dataUri = await renderAtlasToDataUri(crops, layout, quantizeColors);
1011
- if (dataUri.length > MAX_OUTPUT_BYTES) {
1041
+ const losslessCrop = quantizeColors === void 0 ? void 0 : crops.find((c) => c.id === LOSSLESS_PAGE_ROLE);
1042
+ const pages = losslessCrop === void 0 ? [await renderAtlasPage(crops, quantizeColors)] : [
1043
+ await renderAtlasPage(
1044
+ crops.filter((c) => c !== losslessCrop),
1045
+ quantizeColors
1046
+ ),
1047
+ await renderAtlasPage([losslessCrop], void 0)
1048
+ ];
1049
+ const atlasBytes = pages.reduce((sum, p) => sum + p.dataUri.length, 0);
1050
+ if (atlasBytes > MAX_OUTPUT_BYTES) {
1012
1051
  throw new AutoRigInputError(
1013
- `atlas data URI ${dataUri.length} bytes exceeds ${MAX_OUTPUT_BYTES}`
1052
+ `atlas data URI ${atlasBytes} bytes exceeds ${MAX_OUTPUT_BYTES}`
1014
1053
  );
1015
1054
  }
1016
- const partTextureAssignments = crops.map((crop) => {
1017
- const placement2 = layout.placements.find((p) => p.id === crop.id);
1018
- if (placement2 === void 0) {
1019
- throw new Error(`auto-rig: no atlas placement for "${crop.id}"`);
1020
- }
1021
- return {
1022
- partId: crop.id,
1023
- uv: (0, import_editor2.uvRectFor)(placement2, {
1024
- width: layout.pageWidth,
1025
- height: layout.pageHeight
1026
- })
1027
- };
1055
+ const partTextureAssignments = pages.flatMap(
1056
+ ({ crops: pageCrops, layout }) => pageCrops.map((crop) => {
1057
+ const placement2 = layout.placements.find((p) => p.id === crop.id);
1058
+ if (placement2 === void 0) {
1059
+ throw new Error(`auto-rig: no atlas placement for "${crop.id}"`);
1060
+ }
1061
+ return {
1062
+ partId: crop.id,
1063
+ uv: (0, import_editor2.uvRectFor)(placement2, {
1064
+ width: layout.pageWidth,
1065
+ height: layout.pageHeight
1066
+ })
1067
+ };
1068
+ })
1069
+ );
1070
+ doc.applyAtlas({
1071
+ textures: [{ source: pages[0].dataUri }],
1072
+ partTextureAssignments
1028
1073
  });
1029
- doc.applyAtlas({ textures: [{ source: dataUri }], partTextureAssignments });
1030
- const finalModel = (0, import_format.parseIkiModel)(doc.getModel());
1074
+ let patched = doc.getModel();
1075
+ if (losslessCrop !== void 0) {
1076
+ patched = structuredClone(patched);
1077
+ patched.textures = pages.map((p) => ({ source: p.dataUri }));
1078
+ patched.parts.find((p) => p.id === losslessCrop.id).texture.index = 1;
1079
+ }
1080
+ const finalModel = (0, import_format.parseIkiModel)(patched);
1031
1081
  writeFileAtomic(outPath, JSON.stringify(finalModel));
1032
1082
  return {
1033
1083
  ok: true,
1034
1084
  path: outPath,
1035
1085
  canvas: { width: canvasW, height: canvasH },
1036
1086
  partCount: finalModel.parts.length,
1037
- atlasBytes: dataUri.length,
1087
+ atlasBytes,
1038
1088
  ...headHalfWidth === void 0 ? {} : { headHalfWidth },
1039
1089
  headHalfWidthApplied,
1040
1090
  ...headEdges === void 0 ? {} : { headEdges },
1041
1091
  ...strandEdges === void 0 ? {} : { strandEdges },
1092
+ ...noseCore === void 0 ? {} : { noseCore },
1042
1093
  ...turn === void 0 ? {} : { turn }
1043
1094
  };
1044
1095
  } catch (err) {
@@ -1144,6 +1195,16 @@ async function layerStats(filePath) {
1144
1195
  };
1145
1196
  }
1146
1197
  var pct = (v) => `${(v * 100).toFixed(0)}%`;
1198
+ function noseSpeckWarning({ core, part }, source) {
1199
+ const [found, consequence] = source === "compose" ? [
1200
+ `the source part's dense core is ${core.w}x${core.h} in its ${part.w}x${part.h} trimmed part`,
1201
+ `compose_layers_from_parts sized and placed the whole part instead \u2014 layout.nose's w and h now size it, feather included`
1202
+ ] : [
1203
+ `the layer's dense core is ${core.w}x${core.h} in its ${part.w}x${part.h} crop`,
1204
+ `auto_rig_from_layers turns and tilts the nose about its whole crop instead`
1205
+ ];
1206
+ return `nose: ${found} \u2014 under ${SPECK_CORE_FRACTION} of its width or height, a speck: a lone nostril mark or highlight at alpha >= 128, not the drawing, so ${consequence}. Regenerate the nose with its shading painted denser, so the drawing itself reaches alpha 128. Billed.`;
1207
+ }
1147
1208
  async function lashOffSclera(eyePath, lashPath) {
1148
1209
  const eye = await decodePng(eyePath);
1149
1210
  const lash = await decodePng(lashPath);
@@ -1159,7 +1220,7 @@ async function lashOffSclera(eyePath, lashPath) {
1159
1220
  }
1160
1221
  return { opaque, off };
1161
1222
  }
1162
- async function measureDir(absDir) {
1223
+ async function measureDir(absDir, noseSpeck) {
1163
1224
  const files = import_node_fs2.default.readdirSync(absDir).filter((f) => f.endsWith(".png") && f !== "preview.png").sort();
1164
1225
  if (files.length === 0) {
1165
1226
  throw new AutoRigInputError(`no role layers in ${absDir}`);
@@ -1265,6 +1326,17 @@ async function measureDir(absDir) {
1265
1326
  }
1266
1327
  }
1267
1328
  }
1329
+ if (noseSpeck !== void 0) {
1330
+ warnings.push(noseSpeckWarning(noseSpeck, "compose"));
1331
+ } else if (layers.nose !== void 0) {
1332
+ const nose = await decodePng(import_node_path4.default.join(absDir, "nose.png"));
1333
+ const core = denseCoreOf(nose.rgba, nose.width, nose.height);
1334
+ if (core !== null) {
1335
+ const crop = detectAlphaBbox(nose.rgba, nose.width, nose.height);
1336
+ if (isSpeckCore(core, crop))
1337
+ warnings.push(noseSpeckWarning({ core, part: crop }, "layer"));
1338
+ }
1339
+ }
1268
1340
  for (const [role, why] of [
1269
1341
  ["body", "without it the character reads as a floating head on head-turn"],
1270
1342
  ["hair_back", "without it the silhouette is flat behind the face"],
@@ -1325,6 +1397,7 @@ var IRIS_W = Math.round(EYE_W * 0.5625);
1325
1397
  var EYEWHITE_SRC = "eyewhite.png";
1326
1398
  var EYE_LASH_LUMA = 120;
1327
1399
  var LASH_KEEP_FRACTION = 0.5;
1400
+ var NOSE_TIP_AT = 0.86;
1328
1401
  var DEFAULT_LAYOUT = {
1329
1402
  // Back hair and body sit behind the face. Both are OPTIONAL: a parts dir
1330
1403
  // without them still composes (head-only character).
@@ -1336,9 +1409,11 @@ var DEFAULT_LAYOUT = {
1336
1409
  face: { src: "face.png", cx: 550, cy: 475, w: 400 },
1337
1410
  // The nose, drawn on its own (the face is drawn without one): the auto-rig
1338
1411
  // leads the head turn with it and keys the other features' slide on its
1339
- // presence, so without it the features stay on the face plate. Sits between
1340
- // the eyes and above the mouth. OPTIONAL: a parts dir without it composes.
1341
- nose: { src: "nose.png", cx: 550, cy: 586, w: 40, optional: true },
1412
+ // presence, so without it the features stay on the face plate. `w` is the
1413
+ // width of its dense core, and it has no `cy`: its row comes from the tip
1414
+ // rule (NOSE_TIP_AT), between the eyes and the mouth, so it follows them
1415
+ // when they are retuned. OPTIONAL: a parts dir without it composes.
1416
+ nose: { src: "nose.png", cx: 550, w: 40, optional: true },
1342
1417
  mouth: { src: "mouth.png", cx: 550, cy: 619, w: 68 },
1343
1418
  // Cross-fades with `mouth` on ParamMouthOpenY (opacity, not scaleY) once the
1344
1419
  // auto-rig sees both roles. Same cx/w as `mouth` so the lip width matches;
@@ -1409,7 +1484,7 @@ function resolveLayout(overrides) {
1409
1484
  );
1410
1485
  }
1411
1486
  if (override === void 0) continue;
1412
- const next = { ...resolved[role] };
1487
+ const set = {};
1413
1488
  for (const field of ["cx", "cy"]) {
1414
1489
  const value = override[field];
1415
1490
  if (value === void 0) continue;
@@ -1418,7 +1493,7 @@ function resolveLayout(overrides) {
1418
1493
  `layout.${role}.${field} must be a finite number, got ${String(value)}`
1419
1494
  );
1420
1495
  }
1421
- next[field] = value;
1496
+ set[field] = value;
1422
1497
  }
1423
1498
  for (const field of ["w", "h"]) {
1424
1499
  const value = override[field];
@@ -1428,9 +1503,11 @@ function resolveLayout(overrides) {
1428
1503
  `layout.${role}.${field} must be an integer in 1..${CANVAS}, got ${String(value)}`
1429
1504
  );
1430
1505
  }
1431
- next[field] = value;
1506
+ set[field] = value;
1432
1507
  }
1433
- resolved[role] = next;
1508
+ const key = role;
1509
+ if (key === "nose") resolved.nose = { ...resolved.nose, ...set };
1510
+ else resolved[key] = { ...resolved[key], ...set };
1434
1511
  }
1435
1512
  return resolved;
1436
1513
  }
@@ -1455,6 +1532,28 @@ function keyWhiteToAlpha(rgba) {
1455
1532
  }
1456
1533
  return keyed;
1457
1534
  }
1535
+ async function coreAndBoundsOf(png) {
1536
+ const { data, info } = await (0, import_sharp2.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1537
+ return {
1538
+ core: denseCoreOf(data, info.width, info.height),
1539
+ bounds: { x: 0, y: 0, w: info.width, h: info.height }
1540
+ };
1541
+ }
1542
+ async function noseSizingOf(png) {
1543
+ const { core, bounds } = await coreAndBoundsOf(png);
1544
+ if (core === null) return { box: bounds, whole: true };
1545
+ if (isSpeckCore(core, bounds)) {
1546
+ return {
1547
+ box: bounds,
1548
+ whole: true,
1549
+ speck: {
1550
+ core: { w: core.w, h: core.h },
1551
+ part: { w: bounds.w, h: bounds.h }
1552
+ }
1553
+ };
1554
+ }
1555
+ return { box: core, whole: false };
1556
+ }
1458
1557
  async function partBuffer(role, cfg, partsDir, inMemory, flipSource) {
1459
1558
  let img;
1460
1559
  if (inMemory !== void 0) {
@@ -1475,33 +1574,58 @@ async function partBuffer(role, cfg, partsDir, inMemory, flipSource) {
1475
1574
  if (!cfg.noTrim) img = img.trim({ threshold: 12 });
1476
1575
  if ((cfg.mirror ?? false) !== flipSource) img = img.flop();
1477
1576
  const trimmed = await img.png().toBuffer({ resolveWithObject: true });
1478
- if (cfg.h === void 0) {
1479
- const scaledH = Math.round(
1480
- trimmed.info.height * cfg.w / trimmed.info.width
1577
+ const { width: trimmedW, height: trimmedH } = trimmed.info;
1578
+ const nose = role === "nose" ? await noseSizingOf(trimmed.data) : void 0;
1579
+ const sized = nose?.box ?? { x: 0, y: 0, w: trimmedW, h: trimmedH };
1580
+ const width = Math.round(trimmedW * cfg.w / sized.w);
1581
+ const height = cfg.h === void 0 ? Math.round(trimmedH * width / trimmedW) : Math.round(trimmedH * cfg.h / sized.h);
1582
+ if (width > CANVAS || height > CANVAS) {
1583
+ const field = width > CANVAS || cfg.h === void 0 ? "w" : "h";
1584
+ throw new AutoRigInputError(
1585
+ `layout.${role}.${field}: resized part ${width}x${height} exceeds the ${CANVAS} canvas`
1481
1586
  );
1482
- if (scaledH > CANVAS) {
1483
- throw new AutoRigInputError(
1484
- `layout.${role}.w: resized part ${cfg.w}x${scaledH} exceeds the ${CANVAS} canvas`
1485
- );
1486
- }
1487
1587
  }
1488
- const resized = await (0, import_sharp2.default)(trimmed.data).resize(
1489
- cfg.h === void 0 ? { width: cfg.w } : { width: cfg.w, height: cfg.h, fit: "fill" }
1490
- ).png().toBuffer({ resolveWithObject: true });
1588
+ const resized = await (0, import_sharp2.default)(trimmed.data).resize(cfg.h === void 0 ? { width } : { width, height, fit: "fill" }).png().toBuffer({ resolveWithObject: true });
1491
1589
  return {
1492
1590
  buf: resized.data,
1493
1591
  w: resized.info.width,
1494
- h: resized.info.height
1592
+ h: resized.info.height,
1593
+ nose
1495
1594
  };
1496
1595
  }
1497
- function placement(role, cfg, w, h) {
1498
- const left = Math.round(cfg.cx - w / 2);
1499
- const top = Math.round(cfg.cy - h / 2);
1596
+ function assertOnCanvas(source, w, h, left, top) {
1500
1597
  if (left + w <= 0 || top + h <= 0 || left >= CANVAS || top >= CANVAS) {
1501
1598
  throw new AutoRigInputError(
1502
- `layout.${role}.cx/cy: the placed part (${w}x${h} at ${left},${top}) falls entirely outside the ${CANVAS} canvas`
1599
+ `${source}: the placed part (${w}x${h} at ${left},${top}) falls entirely outside the ${CANVAS} canvas`
1503
1600
  );
1504
1601
  }
1602
+ }
1603
+ function placement(role, cfg, w, h) {
1604
+ const left = Math.round(cfg.cx - w / 2);
1605
+ const top = Math.round(cfg.cy - h / 2);
1606
+ assertOnCanvas(`layout.${role}.cx/cy`, w, h, left, top);
1607
+ return { left, top };
1608
+ }
1609
+ function nosePlacement(layout, box, w, h) {
1610
+ const { cx, cy } = layout.nose;
1611
+ const left = Math.round(cx - (box.x + box.w / 2));
1612
+ let top;
1613
+ if (cy !== void 0) {
1614
+ top = Math.round(cy - (box.y + box.h / 2));
1615
+ } else {
1616
+ const eyeRow = (layout.eye_L.cy + layout.eye_R.cy) / 2;
1617
+ const tipRow = Math.round(
1618
+ eyeRow + NOSE_TIP_AT * (layout.mouth.cy - eyeRow)
1619
+ );
1620
+ top = tipRow - (box.y + box.h - 1);
1621
+ }
1622
+ assertOnCanvas(
1623
+ cy !== void 0 ? "layout.nose.cx/cy" : "layout.nose.cx/cy (cy unset: its tip row comes from layout.eye_L/eye_R/mouth.cy)",
1624
+ w,
1625
+ h,
1626
+ left,
1627
+ top
1628
+ );
1505
1629
  return { left, top };
1506
1630
  }
1507
1631
  function blankCanvas() {
@@ -1578,6 +1702,7 @@ async function composeLayersFromParts(input) {
1578
1702
  ]);
1579
1703
  const placed = [];
1580
1704
  const skipped = [];
1705
+ let noseSpeck;
1581
1706
  for (const role of ORDER) {
1582
1707
  const cfg = layout[role];
1583
1708
  const inMemory = splitSources.get(cfg.src);
@@ -1593,7 +1718,16 @@ async function composeLayersFromParts(input) {
1593
1718
  skipped.push(role);
1594
1719
  continue;
1595
1720
  }
1596
- const { left, top } = placement(role, cfg, part.w, part.h);
1721
+ let left;
1722
+ let top;
1723
+ if (role === "nose") {
1724
+ noseSpeck = part.nose?.speck;
1725
+ const { core, bounds } = await coreAndBoundsOf(part.buf);
1726
+ const box = part.nose?.whole ? bounds : core ?? bounds;
1727
+ ({ left, top } = nosePlacement(layout, box, part.w, part.h));
1728
+ } else {
1729
+ ({ left, top } = placement(role, layout[role], part.w, part.h));
1730
+ }
1597
1731
  if (role === "lash_L" || role === "lash_R") {
1598
1732
  const eyeRole = role === "lash_L" ? "eye_L" : "eye_R";
1599
1733
  const eye = placed.find((p) => p.role === eyeRole);
@@ -1640,7 +1774,7 @@ async function composeLayersFromParts(input) {
1640
1774
  layers,
1641
1775
  skipped,
1642
1776
  preview: previewPath,
1643
- measure: await measureDir(outDir)
1777
+ measure: await measureDir(outDir, noseSpeck)
1644
1778
  };
1645
1779
  } catch (err) {
1646
1780
  if (err instanceof AutoRigInputError)
@@ -1651,7 +1785,7 @@ async function composeLayersFromParts(input) {
1651
1785
 
1652
1786
  // src/server.ts
1653
1787
  function createIkiMcpServer() {
1654
- const server = new import_mcp.McpServer({ name: "iki", version: "0.10.0" });
1788
+ const server = new import_mcp.McpServer({ name: "iki", version: "0.11.1" });
1655
1789
  server.registerTool(
1656
1790
  "validate_iki",
1657
1791
  {
@@ -1730,7 +1864,7 @@ function createIkiMcpServer() {
1730
1864
  "Output .iki path (resolved against cwd; parent dir must exist)."
1731
1865
  ),
1732
1866
  quantizeColors: import_zod.z.number().int().min(2).max(256).optional().describe(
1733
- "Palette-quantize the atlas PNG to this many colours (2..256). Flat-shaded art keeps its look at 256 and the model shrinks to about a quarter; omit for lossless."
1867
+ "Palette-quantize the atlas PNG to this many colours (2..256). Flat-shaded art keeps its look at 256 and the model shrinks to about a quarter; omit for lossless. A `nose` layer stays lossless on a second atlas page of its own, since the palette rims a soft-shaded nose's feather; the nose's own lossless page adds a content-dependent amount, since splitting it off also changes how page 0 re-quantizes without it; the result's `atlasBytes` sums both pages."
1734
1868
  ),
1735
1869
  turnTargets: import_zod.z.object({
1736
1870
  eyeShift: import_zod.z.number().optional(),
@@ -1739,7 +1873,7 @@ function createIkiMcpServer() {
1739
1873
  noseShift: import_zod.z.number().optional(),
1740
1874
  mouthShift: import_zod.z.number().optional()
1741
1875
  }).optional().describe(
1742
- "What the head turn is fitted to, as `measure_turn_reference` reports it off a front/turned reference pair. `eyeShift` (and the optional `noseShift`/`mouthShift`, derived from it when absent) is how far that feature slides across the head at full turn, as a fraction of the head's half-width \u2014 a MAGNITUDE: the rig turns both ways, so the sign is ignored. `farEyeRatio` is the far/near eye width at full turn over that same ratio at rest, `silhouetteRatio` the head's half-width turned over at rest. The half-width the shifts are fractions of is measured off the layers themselves, so it is not an input. An omitted field falls back to a default, which is clamped to what this layer set can do, and so is a passed `eyeShift` past the room the art leaves the far eye \u2014 the face plate's edge, or the bangs' side strand over the far iris (the result's `turn.clamped` lists every clamped field, `turn.achieved` what the rig reaches, and `turn.strandOverlap` how much of a far iris the bangs still cover). Any other passed target this layer set cannot reach, including an `eyeShift` smaller than the slide the face's own turn already gives the eyes, comes back as `INVALID: \u2026` naming the field and the attainable range, since it is a measurement rather than a preference."
1876
+ "What the head turn is fitted to, as `measure_turn_reference` reports it off a front/turned reference pair. `eyeShift` (and the optional `noseShift`/`mouthShift`, derived from it when absent) is how far that feature slides across the head at full turn, as a fraction of the head's half-width \u2014 a MAGNITUDE: the rig turns both ways, so the sign is ignored. `farEyeRatio` is the far/near eye width at full turn over that same ratio at rest, `silhouetteRatio` the head's half-width turned over at rest. The half-width the shifts are fractions of is measured off the layers themselves, so it is not an input. An omitted field falls back to a default, which is clamped to what this layer set can do, and so is a passed `eyeShift` past the room the art leaves the far eye \u2014 the face plate's edge, or the bangs' side strand over the far iris (the result's `turn.clamped` lists every clamped field, `turn.achieved` what the rig reaches, and `turn.strandOverlap` how much of a far iris the bangs still cover). Any other passed target this layer set cannot reach, including an `eyeShift` smaller than the slide the face's own turn already gives the eyes, comes back as `INVALID: \u2026` naming the field and the attainable range, since it is a measurement rather than a preference \u2014 except a passed `silhouetteRatio` when no ratio in its whole accepted range renders on this layer set: that refusal reads `\u2026 is unreachable for this layer set, and so is every silhouetteRatio in [0.5, 1.5]` and names no range, so leave the field out, since a defaulted one clamps."
1743
1877
  )
1744
1878
  }
1745
1879
  },
@@ -1761,7 +1895,7 @@ function createIkiMcpServer() {
1761
1895
  server.registerTool(
1762
1896
  "compose_layers_from_parts",
1763
1897
  {
1764
- 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, nose are optional \u2014 without a nose layer the rig does not slide the features on the head turn.",
1898
+ 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, nose are optional \u2014 without a nose layer the rig does not slide the features on the head turn. 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.",
1765
1899
  inputSchema: {
1766
1900
  partsDir: import_zod.z.string().describe(
1767
1901
  "Directory of the source part PNGs (resolved against cwd)."
@@ -1778,7 +1912,7 @@ function createIkiMcpServer() {
1778
1912
  h: import_zod.z.number()
1779
1913
  }).partial()
1780
1914
  ).optional().describe(
1781
- "Per-role override merged over the built-in defaults, keyed by role \u2014 hair_back, body, face, 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. 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."
1915
+ "Per-role override merged over the built-in defaults, keyed by role \u2014 hair_back, body, face, 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 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.86 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."
1782
1916
  ),
1783
1917
  mirrorParts: import_zod.z.array(import_zod.z.string()).optional().describe(
1784
1918
  "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) and brow.png as the brow on the screen RIGHT (thick head at the image's left end, tail 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."
@@ -1806,7 +1940,7 @@ function createIkiMcpServer() {
1806
1940
  server.registerTool(
1807
1941
  "measure_layers",
1808
1942
  {
1809
- 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, missing optional roles). Use to re-check a layers dir without recomposing.",
1943
+ 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.",
1810
1944
  inputSchema: {
1811
1945
  layersDir: import_zod.z.string().describe(
1812
1946
  "Directory of role-named layer PNGs (resolved against cwd)."