@ikijs/mcp 0.7.0 → 0.8.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 +30 -2
- package/dist/{chunk-GDLPXXJ3.mjs → chunk-JPWDKP43.mjs} +547 -31
- package/dist/chunk-JPWDKP43.mjs.map +1 -0
- package/dist/cli.js +530 -17
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +163 -1
- package/dist/index.d.ts +163 -1
- package/dist/index.js +534 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/package.json +2 -2
- package/dist/chunk-GDLPXXJ3.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ A stdio [MCP](https://modelcontextprotocol.io/) server that exposes `.iki` model
|
|
|
12
12
|
| `auto_rig_from_layers` | Auto-rig role-named PNG layers into a renderable `.iki` written to disk; returns the output path. |
|
|
13
13
|
| `compose_layers_from_parts` | Compose generated part PNGs into canvas-aligned, role-named layers, with the geometry report inline. |
|
|
14
14
|
| `measure_layers` | Re-run that same geometry report over an already-composed layers directory. |
|
|
15
|
+
| `measure_turn_reference` | Measure how far a head turns between a front and a turned image at the same scale, as three ratios. |
|
|
15
16
|
|
|
16
17
|
The `model` input for `validate_iki` and `describe_iki` accepts either a plain JSON object or a JSON string — the server normalises both.
|
|
17
18
|
|
|
@@ -21,7 +22,8 @@ Turns a set of role-named, full-canvas transparent PNG layers into a renderable,
|
|
|
21
22
|
|
|
22
23
|
- **`layers`** — array of `{ path, fileName? }`. `path` is a PNG file path (resolved against the server's working directory); the role is derived from `fileName ?? basename(path)`. Required roles: `face`, `eye_L`, `eye_R`, `mouth`. Optional roles include `iris_L`/`iris_R`, `brow_L`/`brow_R`, `hair_front`/`hair_back`, `lash_L`/`lash_R`, etc. All layers must share the same canvas size (taken from the first layer).
|
|
23
24
|
- **`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`.
|
|
24
|
-
-
|
|
25
|
+
- **`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`, derived from it when absent) 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 falls back to a built-in default, which is _clamped_ to what the layer set can do; a target you **do** pass that it cannot reach is refused, because that number is a measurement rather than a preference. Only a layer set carrying a `nose` solves a turn at all.
|
|
26
|
+
- **Result** — on success the result text is the written file path and `structuredContent` carries `{ ok: true, path, canvas, partCount, atlasBytes, headHalfWidth?, headHalfWidthApplied, headEdges?, turn? }`. `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. `turn` is what the solve settled on — `{ radius, holdBase, depths, achieved: { eyeShift, farEyeRatio, silhouetteRatio }, clamped }`, where `clamped` names the _defaulted_ targets this layer set could not reach and `achieved` is what the rig does reach; it is absent without a `nose` layer. The (potentially multi-MB) model is written to disk, not inlined. Invalid input (unknown/missing role, empty layer, mismatched sizes, bad path, oversized atlas, a `turnTargets` field that is not a number or that this layer set cannot reach — the message names the field and the attainable range) returns `{ ok: false, error }` with a `INVALID: …` text — not a protocol error.
|
|
25
27
|
|
|
26
28
|
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.
|
|
27
29
|
|
|
@@ -41,6 +43,32 @@ Reports the same read-only geometry checks `compose_layers_from_parts` returns i
|
|
|
41
43
|
- **`layersDir`** — directory of role-named layer PNGs (resolved against the working directory).
|
|
42
44
|
- **Result** — the text is the report: a per-layer size/bbox-centre/mass-centre/margins table, then the checks that fired. `structuredContent` is `{ ok: true, layersDir, layers, empty, warnings, passed }`. A missing or non-directory `layersDir` returns `{ ok: false, error }` with `INVALID: …` text.
|
|
43
45
|
|
|
46
|
+
### `measure_turn_reference`
|
|
47
|
+
|
|
48
|
+
Measures how far a head turns between two images of the same character — one facing front, one turned — and reports it as three ratios, so a rigged turn can be compared against a reference turn (or against an earlier rig) without registering the two images. Every number is a front→turned _change_ divided by something measured in the same image, which cancels crop and position — **not scale**: the pair must already share framing and head size. A yaw never changes iris height, so that is what is checked — a pair whose mean iris height differs by more than 10% is refused rather than measured as if it were a turn.
|
|
49
|
+
|
|
50
|
+
- **`front`**, **`turned`** — PNG file paths (resolved against the server's working directory). Engine renders (transparent backdrop) and opaque reference art both work; see the two foreground modes below.
|
|
51
|
+
- **`iris`** — optional colour-window override merged over the violet default (`hueMin` 230, `hueMax` 300 degrees, `satMin` 0.22). The iris is found as a saturated blob inside that hue window, closed and paired on one row, so a character whose eyes are another colour needs its own window — otherwise the tool returns `no iris pair found …` naming the file and how many candidate blobs it had.
|
|
52
|
+
- **`debugDir`** — optional existing directory (confined to the working directory, like every other write) to drop a `front-<name>.debug.png` and a `turned-<name>.debug.png` into (role-prefixed, so two inputs that share a basename do not overwrite each other), with the iris boxes, the head edges, the head centre and the eye-pair centre drawn on them. The measurement is only believable once those boxes are seen sitting on the irises.
|
|
53
|
+
- **Result** — `structuredContent` is `{ ok: true, front, turned, farEyeRatio, eyeShift, silhouetteRatio, turnSign, debug? }`, with `front`/`turned` carrying the raw per-image numbers (iris widths and centres, eye row, head span, which foreground mode was used). A missing file, a missing `debugDir`, an image with no iris pair, or a pair whose mean iris heights differ by more than 10% (not at the same scale) returns `{ ok: false, error }` with `INVALID: …` text.
|
|
54
|
+
|
|
55
|
+
The three ratios:
|
|
56
|
+
|
|
57
|
+
| Ratio | What it is |
|
|
58
|
+
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
59
|
+
| `farEyeRatio` | Turned far/near iris width, divided by that same far/near ratio at rest — so a resting asymmetry in the art divides out. |
|
|
60
|
+
| `eyeShift` | How far the eye pair slides across the head, in units of the **front** head half-width (`hh`). **Negative = toward the image's left.** |
|
|
61
|
+
| `silhouetteRatio` | Head half-width, turned over front. |
|
|
62
|
+
|
|
63
|
+
`turnSign` is `-1` when the pair moved toward the image's left and `+1` when it moved right; the "far" eye is the one on the side it moved toward.
|
|
64
|
+
|
|
65
|
+
The head span is the silhouette at the eye row, over a ±10-row band — fixed rather than scaled to the image, so compare renders at like resolutions. The foreground it spans is found two ways, chosen per image:
|
|
66
|
+
|
|
67
|
+
- **alpha** — the file has an alpha channel with transparent pixels (an engine render): foreground is `alpha >= 128` and nothing else, so the character's near-black hair ink and pale highlights all count.
|
|
68
|
+
- **keyed** — a fully opaque image (a reference): the flat lavender-grey backdrop (hue 220–260, low saturation, bright) and near-black frame borders are keyed out by colour instead.
|
|
69
|
+
|
|
70
|
+
The two rules do not agree on the same picture — a near-black outline is silhouette under `alpha` and background under `keyed` — so compare renders with renders and references with references.
|
|
71
|
+
|
|
44
72
|
## Usage
|
|
45
73
|
|
|
46
74
|
Run directly with npx (no install needed):
|
|
@@ -68,7 +96,7 @@ For Claude Desktop this goes in `claude_desktop_config.json`; for Claude Code it
|
|
|
68
96
|
|
|
69
97
|
## Scope note
|
|
70
98
|
|
|
71
|
-
Current tools cover read/validate, auto-rigging a model from PNG layers (`auto_rig_from_layers`),
|
|
99
|
+
Current tools cover read/validate, auto-rigging a model from PNG layers (`auto_rig_from_layers`), composing/measuring the role layers a generated character needs (`compose_layers_from_parts`, `measure_layers`), and measuring a rendered head turn against a reference one (`measure_turn_reference`). PSD input and granular model-mutation primitives (add part, bind parameter, export) are deferred to future slices.
|
|
72
100
|
|
|
73
101
|
## License
|
|
74
102
|
|