@ikijs/mcp 0.32.0 → 0.33.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
@@ -3709,7 +3709,7 @@ async function autoRigFromLayers(input) {
3709
3709
  var import_node_fs7 = __toESM(require("fs"));
3710
3710
  var import_node_path10 = __toESM(require("path"));
3711
3711
  var import_sharp4 = __toESM(require("sharp"));
3712
- var import_editor12 = require("@ikijs/editor");
3712
+ var import_editor13 = require("@ikijs/editor");
3713
3713
 
3714
3714
  // src/trim.ts
3715
3715
  var import_editor4 = require("@ikijs/editor");
@@ -3852,8 +3852,184 @@ function capWarning(arm, g, body) {
3852
3852
  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).`;
3853
3853
  }
3854
3854
 
3855
- // src/measure-forearm-pose.ts
3855
+ // src/measure-hair-side.ts
3856
3856
  var import_editor6 = require("@ikijs/editor");
3857
+ var LOCK_ROLES = ["hair_side_R", "hair_side_L"];
3858
+ var VISIBLE_MIN_PX = 3;
3859
+ var LEAN_HH = 0.12;
3860
+ var TWO_LOCKS_RUN = 0.25;
3861
+ var TWO_LOCKS_GAP = 0.1;
3862
+ function covers(runs, x) {
3863
+ for (let i = 0; i + 1 < runs.length; i += 2) {
3864
+ if (x >= runs[i] && x < runs[i + 1]) return true;
3865
+ }
3866
+ return false;
3867
+ }
3868
+ function runsAt(layer, y) {
3869
+ return layer?.rowRuns?.[y - layer.bbox.y] ?? [];
3870
+ }
3871
+ function opaqueRows(layer) {
3872
+ const runs = layer.rowRuns ?? [];
3873
+ const top = runs.findIndex((r) => r.length > 0);
3874
+ if (top < 0) return void 0;
3875
+ let bottom = runs.length - 1;
3876
+ while (runs[bottom].length === 0) bottom--;
3877
+ return { top: layer.bbox.y + top, bottom: layer.bbox.y + bottom };
3878
+ }
3879
+ async function hairSideWarnings(absDir, layers) {
3880
+ const present = LOCK_ROLES.filter((r) => layers[r] !== void 0);
3881
+ if (present.length === 0) return [];
3882
+ const warnings = [];
3883
+ if (layers.hair_front === void 0) {
3884
+ for (const role of present) {
3885
+ warnings.push(
3886
+ `${role}: needs hair_front \u2014 the rig refuses a lock without the bangs its root hides under. Remove hair_side.png and recompose (free), or draw hair_front.png. Billed.`
3887
+ );
3888
+ }
3889
+ return warnings;
3890
+ }
3891
+ const ref = layers.hair_front;
3892
+ let mismatched = false;
3893
+ for (const r of [...present, "hair_back", "face"]) {
3894
+ const stats = layers[r];
3895
+ if (stats === void 0) continue;
3896
+ if (stats.canvasW !== ref.canvasW || stats.canvasH !== ref.canvasH) {
3897
+ mismatched = true;
3898
+ warnings.push(
3899
+ `${r}: its canvas ${stats.canvasW}x${stats.canvasH} differs from hair_front's ${ref.canvasW}x${ref.canvasH} \u2014 auto_rig_from_layers refuses layers of different sizes; recompose them together.`
3900
+ );
3901
+ }
3902
+ }
3903
+ if (mismatched) return warnings;
3904
+ const measurer = (0, import_editor6.createLayerSetMeasurer)({
3905
+ width: ref.canvasW,
3906
+ height: ref.canvasH
3907
+ });
3908
+ const read = (role) => layers[role] === void 0 ? void 0 : measured(measurer, absDir, role);
3909
+ const front = await read("hair_front");
3910
+ const back = await read("hair_back");
3911
+ const face = await read("face");
3912
+ const axisX = face ? face.bbox.x + face.bbox.w / 2 : ref.canvasW / 2;
3913
+ const locks = /* @__PURE__ */ new Map();
3914
+ for (const role of present) {
3915
+ const lock = await measured(measurer, absDir, role);
3916
+ locks.set(role, lock);
3917
+ const side = lock.bbox.x + lock.bbox.w / 2 < axisX ? -1 : 1;
3918
+ const eyeRole = ["eye_L", "eye_R"].find(
3919
+ (r) => layers[r] !== void 0 && (layers[r].bboxCx < axisX ? -1 : 1) === side
3920
+ );
3921
+ const eye = eyeRole === void 0 ? void 0 : layers[eyeRole];
3922
+ const root = rootWarning(role, lock, front);
3923
+ if (root !== void 0) warnings.push(root);
3924
+ if (eyeRole !== void 0 && eye !== void 0) {
3925
+ const w = eyeCornerWarning(role, lock, side, eyeRole, eye);
3926
+ if (w !== void 0) warnings.push(w);
3927
+ }
3928
+ const rowEye = eye ?? layers.eye_L ?? layers.eye_R;
3929
+ if (face !== void 0 && rowEye !== void 0) {
3930
+ const w = leanWarning(role, lock, side, face, back, rowEye);
3931
+ if (w !== void 0) warnings.push(w);
3932
+ }
3933
+ }
3934
+ if (drawsTwoLocks(locks.get("hair_side_R") ?? locks.get(present[0]))) {
3935
+ warnings.push(
3936
+ `hair_side.png draws two locks \u2014 draw ONE lock, the screen-left one; the composer mirrors it into hair_side_L. Billed.`
3937
+ );
3938
+ }
3939
+ return warnings;
3940
+ }
3941
+ function rootWarning(role, lock, front) {
3942
+ const y = opaqueRows(lock)?.top;
3943
+ if (y === void 0) return void 0;
3944
+ const frontRuns = runsAt(front, y);
3945
+ const lockRuns = runsAt(lock, y);
3946
+ let shown = 0;
3947
+ for (let i = 0; i + 1 < lockRuns.length; i += 2) {
3948
+ let stretch = 0;
3949
+ for (let x = lockRuns[i]; x <= lockRuns[i + 1]; x++) {
3950
+ if (x < lockRuns[i + 1] && !covers(frontRuns, x)) {
3951
+ stretch++;
3952
+ continue;
3953
+ }
3954
+ if (stretch >= VISIBLE_MIN_PX) shown += stretch;
3955
+ stretch = 0;
3956
+ }
3957
+ }
3958
+ if (shown === 0) return void 0;
3959
+ return `${role}: its top row (canvas y ${y}) shows past hair_front on ${shown} px \u2014 the root is visible at rest. Move it under the bangs \u2014 up (layout.${role}.cy) or toward the face (layout.${role}.cx) (free), or regenerate hair_side.png with a longer hidden root. Billed.`;
3960
+ }
3961
+ function eyeCornerWarning(role, lock, side, eyeRole, eye) {
3962
+ const row = Math.floor(eye.bboxCy);
3963
+ const corner = side < 0 ? eye.marginLeft : eye.marginLeft + eye.w - 1;
3964
+ const runs = runsAt(lock, row);
3965
+ let overlap = 0;
3966
+ for (let i = 0; i + 1 < runs.length; i += 2) {
3967
+ if (corner < runs[i] || corner >= runs[i + 1]) continue;
3968
+ overlap = side < 0 ? runs[i + 1] - corner : corner - runs[i] + 1;
3969
+ }
3970
+ if (overlap < VISIBLE_MIN_PX) return void 0;
3971
+ return `${role}: covers ${eyeRole}'s outer corner at rest (canvas x ${corner}, y ${row}) by ${overlap} px \u2014 the eye's outer tail may only slide under it on the turn. Move layout.${role}.cx ${overlap} px ${side < 0 ? "left" : "right"}, outward (free), or regenerate it narrower. Billed.`;
3972
+ }
3973
+ function leanWarning(role, lock, side, face, back, eye) {
3974
+ const faceRows = opaqueRows(face);
3975
+ const lockRows = opaqueRows(lock);
3976
+ if (faceRows === void 0 || lockRows === void 0) return void 0;
3977
+ const faceBottom = faceRows.bottom;
3978
+ const lean = Math.round(LEAN_HH * (faceBottom - Math.floor(eye.bboxCy)));
3979
+ if (lean < 1) return void 0;
3980
+ const bare = /* @__PURE__ */ new Set();
3981
+ const rows = /* @__PURE__ */ new Set();
3982
+ for (let y = lockRows.top; y <= Math.min(lockRows.bottom, faceBottom); y++) {
3983
+ const runs = runsAt(lock, y);
3984
+ if (runs.length === 0) continue;
3985
+ const from = side < 0 ? runs[0] : runs[runs.length - 2];
3986
+ const to = side < 0 ? runs[1] : runs[runs.length - 1];
3987
+ const start = side < 0 ? from : Math.max(from, to - lean);
3988
+ const end = side < 0 ? Math.min(to, from + lean) : to;
3989
+ const faceRuns = runsAt(face, y);
3990
+ const backRuns = runsAt(back, y);
3991
+ for (let x = start; x < end; x++) {
3992
+ if (covers(faceRuns, x) || covers(backRuns, x)) continue;
3993
+ bare.add(x);
3994
+ rows.add(y);
3995
+ }
3996
+ }
3997
+ if (bare.size === 0) return void 0;
3998
+ const cols = [...bare].sort((a, b) => a - b);
3999
+ const ys = [...rows].sort((a, b) => a - b);
4000
+ const where = `leaves bare pixels spanning columns ${cols[0]}\u2013${cols[cols.length - 1]}, rows ${ys[0]}\u2013${ys[ys.length - 1]}`;
4001
+ const lead = `${role}: when the head turns away from it the lock leans inward about ${lean} px and ${where}, where`;
4002
+ if (back === void 0) {
4003
+ return `${lead} the face is not painted \u2014 draw hair_back.png behind the locks. Billed.`;
4004
+ }
4005
+ return `${lead} neither hair_back nor the face is painted \u2014 widen hair_back there (layout.hair_back.w) (free), or regenerate it fuller behind the locks. Billed.`;
4006
+ }
4007
+ function drawsTwoLocks(lock) {
4008
+ const w = lock.bbox.w;
4009
+ const col = new Array(w).fill(false);
4010
+ for (const runs of lock.rowRuns ?? []) {
4011
+ for (let i = 0; i + 1 < runs.length; i += 2) {
4012
+ for (let x = runs[i]; x < runs[i + 1]; x++) col[x - lock.bbox.x] = true;
4013
+ }
4014
+ }
4015
+ const big = [];
4016
+ let start = -1;
4017
+ for (let x = 0; x <= w; x++) {
4018
+ if (x < w && col[x]) {
4019
+ if (start < 0) start = x;
4020
+ } else if (start >= 0) {
4021
+ if (x - start >= TWO_LOCKS_RUN * w) big.push([start, x]);
4022
+ start = -1;
4023
+ }
4024
+ }
4025
+ for (let i = 1; i < big.length; i++) {
4026
+ if (big[i][0] - big[i - 1][1] >= TWO_LOCKS_GAP * w) return true;
4027
+ }
4028
+ return false;
4029
+ }
4030
+
4031
+ // src/measure-forearm-pose.ts
4032
+ var import_editor7 = require("@ikijs/editor");
3857
4033
  var POSE_ROLES = ["forearm_pose_L", "forearm_pose_R"];
