@ikijs/mcp 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,7 +22,7 @@ The `model` input for `validate_iki` and `describe_iki` accepts either a plain J
22
22
 
23
23
  Turns a set of role-named, full-canvas transparent PNG layers into a renderable, validated `.iki` model with the textures atlased and embedded as a base64 `data:image/png` URI. Under `quantizeColors` a `nose` layer is the exception: the palette rims a soft-shaded nose's feather, so the nose is atlased alone on a second, lossless page. The written model declares the head motions Nod, Shake and Tilt and up to six default expressions (smile, laugh, angry, sad, surprised, shy; `shy` needs a blush, `angry` and `sad` need brows), each with a description a host picks by; with a `blush_L`/`blush_R` layer it also declares `ParamCheek`, which fades the blush from faint at rest to as drawn.
24
24
 
25
- - **`layers`** — array of `{ path, fileName? }`. `path` is a PNG file path (resolved against the server's working directory); the role is derived from `fileName ?? basename(path)`. Required roles: `face`, `eye_L`, `eye_R`, `mouth`. Optional roles include `iris_L`/`iris_R`, `brow_L`/`brow_R`, `hair_front`/`hair_back`, `lash_L`/`lash_R`, `lash_lower_L`/`lash_lower_R`, `body`, `arm_L`/`arm_R`, etc. An arm — the whole arm drawn hanging, its shoulder at the top — needs the `body` (it hangs from the body's shoulder) and becomes an upper arm and a forearm sharing its crop, on `ParamArmL/R` (the shoulder) and `ParamElbowL/R`. All layers must share the same canvas size (taken from the first layer).
25
+ - **`layers`** — array of `{ path, fileName? }`. `path` is a PNG file path (resolved against the server's working directory); the role is derived from `fileName ?? basename(path)`. Required roles: `face`, `eye_L`, `eye_R`, `mouth`. Optional roles include `iris_L`/`iris_R`, `brow_L`/`brow_R`, `hair_front`/`hair_back`, `lash_L`/`lash_R`, `lash_lower_L`/`lash_lower_R`, `body`, `arm_L`/`arm_R`, `forearm_pose_L`/`forearm_pose_R`, etc. An arm — the whole arm drawn hanging, its shoulder at the top — needs the `body` (it hangs from the body's shoulder) and becomes an elbow cap, an upper arm and a forearm sharing its crop, on `ParamArmL/R` (the shoulder) and `ParamElbowL/R`. A pose forearm — the forearm raised, standing up from its elbow — needs its arm: it hangs from the arm's elbow and is swapped in for the hanging forearm by `ParamArmPoseL/R`, rocked by `ParamArmPoseAngleL/R`, and drawn above the face and the hair. All layers must share the same canvas size (taken from the first layer).
26
26
  - **`outputPath`** — optional `.iki` output path (resolved against the working directory; the parent directory must already exist, and the path must end in `.iki`). Defaults to `auto-rigged-model.iki`.
