@ikijs/mcp 0.34.0 → 0.35.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-HKJT3Q6G.mjs";
4
+ } from "./chunk-Y36XOSK4.mjs";
5
5
 
6
6
  // src/cli.ts
7
7
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
+ import { IkiModel, IkiOcclusion } from '@ikijs/format';
1
2
  import { CustomPart, TurnTargets, RigPlan, RigPatch, RigBakes, IrisStrand, TurnSolveReport, PatchReport, RigPlanReport, RigPlanField } from '@ikijs/editor';
2
3
  export { RigPlanReport, TurnSolveReport } from '@ikijs/editor';
3
- import { IkiModel } from '@ikijs/format';
4
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
5
 
6
6
  /** A parameter setting to check the rig at; every other parameter rests at its default. */
@@ -224,6 +224,10 @@ interface CustomGatePart {
224
224
  /** Where the part meets the anchor, canvas px. */
225
225
  tie: [number, number];
226
226
  rigid?: boolean;
227
+ /** The roles of the entry's `occlusion.by`, when it declares one. Their
228
+ * paint gives the gate the cover it excuses a reading under; without it a
229
+ * declared occlusion excuses nothing. */
230
+ occludedBy?: string[];
227
231
  }
228
232
  interface CustomGateOptions {
229
233
  /** Replaces the default pose set (`RIGID` still adds its stop midpoints). */
@@ -311,8 +315,37 @@ interface CustomGatePartReport {
311
315
  };
312
316
  rigid?: CustomGateReading;
313
317
  tip: CustomGateTip[];
318
+ /** Only for a part that declares occlusion. Reported, never failing. */
319
+ hidden?: CustomGateHidden;
314
320
  ok: boolean;
315
321
  }
322
+ /** Where the amount leaves its rest value and first reaches 1, on one side of
323
+ * the key parameter's default; null where it never does. */
324
+ interface CustomGateHiddenSide {
325
+ leaves: number | null;
326
+ full: number | null;
327
+ }
328
+ interface CustomGateHidden {
329
+ /** Every occluder part id the model names. */
330
+ by: string[];
331
+ /** Those whose paint gives the gate cover; the rest fade (or are roles not
332
+ * passed) and give none. */
333
+ cover: string[];
334
+ parameter: string;
335
+ /** The parameter's default. */
336
+ default: number;
337
+ /** The amount with every parameter at its default. */
338
+ atRest: number;
339
+ below: CustomGateHiddenSide;
340
+ above: CustomGateHiddenSide;
341
+ /** Poses of the part's set that `TIE` and `SLIDE` left out, and how many of
342
+ * them turn the head. */
343
+ leftOut: number;
344
+ leftOutTurning: number;
345
+ /** Poses that do not turn the head and that `TIE` read. */
346
+ readNoTurn: number;
347
+ poses: number;
348
+ }
316
349
  interface CustomGateReport {
317
350
  ok: boolean;
318
351
  faceWidth: number;
@@ -612,6 +645,9 @@ interface CustomPartReport {
612
645
  };
613
646
  order: number;
614
647
  page: number;
648
+ /** What hides the part, as written on the model; only for a part that
649
+ * declares it. */
650
+ occlusion?: IkiOcclusion;
615
651
  }
616
652
 
617
653
  /**
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import { IkiModel, IkiOcclusion } from '@ikijs/format';
1
2
  import { CustomPart, TurnTargets, RigPlan, RigPatch, RigBakes, IrisStrand, TurnSolveReport, PatchReport, RigPlanReport, RigPlanField } from '@ikijs/editor';
2
3
  export { RigPlanReport, TurnSolveReport } from '@ikijs/editor';
3
- import { IkiModel } from '@ikijs/format';
4
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
5
 
6
6
  /** A parameter setting to check the rig at; every other parameter rests at its default. */
@@ -224,6 +224,10 @@ interface CustomGatePart {
224
224
  /** Where the part meets the anchor, canvas px. */
225
225
  tie: [number, number];
226
226
  rigid?: boolean;
227
+ /** The roles of the entry's `occlusion.by`, when it declares one. Their
228
+ * paint gives the gate the cover it excuses a reading under; without it a
229
+ * declared occlusion excuses nothing. */
230
+ occludedBy?: string[];
227
231
  }
228
232
  interface CustomGateOptions {
229
233
  /** Replaces the default pose set (`RIGID` still adds its stop midpoints). */
@@ -311,8 +315,37 @@ interface CustomGatePartReport {
311
315
  };
312
316
  rigid?: CustomGateReading;
313
317
  tip: CustomGateTip[];
318
+ /** Only for a part that declares occlusion. Reported, never failing. */
319
+ hidden?: CustomGateHidden;
314
320
  ok: boolean;
315
321
  }
322
+ /** Where the amount leaves its rest value and first reaches 1, on one side of
323
+ * the key parameter's default; null where it never does. */
324
+ interface CustomGateHiddenSide {
325
+ leaves: number | null;
326
+ full: number | null;
327
+ }
328
+ interface CustomGateHidden {
329
+ /** Every occluder part id the model names. */
330
+ by: string[];
331
+ /** Those whose paint gives the gate cover; the rest fade (or are roles not
332
+ * passed) and give none. */
333
+ cover: string[];
334
+ parameter: string;
335
+ /** The parameter's default. */
336
+ default: number;
337
+ /** The amount with every parameter at its default. */
338
+ atRest: number;
339
+ below: CustomGateHiddenSide;
340
+ above: CustomGateHiddenSide;
341
+ /** Poses of the part's set that `TIE` and `SLIDE` left out, and how many of
342
+ * them turn the head. */
343
+ leftOut: number;
344
+ leftOutTurning: number;
345
+ /** Poses that do not turn the head and that `TIE` read. */
346
+ readNoTurn: number;
347
+ poses: number;
348
+ }
316
349
  interface CustomGateReport {
317
350
  ok: boolean;
318
351
  faceWidth: number;
@@ -612,6 +645,9 @@ interface CustomPartReport {
612
645
  };
613
646
  order: number;
614
647
  page: number;
648
+ /** What hides the part, as written on the model; only for a part that
649
+ * declares it. */
650
+ occlusion?: IkiOcclusion;
615
651
  }