3858
4034
  var ARM_OF = {
3859
4035
  forearm_pose_L: "arm_L",
@@ -3887,7 +4063,7 @@ async function forearmPoseWarnings(absDir, layers) {
3887
4063
  continue;
3888
4064
  }
3889
4065
  if (layers.body === void 0) continue;
3890
- const measurer = (0, import_editor6.createLayerSetMeasurer)({
4066
+ const measurer = (0, import_editor7.createLayerSetMeasurer)({
3891
4067
  width: stats.canvasW,
3892
4068
  height: stats.canvasH
3893
4069
  });
@@ -3895,12 +4071,12 @@ async function forearmPoseWarnings(absDir, layers) {
3895
4071
  let armLayer;
3896
4072
  try {
3897
4073
  armLayer = await measured(measurer, absDir, arm);
3898
- a = (0, import_editor6.armGeometry)(armLayer, arm === "arm_R" ? Infinity : -Infinity);
4074
+ a = (0, import_editor7.armGeometry)(armLayer, arm === "arm_R" ? Infinity : -Infinity);
3899
4075
  } catch (err) {
3900
- if (err instanceof import_editor6.LayerGeometryError) continue;
4076
+ if (err instanceof import_editor7.LayerGeometryError) continue;
3901
4077
  throw err;
3902
4078
  }
3903
- const b = (0, import_editor6.forearmPoseGeometry)(await measured(measurer, absDir, pose));
4079
+ const b = (0, import_editor7.forearmPoseGeometry)(await measured(measurer, absDir, pose));
3904
4080
  warnings.push(...jointWarnings(pose, arm, stats, a, armLayer, b));
3905
4081
  }
3906
4082
  return warnings;
@@ -3940,11 +4116,11 @@ function jointWarnings(pose, arm, stats, a, armLayer, b) {
3940
4116
 
3941
4117
  // src/measure-lips.ts
3942
4118
  var import_node_path7 = __toESM(require("path"));
3943
- var import_editor8 = require("@ikijs/editor");
4119
+ var import_editor9 = require("@ikijs/editor");
3944
4120
 
3945
4121
  // src/compose-lips.ts
3946
4122
  var import_sharp2 = __toESM(require("sharp"));
3947
- var import_editor7 = require("@ikijs/editor");
4123
+ var import_editor8 = require("@ikijs/editor");
3948
4124
  var KEYED_SRC = "mouth_keyed.png";
3949
4125
  var INTERIOR_SRC = "mouth_interior.png";
3950
4126
  var KEY_CANDIDATE = 0.5;
@@ -4042,7 +4218,7 @@ function keyGreen(rgba, W, H) {
4042
4218
  let candidates = 0;
4043
4219
  for (let p = 0; p < n; p++) {
4044
4220
  const i = p * 4;
4045
- if (rgba[i + 3] < import_editor7.ALPHA_OPAQUE) continue;
4221
+ if (rgba[i + 3] < import_editor8.ALPHA_OPAQUE) continue;
4046
4222
  const excess = (rgba[i + 1] - Math.max(rgba[i], rgba[i + 2])) / 255;
4047
4223
  if (excess < KEY_CANDIDATE) continue;
4048
4224
  candidates++;
@@ -4069,7 +4245,7 @@ function keyGreen(rgba, W, H) {
4069
4245
  const dg = rgba[i + 1] - G[1];
4070
4246
  const db = rgba[i + 2] - G[2];
4071
4247
  const green = dr * dr + dg * dg + db * db <= KEY_FILL_DIST * KEY_FILL_DIST;
4072
- if (rgba[i + 3] < import_editor7.ALPHA_OPAQUE) {
4248
+ if (rgba[i + 3] < import_editor8.ALPHA_OPAQUE) {
4073
4249
  if (green) out[i + 3] = 0;
4074
4250
  } else if (green) {
4075
4251
  fill[p] = 1;
@@ -4245,7 +4421,7 @@ async function prepInterior(rgba, W, H) {
4245
4421
  for (let y = box2.y; y < box2.y + box2.h; y++) {
4246
4422
  for (let x = box2.x; x < box2.x + box2.w; x++) {
4247
4423
  const i = (y * cw + x) * 4;
4248
- if (crop[i + 3] < import_editor7.ALPHA_OPAQUE) continue;
4424
+ if (crop[i + 3] < import_editor8.ALPHA_OPAQUE) continue;
4249
4425
  count++;
4250
4426
  for (let c = 0; c < 3; c++) all[c] += crop[i + c];
4251
4427
  if (luma(crop, i) < CAVITY_LUMA) {
@@ -4268,7 +4444,7 @@ function enclosedHole(frame, w, h) {
4268
4444
  const stack = new Int32Array(n);
4269
4445
  let depth = 0;
4270
4446
  const seed = (p) => {
4271
- if (!outside[p] && alpha(p) < import_editor7.ALPHA_OPAQUE) {
4447
+ if (!outside[p] && alpha(p) < import_editor8.ALPHA_OPAQUE) {
4272
4448
  outside[p] = 1;
4273
4449
  stack[depth++] = p;
4274
4450
  }
@@ -4291,7 +4467,7 @@ function enclosedHole(frame, w, h) {
4291
4467
  }
4292
4468
  const mask = new Uint8Array(n);
4293
4469
  for (let p = 0; p < n; p++) {
4294
- if (alpha(p) < import_editor7.ALPHA_OPAQUE && !outside[p]) mask[p] = 1;
4470
+ if (alpha(p) < import_editor8.ALPHA_OPAQUE && !outside[p]) mask[p] = 1;
4295
4471
  }
4296
4472
  const { label, sizes, boxes } = components(mask, w, h);
4297
4473
  const main2 = largest(sizes);
@@ -4318,7 +4494,7 @@ function enclosedHole(frame, w, h) {
4318
4494
  return { label, main: main2, box: box2 };
4319
4495
  }
4320
4496
  function measureLips(layers, w, h) {
4321
- const measurer = (0, import_editor7.createLayerSetMeasurer)({ width: w, height: h });
4497
+ const measurer = (0, import_editor8.createLayerSetMeasurer)({ width: w, height: h });
4322
4498
  return new Map(
4323
4499
  Object.entries(layers).map(([role, rgba]) => [
4324
4500
  role,
@@ -4336,8 +4512,8 @@ function assertFoldContract(layers, w, h) {
4336
4512
  }
4337
4513
  byRole.set(role, layer);
4338
4514
  }
4339
- const opening = (0, import_editor7.mouthOpening)(byRole);
4340
- const runs = (0, import_editor7.columnRuns)(byRole.get("mouth_inner"));
4515
+ const opening = (0, import_editor8.mouthOpening)(byRole);
4516
+ const runs = (0, import_editor8.columnRuns)(byRole.get("mouth_inner"));
4341
4517
  for (let col = opening.x0; col <= opening.x1; col++) {
4342
4518
  const c = opening.at(col);
4343
4519
  const why = !runs.has(col) ? "has no interior run" : c.Tu > c.T ? `has a gap between the line and the interior (Tu ${c.Tu} > T ${c.T})` : c.T > c.lineTop || c.lineH <= 0 ? `has no line above the interior (T ${c.T}, line top ${c.lineTop})` : c.Bl < c.Bb ? `has a gap between the interior and the skin (Bl ${c.Bl} < Bb ${c.Bb})` : null;
@@ -4367,18 +4543,18 @@ async function splitLipSet(keyedPng, w, h, interior) {
4367
4543
  }
4368
4544
  const centre = Math.round((hb.x0 + hb.x1) / 2);
4369
4545
  let stroke = 0;
4370
- while (top[centre] - 1 - stroke >= 0 && alpha((top[centre] - 1 - stroke) * w + centre) >= import_editor7.ALPHA_OPAQUE)
4546
+ while (top[centre] - 1 - stroke >= 0 && alpha((top[centre] - 1 - stroke) * w + centre) >= import_editor8.ALPHA_OPAQUE)
4371
4547
  stroke++;
4372
4548
  const bandCap = BAND_CAP * Math.max(1, stroke);
4373
4549
  const skinRow = new Int32Array(w).fill(-1);
4374
4550
  const inM = new Uint8Array(n);
4375
4551
  for (let x = hb.x0; x <= hb.x1; x++) {
4376
4552
  let y = bot[x];
4377
- while (y < h && y - bot[x] < bandCap && alpha(y * w + x) >= import_editor7.ALPHA_OPAQUE && luma(frame, (y * w + x) * 4) < BAND_LUMA)
4553
+ while (y < h && y - bot[x] < bandCap && alpha(y * w + x) >= import_editor8.ALPHA_OPAQUE && luma(frame, (y * w + x) * 4) < BAND_LUMA)
4378
4554
  y++;
4379
4555
  for (let k = top[x]; k < y; k++) inM[k * w + x] = 1;
4380
4556
  let r = y;
4381
- while (r < h && alpha(r * w + x) < import_editor7.ALPHA_OPAQUE) r++;
4557
+ while (r < h && alpha(r * w + x) < import_editor8.ALPHA_OPAQUE) r++;
4382
4558
  if (r < h) {
4383
4559
  skinRow[x] = r;
4384
4560
  inM[r * w + x] = 1;
@@ -4388,7 +4564,7 @@ async function splitLipSet(keyedPng, w, h, interior) {
4388
4564
  for (let y = 0; y < h; y++) {
4389
4565
  for (let x = 0; x < w; x++) {
4390
4566
  const p = y * w + x;
4391
- if (inM[p] || alpha(p) < import_editor7.ALPHA_OPAQUE) continue;
4567
+ if (inM[p] || alpha(p) < import_editor8.ALPHA_OPAQUE) continue;
4392
4568
  if (top[x] >= 0 && y < top[x]) continue;
4393
4569
  if (x > 0 && inM[p - 1] || x < w - 1 && inM[p + 1]) grown[p] = 1;
4394
4570
  }
@@ -4398,7 +4574,7 @@ async function splitLipSet(keyedPng, w, h, interior) {
4398
4574
  if (x < 0 || x >= w) continue;
4399
4575
  let first = 0;
4400
4576
  while (first < h && !(grown[first * w + x] && !inM[first * w + x])) first++;
4401
- if (first > 0 && first < h && alpha((first - 1) * w + x) >= import_editor7.ALPHA_OPAQUE)
4577
+ if (first > 0 && first < h && alpha((first - 1) * w + x) >= import_editor8.ALPHA_OPAQUE)
4402
4578
  wall[x] = 1;
4403
4579
  }
4404
4580
  const gx = hb.x0 - 1;
@@ -4425,7 +4601,7 @@ async function splitLipSet(keyedPng, w, h, interior) {
4425
4601
  if (inOpening && skinRow[x] >= 0 && y >= skinRow[x]) copy(lower, p);
4426
4602
  if (!grown[p]) {
4427
4603
  const a = alpha(p);
4428
- if (a >= import_editor7.ALPHA_OPAQUE && a < 255 && besideHole(p, x, y)) {
4604
+ if (a >= import_editor8.ALPHA_OPAQUE && a < 255 && besideHole(p, x, y)) {
4429
4605
  inner.set(interior.cavity, p * 4);
4430
4606
  inner[p * 4 + 3] = 255 - a;
4431
4607
  }
@@ -4490,7 +4666,7 @@ async function restShiftOf(layers, width, height) {
4490
4666
  }
4491
4667
  byRole.set(role, layer);
4492
4668
  }
4493
- return (0, import_editor7.mouthRestShift)(byRole);
4669
+ return (0, import_editor8.mouthRestShift)(byRole);
4494
4670
  }
4495
4671
  async function closedLips(upper, lower, shift, left, top) {
4496
4672
  const shut = async (png, role) => {
@@ -4540,7 +4716,7 @@ async function closedLips(upper, lower, shift, left, top) {
4540
4716
  }
4541
4717
 
4542
4718
  // src/measure-lips.ts
4543
- var isLipLayerRole = (role) => import_editor8.LIP_ROLES.includes(role) || (0, import_editor8.isLipInsideRole)(role);
4719
+ var isLipLayerRole = (role) => import_editor9.LIP_ROLES.includes(role) || (0, import_editor9.isLipInsideRole)(role);
4544
4720
  var MIN_OPENING_ROWS = 8;
4545
4721
  var MIN_LINE_ROWS = 2;
4546
4722
  var GREEN_EXCESS = 40;
@@ -4548,8 +4724,8 @@ var INTERIOR_GAP_FRACTION = 0.05;
4548
4724
  var columns = (cols) => `${cols.length} column${cols.length === 1 ? "" : "s"} (first at x=${cols[0]})`;
4549
4725
  async function lipWarnings(absDir, layers) {
4550
4726
  const warnings = [];
4551
- const present = import_editor8.LIP_ROLES.filter((role) => layers[role] !== void 0);
4552
- const inside = import_editor8.LIP_INSIDE_ROLES.filter((role) => layers[role] !== void 0);
4727
+ const present = import_editor9.LIP_ROLES.filter((role) => layers[role] !== void 0);
4728
+ const inside = import_editor9.LIP_INSIDE_ROLES.filter((role) => layers[role] !== void 0);
4553
4729
  if (present.length === 0) {
4554
4730
  if (inside.length > 0) {
4555
4731
  warnings.push(
@@ -4566,8 +4742,8 @@ async function lipWarnings(absDir, layers) {
4566
4742
  `${present.join("/")}: the lip set cannot be mixed with ${legacy.join("/")} \u2014 auto_rig_from_layers refuses it. Remove one route: compose again with only mouth_keyed.png + mouth_interior.png, or without them.`
4567
4743
  );
4568
4744
  }
4569
- if (present.length < import_editor8.LIP_ROLES.length) {
4570
- const missing = import_editor8.LIP_ROLES.filter((role) => layers[role] === void 0);
4745
+ if (present.length < import_editor9.LIP_ROLES.length) {
4746
+ const missing = import_editor9.LIP_ROLES.filter((role) => layers[role] === void 0);
4571
4747
  warnings.push(
4572
4748
  `${present.join("/")}: partial lip set, missing ${missing.join("/")} \u2014 auto_rig_from_layers refuses it. Compose mouth_keyed.png + mouth_interior.png together, which cuts all three.`
4573
4749
  );
@@ -4598,18 +4774,18 @@ async function lipWarnings(absDir, layers) {
4598
4774
  );
4599
4775
  }
4600
4776
  }
4601
- const measurer = (0, import_editor8.createLayerSetMeasurer)({
4777
+ const measurer = (0, import_editor9.createLayerSetMeasurer)({
4602
4778
  width: inner.canvasW,
4603
4779
  height: inner.canvasH
4604
4780
  });
4605
4781
  const set = /* @__PURE__ */ new Map();
4606
4782
  const green = [];
4607
- for (const role of import_editor8.LIP_ROLES) {
4783
+ for (const role of import_editor9.LIP_ROLES) {
4608
4784
  const fileName = `${role}.png`;
4609
4785
  const { rgba } = await decodePng(import_node_path7.default.join(absDir, fileName));
4610
4786
  set.set(role, measurer.add({ role, fileName, rgba }));
4611
4787
  for (let i = 0; i < rgba.length; i += 4) {
4612
- if (rgba[i + 3] >= import_editor8.ALPHA_OPAQUE && rgba[i + 1] - Math.max(rgba[i], rgba[i + 2]) > GREEN_EXCESS) {
4788
+ if (rgba[i + 3] >= import_editor9.ALPHA_OPAQUE && rgba[i + 1] - Math.max(rgba[i], rgba[i + 2]) > GREEN_EXCESS) {
4613
4789
  green.push(role);
4614
4790
  break;
4615
4791
  }
@@ -4617,15 +4793,15 @@ async function lipWarnings(absDir, layers) {
4617
4793
  }
4618
4794
  let opening;
4619
4795
  try {
4620
- opening = (0, import_editor8.mouthOpening)(set);
4796
+ opening = (0, import_editor9.mouthOpening)(set);
4621
4797
  } catch (err) {
4622
- if (err instanceof import_editor8.LayerGeometryError) {
4798
+ if (err instanceof import_editor9.LayerGeometryError) {
4623
4799
  warnings.push(err.message);
4624
4800
  return { warnings };
4625
4801
  }
4626
4802
  throw err;
4627
4803
  }
4628
- const innerRuns = (0, import_editor8.columnRuns)(set.get("mouth_inner"));
4804
+ const innerRuns = (0, import_editor9.columnRuns)(set.get("mouth_inner"));
4629
4805
  const noInterior = [];
4630
4806
  const gap = [];
4631
4807
  const noLine = [];
@@ -4711,8 +4887,8 @@ async function lipWarnings(absDir, layers) {
4711
4887
 
4712
4888
  // src/measure-turn.ts
4713
4889
  var import_node_path8 = __toESM(require("path"));
4714
- var import_editor9 = require("@ikijs/editor");
4715
4890
  var import_editor10 = require("@ikijs/editor");
4891
+ var import_editor11 = require("@ikijs/editor");
4716
4892
  var DEFAULT_IRIS = { hueMin: 230, hueMax: 300, satMin: 0.22 };
4717
4893
  var IRIS_V_MIN = 0.18;
4718
4894
  var IRIS_V_MAX = 0.95;
@@ -4862,7 +5038,7 @@ async function measureTurnImage(filePath, iris) {
4862
5038
  let transparent = false;
4863
5039
  if (hasAlpha) {
4864
5040
  for (let i = 0; i < n; i++) {
4865
- if (rgba[i * 4 + 3] < import_editor9.ALPHA_OPAQUE) {
5041
+ if (rgba[i * 4 + 3] < import_editor10.ALPHA_OPAQUE) {
4866
5042
  transparent = true;
4867
5043
  break;
4868
5044
  }
@@ -4873,7 +5049,7 @@ async function measureTurnImage(filePath, iris) {
4873
5049
  const fg = new Uint8Array(n);
4874
5050
  const value = new Float32Array(n);
4875
5051
  for (let i = 0; i < n; i++) {
4876
- if (rgba[i * 4 + 3] < import_editor9.ALPHA_OPAQUE) continue;
5052
+ if (rgba[i * 4 + 3] < import_editor10.ALPHA_OPAQUE) continue;
4877
5053
  const [hue, s, v] = rgbToHsv(rgba[i * 4], rgba[i * 4 + 1], rgba[i * 4 + 2]);
4878
5054
  if (maskMode === "alpha") {
4879
5055
  fg[i] = 1;
@@ -4939,12 +5115,12 @@ async function measureTurnImage(filePath, iris) {
4939
5115
  }
4940
5116
  const [irisL, irisR] = best.pair;
4941
5117
  const eyeRow = Math.round((irisL.cy + irisR.cy) / 2);
4942
- const { left, right } = (0, import_editor9.foregroundSpan)(
5118
+ const { left, right } = (0, import_editor10.foregroundSpan)(
4943
5119
  fg,
4944
5120
  width,
4945
5121
  height,
4946
- eyeRow - import_editor9.HEAD_BAND,
4947
- eyeRow + import_editor9.HEAD_BAND
5122
+ eyeRow - import_editor10.HEAD_BAND,
5123
+ eyeRow + import_editor10.HEAD_BAND
4948
5124
  );
4949
5125
  if (right <= left) {
4950
5126
  throw new AutoRigInputError(
@@ -4968,7 +5144,7 @@ async function measureTurnImage(filePath, iris) {
4968
5144
  left,
4969
5145
  right,
4970
5146
  cx: (left + right) / 2,
4971
- half: (0, import_editor9.headHalfOf)({ left, right })
5147
+ half: (0, import_editor10.headHalfOf)({ left, right })
4972
5148
  },
4973
5149
  pairCx: (irisL.cx + irisR.cx) / 2,
4974
5150
  eyeGap: irisR.cx - irisL.cx
@@ -5159,7 +5335,7 @@ function noseSpeckWarning({ core, part }, source) {
5159
5335
  `the layer's dense core is ${core.w}x${core.h} in its ${part.w}x${part.h} crop`,
5160
5336
  `auto_rig_from_layers turns and tilts the nose about its whole crop instead`
5161
5337
  ];
5162
- return `nose: ${found} \u2014 under ${import_editor10.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.`;
5338
+ return `nose: ${found} \u2014 under ${import_editor11.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.`;
5163
5339
  }
5164
5340
  async function lashOffSclera(eyePath, lashPath) {
5165
5341
  const eye = await decodePng(eyePath);
@@ -5240,6 +5416,7 @@ async function measureDir(absDir, noseSpeck) {
5240
5416
  warnings.push(...await forearmPoseWarnings(absDir, layers));
5241
5417
  const lip = await lipWarnings(absDir, layers);
5242
5418
  warnings.push(...lip.warnings);
5419
+ warnings.push(...await hairSideWarnings(absDir, layers));
5243
5420
  for (const side of ["L", "R"]) {
5244
5421
  const eye = layers[`eye_${side}`];
5245
5422
  const iris = layers[`iris_${side}`];
@@ -5296,10 +5473,10 @@ async function measureDir(absDir, noseSpeck) {
5296
5473
  warnings.push(noseSpeckWarning(noseSpeck, "compose"));
5297
5474
  } else if (layers.nose !== void 0) {
5298
5475
  const nose = await decodePng(import_node_path9.default.join(absDir, "nose.png"));
5299
- const core = (0, import_editor10.denseCoreOf)(nose.rgba, nose.width, nose.height);
5476
+ const core = (0, import_editor11.denseCoreOf)(nose.rgba, nose.width, nose.height);
5300
5477
  if (core !== null) {
5301
5478
  const crop = detectAlphaBbox(nose.rgba, nose.width, nose.height);
5302
- if ((0, import_editor10.isSpeckCore)(core, crop))
5479
+ if ((0, import_editor11.isSpeckCore)(core, crop))
5303
5480
  warnings.push(noseSpeckWarning({ core, part: crop }, "layer"));
5304
5481
  }
5305
5482
  }
@@ -5370,12 +5547,12 @@ function formatMeasureReport(result) {
5370
5547
 
5371
5548
  // src/compose-arms.ts
5372
5549
  var import_sharp3 = __toESM(require("sharp"));
5373
- var import_editor11 = require("@ikijs/editor");
5550
+ var import_editor12 = require("@ikijs/editor");
5374
5551
  var ARM_WIDTH = 0.4;
5375
5552
  var SHOULDER_DROP = 0.12;
5376
5553
  async function armPlacement(role, cfg, part, body) {
5377
5554
  const { data } = await (0, import_sharp3.default)(part.buf).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
5378
- const layer = (0, import_editor11.createLayerSetMeasurer)({ width: part.w, height: part.h }).add({
5555
+ const layer = (0, import_editor12.createLayerSetMeasurer)({ width: part.w, height: part.h }).add({
5379
5556
  role,
5380
5557
  fileName: "arm.png",
5381
5558
  rgba: data
@@ -5387,9 +5564,9 @@ async function armPlacement(role, cfg, part, body) {
5387
5564
  }
5388
5565
  let g;
5389
5566
  try {
5390
- g = (0, import_editor11.armGeometry)(layer, role === "arm_R" ? Infinity : -Infinity);
5567
+ g = (0, import_editor12.armGeometry)(layer, role === "arm_R" ? Infinity : -Infinity);
5391
5568
  } catch (err) {
5392
- if (err instanceof import_editor11.LayerGeometryError) {
5569
+ if (err instanceof import_editor12.LayerGeometryError) {
5393
5570
  throw new AutoRigInputError(`layout.${role}: ${err.message}`);
5394
5571
  }
5395
5572
  throw err;
@@ -5416,7 +5593,7 @@ async function armPlacement(role, cfg, part, body) {
5416
5593
  }
5417
5594
  async function poseGeometryOf(role, png, size, when) {
5418
5595
  const { data } = await (0, import_sharp3.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
5419
- const layer = (0, import_editor11.createLayerSetMeasurer)({
5596
+ const layer = (0, import_editor12.createLayerSetMeasurer)({
5420
5597
  width: size.w,
5421
5598
  height: size.h
5422
5599
  }).add({ role, fileName: "forearm_pose.png", rgba: data });
@@ -5425,7 +5602,7 @@ async function poseGeometryOf(role, png, size, when) {
5425
5602
  `layout.${role}: forearm_pose.png is empty after alpha threshold${when}`
5426
5603
  );
5427
5604
  }
5428
- return (0, import_editor11.forearmPoseGeometry)(layer);
5605
+ return (0, import_editor12.forearmPoseGeometry)(layer);
5429
5606
  }
5430
5607
  async function forearmPoseWidth(role, trimmed, elbowRun) {
5431
5608
  const g = await poseGeometryOf(role, trimmed.data, trimmed, "");
@@ -5542,6 +5719,23 @@ var DEFAULT_LAYOUT = {
5542
5719
  // prettier-ignore
5543
5720
  brow_L: { src: "brow.png", cx: 645, cy: 405, w: 105, mirror: false },
5544
5721
  brow_R: { src: "brow.png", cx: 455, cy: 405, w: 105, mirror: true },
5722
+ // The front side locks, one part for both: hair_side_R (screen left) takes
5723
+ // hair_side.png as drawn and hair_side_L mirrors it, like the blush. They
5724
+ // draw over the face, brows and lashes and under the bangs. Mint's tuned
5725
+ // placement (cy 545 at mint's face cy 431, carried to the default face:
5726
+ // 437 + 114 = 551), tuned per character through `layout.hair_side_*`: the
5727
+ // lock's root top lies above the brow row (405) so the bangs' temple hides it
5728
+ // (for a 1:5 lock, whose height follows the image's aspect: w 90 is 450 tall,
5729
+ // so cy 551 puts the top at 326), and the lock runs from the temple over the
5730
+ // front of the ear and down along the cheek's edge, the ear's rim and lobe
5731
+ // showing beside it. Its box overlaps the eye's by about 15 px at the
5732
+ // default face, fine only because a drawn lock's root tapers (the measure's "covers
5733
+ // the eye's outer corner" check catches a lock that does not).
5734
+ // OPTIONAL: a parts dir without it composes.
5735
+ hair_side_L: { src: "hair_side.png", cx: 715, cy: 551, w: 90, optional: true, mirror: true },
5736
+ // prettier-ignore
5737
+ hair_side_R: { src: "hair_side.png", cx: 385, cy: 551, w: 90, optional: true, mirror: false },
5738
+ // prettier-ignore
5545
5739
  hair_front: { src: "hair_front.png", cx: 550, cy: 425, w: 660 },
5546
5740
  // The pose forearms, one drawing for both: forearm_pose_R (screen left)
5547
5741
  // takes forearm_pose.png as drawn and forearm_pose_L mirrors it, like the
@@ -5580,6 +5774,8 @@ var ORDER = [
5580
5774
  "lash_R",
5581
5775
  "brow_L",
5582
5776
  "brow_R",
5777
+ "hair_side_L",
5778
+ "hair_side_R",
5583
5779
  "hair_front",
5584
5780
  "forearm_pose_L",
5585
5781
  "forearm_pose_R"
@@ -5604,7 +5800,9 @@ var FACE_FEATURES = [
5604
5800
  "lash_L",
5605
5801
  "lash_R",
5606
5802
  "brow_L",
5607
- "brow_R"
5803
+ "brow_R",
5804
+ "hair_side_L",
5805
+ "hair_side_R"
5608
5806
  ];
5609
5807
  function resolveLayout(overrides, canvas) {
5610
5808
  const resolved = { ...DEFAULT_LAYOUT };
@@ -5702,18 +5900,18 @@ function keyWhiteToAlpha(rgba) {
5702
5900
  async function coreAndBoundsOf(png) {
5703
5901
  const { data, info } = await (0, import_sharp4.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
5704
5902
  return {
5705
- core: (0, import_editor10.denseCoreOf)(data, info.width, info.height),
5903
+ core: (0, import_editor11.denseCoreOf)(data, info.width, info.height),
5706
5904
  bounds: { x: 0, y: 0, w: info.width, h: info.height }
5707
5905
  };
5708
5906
  }
5709
5907
  async function hasCoverage(png) {
5710
5908
  const { data, info } = await (0, import_sharp4.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
5711
- return (0, import_editor12.detectAlphaBbox)(data, info.width, info.height) !== null;
5909
+ return (0, import_editor13.detectAlphaBbox)(data, info.width, info.height) !== null;
5712
5910
  }
5713
5911
  async function noseSizingOf(png) {
5714
5912
  const { core, bounds } = await coreAndBoundsOf(png);
5715
5913
  if (core === null) return { box: bounds, whole: true };
5716
- if ((0, import_editor10.isSpeckCore)(core, bounds)) {
5914
+ if ((0, import_editor11.isSpeckCore)(core, bounds)) {
5717
5915
  return {
5718
5916
  box: bounds,
5719
5917
  whole: true,
@@ -5835,7 +6033,7 @@ function detachedAboveWhite(rgba, W, H) {
5835
6033
  for (let p = 0; p < n; p++) {
5836
6034
  const alpha = rgba[p * 4 + 3];
5837
6035
  if (alpha > 0 && luma(rgba, p * 4) >= EYE_LASH_LUMA)
5838
- ink[p] = alpha >= import_editor12.ALPHA_OPAQUE ? 2 : 1;
6036
+ ink[p] = alpha >= import_editor13.ALPHA_OPAQUE ? 2 : 1;
5839
6037
  }
5840
6038
  const label = new Int32Array(n).fill(-1);
5841
6039
  const stack = new Int32Array(n);
@@ -5940,7 +6138,7 @@ async function prepEyeSplit(partsDir) {
5940
6138
  const lashCutoffY = minY + LASH_KEEP_FRACTION * (maxY - minY + 1);
5941
6139
  const detached = detachedAboveWhite(data, W, H);
5942
6140
  const isDark = (i) => data[i + 3] > 0 && luma(data, i) < EYE_LASH_LUMA;
5943
- const isLight = (i) => data[i + 3] >= import_editor12.ALPHA_OPAQUE && luma(data, i) >= EYE_LASH_LUMA;
6141
+ const isLight = (i) => data[i + 3] >= import_editor13.ALPHA_OPAQUE && luma(data, i) >= EYE_LASH_LUMA;
5944
6142
  const isWarm = (i) => data[i] - data[i + 2] >= EYE_LID_WARMTH;
5945
6143
  const whiteTop = new Int32Array(W).fill(-1);
5946
6144
  for (let x = 0; x < W; x++) {
@@ -6110,7 +6308,7 @@ async function composeLayersFromParts(input) {
6110
6308
  lip_lower: split2.lower,
6111
6309
  lip_upper: split2.upper
6112
6310
  }[role];
6113
- if ((0, import_editor12.isLipInsideRole)(role) && !await hasCoverage(buf)) {
6311
+ if ((0, import_editor13.isLipInsideRole)(role) && !await hasCoverage(buf)) {
6114
6312
  skipped.push(role);
6115
6313
  continue;
6116
6314
  }
@@ -6305,7 +6503,7 @@ async function composeLayersFromParts(input) {
6305
6503
  });
6306
6504
  }
6307
6505
  const restInput = (role, buf) => {
6308
- if (role === "mouth_inner" || (0, import_editor12.isLipInsideRole)(role)) return null;
6506
+ if (role === "mouth_inner" || (0, import_editor13.isLipInsideRole)(role)) return null;
6309
6507
  if (closed === void 0) return buf;
6310
6508
  if (role === "lip_upper") return closed.upper;
6311
6509
  if (role === "lip_lower") return closed.lower;
@@ -6372,6 +6570,40 @@ async function composeLayersFromParts(input) {
6372
6570
  }
6373
6571
  }
6374
6572
 
6573
+ // src/hair-side-report.ts
6574
+ function signedPx(px2) {
6575
+ const s = px2.toFixed(1);
6576
+ if (s === "-0.0") return "+0.0";
6577
+ return s.startsWith("-") ? s : `+${s}`;
6578
+ }
6579
+ function formatHairSideReport(hairSide, canvas) {
6580
+ if (hairSide === void 0) return [];
6581
+ return [hairSide.left, hairSide.right].flatMap(
6582
+ (room) => room === void 0 ? [] : roomLines(room, canvas)
6583
+ );
6584
+ }
6585
+ function roomLines(room, canvas) {
6586
+ const { role, cover, tail, unavailable } = room;
6587
+ if (unavailable !== void 0) {
6588
+ return [`HAIRSIDE ${role}: unavailable \u2014 ${unavailable}`];
6589
+ }
6590
+ const lines = [];
6591
+ if (cover !== void 0) {
6592
+ const row = Math.floor(canvas.height / 2 - cover.y);
6593
+ lines.push(
6594
+ `HAIRSIDE cover ${role}: the lock's outer edge ${signedPx(cover.px)} model px outside the head's edge at ParamAngleX=${cover.deg}, ${signedPx(cover.rest)} at rest (least over the rows it covers at rest, at model y ${cover.y.toFixed(1)}, row ${row} model px from the top; negative: the turn bares cheek the lock hides at rest)`
6595
+ );
6596
+ }
6597
+ if (tail !== void 0) {
6598
+ const lash = tail.lashToLock === void 0 ? "" : ` / lash ${signedPx(tail.lashToLock)} model px`;
6599
+ lines.push(
6600
+ `HAIRSIDE tail ${role}: eye ${signedPx(tail.eyeToLock)} model px${lash} from the lock's face-side edge at ParamAngleX=${tail.deg} (negative: under the lock, intended), corner ${signedPx(tail.eyeToPlate)} model px from the head's edge (positive: inside it; negative: past it)`
6601
+ );
6602
+ }
6603
+ if (lines.length === 0) lines.push(`HAIRSIDE ${role}: no cover or tail row`);
6604
+ return lines;
6605
+ }
6606
+
6375
6607
  // src/physics-report.ts
6376
6608
  function formatPhysicsReport(report) {
6377
6609
  if (report.targets.length === 0) return ["PHYSICS: no rigs"];
@@ -6397,7 +6629,7 @@ function formatPatchReports(reports) {
6397
6629
  });
6398
6630
  }
6399
6631
  function createIkiMcpServer() {
6400
- const server = new import_mcp.McpServer({ name: "iki", version: "0.32.0" });
6632
+ const server = new import_mcp.McpServer({ name: "iki", version: "0.33.1" });
6401
6633
  server.registerTool(
6402
6634
  "validate_iki",
6403
6635
  {
@@ -6489,7 +6721,7 @@ function createIkiMcpServer() {
6489
6721
  server.registerTool(
6490
6722
  "auto_rig_from_layers",
6491
6723
  {
6492
- description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R and either mouth or the lip set (mouth_inner + lip_lower + lip_upper, a mouth that folds open instead of crossfading) required; iris_L/R, brow_L/R, hair_front, body, arm_L/arm_R, forearm_pose_L/forearm_pose_R, mouth_tongue/mouth_teeth (only with the lip set: drawn under its lips and clipped to mouth_inner), etc. optional; an arm needs the body, a pose forearm needs its arm, and a partial lip set, one mixed with mouth/mouth_open, or mouth_tongue/mouth_teeth without it is refused) 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. The result's `folds` is the written rig's fold report, printed after the path the way render_poses prints it, and report-only: a fold never refuses the rig. The `RIGPLAN:` line (the result's `rigPlan`: `effective`, `clamped`, `overriddenBy`) follows the path and precedes the `PATCH` lines. The `PHYSICS` lines follow the fold report (the result's `physics`), one per physics rig output \u2014 a spring's, or each chain segment's \u2014 reading ok, frozen or unstable with the step and idle amplitudes, or `PHYSICS: no rigs`; report-only too. `patches` (see its field) adds displacements to existing keyform stops of the freshly generated rig; each op then prints one line between the path and the fold report \u2014 `PATCH <i> <target> at <Param=v \u2026>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px`, with `(vertices)` in place of the columns and rows for a mesh part \u2014 and the result's `patches` carries the same reports (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`), present whenever `patches` was passed, `[]` included. An op the input schema accepts but the rig refuses comes back as `INVALID: patches[i]\u2026` and nothing is written; an op with a missing field or a field of the wrong type is the SDK's input validation error.",
6724
+ description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R and either mouth or the lip set (mouth_inner + lip_lower + lip_upper, a mouth that folds open instead of crossfading) required; iris_L/R, brow_L/R, hair_front, body, arm_L/arm_R, forearm_pose_L/forearm_pose_R, hair_side_L/hair_side_R, mouth_tongue/mouth_teeth (only with the lip set: drawn under its lips and clipped to mouth_inner), etc. optional; an arm needs the body, a pose forearm needs its arm, a side lock needs hair_front, and a partial lip set, one mixed with mouth/mouth_open, or mouth_tongue/mouth_teeth without it is refused) 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. The result's `folds` is the written rig's fold report, printed after the path the way render_poses prints it, and report-only: a fold never refuses the rig. The `RIGPLAN:` line (the result's `rigPlan`: `effective`, `clamped`, `overriddenBy`) follows the path and precedes the `PATCH` lines. The `PHYSICS` lines follow the fold report (the result's `physics`), one per physics rig output \u2014 a spring's, or each chain segment's \u2014 reading ok, frozen or unstable with the step and idle amplitudes, or `PHYSICS: no rigs`; report-only too. With side locks and a `nose` (which `turn` needs) the `HAIRSIDE` lines follow the `PHYSICS` lines (the result's `turn.hairSide`), each naming the lock's role, report-only as well. `patches` (see its field) adds displacements to existing keyform stops of the freshly generated rig; each op then prints one line between the path and the fold report \u2014 `PATCH <i> <target> at <Param=v \u2026>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px`, with `(vertices)` in place of the columns and rows for a mesh part \u2014 and the result's `patches` carries the same reports (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`), present whenever `patches` was passed, `[]` included. An op the input schema accepts but the rig refuses comes back as `INVALID: patches[i]\u2026` and nothing is written; an op with a missing field or a field of the wrong type is the SDK's input validation error.",
6493
6725
  inputSchema: {
6494
6726
  layers: import_zod.z.array(
6495
6727
  import_zod.z.object({
@@ -6566,7 +6798,8 @@ function createIkiMcpServer() {
6566
6798
  formatRigPlanReport(r.rigPlan),
6567
6799
  ...formatPatchReports(r.patches ?? []),
6568
6800
  ...formatFoldReport(r.folds, r.canvas),
6569
- ...formatPhysicsReport(r.physics)
6801
+ ...formatPhysicsReport(r.physics),
6802
+ ...formatHairSideReport(r.turn?.hairSide, r.canvas)
6570
6803
  ].join("\n") : `INVALID: ${r.error}`;
6571
6804
  return { content: [{ type: "text", text }], structuredContent: r };
6572
6805
  } catch (err) {
@@ -6582,7 +6815,7 @@ function createIkiMcpServer() {
6582
6815
  server.registerTool(
6583
6816
  "compose_layers_from_parts",
6584
6817
  {
6585
- 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, eyewhite, iris, brow, hair_front are required, with mouth.png \u2014 or the lip set's mouth_keyed.png (the open mouth, its inside painted flat #00FF00) + mouth_interior.png (the cavity, teeth and tongue alone), which the composer keys and splits into mouth_inner / lip_lower / lip_upper on one frame so auto_rig_from_layers folds the mouth open like the eyelid, the interior's light paint (luma 100 and over) written as mouth_tongue and mouth_teeth on the same frame, riding the opening's bottom and the upper line and clipped to the cavity (listed in `skipped` when the interior has none); the two routes cannot be mixed, one keyed file without the other is refused, and a key that fails (no green, green outside the opening, an outline not closed round it, more than one opening, no skin under the opening, an interior that is only lips, or one drawn opaque on a non-white or noisy ground) is refused naming the regeneration; with the lip set neither mouth nor mouth_open is written and preview.png shows the mouth closed, as the rig draws the rest pose. hair_back, body, mouth_open (legacy route only), 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`). One forearm_pose.png \u2014 the arm's forearm raised, on the screen LEFT, standing up from its elbow with the hand at the top \u2014 makes both pose forearms (forearm_pose_R as drawn, forearm_pose_L mirrored): each is scaled so its elbow end is as wide as its arm's elbow run and pinned on that arm's elbow (see `layout`), and it needs arm.png. With one, preview-pose.png shows the switch at 1 as the rig draws it (the hanging forearms hidden below the elbow, the pose forearms over everything) while preview.png stays the rest pose; without one it is removed. 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, an arm whose shoulder cap does not reach under the torso's edge, and a pose forearm without its arm or off its arm's elbow in pivot, width or length. 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`.",
6818
+ 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, eyewhite, iris, brow, hair_front are required, with mouth.png \u2014 or the lip set's mouth_keyed.png (the open mouth, its inside painted flat #00FF00) + mouth_interior.png (the cavity, teeth and tongue alone), which the composer keys and splits into mouth_inner / lip_lower / lip_upper on one frame so auto_rig_from_layers folds the mouth open like the eyelid, the interior's light paint (luma 100 and over) written as mouth_tongue and mouth_teeth on the same frame, riding the opening's bottom and the upper line and clipped to the cavity (listed in `skipped` when the interior has none); the two routes cannot be mixed, one keyed file without the other is refused, and a key that fails (no green, green outside the opening, an outline not closed round it, more than one opening, no skin under the opening, an interior that is only lips, or one drawn opaque on a non-white or noisy ground) is refused naming the regeneration; with the lip set neither mouth nor mouth_open is written and preview.png shows the mouth closed, as the rig draws the rest pose. hair_back, body, mouth_open (legacy route only), blush (one blush.png makes the blush_L/blush_R pair), hair_side (one hair_side.png makes the hair_side_L/hair_side_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). The hair_side.png is the front side lock on the screen LEFT, hanging beside the ear with its root at the image's top: hair_side_R is as drawn and hair_side_L mirrored, both drawn over the face, brows and lashes and under hair_front, and without the file both are listed in `skipped`. 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`). One forearm_pose.png \u2014 the arm's forearm raised, on the screen LEFT, standing up from its elbow with the hand at the top \u2014 makes both pose forearms (forearm_pose_R as drawn, forearm_pose_L mirrored): each is scaled so its elbow end is as wide as its arm's elbow run and pinned on that arm's elbow (see `layout`), and it needs arm.png. With one, preview-pose.png shows the switch at 1 as the rig draws it (the hanging forearms hidden below the elbow, the pose forearms over everything) while preview.png stays the rest pose; without one it is removed. 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, an arm whose shoulder cap does not reach under the torso's edge, and a pose forearm without its arm or off its arm's elbow in pivot, width or length. 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`.",
6586
6819
  inputSchema: {
6587
6820
  partsDir: import_zod.z.string().describe(
6588
6821
  "Directory of the source part PNGs (resolved against cwd)."
@@ -6599,10 +6832,10 @@ function createIkiMcpServer() {
6599
6832
  h: import_zod.z.number()
6600
6833
  }).partial()
6601
6834
  ).optional().describe(
6602
- "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, mouth_inner, eye_L, eye_R, iris_L, iris_R, lash_L, lash_R, brow_L, brow_R, hair_front, forearm_pose_L, forearm_pose_R \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, mouth_inner, 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. mouth_inner is the lip set's one frame (mouth_open's place by default; lip_lower, lip_upper, mouth_tongue and mouth_teeth have no key and land on it, so a retune moves them together), and with the lip set the nose's tip rule reads layout.mouth_inner.cy. 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. forearm_pose_L/forearm_pose_R have no cx/cy/w defaults either: an unset `w` scales the forearm so its elbow end (the shoulder rule run from its bottom) is as wide as the placed arm's elbow run, and an unset `cx` or `cy` pins that elbow end's pivot on the arm's elbow \u2014 the one auto_rig_from_layers hangs it from."
6835
+ "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, mouth_inner, eye_L, eye_R, iris_L, iris_R, lash_L, lash_R, brow_L, brow_R, hair_side_L, hair_side_R, hair_front, forearm_pose_L, forearm_pose_R \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, mouth_inner, eyes, irises, lashes, brows, side locks \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. mouth_inner is the lip set's one frame (mouth_open's place by default; lip_lower, lip_upper, mouth_tongue and mouth_teeth have no key and land on it, so a retune moves them together), and with the lip set the nose's tip rule reads layout.mouth_inner.cy. 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. forearm_pose_L/forearm_pose_R have no cx/cy/w defaults either: an unset `w` scales the forearm so its elbow end (the shoulder rule run from its bottom) is as wide as the placed arm's elbow run, and an unset `cx` or `cy` pins that elbow end's pivot on the arm's elbow \u2014 the one auto_rig_from_layers hangs it from."
6603
6836
  ),
6604
6837
  mirrorParts: import_zod.z.array(import_zod.z.string()).optional().describe(
6605
- "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), arm.png as the arm on the screen LEFT (the character's right, hanging, its shoulder at the image's top), and forearm_pose.png as the raised forearm on the screen LEFT (standing up from its elbow, the hand at the image's top, the thumb toward the body at the image's 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."
6838
+ "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), hair_side.png as the front side lock on the screen LEFT (hanging, its root at the image's top), arm.png as the arm on the screen LEFT (the character's right, hanging, its shoulder at the image's top), and forearm_pose.png as the raised forearm on the screen LEFT (standing up from its elbow, the hand at the image's top, the thumb toward the body at the image's 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."
6606
6839
  ),
6607
6840
  canvasHeight: import_zod.z.number().optional().describe(
6608
6841
  "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."
@@ -6630,7 +6863,7 @@ function createIkiMcpServer() {
6630
6863
  server.registerTool(
6631
6864
  "measure_layers",
6632
6865
  {
6633
- 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, a pose forearm without its arm or whose elbow end is off its arm's elbow in pivot, width or length, and the lip set: a partial one or one beside mouth/mouth_open, the fold's contract per column of the opening, an opening too narrow or short, a line too thin, green left, an interior with holes, and of mouth_tongue/mouth_teeth: one with no lip set, one on another canvas, one whose box leaves mouth_inner's \u2014 with the opening's size and the MouthOpen below which no slit shows). 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.",
6866
+ 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, a pose forearm without its arm or whose elbow end is off its arm's elbow in pivot, width or length, a front side lock without hair_front, one whose top row shows past the bangs at rest, one covering the eye white's outer corner at rest, one whose lean on the turn away from it would bare columns neither hair_back nor the face paints, a hair_side.png drawing two locks, and the lip set: a partial one or one beside mouth/mouth_open, the fold's contract per column of the opening, an opening too narrow or short, a line too thin, green left, an interior with holes, and of mouth_tongue/mouth_teeth: one with no lip set, one on another canvas, one whose box leaves mouth_inner's \u2014 with the opening's size and the MouthOpen below which no slit shows). 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.",
6634
6867
  inputSchema: {
6635
6868
  layersDir: import_zod.z.string().describe(
6636
6869
  "Directory of role-named layer PNGs (resolved against cwd)."