@ikijs/mcp 0.3.0 → 0.4.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 +25 -7
- package/dist/chunk-F5RUDS6T.mjs +1176 -0
- package/dist/chunk-F5RUDS6T.mjs.map +1 -0
- package/dist/cli.js +656 -31
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +239 -1
- package/dist/index.d.ts +239 -1
- package/dist/index.js +662 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -1
- package/package.json +2 -2
- package/dist/chunk-2WIV4YEU.mjs +0 -550
- package/dist/chunk-2WIV4YEU.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -94,6 +94,244 @@ type AutoRigResult = {
|
|
|
94
94
|
*/
|
|
95
95
|
declare function autoRigFromLayers(input: AutoRigInput): Promise<AutoRigResult>;
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Measure composed Iki role layers and flag the failure modes that have
|
|
99
|
+
* actually shipped broken characters. Read-only: it never edits anything.
|
|
100
|
+
*
|
|
101
|
+
* Ports the geometry checks that shipped as a script in the Claude Code plugin,
|
|
102
|
+
* so a plugin user gets them from the MCP server instead of an ad-hoc `sharp`
|
|
103
|
+
* install. They exist because "the eyes look too big" is not actionable but
|
|
104
|
+
* "the iris is 33% of the sclera width, target 0.45-0.72" is. Every check below
|
|
105
|
+
* is one that cost a real regeneration or re-tune round to find by eye.
|
|
106
|
+
*
|
|
107
|
+
* `sharp` must stay confined to @ikijs/mcp; the decode goes through
|
|
108
|
+
* ./node-images, this package's single image-decode boundary.
|
|
109
|
+
*/
|
|
110
|
+
/** Alpha-derived geometry of one layer, in canvas pixels. */
|
|
111
|
+
interface LayerStats {
|
|
112
|
+
w: number;
|
|
113
|
+
h: number;
|
|
114
|
+
/** Longest flat cut through the art, and the row it runs along (-1 if none). */
|
|
115
|
+
flatCutRun: number;
|
|
116
|
+
flatCutY: number;
|
|
117
|
+
bboxCx: number;
|
|
118
|
+
bboxCy: number;
|
|
119
|
+
massCx: number;
|
|
120
|
+
massCy: number;
|
|
121
|
+
/** Distance from the layer's content to each canvas edge. */
|
|
122
|
+
marginTop: number;
|
|
123
|
+
marginBottom: number;
|
|
124
|
+
marginLeft: number;
|
|
125
|
+
marginRight: number;
|
|
126
|
+
/** Fraction of each bbox edge that is opaque. */
|
|
127
|
+
edgeTop: number;
|
|
128
|
+
edgeBottom: number;
|
|
129
|
+
edgeLeft: number;
|
|
130
|
+
edgeRight: number;
|
|
131
|
+
canvasW: number;
|
|
132
|
+
canvasH: number;
|
|
133
|
+
}
|
|
134
|
+
interface MeasureReport {
|
|
135
|
+
/** Measured stats by role (the layer's file name without `.png`). */
|
|
136
|
+
layers: Record<string, LayerStats>;
|
|
137
|
+
/** Roles whose PNG is fully transparent — nothing to measure. */
|
|
138
|
+
empty: string[];
|
|
139
|
+
warnings: string[];
|
|
140
|
+
}
|
|
141
|
+
type MeasureResult = ({
|
|
142
|
+
ok: true;
|
|
143
|
+
layersDir: string;
|
|
144
|
+
passed: boolean;
|
|
145
|
+
} & MeasureReport) | {
|
|
146
|
+
ok: false;
|
|
147
|
+
error: string;
|
|
148
|
+
};
|
|
149
|
+
interface MeasureInput {
|
|
150
|
+
/** Directory of role-named layer PNGs (relative paths resolve against cwd). */
|
|
151
|
+
layersDir: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Measure a caller-supplied layers directory.
|
|
155
|
+
*
|
|
156
|
+
* Error boundary: ONLY AutoRigInputError (caller input / filesystem) →
|
|
157
|
+
* `{ ok:false }`, matching autoRigFromLayers; any other throw propagates.
|
|
158
|
+
*/
|
|
159
|
+
declare function measureLayers(input: MeasureInput): Promise<MeasureResult>;
|
|
160
|
+
/**
|
|
161
|
+
* Render a measurement as plain text: the per-layer table first (numbers to
|
|
162
|
+
* argue with), then the checks that fired. Takes the report itself rather than
|
|
163
|
+
* a MeasureResult so a caller holding one inline (no `ok` to unwrap) can print
|
|
164
|
+
* it too; a failed measurement has no report to render.
|
|
165
|
+
*/
|
|
166
|
+
declare function formatMeasureReport(result: MeasureReport & {
|
|
167
|
+
layersDir: string;
|
|
168
|
+
}): string;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Compose AI-generated part PNGs into canvas-aligned, role-named layers for the
|
|
172
|
+
* Iki auto-rig (`auto_rig_from_layers` / `@ikijs/editor` generateIkiFromLayerSet).
|
|
173
|
+
* Each part is alpha-trimmed, resized to a target width, optionally mirrored,
|
|
174
|
+
* and pasted at a chosen center on a shared transparent CANVAS x CANVAS canvas.
|
|
175
|
+
*
|
|
176
|
+
* Ports the composer that shipped as a script in the Claude Code plugin, so a
|
|
177
|
+
* plugin user gets it from the MCP server instead of an ad-hoc `sharp` install.
|
|
178
|
+
* Composing is deterministic: same parts -> same layers, so re-run freely after
|
|
179
|
+
* tuning `layout` (no image re-generation needed).
|
|
180
|
+
*
|
|
181
|
+
* `sharp` must stay confined to @ikijs/mcp; part decoding goes through
|
|
182
|
+
* ./node-images, this package's single image-decode boundary.
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
declare const DEFAULT_LAYOUT: {
|
|
186
|
+
hair_back: {
|
|
187
|
+
src: string;
|
|
188
|
+
cx: number;
|
|
189
|
+
cy: number;
|
|
190
|
+
w: number;
|
|
191
|
+
optional: true;
|
|
192
|
+
};
|
|
193
|
+
body: {
|
|
194
|
+
src: string;
|
|
195
|
+
cx: number;
|
|
196
|
+
cy: number;
|
|
197
|
+
w: number;
|
|
198
|
+
optional: true;
|
|
199
|
+
};
|
|
200
|
+
face: {
|
|
201
|
+
src: string;
|
|
202
|
+
cx: number;
|
|
203
|
+
cy: number;
|
|
204
|
+
w: number;
|
|
205
|
+
};
|
|
206
|
+
mouth: {
|
|
207
|
+
src: string;
|
|
208
|
+
cx: number;
|
|
209
|
+
cy: number;
|
|
210
|
+
w: number;
|
|
211
|
+
};
|
|
212
|
+
mouth_open: {
|
|
213
|
+
src: string;
|
|
214
|
+
cx: number;
|
|
215
|
+
cy: number;
|
|
216
|
+
w: number;
|
|
217
|
+
optional: true;
|
|
218
|
+
};
|
|
219
|
+
eye_L: {
|
|
220
|
+
src: string;
|
|
221
|
+
cx: number;
|
|
222
|
+
cy: number;
|
|
223
|
+
w: number;
|
|
224
|
+
mirror: true;
|
|
225
|
+
noTrim: true;
|
|
226
|
+
};
|
|
227
|
+
eye_R: {
|
|
228
|
+
src: string;
|
|
229
|
+
cx: number;
|
|
230
|
+
cy: number;
|
|
231
|
+
w: number;
|
|
232
|
+
mirror: false;
|
|
233
|
+
noTrim: true;
|
|
234
|
+
};
|
|
235
|
+
iris_L: {
|
|
236
|
+
src: string;
|
|
237
|
+
cx: number;
|
|
238
|
+
cy: number;
|
|
239
|
+
w: number;
|
|
240
|
+
mirror: false;
|
|
241
|
+
};
|
|
242
|
+
iris_R: {
|
|
243
|
+
src: string;
|
|
244
|
+
cx: number;
|
|
245
|
+
cy: number;
|
|
246
|
+
w: number;
|
|
247
|
+
mirror: false;
|
|
248
|
+
};
|
|
249
|
+
lash_L: {
|
|
250
|
+
src: string;
|
|
251
|
+
cx: number;
|
|
252
|
+
cy: number;
|
|
253
|
+
w: number;
|
|
254
|
+
mirror: true;
|
|
255
|
+
noTrim: true;
|
|
256
|
+
};
|
|
257
|
+
lash_R: {
|
|
258
|
+
src: string;
|
|
259
|
+
cx: number;
|
|
260
|
+
cy: number;
|
|
261
|
+
w: number;
|
|
262
|
+
mirror: false;
|
|
263
|
+
noTrim: true;
|
|
264
|
+
};
|
|
265
|
+
brow_L: {
|
|
266
|
+
src: string;
|
|
267
|
+
cx: number;
|
|
268
|
+
cy: number;
|
|
269
|
+
w: number;
|
|
270
|
+
mirror: false;
|
|
271
|
+
};
|
|
272
|
+
brow_R: {
|
|
273
|
+
src: string;
|
|
274
|
+
cx: number;
|
|
275
|
+
cy: number;
|
|
276
|
+
w: number;
|
|
277
|
+
mirror: true;
|
|
278
|
+
};
|
|
279
|
+
hair_front: {
|
|
280
|
+
src: string;
|
|
281
|
+
cx: number;
|
|
282
|
+
cy: number;
|
|
283
|
+
w: number;
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
type Role = keyof typeof DEFAULT_LAYOUT;
|
|
287
|
+
/** Per-role placement overrides; anything omitted keeps the default above. */
|
|
288
|
+
type LayoutOverride = Partial<Record<Role, {
|
|
289
|
+
cx?: number;
|
|
290
|
+
cy?: number;
|
|
291
|
+
w?: number;
|
|
292
|
+
}>>;
|
|
293
|
+
interface ComposeInput {
|
|
294
|
+
/** Directory of the generated part PNGs (relative paths resolve against cwd). */
|
|
295
|
+
partsDir: string;
|
|
296
|
+
/**
|
|
297
|
+
* Existing directory under cwd to write the role layers into. Callers reuse
|
|
298
|
+
* one across runs (it must pre-exist), so the compose leaves it holding
|
|
299
|
+
* exactly the roles it reports: a skipped role's layer from an earlier run is
|
|
300
|
+
* removed rather than left for the next tool to pick up.
|
|
301
|
+
*/
|
|
302
|
+
outDir: string;
|
|
303
|
+
layout?: LayoutOverride;
|
|
304
|
+
}
|
|
305
|
+
interface ComposedLayer {
|
|
306
|
+
role: Role;
|
|
307
|
+
path: string;
|
|
308
|
+
/** Size of the placed part itself (the file is always CANVAS x CANVAS). */
|
|
309
|
+
width: number;
|
|
310
|
+
height: number;
|
|
311
|
+
left: number;
|
|
312
|
+
top: number;
|
|
313
|
+
}
|
|
314
|
+
type ComposeResult = {
|
|
315
|
+
ok: true;
|
|
316
|
+
outDir: string;
|
|
317
|
+
layers: ComposedLayer[];
|
|
318
|
+
/** Roles whose optional part was absent from the parts dir. */
|
|
319
|
+
skipped: Role[];
|
|
320
|
+
preview: string;
|
|
321
|
+
measure: MeasureReport;
|
|
322
|
+
} | {
|
|
323
|
+
ok: false;
|
|
324
|
+
error: string;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Compose a parts directory into role-named layers plus a flattened preview,
|
|
328
|
+
* then measure the result so the caller sees the geometry checks inline.
|
|
329
|
+
*
|
|
330
|
+
* Error boundary: ONLY AutoRigInputError (caller input / filesystem) →
|
|
331
|
+
* `{ ok:false }`, matching autoRigFromLayers; any other throw propagates.
|
|
332
|
+
*/
|
|
333
|
+
declare function composeLayersFromParts(input: ComposeInput): Promise<ComposeResult>;
|
|
334
|
+
|
|
97
335
|
declare function createIkiMcpServer(): McpServer;
|
|
98
336
|
|
|
99
|
-
export { type AutoRigInput, type AutoRigLayerInput, type AutoRigResult, type DeformerSummary, type DescribeResult, type IkiSummary, type StandardParameterInfo, type ValidateResult, autoRigFromLayers, createIkiMcpServer, describeIki, listStandardParameters, validateIki };
|
|
337
|
+
export { type AutoRigInput, type AutoRigLayerInput, type AutoRigResult, type ComposeInput, type ComposeResult, type DeformerSummary, type DescribeResult, type IkiSummary, type LayoutOverride, type MeasureInput, type MeasureResult, type StandardParameterInfo, type ValidateResult, autoRigFromLayers, composeLayersFromParts, createIkiMcpServer, describeIki, formatMeasureReport, listStandardParameters, measureLayers, validateIki };
|