616
652
 
617
653
  /**
package/dist/index.js CHANGED
@@ -483,6 +483,22 @@ function resolveDeformers(deformers, params) {
483
483
  return { worlds, grids };
484
484
  }
485
485
 
486
+ // ../engine/src/occlusion.ts
487
+ function occlusionAmount(occlusion, value) {
488
+ const { stops } = occlusion;
489
+ const first = stops[0];
490
+ if (value <= first.value) return first.amount;
491
+ for (let i = 1; i < stops.length; i++) {
492
+ const hi = stops[i];
493
+ if (value <= hi.value) {
494
+ const lo = stops[i - 1];
495
+ const t = (value - lo.value) / (hi.value - lo.value);
496
+ return lo.amount * (1 - t) + hi.amount * t;
497
+ }
498
+ }
499
+ return stops[stops.length - 1].amount;
500
+ }
501
+
486
502
  // ../engine/src/idle-motion.ts
487
503
  var import_format = require("@ikijs/format");
488
504
 
@@ -2390,6 +2406,49 @@ function triangleGrid(posed, indices, bounds) {
2390
2406
  Math.floor((x - bounds.x0) / cell) + Math.floor((y - bounds.y0) / cell) * cols
2391
2407
  ) ?? [];
2392
2408
  }
2409
+ function paintedUnder(posed, mesh, paint, points) {
2410
+ if (points.length === 0) return [];
2411
+ const bounds = { x0: Infinity, y0: Infinity, x1: -Infinity, y1: -Infinity };
2412
+ for (const [x, y] of points) {
2413
+ bounds.x0 = Math.min(bounds.x0, x);
2414
+ bounds.y0 = Math.min(bounds.y0, y);
2415
+ bounds.x1 = Math.max(bounds.x1, x);
2416
+ bounds.y1 = Math.max(bounds.y1, y);
2417
+ }
2418
+ const find = triangleGrid(posed, mesh.indices, bounds);
2419
+ return points.map(([x, y]) => {
2420
+ for (const t of find(x, y)) {
2421
+ const tri = [
2422
+ mesh.indices[t * 3],
2423
+ mesh.indices[t * 3 + 1],
2424
+ mesh.indices[t * 3 + 2]
2425
+ ];
2426
+ const w = locate(posed, tri, x, y);
2427
+ if (!w) continue;
2428
+ let rx = 0;
2429
+ let ry = 0;
2430
+ for (let k = 0; k < 3; k++) {
2431
+ rx += w[k] * mesh.rest[tri[k] * 2];
2432
+ ry += w[k] * mesh.rest[tri[k] * 2 + 1];
2433
+ }
2434
+ return paintedAt(paint, rx, ry);
2435
+ }
2436
+ return false;
2437
+ });
2438
+ }
2439
+ function hiddenSide(occlusion, from, direction) {
2440
+ const at = (v) => occlusionAmount(occlusion, v);
2441
+ const rest = at(from);
2442
+ const marks = occlusion.stops.map((s) => s.value).filter((v) => (v - from) * direction > 0).sort((a, b) => (a - b) * direction);
2443
+ const run2 = [from, ...marks];
2444
+ let leaves = null;
2445
+ let full = rest === 1 ? from : null;
2446
+ for (let i = 0; i + 1 < run2.length; i++) {
2447
+ if (leaves === null && at(run2[i + 1]) !== rest) leaves = run2[i];
2448
+ if (full === null && at(run2[i + 1]) === 1) full = run2[i + 1];
2449
+ }
2450
+ return { leaves, full };
2451
+ }
2393
2452
  function posesOf(model, baked, base) {
2394
2453
  const byName = new Map(base.map((p) => [p.name, p]));
2395
2454
  const add = (values) => {
@@ -2462,7 +2521,16 @@ function checkCustomGate(model, parts, paints, options = {}) {
2462
2521
  if (!model.parts.some((p) => p.id === part.id)) {
2463
2522
  throw new Error(`custom gate: the model has no part "${part.id}"`);
2464
2523
  }
2465
- return options.poses ?? posesOf(model, bakedOf(part.id), base);
2524
+ if (options.poses) return options.poses;
2525
+ const sampledOf = bakedOf(part.id);
2526
+ const occ = model.parts.find((p) => p.id === part.id).occlusion;
2527
+ if (occ !== void 0) {
2528
+ const at = sampledOf.get(occ.parameter) ?? [];
2529
+ sampledOf.set(occ.parameter, [
2530
+ .../* @__PURE__ */ new Set([...at, ...occ.stops.map((s) => s.value)])
2531
+ ]);
2532
+ }
2533
+ return posesOf(model, sampledOf, base);
2466
2534
  });
2467
2535
  const all = new Map(poseSets.flat().map((p) => [p.name, p]));
