@ikijs/mcp 0.14.0 → 0.15.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/dist/cli.js CHANGED
@@ -1287,6 +1287,8 @@ var DEFAULT_LAYOUT = {
1287
1287
  brow_R: { src: "brow.png", cx: 455, cy: 405, w: 135, mirror: true },
1288
1288
  hair_front: { src: "hair_front.png", cx: 550, cy: 425, w: 660 }
1289
1289
  };
1290
+ var LOWER_LASH = { lash_lower_L: "eye_L", lash_lower_R: "eye_R" };
1291
+ var LOWER_LASH_SRC = "eyewhite_lash_lower.png";
1290
1292
  var ORDER = [
1291
1293
  "hair_back",
1292
1294
  "body",
@@ -1300,6 +1302,8 @@ var ORDER = [
1300
1302
  "eye_R",
1301
1303
  "iris_L",
1302
1304
  "iris_R",
1305
+ "lash_lower_L",
1306
+ "lash_lower_R",
1303
1307
  "lash_L",
1304
1308
  "lash_R",
1305
1309
  "brow_L",
@@ -1377,6 +1381,10 @@ async function coreAndBoundsOf(png) {
1377
1381
  bounds: { x: 0, y: 0, w: info.width, h: info.height }
1378
1382
  };
1379
1383
  }
1384
+ async function hasCoverage(png) {
1385
+ const { data, info } = await (0, import_sharp2.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1386
+ return (0, import_editor5.detectAlphaBbox)(data, info.width, info.height) !== null;
1387
+ }
1380
1388
  async function noseSizingOf(png) {
1381
1389
  const { core, bounds } = await coreAndBoundsOf(png);
1382
1390
  if (core === null) return { box: bounds, whole: true };
@@ -1657,13 +1665,18 @@ async function prepEyeSplit(partsDir) {
1657
1665
  const detached = detachedAboveWhite(data, W, H);
1658
1666
  const sclera = Buffer.from(data);
1659
1667
  const lash = Buffer.from(data);
1668
+ const lashLower = Buffer.from(data);
1669
+ let lowerInk = false;
1660
1670
  for (let y = 0; y < H; y++) {
1661
1671
  for (let x = 0; x < W; x++) {
1662
1672
  const i = (y * W + x) * 4;
1663
1673
  const isDark = data[i + 3] > 0 && luma(data, i) < EYE_LASH_LUMA;
1664
- if (isDark) sclera[i] = sclera[i + 1] = sclera[i + 2] = 255;
1674
+ const upper = y <= lashCutoffY;
1675
+ if (isDark && upper) sclera[i] = sclera[i + 1] = sclera[i + 2] = 255;
1665
1676
  if (detached[y * W + x]) sclera[i + 3] = 0;
1666
- if (!(isDark && y <= lashCutoffY)) lash[i + 3] = 0;
1677
+ if (!(isDark && upper)) lash[i + 3] = 0;
1678
+ if (isDark && !upper) lowerInk = true;
1679
+ else lashLower[i + 3] = 0;
1667
1680
  }
1668
1681
  }
1669
1682
  const region = {
@@ -1674,7 +1687,8 @@ async function prepEyeSplit(partsDir) {
1674
1687
  };
1675
1688
  return {
1676
1689
  sclera: await cropToBuffer(sclera, W, H, region),
1677
- lash: await cropToBuffer(lash, W, H, region)
1690
+ lash: await cropToBuffer(lash, W, H, region),
1691
+ lashLower: lowerInk ? await cropToBuffer(lashLower, W, H, region) : null
1678
1692
  };
1679
1693
  }
1680
1694
  async function composeLayersFromParts(input) {
@@ -1693,11 +1707,20 @@ async function composeLayersFromParts(input) {
1693
1707
  ["eyewhite_sclera.png", split.sclera],
1694
1708
  ["eyewhite_lash.png", split.lash]
1695
1709
  ]);
1710
+ if (split.lashLower !== null) {
1711
+ splitSources.set(LOWER_LASH_SRC, split.lashLower);
1712
+ }
1696
1713
  const placed = [];
1697
1714
  const skipped = [];
1698
1715
  let noseSpeck;
1699
1716
  for (const role of ORDER) {
1700
- const cfg = layout[role];
1717
+ const lower = role === "lash_lower_L" || role === "lash_lower_R";
1718
+ const key = lower ? LOWER_LASH[role] : role;
1719
+ if (lower && split.lashLower === null) {
1720
+ skipped.push(role);
1721
+ continue;
1722
+ }
1723
+ const cfg = lower ? { ...layout[key], src: LOWER_LASH_SRC } : layout[key];
1701
1724
  const inMemory = splitSources.get(cfg.src);
1702
1725
  const part = await partBuffer(
1703
1726
  role,
@@ -1707,19 +1730,19 @@ async function composeLayersFromParts(input) {
1707
1730
  // The split halves are cut from eyewhite.png, the file a caller names.
1708
1731
  mirrored.has(inMemory === void 0 ? cfg.src : EYEWHITE_SRC)
1709
1732
  );
1710
- if (part === null) {
1733
+ if (part === null || lower && !await hasCoverage(part.buf)) {
1711
1734
  skipped.push(role);
1712
1735
  continue;
1713
1736
  }
1714
1737
  let left;
1715
1738
  let top;
1716
- if (role === "nose") {
1739
+ if (key === "nose") {
1717
1740
  noseSpeck = part.nose?.speck;
1718
1741
  const { core, bounds } = await coreAndBoundsOf(part.buf);
1719
1742
  const box = part.nose?.whole ? bounds : core ?? bounds;
1720
1743
  ({ left, top } = nosePlacement(layout, box, part.w, part.h));
1721
1744
  } else {
1722
- ({ left, top } = placement(role, layout[role], part.w, part.h));
1745
+ ({ left, top } = placement(key, layout[key], part.w, part.h));
1723
1746
  }
1724
1747
  if (role === "lash_L" || role === "lash_R") {
1725
1748
  const eyeRole = role === "lash_L" ? "eye_L" : "eye_R";
@@ -1778,7 +1801,7 @@ async function composeLayersFromParts(input) {
1778
1801
 
1779
1802
  // src/server.ts
1780
1803
  function createIkiMcpServer() {
1781
- const server = new import_mcp.McpServer({ name: "iki", version: "0.14.0" });
1804
+ const server = new import_mcp.McpServer({ name: "iki", version: "0.15.0" });
1782
1805
  server.registerTool(
1783
1806
  "validate_iki",
1784
1807
  {
@@ -1898,7 +1921,7 @@ function createIkiMcpServer() {
1898
1921
  server.registerTool(
1899
1922
  "compose_layers_from_parts",
1900
1923
  {
1901
- 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, mouth, eyewhite, iris, brow, hair_front are required; hair_back, body, mouth_open, blush (one blush.png makes the blush_L/blush_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). 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.",
1924
+ 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, mouth, eyewhite, iris, brow, hair_front are required; hair_back, body, mouth_open, blush (one blush.png makes the blush_L/blush_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). 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`.",
1902
1925
  inputSchema: {
1903
1926
  partsDir: import_zod.z.string().describe(
1904
1927
  "Directory of the source part PNGs (resolved against cwd)."
@@ -1915,7 +1938,7 @@ function createIkiMcpServer() {
1915
1938
  h: import_zod.z.number()
1916
1939
  }).partial()
1917
1940
  ).optional().describe(
1918
- "Per-role override merged over the built-in defaults, keyed by role \u2014 hair_back, body, face, blush_L, blush_R, nose, mouth, mouth_open, eye_L, eye_R, iris_L, iris_R, lash_L, lash_R, brow_L, brow_R, hair_front \u2014 e.g. `{ eye_L: { cx: 660 } }`. `w` and `h` are integers in 1..1100; omit `h` to keep the part's own aspect, set it to stretch. The nose is sized and placed by its dense core (its pixels at alpha >= 128, the drawing inside a soft nose's feather), not its whole part: `w`/`h` size the core, `cx` centres it, and a set `cy` centres its rows. A nose whose core is a speck \u2014 under a quarter of the trimmed part's width or height, such as a lone nostril mark or highlight \u2014 is sized and placed whole instead, and the report warns of it. Its `cy` defaults to unset, which lands the core's bottom row (the tip) 0.86 of the way from the eye row down to the mouth's, so the nose follows a retuned eye or mouth row. eye_L/lash_L and eye_R/lash_R are cut from one eyewhite into one frame, so each pair must land on the same frame \u2014 a pair set to land apart is rejected."
1941
+ "Per-role override merged over the built-in defaults, keyed by role \u2014 hair_back, body, face, blush_L, blush_R, nose, mouth, mouth_open, eye_L, eye_R, iris_L, iris_R, lash_L, lash_R, brow_L, brow_R, hair_front \u2014 e.g. `{ eye_L: { cx: 660 } }`. `w` and `h` are integers in 1..1100; omit `h` to keep the part's own aspect, set it to stretch. The nose is sized and placed by its dense core (its pixels at alpha >= 128, the drawing inside a soft nose's feather), not its whole part: `w`/`h` size the core, `cx` centres it, and a set `cy` centres its rows. A nose whose core is a speck \u2014 under a quarter of the trimmed part's width or height, such as a lone nostril mark or highlight \u2014 is sized and placed whole instead, and the report warns of it. Its `cy` defaults to unset, which lands the core's bottom row (the tip) 0.86 of the way from the eye row down to the mouth's, so the nose follows a retuned eye or mouth row. eye_L/lash_L and eye_R/lash_R are cut from one eyewhite into one frame, so each pair must land on the same frame \u2014 a pair set to land apart is rejected. lash_lower_L/lash_lower_R are cut from it too and have no key: they land on their eye's frame."
1919
1942
  ),
1920
1943
  mirrorParts: import_zod.z.array(import_zod.z.string()).optional().describe(
1921
1944
  "Part files to flip left-right as they are read, e.g. `[\"eyewhite.png\"]`. The composer reads eyewhite.png as the eye on the screen LEFT (lash wing at the image's left end, lash-free tear duct at its right), brow.png as the brow on the screen RIGHT (thick head at the image's left end, tail at its right), and blush.png as the blush on the screen LEFT (outer end, toward the face's edge, at the image's left end, inner end at its right); a part drawn the other way round is fixed here for free. It flips the source, so every role cut from it flips together and an eye's sclera and lash stay in one frame."