@ikijs/mcp 0.39.0 → 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/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createIkiMcpServer
4
- } from "./chunk-KLZ6EOMG.mjs";
4
+ } from "./chunk-3XQLLYUF.mjs";
5
5
 
6
6
  // src/cli.ts
7
7
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
package/dist/index.js CHANGED
@@ -76,7 +76,7 @@ var import_format = require("@ikijs/format");
76
76
  var PLUGIN_ENV = "IKI_PLUGIN";
77
77
  function toolGenerator(env = process.env) {
78
78
  const generator = {
79
- tool: `@ikijs/mcp@${"0.39.0"}`,
79
+ tool: `@ikijs/mcp@${"0.39.1"}`,
80
80
  rigger: `@ikijs/editor@${import_editor.EDITOR_VERSION}`
81
81
  };
82
82
  const plugin = env[PLUGIN_ENV];
@@ -667,6 +667,9 @@ var Spring = class {
667
667
  }
668
668
  }
669
669
  };
670
+ function eyeSpring() {
671
+ return new Spring(EYE_SPRING_OMEGA, EYE_SPRING_ZETA);
672
+ }
670
673
  var IdleMotion = class {
671
674
  /**
672
675
  * Every parameter id {@link update} and `emitRestingPose` write, in write
@@ -692,8 +695,8 @@ var IdleMotion = class {
692
695
  // Gaze state: the scheduled pick starts at eye contact, (0, 0), until the
693
696
  // first retarget. A host target, while set, replaces the pick as what the
694
697
  // eyes and head chase; the schedule keeps picking underneath it.
695
- eyeX = new Spring(EYE_SPRING_OMEGA, EYE_SPRING_ZETA);
696
- eyeY = new Spring(EYE_SPRING_OMEGA, EYE_SPRING_ZETA);
698
+ eyeX = eyeSpring();
699
+ eyeY = eyeSpring();
697
700
  gazeTargetX = 0;
698
701
  gazeTargetY = 0;
699
702
  nextGazeRetargetMs;
@@ -5164,6 +5167,8 @@ var import_node_path9 = __toESM(require("path"));
5164
5167
  // src/measure-arms.ts
5165
5168
  var import_node_path6 = __toESM(require("path"));
5166
5169
  var import_editor7 = require("@ikijs/editor");
5170
+ var UPPER_BODY = 0.35;
5171
+ var NARROW_ROW = 0.6;
5167
5172
  var ARM_ROLES = ["arm_L", "arm_R"];
5168
5173
  var CAP_OVERLAP = 0.5;
5169
5174
  var px = (v) => `${Number(v.toFixed(1))}`;
@@ -5229,6 +5234,19 @@ function capWarning(arm, g, body) {
5229
5234
  const overlap = g.shoulderRadius - g.side * (pivotX - edge);
5230
5235
  const need = CAP_OVERLAP * g.shoulderRadius;
5231
5236
  if (overlap >= need) return void 0;
5237
+ const crop = row - body.bbox.y;
5238
+ const width = (r) => r === void 0 || r.length === 0 ? 0 : r[r.length - 1] - r[0];
5239
+ const here = width(runs);
5240
+ let below = 0;
5241
+ let belowRow = row;
5242
+ const end = Math.ceil(UPPER_BODY * body.bbox.h);
5243
+ for (let k = crop + 1; k < end; k++) {
5244
+ const w = width(body.rowRuns?.[k]);
5245
+ if (w > below) [below, belowRow] = [w, body.bbox.y + k];
5246
+ }
5247
+ if (here < NARROW_ROW * below) {
5248
+ 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).`;
5249
+ }
5232
5250
  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).`;
5233
5251
  }
5234
5252
 
@@ -5691,6 +5709,15 @@ function keyGreen(rgba, W, H) {
5691
5709
  }
5692
5710
  return out;
5693
5711
  }
5712
+ var SPILL_REACH = 3;
5713
+ function despill(rgba, only) {
5714
+ for (let i = 0; i < rgba.length; i += 4) {
5715
+ if (only !== void 0 && !only[i >> 2]) continue;
5716
+ const cap = Math.max(rgba[i], rgba[i + 2]);
5717
+ if (rgba[i + 1] > cap) rgba[i + 1] = cap;
5718
+ }
5719
+ return rgba;
5720
+ }
5694
5721
  var GROUND_TOLERANCE = 4;
5695
5722
  var GROUND_LIGHT = 200;
5696
5723
  var GROUND_MIN = 238;
@@ -5923,6 +5950,21 @@ async function splitLipSet(keyedPng, w, h, interior) {
5923
5950
  const alpha = (p) => frame[p * 4 + 3];
5924
5951
  const { label, main, box: hb } = enclosedHole(frame, w, h);
5925
5952
  const holeW = hb.x1 - hb.x0 + 1;
5953
+ const near = new Uint8Array(n);
5954
+ for (let y = Math.max(0, hb.y0 - SPILL_REACH); y <= Math.min(h - 1, hb.y1 + SPILL_REACH); y++) {
5955
+ for (let x = Math.max(0, hb.x0 - SPILL_REACH); x <= Math.min(w - 1, hb.x1 + SPILL_REACH); x++) {
5956
+ if (label[y * w + x] !== main) continue;
5957
+ for (let dy = -SPILL_REACH; dy <= SPILL_REACH; dy++) {
5958
+ const yy = y + dy;
5959
+ if (yy < 0 || yy >= h) continue;
5960
+ for (let dx = -SPILL_REACH; dx <= SPILL_REACH; dx++) {
5961
+ const xx = x + dx;
5962
+ if (xx >= 0 && xx < w) near[yy * w + xx] = 1;
5963
+ }
5964
+ }
5965
+ }
5966
+ }
5967
+ const paint = despill(Buffer.from(frame), near);
5926
5968
  const top = new Int32Array(w).fill(-1);
5927
5969
  const bot = new Int32Array(w).fill(-1);
5928
5970
  for (let y = 0; y < h; y++) {
@@ -5982,7 +6024,7 @@ async function splitLipSet(keyedPng, w, h, interior) {
5982
6024
  const inner = Buffer.alloc(n * 4);
5983
6025
  const tongue = Buffer.alloc(n * 4);
5984
6026
  const teeth = Buffer.alloc(n * 4);
5985
- const copy = (to, p) => frame.copy(to, p * 4, p * 4, p * 4 + 4);
6027
+ const copy = (to, p) => paint.copy(to, p * 4, p * 4, p * 4 + 4);
5986
6028
  for (let y = 0; y < h; y++) {
5987
6029
  for (let x = 0; x < w; x++) {
5988
6030
  const p = y * w + x;
@@ -6008,7 +6050,7 @@ async function splitLipSet(keyedPng, w, h, interior) {
6008
6050
  }
6009
6051
  if ((inM[p] || wall[x]) && !faintUpper(p, x, y)) {
6010
6052
  const a = alpha(p) / 255;
6011
- for (let c = 0; c < 3; c++) out[c] += (frame[p * 4 + c] - out[c]) * a;
6053
+ for (let c = 0; c < 3; c++) out[c] += (paint[p * 4 + c] - out[c]) * a;
6012
6054
  }
6013
6055
  inner[p * 4] = Math.round(out[0]);
6014
6056
  inner[p * 4 + 1] = Math.round(out[1]);
@@ -6110,7 +6152,9 @@ async function closedLips(upper, lower, shift, left, top) {
6110
6152
  var isLipLayerRole = (role) => import_editor11.LIP_ROLES.includes(role) || (0, import_editor11.isLipInsideRole)(role);
6111
6153
  var MIN_OPENING_ROWS = 8;
6112
6154
  var MIN_LINE_ROWS = 2;
6113
- var GREEN_EXCESS = 40;
6155
+ var GREEN_EXCESS = 16;
6156
+ var KEY_GREEN_EXCESS = 40;
6157
+ var EDGE_REACH = 3;
6114
6158
  var INTERIOR_GAP_FRACTION = 0.05;
6115
6159
  var columns = (cols) => `${cols.length} column${cols.length === 1 ? "" : "s"} (first at x=${cols[0]})`;
6116
6160
  async function lipWarnings(absDir, layers, inPlace = false) {
@@ -6171,17 +6215,49 @@ async function lipWarnings(absDir, layers, inPlace = false) {
6171
6215
  });
6172
6216
  const set = /* @__PURE__ */ new Map();
6173
6217
  const green = [];
6218
+ const pixels = /* @__PURE__ */ new Map();
6174
6219
  for (const role of import_editor11.LIP_ROLES) {
6175
6220
  const fileName = `${role}.png`;
6176
6221
  const { rgba } = await decodePng(import_node_path7.default.join(absDir, fileName));
6177
6222
  set.set(role, measurer.add({ role, fileName, rgba }));
6223
+ pixels.set(role, rgba);
6178
6224
  for (let i = 0; i < rgba.length; i += 4) {
6179
- if (rgba[i + 3] >= import_editor11.ALPHA_OPAQUE && rgba[i + 1] - Math.max(rgba[i], rgba[i + 2]) > GREEN_EXCESS) {
6225
+ if (rgba[i + 3] >= import_editor11.ALPHA_OPAQUE && rgba[i + 1] - Math.max(rgba[i], rgba[i + 2]) > KEY_GREEN_EXCESS) {
6180
6226
  green.push(role);
6181
6227
  break;
6182
6228
  }
6183
6229
  }
6184
6230
  }
6231
+ {
6232
+ const W = inner.canvasW;
6233
+ const H = inner.canvasH;
6234
+ const cavity2 = pixels.get("mouth_inner");
6235
+ const edge = new Uint8Array(W * H);
6236
+ for (let p = 0; p < W * H; p++) {
6237
+ if (cavity2[p * 4 + 3] < 128) continue;
6238
+ const x = p % W;
6239
+ const y = (p - x) / W;
6240
+ for (let dy = -EDGE_REACH; dy <= EDGE_REACH; dy++) {
6241
+ const yy = y + dy;
6242
+ if (yy < 0 || yy >= H) continue;
6243
+ for (let dx = -EDGE_REACH; dx <= EDGE_REACH; dx++) {
6244
+ const xx = x + dx;
6245
+ if (xx >= 0 && xx < W) edge[yy * W + xx] = 1;
6246
+ }
6247
+ }
6248
+ }
6249
+ for (const role of ["lip_upper", "lip_lower"]) {
6250
+ if (green.includes(role)) continue;
6251
+ const rgba = pixels.get(role);
6252
+ for (let p = 0; p < W * H; p++) {
6253
+ const i = p * 4;
6254
+ if (edge[p] && (rgba[i + 1] - Math.max(rgba[i], rgba[i + 2])) * rgba[i + 3] / 255 > GREEN_EXCESS) {
6255
+ green.push(role);
6256
+ break;
6257
+ }
6258
+ }
6259
+ }
6260
+ }
6185
6261
  let opening;
6186
6262
  try {
6187
6263
  opening = (0, import_editor11.mouthOpening)(set);
@@ -6259,7 +6335,11 @@ async function lipWarnings(absDir, layers, inPlace = false) {
6259
6335
  }
6260
6336
  if (!inPlace && green.length > 0) {
6261
6337
  warnings.push(
6262
- `${green.join("/")}: opaque green left (key green, g exceeds r and b by over ${GREEN_EXCESS}) \u2014 it shows as a green fringe on the lips. Regenerate mouth_keyed.png with the green only inside the opening, or mouth_interior.png without green in it. Billed.`
6338
+ `${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(
6339
+ "mouth_keyed.png",
6340
+ // mouth_inner's fill is the interior's own paint, which the composer keeps as drawn.
6341
+ 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"
6342
+ )}`
6263
6343
  );
6264
6344
  }
6265
6345
  if (!inPlace && area > 0 && hollow > INTERIOR_GAP_FRACTION * area) {
@@ -12630,7 +12710,7 @@ function formatBakeChecks(bakes) {
12630
12710
  );
12631
12711
  }
12632
12712
  function createIkiMcpServer() {
12633
- const server = new import_mcp.McpServer({ name: "iki", version: "0.39.0" });
12713
+ const server = new import_mcp.McpServer({ name: "iki", version: "0.39.1" });
12634
12714
  server.registerTool(
12635
12715
  "validate_iki",
12636
12716
  {
@@ -12912,7 +12992,7 @@ function createIkiMcpServer() {
12912
12992
  server.registerTool(
12913
12993
  "compose_layers_from_parts",
12914
12994
  {
12915
- 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`.",
12995
+ 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`.",
12916
12996
  inputSchema: {
12917
12997
  partsDir: import_zod.z.string().describe(
12918
12998
  "Directory of the source part PNGs (resolved against cwd)."
@@ -12960,7 +13040,7 @@ function createIkiMcpServer() {
12960
13040
  server.registerTool(
12961
13041
  "measure_layers",
12962
13042
  {
12963
- 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.",
13043
+ 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.",
12964
13044
  inputSchema: {
12965
13045
  layersDir: import_zod.z.string().describe(
12966
13046
  "Directory of role-named layer PNGs (resolved against cwd)."