@ikijs/mcp 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,17 +6,17 @@ A stdio [MCP](https://modelcontextprotocol.io/) server that exposes `.iki` model
6
6
 
7
7
  ## Tools
8
8
 
9
- | Tool | Description |
10
- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
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. |
13
- | `list_standard_parameters` | List the recommended standard parameter ids (e.g. `ParamAngleX`, `ParamMouthOpenY`) with descriptions. |
14
- | `describe_rig_plan` | List the fields of `auto_rig_from_layers`'s `rigPlan` with their defaults, ranges, recommended spans, steps and poses. |
15
- | `auto_rig_from_layers` | Auto-rig role-named PNG layers into a renderable `.iki` written to disk; returns the output path. |
16
- | `compose_layers_from_parts` | Compose generated part PNGs into canvas-aligned, role-named layers, with the geometry report inline. |
17
- | `measure_layers` | Re-run that same geometry report over an already-composed layers directory. |
18
- | `measure_turn_reference` | Measure how far a head turns between a front and a turned image at the same scale, as three ratios. |
19
- | `render_poses` | Render a rigged `.iki` into the character loop's pose PNGs through the installed Chrome, Edge or Chromium. |
9
+ | Tool | Description |
10
+ | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
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. |
13
+ | `list_standard_parameters` | List the recommended standard parameter ids (e.g. `ParamAngleX`, `ParamMouthOpenY`) with descriptions. |
14
+ | `describe_rig_plan` | List the fields of `auto_rig_from_layers`'s `rigPlan` with their defaults, ranges, recommended spans, steps and poses. |
15
+ | `auto_rig_from_layers` | Auto-rig role-named PNG layers into a renderable `.iki` written to disk; returns the output path. |
16
+ | `compose_layers_from_parts` | Compose generated part PNGs into canvas-aligned, role-named layers, with the geometry report inline. |
17
+ | `measure_layers` | Re-run that same geometry report over an already-composed layers directory. |
18
+ | `measure_turn_reference` | Measure how far a head turns between a front and a turned image at the same scale, as three ratios. |
19
+ | `render_poses` | Render a rigged `.iki` into the character loop's pose PNGs through the installed Chrome, Edge or Chromium, and a turn sweep. |
20
20
 
21
21
  The `model` input for `validate_iki` and `describe_iki` accepts either a plain JSON object or a JSON string — the server normalises both. `describe_iki` also takes `modelPath` instead (exactly one of the two; resolved against the working directory, under it), so a written rig never crosses the context, and returns the patch writer's view of it: per part the rest `box` in model px, the `bustBox` in bust-render px and its `warps` with their stops; per `warp2d` deformer `stopsX` and `stopsY`; and `faceWidth` (the `face` part's width, the unit of a patch's `by`) and `bustScale`.
22
22
 
@@ -84,10 +84,12 @@ Renders a rigged `.iki` into the pose PNGs the character loop reviews, with the
84
84
  - **`modelPath`** — the rigged `.iki` (resolved against the working directory; must sit under it).
85
85
  - **`outDir`** — an existing directory under the working directory. One `<pose>.png` per pose is written into it, replacing a same-named file in place.
86
86
  - **`poses`** — optional caller-named poses rendered instead of the standard set, each `{ name, values, crop? }`: `name` becomes `<outDir>/<name>.png` (letters, digits, `_`, `.`, `-`; unique ignoring case), `values` are parameter settings (the rest at their defaults), and `crop` `{ x, y, w, h }` is a rectangle in model px from the top-left — the frame of `describe_iki`'s boxes and the `FOLD` lines — clamped to the canvas and drawn 720 px wide (an empty list, a bad or repeated name, a non-finite value, or a crop that misses the canvas or would draw under 1 or over 8192 px tall is `INVALID: poses…`; a parameter id the model lacks is ignored). Each pose is also added to the fold sweep, after the engine's own poses.
87
+ - **`sweep`** — optional `{ name, preset: "turn", crop? }`, rendered in addition to the poses: `ParamAngleX` eased 0 → −30 → +30 → 0 over 3 s (sinusoidal, so it never pauses at a stop and crosses 0 at its top speed), at 30 fps on a 60 Hz clock, with the hair physics running through `IkiMotion` and the idle, clips and expressions off (only the physics outputs reach the player), every other parameter at its default, after a 0.5 s warm-up at rest. The frames share one fixed framing: `crop` (model px, as a pose's) or the standard shots. `name` becomes the directory `<outDir>/<name>/` — it starts with a letter or digit, then letters, digits, `_`, `.`, `-`; the tool creates it, refuses a symbolic link or a non-directory there; every run overwrites all 90 frames. Written: `fNNN.png` (90 frames), `manifest.json` (per frame its time, angle and the effective `ParamAngleX` and physics outputs), `sheet.png` (nine frames of the −30 → +30 leg, chronological in a 3 × 3 grid, labelled with angle and time only, at most 2000 px a side), `kymograph.png` (the eye row of every frame, three px each, stacked in time: a bend at the centre is a kink, a trailing curve the hair's lag) and `index.html` (a flipbook that opens from disk; `?b=<relative dir of another sweep>` plays two side by side). A sweep adds about 4–5 s on a bust (measured on the corpus characters). A server before 0.31.0 strips `sweep` and renders the stills alone.
87
88
  - **What is written** — the model decides the set. A bust gets 560 × 560 shots: `rest`, `turn-m30`, `turn-p30`, `turn-15`, `nod-15`, `blink`, `blink-half`, `gaze`, `combined` (`ParamAngleX`/`Y`/`Z` all at 30), `stress` (`ParamAngleX`/`Y`/`Z` all at −30, `ParamMouthOpenY` 1, `ParamEyeLOpen` and `ParamEyeROpen` 0.5, `ParamBrowLY` −1, `ParamBrowRY` 1, `ParamBrowLAngle` 1, `ParamBrowRAngle` −1, and each of `ParamBodyAngleX`/`Y`/`Z` the model declares at −10: moves that each look fine alone, stacked). A model with a `mouth` or `mouth_inner` adds 720 × 480 mouth crops (`mouth-open-*-form-*`, `mouth-laugh`, `mouth-surprised`, `mouth-turn-p30-half`). A full body (canvas taller than wide) shoots the same squares from the model's top (the head), centred horizontally, and adds whole-canvas `full-*` shots (body, arm and elbow poses) at 1400 px wide; one with a pose forearm (`ParamArmPoseR`) adds the `full-pose-*` shots.
88
- - **Result** — the text is the written paths, one per line, then the model's fold report, then its physics report. `failedTextures` lists the atlas pages the engine could not load; their parts are missing from the renders. `structuredContent` is `{ ok: true, outDir, canvas, fullBody, mouth?, failedTextures, poses: [{ name, path }], modelCanvas, folds, physics }`. A missing model, an `outDir` that is missing or outside the working directory, or a file that is not a valid model returns `{ ok: false, error }` with `INVALID: …` text.
89
+ - **Result** — the text is the written paths, one per line (then, with `sweep`, its directory, `sheet.png`, `kymograph.png`, `index.html` and `manifest.json`), then the model's fold report, then its physics report, then the `SWEEP` lines. `failedTextures` lists the atlas pages the engine could not load; their parts are missing from the renders. `structuredContent` is `{ ok: true, outDir, canvas, fullBody, mouth?, failedTextures, poses: [{ name, path }], modelCanvas, folds, physics, sweep? }`. A missing model, an `outDir` that is missing or outside the working directory, or a file that is not a valid model returns `{ ok: false, error }` with `INVALID: …` text.
89
90
  - **Folds** — `folds` is the engine's `checkFolds` over its own pose set (`foldPoses`: rest, each parameter alone at its min and max, and the corners of the head and body angles crossed with the eyes, the mouth, the arms and the elbows), not over the rendered shots: `{ poses, thresholds: { flip: 0, collapse: 0.1 }, targets, offenders }`, one target per warp deformer (its grid cells) and per mesh part (its triangles), each `{ target: { kind, id }, kind, worst?, expected? }`: `worst` and `expected` are the least ratio of an area at a pose to the same at rest over the poses that are not, and that are, a by-design closure (below), each with its cell or triangle, its pose and its rest point; `kind` (`flip`, `collapse` or `ok`) is read off `worst` alone, and `offenders` are the targets that are not `ok`. The text prints one `FOLD` line per offender, worst first — `flip` (ratio ≤ 0) or `collapse` (under 0.1), `deformer` or `part`, its id, `cell (col,row)` or `triangle i`, the ratio (two significant figures under 0.01, so a flip never reads `-0.00`), the pose in brackets as its sorted `id=value` settings (`rest` for none), and where it sits at rest in model space and in model px from the top-left of `modelCanvas` (the layer PNGs' own pixels, not a render's) — or `FOLDS: none over N poses`. Then, when one folds, a `FOLDS expected:` line names the closures the auto-rig draws on purpose, each by part id, ratio and the parameter that shuts it: `eye_L` and `lash_lower_L` while `ParamEyeLOpen` is 0, `eye_R` and `lash_lower_R` while `ParamEyeROpen` is 0, and the lip set (`mouth_inner`, `mouth_tongue`, `mouth_teeth`, `lip_lower`, `lip_upper`) while `ParamMouthOpenY` is 0, read as each pose's effective value, its default included. The sweep covers the engine's pose set plus the caller's `poses`; a caller's pose is named in the `FOLD` lines by its sorted `id=value` settings (`rest` when empty), never by its PNG name, so a host reproduces any fold by setting those parameters on a player. Report-only: a fold never fails the render.
90
91
  - **Physics** — `physics` is the engine's `checkPhysics` over the model's own rigs (`poses` do not enter it): `{ thresholds: { displacementPx: 1, pinnedFrames: 60 }, targets, offenders }`, one target per `model.physics` rig, then one per chain segment, in model order, each `{ rig, input, output, drives, kind, why?, step, idle }`. `rig` is `{ kind: "spring", id }` or `{ kind: "chain", id, segment }`; `input` is every input parameter of the spring, in rig order, or every parameter that turns the chain's anchor; `output` is the driven parameter; `drives` lists what reads it, the parts then the deformers (`{ kind, id }`); `kind` is `ok`, `frozen` or `unstable`, and `why`, present when it is not `ok`, is one phrase naming the window it came from; `offenders` are the targets that are not `ok`, unstable first. Each output is excited through the engine's real drivers on a 60 Hz clock. The step holds a fresh rig's input at its far end — the end farther from its default — for 5 s; a spring steps each input that has a range alone, in its own run, and a chain each parameter that turns its anchor, and either reports the run moving the parts most among those that are not unstable. A `lag` input's step peaks at once at its bound, −scale × weight (less one sub-step), and its `final` reads rest: the bound is what a one-frame step shows, and a gradual turn swings less. The idle runs every rig and chain together behind the procedural idle, on a seeded rng, for 30 s. `step` is `{ values, peak, at, final, displacementPx }`: the setting held, the output's largest signed displacement from rest and when, in seconds, its value at the end of the window, and the largest vertex move of any part in model px with the output alone at every value the step emitted. `idle` is `{ peak, at, displacementPx }`, its peak a size, since the sway goes both ways, and its move taken at every value the idle emitted. A target is `unstable` when a spring's one-sub-step map has a spectral radius over 1 (exact, in closed form) or sits on its undamped boundary `dt²k/m = 4`, when a driver's finiteness guard fires (`why` says how often), or when the raw output stays outside its range for 60 consecutive frames (1 s), in either window. A chain's update is nonlinear, so it gets no radius verdict: a chain that grows yet stays finite and inside its range trips none of these, which is deferred to a later slice, and shows in the numbers only. A target is `frozen` when it drives nothing, none of its spring's inputs has a range, nothing turns its chain's anchor, or the step moves the parts under 1 model px. The amplitudes are numbers only: however little the idle moves an output, that never flags. The text prints one `PHYSICS` line per target after the fold lines — its kind, the rig (`id`, or `id/segment [inputs]` for a chain segment) and `input -> output`; then `step`, its setting as sorted `id=value` pairs (`rest` for none), the peak and when, the final value and the move, with the ids it drives in parentheses; then `idle`, its peak, when and move; and ` — <why>` when it is not `ok` — or `PHYSICS: no rigs`. Parameter values and seconds print to two decimals and px to one, rounded down, so a frozen 0.96 px never reads 1.0. Report-only: nothing here refuses a rig or fails a render.
92
+ - **Sweep** — `sweep.report` (when `sweep` was asked for) is geometry from the engine's `landParts`, not pixels, and it needs no browser: `ParamAngleX` from −30 to +30 in 1° steps, every other parameter at its default and no physics (it reads the rig; the frames show the rig plus hair). The landmarks are the `eye_L` and `eye_R` parts and the `nose` when there is one; the local face plate is the `face` part's landed vertex nearest each landmark's rest centre. Every distance is in `fw`, the `face` part's width in model px (`describe_iki`'s `faceWidth`, the unit of a patch's `by`). Per landmark: `amplitude` = x(+30) − x(−30) (0 on a frozen rig); `x kink` and, for an eye, `width kink` = |s₊ − s₋| / max(|s₊|, |s₋|) with s₋ the slope over −5 → 0 and s₊ over 0 → +5, in fw per degree, `n/a` when both are under 1e-4 fw/deg; `lead` at −30 and +30 = how far the landmark moved beyond the plate; `pop` = the largest second difference of x over the ladder (the two steps touching 0 excluded) over the mean step, 0 on a rig linear on each side and large at a keyform that is not a stop. A final `plate` line gives the plate's own amplitude. The text prints `SWEEP turn <id>: amplitude … fw, x kink …, width kink …, lead -30 … fw / +30 … fw, pop …` per landmark and `SWEEP turn plate: amplitude … fw`, after the `PHYSICS` lines; without a `face` part or an eye pair it is `SWEEP: unavailable — <reason>` (`sweep.report.unavailable`). Report-only: no number here refuses a rig or fails a render, and a small `pop` is the rig's construction (an eye under `bodyWarp` lands as a product of two maps).
91
93
 
92
94
  ## Usage
93
95