@ikijs/mcp 0.18.0 → 0.19.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 +10 -9
- package/dist/{chunk-JKH44M2Z.mjs → chunk-E6DLZPCX.mjs} +283 -72
- package/dist/chunk-E6DLZPCX.mjs.map +1 -0
- package/dist/cli.js +289 -90
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +31 -6
- package/dist/index.d.ts +31 -6
- package/dist/index.js +289 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-JKH44M2Z.mjs.map +0 -1
|
@@ -28,10 +28,10 @@ import path from "path";
|
|
|
28
28
|
var MAX_LAYERS = 64;
|
|
29
29
|
var MAX_LAYER_DIM = 4096;
|
|
30
30
|
var MAX_CANVAS_DIM = 4096;
|
|
31
|
-
var
|
|
31
|
+
var MAX_ATLAS_SIDE = 4096;
|
|
32
32
|
var MAX_INPUT_PIXELS = 4096 * 4096;
|
|
33
|
-
var MAX_TOTAL_PIXELS =
|
|
34
|
-
var MAX_OUTPUT_BYTES =
|
|
33
|
+
var MAX_TOTAL_PIXELS = 128 * 1024 * 1024;
|
|
34
|
+
var MAX_OUTPUT_BYTES = 12 * 1024 * 1024;
|
|
35
35
|
var AutoRigInputError = class extends Error {
|
|
36
36
|
constructor(message) {
|
|
37
37
|
super(message);
|
|
@@ -410,9 +410,13 @@ async function renderAtlasPage(crops, quantizeColors) {
|
|
|
410
410
|
const layout = packAtlas(
|
|
411
411
|
crops.map((c) => ({ id: c.id, width: c.width, height: c.height }))
|
|
412
412
|
);
|
|
413
|
-
|
|
413
|
+
const over = layout.pageWidth > MAX_ATLAS_SIDE ? { side: "width", crop: "widest" } : layout.pageHeight > MAX_ATLAS_SIDE ? { side: "height", crop: "tallest" } : void 0;
|
|
414
|
+
if (over !== void 0) {
|
|
415
|
+
const crop = layout.placements.reduce(
|
|
416
|
+
(a, b) => b[over.side] > a[over.side] ? b : a
|
|
417
|
+
);
|
|
414
418
|
throw new AutoRigInputError(
|
|
415
|
-
`atlas page ${layout.pageWidth}x${layout.pageHeight} exceeds max
|
|
419
|
+
`atlas page ${layout.pageWidth}x${layout.pageHeight} exceeds max side ${MAX_ATLAS_SIDE} (its ${over.crop} crop: "${crop.id}" ${crop.width}x${crop.height})`
|
|
416
420
|
);
|
|
417
421
|
}
|
|
418
422
|
const dataUri = await renderAtlasToDataUri(crops, layout, quantizeColors);
|
|
@@ -962,7 +966,84 @@ function formatTurnReport(result) {
|
|
|
962
966
|
|
|
963
967
|
// src/measure.ts
|
|
964
968
|
import fs2 from "fs";
|
|
969
|
+
import path5 from "path";
|
|
970
|
+
|
|
971
|
+
// src/measure-arms.ts
|
|
965
972
|
import path4 from "path";
|
|
973
|
+
import {
|
|
974
|
+
LayerGeometryError as LayerGeometryError2,
|
|
975
|
+
armGeometry,
|
|
976
|
+
createLayerSetMeasurer as createLayerSetMeasurer2
|
|
977
|
+
} from "@ikijs/editor";
|
|
978
|
+
var ARM_ROLES = ["arm_L", "arm_R"];
|
|
979
|
+
var CAP_OVERLAP = 0.5;
|
|
980
|
+
var px = (v) => `${Number(v.toFixed(1))}`;
|
|
981
|
+
async function measured(measurer, absDir, role) {
|
|
982
|
+
const fileName = `${role}.png`;
|
|
983
|
+
const { rgba } = await decodePng(path4.join(absDir, fileName));
|
|
984
|
+
return measurer.add({ role, fileName, rgba });
|
|
985
|
+
}
|
|
986
|
+
async function armWarnings(absDir, layers) {
|
|
987
|
+
const warnings = [];
|
|
988
|
+
const body = layers.body;
|
|
989
|
+
let set;
|
|
990
|
+
for (const arm of ARM_ROLES) {
|
|
991
|
+
const stats = layers[arm];
|
|
992
|
+
if (stats === void 0) continue;
|
|
993
|
+
if (body === void 0) {
|
|
994
|
+
warnings.push(
|
|
995
|
+
`${arm}: no body layer \u2014 an arm hangs from the body's shoulder, and auto_rig_from_layers refuses it.`
|
|
996
|
+
);
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
999
|
+
if (stats.canvasW !== body.canvasW || stats.canvasH !== body.canvasH) {
|
|
1000
|
+
warnings.push(
|
|
1001
|
+
`${arm}: its canvas ${stats.canvasW}x${stats.canvasH} differs from body's ${body.canvasW}x${body.canvasH} \u2014 auto_rig_from_layers refuses layers of different sizes; recompose them together.`
|
|
1002
|
+
);
|
|
1003
|
+
continue;
|
|
1004
|
+
}
|
|
1005
|
+
if (set === void 0) {
|
|
1006
|
+
const measurer = createLayerSetMeasurer2({
|
|
1007
|
+
width: body.canvasW,
|
|
1008
|
+
height: body.canvasH
|
|
1009
|
+
});
|
|
1010
|
+
set = { measurer, body: await measured(measurer, absDir, "body") };
|
|
1011
|
+
}
|
|
1012
|
+
let g;
|
|
1013
|
+
try {
|
|
1014
|
+
g = armGeometry(
|
|
1015
|
+
await measured(set.measurer, absDir, arm),
|
|
1016
|
+
set.body.bbox.x + set.body.bbox.w / 2 - body.canvasW / 2
|
|
1017
|
+
);
|
|
1018
|
+
} catch (err) {
|
|
1019
|
+
if (err instanceof LayerGeometryError2) {
|
|
1020
|
+
warnings.push(
|
|
1021
|
+
`${arm}: ${err.message} \u2014 auto_rig_from_layers refuses it. Regenerate arm.png drawn hanging, shoulder at the top. Billed.`
|
|
1022
|
+
);
|
|
1023
|
+
continue;
|
|
1024
|
+
}
|
|
1025
|
+
throw err;
|
|
1026
|
+
}
|
|
1027
|
+
const cap = capWarning(arm, g, set.body);
|
|
1028
|
+
if (cap !== void 0) warnings.push(cap);
|
|
1029
|
+
}
|
|
1030
|
+
return warnings;
|
|
1031
|
+
}
|
|
1032
|
+
function capWarning(arm, g, body) {
|
|
1033
|
+
const pivotX = g.shoulder.x + body.canvasW / 2;
|
|
1034
|
+
const row = Math.floor(body.canvasH / 2 - g.shoulder.y);
|
|
1035
|
+
const runs = body.rowRuns?.[row - body.bbox.y] ?? [];
|
|
1036
|
+
if (runs.length === 0) {
|
|
1037
|
+
return `${arm}: the body has no paint on its shoulder pivot's row (y=${row}) \u2014 the torso shows a gap beside the shoulder once the arm raises. Retune layout.${arm}.cy onto the shoulder (free).`;
|
|
1038
|
+
}
|
|
1039
|
+
const edge = g.side === 1 ? runs[runs.length - 1] : runs[0];
|
|
1040
|
+
const overlap = g.shoulderRadius - g.side * (pivotX - edge);
|
|
1041
|
+
const need = CAP_OVERLAP * g.shoulderRadius;
|
|
1042
|
+
if (overlap >= need) return void 0;
|
|
1043
|
+
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).`;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
// src/measure.ts
|
|
966
1047
|
var IRIS_RATIO_MIN = 0.45;
|
|
967
1048
|
var IRIS_RATIO_MAX = 0.72;
|
|
968
1049
|
var EYE_ASPECT_MIN = 0.5;
|
|
@@ -1051,6 +1132,7 @@ async function layerStats(filePath) {
|
|
|
1051
1132
|
};
|
|
1052
1133
|
}
|
|
1053
1134
|
var pct = (v) => `${(v * 100).toFixed(0)}%`;
|
|
1135
|
+
var isArm = (role) => ARM_ROLES.includes(role);
|
|
1054
1136
|
function noseSpeckWarning({ core, part }, source) {
|
|
1055
1137
|
const [found, consequence] = source === "compose" ? [
|
|
1056
1138
|
`the source part's dense core is ${core.w}x${core.h} in its ${part.w}x${part.h} trimmed part`,
|
|
@@ -1077,7 +1159,7 @@ async function lashOffSclera(eyePath, lashPath) {
|
|
|
1077
1159
|
return { opaque, off };
|
|
1078
1160
|
}
|
|
1079
1161
|
async function measureDir(absDir, noseSpeck) {
|
|
1080
|
-
const files = fs2.readdirSync(absDir).filter((f) => f.endsWith(".png") && f
|
|
1162
|
+
const files = fs2.readdirSync(absDir).filter((f) => f.endsWith(".png") && !f.startsWith("preview")).sort();
|
|
1081
1163
|
if (files.length === 0) {
|
|
1082
1164
|
throw new AutoRigInputError(`no role layers in ${absDir}`);
|
|
1083
1165
|
}
|
|
@@ -1089,8 +1171,8 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
1089
1171
|
const layers = {};
|
|
1090
1172
|
const empty = [];
|
|
1091
1173
|
for (const f of files) {
|
|
1092
|
-
const role =
|
|
1093
|
-
const m = await layerStats(
|
|
1174
|
+
const role = path5.basename(f, ".png");
|
|
1175
|
+
const m = await layerStats(path5.join(absDir, f));
|
|
1094
1176
|
if (!m) {
|
|
1095
1177
|
empty.push(role);
|
|
1096
1178
|
continue;
|
|
@@ -1104,8 +1186,13 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
1104
1186
|
["left", m.edgeLeft, m.h, m.marginLeft],
|
|
1105
1187
|
["right", m.edgeRight, m.h, m.marginRight]
|
|
1106
1188
|
];
|
|
1107
|
-
if (role !== "body")
|
|
1189
|
+
if (role !== "body") {
|
|
1108
1190
|
edges.push(["bottom", m.edgeBottom, m.w, m.marginBottom]);
|
|
1191
|
+
} else if (m.canvasH > m.canvasW && m.marginBottom === 0) {
|
|
1192
|
+
warnings.push(
|
|
1193
|
+
`body: its bottom row is the canvas's last \u2014 on a tall canvas that cuts the feet off. Free fix: raise canvasHeight (the canvas grows downward, nothing else moves) and remeasure; regenerate body.png only if the drawing itself stops short of the soles.`
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1109
1196
|
for (const [side, v, span, margin] of edges) {
|
|
1110
1197
|
if (v > EDGE_SOLID_MAX && v * span >= EDGE_RUN_MIN_PX) {
|
|
1111
1198
|
const remedy = margin === 0 ? (
|
|
@@ -1117,7 +1204,7 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
1117
1204
|
`it sits flush against the canvas ${side}, which a clipped placement and already-cropped art both produce. Move it inward first \u2014 retune layout.${role}.cx/cy/w, free \u2014 and remeasure; regenerate only if the edge is still opaque with margin to spare.`
|
|
1118
1205
|
) : `its own drawing runs to the frame ${margin} px inside the canvas \u2014 regenerate that part with empty margin on that side. Billed.`;
|
|
1119
1206
|
warnings.push(
|
|
1120
|
-
`${role}: ${pct(v)} of its ${side} edge is opaque \u2014 the art is cut off there, which shows as a straight seam once the head turns. Cause: ${remedy}`
|
|
1207
|
+
`${role}: ${pct(v)} of its ${side} edge is opaque \u2014 the art is cut off there, which shows as a straight seam ${isArm(role) ? "once the arm raises" : "once the head turns"}. Cause: ${remedy}`
|
|
1121
1208
|
);
|
|
1122
1209
|
}
|
|
1123
1210
|
}
|
|
@@ -1126,10 +1213,11 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
1126
1213
|
if (role === "body") continue;
|
|
1127
1214
|
if (m.flatCutRun > FLAT_CUT_MAX_FRAC * m.w && m.flatCutRun >= FLAT_CUT_MIN_PX) {
|
|
1128
1215
|
warnings.push(
|
|
1129
|
-
`${role}: ${m.flatCutRun}px of straight flat edge at y=${m.flatCutY} (${pct(m.flatCutRun / m.w)} of its width) \u2014 the source art is cut through there. It hides while the head faces front and opens into a seam on turn. Regenerate this part with the whole subject inside the frame.`
|
|
1216
|
+
`${role}: ${m.flatCutRun}px of straight flat edge at y=${m.flatCutY} (${pct(m.flatCutRun / m.w)} of its width) \u2014 the source art is cut through there. ` + (isArm(role) ? `It hides at rest and opens into a seam once the arm raises. ` : `It hides while the head faces front and opens into a seam on turn. `) + `Regenerate this part with the whole subject inside the frame.`
|
|
1130
1217
|
);
|
|
1131
1218
|
}
|
|
1132
1219
|
}
|
|
1220
|
+
warnings.push(...await armWarnings(absDir, layers));
|
|
1133
1221
|
for (const side of ["L", "R"]) {
|
|
1134
1222
|
const eye = layers[`eye_${side}`];
|
|
1135
1223
|
const iris = layers[`iris_${side}`];
|
|
@@ -1158,8 +1246,8 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
1158
1246
|
}
|
|
1159
1247
|
if (lash) {
|
|
1160
1248
|
const { opaque, off } = await lashOffSclera(
|
|
1161
|
-
|
|
1162
|
-
|
|
1249
|
+
path5.join(absDir, `eye_${side}.png`),
|
|
1250
|
+
path5.join(absDir, `lash_${side}.png`)
|
|
1163
1251
|
);
|
|
1164
1252
|
const dTop = lash.marginTop - eye.marginTop;
|
|
1165
1253
|
const faults = [
|
|
@@ -1185,7 +1273,7 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
1185
1273
|
if (noseSpeck !== void 0) {
|
|
1186
1274
|
warnings.push(noseSpeckWarning(noseSpeck, "compose"));
|
|
1187
1275
|
} else if (layers.nose !== void 0) {
|
|
1188
|
-
const nose = await decodePng(
|
|
1276
|
+
const nose = await decodePng(path5.join(absDir, "nose.png"));
|
|
1189
1277
|
const core = denseCoreOf(nose.rgba, nose.width, nose.height);
|
|
1190
1278
|
if (core !== null) {
|
|
1191
1279
|
const crop = detectAlphaBbox(nose.rgba, nose.width, nose.height);
|
|
@@ -1248,10 +1336,62 @@ function formatMeasureReport(result) {
|
|
|
1248
1336
|
|
|
1249
1337
|
// src/compose.ts
|
|
1250
1338
|
import fs3 from "fs";
|
|
1251
|
-
import
|
|
1252
|
-
import
|
|
1339
|
+
import path6 from "path";
|
|
1340
|
+
import sharp3 from "sharp";
|
|
1253
1341
|
import { ALPHA_OPAQUE as ALPHA_OPAQUE2, detectAlphaBbox as scanAlphaBbox2 } from "@ikijs/editor";
|
|
1342
|
+
|
|
1343
|
+
// src/compose-arms.ts
|
|
1344
|
+
import sharp2 from "sharp";
|
|
1345
|
+
import {
|
|
1346
|
+
LayerGeometryError as LayerGeometryError3,
|
|
1347
|
+
armGeometry as armGeometry2,
|
|
1348
|
+
createLayerSetMeasurer as createLayerSetMeasurer3
|
|
1349
|
+
} from "@ikijs/editor";
|
|
1350
|
+
var ARM_WIDTH = 0.4;
|
|
1351
|
+
var SHOULDER_DROP = 0.12;
|
|
1352
|
+
async function armPlacement(role, cfg, part, body) {
|
|
1353
|
+
const { data } = await sharp2(part.buf).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1354
|
+
const layer = createLayerSetMeasurer3({ width: part.w, height: part.h }).add({
|
|
1355
|
+
role,
|
|
1356
|
+
fileName: "arm.png",
|
|
1357
|
+
rgba: data
|
|
1358
|
+
});
|
|
1359
|
+
if (layer === null) {
|
|
1360
|
+
throw new AutoRigInputError(
|
|
1361
|
+
`layout.${role}: arm.png is empty after alpha threshold once resized`
|
|
1362
|
+
);
|
|
1363
|
+
}
|
|
1364
|
+
let shoulder;
|
|
1365
|
+
try {
|
|
1366
|
+
({ shoulder } = armGeometry2(
|
|
1367
|
+
layer,
|
|
1368
|
+
role === "arm_R" ? Infinity : -Infinity
|
|
1369
|
+
));
|
|
1370
|
+
} catch (err) {
|
|
1371
|
+
if (err instanceof LayerGeometryError3) {
|
|
1372
|
+
throw new AutoRigInputError(`layout.${role}: ${err.message}`);
|
|
1373
|
+
}
|
|
1374
|
+
throw err;
|
|
1375
|
+
}
|
|
1376
|
+
const pivotX = shoulder.x + part.w / 2;
|
|
1377
|
+
const pivotY = part.h / 2 - shoulder.y;
|
|
1378
|
+
const cornerX = role === "arm_R" ? body.left : body.left + body.w;
|
|
1379
|
+
const cornerY = body.top + SHOULDER_DROP * body.h;
|
|
1380
|
+
return {
|
|
1381
|
+
left: Math.round(
|
|
1382
|
+
cfg.cx === void 0 ? cornerX - pivotX : cfg.cx - part.w / 2
|
|
1383
|
+
),
|
|
1384
|
+
top: Math.round(
|
|
1385
|
+
cfg.cy === void 0 ? cornerY - pivotY : cfg.cy - part.h / 2
|
|
1386
|
+
)
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
// src/compose.ts
|
|
1254
1391
|
var CANVAS = 1100;
|
|
1392
|
+
function canvasName(canvas) {
|
|
1393
|
+
return canvas.width === canvas.height ? `${canvas.width}` : `${canvas.width}x${canvas.height}`;
|
|
1394
|
+
}
|
|
1255
1395
|
var EYE_W = 98;
|
|
1256
1396
|
var IRIS_W = 50;
|
|
1257
1397
|
var EYEWHITE_SRC = "eyewhite.png";
|
|
@@ -1264,9 +1404,17 @@ var DEFAULT_LAYOUT = {
|
|
|
1264
1404
|
// Back hair and body sit behind the face. Both are OPTIONAL: a parts dir
|
|
1265
1405
|
// without them still composes (head-only character).
|
|
1266
1406
|
hair_back: { src: "hair_back.png", cx: 550, cy: 523, w: 800, optional: true },
|
|
1267
|
-
// The torso, cut off by
|
|
1268
|
-
// floating head
|
|
1407
|
+
// The bust's torso, cut off by a square canvas's bottom, so the character is
|
|
1408
|
+
// not a floating head; a full body on a tall canvas sets `layout.body`
|
|
1409
|
+
// itself. It rides the rig's `bodyWarp`, which the head hangs from.
|
|
1269
1410
|
body: { src: "body.png", cx: 550, cy: 1017, w: 840, optional: true },
|
|
1411
|
+
// The arms, one part for both: arm_R (screen left) takes arm.png as drawn
|
|
1412
|
+
// and arm_L mirrors it, like the blush. They draw over the body and under
|
|
1413
|
+
// the face. They have no cx/cy/w defaults: each is derived from the placed
|
|
1414
|
+
// body (ArmLayout). OPTIONAL and opt-in: a parts dir without arm.png
|
|
1415
|
+
// composes as a bust does, and `skipped` never lists them.
|
|
1416
|
+
arm_L: { src: "arm.png", optional: true, mirror: true },
|
|
1417
|
+
arm_R: { src: "arm.png", optional: true, mirror: false },
|
|
1270
1418
|
// The face is drawn without a neck, so its box is the skull and centres
|
|
1271
1419
|
// above the eye row (bob's skull at 437 against his eyes' 475).
|
|
1272
1420
|
face: { src: "face.png", cx: 550, cy: 437, w: 400 },
|
|
@@ -1331,6 +1479,8 @@ var LOWER_LASH_SRC = "eyewhite_lash_lower.png";
|
|
|
1331
1479
|
var ORDER = [
|
|
1332
1480
|
"hair_back",
|
|
1333
1481
|
"body",
|
|
1482
|
+
"arm_L",
|
|
1483
|
+
"arm_R",
|
|
1334
1484
|
"face",
|
|
1335
1485
|
"blush_L",
|
|
1336
1486
|
"blush_R",
|
|
@@ -1369,7 +1519,7 @@ var FACE_FEATURES = [
|
|
|
1369
1519
|
"brow_L",
|
|
1370
1520
|
"brow_R"
|
|
1371
1521
|
];
|
|
1372
|
-
function resolveLayout(overrides) {
|
|
1522
|
+
function resolveLayout(overrides, canvas) {
|
|
1373
1523
|
const resolved = { ...DEFAULT_LAYOUT };
|
|
1374
1524
|
if (overrides === void 0) return resolved;
|
|
1375
1525
|
const sets = /* @__PURE__ */ new Map();
|
|
@@ -1394,9 +1544,10 @@ function resolveLayout(overrides) {
|
|
|
1394
1544
|
for (const field of ["w", "h"]) {
|
|
1395
1545
|
const value = override[field];
|
|
1396
1546
|
if (value === void 0) continue;
|
|
1397
|
-
|
|
1547
|
+
const max = field === "w" ? canvas.width : canvas.height;
|
|
1548
|
+
if (!Number.isInteger(value) || value < 1 || value > max) {
|
|
1398
1549
|
throw new AutoRigInputError(
|
|
1399
|
-
`layout.${role}.${field} must be an integer in 1..${
|
|
1550
|
+
`layout.${role}.${field} must be an integer in 1..${max}, got ${String(value)}`
|
|
1400
1551
|
);
|
|
1401
1552
|
}
|
|
1402
1553
|
set[field] = value;
|
|
@@ -1424,10 +1575,22 @@ function resolveLayout(overrides) {
|
|
|
1424
1575
|
for (const [role, set] of sets) {
|
|
1425
1576
|
if (role === "face" || role === "nose") continue;
|
|
1426
1577
|
if (FACE_FEATURES.includes(role)) continue;
|
|
1427
|
-
resolved
|
|
1578
|
+
mergeRole(resolved, role, set);
|
|
1428
1579
|
}
|
|
1429
1580
|
return resolved;
|
|
1430
1581
|
}
|
|
1582
|
+
function mergeRole(resolved, role, set) {
|
|
1583
|
+
resolved[role] = { ...resolved[role], ...set };
|
|
1584
|
+
}
|
|
1585
|
+
function resolveCanvasHeight(value) {
|
|
1586
|
+
if (value === void 0) return CANVAS;
|
|
1587
|
+
if (!Number.isInteger(value) || value % 2 !== 0 || value < CANVAS || value > MAX_CANVAS_DIM) {
|
|
1588
|
+
throw new AutoRigInputError(
|
|
1589
|
+
`canvasHeight must be an even integer in ${CANVAS}..${MAX_CANVAS_DIM}, got ${String(value)}`
|
|
1590
|
+
);
|
|
1591
|
+
}
|
|
1592
|
+
return value;
|
|
1593
|
+
}
|
|
1431
1594
|
function resolveMirrorParts(names) {
|
|
1432
1595
|
const mirrored = /* @__PURE__ */ new Set();
|
|
1433
1596
|
for (const [i, name] of (names ?? []).entries()) {
|
|
@@ -1450,14 +1613,14 @@ function keyWhiteToAlpha(rgba) {
|
|
|
1450
1613
|
return keyed;
|
|
1451
1614
|
}
|
|
1452
1615
|
async function coreAndBoundsOf(png) {
|
|
1453
|
-
const { data, info } = await
|
|
1616
|
+
const { data, info } = await sharp3(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1454
1617
|
return {
|
|
1455
1618
|
core: denseCoreOf(data, info.width, info.height),
|
|
1456
1619
|
bounds: { x: 0, y: 0, w: info.width, h: info.height }
|
|
1457
1620
|
};
|
|
1458
1621
|
}
|
|
1459
1622
|
async function hasCoverage(png) {
|
|
1460
|
-
const { data, info } = await
|
|
1623
|
+
const { data, info } = await sharp3(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1461
1624
|
return scanAlphaBbox2(data, info.width, info.height) !== null;
|
|
1462
1625
|
}
|
|
1463
1626
|
async function noseSizingOf(png) {
|
|
@@ -1475,12 +1638,12 @@ async function noseSizingOf(png) {
|
|
|
1475
1638
|
}
|
|
1476
1639
|
return { box: core, whole: false };
|
|
1477
1640
|
}
|
|
1478
|
-
async function partBuffer(role, cfg, partsDir, inMemory, flipSource) {
|
|
1641
|
+
async function partBuffer(role, cfg, partsDir, inMemory, flipSource, canvas) {
|
|
1479
1642
|
let img;
|
|
1480
1643
|
if (inMemory !== void 0) {
|
|
1481
|
-
img =
|
|
1644
|
+
img = sharp3(inMemory);
|
|
1482
1645
|
} else {
|
|
1483
|
-
const srcPath =
|
|
1646
|
+
const srcPath = path6.join(partsDir, cfg.src);
|
|
1484
1647
|
if (!fs3.existsSync(srcPath)) {
|
|
1485
1648
|
if (cfg.optional) return null;
|
|
1486
1649
|
throw new AutoRigInputError(
|
|
@@ -1488,14 +1651,14 @@ async function partBuffer(role, cfg, partsDir, inMemory, flipSource) {
|
|
|
1488
1651
|
);
|
|
1489
1652
|
}
|
|
1490
1653
|
const png = await decodePng(srcPath);
|
|
1491
|
-
img =
|
|
1654
|
+
img = sharp3(png.hasAlpha ? png.rgba : keyWhiteToAlpha(png.rgba), {
|
|
1492
1655
|
raw: { width: png.width, height: png.height, channels: 4 }
|
|
1493
1656
|
});
|
|
1494
1657
|
}
|
|
1495
1658
|
if (!cfg.noTrim) {
|
|
1496
1659
|
const kept = await img.trim({ threshold: TRIM_THRESHOLD }).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1497
1660
|
const { width: keptW, height: keptH } = kept.info;
|
|
1498
|
-
img =
|
|
1661
|
+
img = sharp3(kept.data, {
|
|
1499
1662
|
raw: { width: keptW, height: keptH, channels: 4 }
|
|
1500
1663
|
});
|
|
1501
1664
|
const box = boxWithoutStraySpecks(kept.data, keptW, keptH);
|
|
@@ -1508,13 +1671,13 @@ async function partBuffer(role, cfg, partsDir, inMemory, flipSource) {
|
|
|
1508
1671
|
const sized = nose?.box ?? { x: 0, y: 0, w: trimmedW, h: trimmedH };
|
|
1509
1672
|
const width = Math.round(trimmedW * cfg.w / sized.w);
|
|
1510
1673
|
const height = cfg.h === void 0 ? Math.round(trimmedH * width / trimmedW) : Math.round(trimmedH * cfg.h / sized.h);
|
|
1511
|
-
if (width >
|
|
1512
|
-
const field = width >
|
|
1674
|
+
if (width > canvas.width || height > canvas.height) {
|
|
1675
|
+
const field = width > canvas.width || cfg.h === void 0 ? "w" : "h";
|
|
1513
1676
|
throw new AutoRigInputError(
|
|
1514
|
-
`layout.${role}.${field}: resized part ${width}x${height} exceeds the ${
|
|
1677
|
+
`layout.${role}.${field}: resized part ${width}x${height} exceeds the ${canvasName(canvas)} canvas`
|
|
1515
1678
|
);
|
|
1516
1679
|
}
|
|
1517
|
-
const resized = await
|
|
1680
|
+
const resized = await sharp3(trimmed.data).resize(cfg.h === void 0 ? { width } : { width, height, fit: "fill" }).png().toBuffer({ resolveWithObject: true });
|
|
1518
1681
|
return {
|
|
1519
1682
|
buf: resized.data,
|
|
1520
1683
|
w: resized.info.width,
|
|
@@ -1522,20 +1685,20 @@ async function partBuffer(role, cfg, partsDir, inMemory, flipSource) {
|
|
|
1522
1685
|
nose
|
|
1523
1686
|
};
|
|
1524
1687
|
}
|
|
1525
|
-
function assertOnCanvas(source, w, h, left, top) {
|
|
1526
|
-
if (left + w <= 0 || top + h <= 0 || left >=
|
|
1688
|
+
function assertOnCanvas(source, w, h, left, top, canvas) {
|
|
1689
|
+
if (left + w <= 0 || top + h <= 0 || left >= canvas.width || top >= canvas.height) {
|
|
1527
1690
|
throw new AutoRigInputError(
|
|
1528
|
-
`${source}: the placed part (${w}x${h} at ${left},${top}) falls entirely outside the ${
|
|
1691
|
+
`${source}: the placed part (${w}x${h} at ${left},${top}) falls entirely outside the ${canvasName(canvas)} canvas`
|
|
1529
1692
|
);
|
|
1530
1693
|
}
|
|
1531
1694
|
}
|
|
1532
|
-
function placement(role, cfg, w, h) {
|
|
1695
|
+
function placement(role, cfg, w, h, canvas) {
|
|
1533
1696
|
const left = Math.round(cfg.cx - w / 2);
|
|
1534
1697
|
const top = Math.round(cfg.cy - h / 2);
|
|
1535
|
-
assertOnCanvas(`layout.${role}.cx/cy`, w, h, left, top);
|
|
1698
|
+
assertOnCanvas(`layout.${role}.cx/cy`, w, h, left, top, canvas);
|
|
1536
1699
|
return { left, top };
|
|
1537
1700
|
}
|
|
1538
|
-
function nosePlacement(layout, box, w, h) {
|
|
1701
|
+
function nosePlacement(layout, box, w, h, canvas) {
|
|
1539
1702
|
const { cx, cy } = layout.nose;
|
|
1540
1703
|
const left = Math.round(cx - (box.x + box.w / 2));
|
|
1541
1704
|
let top;
|
|
@@ -1553,15 +1716,16 @@ function nosePlacement(layout, box, w, h) {
|
|
|
1553
1716
|
w,
|
|
1554
1717
|
h,
|
|
1555
1718
|
left,
|
|
1556
|
-
top
|
|
1719
|
+
top,
|
|
1720
|
+
canvas
|
|
1557
1721
|
);
|
|
1558
1722
|
return { left, top };
|
|
1559
1723
|
}
|
|
1560
|
-
function blankCanvas() {
|
|
1561
|
-
return
|
|
1724
|
+
function blankCanvas(canvas) {
|
|
1725
|
+
return sharp3({
|
|
1562
1726
|
create: {
|
|
1563
|
-
width:
|
|
1564
|
-
height:
|
|
1727
|
+
width: canvas.width,
|
|
1728
|
+
height: canvas.height,
|
|
1565
1729
|
channels: 4,
|
|
1566
1730
|
background: { r: 0, g: 0, b: 0, alpha: 0 }
|
|
1567
1731
|
}
|
|
@@ -1594,14 +1758,14 @@ function boxWithoutStraySpecks(rgba, W, H) {
|
|
|
1594
1758
|
const p = stack[--depth];
|
|
1595
1759
|
size++;
|
|
1596
1760
|
if (rgba[p * 4 + 3] >= ALPHA_OPAQUE2) opaque = true;
|
|
1597
|
-
const
|
|
1598
|
-
const py = (p -
|
|
1599
|
-
setLeft = Math.min(setLeft,
|
|
1761
|
+
const px2 = p % W;
|
|
1762
|
+
const py = (p - px2) / W;
|
|
1763
|
+
setLeft = Math.min(setLeft, px2);
|
|
1600
1764
|
setTop = Math.min(setTop, py);
|
|
1601
|
-
setRight = Math.max(setRight,
|
|
1765
|
+
setRight = Math.max(setRight, px2);
|
|
1602
1766
|
setBottom = Math.max(setBottom, py);
|
|
1603
1767
|
for (let y = Math.max(0, py - 1); y <= Math.min(H - 1, py + 1); y++) {
|
|
1604
|
-
for (let x = Math.max(0,
|
|
1768
|
+
for (let x = Math.max(0, px2 - 1); x <= Math.min(W - 1, px2 + 1); x++) {
|
|
1605
1769
|
const q = y * W + x;
|
|
1606
1770
|
if (!visited[q] && rgba[q * 4 + 3] > TRIM_THRESHOLD) {
|
|
1607
1771
|
visited[q] = 1;
|
|
@@ -1639,10 +1803,10 @@ function detachedAboveWhite(rgba, W, H) {
|
|
|
1639
1803
|
const label = new Int32Array(n).fill(-1);
|
|
1640
1804
|
const stack = new Int32Array(n);
|
|
1641
1805
|
const near = (p, visit) => {
|
|
1642
|
-
const
|
|
1643
|
-
const py = (p -
|
|
1806
|
+
const px2 = p % W;
|
|
1807
|
+
const py = (p - px2) / W;
|
|
1644
1808
|
for (let y = Math.max(0, py - 1); y <= Math.min(H - 1, py + 1); y++) {
|
|
1645
|
-
for (let x = Math.max(0,
|
|
1809
|
+
for (let x = Math.max(0, px2 - 1); x <= Math.min(W - 1, px2 + 1); x++) {
|
|
1646
1810
|
visit(y * W + x);
|
|
1647
1811
|
}
|
|
1648
1812
|
}
|
|
@@ -1714,7 +1878,7 @@ function detachedAboveWhite(rgba, W, H) {
|
|
|
1714
1878
|
return detached;
|
|
1715
1879
|
}
|
|
1716
1880
|
async function prepEyeSplit(partsDir) {
|
|
1717
|
-
const srcPath =
|
|
1881
|
+
const srcPath = path6.join(partsDir, EYEWHITE_SRC);
|
|
1718
1882
|
if (!fs3.existsSync(srcPath)) {
|
|
1719
1883
|
throw new AutoRigInputError(`missing eyewhite source: ${srcPath}`);
|
|
1720
1884
|
}
|
|
@@ -1775,7 +1939,11 @@ async function composeLayersFromParts(input) {
|
|
|
1775
1939
|
`partsDir and outDir resolve to the same directory (${outDir}): composing would overwrite the source parts`
|
|
1776
1940
|
);
|
|
1777
1941
|
}
|
|
1778
|
-
const
|
|
1942
|
+
const canvas = {
|
|
1943
|
+
width: CANVAS,
|
|
1944
|
+
height: resolveCanvasHeight(input.canvasHeight)
|
|
1945
|
+
};
|
|
1946
|
+
const layout = resolveLayout(input.layout, canvas);
|
|
1779
1947
|
const mirrored = resolveMirrorParts(input.mirrorParts);
|
|
1780
1948
|
const split = await prepEyeSplit(partsDir);
|
|
1781
1949
|
const splitSources = /* @__PURE__ */ new Map([
|
|
@@ -1795,6 +1963,44 @@ async function composeLayersFromParts(input) {
|
|
|
1795
1963
|
skipped.push(role);
|
|
1796
1964
|
continue;
|
|
1797
1965
|
}
|
|
1966
|
+
if (key === "arm_L" || key === "arm_R") {
|
|
1967
|
+
const arm = layout[key];
|
|
1968
|
+
if (!fs3.existsSync(path6.join(partsDir, arm.src))) continue;
|
|
1969
|
+
const body = placed.find((p) => p.role === "body");
|
|
1970
|
+
if (body === void 0) {
|
|
1971
|
+
throw new AutoRigInputError(
|
|
1972
|
+
"arm.png: an arm needs body.png \u2014 the composer hangs each arm on the body's shoulder, and auto_rig_from_layers hangs it from the body"
|
|
1973
|
+
);
|
|
1974
|
+
}
|
|
1975
|
+
const w = arm.w ?? Math.max(1, Math.round(ARM_WIDTH * body.part.w));
|
|
1976
|
+
const part2 = await partBuffer(
|
|
1977
|
+
role,
|
|
1978
|
+
{ ...arm, w },
|
|
1979
|
+
partsDir,
|
|
1980
|
+
void 0,
|
|
1981
|
+
mirrored.has(arm.src),
|
|
1982
|
+
canvas
|
|
1983
|
+
);
|
|
1984
|
+
const { left: left2, top: top2 } = await armPlacement(key, arm, part2, {
|
|
1985
|
+
left: body.left,
|
|
1986
|
+
top: body.top,
|
|
1987
|
+
w: body.part.w,
|
|
1988
|
+
h: body.part.h
|
|
1989
|
+
});
|
|
1990
|
+
const unset = ["cx", "cy"].filter(
|
|
1991
|
+
(field) => arm[field] === void 0
|
|
1992
|
+
);
|
|
1993
|
+
assertOnCanvas(
|
|
1994
|
+
unset.length === 0 ? `layout.${key}.cx/cy` : `layout.${key}.cx/cy (${unset.join("/")} unset: its shoulder pivot hangs on the shoulder corner of layout.body's box)`,
|
|
1995
|
+
part2.w,
|
|
1996
|
+
part2.h,
|
|
1997
|
+
left2,
|
|
1998
|
+
top2,
|
|
1999
|
+
canvas
|
|
2000
|
+
);
|
|
2001
|
+
placed.push({ role, part: part2, left: left2, top: top2 });
|
|
2002
|
+
continue;
|
|
2003
|
+
}
|
|
1798
2004
|
const cfg = lower ? { ...layout[key], src: LOWER_LASH_SRC } : layout[key];
|
|
1799
2005
|
const inMemory = splitSources.get(cfg.src);
|
|
1800
2006
|
const part = await partBuffer(
|
|
@@ -1803,7 +2009,8 @@ async function composeLayersFromParts(input) {
|
|
|
1803
2009
|
partsDir,
|
|
1804
2010
|
inMemory,
|
|
1805
2011
|
// The split halves are cut from eyewhite.png, the file a caller names.
|
|
1806
|
-
mirrored.has(inMemory === void 0 ? cfg.src : EYEWHITE_SRC)
|
|
2012
|
+
mirrored.has(inMemory === void 0 ? cfg.src : EYEWHITE_SRC),
|
|
2013
|
+
canvas
|
|
1807
2014
|
);
|
|
1808
2015
|
if (part === null || lower && !await hasCoverage(part.buf)) {
|
|
1809
2016
|
skipped.push(role);
|
|
@@ -1815,9 +2022,9 @@ async function composeLayersFromParts(input) {
|
|
|
1815
2022
|
noseSpeck = part.nose?.speck;
|
|
1816
2023
|
const { core, bounds } = await coreAndBoundsOf(part.buf);
|
|
1817
2024
|
const box = part.nose?.whole ? bounds : core ?? bounds;
|
|
1818
|
-
({ left, top } = nosePlacement(layout, box, part.w, part.h));
|
|
2025
|
+
({ left, top } = nosePlacement(layout, box, part.w, part.h, canvas));
|
|
1819
2026
|
} else {
|
|
1820
|
-
({ left, top } = placement(key, layout[key], part.w, part.h));
|
|
2027
|
+
({ left, top } = placement(key, layout[key], part.w, part.h, canvas));
|
|
1821
2028
|
}
|
|
1822
2029
|
if (role === "lash_L" || role === "lash_R") {
|
|
1823
2030
|
const eyeRole = role === "lash_L" ? "eye_L" : "eye_R";
|
|
@@ -1830,14 +2037,15 @@ async function composeLayersFromParts(input) {
|
|
|
1830
2037
|
}
|
|
1831
2038
|
placed.push({ role, part, left, top });
|
|
1832
2039
|
}
|
|
1833
|
-
for (const role of
|
|
1834
|
-
|
|
2040
|
+
for (const role of ORDER) {
|
|
2041
|
+
if (placed.some((p) => p.role === role)) continue;
|
|
2042
|
+
fs3.rmSync(path6.join(outDir, `${role}.png`), { force: true });
|
|
1835
2043
|
}
|
|
1836
2044
|
const layers = [];
|
|
1837
2045
|
const preview = [];
|
|
1838
2046
|
for (const { role, part, left, top } of placed) {
|
|
1839
|
-
const layer = await blankCanvas().composite([{ input: part.buf, left, top }]).png().toBuffer();
|
|
1840
|
-
const outPath =
|
|
2047
|
+
const layer = await blankCanvas(canvas).composite([{ input: part.buf, left, top }]).png().toBuffer();
|
|
2048
|
+
const outPath = path6.join(outDir, `${role}.png`);
|
|
1841
2049
|
writeFileAtomic(outPath, layer);
|
|
1842
2050
|
layers.push({
|
|
1843
2051
|
role,
|
|
@@ -1849,15 +2057,15 @@ async function composeLayersFromParts(input) {
|
|
|
1849
2057
|
});
|
|
1850
2058
|
preview.push({ input: part.buf, left, top });
|
|
1851
2059
|
}
|
|
1852
|
-
const previewPng = await
|
|
2060
|
+
const previewPng = await sharp3({
|
|
1853
2061
|
create: {
|
|
1854
|
-
width:
|
|
1855
|
-
height:
|
|
2062
|
+
width: canvas.width,
|
|
2063
|
+
height: canvas.height,
|
|
1856
2064
|
channels: 4,
|
|
1857
2065
|
background: { r: 245, g: 245, b: 248, alpha: 1 }
|
|
1858
2066
|
}
|
|
1859
2067
|
}).composite(preview).png().toBuffer();
|
|
1860
|
-
const previewPath =
|
|
2068
|
+
const previewPath = path6.join(outDir, "preview.png");
|
|
1861
2069
|
writeFileAtomic(previewPath, previewPng);
|
|
1862
2070
|
return {
|
|
1863
2071
|
ok: true,
|
|
@@ -1878,7 +2086,7 @@ async function composeLayersFromParts(input) {
|
|
|
1878
2086
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1879
2087
|
import { z } from "zod";
|
|
1880
2088
|
function createIkiMcpServer() {
|
|
1881
|
-
const server = new McpServer({ name: "iki", version: "0.
|
|
2089
|
+
const server = new McpServer({ name: "iki", version: "0.19.0" });
|
|
1882
2090
|
server.registerTool(
|
|
1883
2091
|
"validate_iki",
|
|
1884
2092
|
{
|
|
@@ -1998,13 +2206,13 @@ function createIkiMcpServer() {
|
|
|
1998
2206
|
server.registerTool(
|
|
1999
2207
|
"compose_layers_from_parts",
|
|
2000
2208
|
{
|
|
2001
|
-
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`.",
|
|
2209
|
+
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). 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`). 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, and an arm whose shoulder cap does not reach under the torso's edge. 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`.",
|
|
2002
2210
|
inputSchema: {
|
|
2003
2211
|
partsDir: z.string().describe(
|
|
2004
2212
|
"Directory of the source part PNGs (resolved against cwd)."
|
|
2005
2213
|
),
|
|
2006
2214
|
outDir: z.string().describe(
|
|
2007
|
-
"Existing directory to write the role layer PNGs + preview.png into (resolved against cwd; must already exist; confined to the working directory). Reused across runs: a role this run skips has its stale PNG from an earlier run deleted."
|
|
2215
|
+
"Existing directory to write the role layer PNGs + preview.png into (resolved against cwd; must already exist; confined to the working directory). Reused across runs: a role this run does not write \u2014 one it skips, or an arm once arm.png is gone \u2014 has its stale PNG from an earlier run deleted."
|
|
2008
2216
|
),
|
|
2009
2217
|
layout: z.record(
|
|
2010
2218
|
z.string(),
|
|
@@ -2015,10 +2223,13 @@ function createIkiMcpServer() {
|
|
|
2015
2223
|
h: z.number()
|
|
2016
2224
|
}).partial()
|
|
2017
2225
|
).optional().describe(
|
|
2018
|
-
"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`
|
|
2226
|
+
"Per-role override merged over the built-in defaults, keyed by role \u2014 hair_back, body, arm_L, arm_R, 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` is an integer in 1..1100 (the canvas width) and `h` in 1..canvasHeight; omit `h` to keep the part's own aspect, set it to stretch. The defaults of the face's features \u2014 blush, nose, mouth, mouth_open, eyes, irises, lashes, brows \u2014 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. 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.66 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. arm_L/arm_R have no cx/cy/w defaults: an unset `w` is 0.4 of the placed body's width, and an unset `cx` or `cy` hangs the arm's shoulder pivot \u2014 the one auto_rig_from_layers turns it about \u2014 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. A set one centres the arm as for every other role."
|
|
2019
2227
|
),
|
|
2020
2228
|
mirrorParts: z.array(z.string()).optional().describe(
|
|
2021
|
-
"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),
|
|
2229
|
+
"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), 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), and arm.png as the arm on the screen LEFT (the character's right, hanging, its shoulder at the image's top); 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."
|
|
2230
|
+
),
|
|
2231
|
+
canvasHeight: z.number().optional().describe(
|
|
2232
|
+
"The canvas's height in px: an even integer in 1100..4096, default 1100 (a square bust canvas; at 1100 every output is byte-identical to leaving it out). The width stays 1100. The canvas grows downward: every default and every override keeps its canvas px from the top-left, so the head lands where it does on a bust and a full body gets room below. An odd height is refused \u2014 model space is centred on the canvas, so it would put the head on a half pixel \u2014 and it is checked before any part decodes."
|
|
2022
2233
|
)
|
|
2023
2234
|
}
|
|
2024
2235
|
},
|
|
@@ -2043,7 +2254,7 @@ function createIkiMcpServer() {
|
|
|
2043
2254
|
server.registerTool(
|
|
2044
2255
|
"measure_layers",
|
|
2045
2256
|
{
|
|
2046
|
-
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). 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.",
|
|
2257
|
+
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). 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.",
|
|
2047
2258
|
inputSchema: {
|
|
2048
2259
|
layersDir: z.string().describe(
|
|
2049
2260
|
"Directory of role-named layer PNGs (resolved against cwd)."
|
|
@@ -2120,4 +2331,4 @@ export {
|
|
|
2120
2331
|
composeLayersFromParts,
|
|
2121
2332
|
createIkiMcpServer
|
|
2122
2333
|
};
|
|
2123
|
-
//# sourceMappingURL=chunk-
|
|
2334
|
+
//# sourceMappingURL=chunk-E6DLZPCX.mjs.map
|