@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/README.md CHANGED
@@ -24,12 +24,12 @@ The `model` input for `validate_iki` and `describe_iki` accepts either a plain J
24
24
 
25
25
  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.
26
26
 
27
- - **`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`, and `mouth` or the lip set `mouth_inner`, `lip_lower`, `lip_upper` (a mouth that folds open instead of crossfading; a partial lip set, or one mixed with `mouth`/`mouth_open`, is refused). `mouth_tongue` / `mouth_teeth` are optional with the lip set only: drawn under its lips and clipped to `mouth_inner`, the teeth riding the upper line and the tongue the opening's bottom; without the set they are refused. 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).
27
+ - **`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`, and `mouth` or the lip set `mouth_inner`, `lip_lower`, `lip_upper` (a mouth that folds open instead of crossfading; a partial lip set, or one mixed with `mouth`/`mouth_open`, is refused). `mouth_tongue` / `mouth_teeth` are optional with the lip set only: drawn under its lips and clipped to `mouth_inner`, the teeth riding the upper line and the tongue the opening's bottom; without the set they are refused. 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`, `hair_side_L`/`hair_side_R`, etc. A side lock — the front lock hanging beside the ear, its root hidden under the bangs, drawn over the face, brows and lashes and under `hair_front` — needs `hair_front` (a lock without it is refused) and follows the face plate on the turn. 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).
28
28
  - **`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`.
29
29
  - **`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`.