2468
2536
  const reports = parts.map((part, n) => {
@@ -2547,6 +2615,45 @@ function checkCustomGate(model, parts, paints, options = {}) {
2547
2615
  const hiddenOn = locatePoints(lowerMesh, hidden).filter(
2548
2616
  (l, i) => l !== null && onAnchorMesh[i] !== null
2549
2617
  );
2618
+ const occlusion = ownPart.occlusion;
2619
+ const coverParts = [];
2620
+ if (occlusion !== void 0) {
2621
+ for (const role of part.occludedBy ?? []) {
2622
+ for (const id of (0, import_editor3.partIdsOfRole)(role)) {
2623
+ const o = model.parts.find((p) => p.id === id);
2624
+ if (o === void 0 || !occlusion.by.includes(id)) continue;
2625
+ const steady = o.color[3] === 1 && (o.transform.opacity ?? 1) >= 1 && !(o.bindings ?? []).some((b) => b.channel === "opacity");
2626
+ if (!steady) continue;
2627
+ const paint = paints.get(role);
2628
+ if (paint === void 0) {
2629
+ throw new Error(`custom gate: no paint for "${role}"`);
2630
+ }
2631
+ coverParts.push({ id, mesh: restMesh(model, cache, id), paint });
2632
+ }
2633
+ }
2634
+ }
2635
+ const coverIds = new Set(coverParts.map((c) => c.id));
2636
+ const keyParam = occlusion === void 0 ? void 0 : model.parameters.find((p) => p.id === occlusion.parameter);
2637
+ const keyOf = (values) => Math.min(
2638
+ keyParam.max,
2639
+ Math.max(keyParam.min, values[keyParam.id] ?? keyParam.default)
2640
+ );
2641
+ const sampled = keyParam === void 0 ? [] : [
2642
+ .../* @__PURE__ */ new Set([
2643
+ keyParam.default,
2644
+ ...poses.map((p) => keyOf(p.values))
2645
+ ])
2646
+ ].sort((a, b) => a - b);
2647
+ const fullyHidden = (lo, hi) => occlusion.stops.every(
2648
+ (st) => st.value <= lo || st.value >= hi || st.amount === 1
2649
+ ) && occlusionAmount(occlusion, lo) === 1 && occlusionAmount(occlusion, hi) === 1;
2650
+ const hiddenAt = (v) => fullyHidden(
2651
+ sampled.filter((x) => x < v).at(-1) ?? v,
2652
+ sampled.find((x) => x > v) ?? v
2653
+ );
2654
+ let leftOut = 0;
2655
+ let leftOutTurning = 0;
2656
+ let readNoTurn = 0;
2550
2657
  const stops = bakedOf(part.id);
2551
2658
  const worstOf = {
2552
2659
  tie: { v: -1, pose: "rest" },
@@ -2575,21 +2682,54 @@ function checkCustomGate(model, parts, paints, options = {}) {
2575
2682
  keep(worstOf.rigid, (0, import_editor3.rigidResidual)(restPoints, moved), pose.name);
2576
2683
  };
2577
2684
  for (const pose of poses) {
2578
- const landed = landParts(model, pose.values, [part.id, anchorId]);
2685
+ const hiding = occlusion !== void 0 && hiddenAt(keyOf(pose.values));
2686
+ const landed = landParts(model, pose.values, [
2687
+ .../* @__PURE__ */ new Set([
2688
+ part.id,
2689
+ anchorId,
2690
+ ...hiding && coverIds.size > 0 ? coverIds : []
2691
+ ])
2692
+ ]);
2579
2693
  const partPosed = toCanvas(model, landed.get(part.id));
2580
2694
  const anchorPosed = toCanvas(model, landed.get(anchorId));
2695
+ const canvasOf = /* @__PURE__ */ new Map();
2696
+ const underCover = (points, skip) => {
2697
+ const covered = points.map(() => false);
2698
+ if (!hiding) return covered;
2699
+ for (const c of coverParts) {
2700
+ if (c.id === skip) continue;
2701
+ let posed = canvasOf.get(c.id);
2702
+ if (posed === void 0) {
2703
+ posed = toCanvas(model, landed.get(c.id));
2704
+ canvasOf.set(c.id, posed);
2705
+ }
2706
+ const under = paintedUnder(posed, c.mesh, c.paint, points);
2707
+ under.forEach((u, i) => {
2708
+ if (u) covered[i] = true;
2709
+ });
2710
+ }
2711
+ return covered;
2712
+ };
2581
2713
  const turning = turns(pose);
2582
- if (turning) turningPoses++;
2714
+ const ringLands = onPart.map(
2715
+ (l) => l === null ? null : landLocated(partPosed, l)
2716
+ );
2717
+ const ringHidden = hiding && ringLands.every((p) => p !== null) && underCover(ringLands).every(Boolean);
2718
+ if (ringHidden) {
2719
+ leftOut++;
2720
+ if (turning) leftOutTurning++;
2721
+ } else if (turning) turningPoses++;
2722
+ else readNoTurn++;
2583
2723
  let gap = 0;
2584
2724
  for (const i of shared) {
2585
2725
  const a = landLocated(partPosed, onPart[i]);
2586
2726
  const b = landLocated(anchorPosed, onAnchor[i]);
2587
2727
  gap = Math.max(gap, Math.hypot(a[0] - b[0], a[1] - b[1]));
2588
2728
  }
2589
- if (shared.length > 0) {
2729
+ if (shared.length > 0 && !ringHidden) {
2590
2730
  keep(turning ? worstOf.slide : worstOf.tie, gap, pose.name);
2591
2731
  }
2592
- if (turning) {
2732
+ if (turning && !ringHidden) {
2593
2733
  const at = landLocated(partPosed, tieOnPart);
2594
2734
  let nearest = null;
2595
2735
  if (at !== null) {
@@ -2605,43 +2745,18 @@ function checkCustomGate(model, parts, paints, options = {}) {
2605
2745
  if (hiddenOn.length > 0) {
2606
2746
  const lowerPosed = lowerId === part.id ? partPosed : anchorPosed;
2607
2747
  const upperPosed = upperId === part.id ? partPosed : anchorPosed;
2608
- const upperIndices = upperMesh.indices;
2609
2748
  const lands = hiddenOn.map((l) => landLocated(lowerPosed, l));
2610
- const bounds = {
2611
- x0: Infinity,
2612
- y0: Infinity,
2613
- x1: -Infinity,
2614
- y1: -Infinity
2615
- };
2616
- for (const [x, y] of lands) {
2617
- bounds.x0 = Math.min(bounds.x0, x);
2618
- bounds.y0 = Math.min(bounds.y0, y);
2619
- bounds.x1 = Math.max(bounds.x1, x);
2620
- bounds.y1 = Math.max(bounds.y1, y);
2621
- }
2622
- const find = triangleGrid(upperPosed, upperIndices, bounds);
2749
+ const underUpper = paintedUnder(
2750
+ upperPosed,
2751
+ upperMesh,
2752
+ upperPaint,
2753
+ lands
2754
+ );
2755
+ const underHider = coverIds.has(lowerId) ? lands.map(() => hiding) : underCover(lands, upperId);
2623
2756
  let showing = 0;
2624
- for (const at of lands) {
2625
- let covered = false;
2626
- for (const t of find(at[0], at[1])) {
2627
- const tri = [
2628
- upperIndices[t * 3],
2629
- upperIndices[t * 3 + 1],
2630
- upperIndices[t * 3 + 2]
2631
- ];
2632
- const w = locate(upperPosed, tri, at[0], at[1]);
2633
- if (!w) continue;
2634
- let rx = 0;
2635
- let ry = 0;
2636
- for (let k = 0; k < 3; k++) {
2637
- rx += w[k] * upperMesh.rest[tri[k] * 2];
2638
- ry += w[k] * upperMesh.rest[tri[k] * 2 + 1];
2639
- }
2640
- covered = paintedAt(upperPaint, rx, ry);
2641
- break;
2642
- }
2643
- if (!covered) showing++;
2644
- }
2757
+ lands.forEach((_, i) => {
2758
+ if (!underUpper[i] && !underHider[i]) showing++;
2759
+ });
2645
2760
  keep(
2646
2761
  turning ? worstOf.exposedTurn : worstOf.exposed,
2647
2762
  showing,
@@ -2779,6 +2894,21 @@ function checkCustomGate(model, parts, paints, options = {}) {
2779
2894
  },
2780
2895
  ...rigidReading === void 0 ? {} : { rigid: rigidReading },
2781
2896
  tip,
2897
+ ...occlusion === void 0 ? {} : {
2898
+ hidden: {
2899
+ by: occlusion.by,
2900
+ cover: [...coverIds],
2901
+ parameter: occlusion.parameter,
2902
+ default: keyParam.default,
2903
+ atRest: occlusionAmount(occlusion, keyParam.default),
2904
+ below: hiddenSide(occlusion, keyParam.default, -1),
2905
+ above: hiddenSide(occlusion, keyParam.default, 1),
2906
+ leftOut,
2907
+ leftOutTurning,
2908
+ readNoTurn,
2909
+ poses: poses.length
2910
+ }
2911
+ },
2782
2912
  ok
2783
2913
  };
2784
2914
  });
@@ -2809,18 +2939,26 @@ function formatCustomGate(report) {
2809
2939
  lines.push(
2810
2940
  `${at} FOLDS: least triangle area ratio ${r.folds.ratio.toFixed(3)} at [${r.folds.pose}] (limit >= ${r.folds.limit}) ${verdict(r.folds.pass, r.folds.reason)}`
2811
2941
  );
2942
+ const noTurnLeftOut = r.hidden !== void 0 && r.hidden.readNoTurn === 0 && r.hidden.leftOut > r.hidden.leftOutTurning;
2812
2943
  lines.push(
2813
- `${at} TIE: at the tie and the ring around it, ${r.id} against ${r.anchor}, poses that do not turn the head: max ${both(w, r.tie.px)} at [${r.tie.pose}] (limit <= ${limit(r.tie.limit)}) ${verdict(r.tie.pass, r.tie.reason)}`
2944
+ noTurnLeftOut ? `${at} TIE: every pose that does not turn the head is left out as hidden (see HIDDEN) ${verdict(r.tie.pass, r.tie.reason)}` : `${at} TIE: at the tie and the ring around it, ${r.id} against ${r.anchor}, poses that do not turn the head: max ${both(w, r.tie.px)} at [${r.tie.pose}] (limit <= ${limit(r.tie.limit)}) ${verdict(r.tie.pass, r.tie.reason)}`
2814
2945
  );
2815
2946
  const s = r.slide;
2816
2947
  lines.push(
2817
- s.turningPoses === 0 ? `${at} SLIDE: no pose turns the head pass` : `${at} SLIDE: poses that turn the head, the same length: max ${both(w, s.slide.px)} at [${s.slide.pose}] (limit <= ${limit(s.slide.limit)}); the tie's distance to the nearest painted point of ${r.anchor} as landed: max ${both(w, s.onAnchor.px)} at [${s.onAnchor.pose}] (limit <= ${limit(s.onAnchor.limit)}) ${verdict(s.pass, s.slide.pass ? s.onAnchor.reason : s.slide.reason)}`
2948
+ s.turningPoses === 0 ? r.hidden !== void 0 && r.hidden.leftOutTurning > 0 ? `${at} SLIDE: every pose that turns the head is left out as hidden (see HIDDEN) pass` : `${at} SLIDE: no pose turns the head pass` : `${at} SLIDE: poses that turn the head, the same length: max ${both(w, s.slide.px)} at [${s.slide.pose}] (limit <= ${limit(s.slide.limit)}); the tie's distance to the nearest painted point of ${r.anchor} as landed: max ${both(w, s.onAnchor.px)} at [${s.onAnchor.pose}] (limit <= ${limit(s.onAnchor.limit)}) ${verdict(s.pass, s.slide.pass ? s.onAnchor.reason : s.slide.reason)}`
2818
2949
  );
2819
2950
  const e = r.exposed;
2820
2951
  const turnText = e.turning === null ? "no pose turns the head" : `max ${e.turning.px2.toFixed(0)} px\xB2 (${e.turning.value.toFixed(5)} face widths\xB2) at [${e.turning.pose}] (reported, no limit)`;
2821
2952
  lines.push(
2822
2953
  `${at} EXPOSED: ${e.hiddenPx} px of art both ${r.id} and ${r.anchor} paint near the tie, the lower one's hidden at rest; showing where the head does not turn: max ${(e.noTurn.px2 ?? 0).toFixed(0)} px\xB2 (${(e.noTurn.value ?? 0).toFixed(5)} face widths\xB2) at [${e.noTurn.pose}] (limit <= ${e.noTurn.limit} face widths\xB2, ${(e.noTurn.limit * w * w).toFixed(0)} px\xB2) ${verdict(e.pass, e.noTurn.reason)}; where it turns: ${turnText}`
2823
2954
  );
2955
+ if (r.hidden) {
2956
+ const h = r.hidden;
2957
+ const side = (name, s2) => h.atRest === 1 ? `${name} ${h.default} the amount is 1 at rest and ${s2.leaves === null ? "stays 1" : `leaves it at ${s2.leaves}`}` : `${name} ${h.default} the amount ${s2.leaves === null ? `never leaves ${h.atRest}` : `leaves ${h.atRest} at ${s2.leaves}`} and ${s2.full === null ? "never reaches 1" : `reaches 1 at ${s2.full}`}`;
2958
+ lines.push(
2959
+ `${at} HIDDEN: hidden by ${h.by.join(",")} on ${h.parameter}, cover from ${h.cover.length === 0 ? "none of them" : h.cover.join(",")}${h.cover.length === h.by.length ? "" : " (the rest fade or are roles not passed, and give none)"}; amount ${h.atRest} at rest; ${side("below", h.below)}; ${side("above", h.above)}; left out of TIE and SLIDE: ${h.leftOut} of ${h.poses} poses (reported, no limit)`
2960
+ );
2961
+ }
2824
2962
  if (r.rigid) {
2825
2963
  lines.push(
2826
2964
  `${at} RIGID: bend against rest: max ${both(w, r.rigid.px)} at [${r.rigid.pose}] (limit <= ${limit(r.rigid.limit)}) ${verdict(r.rigid.pass, r.rigid.reason)}`
@@ -3924,6 +4062,14 @@ function withoutParts(model, hideParts) {
3924
4062
  `hideParts[${i}] ${JSON.stringify(id)} masks ${JSON.stringify(kept.id)}, which stays; hide ${JSON.stringify(kept.id)} too`
3925
4063
  );
3926
4064
  }
4065
+ const occluded = model.parts.find(
4066
+ (p) => !hidden.has(p.id) && p.occlusion?.by.includes(id)
4067
+ );
4068
+ if (occluded) {
4069
+ throw new AutoRigInputError(
4070
+ `hideParts[${i}] ${JSON.stringify(id)} occludes ${JSON.stringify(occluded.id)}, which stays; hide ${JSON.stringify(occluded.id)} too`
4071
+ );
4072
+ }
3927
4073
  });
3928
4074
  return { ...model, parts: model.parts.filter((p) => !hidden.has(p.id)) };
3929
4075
  }
@@ -4488,7 +4634,9 @@ async function autoRigFromLayers(input) {
4488
4634
  let measurer;
4489
4635
  const crops = [];
4490
4636
  const paints = /* @__PURE__ */ new Map();
4491
- const anchorRoles = new Set(customEntries.map((e) => e.anchor));
4637
+ const anchorRoles = new Set(
4638
+ customEntries.flatMap((e) => [e.anchor, ...e.occlusion?.by ?? []])
4639
+ );
4492
4640
  for (let i = 0; i < resolvedLayers.length; i++) {
4493
4641
  const { resolved, fileName } = resolvedLayers[i];
4494
4642
  const png = await decodePng(resolved);
@@ -4700,11 +4848,12 @@ async function autoRigFromLayers(input) {
4700
4848
  try {
4701
4849
  gate = checkCustomGate(
4702
4850
  finalModel,
4703
- customEntries.map(({ id, anchor, tie, rigid }) => ({
4851
+ customEntries.map(({ id, anchor, tie, rigid, occlusion }) => ({
4704
4852
  id,
4705
4853
  anchor,
4706
4854
  tie,
4707
- ...rigid === void 0 ? {} : { rigid }
4855
+ ...rigid === void 0 ? {} : { rigid },
4856
+ ...occlusion === void 0 ? {} : { occludedBy: occlusion.by }
4708
4857
  })),
4709
4858
  paints
4710
4859
  );
@@ -4740,7 +4889,8 @@ async function autoRigFromLayers(input) {
4740
4889
  triangles: part.mesh.indices.length / 3
4741
4890
  },
4742
4891
  order: part.order,
4743
- page: part.texture.index
4892
+ page: part.texture.index,
4893
+ ...part.occlusion === void 0 ? {} : { occlusion: part.occlusion }
4744
4894
  };
4745
4895
  }),
4746
4896
  ...bakes === void 0 ? {} : { bakes },
@@ -7681,9 +7831,12 @@ function formatPatchReports(reports) {
7681
7831
  });
7682
7832
  }
7683
7833
  function formatCustomPartReports(parts) {
7684
- return parts.map(
7685
- (p) => `CUSTOM ${p.id}: box ${p.box.x},${p.box.y} ${p.box.w}x${p.box.h} px, mesh ${p.mesh.vertices} vertices ${p.mesh.triangles} triangles, order ${p.order}, atlas page ${p.page}`
7686
- );
7834
+ return parts.map((p) => {
7835
+ const line = `CUSTOM ${p.id}: box ${p.box.x},${p.box.y} ${p.box.w}x${p.box.h} px, mesh ${p.mesh.vertices} vertices ${p.mesh.triangles} triangles, order ${p.order}, atlas page ${p.page}`;
7836
+ if (p.occlusion === void 0) return line;
7837
+ const { by, parameter, stops } = p.occlusion;
7838
+ return `${line}, hidden by ${by.join(",")} on ${parameter} at ${stops.map((s) => `${s.value}:${s.amount}`).join(" ")}`;
7839
+ });
7687
7840
  }
7688
7841
  function formatBakeChecks(bakes) {
7689
7842
  return bakes.map(
@@ -7691,7 +7844,7 @@ function formatBakeChecks(bakes) {
7691
7844
  );
7692
7845
  }
7693
7846
  function createIkiMcpServer() {
7694
- const server = new import_mcp.McpServer({ name: "iki", version: "0.34.0" });
7847
+ const server = new import_mcp.McpServer({ name: "iki", version: "0.35.1" });
7695
7848
  server.registerTool(
7696
7849
  "validate_iki",
7697
7850
  {
@@ -7783,7 +7936,7 @@ function createIkiMcpServer() {
7783
7936
  server.registerTool(
7784
7937
  "auto_rig_from_layers",
7785
7938
  {
7786
- description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R and either mouth or the lip set (mouth_inner + lip_lower + lip_upper, a mouth that folds open instead of crossfading) required; iris_L/R, brow_L/R, hair_front, body, arm_L/arm_R, forearm_pose_L/forearm_pose_R, hair_side_L/hair_side_R, mouth_tongue/mouth_teeth (only with the lip set: drawn under its lips and clipped to mouth_inner), etc. optional; an arm needs the body, a pose forearm needs its arm, a side lock needs hair_front, and a partial lip set, one mixed with mouth/mouth_open, or mouth_tongue/mouth_teeth without it is refused) into a renderable .iki written to disk. Pass full-canvas PNG file paths; returns the output path + summary (the model is NOT inlined). Filenames map to roles unless `fileName` is given. The result's `folds` is the written rig's fold report, printed after the path the way render_poses prints it, and report-only: a fold never refuses the rig. The `RIGPLAN:` line (the result's `rigPlan`: `effective`, `clamped`, `overriddenBy`) follows the path and precedes the `PATCH` lines. The `PHYSICS` lines follow the fold report (the result's `physics`), one per physics rig output \u2014 a spring's, or each chain segment's \u2014 reading ok, frozen or unstable with the step and idle amplitudes, or `PHYSICS: no rigs`; report-only too. With side locks and a `nose` (which `turn` needs) the `HAIRSIDE` lines follow the `PHYSICS` lines (the result's `turn.hairSide`), each naming the lock's role, report-only as well. `patches` (see its field) adds displacements to existing keyform stops of the freshly generated rig; each op then prints one line between the path and the fold report \u2014 `PATCH <i> <target> at <Param=v \u2026>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px`, with `(vertices)` in place of the columns and rows for a mesh part \u2014 and the result's `patches` carries the same reports (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`), present whenever `patches` was passed, `[]` included. An op the input schema accepts but the rig refuses comes back as `INVALID: patches[i]\u2026` and nothing is written; an op with a missing field or a field of the wrong type is the SDK's input validation error. `customParts` adds parts the rig has no role for (a twin tail, a hairpin), each from a canvas-sized PNG of its own, as an unrigged mesh on `headDeformer` after its `after` role's parts; it needs @ikijs/mcp 0.34.0, and an older server drops the field and returns no `customParts`. The result's `customParts` (`parts`: `id`, rest `box`, `mesh`, `order`, atlas `page`) is present whenever the input was passed, `[]` included, and one `CUSTOM <id>: \u2026` line per part follows the `HAIRSIDE` lines. `bakes` (see its field) moves the custom parts with a parameter and needs `customParts`; each part and parameter it moves then prints one `BAKE <part> <param>: <n> vertices, stops <values>, error <px> px` line after the `CUSTOM` lines (the result's `customParts.bakes`: `part`, `param`, `vertices`, `stops`, `errorPx`), the written model having been landed through the engine, and a stop off by 0.1 px or more comes back as `INVALID: BAKE ERROR <part> <param>=<value>: \u2026`, and a part the bake moves at rest as `INVALID: BAKE ERROR <part> at rest: \u2026`, with nothing written (the rig and the engine disagree: report it as a bug in the packages). Whenever `customParts` was passed, the written model is also measured per custom part (the result's `customParts.gate`: `ok`, `limits`, `parts`, `failed`) and the text ends with its lines, `CUSTOM <id> FOLDS|TIE|SLIDE|EXPOSED|RIGID|TIP: \u2026` then `CUSTOM GATE pass` or `CUSTOM GATE FAIL: <part LINE, \u2026>`, always the last line: a part's least triangle area ratio, its tie's displacement against the anchor where the head does not turn and where it does, the hidden art showing, how far a rigid part bends and where its free end lands, each in px and face widths with its worst pose; `TIP` never fails the gate and the other lines do. The model is written either way; from 0.34.0 on `customParts` always carries `gate` (a gate that throws still writes the file and ends the text `CUSTOM GATE FAIL: gate error: <message>`), so a result without `customParts` is from an older server and was never gated. The custom layers are not role layers: they are left out of the head's width and turn measurements, and an empty or wrong-size one, or an entry the rig refuses, comes back as `INVALID: customParts[i]\u2026` with nothing written. A missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error.",
7939
+ description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R and either mouth or the lip set (mouth_inner + lip_lower + lip_upper, a mouth that folds open instead of crossfading) required; iris_L/R, brow_L/R, hair_front, body, arm_L/arm_R, forearm_pose_L/forearm_pose_R, hair_side_L/hair_side_R, mouth_tongue/mouth_teeth (only with the lip set: drawn under its lips and clipped to mouth_inner), etc. optional; an arm needs the body, a pose forearm needs its arm, a side lock needs hair_front, and a partial lip set, one mixed with mouth/mouth_open, or mouth_tongue/mouth_teeth without it is refused) into a renderable .iki written to disk. Pass full-canvas PNG file paths; returns the output path + summary (the model is NOT inlined). Filenames map to roles unless `fileName` is given. The result's `folds` is the written rig's fold report, printed after the path the way render_poses prints it, and report-only: a fold never refuses the rig. The `RIGPLAN:` line (the result's `rigPlan`: `effective`, `clamped`, `overriddenBy`) follows the path and precedes the `PATCH` lines. The `PHYSICS` lines follow the fold report (the result's `physics`), one per physics rig output \u2014 a spring's, or each chain segment's \u2014 reading ok, frozen or unstable with the step and idle amplitudes, or `PHYSICS: no rigs`; report-only too. With side locks and a `nose` (which `turn` needs) the `HAIRSIDE` lines follow the `PHYSICS` lines (the result's `turn.hairSide`), each naming the lock's role, report-only as well. `patches` (see its field) adds displacements to existing keyform stops of the freshly generated rig; each op then prints one line between the path and the fold report \u2014 `PATCH <i> <target> at <Param=v \u2026>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px`, with `(vertices)` in place of the columns and rows for a mesh part \u2014 and the result's `patches` carries the same reports (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`), present whenever `patches` was passed, `[]` included. An op the input schema accepts but the rig refuses comes back as `INVALID: patches[i]\u2026` and nothing is written; an op with a missing field or a field of the wrong type is the SDK's input validation error. `customParts` adds parts the rig has no role for (a twin tail, a hairpin), each from a canvas-sized PNG of its own, as an unrigged mesh on `headDeformer` after its `after` role's parts; it needs @ikijs/mcp 0.34.0, and an older server drops the field and returns no `customParts`. A part can declare `occlusion` (hidden where named roles' paint covers it, by an amount keyed on a parameter; it needs 0.35.0, and an older server refuses the key as `INVALID: customParts[i]\u2026`); its `CUSTOM <id>:` line then ends `, hidden by <id>,<id>\u2026 on <parameter> at <value>:<amount> <value>:<amount>\u2026`, and the result's part carries `occlusion` (`by` as the part ids written, `parameter`, `stops`). The result's `customParts` (`parts`: `id`, rest `box`, `mesh`, `order`, atlas `page`) is present whenever the input was passed, `[]` included, and one `CUSTOM <id>: \u2026` line per part follows the `HAIRSIDE` lines. `bakes` (see its field) moves the custom parts with a parameter and needs `customParts`; each part and parameter it moves then prints one `BAKE <part> <param>: <n> vertices, stops <values>, error <px> px` line after the `CUSTOM` lines (the result's `customParts.bakes`: `part`, `param`, `vertices`, `stops`, `errorPx`), the written model having been landed through the engine, and a stop off by 0.1 px or more comes back as `INVALID: BAKE ERROR <part> <param>=<value>: \u2026`, and a part the bake moves at rest as `INVALID: BAKE ERROR <part> at rest: \u2026`, with nothing written (the rig and the engine disagree: report it as a bug in the packages). Whenever `customParts` was passed, the written model is also measured per custom part (the result's `customParts.gate`: `ok`, `limits`, `parts`, `failed`) and the text ends with its lines, `CUSTOM <id> FOLDS|TIE|SLIDE|EXPOSED|RIGID|TIP: \u2026` then `CUSTOM GATE pass` or `CUSTOM GATE FAIL: <part LINE, \u2026>`, always the last line: a part's least triangle area ratio, its tie's displacement against the anchor where the head does not turn and where it does, the hidden art showing, how far a rigid part bends and where its free end lands, each in px and face widths with its worst pose; `TIP` never fails the gate and the other lines do. The model is written either way; from 0.34.0 on `customParts` always carries `gate` (a gate that throws still writes the file and ends the text `CUSTOM GATE FAIL: gate error: <message>`), so a result without `customParts` is from an older server and was never gated. The custom layers are not role layers: they are left out of the head's width and turn measurements, and an empty or wrong-size one, or an entry the rig refuses, comes back as `INVALID: customParts[i]\u2026` with nothing written. A missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error.",
7787
7940
  inputSchema: {
7788
7941
  layers: import_zod.z.array(
7789
7942
  import_zod.z.object({
@@ -7847,10 +8000,30 @@ function createIkiMcpServer() {
7847
8000
  ),
7848
8001
  rigid: import_zod.z.boolean().optional().describe(
7849
8002
  "The art does not bend (a hairpin, a ribbon): a bake that bends it by more than 0.0025 face widths at a stop, from its best-fit rotation and translation, is refused as `INVALID: bakes\u2026` with nothing written. Give a rigid part one displacement for every control point, or a rotation."
8003
+ ),
8004
+ occlusion: import_zod.z.object({
8005
+ by: import_zod.z.array(import_zod.z.string()).describe(
8006
+ "Roles of the set whose paint hides the part (an arm role is its three parts); a non-empty list with no role repeated, each a role of the set. A role with a clipped or meshless part (`iris_L`, `forearm_pose_L`) is refused."
8007
+ ),
8008
+ parameter: import_zod.z.string().describe(
8009
+ "Any declared parameter but a physics output (a spring's or a chain segment's)."
8010
+ ),
8011
+ stops: import_zod.z.array(
8012
+ import_zod.z.object({
8013
+ value: import_zod.z.number(),
8014
+ amount: import_zod.z.number().describe(
8015
+ "0 to 1: 1 hides the part wherever the roles' paint lies over it."
8016
+ )
8017
+ }).passthrough()
8018
+ ).describe(
8019
+ "At least one, `value` strictly ascending and inside the parameter's range. The amount is linear between stops and held before the first and after the last."
8020
+ )
8021
+ }).passthrough().optional().describe(
8022
+ "Hide the part where the named roles' paint covers it, by an amount keyed on a parameter: `{ by, parameter, stops: [{ value, amount }] }`. Cover is where a role's drawn alpha at that pose is at least 0.5, a hard edge; a role that fades (`mouth_open`, a blush, a pose forearm) covers only while drawn at half strength or more. Use the stops as a short switch starting a degree or more past the idle sway, the hiding's progress coming from the part's baked motion. Needs @ikijs/mcp 0.35.0; an older server refuses the key as an unknown key (`INVALID: customParts[i]\u2026`). An unknown key, a bad stop or a part the key cannot be written for comes back as `INVALID: customParts[i].occlusion\u2026` with nothing written."
7850
8023
  )
7851
8024
  }).passthrough()
7852
8025
  ).optional().describe(
7853
- "Parts the auto-rigger has no role for, each `{ id, path, anchor, tie, after, deformer?, rigid? }`. A custom layer is read apart from `layers`: never role-parsed or measured, so its name is free and it does not widen the head the turn is fitted to; it counts toward the layer and pixel limits. All custom parts share one extra atlas page, the last, quantized on a palette of its own, so the other pages keep their bytes. An entry the rig refuses (an unknown key, a bad tie) comes back as `INVALID: customParts[i]\u2026` with nothing written; a missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error. `[]` is the same rig as leaving the field out, plus an empty `customParts` in the result."
8026
+ "Parts the auto-rigger has no role for, each `{ id, path, anchor, tie, after, deformer?, rigid?, occlusion? }`. A custom layer is read apart from `layers`: never role-parsed or measured, so its name is free and it does not widen the head the turn is fitted to; it counts toward the layer and pixel limits. All custom parts share one extra atlas page, the last, quantized on a palette of its own, so the other pages keep their bytes. An entry the rig refuses (an unknown key, a bad tie) comes back as `INVALID: customParts[i]\u2026` with nothing written; a missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error. `[]` is the same rig as leaving the field out, plus an empty `customParts` in the result."
7854
8027
  ),
7855
8028
  bakes: import_zod.z.object({
7856
8029
  targets: import_zod.z.array(
@@ -8103,7 +8276,7 @@ function createIkiMcpServer() {
8103
8276
  "More sweeps rendered after `sweep`, each `{ name, preset, crop? }` into its own `<outDir>/<name>/` (files and `crop` as `sweep`'s). Names are distinct from `sweep`'s and from each other's ignoring case, and presets are distinct (at most one of each). `turn` is `sweep`'s. `roll` is the same eased curve on `ParamAngleZ` (0 to -30 to +30 to 0 over 3 s, 90 frames, physics running, idle off); its `sheet.png` is the nine frames nearest the turn sheet's angles on the -30 to +30 leg, labelled with the angle (Z) and time, and it has no kymograph (the eye row moves with the roll). `turn-nod` is the box (0,0) -> (0,-30) -> (-30,-30) -> (-30,+30) -> (+30,+30) -> (+30,-30) -> (0,-30) -> (0,0) of `ParamAngleX` x `ParamAngleY`, each leg eased, 6 s, 180 frames; its `sheet.png` is a 3 x 3 grid BY ANGLE (columns AngleX -30/0/+30, rows AngleY +30/0/-30, rest in the centre, cells labelled X, Y and t) and it has no kymograph. `manifest.json` is version 2 (`parameters`, and per frame `t` and `values`). A sweep dir's earlier frames, sheet, kymograph, manifest and flipbook are cleared first. An empty list, a repeated name or preset, or a bad crop comes back as `INVALID: sweeps...`. A server before 0.32.0 strips `sweeps` and renders the rest. The `SWEEP nod` lines (the eye-pair and iris-pair gap range and the mouth width range along the nod at each turn, in face widths) and `SWEEP corner` lines (the additivity residual per landmark at the four corners, the rest term included; 0 on an additive rig) print once per call whenever `sweep` or `sweeps` was asked for, report-only like `FOLD` and `PHYSICS`. A `roll` adds no `SWEEP` line of its own and changes none: they are read from the model. `roll` needs @ikijs/mcp 0.34.0; an older server refuses it as an input validation error."
8104
8277
  ),
8105
8278
  hideParts: import_zod.z.array(import_zod.z.string()).optional().describe(
8106
- "Part ids left out of the drawn frames (poses and sweeps); the fold, physics and sweep reports still read the whole model. Use it to render a character without its custom parts, so `measure_turn_reference` reads the rig's own head (a custom part crossing the eye row widens the head it measures, as it does on a drawn reference). An id the model lacks, or one that is the clip mask of a part that stays, comes back as `INVALID: hideParts[i] \u2026` and nothing is rendered. Needs @ikijs/mcp 0.34.0; an older server drops the field and draws every part."
8279
+ "Part ids left out of the drawn frames (poses and sweeps); the fold, physics and sweep reports still read the whole model. Use it to render a character without its custom parts, so `measure_turn_reference` reads the rig's own head (a custom part crossing the eye row widens the head it measures, as it does on a drawn reference). An id the model lacks, or one that is the clip mask of a part that stays, or one a part that stays names in its `occlusion.by` (hide that part too), comes back as `INVALID: hideParts[i] \u2026` and nothing is rendered. Needs @ikijs/mcp 0.34.0; an older server drops the field and draws every part."
8107
8280
  )
8108
8281
  }
8109
8282
  },