27
27
  - **`turnTargets`** — optional head-turn cues to fit the rig to, in the units `measure_turn_reference` reports off a front/turned reference pair: `eyeShift` (plus `noseShift` and `mouthShift`) is how far that feature slides across the head at full turn, as a fraction of the head's half-width — a **magnitude**, since the rig turns both ways and the sign is the turn's own business; `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. An omitted field leaves that part of the turn at the profile the rig defaults to. An `eyeShift` you pass is fitted by the turn's amount and _clamped_ when it runs past the room the art leaves the far eye — the face plate's edge, or the bangs' side strand over the far iris — since that room is a fact about these layers, not about the reference. Any other target you **do** pass that it cannot reach is refused, because that number is a measurement rather than a preference. A layer set without a `nose` still turns its head, on the profile, but fits no target: `turnTargets` is then inert and the result carries no `turn`.
28
28
  - **`style`** — optional per-character tuning from the profile the rig defaults to: `turn` (the whole head turn, the eyes' foreshortening with it, 0..3, 1 = the profile; ignored when `turnTargets.eyeShift` is given), `featureLead` (how far the features lead the face plate, 0..3), `hairFollow` (the front hair's share of the face's turn, 0..2, profile 1), `outlineFollow` (its outer edge's share where it draws the head's outline, 0..2, profile 0: the outline holds), `blink` (how far the upper lid comes down over the eye's height, 0.1..1, profile 0.6) and `sway` (the hair sway amplitude, 0..5). A value out of range, or a knob not named here, is refused.
@@ -34,16 +34,16 @@ The decode/atlas pipeline runs in Node via `sharp` (a native dependency confined
34
34
 
35
35
  Composes a directory of AI-generated part PNGs into canvas-aligned, role-named layer PNGs ready for `auto_rig_from_layers`, on a canvas 1100 px wide and `canvasHeight` tall (1100 by default) with a built-in default layout tuned for the character-generation skill's standard front-facing framing. It ports the composer that shipped as a script (`compose.cjs`) in the Claude Code plugin.
36
36
 
37
- - **`partsDir`** — directory of the source part PNGs (resolved against the server's working directory). Required sources: `face.png`, `eyewhite.png` (split into the sclera, the upper lash and the lower lid — `lash_lower_L`/`lash_lower_R`, the dark line and lashes of the eye's lower part, which draw over the iris and are placed on the sclera's frame by the `eye_*` layout, so they have no layout key of their own; an eyewhite with no dark lower lid writes none and lists them in `skipped`. A light mark drawn detached above the eye white, such as a double-eyelid crease, is dropped from the sclera — the iris's clip — while dark strokes there stay lash ink), `iris.png`, `mouth.png`, `brow.png`, `hair_front.png`. Optional: `hair_back.png`, `body.png`, `mouth_open.png`, `blush.png`, `nose.png` — a parts dir without them still composes, minus those roles. One `blush.png` makes both cheeks' blush: `blush_R` takes it as drawn and `blush_L` mirrored. It is decoration, so the report does not flag a set without it. One `arm.png` — the arm on the screen left, drawn hanging with its shoulder at the top — makes both arms of a full body: `arm_R` takes it as drawn and `arm_L` mirrored, and each is hung on the body's shoulder (see `layout`). The arms are opt-in: a parts dir without `arm.png` composes as a bust does, and `skipped` never lists them. An `arm.png` needs a `body.png`. The nose is what the auto-rig leads the head turn with, and a face supplied alongside it must be drawn without one, or the painted nose stays on the face plate while the real one moves. Each part but the eye pair is cropped to its drawing before it is sized and placed. A faint speck detached from the drawing, one that never reaches alpha 128 and covers under 1 % of the part's pixels (residue a background removal leaves), is cut out with the margin it widened, so it cannot pull the part off its centre. A detached stroke that reaches alpha 128 is kept.
38
- - **`outDir`** — an existing directory (resolved against the working directory, confined to it exactly like `auto_rig_from_layers`'s `outputPath`; the tool never creates directories) to write the role layer PNGs and a flattened `preview.png` into. Reusing a directory across runs is intentional — a role this run does not write (one it skips, e.g. composing a head-only set that omits `body`, or an arm once `arm.png` is gone) has its stale `<role>.png` from an earlier run deleted, so the directory always holds exactly this run's roles.
39
- - **`layout`** — optional per-role override merged over the built-in defaults, e.g. `{ "eye_L": { "cx": 660 } }`, so a character can be retuned by re-running compose rather than editing a script. Each of `cx`, `cy`, `w`, `h` is optional; `w` must be an integer in 1..1100 (the canvas width) and `h` in 1..`canvasHeight` (the canvas height). The defaults of the face's features — blush, nose, mouth, `mouth_open`, eyes, irises, lashes, brows — 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. Omitting `h` keeps the part's own aspect ratio, which is what every role wants until one does not: a generated eyewhite often comes back flatter than its reference, and stretching a flat white lens costs nothing where regenerating it is billed and unreliable. The nose is sized and placed by its dense core — its pixels at alpha ≥ 128, the drawing a viewer reads inside a soft nose's feather — rather than its whole part, which for a shaded-bump nose is mostly feather: `w` (default 20) and `h` size the core, `cx` (default 550) centres it, and a set `cy` centres its rows. By default its `cy` is unset, and the core's bottom row (the tip) lands 0.66 of the way from the eye row down to the mouth's, so the nose follows a retuned eye or mouth row. A nose with no pixel at alpha ≥ 128 is sized and placed whole, and so is one whose core is a speck of its trimmed part — under a quarter of its width or height, such as a lone nostril mark or highlight, which sized to `w` would blow the whole nose up — and the report warns of the speck. Set `h` on a sclera and its lash together — they share one frame, and the blink fold tears if they diverge, so a pair set to land on different frames is rejected. `arm_L` and `arm_R` have no `cx`/`cy`/`w` defaults; each is derived from the placed body. An unset `w` is 0.4 of the body's width. An unset `cx` or `cy` hangs the arm's shoulder pivot — the one `auto_rig_from_layers` turns it about, read off the resized arm by the rig's own rule — 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. On a torso widest at its shoulders, the shoulder cap's centre then sits on the torso's edge. A set one centres the arm as for every other role. Both values are provisional.
40
- - **`mirrorParts`** — optional list of part files to flip left-right as they are read, e.g. `["eyewhite.png"]`. Which way a part faces is fixed by the layout, and "left eye" cannot pin it down — it reads as the viewer's left or the character's — so in image terms: `eyewhite.png` is read as the eye on the screen left, lash wing (outer corner) at the image's left end and lash-free tear duct at its right; `brow.png` as the brow on the screen right, thick head at the image's left end and 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 and 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. A part drawn the other way round is fixed here for free instead of regenerated. It flips the source, so every role cut from it flips together and an eye's sclera and lash stay in one frame.
37
+ - **`partsDir`** — directory of the source part PNGs (resolved against the server's working directory). Required sources: `face.png`, `eyewhite.png` (split into the sclera, the upper lash and the lower lid — `lash_lower_L`/`lash_lower_R`, the dark line and lashes of the eye's lower part, which draw over the iris and are placed on the sclera's frame by the `eye_*` layout, so they have no layout key of their own; an eyewhite with no dark lower lid writes none and lists them in `skipped`. A light mark drawn detached above the eye white, such as a double-eyelid crease, is dropped from the sclera — the iris's clip — while dark strokes there stay lash ink), `iris.png`, `mouth.png`, `brow.png`, `hair_front.png`. Optional: `hair_back.png`, `body.png`, `mouth_open.png`, `blush.png`, `nose.png` — a parts dir without them still composes, minus those roles. One `blush.png` makes both cheeks' blush: `blush_R` takes it as drawn and `blush_L` mirrored. It is decoration, so the report does not flag a set without it. One `arm.png` — the arm on the screen left, drawn hanging with its shoulder at the top — makes both arms of a full body: `arm_R` takes it as drawn and `arm_L` mirrored, and each is hung on the body's shoulder (see `layout`). The arms are opt-in: a parts dir without `arm.png` composes as a bust does, and `skipped` never lists them. An `arm.png` needs a `body.png`. One `forearm_pose.png` — the arm's forearm raised, on the screen left, standing up from its elbow with the hand at the top — makes both pose forearms (`forearm_pose_R` as drawn, `forearm_pose_L` mirrored); it is opt-in too and needs an `arm.png`. With one the compose also writes `preview-pose.png`, the switch at 1 as the rig draws it (each arm with a pose forearm cropped to the rows above its elbow, the pose forearms over everything); `preview.png` stays the rest pose, where a pose forearm is invisible. Without a `forearm_pose.png`, `preview-pose.png` is removed. The nose is what the auto-rig leads the head turn with, and a face supplied alongside it must be drawn without one, or the painted nose stays on the face plate while the real one moves. Each part but the eye pair is cropped to its drawing before it is sized and placed. A faint speck detached from the drawing, one that never reaches alpha 128 and covers under 1 % of the part's pixels (residue a background removal leaves), is cut out with the margin it widened, so it cannot pull the part off its centre. A detached stroke that reaches alpha 128 is kept.
38
+ - **`outDir`** — an existing directory (resolved against the working directory, confined to it exactly like `auto_rig_from_layers`'s `outputPath`; the tool never creates directories) to write the role layer PNGs and a flattened `preview.png` (and, with a `forearm_pose.png`, `preview-pose.png`) into. Reusing a directory across runs is intentional — a role this run does not write (one it skips, e.g. composing a head-only set that omits `body`, or an arm or pose forearm once `arm.png` or `forearm_pose.png` is gone, `preview-pose.png` included) has its stale `<role>.png` from an earlier run deleted, so the directory always holds exactly this run's roles.
39
+ - **`layout`** — optional per-role override merged over the built-in defaults, e.g. `{ "eye_L": { "cx": 660 } }`, so a character can be retuned by re-running compose rather than editing a script. Each of `cx`, `cy`, `w`, `h` is optional; `w` must be an integer in 1..1100 (the canvas width) and `h` in 1..`canvasHeight` (the canvas height). The defaults of the face's features — blush, nose, mouth, `mouth_open`, eyes, irises, lashes, brows — 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. Omitting `h` keeps the part's own aspect ratio, which is what every role wants until one does not: a generated eyewhite often comes back flatter than its reference, and stretching a flat white lens costs nothing where regenerating it is billed and unreliable. The nose is sized and placed by its dense core — its pixels at alpha ≥ 128, the drawing a viewer reads inside a soft nose's feather — rather than its whole part, which for a shaded-bump nose is mostly feather: `w` (default 20) and `h` size the core, `cx` (default 550) centres it, and a set `cy` centres its rows. By default its `cy` is unset, and the core's bottom row (the tip) lands 0.66 of the way from the eye row down to the mouth's, so the nose follows a retuned eye or mouth row. A nose with no pixel at alpha ≥ 128 is sized and placed whole, and so is one whose core is a speck of its trimmed part — under a quarter of its width or height, such as a lone nostril mark or highlight, which sized to `w` would blow the whole nose up — and the report warns of the speck. Set `h` on a sclera and its lash together — they share one frame, and the blink fold tears if they diverge, so a pair set to land on different frames is rejected. `arm_L` and `arm_R` have no `cx`/`cy`/`w` defaults; each is derived from the placed body. An unset `w` is 0.4 of the body's width. An unset `cx` or `cy` hangs the arm's shoulder pivot — the one `auto_rig_from_layers` turns it about, read off the resized arm by the rig's own rule — 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. On a torso widest at its shoulders, the shoulder cap's centre then sits on the torso's edge. A set one centres the arm as for every other role. Both values are provisional. `forearm_pose_L` and `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, on the trimmed source) is as wide as the placed arm's elbow run, and an unset `cx` or `cy` pins the elbow end's pivot — measured on the resized part — on the arm's placed elbow, the pivot `auto_rig_from_layers` hangs it from.
40
+ - **`mirrorParts`** — optional list of part files to flip left-right as they are read, e.g. `["eyewhite.png"]`. Which way a part faces is fixed by the layout, and "left eye" cannot pin it down — it reads as the viewer's left or the character's — so in image terms: `eyewhite.png` is read as the eye on the screen left, lash wing (outer corner) at the image's left end and lash-free tear duct at its right; `brow.png` as the brow on the screen right, thick head at the image's left end and 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 and 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; `forearm_pose.png` as the raised forearm on the screen left, standing up from its elbow, the hand at the image's top and the thumb toward the body at its right. A part drawn the other way round is fixed here for free instead of regenerated. It flips the source, so every role cut from it flips together and an eye's sclera and lash stay in one frame.
41
41
  - **`canvasHeight`** — optional height of the canvas in px: an even integer in 1100..4096, default 1100, a square bust canvas — and 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, since model space is centred on the canvas and it would put the head on a half pixel. It is checked before any part decodes.
