@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/README.md +2 -2
- package/dist/{chunk-PKIN326J.mjs → chunk-V2FRFOKX.mjs} +35 -12
- package/dist/chunk-V2FRFOKX.mjs.map +1 -0
- package/dist/cli.js +33 -10
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +33 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-PKIN326J.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -395,6 +395,13 @@ declare const DEFAULT_LAYOUT: {
|
|
|
395
395
|
};
|
|
396
396
|
};
|
|
397
397
|
type Role = keyof typeof DEFAULT_LAYOUT;
|
|
398
|
+
/** The lower lash of each eye, and the eye whose placement it takes. */
|
|
399
|
+
declare const LOWER_LASH: {
|
|
400
|
+
readonly lash_lower_L: "eye_L";
|
|
401
|
+
readonly lash_lower_R: "eye_R";
|
|
402
|
+
};
|
|
403
|
+
/** A role the composer writes a layer for. */
|
|
404
|
+
type LayerRole = Role | keyof typeof LOWER_LASH;
|
|
398
405
|
/** Per-role placement overrides; anything omitted keeps the default above. */
|
|
399
406
|
type LayoutOverride = Partial<Record<Role, {
|
|
400
407
|
cx?: number;
|
|
@@ -422,7 +429,7 @@ interface ComposeInput {
|
|
|
422
429
|
mirrorParts?: string[];
|
|
423
430
|
}
|
|
424
431
|
interface ComposedLayer {
|
|
425
|
-
role:
|
|
432
|
+
role: LayerRole;
|
|
426
433
|
path: string;
|
|
427
434
|
/** Size of the placed part itself (the file is always CANVAS x CANVAS). */
|
|
428
435
|
width: number;
|
|
@@ -434,8 +441,11 @@ type ComposeResult = {
|
|
|
434
441
|
ok: true;
|
|
435
442
|
outDir: string;
|
|
436
443
|
layers: ComposedLayer[];
|
|
437
|
-
/**
|
|
438
|
-
|
|
444
|
+
/**
|
|
445
|
+
* Roles whose optional part was absent from the parts dir, and the lower
|
|
446
|
+
* lashes when the eyewhite draws no dark lower lid.
|
|
447
|
+
*/
|
|
448
|
+
skipped: LayerRole[];
|
|
439
449
|
preview: string;
|
|
440
450
|
measure: MeasureReport;
|
|
441
451
|
} | {
|
package/dist/index.d.ts
CHANGED
|
@@ -395,6 +395,13 @@ declare const DEFAULT_LAYOUT: {
|
|
|
395
395
|
};
|
|
396
396
|
};
|
|
397
397
|
type Role = keyof typeof DEFAULT_LAYOUT;
|
|
398
|
+
/** The lower lash of each eye, and the eye whose placement it takes. */
|
|
399
|
+
declare const LOWER_LASH: {
|
|
400
|
+
readonly lash_lower_L: "eye_L";
|
|
401
|
+
readonly lash_lower_R: "eye_R";
|
|
402
|
+
};
|
|
403
|
+
/** A role the composer writes a layer for. */
|
|
404
|
+
type LayerRole = Role | keyof typeof LOWER_LASH;
|
|
398
405
|
/** Per-role placement overrides; anything omitted keeps the default above. */
|
|
399
406
|
type LayoutOverride = Partial<Record<Role, {
|
|
400
407
|
cx?: number;
|
|
@@ -422,7 +429,7 @@ interface ComposeInput {
|
|
|
422
429
|
mirrorParts?: string[];
|
|
423
430
|
}
|
|
424
431
|
interface ComposedLayer {
|
|
425
|
-
role:
|
|
432
|
+
role: LayerRole;
|
|
426
433
|
path: string;
|
|
427
434
|
/** Size of the placed part itself (the file is always CANVAS x CANVAS). */
|
|
428
435
|
width: number;
|
|
@@ -434,8 +441,11 @@ type ComposeResult = {
|
|
|
434
441
|
ok: true;
|
|
435
442
|
outDir: string;
|
|
436
443
|
layers: ComposedLayer[];
|
|
437
|
-
/**
|
|
438
|
-
|
|
444
|
+
/**
|
|
445
|
+
* Roles whose optional part was absent from the parts dir, and the lower
|
|
446
|
+
* lashes when the eyewhite draws no dark lower lid.
|
|
447
|
+
*/
|
|
448
|
+
skipped: LayerRole[];
|
|
439
449
|
preview: string;
|
|
440
450
|
measure: MeasureReport;
|
|
441
451
|
} | {
|
package/dist/index.js
CHANGED
|
@@ -1303,6 +1303,8 @@ var DEFAULT_LAYOUT = {
|
|
|
1303
1303
|
brow_R: { src: "brow.png", cx: 455, cy: 405, w: 135, mirror: true },
|
|
1304
1304
|
hair_front: { src: "hair_front.png", cx: 550, cy: 425, w: 660 }
|
|
1305
1305
|
};
|
|
1306
|
+
var LOWER_LASH = { lash_lower_L: "eye_L", lash_lower_R: "eye_R" };
|
|
1307
|
+
var LOWER_LASH_SRC = "eyewhite_lash_lower.png";
|
|
1306
1308
|
var ORDER = [
|
|
1307
1309
|
"hair_back",
|
|
1308
1310
|
"body",
|
|
@@ -1316,6 +1318,8 @@ var ORDER = [
|
|
|
1316
1318
|
"eye_R",
|
|
1317
1319
|
"iris_L",
|
|
1318
1320
|
"iris_R",
|
|
1321
|
+
"lash_lower_L",
|
|
1322
|
+
"lash_lower_R",
|
|
1319
1323
|
"lash_L",
|
|
1320
1324
|
"lash_R",
|
|
1321
1325
|
"brow_L",
|
|
@@ -1393,6 +1397,10 @@ async function coreAndBoundsOf(png) {
|
|
|
1393
1397
|
bounds: { x: 0, y: 0, w: info.width, h: info.height }
|
|
1394
1398
|
};
|
|
1395
1399
|
}
|
|
1400
|
+
async function hasCoverage(png) {
|
|
1401
|
+
const { data, info } = await (0, import_sharp2.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1402
|
+
return (0, import_editor5.detectAlphaBbox)(data, info.width, info.height) !== null;
|
|
1403
|
+
}
|
|
1396
1404
|
async function noseSizingOf(png) {
|
|
1397
1405
|
const { core, bounds } = await coreAndBoundsOf(png);
|
|
1398
1406
|
if (core === null) return { box: bounds, whole: true };
|
|
@@ -1673,13 +1681,18 @@ async function prepEyeSplit(partsDir) {
|
|
|
1673
1681
|
const detached = detachedAboveWhite(data, W, H);
|
|
1674
1682
|
const sclera = Buffer.from(data);
|
|
1675
1683
|
const lash = Buffer.from(data);
|
|
1684
|
+
const lashLower = Buffer.from(data);
|
|
1685
|
+
let lowerInk = false;
|
|
1676
1686
|
for (let y = 0; y < H; y++) {
|
|
1677
1687
|
for (let x = 0; x < W; x++) {
|
|
1678
1688
|
const i = (y * W + x) * 4;
|
|
1679
1689
|
const isDark = data[i + 3] > 0 && luma(data, i) < EYE_LASH_LUMA;
|
|
1680
|
-
|
|
1690
|
+
const upper = y <= lashCutoffY;
|
|
1691
|
+
if (isDark && upper) sclera[i] = sclera[i + 1] = sclera[i + 2] = 255;
|
|
1681
1692
|
if (detached[y * W + x]) sclera[i + 3] = 0;
|
|
1682
|
-
if (!(isDark &&
|
|
1693
|
+
if (!(isDark && upper)) lash[i + 3] = 0;
|
|
1694
|
+
if (isDark && !upper) lowerInk = true;
|
|
1695
|
+
else lashLower[i + 3] = 0;
|
|
1683
1696
|
}
|
|
1684
1697
|
}
|
|
1685
1698
|
const region = {
|
|
@@ -1690,7 +1703,8 @@ async function prepEyeSplit(partsDir) {
|
|
|
1690
1703
|
};
|
|
1691
1704
|
return {
|
|
1692
1705
|
sclera: await cropToBuffer(sclera, W, H, region),
|
|
1693
|
-
lash: await cropToBuffer(lash, W, H, region)
|
|
1706
|
+
lash: await cropToBuffer(lash, W, H, region),
|
|
1707
|
+
lashLower: lowerInk ? await cropToBuffer(lashLower, W, H, region) : null
|
|
1694
1708
|
};
|
|
1695
1709
|
}
|
|
1696
1710
|
async function composeLayersFromParts(input) {
|
|
@@ -1709,11 +1723,20 @@ async function composeLayersFromParts(input) {
|
|
|
1709
1723
|
["eyewhite_sclera.png", split.sclera],
|
|
1710
1724
|
["eyewhite_lash.png", split.lash]
|
|
1711
1725
|
]);
|
|
1726
|
+
if (split.lashLower !== null) {
|
|
1727
|
+
splitSources.set(LOWER_LASH_SRC, split.lashLower);
|
|
1728
|
+
}
|
|
1712
1729
|
const placed = [];
|
|
1713
1730
|
const skipped = [];
|
|
1714
1731
|
let noseSpeck;
|
|
1715
1732
|
for (const role of ORDER) {
|
|
1716
|
-
const
|
|
1733
|
+
const lower = role === "lash_lower_L" || role === "lash_lower_R";
|
|
1734
|
+
const key = lower ? LOWER_LASH[role] : role;
|
|
1735
|
+
if (lower && split.lashLower === null) {
|
|
1736
|
+
skipped.push(role);
|
|
1737
|
+
continue;
|
|
1738
|
+
}
|
|
1739
|
+
const cfg = lower ? { ...layout[key], src: LOWER_LASH_SRC } : layout[key];
|
|
1717
1740
|
const inMemory = splitSources.get(cfg.src);
|
|
1718
1741
|
const part = await partBuffer(
|
|
1719
1742
|
role,
|
|
@@ -1723,19 +1746,19 @@ async function composeLayersFromParts(input) {
|
|
|
1723
1746
|
// The split halves are cut from eyewhite.png, the file a caller names.
|
|
1724
1747
|
mirrored.has(inMemory === void 0 ? cfg.src : EYEWHITE_SRC)
|
|
1725
1748
|
);
|
|
1726
|
-
if (part === null) {
|
|
1749
|
+
if (part === null || lower && !await hasCoverage(part.buf)) {
|
|
1727
1750
|
skipped.push(role);
|
|
1728
1751
|
continue;
|
|
1729
1752
|
}
|
|
1730
1753
|
let left;
|
|
1731
1754
|
let top;
|
|
1732
|
-
if (
|
|
1755
|
+
if (key === "nose") {
|
|
1733
1756
|
noseSpeck = part.nose?.speck;
|
|
1734
1757
|
const { core, bounds } = await coreAndBoundsOf(part.buf);
|
|
1735
1758
|
const box = part.nose?.whole ? bounds : core ?? bounds;
|
|
1736
1759
|
({ left, top } = nosePlacement(layout, box, part.w, part.h));
|
|
1737
1760
|
} else {
|
|
1738
|
-
({ left, top } = placement(
|
|
1761
|
+
({ left, top } = placement(key, layout[key], part.w, part.h));
|
|
1739
1762
|
}
|
|
1740
1763
|
if (role === "lash_L" || role === "lash_R") {
|
|
1741
1764
|
const eyeRole = role === "lash_L" ? "eye_L" : "eye_R";
|
|
@@ -1796,7 +1819,7 @@ async function composeLayersFromParts(input) {
|
|
|
1796
1819
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
1797
1820
|
var import_zod = require("zod");
|
|
1798
1821
|
function createIkiMcpServer() {
|
|
1799
|
-
const server = new import_mcp.McpServer({ name: "iki", version: "0.
|
|
1822
|
+
const server = new import_mcp.McpServer({ name: "iki", version: "0.15.0" });
|
|
1800
1823
|
server.registerTool(
|
|
1801
1824
|
"validate_iki",
|
|
1802
1825
|
{
|
|
@@ -1916,7 +1939,7 @@ function createIkiMcpServer() {
|
|
|
1916
1939
|
server.registerTool(
|
|
1917
1940
|
"compose_layers_from_parts",
|
|
1918
1941
|
{
|
|
1919
|
-
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.",
|
|
1942
|
+
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`.",
|
|
1920
1943
|
inputSchema: {
|
|
1921
1944
|
partsDir: import_zod.z.string().describe(
|
|
1922
1945
|
"Directory of the source part PNGs (resolved against cwd)."
|
|
@@ -1933,7 +1956,7 @@ function createIkiMcpServer() {
|
|
|
1933
1956
|
h: import_zod.z.number()
|
|
1934
1957
|
}).partial()
|
|
1935
1958
|
).optional().describe(
|
|
1936
|
-
"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."
|
|
1959
|
+
"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."
|
|
1937
1960
|
),
|
|
1938
1961
|
mirrorParts: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
1939
1962
|
"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."
|