@ikijs/mcp 0.13.5 → 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 +4 -4
- package/dist/{chunk-FYHLTB6F.mjs → chunk-V2FRFOKX.mjs} +38 -15
- package/dist/chunk-V2FRFOKX.mjs.map +1 -0
- package/dist/cli.js +36 -13
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +36 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-FYHLTB6F.mjs.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1164,7 +1164,7 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
1164
1164
|
["hair_back", "without it the silhouette is flat behind the face"],
|
|
1165
1165
|
[
|
|
1166
1166
|
"nose",
|
|
1167
|
-
"without it the head still turns on the
|
|
1167
|
+
"without it the head still turns on the default profile, but there is no nose to lead it, and no turn fit to the art (`turnTargets` is inert, no `turn` report)"
|
|
1168
1168
|
]
|
|
1169
1169
|
]) {
|
|
1170
1170
|
if (layers[role] === void 0) warnings.push(`${role}: missing \u2014 ${why}.`);
|
|
@@ -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
|
-
|
|
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 &&
|
|
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
|
|
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 (
|
|
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(
|
|
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.
|
|
1804
|
+
const server = new import_mcp.McpServer({ name: "iki", version: "0.15.0" });
|
|
1782
1805
|
server.registerTool(
|
|
1783
1806
|
"validate_iki",
|
|
1784
1807
|
{
|
|
@@ -1866,7 +1889,7 @@ function createIkiMcpServer() {
|
|
|
1866
1889
|
noseShift: import_zod.z.number().optional(),
|
|
1867
1890
|
mouthShift: import_zod.z.number().optional()
|
|
1868
1891
|
}).passthrough().optional().describe(
|
|
1869
|
-
"What the head turn is fitted to, as `measure_turn_reference` reports it off a front/turned reference pair. `eyeShift` (and the optional `noseShift`/`mouthShift`) is how far that feature slides across the head at full turn, as a fraction of the head's half-width \u2014 a MAGNITUDE: the rig turns both ways, so the sign is ignored. `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. The half-width the shifts are fractions of is measured off the layers themselves, so it is not an input. An omitted field leaves that part of the turn at the
|
|
1892
|
+
"What the head turn is fitted to, as `measure_turn_reference` reports it off a front/turned reference pair. `eyeShift` (and the optional `noseShift`/`mouthShift`) is how far that feature slides across the head at full turn, as a fraction of the head's half-width \u2014 a MAGNITUDE: the rig turns both ways, so the sign is ignored. `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. The half-width the shifts are fractions of is measured off the layers themselves, so it is not an input. An omitted field leaves that part of the turn at the profile the rig defaults to. A passed `eyeShift` is fitted by the turn's amount and clamped to the room the art leaves the far eye \u2014 the face plate's edge, or the bangs' side strand over the far iris (the result's `turn.clamped` lists every clamped field, `turn.achieved` what the rig reaches, and `turn.strandOverlap` how much of a far iris the bangs still cover). A passed `silhouetteRatio` is clamped too, only on a face drawn without hair and with ear islands, where narrowing the head that far would no longer cover the far ear's slide. Any other passed target this layer set cannot reach comes back as `INVALID: \u2026` naming the field and the attainable range, since it is a measurement rather than a preference. A field not named here is refused the same way."
|
|
1870
1893
|
),
|
|
1871
1894
|
style: import_zod.z.object({
|
|
1872
1895
|
turn: import_zod.z.number().optional(),
|
|
@@ -1876,7 +1899,7 @@ function createIkiMcpServer() {
|
|
|
1876
1899
|
blink: import_zod.z.number().optional(),
|
|
1877
1900
|
sway: import_zod.z.number().optional()
|
|
1878
1901
|
}).passthrough().optional().describe(
|
|
1879
|
-
"Per-character tuning from the
|
|
1902
|
+
"Per-character tuning from the profile the rig defaults to: `turn` scales the whole head turn (plate, features, hair and the eyes' foreshortening; 0..3, 1 = the profile; ignored when `turnTargets.eyeShift` is given), `featureLead` how far the features lead the face plate (0..3, 1 = the profile), `hairFollow` the front hair's share of the face's turn (0..2, profile 1), `outlineFollow` its outer edge's share where the front hair draws the head's outline (0..2, profile 0: the outline holds), `blink` how far the upper lid comes down over the eye's height (0.1..1, profile 0.6), `sway` the hair sway amplitude (0..5, 1 = the profile). A value out of range, or a knob not named here, comes back as `INVALID: \u2026`."
|
|
1880
1903
|
)
|
|
1881
1904
|
}
|
|
1882
1905
|
},
|
|
@@ -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
|
|
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."
|