@ikijs/mcp 0.38.2 → 0.39.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 +2 -1
- package/dist/{chunk-I4P7THTB.mjs → chunk-3XQLLYUF.mjs} +144 -14
- package/dist/chunk-3XQLLYUF.mjs.map +1 -0
- package/dist/cli.js +140 -16
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +331 -203
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/render-page.global.js +132 -17
- package/package.json +4 -4
- package/dist/chunk-I4P7THTB.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ A stdio [MCP](https://modelcontextprotocol.io/) server that exposes `.iki` model
|
|
|
9
9
|
| Tool | Description |
|
|
10
10
|
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
11
11
|
| `validate_iki` | Validate a raw `.iki` model — accepts an object or a JSON string — fail-fast, one error at a time. |
|
|
12
|
-
| `describe_iki` | Return a summary of a valid model (inline or by `modelPath`): canvas, parameters, parts, deformers, expressions, motions.
|
|
12
|
+
| `describe_iki` | Return a summary of a valid model (inline or by `modelPath`): canvas, parameters, parts, deformers, expressions, motions, and its `generator` when it records one. |
|
|
13
13
|
| `list_standard_parameters` | List the recommended standard parameter ids (e.g. `ParamAngleX`, `ParamMouthOpenY`) with descriptions. |
|
|
14
14
|
| `describe_rig_plan` | List the fields of `auto_rig_from_layers`'s `rigPlan` with their defaults, ranges, recommended spans, steps and poses. |
|
|
15
15
|
| `auto_rig_from_layers` | Auto-rig role-named PNG layers into a renderable `.iki` written to disk; returns the output path. |
|
|
@@ -36,6 +36,7 @@ Turns a set of role-named, full-canvas transparent PNG layers into a renderable,
|
|
|
36
36
|
- **`bakes`** — optional lattices that move the custom parts when a parameter does, which an unrigged custom part otherwise does not: `{ targets, meshes? }` (`RigBakes` in `@ikijs/editor`; it needs `customParts` and names no other part). A target `{ id?, param, parts, box?, grid: { cols, rows }, stops, mirror?, why? }` is `(cols + 1) x (rows + 1)` control points laid evenly over `box` (canvas px; absent, the union of the parts' rest boxes grown by 2 px), listed row-major from the top-left, with a `[dx, dy]` per point at each stop. Every position and displacement is in canvas px, origin top-left, y down. A stop is the part's TOTAL landed displacement from rest when `param` alone is at that value and every other parameter is at its default, so the head's own carry is inside it and a neighbour's displacement as `probe_rig` measures it is written as it is. Stop keys are values of `param` inside its range, never its default. The landing is exact at rest, at each stop and at one end key the rig writes at the range end on a side whose outermost stop is inside the range (it holds that stop's displacement); a side with no stop is not moved. Between two keys the part's offsets are blended linearly, so under the head's roll the path bows off the line (about 1 px midway over 15°): put a stop where the path matters. Each vertex takes the bilinear value of the lattice at its rest position, and a vertex outside `box` takes the nearest edge's value. `mirror: true` fills a missing stop from the one at the mirrored value, when that value is inside the parameter's range (the lattice reflected about the box's vertical centre line, `dx` negated). Targets that name the same part and parameter sum. `meshes` re-meshes a custom part first (`{ rows, cols }` or `{ cellPx }`). The written model is landed through the engine at every stop and at the range end each side holds its outermost stop to, and compared with the displacement the generator was asked for; a stop off by 0.1 px or more is `INVALID: BAKE ERROR <part> <param>=<value>: …`, and a part the bake moves at rest by as much is `INVALID: BAKE ERROR <part> at rest: …`; both mean the rig and the engine disagree (a bug in the packages, not in the input), and nothing is written, and an input the rig refuses is `INVALID: bakes…` with its path (`bakes.targets[2].stops["30"][7]`), nothing written either. Needs 0.34.0.
|
|
37
37
|
- **The custom gate** — whenever `customParts` is passed the written model is also measured, per custom part, over a pose set: the engine's fold poses, each of the part's own stops alone, and for every pair of parameters it is baked on every combination of their stops (the stops of a part's `occlusion` on its key parameter count as its stops here). Lengths are in face widths (the `face` part's width), so no limit is tied to one canvas; the values are the experiment's over a 402 px face. Lines: `FOLDS` (the part's least triangle area ratio, ≥ 0.1, the engine's collapse); `TIE` (at the tie and a ring around it (5 px on a 402 px face, scaled with the face width), the part's displacement less the anchor's, the largest over the poses where `ParamAngleX` is at its default, ≤ 0.005); `SLIDE` (the same length over the poses that turn the head, ≤ 0.1; and the distance from where the part lands its tie to the nearest painted point of the anchor as the anchor lands it, ≤ 0.015); `EXPOSED` (the canvas pixels within 0.15 face widths of the tie that the part and its anchor both paint: of the two, the one drawn below has art the other hides at rest; at a pose each such pixel is landed through the lower part and counted as showing when no painted point of the upper one lands there; the largest count over the poses where the head does not turn, ≤ 0.0009 face widths², with the largest over the poses that turn it printed beside it, reported and not limited, since a tie allowed to slide uncovers what lies under it; draw order is the model's one `order` per part, so only the pair is read, and cover from any other part does not count unless the part declares an occlusion, below; rest counts 0); `RIGID` (rigid parts only: the least-squares rigid residual of the landed vertices against rest, over the pose set and the midpoint of each neighbouring pair of the part's stops, ≤ 0.0025); `HIDDEN` (only for a part that declares `occlusion`: the occluders, which of them give cover, the key parameter, the amount at rest, where the amount leaves its rest value and where it first reaches 1 on each side of the parameter's default, and how many of the part's poses `TIE` and `SLIDE` left out; reported, no limit, printed after `EXPOSED`); and `TIP` (per baked parameter, at the parameter's ends: where the part's free end lands, where it lands with the part's warps removed, the distance between and the travel end to end; reported, no limit). **What an occlusion excuses.** The gate excuses a reading only where it can establish that the player hides what the reading measures, and keeps the check everywhere else. Cover is an occluder's layer paint as that occluder lands at the pose, and only from an occluder the player draws at full alpha in every pose: colour alpha 1, no transform opacity under 1 and no `opacity` binding, so `mouth_open`, a blush and a pose forearm give none. A pose is left out only when the part is fully hidden across the stretches to the neighbouring sampled values of the key parameter on both sides (the amount is 1 at the pose, at both neighbours and at every occlusion stop between them; the sampled values are the ones the part's pose set takes, the default, its bake stops and its occlusion's stops included): a reading between two samples is bounded by the readings at its ends, so a stretch where the part is drawn keeps both poses it bounds in. For a left-out pose, `TIE` and `SLIDE` leave it out when every ring point lies on the part's mesh and under cover (it is then not counted among `SLIDE`'s turning poses; a line whose every pose is left out says so); `EXPOSED` does not count a hidden-art pixel whose landed spot is under cover, and counts every other pixel as before. An amount under 1 is judged in full, and so is a part whose tie is not under cover. `FOLDS`, `RIGID` and `TIP` read every pose, and the occlusion's stops are sampled like bake stops, so a bake key at one changes no verdict. Each line gives the worst value in px and face widths and its pose, then `pass` or `FAIL: <reason>`; the text ends with `CUSTOM GATE pass` or `CUSTOM GATE FAIL: <part LINE, …>`, always the text's last line. `FOLDS`, `TIE`, `SLIDE`, `EXPOSED` and `RIGID` each fail the gate, `TIP` never does; a tie no ring point of which lies on both the part and its anchor fails `TIE` with that reason. The model is written either way, and the folds and physics reports for the rest of the model stay report-only. `HIDDEN` needs 0.35.0. Needs 0.34.0: from then on `customParts` always carries `gate`, so a result without `customParts` is from an older server and was never gated. A gate that throws still writes the file and returns the path, with `gate.ok` false, `gate.failed` `["gate error: <message>"]` and the text ending `CUSTOM GATE FAIL: gate error: <message>`.
|
|
38
38
|
- **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, then one `CUSTOM <id>: box x,y WxH px, mesh N vertices M triangles, order O, atlas page P` line per custom part, then, with `bakes`, one `BAKE <part> <param>: N vertices, stops …, error E px` line per part and parameter (E: the engine's landing against the asked displacement, under 0.1 px; carried as `customParts.bakes`), then, with `customParts`, the custom gate's `CUSTOM <id> <LINE>: …` lines and `CUSTOM GATE pass` or `CUSTOM GATE FAIL: …` last (carried as `customParts.gate`: `ok`, `limits`, `parts` with each measure, `failed`), and `structuredContent` carries `{ ok: true, path, canvas, partCount, atlasBytes, headHalfWidth?, headHalfWidthApplied, headEdges?, strandEdges?, noseCore?, turn?, patches?, folds, physics, rigPlan, customParts? }`. `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. `customParts` is `{ parts, bakes?, gate }`, each part `{ id, box, mesh: { vertices, triangles }, order, page }` (`box` the layer's alpha box in canvas px, `page` the last atlas page), present whenever `customParts` was passed, `[]` included; `bakes` (`{ part, param, vertices, stops, errorPx }` per baked part and parameter) is present only when `bakes` was passed. `atlasBytes` is the embedded atlas's data-URI length, summed over every page: the nose's own, when it has one, and the custom parts' page. `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`.
|
|
39
|
+
- **The model's `generator`** (0.39.0 on) — the written model records what made it: `{ tool: "@ikijs/mcp@<version>", rigger: "@ikijs/editor@<version>" }` (the installed `@ikijs/editor`'s version), plus `plugin` when the server was launched with the `IKI_PLUGIN` environment variable set to a label such as `iki@0.59.4`, as the Iki plugin's `.mcp.json` does. It is not a tool input: a caller cannot set it. A value of `IKI_PLUGIN` that is no label (empty counts as unset; blank, over 128 characters or with a control character does not) refuses the rig as `INVALID: the IKI_PLUGIN environment variable is no label for a model: …`. `describe_iki` returns a model's `generator` in its summary. The library function `autoRigFromLayers` writes a `generator` only when it is passed one (`toolGenerator()` builds the tool's), so the same layers give the same bytes across releases.
|
|
39
40
|
|
|
40
41
|
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.
|
|
41
42
|
|
|
@@ -571,6 +571,9 @@ var Spring = class {
|
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
};
|
|
574
|
+
function eyeSpring() {
|
|
575
|
+
return new Spring(EYE_SPRING_OMEGA, EYE_SPRING_ZETA);
|
|
576
|
+
}
|
|
574
577
|
var IdleMotion = class {
|
|
575
578
|
/**
|
|
576
579
|
* Every parameter id {@link update} and `emitRestingPose` write, in write
|
|
@@ -596,8 +599,8 @@ var IdleMotion = class {
|
|
|
596
599
|
// Gaze state: the scheduled pick starts at eye contact, (0, 0), until the
|
|
597
600
|
// first retarget. A host target, while set, replaces the pick as what the
|
|
598
601
|
// eyes and head chase; the schedule keeps picking underneath it.
|
|
599
|
-
eyeX =
|
|
600
|
-
eyeY =
|
|
602
|
+
eyeX = eyeSpring();
|
|
603
|
+
eyeY = eyeSpring();
|
|
601
604
|
gazeTargetX = 0;
|
|
602
605
|
gazeTargetY = 0;
|
|
603
606
|
nextGazeRetargetMs;
|
|
@@ -4304,6 +4307,7 @@ function clearSweepDir(real) {
|
|
|
4304
4307
|
import { readFileSync as readFileSync3 } from "fs";
|
|
4305
4308
|
import path5 from "path";
|
|
4306
4309
|
import {
|
|
4310
|
+
parseIkiGenerator,
|
|
4307
4311
|
parseIkiModel,
|
|
4308
4312
|
loadIkiModel as loadIkiModel3,
|
|
4309
4313
|
IkiFormatError as IkiFormatError3,
|
|
@@ -4499,6 +4503,7 @@ function describeIki(model) {
|
|
|
4499
4503
|
motions,
|
|
4500
4504
|
bustScale
|
|
4501
4505
|
};
|
|
4506
|
+
if (m.generator !== void 0) summary.generator = m.generator;
|
|
4502
4507
|
const face = m.parts.find((p) => p.id === "face");
|
|
4503
4508
|
if (face !== void 0) summary.faceWidth = face.width;
|
|
4504
4509
|
return { ok: true, summary };
|
|
@@ -4688,6 +4693,14 @@ async function renderAtlasPage(crops, quantizeColors) {
|
|
|
4688
4693
|
}
|
|
4689
4694
|
async function autoRigFromLayers(input) {
|
|
4690
4695
|
try {
|
|
4696
|
+
if (input.generator !== void 0) {
|
|
4697
|
+
try {
|
|
4698
|
+
parseIkiGenerator(input.generator);
|
|
4699
|
+
} catch (e) {
|
|
4700
|
+
if (e instanceof IkiFormatError3) throw new AutoRigInputError(e.message);
|
|
4701
|
+
throw e;
|
|
4702
|
+
}
|
|
4703
|
+
}
|
|
4691
4704
|
const layers = input.layers;
|
|
4692
4705
|
if (!Array.isArray(layers) || layers.length === 0) {
|
|
4693
4706
|
throw new AutoRigInputError("layers must be a non-empty array");
|
|
@@ -4953,7 +4966,9 @@ async function autoRigFromLayers(input) {
|
|
|
4953
4966
|
patched.parts.find((p) => p.id === crop.id).texture.index = pages.length;
|
|
4954
4967
|
}
|
|
4955
4968
|
}
|
|
4956
|
-
const finalModel = parseIkiModel(
|
|
4969
|
+
const finalModel = parseIkiModel(
|
|
4970
|
+
input.generator === void 0 ? patched : { ...patched, generator: input.generator }
|
|
4971
|
+
);
|
|
4957
4972
|
const bakes = bakeReports === void 0 ? void 0 : checkBakes(finalModel, bakeReports);
|
|
4958
4973
|
writeFileAtomic(outPath, JSON.stringify(finalModel));
|
|
4959
4974
|
const folds = checkModelFolds(finalModel);
|
|
@@ -5393,6 +5408,8 @@ import {
|
|
|
5393
5408
|
armGeometry,
|
|
5394
5409
|
createLayerSetMeasurer as createLayerSetMeasurer2
|
|
5395
5410
|
} from "@ikijs/editor";
|
|
5411
|
+
var UPPER_BODY = 0.35;
|
|
5412
|
+
var NARROW_ROW = 0.6;
|
|
5396
5413
|
var ARM_ROLES = ["arm_L", "arm_R"];
|
|
5397
5414
|
var CAP_OVERLAP = 0.5;
|
|
5398
5415
|
var px = (v) => `${Number(v.toFixed(1))}`;
|
|
@@ -5458,6 +5475,19 @@ function capWarning(arm, g, body) {
|
|
|
5458
5475
|
const overlap = g.shoulderRadius - g.side * (pivotX - edge);
|
|
5459
5476
|
const need = CAP_OVERLAP * g.shoulderRadius;
|
|
5460
5477
|
if (overlap >= need) return void 0;
|
|
5478
|
+
const crop = row - body.bbox.y;
|
|
5479
|
+
const width = (r) => r === void 0 || r.length === 0 ? 0 : r[r.length - 1] - r[0];
|
|
5480
|
+
const here = width(runs);
|
|
5481
|
+
let below = 0;
|
|
5482
|
+
let belowRow = row;
|
|
5483
|
+
const end = Math.ceil(UPPER_BODY * body.bbox.h);
|
|
5484
|
+
for (let k = crop + 1; k < end; k++) {
|
|
5485
|
+
const w = width(body.rowRuns?.[k]);
|
|
5486
|
+
if (w > below) [below, belowRow] = [w, body.bbox.y + k];
|
|
5487
|
+
}
|
|
5488
|
+
if (here < NARROW_ROW * below) {
|
|
5489
|
+
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), and the body is ${here} px wide there against ${below} px at y=${belowRow}. Read the shoulder line off preview.png: if that row is the neck, move layout.${arm}.cy down by the px the shoulder line lies under y=${row} (free) \u2014 not its cx, which hangs the arm from the neck; if it is the shoulders over a wider garment, move layout.${arm}.cx ${Math.ceil(need - overlap)} px toward the body (free).`;
|
|
5490
|
+
}
|
|
5461
5491
|
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).`;
|
|
5462
5492
|
}
|
|
5463
5493
|
|
|
@@ -6010,6 +6040,15 @@ function keyGreen(rgba, W, H) {
|
|
|
6010
6040
|
}
|
|
6011
6041
|
return out;
|
|
6012
6042
|
}
|
|
6043
|
+
var SPILL_REACH = 3;
|
|
6044
|
+
function despill(rgba, only) {
|
|
6045
|
+
for (let i = 0; i < rgba.length; i += 4) {
|
|
6046
|
+
if (only !== void 0 && !only[i >> 2]) continue;
|
|
6047
|
+
const cap = Math.max(rgba[i], rgba[i + 2]);
|
|
6048
|
+
if (rgba[i + 1] > cap) rgba[i + 1] = cap;
|
|
6049
|
+
}
|
|
6050
|
+
return rgba;
|
|
6051
|
+
}
|
|
6013
6052
|
var GROUND_TOLERANCE = 4;
|
|
6014
6053
|
var GROUND_LIGHT = 200;
|
|
6015
6054
|
var GROUND_MIN = 238;
|
|
@@ -6242,6 +6281,21 @@ async function splitLipSet(keyedPng, w, h, interior) {
|
|
|
6242
6281
|
const alpha = (p) => frame[p * 4 + 3];
|
|
6243
6282
|
const { label, main, box: hb } = enclosedHole(frame, w, h);
|
|
6244
6283
|
const holeW = hb.x1 - hb.x0 + 1;
|
|
6284
|
+
const near = new Uint8Array(n);
|
|
6285
|
+
for (let y = Math.max(0, hb.y0 - SPILL_REACH); y <= Math.min(h - 1, hb.y1 + SPILL_REACH); y++) {
|
|
6286
|
+
for (let x = Math.max(0, hb.x0 - SPILL_REACH); x <= Math.min(w - 1, hb.x1 + SPILL_REACH); x++) {
|
|
6287
|
+
if (label[y * w + x] !== main) continue;
|
|
6288
|
+
for (let dy = -SPILL_REACH; dy <= SPILL_REACH; dy++) {
|
|
6289
|
+
const yy = y + dy;
|
|
6290
|
+
if (yy < 0 || yy >= h) continue;
|
|
6291
|
+
for (let dx = -SPILL_REACH; dx <= SPILL_REACH; dx++) {
|
|
6292
|
+
const xx = x + dx;
|
|
6293
|
+
if (xx >= 0 && xx < w) near[yy * w + xx] = 1;
|
|
6294
|
+
}
|
|
6295
|
+
}
|
|
6296
|
+
}
|
|
6297
|
+
}
|
|
6298
|
+
const paint = despill(Buffer.from(frame), near);
|
|
6245
6299
|
const top = new Int32Array(w).fill(-1);
|
|
6246
6300
|
const bot = new Int32Array(w).fill(-1);
|
|
6247
6301
|
for (let y = 0; y < h; y++) {
|
|
@@ -6301,7 +6355,7 @@ async function splitLipSet(keyedPng, w, h, interior) {
|
|
|
6301
6355
|
const inner = Buffer.alloc(n * 4);
|
|
6302
6356
|
const tongue = Buffer.alloc(n * 4);
|
|
6303
6357
|
const teeth = Buffer.alloc(n * 4);
|
|
6304
|
-
const copy = (to, p) =>
|
|
6358
|
+
const copy = (to, p) => paint.copy(to, p * 4, p * 4, p * 4 + 4);
|
|
6305
6359
|
for (let y = 0; y < h; y++) {
|
|
6306
6360
|
for (let x = 0; x < w; x++) {
|
|
6307
6361
|
const p = y * w + x;
|
|
@@ -6327,7 +6381,7 @@ async function splitLipSet(keyedPng, w, h, interior) {
|
|
|
6327
6381
|
}
|
|
6328
6382
|
if ((inM[p] || wall[x]) && !faintUpper(p, x, y)) {
|
|
6329
6383
|
const a = alpha(p) / 255;
|
|
6330
|
-
for (let c = 0; c < 3; c++) out[c] += (
|
|
6384
|
+
for (let c = 0; c < 3; c++) out[c] += (paint[p * 4 + c] - out[c]) * a;
|
|
6331
6385
|
}
|
|
6332
6386
|
inner[p * 4] = Math.round(out[0]);
|
|
6333
6387
|
inner[p * 4 + 1] = Math.round(out[1]);
|
|
@@ -6429,7 +6483,9 @@ async function closedLips(upper, lower, shift, left, top) {
|
|
|
6429
6483
|
var isLipLayerRole = (role) => LIP_ROLES.includes(role) || isLipInsideRole(role);
|
|
6430
6484
|
var MIN_OPENING_ROWS = 8;
|
|
6431
6485
|
var MIN_LINE_ROWS = 2;
|
|
6432
|
-
var GREEN_EXCESS =
|
|
6486
|
+
var GREEN_EXCESS = 16;
|
|
6487
|
+
var KEY_GREEN_EXCESS = 40;
|
|
6488
|
+
var EDGE_REACH = 3;
|
|
6433
6489
|
var INTERIOR_GAP_FRACTION = 0.05;
|
|
6434
6490
|
var columns = (cols) => `${cols.length} column${cols.length === 1 ? "" : "s"} (first at x=${cols[0]})`;
|
|
6435
6491
|
async function lipWarnings(absDir, layers, inPlace = false) {
|
|
@@ -6490,17 +6546,49 @@ async function lipWarnings(absDir, layers, inPlace = false) {
|
|
|
6490
6546
|
});
|
|
6491
6547
|
const set = /* @__PURE__ */ new Map();
|
|
6492
6548
|
const green = [];
|
|
6549
|
+
const pixels = /* @__PURE__ */ new Map();
|
|
6493
6550
|
for (const role of LIP_ROLES) {
|
|
6494
6551
|
const fileName = `${role}.png`;
|
|
6495
6552
|
const { rgba } = await decodePng(path8.join(absDir, fileName));
|
|
6496
6553
|
set.set(role, measurer.add({ role, fileName, rgba }));
|
|
6554
|
+
pixels.set(role, rgba);
|
|
6497
6555
|
for (let i = 0; i < rgba.length; i += 4) {
|
|
6498
|
-
if (rgba[i + 3] >= ALPHA_OPAQUE4 && rgba[i + 1] - Math.max(rgba[i], rgba[i + 2]) >
|
|
6556
|
+
if (rgba[i + 3] >= ALPHA_OPAQUE4 && rgba[i + 1] - Math.max(rgba[i], rgba[i + 2]) > KEY_GREEN_EXCESS) {
|
|
6499
6557
|
green.push(role);
|
|
6500
6558
|
break;
|
|
6501
6559
|
}
|
|
6502
6560
|
}
|
|
6503
6561
|
}
|
|
6562
|
+
{
|
|
6563
|
+
const W = inner.canvasW;
|
|
6564
|
+
const H = inner.canvasH;
|
|
6565
|
+
const cavity2 = pixels.get("mouth_inner");
|
|
6566
|
+
const edge = new Uint8Array(W * H);
|
|
6567
|
+
for (let p = 0; p < W * H; p++) {
|
|
6568
|
+
if (cavity2[p * 4 + 3] < 128) continue;
|
|
6569
|
+
const x = p % W;
|
|
6570
|
+
const y = (p - x) / W;
|
|
6571
|
+
for (let dy = -EDGE_REACH; dy <= EDGE_REACH; dy++) {
|
|
6572
|
+
const yy = y + dy;
|
|
6573
|
+
if (yy < 0 || yy >= H) continue;
|
|
6574
|
+
for (let dx = -EDGE_REACH; dx <= EDGE_REACH; dx++) {
|
|
6575
|
+
const xx = x + dx;
|
|
6576
|
+
if (xx >= 0 && xx < W) edge[yy * W + xx] = 1;
|
|
6577
|
+
}
|
|
6578
|
+
}
|
|
6579
|
+
}
|
|
6580
|
+
for (const role of ["lip_upper", "lip_lower"]) {
|
|
6581
|
+
if (green.includes(role)) continue;
|
|
6582
|
+
const rgba = pixels.get(role);
|
|
6583
|
+
for (let p = 0; p < W * H; p++) {
|
|
6584
|
+
const i = p * 4;
|
|
6585
|
+
if (edge[p] && (rgba[i + 1] - Math.max(rgba[i], rgba[i + 2])) * rgba[i + 3] / 255 > GREEN_EXCESS) {
|
|
6586
|
+
green.push(role);
|
|
6587
|
+
break;
|
|
6588
|
+
}
|
|
6589
|
+
}
|
|
6590
|
+
}
|
|
6591
|
+
}
|
|
6504
6592
|
let opening;
|
|
6505
6593
|
try {
|
|
6506
6594
|
opening = mouthOpening2(set);
|
|
@@ -6578,7 +6666,11 @@ async function lipWarnings(absDir, layers, inPlace = false) {
|
|
|
6578
6666
|
}
|
|
6579
6667
|
if (!inPlace && green.length > 0) {
|
|
6580
6668
|
warnings.push(
|
|
6581
|
-
`${green.join("/")}:
|
|
6669
|
+
`${green.join("/")}: green left (key green: g over r and b by more than ${KEY_GREEN_EXCESS} in an opaque pixel, or by more than ${GREEN_EXCESS} at the pixel's alpha on the opening's edge) \u2014 it shows as a green fringe on the lips. ${recompose(
|
|
6670
|
+
"mouth_keyed.png",
|
|
6671
|
+
// mouth_inner's fill is the interior's own paint, which the composer keeps as drawn.
|
|
6672
|
+
green.includes("mouth_inner") ? "with the green only inside the opening, or mouth_interior.png without green in it" : "with the green only inside the opening"
|
|
6673
|
+
)}`
|
|
6582
6674
|
);
|
|
6583
6675
|
}
|
|
6584
6676
|
if (!inPlace && area > 0 && hollow > INTERIOR_GAP_FRACTION * area) {
|
|
@@ -7953,6 +8045,30 @@ async function composeLayersFromParts(input) {
|
|
|
7953
8045
|
}
|
|
7954
8046
|
}
|
|
7955
8047
|
|
|
8048
|
+
// src/generator.ts
|
|
8049
|
+
import { EDITOR_VERSION } from "@ikijs/editor";
|
|
8050
|
+
import {
|
|
8051
|
+
IkiFormatError as IkiFormatError4,
|
|
8052
|
+
parseIkiGenerator as parseIkiGenerator2
|
|
8053
|
+
} from "@ikijs/format";
|
|
8054
|
+
var PLUGIN_ENV = "IKI_PLUGIN";
|
|
8055
|
+
function toolGenerator(env = process.env) {
|
|
8056
|
+
const generator = {
|
|
8057
|
+
tool: `@ikijs/mcp@${"0.39.1"}`,
|
|
8058
|
+
rigger: `@ikijs/editor@${EDITOR_VERSION}`
|
|
8059
|
+
};
|
|
8060
|
+
const plugin = env[PLUGIN_ENV];
|
|
8061
|
+
if (plugin === void 0 || plugin === "") return generator;
|
|
8062
|
+
try {
|
|
8063
|
+
return parseIkiGenerator2({ ...generator, plugin });
|
|
8064
|
+
} catch (e) {
|
|
8065
|
+
if (!(e instanceof IkiFormatError4)) throw e;
|
|
8066
|
+
throw new IkiFormatError4(
|
|
8067
|
+
`the ${PLUGIN_ENV} environment variable is no label for a model: ${e.message}`
|
|
8068
|
+
);
|
|
8069
|
+
}
|
|
8070
|
+
}
|
|
8071
|
+
|
|
7956
8072
|
// src/hair-side-report.ts
|
|
7957
8073
|
function signedPx(px2) {
|
|
7958
8074
|
const s = px2.toFixed(1);
|
|
@@ -12590,6 +12706,7 @@ function formatCutReport(r) {
|
|
|
12590
12706
|
// src/server.ts
|
|
12591
12707
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12592
12708
|
import { z } from "zod";
|
|
12709
|
+
import { IkiFormatError as IkiFormatError5 } from "@ikijs/format";
|
|
12593
12710
|
function formatPatchReports(reports) {
|
|
12594
12711
|
return reports.map((r) => {
|
|
12595
12712
|
const at = Object.keys(r.at).sort().map((p) => `${p}=${r.at[p]}`).join(" ");
|
|
@@ -12611,7 +12728,7 @@ function formatBakeChecks(bakes) {
|
|
|
12611
12728
|
);
|
|
12612
12729
|
}
|
|
12613
12730
|
function createIkiMcpServer() {
|
|
12614
|
-
const server = new McpServer({ name: "iki", version: "0.
|
|
12731
|
+
const server = new McpServer({ name: "iki", version: "0.39.1" });
|
|
12615
12732
|
server.registerTool(
|
|
12616
12733
|
"validate_iki",
|
|
12617
12734
|
{
|
|
@@ -12638,7 +12755,7 @@ function createIkiMcpServer() {
|
|
|
12638
12755
|
server.registerTool(
|
|
12639
12756
|
"describe_iki",
|
|
12640
12757
|
{
|
|
12641
|
-
description: "Summarizes a valid model's canvas/params/parts/deformers and its expressions and motion clips (with the descriptions a host picks them by); returns an error for an invalid model. It is also the patch writer's view of a rigged model: each part's rest box in model px and in bust-render px, each part's warp stops, each warp2d's stops, and faceWidth, which is what an auto_rig_from_layers `patches` op is aimed with. Pass exactly one of model or modelPath; prefer modelPath for a written rig so a large model never crosses your context.",
|
|
12758
|
+
description: "Summarizes a valid model's canvas/params/parts/deformers and its expressions and motion clips (with the descriptions a host picks them by), and its `generator` (what wrote it: tool, rigger and plugin, each name@version) when it records one; returns an error for an invalid model. It is also the patch writer's view of a rigged model: each part's rest box in model px and in bust-render px, each part's warp stops, each warp2d's stops, and faceWidth, which is what an auto_rig_from_layers `patches` op is aimed with. Pass exactly one of model or modelPath; prefer modelPath for a written rig so a large model never crosses your context.",
|
|
12642
12759
|
inputSchema: {
|
|
12643
12760
|
model: z.unknown().optional().describe("Raw .iki model JSON (object or JSON string)"),
|
|
12644
12761
|
modelPath: z.string().optional().describe(
|
|
@@ -12703,7 +12820,7 @@ function createIkiMcpServer() {
|
|
|
12703
12820
|
server.registerTool(
|
|
12704
12821
|
"auto_rig_from_layers",
|
|
12705
12822
|
{
|
|
12706
|
-
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. `customParts` adds parts the rig has no role for (a twin tail, a hairpin), each from a canvas-sized PNG of its own, as an unrigged mesh on `headDeformer` after its `after` role's parts; it needs @ikijs/mcp 0.34.0, and an older server drops the field and returns no `customParts`. A part can declare `occlusion` (hidden where named roles' paint covers it, by an amount keyed on a parameter; it needs 0.35.0, and an older server refuses the key as `INVALID: customParts[i]\u2026`); its `CUSTOM <id>:` line then ends `, hidden by <id>,<id>\u2026 on <parameter> at <value>:<amount> <value>:<amount>\u2026`, and the result's part carries `occlusion` (`by` as the part ids written, `parameter`, `stops`). The result's `customParts` (`parts`: `id`, rest `box`, `mesh`, `order`, atlas `page`) is present whenever the input was passed, `[]` included, and one `CUSTOM <id>: \u2026` line per part follows the `HAIRSIDE` lines. `bakes` (see its field) moves the custom parts with a parameter and needs `customParts`; each part and parameter it moves then prints one `BAKE <part> <param>: <n> vertices, stops <values>, error <px> px` line after the `CUSTOM` lines (the result's `customParts.bakes`: `part`, `param`, `vertices`, `stops`, `errorPx`), the written model having been landed through the engine, and a stop off by 0.1 px or more comes back as `INVALID: BAKE ERROR <part> <param>=<value>: \u2026`, and a part the bake moves at rest as `INVALID: BAKE ERROR <part> at rest: \u2026`, with nothing written (the rig and the engine disagree: report it as a bug in the packages). Whenever `customParts` was passed, the written model is also measured per custom part (the result's `customParts.gate`: `ok`, `limits`, `parts`, `failed`) and the text ends with its lines, `CUSTOM <id> FOLDS|TIE|SLIDE|EXPOSED|RIGID|TIP: \u2026` then `CUSTOM GATE pass` or `CUSTOM GATE FAIL: <part LINE, \u2026>`, always the last line: a part's least triangle area ratio, its tie's displacement against the anchor where the head does not turn and where it does, the hidden art showing, how far a rigid part bends and where its free end lands, each in px and face widths with its worst pose; `TIP` never fails the gate and the other lines do. The model is written either way; from 0.34.0 on `customParts` always carries `gate` (a gate that throws still writes the file and ends the text `CUSTOM GATE FAIL: gate error: <message>`), so a result without `customParts` is from an older server and was never gated. The custom layers are not role layers: they are left out of the head's width and turn measurements, and an empty or wrong-size one, or an entry the rig refuses, comes back as `INVALID: customParts[i]\u2026` with nothing written. A missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error.",
|
|
12823
|
+
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. `customParts` adds parts the rig has no role for (a twin tail, a hairpin), each from a canvas-sized PNG of its own, as an unrigged mesh on `headDeformer` after its `after` role's parts; it needs @ikijs/mcp 0.34.0, and an older server drops the field and returns no `customParts`. A part can declare `occlusion` (hidden where named roles' paint covers it, by an amount keyed on a parameter; it needs 0.35.0, and an older server refuses the key as `INVALID: customParts[i]\u2026`); its `CUSTOM <id>:` line then ends `, hidden by <id>,<id>\u2026 on <parameter> at <value>:<amount> <value>:<amount>\u2026`, and the result's part carries `occlusion` (`by` as the part ids written, `parameter`, `stops`). The result's `customParts` (`parts`: `id`, rest `box`, `mesh`, `order`, atlas `page`) is present whenever the input was passed, `[]` included, and one `CUSTOM <id>: \u2026` line per part follows the `HAIRSIDE` lines. `bakes` (see its field) moves the custom parts with a parameter and needs `customParts`; each part and parameter it moves then prints one `BAKE <part> <param>: <n> vertices, stops <values>, error <px> px` line after the `CUSTOM` lines (the result's `customParts.bakes`: `part`, `param`, `vertices`, `stops`, `errorPx`), the written model having been landed through the engine, and a stop off by 0.1 px or more comes back as `INVALID: BAKE ERROR <part> <param>=<value>: \u2026`, and a part the bake moves at rest as `INVALID: BAKE ERROR <part> at rest: \u2026`, with nothing written (the rig and the engine disagree: report it as a bug in the packages). Whenever `customParts` was passed, the written model is also measured per custom part (the result's `customParts.gate`: `ok`, `limits`, `parts`, `failed`) and the text ends with its lines, `CUSTOM <id> FOLDS|TIE|SLIDE|EXPOSED|RIGID|TIP: \u2026` then `CUSTOM GATE pass` or `CUSTOM GATE FAIL: <part LINE, \u2026>`, always the last line: a part's least triangle area ratio, its tie's displacement against the anchor where the head does not turn and where it does, the hidden art showing, how far a rigid part bends and where its free end lands, each in px and face widths with its worst pose; `TIP` never fails the gate and the other lines do. The model is written either way; from 0.34.0 on `customParts` always carries `gate` (a gate that throws still writes the file and ends the text `CUSTOM GATE FAIL: gate error: <message>`), so a result without `customParts` is from an older server and was never gated. The custom layers are not role layers: they are left out of the head's width and turn measurements, and an empty or wrong-size one, or an entry the rig refuses, comes back as `INVALID: customParts[i]\u2026` with nothing written. A missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error. The written model records what made it as `generator`: this server and the auto-rigger, each name@version, and the plugin named in the server's IKI_PLUGIN environment variable, if any; it is no input.",
|
|
12707
12824
|
inputSchema: {
|
|
12708
12825
|
layers: z.array(
|
|
12709
12826
|
z.object({
|
|
@@ -12847,8 +12964,19 @@ function createIkiMcpServer() {
|
|
|
12847
12964
|
},
|
|
12848
12965
|
async (args) => {
|
|
12849
12966
|
try {
|
|
12967
|
+
let generator;
|
|
12968
|
+
try {
|
|
12969
|
+
generator = toolGenerator();
|
|
12970
|
+
} catch (e) {
|
|
12971
|
+
if (!(e instanceof IkiFormatError5)) throw e;
|
|
12972
|
+
return {
|
|
12973
|
+
content: [{ type: "text", text: `INVALID: ${e.message}` }],
|
|
12974
|
+
structuredContent: { ok: false, error: e.message }
|
|
12975
|
+
};
|
|
12976
|
+
}
|
|
12850
12977
|
const r = await autoRigFromLayers({
|
|
12851
12978
|
...args,
|
|
12979
|
+
generator,
|
|
12852
12980
|
// `.length(2)` makes each region span a pair, which its inferred
|
|
12853
12981
|
// `number[]` cannot say.
|
|
12854
12982
|
patches: args.patches,
|
|
@@ -12882,7 +13010,7 @@ function createIkiMcpServer() {
|
|
|
12882
13010
|
server.registerTool(
|
|
12883
13011
|
"compose_layers_from_parts",
|
|
12884
13012
|
{
|
|
12885
|
-
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`.",
|
|
13013
|
+
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 (with both readings \u2014 a neck, or shoulders over a wider garment \u2014 when its pivot row is much narrower than the body below it), 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`.",
|
|
12886
13014
|
inputSchema: {
|
|
12887
13015
|
partsDir: z.string().describe(
|
|
12888
13016
|
"Directory of the source part PNGs (resolved against cwd)."
|
|
@@ -12930,7 +13058,7 @@ function createIkiMcpServer() {
|
|
|
12930
13058
|
server.registerTool(
|
|
12931
13059
|
"measure_layers",
|
|
12932
13060
|
{
|
|
12933
|
-
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.",
|
|
13061
|
+
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 (with both readings \u2014 a neck, or shoulders over a wider garment \u2014 when that row is much narrower than the body below it), 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.",
|
|
12934
13062
|
inputSchema: {
|
|
12935
13063
|
layersDir: z.string().describe(
|
|
12936
13064
|
"Directory of role-named layer PNGs (resolved against cwd)."
|
|
@@ -13287,6 +13415,8 @@ export {
|
|
|
13287
13415
|
measureLayers,
|
|
13288
13416
|
formatMeasureReport,
|
|
13289
13417
|
composeLayersFromParts,
|
|
13418
|
+
PLUGIN_ENV,
|
|
13419
|
+
toolGenerator,
|
|
13290
13420
|
formatHairSideReport,
|
|
13291
13421
|
formatPhysicsReport,
|
|
13292
13422
|
viewIllustrationGrid,
|
|
@@ -13294,4 +13424,4 @@ export {
|
|
|
13294
13424
|
formatCutReport,
|
|
13295
13425
|
createIkiMcpServer
|
|
13296
13426
|
};
|
|
13297
|
-
//# sourceMappingURL=chunk-
|
|
13427
|
+
//# sourceMappingURL=chunk-3XQLLYUF.mjs.map
|