spine-parts 2.15.0 → 2.16.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/cli.ts +32 -1
- package/docs/AUTHORING.md +3 -0
- package/docs/STABILITY.md +1 -0
- package/package.json +1 -1
- package/src/headcroppreflight.ts +40 -0
package/cli.ts
CHANGED
|
@@ -29,7 +29,8 @@ import { type CharacterConfig, loadClothConfig, loadConfig, loadEarlyConfig, loa
|
|
|
29
29
|
import { configWriteLines, readConfigWriteTarget, separateConfigWriteTarget, stageConfigWrite, type StagedConfigWrite } from './tools/configwrite.ts';
|
|
30
30
|
import { failLine, guidePointer, PartsError } from './src/errors.ts';
|
|
31
31
|
import { GUIDE_DOC, type GuideAnswer, guideRule, guideSection } from './src/guide.ts';
|
|
32
|
-
import { proposeHeadBox } from './src/headbox.ts';
|
|
32
|
+
import { proposeHeadBox, type Box } from './src/headbox.ts';
|
|
33
|
+
import { headCropPreflight, headCropPreflightLines } from './src/headcroppreflight.ts';
|
|
33
34
|
import { makeInputs } from './src/inputs.ts';
|
|
34
35
|
import { idleKeysOf, isIdleKeys } from './src/rig.ts';
|
|
35
36
|
import { bodyCoreBox, bodyOpaqueBox, CORE_ALPHA, depthSkipLine, exportLayers, figuresPhrase, hiddenLayerLine, implausibleRules, layerCoreBox, layerFigures, layerOpaqueBox, type LayerSet, layerSetDiff, type OpaqueBox, OPAQUE_ALPHA_ABOVE, pct, readLayers, readWrapperLayers, ruleSummary, templateLayerNames, templatePsdBytes, times } from './src/layers.ts';
|
|
@@ -350,6 +351,9 @@ usage:
|
|
|
350
351
|
--no-back-hair leaves "back hair" out of the box. --write-config updates
|
|
351
352
|
only seethrough.head_box in an existing config through the layers loader.
|
|
352
353
|
|
|
354
|
+
rig-parts head-crop-preflight --full <run> --canvas <W>x<H> --head-box '[left,top,right,bottom]'
|
|
355
|
+
Report full-run drawn pixels beyond the crop: JSON stdout, advice stderr; no head run needed.
|
|
356
|
+
|
|
353
357
|
rig-parts compare --left <file> --right <file> [--map <bonemap.json>]
|
|
354
358
|
Compare two skeletons bone by bone. Each file is a config, a proposal.json
|
|
355
359
|
or a rig.json (rigc-rig/1), told apart by what it states: "spec" (read by
|
|
@@ -1142,6 +1146,7 @@ const TAKES = {
|
|
|
1142
1146
|
'mesh-stats': { valued: ['--config', '--parts'], switches: [] },
|
|
1143
1147
|
remesh: { valued: ['--rig', '--config', '--parts', '--part', '--mesh', '--delta', '--out', '--requirements', '--idle-keys', '--page-edges', '--pack-shape', '--input-check'], switches: ['--record-input-check'] },
|
|
1144
1148
|
retune: { valued: ['--rig', '--config', '--parts', '--out', '--requirements', '--idle-keys', '--page-edges', '--pack-shape', '--input-check'], switches: ['--record-input-check'] },
|
|
1149
|
+
'head-crop-preflight': { valued: ['--full', '--canvas', '--head-box'], switches: [] },
|
|
1145
1150
|
painting: { valued: ['--keypoints', '--person', '--form'], switches: [] },
|
|
1146
1151
|
} as const satisfies Record<string, { valued: readonly string[]; switches: readonly string[] }>;
|
|
1147
1152
|
|
|
@@ -1438,6 +1443,31 @@ function printLint(P: PartSet, spec: { bones: CharacterConfig['bones']; meshes:
|
|
|
1438
1443
|
return res.findings.length;
|
|
1439
1444
|
}
|
|
1440
1445
|
|
|
1446
|
+
/** A separate command preserves all existing command parsers and their output bytes. */
|
|
1447
|
+
function cmdHeadCropPreflight(args: string[]): number {
|
|
1448
|
+
const flags = new Map<string, string>();
|
|
1449
|
+
for (let i = 0; i < args.length; i += 2) {
|
|
1450
|
+
const flag = args[i];
|
|
1451
|
+
if (!takesValued('head-crop-preflight', flag)) return usage(notTaken('head-crop-preflight', flag));
|
|
1452
|
+
if (flags.has(flag)) return usage(`${flag} is given twice`);
|
|
1453
|
+
if (args[i + 1] === undefined || args[i + 1].startsWith('--')) return usage(`${flag} needs a value`);
|
|
1454
|
+
flags.set(flag, args[i + 1]);
|
|
1455
|
+
}
|
|
1456
|
+
const full = flags.get('--full'), canvasArg = flags.get('--canvas'), boxArg = flags.get('--head-box');
|
|
1457
|
+
if (full === undefined || canvasArg === undefined || boxArg === undefined) return usage("head-crop-preflight needs --full <run>, --canvas <W>x<H> and --head-box '[left,top,right,bottom]'");
|
|
1458
|
+
const canvas = parseCanvas(canvasArg);
|
|
1459
|
+
if (canvas === null) return usage(`--canvas ${canvasArg} is not <W>x<H> in integer px`);
|
|
1460
|
+
let box: unknown;
|
|
1461
|
+
try { box = JSON.parse(boxArg); } catch { return usage('--head-box needs a JSON array of four finite coordinates'); }
|
|
1462
|
+
if (!Array.isArray(box) || box.length !== 4 || !box.every(n => typeof n === 'number' && Number.isFinite(n))) return usage('--head-box needs a JSON array of four finite coordinates');
|
|
1463
|
+
try {
|
|
1464
|
+
const report = headCropPreflight(readLayers(full), canvas, box as Box);
|
|
1465
|
+
console.log(JSON.stringify(report));
|
|
1466
|
+
for (const line of headCropPreflightLines(report)) console.error(line);
|
|
1467
|
+
return EXIT_OK;
|
|
1468
|
+
} catch (err) { return printRefusal(err); }
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1441
1471
|
function cmdPropose(args: string[]): number {
|
|
1442
1472
|
const flags = new Map<string, string>();
|
|
1443
1473
|
let headBox = false;
|
|
@@ -2300,6 +2330,7 @@ function main(argv: string[]): number | Promise<number> {
|
|
|
2300
2330
|
if (command === 'sheet') return cmdSheet(rest);
|
|
2301
2331
|
if (command === 'rig') return cmdRig(rest);
|
|
2302
2332
|
if (command === 'propose') return cmdPropose(rest);
|
|
2333
|
+
if (command === 'head-crop-preflight') return cmdHeadCropPreflight(rest);
|
|
2303
2334
|
if (command === 'compare') return cmdCompare(rest);
|
|
2304
2335
|
if (command === 'check') return cmdCheck(rest);
|
|
2305
2336
|
if (command === 'loop') return cmdLoop(rest);
|
package/docs/AUTHORING.md
CHANGED
|
@@ -4123,6 +4123,7 @@ existing hardlinks are refused before artifact output; the ordinary mode names
|
|
|
4123
4123
|
| `sheet --source <png> --layers <path>… --out <png>` | a labelled contact sheet of the painting and every layer or part |
|
|
4124
4124
|
| `assemble --propose-plan … [--write-config <config>]` | propose `assemble.plan` and `extend_below_crop` from the two runs, leaving out an implausible layer with a note naming the rule, naming in a note any full-run body no planned part covers, and naming every layer no row takes with why (empty, taken from the other run only, a plausibility rule; `nose`, never planned, with the row that lets `propose` read the head's pitch). Front/back hair reaching more than 8 rig pixels beyond a side or top edge receives explicit `edges`; each explicit edge has the same strict reach bar. The legacy bottom entry is retained unchanged; qualifying side/top edges receive a separate entry without bottom. With no qualifying side/top edge, the proposal remains unchanged. |
|
|
4125
4125
|
| `assemble --source --full --head --config --out [--seam] [--project]` | merge the two runs into rig-space parts, `parts.json`, the recomposite and its error map, and list the uncovered holes |
|
|
4126
|
+
| `head-crop-preflight --full <run> --canvas WxH --head-box '[left,top,right,bottom]'` | before the head run: JSON on stdout, one advice line per hit tag on stderr, exit 0 even when clipped. Counts original alpha > 8 full-run samples after centre registration through the square pad into painting coordinates: centres below left/top or at/above right/bottom are outside. Fractional boxes are accepted; corner samples count on both edges. No ghost cleanup, resampling, head run or assemble is needed. Bottom is distinct because `extend_below_crop` handles it. Zero-hit tags remain in JSON. Existing pipeline outputs stay unchanged; help adds this command and guide reflects these documentation edits. |
|
|
4126
4127
|
| `propose --head-box --full <run> --canvas WxH [--no-back-hair] [--write-config <config>]` | propose `seethrough.head_box` from the full run, held inside the painting; `--no-back-hair` leaves the back-hair layer out of that proposal |
|
|
4127
4128
|
| `propose --parts --source --out [--compare <config>] [--write-config <config> [--only-missing]]` | propose bones, meshes, regions and an idle; draw the overlay; print, per bone, which check read it or that none did and why (its role, its kind of segment), and write `basis.json` beside the proposal — what each bone rests on (a joint, a part's mask, a ratio, other bones) and, with `--compare`, whether the config's bone differs |
|
|
4128
4129
|
| `propose … --keypoints <file> [--person <id>]` | read a posed figure's joints from one explicit file (space, image size, people, each joint observed, occluded or missing, its source): a joint with a position places the neck, hip, chest or a sleeve chain as given, a note says how every joint was used or which rule stood in, and LINT reads the torso and sleeves along the joints instead of by screen y ([AUTHORING §3](AUTHORING.md)) |
|
|
@@ -5274,6 +5275,8 @@ those settings. Changing a config seed alone cannot change a no-config run.
|
|
|
5274
5275
|
|
|
5275
5276
|
| rule | means | change |
|
|
5276
5277
|
| --- | --- | --- |
|
|
5278
|
+
| <a id="HEAD_CROP_PREFLIGHT"></a>`HEAD_CROP_PREFLIGHT` | report-only: full-run drawn samples outside the declared crop, per tag and edge; bottom is separate for `extend_below_crop`; clipping never refuses | `head-crop-preflight --full <run> --canvas WxH --head-box '[left,top,right,bottom]'` |
|
|
5279
|
+
| <a id="HEAD_CROP_PREFLIGHT_BOX"></a>`HEAD_CROP_PREFLIGHT_BOX` | malformed box: four finite coordinates with left < right and top < bottom required | `--head-box` JSON array |
|
|
5277
5280
|
| <a id="HEADBOX_FACE_PRESENT"></a><a id="HEADBOX_RUN_SQUARE"></a><a id="HEADBOX_CANVAS_SIZE"></a><a id="HEADBOX_FITS_CANVAS"></a>`HEADBOX_FACE_PRESENT`, `HEADBOX_RUN_SQUARE`, `HEADBOX_CANVAS_SIZE`, `HEADBOX_FITS_CANVAS` | the full run has no face or is not square; `--canvas` is not a positive size; or the painting cannot hold the proposed box at its size — its shorter side is the bound (shrinking it would cut the head) | `--full`, `--canvas`, or the painting |
|
|
5278
5281
|
| <a id="PROPOSE_SOURCE_PRESENT"></a><a id="PROPOSE_PNG_PRESENT"></a><a id="PROPOSE_PNG_MATCHES_BOX"></a>`PROPOSE_SOURCE_PRESENT`, `PROPOSE_PNG_PRESENT`, `PROPOSE_PNG_MATCHES_BOX` | the painting or a part PNG is missing, or a PNG is not its box | `--source`, `--parts` (re-run assemble) |
|
|
5279
5282
|
| <a id="PROPOSE_FACE_PRESENT"></a>`PROPOSE_FACE_PRESENT` | no part comes from a `face` layer, and the face-less fallback cannot derive a face box either: it needs the head run's `neck` and at least one head-run `front hair`/`back hair` part whose top is above the neck's, and the message names the half that is missing. With both, `propose` does not refuse — it derives the box and says so in its first note (§5) | `assemble.plan`: take the face, or the head run's hair and neck |
|
package/docs/STABILITY.md
CHANGED
|
@@ -58,6 +58,7 @@ defaults are the help's too, and none is guessed from the art.
|
|
|
58
58
|
| `comfy` | `paint`: `--config`, `--out`; optional `--seeds`, `--seed0`, `--host`, `--wait`, `--timeout`, `--poll` |
|
|
59
59
|
| `comfy` | `seethrough`: `--image`, `--out`; optional `--resolution`, `--steps`, `--seed`, `--prefix`, `--offload`, `--no-offload`, `--lama`, `--nf4`, `--host`, `--wait`, `--timeout`, `--poll`, `--config` (See-through settings and optional depth block), `--depth-run` (`full` or `head`, required with the block) |
|
|
60
60
|
| `assemble` | `--propose-plan` with `--source`, `--full`, `--config`, optional `--head`, `--write-config` (must name `--config` itself, issue #356); or `--source`, `--full`, `--config`, `--out`, optional `--head` (without it, one run: issue #359), `--seam` (near-white, silhouette), `--project` (core, visible), `--alt` (repeatable `<name>=<source>:<full>[:<head>]`, issue #454), `--requirements` (source-bound cut-material evidence only when the file declares `cut_material`, issue #888) |
|
|
61
|
+
| `head-crop-preflight` | `--full`, `--canvas`, `--head-box` (JSON coordinate array); read-only advice before the head run, original alpha > 8 samples (issue #1082) |
|
|
61
62
|
| `propose` | `--head-box` with `--full`, `--canvas`; optional `--no-back-hair`, `--write-config` (existing config, issue #356) |
|
|
62
63
|
| `propose` | `--parts`, `--source`, `--out`; optional `--compare` or `--from-config` (one of them), `--keypoints`, `--person` and `--wrist-snap` (each with `--keypoints`), `--full`, `--head` (the turn control's depths; not with `--from-config`), `--grid-rule` (`figure` or `part`, the drafted lattice's spacing; not with `--from-config`), `--cloth` (a config whose `cloth` block is the recipe, issue #364; not with `--from-config`), `--write-config` (existing config for an ordinary proposal, issue #356; a new file with `--cloth`, issue #537; not with `--from-config` — additive: without it nothing `propose` writes changes), `--from` (the config the recipe is changed from, only with `--write-config`, issue #571 — additive: without it nothing `--write-config` writes changes), `--only-missing` (only with `--parts` and `--write-config`, not with `--cloth` or `--from-config`, issue #671 — additive: without it nothing `--write-config` writes changes) `--bust-landmarks` (rig-pixel apex_r/apex_l and optional cleavage), or `--no-bust` (non-blank omission reason), one required when drafting a chest-holding torso, both incompatible with `--from-config` |
|
|
63
64
|
| `propose` | `--parts`, `--source`, `--out`, `--full`, `--head`, `--write-config` together: the [neck draft](AUTHORING.md#a-neck-that-moves-on-its-own) for an existing config with `turn.body` and one neck plan row; reassembles under `<out>/rig`, preserves the sampled turn and drafts a rigid neck unit (issue #826) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spine-parts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Read-only crop advice on the original full-run drawn-pixel grid (issue #1082). */
|
|
2
|
+
import { squarePad } from './inputs.ts';
|
|
3
|
+
import { OPAQUE_ALPHA_ABOVE, type LayerSet } from './layers.ts';
|
|
4
|
+
import type { Box } from './headbox.ts';
|
|
5
|
+
import { refuseIfAny, type Problem } from './errors.ts';
|
|
6
|
+
|
|
7
|
+
export const HEAD_CROP_PREFLIGHT_LINE = 'HEAD_CROP_PREFLIGHT';
|
|
8
|
+
|
|
9
|
+
/** Counts are native full-run samples, never resampled area; corners count on both edges. */
|
|
10
|
+
export function headCropPreflight(full: LayerSet, source: { w: number; h: number }, box: Box) {
|
|
11
|
+
const problems: Problem[] = [];
|
|
12
|
+
if (![source.w, source.h].every(n => Number.isInteger(n) && n > 0)) problems.push({ code: 'HEADBOX_CANVAS_SIZE', object: '--canvas', detail: `painting is ${source.w}x${source.h}; positive integer dimensions required` });
|
|
13
|
+
if (full.canvas.w !== full.canvas.h || !Number.isInteger(full.canvas.w) || full.canvas.w <= 0) problems.push({ code: 'HEADBOX_RUN_SQUARE', object: full.source, detail: `full run is ${full.canvas.w}x${full.canvas.h}; a positive square canvas is required` });
|
|
14
|
+
if (box.length !== 4 || !box.every(Number.isFinite) || !(box[0] < box[2] && box[1] < box[3])) problems.push({ code: 'HEAD_CROP_PREFLIGHT_BOX', object: '--head-box', detail: `head_box ${JSON.stringify(box)}; four finite coordinates with left < right and top < bottom required` });
|
|
15
|
+
refuseIfAny(problems);
|
|
16
|
+
const pad = squarePad(source.w, source.h);
|
|
17
|
+
const scale = pad.side / full.canvas.w;
|
|
18
|
+
const layers = full.layers.map(layer => {
|
|
19
|
+
let drawn_px = 0, top_px = 0, left_px = 0, right_px = 0, bottom_px = 0;
|
|
20
|
+
for (let y = 0; y < layer.pixels.height; y++) for (let x = 0; x < layer.pixels.width; x++) {
|
|
21
|
+
if (layer.pixels.data[(y * layer.pixels.width + x) * 4 + 3] <= OPAQUE_ALPHA_ABOVE) continue;
|
|
22
|
+
drawn_px++;
|
|
23
|
+
const cx = (layer.left + x + 0.5) * scale - pad.left;
|
|
24
|
+
const cy = (layer.top + y + 0.5) * scale - pad.top;
|
|
25
|
+
if (cx < box[0]) left_px++;
|
|
26
|
+
if (cx >= box[2]) right_px++;
|
|
27
|
+
if (cy < box[1]) top_px++;
|
|
28
|
+
if (cy >= box[3]) bottom_px++;
|
|
29
|
+
}
|
|
30
|
+
return { tag: layer.name, drawn_px, sides: { top_px, left_px, right_px }, bottom_px };
|
|
31
|
+
});
|
|
32
|
+
return { spec: 'rig-parts/head-crop-preflight/1', head_box: box, source_canvas: source, run_canvas: full.canvas,
|
|
33
|
+
drawn_alpha_above: OPAQUE_ALPHA_ABOVE, pixel_grid: 'full-run', registration: { scale_source_per_run: scale, pad_left: pad.left, pad_top: pad.top }, layers };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** One advice line per hit tag; bottom remains distinct from the three side/top edges. */
|
|
37
|
+
export function headCropPreflightLines(report: ReturnType<typeof headCropPreflight>): string[] {
|
|
38
|
+
return report.layers.filter(r => r.sides.top_px + r.sides.left_px + r.sides.right_px + r.bottom_px > 0).map(r =>
|
|
39
|
+
`${HEAD_CROP_PREFLIGHT_LINE}: tag ${JSON.stringify(r.tag)} — top ${r.sides.top_px}, left ${r.sides.left_px}, right ${r.sides.right_px} drawn px; bottom ${r.bottom_px} drawn px (extend_below_crop); report only`);
|
|
40
|
+
}
|