@ikijs/mcp 0.26.0 → 0.26.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
@@ -36,7 +36,7 @@ The decode/atlas pipeline runs in Node via `sharp` (a native dependency confined
36
36
 
37
37
  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.
38
38
 
39
- - **`partsDir`** — directory of the source part PNGs (resolved against the server's working directory). Required sources: `face.png`, `eyewhite.png` (split into the sclera, the upper lash and the lower lid — `lash_lower_L`/`lash_lower_R`, the dark line and lashes of the eye's lower part, which draw over the iris and are placed on the sclera's frame by the `eye_*` layout, so they have no layout key of their own; an eyewhite with no dark lower lid writes none and lists them in `skipped`. A light mark drawn detached above the eye white, such as a double-eyelid crease, is dropped from the sclera — the iris's clip — while dark strokes there stay lash ink), `iris.png`, `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.
39
+ - **`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
40
  - **`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.
41
41
  - **`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.
42
42
  - **`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.
@@ -3832,6 +3832,7 @@ var IRIS_W = 50;
3832
3832
  var EYEWHITE_SRC = "eyewhite.png";
3833
3833
  var EYE_LASH_LUMA = 120;
3834
3834
  var LASH_KEEP_FRACTION = 0.5;
3835
+ var EYE_LID_WARMTH = 30;
3835
3836
  var NOSE_TIP_AT = 0.66;
3836
3837
  var DEFAULT_LAYOUT = {
3837
3838
  // Back hair and body sit behind the face. Both are OPTIONAL: a parts dir
@@ -4315,6 +4316,36 @@ async function prepEyeSplit(partsDir) {
4315
4316
  }
4316
4317
  const lashCutoffY = minY + LASH_KEEP_FRACTION * (maxY - minY + 1);
4317
4318
  const detached = detachedAboveWhite(data, W, H);
4319
+ const isDark = (i) => data[i + 3] > 0 && luma(data, i) < EYE_LASH_LUMA;
4320
+ const isLight = (i) => data[i + 3] >= ALPHA_OPAQUE5 && luma(data, i) >= EYE_LASH_LUMA;
4321
+ const isWarm = (i) => data[i] - data[i + 2] >= EYE_LID_WARMTH;
4322
+ const whiteTop = new Int32Array(W).fill(-1);
4323
+ for (let x = 0; x < W; x++) {
4324
+ for (let y = 0; y < H; y++) {
4325
+ const i = (y * W + x) * 4;
4326
+ if (!detached[y * W + x] && isLight(i) && !isWarm(i)) {
4327
+ whiteTop[x] = y;
4328
+ break;
4329
+ }
4330
+ }
4331
+ }
4332
+ let first = 0;
4333
+ while (first < W && whiteTop[first] === -1) first++;
4334
+ if (first < W) {
4335
+ let last = W - 1;
4336
+ while (whiteTop[last] === -1) last--;
4337
+ whiteTop.fill(whiteTop[first], 0, first);
4338
+ whiteTop.fill(whiteTop[last], last + 1);
4339
+ }
4340
+ const lidStop = new Int32Array(W).fill(-1);
4341
+ for (let x = 0; x < W; x++) {
4342
+ for (let y = whiteTop[x] - 1; y >= 0; y--) {
4343
+ if (isDark((y * W + x) * 4)) {
4344
+ lidStop[x] = y;
4345
+ break;
4346
+ }
4347
+ }
4348
+ }
4318
4349
  const sclera = Buffer.from(data);
4319
4350
  const lash = Buffer.from(data);
4320
4351
  const lashLower = Buffer.from(data);
@@ -4322,12 +4353,13 @@ async function prepEyeSplit(partsDir) {
4322
4353
  for (let y = 0; y < H; y++) {
4323
4354
  for (let x = 0; x < W; x++) {
4324
4355
  const i = (y * W + x) * 4;
4325
- const isDark = data[i + 3] > 0 && luma(data, i) < EYE_LASH_LUMA;
4356
+ const dark = isDark(i);
4326
4357
  const upper = y <= lashCutoffY;
4327
- if (isDark && upper) sclera[i] = sclera[i + 1] = sclera[i + 2] = 255;
4358
+ if (dark && upper) sclera[i] = sclera[i + 1] = sclera[i + 2] = 255;
4328
4359
  if (detached[y * W + x]) sclera[i + 3] = 0;
4329
- if (!(isDark && upper)) lash[i + 3] = 0;
4330
- if (isDark && !upper) lowerInk = true;
4360
+ if (y < lidStop[x] && isLight(i) && isWarm(i)) sclera[i + 3] = 0;
4361
+ if (!(dark && upper)) lash[i + 3] = 0;
4362
+ if (dark && !upper) lowerInk = true;
4331
4363
  else lashLower[i + 3] = 0;
4332
4364
  }
4333
4365
  }
@@ -4728,7 +4760,7 @@ function formatPatchReports(reports) {
4728
4760
  });
4729
4761
  }
4730
4762
  function createIkiMcpServer() {
4731
- const server = new McpServer({ name: "iki", version: "0.26.0" });
4763
+ const server = new McpServer({ name: "iki", version: "0.26.1" });
4732
4764
  server.registerTool(
4733
4765
  "validate_iki",
4734
4766
  {
@@ -5059,4 +5091,4 @@ export {
5059
5091
  composeLayersFromParts,
5060
5092
  createIkiMcpServer
5061
5093
  };
5062
- //# sourceMappingURL=chunk-K2CWU4AL.mjs.map
5094
+ //# sourceMappingURL=chunk-GPEGV2AT.mjs.map