42
- - **Result** — on success the text is the written layer paths (one per line) followed by the same geometry report `measure_layers` returns — except that when the composer found the core of the nose's source part a speck, its nose check reports that verdict instead of what the composed file shows, so a speck that resampling erased from the layer is warned about here and not by `measure_layers`. `structuredContent` is `{ ok: true, outDir, layers, skipped, preview, measure }`. Invalid input (a missing required part, a `canvasHeight` that is odd or outside 1100..4096, an unknown `layout` role, an out-of-range `w` or `h`, a lash placed on a different frame from its sclera's, an `arm.png` without a `body.png`, an arm too short for the rig to hang an elbow under its shoulder, a `mirrorParts` entry that is not a part file, a part that lands entirely off-canvas, a non-existent `outDir`) returns `{ ok: false, error }` with `INVALID: …` text.
42
+ - **Result** — on success the text is the written layer paths (one per line) followed by the same geometry report `measure_layers` returns — except that when the composer found the core of the nose's source part a speck, its nose check reports that verdict instead of what the composed file shows, so a speck that resampling erased from the layer is warned about here and not by `measure_layers`. `structuredContent` is `{ ok: true, outDir, layers, skipped, preview, previewPose?, measure }` (`previewPose` only with a `forearm_pose.png`). Invalid input (a missing required part, a `canvasHeight` that is odd or outside 1100..4096, an unknown `layout` role, an out-of-range `w` or `h`, a lash placed on a different frame from its sclera's, an `arm.png` without a `body.png`, a `forearm_pose.png` without an `arm.png`, an arm too short for the rig to hang an elbow under its shoulder, a `mirrorParts` entry that is not a part file, a part that lands entirely off-canvas, a non-existent `outDir`) returns `{ ok: false, error }` with `INVALID: …` text.
43
43
 
44
44
  ### `measure_layers`
45
45
 
