@ikijs/mcp 0.38.1 → 0.38.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -9728,6 +9728,7 @@ var IRIS_IOU = 0.7;
9728
9728
  var DISC_CLOSE = 2;
9729
9729
  var IRIS_MARGIN = 0.25;
9730
9730
  var LID_SIDE = 4;
9731
+ var LID_STREAK = 6;
9731
9732
  var EYE_EDGE = 2;
9732
9733
  var OPENING_SPARE = 2;
9733
9734
  var STROKE_PAST_SHARE = 0.5;
@@ -10054,35 +10055,85 @@ function lashCutOf(pic, all) {
10054
10055
  function upperLid(pic, f, eye2, c) {
10055
10056
  const { width } = pic;
10056
10057
  const { b, cx, cy, rx } = f;
10058
+ const mid = Math.min(b.y1, Math.floor(cy));
10057
10059
  const lid = new Int32Array(width).fill(-1);
10058
- const lashTop = new Int32Array(width).fill(-1);
10060
+ const dark = (x, y) => {
10061
+ const i = y * width + x;
10062
+ return eye2[i] === 1 && c.dark(i);
10063
+ };
10064
+ const ink = (x, y) => dark(x, y) && !c.nearIris(y * width + x);
10065
+ const softTop = (x, top) => {
10066
+ let y = top;
10067
+ while (y - 1 >= b.y0 && top - (y - 1) <= EYE_EDGE && dark(x, y - 1)) y--;
10068
+ return y;
10069
+ };
10070
+ const runEnd = (x, y, step) => {
10071
+ const inside = (r) => r >= b.y0 && r <= mid;
10072
+ for (; ; ) {
10073
+ while (inside(y + step) && ink(x, y + step)) y += step;
10074
+ let rows = 0;
10075
+ while (rows <= LID_STREAK) {
10076
+ const r = y + step * (rows + 1);
10077
+ if (!inside(r) || !dark(x, r) || ink(x, r)) break;
10078
+ rows++;
10079
+ }
10080
+ const next = y + step * (rows + 1);
10081
+ if (rows === 0 || rows > LID_STREAK || !inside(next) || !ink(x, next)) {
10082
+ return y;
10083
+ }
10084
+ y = next;
10085
+ }
10086
+ };
10087
+ const fromTop = (x) => {
10088
+ let run2 = null;
10089
+ let skin = false;
10090
+ for (let y = b.y0; y <= mid; y++) {
10091
+ if (!ink(x, y)) {
10092
+ if (eye2[y * width + x] === 0) skin = true;
10093
+ continue;
10094
+ }
10095
+ if (run2 !== null && !skin) break;
10096
+ const top = y;
10097
+ y = runEnd(x, y, 1);
10098
+ run2 = [softTop(x, top), y];
10099
+ skin = false;
10100
+ }
10101
+ return run2;
10102
+ };
10103
+ const fromInside = (x) => {
10104
+ let y = mid;
10105
+ if (ink(x, y)) return null;
10106
+ while (y >= b.y0 && !ink(x, y)) y--;
10107
+ if (y < b.y0) return null;
10108
+ return [softTop(x, runEnd(x, y, -1)), y];
10109
+ };
10110
+ const x0 = Math.max(b.x0, Math.ceil(cx - rx));
10111
+ const x1 = Math.min(b.x1, Math.floor(cx + rx));
10059
10112
  for (let x = b.x0; x <= b.x1; x++) {
10060
- const at = (y2) => y2 * width + x;
10061
- const lashInk = (y2) => eye2[at(y2)] === 1 && c.dark(at(y2)) && !c.nearIris(at(y2));
10062
- let y = b.y0;
10063
- while (y <= b.y1 && !(eye2[at(y)] && c.dark(at(y)))) y++;
10064
- const first = y;
10065
- while (y <= b.y1 && y - first < EYE_EDGE && !lashInk(y)) y++;
10066
- if (y > b.y1 || y >= cy || !lashInk(y)) continue;
10067
- lashTop[x] = first;
10068
- while (y + 1 <= Math.min(b.y1, Math.floor(cy)) && lashInk(y + 1)) y++;
10069
- lid[x] = y;
10113
+ if (x >= x0 && x <= x1) continue;
10114
+ const run2 = fromInside(x) ?? fromTop(x);
10115
+ if (run2) lid[x] = run2[1];
10070
10116
  }
10071
10117
  const thickness = (from, step) => {
10072
10118
  const t = [];
10073
10119
  for (let x = from; t.length < LID_SIDE && x >= b.x0 && x <= b.x1; x += step) {
10074
- if (lashTop[x] >= 0) t.push(lid[x] - lashTop[x] + 1);
10120
+ const run2 = fromInside(x) ?? fromTop(x);
10121
+ if (run2) t.push(run2[1] - run2[0] + 1);
10075
10122
  }
10076
10123
  return t.length > 0 ? median(t) : null;
10077
10124
  };
10078
10125
  const left = thickness(Math.floor(cx - rx) - 1, -1);
10079
10126
  const right = thickness(Math.ceil(cx + rx) + 1, 1);
10080
- if (left === null && right === null) return lid;
10081
- for (let x = Math.ceil(cx - rx); x <= Math.floor(cx + rx); x++) {
10082
- if (x < b.x0 || x > b.x1 || lashTop[x] < 0) continue;
10127
+ for (let x = x0; x <= x1; x++) {
10128
+ const run2 = fromTop(x);
10129
+ if (!run2) continue;
10130
+ if (left === null && right === null) {
10131
+ lid[x] = run2[1];
10132
+ continue;
10133
+ }
10083
10134
  const u = (x - (cx - rx)) / (2 * rx);
10084
10135
  const t = left === null ? right : right === null ? left : left + (right - left) * u;
10085
- lid[x] = Math.min(lid[x], lashTop[x] + Math.round(t) - 1);
10136
+ lid[x] = Math.min(run2[1], run2[0] + Math.round(t) - 1);
10086
10137
  }
10087
10138
  return lid;
10088
10139
  }
@@ -10106,9 +10157,12 @@ function lowerLidAcross(pic, f, eye2, c, lashCut, upper) {
10106
10157
  const runs = [];
10107
10158
  for (let k = 0; k < LID_SIDE; k++) {
10108
10159
  const x = from + k * step;
10109
- if (x < b.x0 || x > b.x1) break;
10110
- const run2 = runAt(x);
10111
- if (run2) runs.push(run2);
10160
+ const run2 = x < b.x0 || x > b.x1 ? null : runAt(x);
10161
+ const prev = runs[runs.length - 1];
10162
+ if (!run2 || prev && (run2[0] > prev[1] + LID_DRIFT || run2[1] < prev[0] - LID_DRIFT)) {
10163
+ return [];
10164
+ }
10165
+ runs.push(run2);
10112
10166
  }
10113
10167
  return runs;
10114
10168
  };
@@ -12502,7 +12556,7 @@ function formatBakeChecks(bakes) {
12502
12556
  );
12503
12557
  }
12504
12558
  function createIkiMcpServer() {
12505
- const server = new import_mcp.McpServer({ name: "iki", version: "0.38.1" });
12559
+ const server = new import_mcp.McpServer({ name: "iki", version: "0.38.2" });
12506
12560
  server.registerTool(
12507
12561
  "validate_iki",
12508
12562
  {
@@ -12662,7 +12716,7 @@ function createIkiMcpServer() {
12662
12716
  ),
12663
12717
  occlusion: import_zod.z.object({
12664
12718
  by: import_zod.z.array(import_zod.z.string()).describe(
12665
- "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."
12719
+ "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`, a brow drawn on the face, `forearm_pose_L`) is refused."
12666
12720
  ),
12667
12721
  parameter: import_zod.z.string().describe(
12668
12722
  "Any declared parameter but a physics output (a spring's or a chain segment's)."