30
30
  - **`rigPlan`** — optional per-character tuning from the profile the rig defaults to, in three groups: `turn` (`amount`: the whole head turn, ignored when `turnTargets.eyeShift` is given; `featureLead`: how far the features lead the face plate; `eyeForeshorten`: how much the far eye narrows on the turn, ignored when `turnTargets.farEyeRatio` is given; `noseLead`: how far the nose leads the plate on the turn, never the nod, ignored when `turnTargets.noseShift` is given — the last two have provisional recommended spans), `hair` (`follow`: the front hair's share of the face's turn; `outlineFollow`: its outer edge's share where it draws the head's outline; `sway`: the hair sway amplitude) and `eyes` (`blink`: how far the upper lid comes down over the eye's height). Call `describe_rig_plan` for each field's default, range, recommended span, step and poses. A value out of range, or a group or key not in the catalog, is refused as `INVALID: rigPlan.<path> …`. The old `style` input was removed in 0.30.0 and is refused with the map from each old knob to its `rigPlan` path.
31
31
  - **`patches`** — optional displacements added to existing keyform stops of the freshly generated rig, each `{ target, at, region, by, falloff?, why? }` (`RigPatch` in `@ikijs/editor`). `target` is a feature grid (`eyeWarp_L`/`_R`, `browWarp_L`/`_R`, `noseWarp`, `mouthWarp`; `at` names `ParamAngleX` and `ParamAngleY`, each −30, 0 or 30, never both 0) or a mesh part with warps (`face`, `hair_front`, …; `at` names one parameter at one of its warp stops). `region` is a rectangle in fractions of a role's rest layer box (top-left origin, y down); `by` and `falloff` are in face widths on screen axes (+dx right, +dy down). They are replayed on every rig of these inputs, so they hold through a layout or `rigPlan` retune, and they never touch the rest stop or a stop where the rig shuts a part on purpose; `bodyWarp` and the matrix deformers are not targets. Aim them with `describe_iki`.
32
- - **Result** — on success the result text is the written file path, then one `RIGPLAN: turn.amount=1 …` line (every plan field's effective value, each annotated with `(requested …, clamped at …)` where the art's room cut it or `(fitted by turnTargets.…)` where a cue fitted it), then one `PATCH <i> <target> at <Param=v …>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px` line per patch op (`(vertices)` in place of the columns and rows for a mesh part), then the rig's fold report lines and its `PHYSICS` lines (as `render_poses` prints them), and `structuredContent` carries `{ ok: true, path, canvas, partCount, atlasBytes, headHalfWidth?, headHalfWidthApplied, headEdges?, strandEdges?, noseCore?, turn?, patches?, folds, physics, rigPlan }`. `rigPlan` is `{ requested, effective, clamped, overriddenBy }` — the plan as passed, every field's value the rig built with, the plan-owned fields the room cut (`{ field, bound }`) and the fields a `turnTargets` cue fitted instead (path to cue); it is always present on a rigged model, and a result without it comes from a server before 0.30.0. `patches` is what each op moved (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`) and is present whenever `patches` was passed, `[]` included. `atlasBytes` is the embedded atlas's data-URI length, summed over both pages when the nose has one of its own. `headHalfWidth` is the head measured here rather than asked for: the layers' own opaque union at the eye row, under the same `alpha >= 128` rule and ±10-row band `measure_turn_reference` spans a render with, so the rig's own rest render measures that span back; it is **absent** when that union has no span there at all (translucent art painted below alpha 128 — still a valid layer set, just with nothing to measure). `headHalfWidthApplied` is `false` when the measured value is absent, or no wider than the face plate (a hairless set, or one widest at the plate itself) — the generator will not take such a head, so the plate stands in for it and the rig is still produced either way. `headEdges` is a companion to a measured, applied `headHalfWidth` (absent otherwise): every role with an opaque pixel in that same eye-row band, per side, each with its own rest x there — passed straight to the generator's own `options.headEdges` so it can tell which part's own deformation actually carries the union's outermost pixel through the turn. `strandEdges` is each side's iris and the `hair_front` run it would slide under on the turn, measured whenever the layers include `hair_front`, `iris_L` and `iris_R`: the iris's opaque span and the run's outer and face-side ends as pixel edges on the row holding the iris's centre (a run that reaches the other iris's centre, a fringe spanning the face, has `runFace: null`; a run narrower than half the iris's painted width on that row is hair detail the iris may cross, and is skipped as if clear) — passed straight to the generator's own `options.strandEdges`, which keeps the far iris from sliding under the bangs any further than it is painted. `turn` is what the solve settled on — `{ radius, holdBase, depths, achieved: { eyeShift, farEyeRatio, silhouetteRatio }, clamped, strandOverlap? }`, where `achieved` is what the rig does reach and `clamped` names every target the rig cut down: the turn (`eyeShift`, passed or the profile's own) where the face plate's edge or the strand cut it short, and a profile `noseShift` / `mouthShift` past its room. `strandOverlap` gives, per side whose far iris the bangs still cover at some far stop, the covered width — how much of the iris's painted row the run covers where that is largest (`deg`, `px`, and `hh` in head half-widths), how much it covers at rest (`restPx`), and whether the bound held (`held`: `true` means the iris is kept no deeper under the run than it is painted; `false` means the art left no room to — always so for a fringe spanning the face — and `px` is what stays covered); it is absent when nothing is covered. `noseCore` is the nose's dense core in canvas px — its pixels at alpha >= 128, not grown, the box handed to the generator as the nose layer's `denseCore` and its turn landmark — absent without a `nose` layer, when it has no pixel at that threshold (painted wholly translucent), or when that core is a speck of the nose's crop (under a quarter of its width or height, such as a lone nostril mark), and in both of the last two cases the crop stands in for it. `turn` is absent without a `nose` layer. `folds` is the written model's fold report, the engine's `checkFolds` over its own pose set (`{ poses, thresholds, targets, offenders }`, described under `render_poses`); it never refuses a rig — a model that folds is still written and returned — and each fold names its pose by its parameter settings, which a host reproduces by setting those parameters on a player (`IkiPlayer.setParameter`). `physics` is the written model's physics report, the engine's `checkPhysics` over its rigs (`{ thresholds, targets, offenders }`, described under `render_poses`) — the hair springs a `hair_front` layer brings (two for the front hair and, with `hair_back`, one for the back), or none — and never refuses a rig either. The (potentially multi-MB) model is written to disk, not inlined. Invalid input (a `patches` op the rig refuses — `INVALID: patches[i]…`, naming the stops, targets or roles there are; unknown/missing role, an arm without a `body`, empty layer, mismatched sizes, bad path, an atlas page over 4096 px on a side, or an atlas over 12 MiB; art the rig cannot build on, such as a body's hips with no room under its pivots for a row line or for the body's motion, or an arm too short to hang an elbow under its shoulder; a `turnTargets` field that is unknown or that this layer set cannot reach — any passed field other than an `eyeShift` past the art's room; a `rigPlan` field out of range or unknown, or the removed `style` input; the message names the field and the attainable range) returns `{ ok: false, error }` with a `INVALID: …` text — not a protocol error. An argument the tool's input schema refuses — a `turnTargets` or `rigPlan` that is not an object, or one of their named fields that is not a number — never reaches the tool: the MCP SDK answers with an `isError` result whose text is `MCP error -32602: Input validation error: …`, and no `structuredContent`.
32
+ - **Result** — on success the result text is the written file path, then one `RIGPLAN: turn.amount=1 …` line (every plan field's effective value, each annotated with `(requested …, clamped at …)` where the art's room cut it or `(fitted by turnTargets.…)` where a cue fitted it), then one `PATCH <i> <target> at <Param=v …>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px` line per patch op (`(vertices)` in place of the columns and rows for a mesh part), then the rig's fold report lines and its `PHYSICS` lines (as `render_poses` prints them), then, with side locks and a `nose` (which `turn` needs), the `HAIRSIDE` lines, and `structuredContent` carries `{ ok: true, path, canvas, partCount, atlasBytes, headHalfWidth?, headHalfWidthApplied, headEdges?, strandEdges?, noseCore?, turn?, patches?, folds, physics, rigPlan }`. `rigPlan` is `{ requested, effective, clamped, overriddenBy }` — the plan as passed, every field's value the rig built with, the plan-owned fields the room cut (`{ field, bound }`) and the fields a `turnTargets` cue fitted instead (path to cue); it is always present on a rigged model, and a result without it comes from a server before 0.30.0. `patches` is what each op moved (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`) and is present whenever `patches` was passed, `[]` included. `atlasBytes` is the embedded atlas's data-URI length, summed over both pages when the nose has one of its own. `headHalfWidth` is the head measured here rather than asked for: the layers' own opaque union at the eye row, under the same `alpha >= 128` rule and ±10-row band `measure_turn_reference` spans a render with, so the rig's own rest render measures that span back; it is **absent** when that union has no span there at all (translucent art painted below alpha 128 — still a valid layer set, just with nothing to measure). `headHalfWidthApplied` is `false` when the measured value is absent, or no wider than the face plate (a hairless set, or one widest at the plate itself) — the generator will not take such a head, so the plate stands in for it and the rig is still produced either way. `headEdges` is a companion to a measured, applied `headHalfWidth` (absent otherwise): every role with an opaque pixel in that same eye-row band, per side, each with its own rest x there — passed straight to the generator's own `options.headEdges` so it can tell which part's own deformation actually carries the union's outermost pixel through the turn. `strandEdges` is each side's iris and the `hair_front` run it would slide under on the turn, measured whenever the layers include `hair_front`, `iris_L` and `iris_R`: the iris's opaque span and the run's outer and face-side ends as pixel edges on the row holding the iris's centre (a run that reaches the other iris's centre, a fringe spanning the face, has `runFace: null`; a run narrower than half the iris's painted width on that row is hair detail the iris may cross, and is skipped as if clear) — passed straight to the generator's own `options.strandEdges`, which keeps the far iris from sliding under the bangs any further than it is painted. `turn` is what the solve settled on — `{ radius, holdBase, depths, achieved: { eyeShift, farEyeRatio, silhouetteRatio }, clamped, strandOverlap? }`, where `achieved` is what the rig does reach and `clamped` names every target the rig cut down: the turn (`eyeShift`, passed or the profile's own) where the face plate's edge or the strand cut it short, and a profile `noseShift` / `mouthShift` past its room. `strandOverlap` gives, per side whose far iris the bangs still cover at some far stop, the covered width — how much of the iris's painted row the run covers where that is largest (`deg`, `px`, and `hh` in head half-widths), how much it covers at rest (`restPx`), and whether the bound held (`held`: `true` means the iris is kept no deeper under the run than it is painted; `false` means the art left no room to — always so for a fringe spanning the face — and `px` is what stays covered); it is absent when nothing is covered. `noseCore` is the nose's dense core in canvas px — its pixels at alpha >= 128, not grown, the box handed to the generator as the nose layer's `denseCore` and its turn landmark — absent without a `nose` layer, when it has no pixel at that threshold (painted wholly translucent), or when that core is a speck of the nose's crop (under a quarter of its width or height, such as a lone nostril mark), and in both of the last two cases the crop stands in for it. `hairSide` (inside `turn`, present only with a side lock) is `{ left?, right? }` by screen side — `left` the lock at −x (`hair_side_R`), `right` at +x — each `{ role, cover?, tail?, unavailable? }`, report-only, measured as the far lock at its side's far stops (−15 and −30 on the left, 15 and 30 on the right), px, every x landed through the rendered rig: `cover` is `{ deg, px, y, rest }`, the least over the lock's rows on the face plate that cover the head's edge at rest (a root under the bangs, or the rows an ear shows beside the lock, lie inside it by design and do not count) and over the far stops of the lock's outer edge minus the head's edge (the plate's painted edge, with any ear replaced by the head's edge beneath it, so an ear does not count as cheek the lock covers), positive still covering it and negative the turn baring cheek the lock hides at rest, `rest` that row's cover at rest (≥ 0, read off the geometry; `px` may exceed it), `y` the row where it is least in model space (the canvas centre the origin, +y up — the line also gives it as model px from the top, the row of the layer PNG); `tail` is `{ deg, eyeToLock, lashToLock?, eyeToPlate }` for the far eye's outer corner on the eye's centre row at the stop where `eyeToLock` is least — the corner against the lock's face-side edge, positive a gap and negative under the lock (intended), `lashToLock` the same for the lash box with a `lash_*` layer, and `eyeToPlate` the corner's signed distance from that head edge (positive: inside it; negative: past it). A metric that cannot be read is omitted; a lock measured without `rowRuns` (never the case through this tool) carries `unavailable` (a reason) and nothing else. The result text prints them as `HAIRSIDE cover <role>: …` / `HAIRSIDE tail <role>: …` lines, one per metric present, the lock named by its role (`hair_side_R` hangs on the screen left), the pose as the setting that reproduces it (`ParamAngleX=-30`) and every edge distance signed to one decimal in model px (`+0.0` for zero); a lock with neither prints `HAIRSIDE <role>: no cover or tail row`, one carrying `unavailable` prints `HAIRSIDE <role>: unavailable — <why>`; a set with no side lock prints none. `turn` is absent without a `nose` layer. `folds` is the written model's fold report, the engine's `checkFolds` over its own pose set (`{ poses, thresholds, targets, offenders }`, described under `render_poses`); it never refuses a rig — a model that folds is still written and returned — and each fold names its pose by its parameter settings, which a host reproduces by setting those parameters on a player (`IkiPlayer.setParameter`). `physics` is the written model's physics report, the engine's `checkPhysics` over its rigs (`{ thresholds, targets, offenders }`, described under `render_poses`) — the hair springs a `hair_front` layer brings (two for the front hair and, with `hair_back`, one for the back), or none — and never refuses a rig either. The (potentially multi-MB) model is written to disk, not inlined. Invalid input (a `patches` op the rig refuses — `INVALID: patches[i]…`, naming the stops, targets or roles there are; unknown/missing role, an arm without a `body`, empty layer, mismatched sizes, bad path, an atlas page over 4096 px on a side, or an atlas over 12 MiB; art the rig cannot build on, such as a body's hips with no room under its pivots for a row line or for the body's motion, or an arm too short to hang an elbow under its shoulder; a `turnTargets` field that is unknown or that this layer set cannot reach — any passed field other than an `eyeShift` past the art's room; a `rigPlan` field out of range or unknown, or the removed `style` input; the message names the field and the attainable range) returns `{ ok: false, error }` with a `INVALID: …` text — not a protocol error. An argument the tool's input schema refuses — a `turnTargets` or `rigPlan` that is not an object, or one of their named fields that is not a number — never reaches the tool: the MCP SDK answers with an `isError` result whose text is `MCP error -32602: Input validation error: …`, and no `structuredContent`.
33
33
 