46
- Reports the same read-only geometry checks `compose_layers_from_parts` returns inline (iris size/offset relative to the sclera, eye aspect, an eye drawn facing the other way, cropped or flat-cut edges, a nose whose dense core is a speck of its crop, missing optional roles, and for a full body: a body whose feet the bottom of a canvas taller than wide cuts off, an arm without a body, and an arm whose shoulder cap — the one `auto_rig_from_layers` turns it about, read by the rig's own rule — does not reach half its radius under the torso's edge on its shoulder pivot's row), over an already-composed layers directory — for re-checking a layers dir without recomposing it. Its nose check reads the composed file against its crop, which is what `auto_rig_from_layers` acts on: a speck core there is one the rig does not turn or tilt the nose about. The composer's inline report does the same unless it found the source part's core a speck, which it reports instead, so a speck that resampling erased from the layer shows there and not here.
46
+ Reports the same read-only geometry checks `compose_layers_from_parts` returns inline (iris size/offset relative to the sclera, eye aspect, an eye drawn facing the other way, cropped or flat-cut edges, a nose whose dense core is a speck of its crop, missing optional roles, and for a full body: a body whose feet the bottom of a canvas taller than wide cuts off, an arm without a body, an arm whose shoulder cap — the one `auto_rig_from_layers` turns it about, read by the rig's own rule — does not reach half its radius under the torso's edge on its shoulder pivot's row, and a pose forearm without its arm or whose elbow end is more than 2 px off the arm's elbow, more than 10 % off its elbow run in width, or more than 15 % off its hand's reach in length), over an already-composed layers directory — for re-checking a layers dir without recomposing it. Its nose check reads the composed file against its crop, which is what `auto_rig_from_layers` acts on: a speck core there is one the rig does not turn or tilt the nose about. The composer's inline report does the same unless it found the source part's core a speck, which it reports instead, so a speck that resampling erased from the layer shows there and not here.
47
47
 
48
48
  - **`layersDir`** — directory of role-named layer PNGs (resolved against the working directory). Every `preview*.png` in it is skipped.
49
49
  - **Result** — the text is the report: a per-layer size/bbox-centre/mass-centre/margins table, then the checks that fired. `structuredContent` is `{ ok: true, layersDir, layers, empty, warnings, passed }`. A missing or non-directory `layersDir` returns `{ ok: false, error }` with `INVALID: …` text.
@@ -386,11 +386,27 @@ var STANDARD_PARAMETER_INFO = [
386
386
  },
387
387
  {
388
388
  id: StandardParameter.ElbowLeft,
389
- description: "Left elbow, degrees; positive bends the forearm the way positive ArmLeft raises the arm."
389
+ description: "Left elbow, degrees; positive bends the forearm toward the body (the flexion of a hanging arm), negative a little outward (mirrored on the right)."
390
390
  },
391
391
  {
392
392
  id: StandardParameter.ElbowRight,
393
- description: "Right elbow, degrees; positive bends the forearm the way positive ArmRight raises the arm."
393
+ description: "Right elbow, degrees; positive bends the forearm toward the body (the flexion of a hanging arm), negative a little outward (mirrored on the left)."
394
+ },
395
+ {
396
+ id: StandardParameter.ArmPoseLeft,
397
+ description: "Left pose-forearm switch, 0..1; 0 the hanging forearm, 1 the drawn pose forearm, between them a crossfade of the two. Declared by auto-rigged models with a pose forearm."
398
+ },
399
+ {
400
+ id: StandardParameter.ArmPoseRight,
401
+ description: "Right pose-forearm switch, 0..1; 0 the hanging forearm, 1 the drawn pose forearm, between them a crossfade of the two. Declared by auto-rigged models with a pose forearm."
402
+ },
403
+ {
404
+ id: StandardParameter.ArmPoseAngleLeft,
405
+ description: "Left pose forearm's own small rotation about the elbow, degrees; positive tips the raised hand outward, away from the body (mirrored on the right)."
406
+ },
407
+ {
408
+ id: StandardParameter.ArmPoseAngleRight,
409
+ description: "Right pose forearm's own small rotation about the elbow, degrees; positive tips the raised hand outward, away from the body (mirrored on the left)."
394
410
  }
395
411
  ];
396
412
  function listStandardParameters() {
@@ -1043,6 +1059,97 @@ function capWarning(arm, g, body) {
1043
1059
  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
1060
  }
1045
1061
 
1062
+ // src/measure-forearm-pose.ts
1063
+ import {
1064
+ LayerGeometryError as LayerGeometryError3,
1065
+ armGeometry as armGeometry2,
1066
+ createLayerSetMeasurer as createLayerSetMeasurer3,
1067
+ forearmPoseGeometry
1068
+ } from "@ikijs/editor";
1069
+ var POSE_ROLES = ["forearm_pose_L", "forearm_pose_R"];
1070
+ var ARM_OF = {
1071
+ forearm_pose_L: "arm_L",
1072
+ forearm_pose_R: "arm_R"
1073
+ };
1074
+ var POSE_PIVOT_TOLERANCE = 2;
1075
+ var POSE_WIDTH_TOLERANCE = 0.1;
1076
+ var POSE_LENGTH_TOLERANCE = 0.15;
1077
+ function bottomRowY(layer) {
1078
+ const painted = layer.rowRuns?.flatMap((runs, k2) => runs.length > 0 ? [k2] : []) ?? [];
1079
+ const k = painted.at(-1) ?? layer.bbox.h - 1;
1080
+ return layer.canvasH / 2 - (layer.bbox.y + k + 0.5);
1081
+ }
1082
+ async function forearmPoseWarnings(absDir, layers) {
1083
+ const warnings = [];
1084
+ for (const pose of POSE_ROLES) {
1085
+ const stats = layers[pose];
1086
+ if (stats === void 0) continue;
1087
+ const arm = ARM_OF[pose];
1088
+ const armStats = layers[arm];
1089
+ if (armStats === void 0) {
1090
+ warnings.push(
1091
+ `${pose}: no ${arm} layer \u2014 a pose forearm hangs from its arm's elbow, and auto_rig_from_layers refuses it.`
1092
+ );
1093
+ continue;
1094
+ }
1095
+ if (stats.canvasW !== armStats.canvasW || stats.canvasH !== armStats.canvasH) {
1096
+ warnings.push(
1097
+ `${pose}: its canvas ${stats.canvasW}x${stats.canvasH} differs from ${arm}'s ${armStats.canvasW}x${armStats.canvasH} \u2014 auto_rig_from_layers refuses layers of different sizes; recompose them together.`
1098
+ );
1099
+ continue;
1100
+ }
1101
+ if (layers.body === void 0) continue;
1102
+ const measurer = createLayerSetMeasurer3({
1103
+ width: stats.canvasW,
1104
+ height: stats.canvasH
1105
+ });
1106
+ let a;
1107
+ let armLayer;
1108
+ try {
1109
+ armLayer = await measured(measurer, absDir, arm);
1110
+ a = armGeometry2(armLayer, arm === "arm_R" ? Infinity : -Infinity);
1111
+ } catch (err) {
1112
+ if (err instanceof LayerGeometryError3) continue;
1113
+ throw err;
1114
+ }
1115
+ const b = forearmPoseGeometry(await measured(measurer, absDir, pose));
1116
+ warnings.push(...jointWarnings(pose, arm, stats, a, armLayer, b));
1117
+ }
1118
+ return warnings;
1119
+ }
1120
+ function jointWarnings(pose, arm, stats, a, armLayer, b) {
1121
+ const warnings = [];
1122
+ const key = `layout.${pose}`;
1123
+ const dx = a.elbow.x - b.pivot.x;
1124
+ const dy = a.elbow.y - b.pivot.y;
1125
+ const off = Math.hypot(dx, dy);
1126
+ if (off > POSE_PIVOT_TOLERANCE) {
1127
+ warnings.push(
1128
+ `${pose}: its elbow end is ${px(off)} px off ${arm}'s elbow \u2014 the raised forearm detaches from the arm at the joint once it swaps in. Remove ${key}.cx/cy from the layout so it stays pinned on the elbow through later arm retunes (free), or set ${key}.cx to ${Math.round(stats.bboxCx + 0.5 + dx)} and ${key}.cy to ${Math.round(stats.bboxCy + 0.5 - dy)} (free).`
1129
+ );
1130
+ }
1131
+ const armRun = a.seamRun[1] - a.seamRun[0];
1132
+ const poseRun = 2 * b.radius;
1133
+ const widthRatio = poseRun / armRun;
1134
+ const widthBad = Math.abs(widthRatio - 1) > POSE_WIDTH_TOLERANCE;
1135
+ if (widthBad) {
1136
+ warnings.push(
1137
+ `${pose}: its elbow end is ${px(poseRun)} px wide, ${Math.round(Math.abs(widthRatio - 1) * 100)}% off ${arm}'s elbow run (${px(armRun)} px) \u2014 the sleeve steps at the joint once it swaps in. Set ${key}.w to ${Math.round(stats.w / widthRatio)} (free).`
1138
+ );
1139
+ }
1140
+ const armLen = a.elbow.y - bottomRowY(armLayer);
1141
+ const poseLen = b.top - b.pivot.y;
1142
+ const lengthRatio = poseLen / armLen;
1143
+ if (Math.abs(lengthRatio - 1) > POSE_LENGTH_TOLERANCE) {
1144
+ const fix = 1 / lengthRatio;
1145
+ const freeFix = Math.abs(widthRatio * fix - 1) <= POSE_WIDTH_TOLERANCE;
1146
+ warnings.push(
1147
+ `${pose}: its length from the elbow end to the hand is ${px(poseLen)} px against ${arm}'s ${px(armLen)} px from its elbow to its hand \u2014 ` + (freeFix ? `the raised hand reaches the wrong height. Set ${key}.w to ${Math.round(stats.w * fix)} (free)` + (widthBad ? `, which fixes the width too.` : `.`) : `the raised hand reaches the wrong height, and no single w fits both its length and its width. Regenerate forearm_pose.png with the forearm and hand as long as the hanging arm's below its elbow. Billed.`)
1148
+ );
1149
+ }
1150
+ return warnings;
1151
+ }
1152
+
1046
1153
  // src/measure.ts
1047
1154
  var IRIS_RATIO_MIN = 0.45;
1048
1155
  var IRIS_RATIO_MAX = 0.72;
@@ -1132,7 +1239,7 @@ async function layerStats(filePath) {
1132
1239
  };
1133
1240
  }
1134
1241
  var pct = (v) => `${(v * 100).toFixed(0)}%`;
1135
- var isArm = (role) => ARM_ROLES.includes(role);
1242
+ var isArm = (role) => ARM_ROLES.includes(role) || POSE_ROLES.includes(role);
1136
1243
  function noseSpeckWarning({ core, part }, source) {
1137
1244
  const [found, consequence] = source === "compose" ? [
1138
1245
  `the source part's dense core is ${core.w}x${core.h} in its ${part.w}x${part.h} trimmed part`,
@@ -1218,6 +1325,7 @@ async function measureDir(absDir, noseSpeck) {
1218
1325
  }
1219
1326
  }
1220
1327
  warnings.push(...await armWarnings(absDir, layers));
1328
+ warnings.push(...await forearmPoseWarnings(absDir, layers));
1221
1329
  for (const side of ["L", "R"]) {
1222
1330
  const eye = layers[`eye_${side}`];
1223
1331
  const iris = layers[`iris_${side}`];
@@ -1343,15 +1451,16 @@ import { ALPHA_OPAQUE as ALPHA_OPAQUE2, detectAlphaBbox as scanAlphaBbox2 } from
1343
1451
  // src/compose-arms.ts
1344
1452
  import sharp2 from "sharp";
1345
1453
  import {
1346
- LayerGeometryError as LayerGeometryError3,
1347
- armGeometry as armGeometry2,
1348
- createLayerSetMeasurer as createLayerSetMeasurer3
1454
+ LayerGeometryError as LayerGeometryError4,
1455
+ armGeometry as armGeometry3,
1456
+ createLayerSetMeasurer as createLayerSetMeasurer4,
1457
+ forearmPoseGeometry as forearmPoseGeometry2
1349
1458
  } from "@ikijs/editor";
1350
1459
  var ARM_WIDTH = 0.4;
1351
1460
  var SHOULDER_DROP = 0.12;
1352
1461
  async function armPlacement(role, cfg, part, body) {
1353
1462
  const { data } = await sharp2(part.buf).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1354
- const layer = createLayerSetMeasurer3({ width: part.w, height: part.h }).add({
1463
+ const layer = createLayerSetMeasurer4({ width: part.w, height: part.h }).add({
1355
1464
  role,
1356
1465
  fileName: "arm.png",
1357
1466
  rgba: data
@@ -1361,28 +1470,62 @@ async function armPlacement(role, cfg, part, body) {
1361
1470
  `layout.${role}: arm.png is empty after alpha threshold once resized`
1362
1471
  );
1363
1472
  }
1364
- let shoulder;
1473
+ let g;
1365
1474
  try {
1366
- ({ shoulder } = armGeometry2(
1367
- layer,
1368
- role === "arm_R" ? Infinity : -Infinity
1369
- ));
1475
+ g = armGeometry3(layer, role === "arm_R" ? Infinity : -Infinity);
1370
1476
  } catch (err) {
1371
- if (err instanceof LayerGeometryError3) {
1477
+ if (err instanceof LayerGeometryError4) {
1372
1478
  throw new AutoRigInputError(`layout.${role}: ${err.message}`);
1373
1479
  }
1374
1480
  throw err;
1375
1481
  }
1376
- const pivotX = shoulder.x + part.w / 2;
1377
- const pivotY = part.h / 2 - shoulder.y;
1482
+ const pivotX = g.shoulder.x + part.w / 2;
1483
+ const pivotY = part.h / 2 - g.shoulder.y;
1378
1484
  const cornerX = role === "arm_R" ? body.left : body.left + body.w;
1379
1485
  const cornerY = body.top + SHOULDER_DROP * body.h;
1486
+ const left = Math.round(
1487
+ cfg.cx === void 0 ? cornerX - pivotX : cfg.cx - part.w / 2
1488
+ );
1489
+ const top = Math.round(
1490
+ cfg.cy === void 0 ? cornerY - pivotY : cfg.cy - part.h / 2
1491
+ );
1492
+ return {
1493
+ left,
1494
+ top,
1495
+ elbow: {
1496
+ x: left + g.elbow.x + part.w / 2,
1497
+ y: top + part.h / 2 - g.elbow.y
1498
+ },
1499
+ elbowRun: g.seamRun[1] - g.seamRun[0]
1500
+ };
1501
+ }
1502
+ async function poseGeometryOf(role, png, size, when) {
1503
+ const { data } = await sharp2(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1504
+ const layer = createLayerSetMeasurer4({
1505
+ width: size.w,
1506
+ height: size.h
1507
+ }).add({ role, fileName: "forearm_pose.png", rgba: data });
1508
+ if (layer === null) {
1509
+ throw new AutoRigInputError(
1510
+ `layout.${role}: forearm_pose.png is empty after alpha threshold${when}`
1511
+ );
1512
+ }
1513
+ return forearmPoseGeometry2(layer);
1514
+ }
1515
+ async function forearmPoseWidth(role, trimmed, elbowRun) {
1516
+ const g = await poseGeometryOf(role, trimmed.data, trimmed, "");
1517
+ return Math.max(1, Math.round(trimmed.w * elbowRun / (2 * g.radius)));
1518
+ }
1519
+ async function forearmPosePlacement(role, cfg, part, elbow) {
1520
+ const { pivot } = await poseGeometryOf(role, part.buf, part, " once resized");
1521
+ const pivotX = pivot.x + part.w / 2;
1522
+ const pivotY = part.h / 2 - pivot.y;
1380
1523
  return {
1381
1524
  left: Math.round(
1382
- cfg.cx === void 0 ? cornerX - pivotX : cfg.cx - part.w / 2
1525
+ cfg.cx === void 0 ? elbow.x - pivotX : cfg.cx - part.w / 2
1383
1526
  ),
1384
1527
  top: Math.round(
1385
- cfg.cy === void 0 ? cornerY - pivotY : cfg.cy - part.h / 2
1528
+ cfg.cy === void 0 ? elbow.y - pivotY : cfg.cy - part.h / 2
1386
1529
  )
1387
1530
  };
1388
1531
  }
@@ -1472,7 +1615,15 @@ var DEFAULT_LAYOUT = {
1472
1615
  // prettier-ignore
1473
1616
  brow_L: { src: "brow.png", cx: 645, cy: 405, w: 105, mirror: false },
1474
1617
  brow_R: { src: "brow.png", cx: 455, cy: 405, w: 105, mirror: true },
1475
- hair_front: { src: "hair_front.png", cx: 550, cy: 425, w: 660 }
1618
+ hair_front: { src: "hair_front.png", cx: 550, cy: 425, w: 660 },
1619
+ // The pose forearms, one drawing for both: forearm_pose_R (screen left)
1620
+ // takes forearm_pose.png as drawn and forearm_pose_L mirrors it, like the
1621
+ // arms. The rig draws them above the face and the hair, so they come last.
1622
+ // No cx/cy/w defaults: an unset `w` scales the forearm's elbow end to the
1623
+ // placed arm's elbow run, an unset `cx` or `cy` pins its elbow-end pivot
1624
+ // on the arm's elbow (ArmLayout). OPTIONAL and opt-in, like the arms.
1625
+ forearm_pose_L: { src: "forearm_pose.png", optional: true, mirror: true },
1626
+ forearm_pose_R: { src: "forearm_pose.png", optional: true, mirror: false }
1476
1627
  };
1477
1628
  var LOWER_LASH = { lash_lower_L: "eye_L", lash_lower_R: "eye_R" };
1478
1629
  var LOWER_LASH_SRC = "eyewhite_lash_lower.png";
@@ -1497,7 +1648,9 @@ var ORDER = [
1497
1648
  "lash_R",
1498
1649
  "brow_L",
1499
1650
  "brow_R",
1500
- "hair_front"
1651
+ "hair_front",
1652
+ "forearm_pose_L",
1653
+ "forearm_pose_R"
1501
1654
  ];
1502
1655
  var PART_FILES = [
1503
1656
  ...new Set(
@@ -1638,7 +1791,7 @@ async function noseSizingOf(png) {
1638
1791
  }
1639
1792
  return { box: core, whole: false };
1640
1793
  }
1641
- async function partBuffer(role, cfg, partsDir, inMemory, flipSource, canvas) {
1794
+ async function trimmedPart(role, cfg, partsDir, inMemory, flipSource) {
1642
1795
  let img;
1643
1796
  if (inMemory !== void 0) {
1644
1797
  img = sharp3(inMemory);
@@ -1666,7 +1819,14 @@ async function partBuffer(role, cfg, partsDir, inMemory, flipSource, canvas) {
1666
1819
  }
1667
1820
  if ((cfg.mirror ?? false) !== flipSource) img = img.flop();
1668
1821
  const trimmed = await img.png().toBuffer({ resolveWithObject: true });
1669
- const { width: trimmedW, height: trimmedH } = trimmed.info;
1822
+ return {
1823
+ data: trimmed.data,
1824
+ w: trimmed.info.width,
1825
+ h: trimmed.info.height
1826
+ };
1827
+ }
1828
+ async function sizedPart(role, cfg, trimmed, canvas) {
1829
+ const { w: trimmedW, h: trimmedH } = trimmed;
1670
1830
  const nose = role === "nose" ? await noseSizingOf(trimmed.data) : void 0;
1671
1831
  const sized = nose?.box ?? { x: 0, y: 0, w: trimmedW, h: trimmedH };
1672
1832
  const width = Math.round(trimmedW * cfg.w / sized.w);
@@ -1685,6 +1845,10 @@ async function partBuffer(role, cfg, partsDir, inMemory, flipSource, canvas) {
1685
1845
  nose
1686
1846
  };
1687
1847
  }
1848
+ async function partBuffer(role, cfg, partsDir, inMemory, flipSource, canvas) {
1849
+ const trimmed = await trimmedPart(role, cfg, partsDir, inMemory, flipSource);
1850
+ return trimmed === null ? null : sizedPart(role, cfg, trimmed, canvas);
1851
+ }
1688
1852
  function assertOnCanvas(source, w, h, left, top, canvas) {
1689
1853
  if (left + w <= 0 || top + h <= 0 || left >= canvas.width || top >= canvas.height) {
1690
1854
  throw new AutoRigInputError(
@@ -1981,12 +2145,17 @@ async function composeLayersFromParts(input) {
1981
2145
  mirrored.has(arm.src),
1982
2146
  canvas
1983
2147
  );
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
- });
2148
+ const { left: left2, top: top2, elbow, elbowRun } = await armPlacement(
2149
+ key,
2150
+ arm,
2151
+ part2,
2152
+ {
2153
+ left: body.left,
2154
+ top: body.top,
2155
+ w: body.part.w,
2156
+ h: body.part.h
2157
+ }
2158
+ );
1990
2159
  const unset = ["cx", "cy"].filter(
1991
2160
  (field) => arm[field] === void 0
1992
2161
  );
@@ -1998,6 +2167,58 @@ async function composeLayersFromParts(input) {
1998
2167
  top2,
1999
2168
  canvas
2000
2169
  );
2170
+ placed.push({ role, part: part2, left: left2, top: top2, elbow, elbowRun });
2171
+ continue;
2172
+ }
2173
+ if (key === "forearm_pose_L" || key === "forearm_pose_R") {
2174
+ const pose = layout[key];
2175
+ if (!fs3.existsSync(path6.join(partsDir, pose.src))) continue;
2176
+ const armRole = key === "forearm_pose_L" ? "arm_L" : "arm_R";
2177
+ const arm = placed.find((p) => p.role === armRole);
2178
+ if (arm?.elbow === void 0 || arm.elbowRun === void 0) {
2179
+ throw new AutoRigInputError(
2180
+ "forearm_pose.png: a pose forearm needs arm.png \u2014 the composer pins it on the arm's elbow, and auto_rig_from_layers hangs it from the arm"
2181
+ );
2182
+ }
2183
+ const trimmed = await trimmedPart(
2184
+ role,
2185
+ pose,
2186
+ partsDir,
2187
+ void 0,
2188
+ mirrored.has(pose.src)
2189
+ );
2190
+ const w = pose.w ?? await forearmPoseWidth(key, trimmed, arm.elbowRun);
2191
+ let part2;
2192
+ try {
2193
+ part2 = await sizedPart(role, { ...pose, w }, trimmed, canvas);
2194
+ } catch (err) {
2195
+ if (pose.w === void 0 && err instanceof AutoRigInputError) {
2196
+ throw new AutoRigInputError(
2197
+ err.message.replace(
2198
+ `layout.${role}.w:`,
2199
+ `layout.${role}.w (unset: scaled to ${armRole}'s elbow run):`
2200
+ )
2201
+ );
2202
+ }
2203
+ throw err;
2204
+ }
2205
+ const { left: left2, top: top2 } = await forearmPosePlacement(
2206
+ key,
2207
+ pose,
2208
+ part2,
2209
+ arm.elbow
2210
+ );
2211
+ const unset = ["cx", "cy"].filter(
2212
+ (field) => pose[field] === void 0
2213
+ );
2214
+ assertOnCanvas(
2215
+ unset.length === 0 ? `layout.${key}.cx/cy` : `layout.${key}.cx/cy (${unset.join("/")} unset: its elbow-end pivot hangs on the elbow of layout.${armRole}'s placed arm)`,
2216
+ part2.w,
2217
+ part2.h,
2218
+ left2,
2219
+ top2,
2220
+ canvas
2221
+ );
2001
2222
  placed.push({ role, part: part2, left: left2, top: top2 });
2002
2223
  continue;
2003
2224
  }
@@ -2041,6 +2262,10 @@ async function composeLayersFromParts(input) {
2041
2262
  if (placed.some((p) => p.role === role)) continue;
2042
2263
  fs3.rmSync(path6.join(outDir, `${role}.png`), { force: true });
2043
2264
  }
2265
+ const posed = (role) => role === "forearm_pose_L" || role === "forearm_pose_R";
2266
+ if (!placed.some((p) => posed(p.role))) {
2267
+ fs3.rmSync(path6.join(outDir, "preview-pose.png"), { force: true });
2268
+ }
2044
2269
  const layers = [];
2045
2270
  const preview = [];
2046
2271
  for (const { role, part, left, top } of placed) {
@@ -2055,7 +2280,7 @@ async function composeLayersFromParts(input) {
2055
2280
  left,
2056
2281
  top
2057
2282
  });
2058
- preview.push({ input: part.buf, left, top });
2283
+ if (!posed(role)) preview.push({ input: part.buf, left, top });
2059
2284
  }
2060
2285
  const previewPng = await sharp3({
2061
2286
  create: {
@@ -2067,12 +2292,42 @@ async function composeLayersFromParts(input) {
2067
2292
  }).composite(preview).png().toBuffer();
2068
2293
  const previewPath = path6.join(outDir, "preview.png");
2069
2294
  writeFileAtomic(previewPath, previewPng);
2295
+ let previewPosePath;
2296
+ if (placed.some((p) => posed(p.role))) {
2297
+ const pose = [];
2298
+ for (const { role, part, left, top, elbow } of placed) {
2299
+ const armPosed = elbow !== void 0 && placed.some(
2300
+ (p) => p.role === (role === "arm_L" ? "forearm_pose_L" : "forearm_pose_R")
2301
+ );
2302
+ if (!armPosed) {
2303
+ pose.push({ input: part.buf, left, top });
2304
+ continue;
2305
+ }
2306
+ const rows = Math.min(part.h, Math.max(1, Math.round(elbow.y - top)));
2307
+ pose.push({
2308
+ input: await sharp3(part.buf).extract({ left: 0, top: 0, width: part.w, height: rows }).png().toBuffer(),
2309
+ left,
2310
+ top
2311
+ });
2312
+ }
2313
+ const posePng = await sharp3({
2314
+ create: {
2315
+ width: canvas.width,
2316
+ height: canvas.height,
2317
+ channels: 4,
2318
+ background: { r: 245, g: 245, b: 248, alpha: 1 }
2319
+ }
2320
+ }).composite(pose).png().toBuffer();
2321
+ previewPosePath = path6.join(outDir, "preview-pose.png");
2322
+ writeFileAtomic(previewPosePath, posePng);
2323
+ }
2070
2324
  return {
2071
2325
  ok: true,
2072
2326
  outDir,
2073
2327
  layers,
2074
2328
  skipped,
2075
2329
  preview: previewPath,
2330
+ ...previewPosePath === void 0 ? {} : { previewPose: previewPosePath },
2076
2331
  measure: await measureDir(outDir, noseSpeck)
2077
2332
  };
2078
2333
  } catch (err) {
@@ -2086,7 +2341,7 @@ async function composeLayersFromParts(input) {
2086
2341
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2087
2342
  import { z } from "zod";
2088
2343
  function createIkiMcpServer() {
2089
- const server = new McpServer({ name: "iki", version: "0.19.0" });
2344
+ const server = new McpServer({ name: "iki", version: "0.20.0" });
2090
2345
  server.registerTool(
2091
2346
  "validate_iki",
2092
2347
  {
@@ -2151,7 +2406,7 @@ function createIkiMcpServer() {
2151
2406
  server.registerTool(
2152
2407
  "auto_rig_from_layers",
2153
2408
  {
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.",
2409
+ 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, forearm_pose_L/forearm_pose_R, etc. optional; an arm needs the body, and a pose forearm needs its arm) 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.",
2155
2410
  inputSchema: {
2156
2411
  layers: z.array(
2157
2412
  z.object({
@@ -2206,13 +2461,13 @@ function createIkiMcpServer() {
2206
2461
  server.registerTool(
2207
2462
  "compose_layers_from_parts",
2208
2463
  {
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`.",
2464
+ 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`). 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`.",
2210
2465
  inputSchema: {
2211
2466
  partsDir: z.string().describe(
2212
2467
  "Directory of the source part PNGs (resolved against cwd)."
2213
2468
  ),
2214
2469
  outDir: z.string().describe(
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."
2470
+ "Existing directory to write the role layer PNGs + preview.png (and preview-pose.png when there is a forearm_pose.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 or pose forearm once arm.png or forearm_pose.png is gone, preview-pose.png included \u2014 has its stale PNG from an earlier run deleted."
2216
2471
  ),
2217
2472
  layout: z.record(
2218
2473
  z.string(),
@@ -2223,10 +2478,10 @@ function createIkiMcpServer() {
2223
2478
  h: z.number()
2224
2479
  }).partial()
2225
2480
  ).optional().describe(
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."
2481
+ "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, 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, 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. 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."
2227
2482
  ),
2228
2483
  mirrorParts: z.array(z.string()).optional().describe(
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."
2484
+ "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."
2230
2485
  ),
2231
2486
  canvasHeight: z.number().optional().describe(
2232
2487
  "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."
@@ -2254,7 +2509,7 @@ function createIkiMcpServer() {
2254
2509
  server.registerTool(
2255
2510
  "measure_layers",
2256
2511
  {
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.",
2512
+ 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). 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.",
2258
2513
  inputSchema: {
2259
2514
  layersDir: z.string().describe(
2260
2515
  "Directory of role-named layer PNGs (resolved against cwd)."
@@ -2331,4 +2586,4 @@ export {
2331
2586
  composeLayersFromParts,
2332
2587
  createIkiMcpServer
2333
2588
  };
2334
- //# sourceMappingURL=chunk-E6DLZPCX.mjs.map
2589
+ //# sourceMappingURL=chunk-6F4ZP5S4.mjs.map