34
34
  The decode/atlas pipeline runs in Node via `sharp` (a native dependency confined to this package); it mirrors the browser editor app's import flow and reuses the pure `@ikijs/editor` model + atlas math, so both paths produce the same rig. The fold and physics checks run the workspace `@ikijs/engine`, inlined into this package's Node build (as it already is into the `render_poses` page script), while `@ikijs/format` stays an external dependency.
35
35
 
@@ -37,16 +37,16 @@ The decode/atlas pipeline runs in Node via `sharp` (a native dependency confined
37
37
 
38
38
  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.
39
39
 
40
- - **`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. So is the lid's skin drawn attached above the white, a warm light band over the lash, in the columns that have a lash there — a band over a lash-free column, such as the tear duct, stays, as the white's own warm shading would — while the eye's frame stays the drawing's), `iris.png`, `brow.png`, `hair_front.png`, and a mouth by one of two routes: `mouth.png` (a closed drawing, with an optional `mouth_open.png` it cross-fades to), or the lip set — `mouth_keyed.png` (the open mouth, its inside painted ONE 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: the teeth, the tongue) is written as `mouth_teeth` and `mouth_tongue` on the same frame, split at each column's middle, riding the upper line and the opening's bottom and clipped to the cavity; `mouth_inner` takes the cavity's fill under it, its edge softened by the key's own coverage. An interior with no light paint writes neither and lists them in `skipped`. The key reads each antialiased pixel against its own ramp to the art's green, the interior is trimmed of the lip rim a generator draws round it, and the split is cut at the composed size so every boundary meets the rig's per-column contract by construction. The lip set is opt-in: with neither file the legacy route runs; one without the other, or either beside `mouth.png` / `mouth_open.png`, is refused naming the file to draw or remove. With the set, `mouth` and `mouth_open` are neither written nor listed in `skipped`. Optional: `hair_back.png`, `body.png`, `mouth_open.png` (legacy route), `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.
40
+ - **`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. So is the lid's skin drawn attached above the white, a warm light band over the lash, in the columns that have a lash there — a band over a lash-free column, such as the tear duct, stays, as the white's own warm shading would — while the eye's frame stays the drawing's), `iris.png`, `brow.png`, `hair_front.png`, and a mouth by one of two routes: `mouth.png` (a closed drawing, with an optional `mouth_open.png` it cross-fades to), or the lip set — `mouth_keyed.png` (the open mouth, its inside painted ONE 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: the teeth, the tongue) is written as `mouth_teeth` and `mouth_tongue` on the same frame, split at each column's middle, riding the upper line and the opening's bottom and clipped to the cavity; `mouth_inner` takes the cavity's fill under it, its edge softened by the key's own coverage. An interior with no light paint writes neither and lists them in `skipped`. The key reads each antialiased pixel against its own ramp to the art's green, the interior is trimmed of the lip rim a generator draws round it, and the split is cut at the composed size so every boundary meets the rig's per-column contract by construction. The lip set is opt-in: with neither file the legacy route runs; one without the other, or either beside `mouth.png` / `mouth_open.png`, is refused naming the file to draw or remove. With the set, `mouth` and `mouth_open` are neither written nor listed in `skipped`. Optional: `hair_back.png`, `body.png`, `mouth_open.png` (legacy route), `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 `hair_side.png` — the front side lock on the screen left, hanging beside the ear with its root at the image's top — makes both locks: `hair_side_R` takes it as drawn and `hair_side_L` mirrored, drawn over the face, brows and lashes and under `hair_front`, and each is retuned through `layout.hair_side_L` / `layout.hair_side_R`. It is optional: without it both are listed in `skipped`. The rig needs a `hair_front` beside a lock. 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.
41
41
  - **`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.
42
- - **`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`, `mouth_inner`, 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. `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 set the nose's tip rule reads `layout.mouth_inner.cy`. 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.
43
- - **`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.
42
+ - **`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`, `mouth_inner`, eyes, irises, lashes, brows, side locks — 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. `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 set the nose's tip rule reads `layout.mouth_inner.cy`. 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.
43
+ - **`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; `hair_side.png` as the front side lock on the screen left, its root 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.
44
44
  - **`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.
45
45
  - **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`). With the lip set `preview.png` shows the mouth closed, as the rig draws the rest pose (the tongue and the teeth left out with the interior), and `skipped` lists `mouth_tongue` / `mouth_teeth` when the interior has no light paint. 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`, a lip set with one source missing or beside the legacy mouth, a key that fails (no green, green outside the opening, an outline not closed round it, more than one opening, no skin under it, an interior that is only lips or drawn opaque on a non-white or noisy ground), 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.
46
46
 
47
47
  ### `measure_layers`
48
48
 
49
- 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, 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, and for the lip set: a partial set or one beside `mouth` / `mouth_open`, a column of the opening where the interior does not reach the line or the skin does not reach the interior, an opening under 0.3 of the upper lip's width or under 8 rows tall, a line under 2 rows, key green left, an interior with transparent holes, and a `mouth_tongue` / `mouth_teeth` with no lip set, on another canvas, or whose box leaves `mouth_inner`'s, where the cavity clips it away), 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.
49
+ 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, for a side lock: one 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, and a `hair_side.png` drawing two locks (a lock set on another canvas than `hair_front`'s is warned of too), 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, 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, and for the lip set: a partial set or one beside `mouth` / `mouth_open`, a column of the opening where the interior does not reach the line or the skin does not reach the interior, an opening under 0.3 of the upper lip's width or under 8 rows tall, a line under 2 rows, key green left, an interior with transparent holes, and a `mouth_tongue` / `mouth_teeth` with no lip set, on another canvas, or whose box leaves `mouth_inner`'s, where the cavity clips it away), 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.
50
50
 
51
51
  - **`layersDir`** — directory of role-named layer PNGs (resolved against the working directory). Every `preview*.png` in it is skipped.
52
52
  - **Result** — the text is the report: a per-layer size/bbox-centre/mass-centre/margins table, then, with a lip set, one `lips:` line — the opening's width, its height at the centre, the line's rows and the `MouthOpen` below which no slit shows — then the checks that fired. `structuredContent` is `{ ok: true, layersDir, layers, empty, warnings, lips?, passed }`. A missing or non-directory `layersDir` returns `{ ok: false, error }` with `INVALID: …` text.
@@ -4151,11 +4151,189 @@ function capWarning(arm, g, body) {
4151
4151
  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).`;
4152
4152
  }
4153
4153
 
4154
+ // src/measure-hair-side.ts
4155
+ import {
4156
+ createLayerSetMeasurer as createLayerSetMeasurer3
4157
+ } from "@ikijs/editor";
4158
+ var LOCK_ROLES = ["hair_side_R", "hair_side_L"];
4159
+ var VISIBLE_MIN_PX = 3;
4160
+ var LEAN_HH = 0.12;
4161
+ var TWO_LOCKS_RUN = 0.25;
4162
+ var TWO_LOCKS_GAP = 0.1;
4163
+ function covers(runs, x) {
4164
+ for (let i = 0; i + 1 < runs.length; i += 2) {
4165
+ if (x >= runs[i] && x < runs[i + 1]) return true;
4166
+ }
4167
+ return false;
4168
+ }
4169
+ function runsAt(layer, y) {
4170
+ return layer?.rowRuns?.[y - layer.bbox.y] ?? [];
4171
+ }
4172
+ function opaqueRows(layer) {
4173
+ const runs = layer.rowRuns ?? [];
4174
+ const top = runs.findIndex((r) => r.length > 0);
4175
+ if (top < 0) return void 0;
4176
+ let bottom = runs.length - 1;
4177
+ while (runs[bottom].length === 0) bottom--;
4178
+ return { top: layer.bbox.y + top, bottom: layer.bbox.y + bottom };
4179
+ }
4180
+ async function hairSideWarnings(absDir, layers) {
4181
+ const present = LOCK_ROLES.filter((r) => layers[r] !== void 0);
4182
+ if (present.length === 0) return [];
4183
+ const warnings = [];
4184
+ if (layers.hair_front === void 0) {
4185
+ for (const role of present) {
4186
+ warnings.push(
4187
+ `${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.`
4188
+ );
4189
+ }
4190
+ return warnings;
4191
+ }
4192
+ const ref = layers.hair_front;
4193
+ let mismatched = false;
4194
+ for (const r of [...present, "hair_back", "face"]) {
4195
+ const stats = layers[r];
4196
+ if (stats === void 0) continue;
4197
+ if (stats.canvasW !== ref.canvasW || stats.canvasH !== ref.canvasH) {
4198
+ mismatched = true;
4199
+ warnings.push(
4200
+ `${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.`
4201
+ );
4202
+ }
4203
+ }
4204
+ if (mismatched) return warnings;
4205
+ const measurer = createLayerSetMeasurer3({
4206
+ width: ref.canvasW,
4207
+ height: ref.canvasH
4208
+ });
4209
+ const read = (role) => layers[role] === void 0 ? void 0 : measured(measurer, absDir, role);
4210
+ const front = await read("hair_front");
4211
+ const back = await read("hair_back");
4212
+ const face = await read("face");
4213
+ const axisX = face ? face.bbox.x + face.bbox.w / 2 : ref.canvasW / 2;
4214
+ const locks = /* @__PURE__ */ new Map();
4215
+ for (const role of present) {
4216
+ const lock = await measured(measurer, absDir, role);
4217
+ locks.set(role, lock);
4218
+ const side = lock.bbox.x + lock.bbox.w / 2 < axisX ? -1 : 1;
4219
+ const eyeRole = ["eye_L", "eye_R"].find(
4220
+ (r) => layers[r] !== void 0 && (layers[r].bboxCx < axisX ? -1 : 1) === side
4221
+ );
4222
+ const eye = eyeRole === void 0 ? void 0 : layers[eyeRole];
4223
+ const root = rootWarning(role, lock, front);
4224
+ if (root !== void 0) warnings.push(root);
4225
+ if (eyeRole !== void 0 && eye !== void 0) {
4226
+ const w = eyeCornerWarning(role, lock, side, eyeRole, eye);
4227
+ if (w !== void 0) warnings.push(w);
4228
+ }
4229
+ const rowEye = eye ?? layers.eye_L ?? layers.eye_R;
4230
+ if (face !== void 0 && rowEye !== void 0) {
4231
+ const w = leanWarning(role, lock, side, face, back, rowEye);
4232
+ if (w !== void 0) warnings.push(w);
4233
+ }
4234
+ }
4235
+ if (drawsTwoLocks(locks.get("hair_side_R") ?? locks.get(present[0]))) {
4236
+ warnings.push(
4237
+ `hair_side.png draws two locks \u2014 draw ONE lock, the screen-left one; the composer mirrors it into hair_side_L. Billed.`
4238
+ );
4239
+ }
4240
+ return warnings;
4241
+ }
4242
+ function rootWarning(role, lock, front) {
4243
+ const y = opaqueRows(lock)?.top;
4244
+ if (y === void 0) return void 0;
4245
+ const frontRuns = runsAt(front, y);
4246
+ const lockRuns = runsAt(lock, y);
4247
+ let shown = 0;
4248
+ for (let i = 0; i + 1 < lockRuns.length; i += 2) {
4249
+ let stretch = 0;
4250
+ for (let x = lockRuns[i]; x <= lockRuns[i + 1]; x++) {
4251
+ if (x < lockRuns[i + 1] && !covers(frontRuns, x)) {
4252
+ stretch++;
4253
+ continue;
4254
+ }
4255
+ if (stretch >= VISIBLE_MIN_PX) shown += stretch;
4256
+ stretch = 0;
4257
+ }
4258
+ }
4259
+ if (shown === 0) return void 0;
4260
+ 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.`;
4261
+ }
4262
+ function eyeCornerWarning(role, lock, side, eyeRole, eye) {
4263
+ const row = Math.floor(eye.bboxCy);
4264
+ const corner = side < 0 ? eye.marginLeft : eye.marginLeft + eye.w - 1;
4265
+ const runs = runsAt(lock, row);
4266
+ let overlap = 0;
4267
+ for (let i = 0; i + 1 < runs.length; i += 2) {
4268
+ if (corner < runs[i] || corner >= runs[i + 1]) continue;
4269
+ overlap = side < 0 ? runs[i + 1] - corner : corner - runs[i] + 1;
4270
+ }
4271
+ if (overlap < VISIBLE_MIN_PX) return void 0;
4272
+ 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.`;
4273
+ }
4274
+ function leanWarning(role, lock, side, face, back, eye) {
4275
+ const faceRows = opaqueRows(face);
4276
+ const lockRows = opaqueRows(lock);
4277
+ if (faceRows === void 0 || lockRows === void 0) return void 0;
4278
+ const faceBottom = faceRows.bottom;
4279
+ const lean = Math.round(LEAN_HH * (faceBottom - Math.floor(eye.bboxCy)));
4280
+ if (lean < 1) return void 0;
4281
+ const bare = /* @__PURE__ */ new Set();
4282
+ const rows = /* @__PURE__ */ new Set();
4283
+ for (let y = lockRows.top; y <= Math.min(lockRows.bottom, faceBottom); y++) {
4284
+ const runs = runsAt(lock, y);
4285
+ if (runs.length === 0) continue;
4286
+ const from = side < 0 ? runs[0] : runs[runs.length - 2];
4287
+ const to = side < 0 ? runs[1] : runs[runs.length - 1];
4288
+ const start = side < 0 ? from : Math.max(from, to - lean);
4289
+ const end = side < 0 ? Math.min(to, from + lean) : to;
4290
+ const faceRuns = runsAt(face, y);
4291
+ const backRuns = runsAt(back, y);
4292
+ for (let x = start; x < end; x++) {
4293
+ if (covers(faceRuns, x) || covers(backRuns, x)) continue;
4294
+ bare.add(x);
4295
+ rows.add(y);
4296
+ }
4297
+ }
4298
+ if (bare.size === 0) return void 0;
4299
+ const cols = [...bare].sort((a, b) => a - b);
4300
+ const ys = [...rows].sort((a, b) => a - b);
4301
+ const where = `leaves bare pixels spanning columns ${cols[0]}\u2013${cols[cols.length - 1]}, rows ${ys[0]}\u2013${ys[ys.length - 1]}`;
4302
+ const lead = `${role}: when the head turns away from it the lock leans inward about ${lean} px and ${where}, where`;
4303
+ if (back === void 0) {
4304
+ return `${lead} the face is not painted \u2014 draw hair_back.png behind the locks. Billed.`;
4305
+ }
4306
+ 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.`;
4307
+ }
4308
+ function drawsTwoLocks(lock) {
4309
+ const w = lock.bbox.w;
4310
+ const col = new Array(w).fill(false);
4311
+ for (const runs of lock.rowRuns ?? []) {
4312
+ for (let i = 0; i + 1 < runs.length; i += 2) {
4313
+ for (let x = runs[i]; x < runs[i + 1]; x++) col[x - lock.bbox.x] = true;
4314
+ }
4315
+ }
4316
+ const big = [];
4317
+ let start = -1;
4318
+ for (let x = 0; x <= w; x++) {
4319
+ if (x < w && col[x]) {
4320
+ if (start < 0) start = x;
4321
+ } else if (start >= 0) {
4322
+ if (x - start >= TWO_LOCKS_RUN * w) big.push([start, x]);
4323
+ start = -1;
4324
+ }
4325
+ }
4326
+ for (let i = 1; i < big.length; i++) {
4327
+ if (big[i][0] - big[i - 1][1] >= TWO_LOCKS_GAP * w) return true;
4328
+ }
4329
+ return false;
4330
+ }
4331
+
4154
4332
  // src/measure-forearm-pose.ts
4155
4333
  import {
4156
4334
  LayerGeometryError as LayerGeometryError3,
4157
4335
  armGeometry as armGeometry2,
4158
- createLayerSetMeasurer as createLayerSetMeasurer3,
4336
+ createLayerSetMeasurer as createLayerSetMeasurer4,
4159
4337
  forearmPoseGeometry
4160
4338
  } from "@ikijs/editor";
4161
4339
  var POSE_ROLES = ["forearm_pose_L", "forearm_pose_R"];
@@ -4191,7 +4369,7 @@ async function forearmPoseWarnings(absDir, layers) {
4191
4369
  continue;
4192
4370
  }
4193
4371
  if (layers.body === void 0) continue;
4194
- const measurer = createLayerSetMeasurer3({
4372
+ const measurer = createLayerSetMeasurer4({
4195
4373
  width: stats.canvasW,
4196
4374
  height: stats.canvasH
4197
4375
  });
@@ -4250,7 +4428,7 @@ import {
4250
4428
  LIP_ROLES,
4251
4429
  LayerGeometryError as LayerGeometryError4,
4252
4430
  columnRuns as columnRuns2,
4253
- createLayerSetMeasurer as createLayerSetMeasurer5,
4431
+ createLayerSetMeasurer as createLayerSetMeasurer6,
4254
4432
  isLipInsideRole,
4255
4433
  mouthOpening as mouthOpening2
4256
4434
  } from "@ikijs/editor";
@@ -4260,7 +4438,7 @@ import sharp2 from "sharp";
4260
4438
  import {
4261
4439
  ALPHA_OPAQUE as ALPHA_OPAQUE3,
4262
4440
  columnRuns,
4263
- createLayerSetMeasurer as createLayerSetMeasurer4,
4441
+ createLayerSetMeasurer as createLayerSetMeasurer5,
4264
4442
  mouthOpening,
4265
4443
  mouthRestShift
4266
4444
  } from "@ikijs/editor";
@@ -4705,7 +4883,7 @@ function enclosedHole(frame, w, h) {
4705
4883
  return { label, main, box: box2 };
4706
4884
  }
4707
4885
  function measureLips(layers, w, h) {
4708
- const measurer = createLayerSetMeasurer4({ width: w, height: h });
4886
+ const measurer = createLayerSetMeasurer5({ width: w, height: h });
4709
4887
  return new Map(
4710
4888
  Object.entries(layers).map(([role, rgba]) => [
4711
4889
  role,
@@ -4985,7 +5163,7 @@ async function lipWarnings(absDir, layers) {
4985
5163
  );
4986
5164
  }
4987
5165
  }
4988
- const measurer = createLayerSetMeasurer5({
5166
+ const measurer = createLayerSetMeasurer6({
4989
5167
  width: inner.canvasW,
4990
5168
  height: inner.canvasH
4991
5169
  });
@@ -5275,6 +5453,7 @@ async function measureDir(absDir, noseSpeck) {
5275
5453
  warnings.push(...await forearmPoseWarnings(absDir, layers));
5276
5454
  const lip = await lipWarnings(absDir, layers);
5277
5455
  warnings.push(...lip.warnings);
5456
+ warnings.push(...await hairSideWarnings(absDir, layers));
5278
5457
  for (const side of ["L", "R"]) {
5279
5458
  const eye = layers[`eye_${side}`];
5280
5459
  const iris = layers[`iris_${side}`];
@@ -5418,14 +5597,14 @@ import sharp3 from "sharp";
5418
5597
  import {
5419
5598
  LayerGeometryError as LayerGeometryError5,
5420
5599
  armGeometry as armGeometry3,
5421
- createLayerSetMeasurer as createLayerSetMeasurer6,
5600
+ createLayerSetMeasurer as createLayerSetMeasurer7,
5422
5601
  forearmPoseGeometry as forearmPoseGeometry2
5423
5602
  } from "@ikijs/editor";
5424
5603
  var ARM_WIDTH = 0.4;
5425
5604
  var SHOULDER_DROP = 0.12;
5426
5605
  async function armPlacement(role, cfg, part, body) {
5427
5606
  const { data } = await sharp3(part.buf).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
5428
- const layer = createLayerSetMeasurer6({ width: part.w, height: part.h }).add({
5607
+ const layer = createLayerSetMeasurer7({ width: part.w, height: part.h }).add({
5429
5608
  role,
5430
5609
  fileName: "arm.png",
5431
5610
  rgba: data
@@ -5466,7 +5645,7 @@ async function armPlacement(role, cfg, part, body) {
5466
5645
  }
5467
5646
  async function poseGeometryOf(role, png, size, when) {
5468
5647
  const { data } = await sharp3(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
5469
- const layer = createLayerSetMeasurer6({
5648
+ const layer = createLayerSetMeasurer7({
5470
5649
  width: size.w,
5471
5650
  height: size.h
5472
5651
  }).add({ role, fileName: "forearm_pose.png", rgba: data });
@@ -5592,6 +5771,23 @@ var DEFAULT_LAYOUT = {
5592
5771
  // prettier-ignore
5593
5772
  brow_L: { src: "brow.png", cx: 645, cy: 405, w: 105, mirror: false },
5594
5773
  brow_R: { src: "brow.png", cx: 455, cy: 405, w: 105, mirror: true },
5774
+ // The front side locks, one part for both: hair_side_R (screen left) takes
5775
+ // hair_side.png as drawn and hair_side_L mirrors it, like the blush. They
5776
+ // draw over the face, brows and lashes and under the bangs. Mint's tuned
5777
+ // placement (cy 545 at mint's face cy 431, carried to the default face:
5778
+ // 437 + 114 = 551), tuned per character through `layout.hair_side_*`: the
5779
+ // lock's root top lies above the brow row (405) so the bangs' temple hides it
5780
+ // (for a 1:5 lock, whose height follows the image's aspect: w 90 is 450 tall,
5781
+ // so cy 551 puts the top at 326), and the lock runs from the temple over the
5782
+ // front of the ear and down along the cheek's edge, the ear's rim and lobe
5783
+ // showing beside it. Its box overlaps the eye's by about 15 px at the
5784
+ // default face, fine only because a drawn lock's root tapers (the measure's "covers
5785
+ // the eye's outer corner" check catches a lock that does not).
5786
+ // OPTIONAL: a parts dir without it composes.
5787
+ hair_side_L: { src: "hair_side.png", cx: 715, cy: 551, w: 90, optional: true, mirror: true },
5788
+ // prettier-ignore
5789
+ hair_side_R: { src: "hair_side.png", cx: 385, cy: 551, w: 90, optional: true, mirror: false },
5790
+ // prettier-ignore
5595
5791
  hair_front: { src: "hair_front.png", cx: 550, cy: 425, w: 660 },
5596
5792
  // The pose forearms, one drawing for both: forearm_pose_R (screen left)
5597
5793
  // takes forearm_pose.png as drawn and forearm_pose_L mirrors it, like the
@@ -5630,6 +5826,8 @@ var ORDER = [
5630
5826
  "lash_R",
5631
5827
  "brow_L",
5632
5828
  "brow_R",
5829
+ "hair_side_L",
5830
+ "hair_side_R",
5633
5831
  "hair_front",
5634
5832
  "forearm_pose_L",
5635
5833
  "forearm_pose_R"
@@ -5654,7 +5852,9 @@ var FACE_FEATURES = [
5654
5852
  "lash_L",
5655
5853
  "lash_R",
5656
5854
  "brow_L",
5657
- "brow_R"
5855
+ "brow_R",
5856
+ "hair_side_L",
5857
+ "hair_side_R"
5658
5858
  ];
5659
5859
  function resolveLayout(overrides, canvas) {
5660
5860
  const resolved = { ...DEFAULT_LAYOUT };
@@ -6422,6 +6622,40 @@ async function composeLayersFromParts(input) {
6422
6622
  }
6423
6623
  }
6424
6624
 
6625
+ // src/hair-side-report.ts
6626
+ function signedPx(px2) {
6627
+ const s = px2.toFixed(1);
6628
+ if (s === "-0.0") return "+0.0";
6629
+ return s.startsWith("-") ? s : `+${s}`;
6630
+ }
6631
+ function formatHairSideReport(hairSide, canvas) {
6632
+ if (hairSide === void 0) return [];
6633
+ return [hairSide.left, hairSide.right].flatMap(
6634
+ (room) => room === void 0 ? [] : roomLines(room, canvas)
6635
+ );
6636
+ }
6637
+ function roomLines(room, canvas) {
6638
+ const { role, cover, tail, unavailable } = room;
6639
+ if (unavailable !== void 0) {
6640
+ return [`HAIRSIDE ${role}: unavailable \u2014 ${unavailable}`];
6641
+ }
6642
+ const lines = [];
6643
+ if (cover !== void 0) {
6644
+ const row = Math.floor(canvas.height / 2 - cover.y);
6645
+ lines.push(
6646
+ `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)`
6647
+ );
6648
+ }
6649
+ if (tail !== void 0) {
6650
+ const lash = tail.lashToLock === void 0 ? "" : ` / lash ${signedPx(tail.lashToLock)} model px`;
6651
+ lines.push(
6652
+ `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)`
6653
+ );
6654
+ }
6655
+ if (lines.length === 0) lines.push(`HAIRSIDE ${role}: no cover or tail row`);
6656
+ return lines;
6657
+ }
6658
+
6425
6659
  // src/physics-report.ts
6426
6660
  function formatPhysicsReport(report) {
6427
6661
  if (report.targets.length === 0) return ["PHYSICS: no rigs"];
@@ -6449,7 +6683,7 @@ function formatPatchReports(reports) {
6449
6683
  });
6450
6684
  }
6451
6685
  function createIkiMcpServer() {
6452
- const server = new McpServer({ name: "iki", version: "0.32.0" });
6686
+ const server = new McpServer({ name: "iki", version: "0.33.1" });
6453
6687
  server.registerTool(
6454
6688
  "validate_iki",
6455
6689
  {
@@ -6541,7 +6775,7 @@ function createIkiMcpServer() {
6541
6775
  server.registerTool(
6542
6776
  "auto_rig_from_layers",
6543
6777
  {
6544
- 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.",
6778
+ 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.",
6545
6779
  inputSchema: {
6546
6780
  layers: z.array(
6547
6781
  z.object({
@@ -6618,7 +6852,8 @@ function createIkiMcpServer() {
6618
6852
  formatRigPlanReport(r.rigPlan),
6619
6853
  ...formatPatchReports(r.patches ?? []),
6620
6854
  ...formatFoldReport(r.folds, r.canvas),
6621
- ...formatPhysicsReport(r.physics)
6855
+ ...formatPhysicsReport(r.physics),
6856
+ ...formatHairSideReport(r.turn?.hairSide, r.canvas)
6622
6857
  ].join("\n") : `INVALID: ${r.error}`;
6623
6858
  return { content: [{ type: "text", text }], structuredContent: r };
6624
6859
  } catch (err) {
@@ -6634,7 +6869,7 @@ function createIkiMcpServer() {
6634
6869
  server.registerTool(
6635
6870
  "compose_layers_from_parts",
6636
6871
  {
6637
- 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`.",
6872
+ 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`.",
6638
6873
  inputSchema: {
6639
6874
  partsDir: z.string().describe(
6640
6875
  "Directory of the source part PNGs (resolved against cwd)."
@@ -6651,10 +6886,10 @@ function createIkiMcpServer() {
6651
6886
  h: z.number()
6652
6887
  }).partial()
6653
6888
  ).optional().describe(
6654
- "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."
6889
+ "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."
6655
6890
  ),
6656
6891
  mirrorParts: z.array(z.string()).optional().describe(
6657
- "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."
6892
+ "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."
6658
6893
  ),
6659
6894
  canvasHeight: z.number().optional().describe(
6660
6895
  "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."
@@ -6682,7 +6917,7 @@ function createIkiMcpServer() {
6682
6917
  server.registerTool(
6683
6918
  "measure_layers",
6684
6919
  {
6685
- 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.",
6920
+ 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.",
6686
6921
  inputSchema: {
6687
6922
  layersDir: z.string().describe(
6688
6923
  "Directory of role-named layer PNGs (resolved against cwd)."
@@ -6853,7 +7088,8 @@ export {
6853
7088
  measureLayers,
6854
7089
  formatMeasureReport,
6855
7090
  composeLayersFromParts,
7091
+ formatHairSideReport,
6856
7092
  formatPhysicsReport,
6857
7093
  createIkiMcpServer
6858
7094
  };
6859
- //# sourceMappingURL=chunk-576N2JWR.mjs.map
7095
+ //# sourceMappingURL=chunk-VTJEYDRK.mjs.map