@rig-c/parts 2.44.0 → 2.46.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 +2 -0
- package/cli.ts +142 -33
- package/docs/AUTHORING.md +441 -100
- package/docs/DEPTH.md +33 -6
- package/docs/MIGRATION.md +2 -0
- package/docs/STABILITY.md +405 -51
- package/package.json +5 -1
- package/src/assemble.ts +7 -2
- package/src/assembly-reading.ts +267 -0
- package/src/boundarydepth.ts +113 -0
- package/src/build.ts +27 -13
- package/src/check.ts +305 -81
- package/src/cloth.ts +14 -3
- package/src/config.ts +78 -11
- package/src/configrelocation.ts +48 -2
- package/src/configwrite.ts +9 -7
- package/src/diffdrafts.ts +593 -0
- package/src/editedparts.ts +11 -2
- package/src/externalreceipt.ts +130 -0
- package/src/maskvalues.ts +21 -0
- package/src/outputpaths.ts +40 -0
- package/src/parts.ts +48 -11
- package/src/plate.ts +2 -6
- package/src/propose.ts +169 -12
- package/src/receiptproducer.ts +41 -0
- package/src/remesh-api.ts +33 -0
- package/src/remesh.ts +197 -19
- package/src/remeshdelta.ts +143 -30
- package/src/rig.ts +95 -21
- package/src/scene.ts +45 -9
- package/src/sceneclips.ts +60 -1
- package/src/turn.ts +24 -3
- package/tools/configwrite.ts +22 -14
- package/tools/edited-part-cli.ts +28 -8
- package/tools/neck-propose.ts +2 -0
package/README.md
CHANGED
|
@@ -329,7 +329,9 @@ Command details and config saving are in the [command reference](docs/AUTHORING.
|
|
|
329
329
|
| `layers` | [Inspect wrapper layers or a PSD](docs/AUTHORING.md#command-reference) |
|
|
330
330
|
| `sheet` | [Make a contact sheet](docs/AUTHORING.md#command-reference) |
|
|
331
331
|
| `assemble` | [Merge layers into measured parts](docs/AUTHORING.md#command-reference) |
|
|
332
|
+
| `diff-drafts` | [Compare two assemble outputs](docs/AUTHORING.md#command-reference) |
|
|
332
333
|
| `edited-part` | [Record an edited part receipt](docs/AUTHORING.md#edited-rig-space-parts-assembleedited_parts-issue-1278) |
|
|
334
|
+
| `external-receipt` | [Record or verify an external mask](docs/AUTHORING.md#external-mask-receipt) |
|
|
333
335
|
| `propose` | [Draft or inspect a character config](docs/AUTHORING.md#command-reference) |
|
|
334
336
|
| `compare` | [Compare two skeletons by name](docs/AUTHORING.md#command-reference) |
|
|
335
337
|
| `rig` | [Author gated rig and motion specs](docs/AUTHORING.md#command-reference) |
|
package/cli.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
+
import { assemblyChangeDetail, assemblyConfigChanges } from './src/assembly-reading.ts';
|
|
2
3
|
import { diffComponentsCommand } from './src/diffcomponents.ts';
|
|
4
|
+
import { DIFF_DRAFTS_SPEC, diffDraftsCommand } from './src/diffdrafts.ts';
|
|
3
5
|
import { applyTakenLayers } from './src/takelayers.ts';
|
|
4
6
|
import { applyDepth, bindDepthMap, prepareDepth } from './src/depthworkflow.ts';
|
|
7
|
+
import { externalReceipt } from './src/externalreceipt.ts';
|
|
5
8
|
import { writeEditedPart } from './tools/edited-part-cli.ts';
|
|
6
9
|
/**
|
|
7
10
|
* rig-parts — one painting and its See-through layers in, Spine-ready parts
|
|
@@ -74,7 +77,9 @@ const LATER: ReadonlyArray<[string, string]> = [];
|
|
|
74
77
|
const HELP = `rig-parts ${version()} — Spine-ready parts from one painting and its See-through layers
|
|
75
78
|
|
|
76
79
|
usage:
|
|
77
|
-
rig-parts edited-part --config <config.json> --part <name> --file <edited.png> --from <assembled.png> --editor <text> [--rig-config <config.json>]
|
|
80
|
+
rig-parts edited-part --config <config.json> --part <name> --file <edited.png> --from <assembled.png> (--producer <json> | --editor <text>) [--parts <parts.json>] [--rig-config <config.json>]
|
|
81
|
+
rig-parts external-receipt --kind mask --file <png> --painting <png> --producer <json> --out <receipt.json>
|
|
82
|
+
rig-parts external-receipt --verify <receipt.json>
|
|
78
83
|
Record both file hashes and the declared editor in one edited_parts receipt.
|
|
79
84
|
Update only explicitly named configs; build verifies the assembled baseline.
|
|
80
85
|
|
|
@@ -82,6 +87,12 @@ usage:
|
|
|
82
87
|
[--threshold <channel>] [--figure <binary-png>] [--owners] (--out <json> | --verify <json>)
|
|
83
88
|
Exhaustive native difference inventory; default max RGB channel > 40.
|
|
84
89
|
|
|
90
|
+
rig-parts diff-drafts --left <dir> --right <dir> --out <json>
|
|
91
|
+
Compare two assemble or build outputs and write ${DIFF_DRAFTS_SPEC} JSON:
|
|
92
|
+
per-part status (same, changed, added, removed), file sha256, rig-pixel
|
|
93
|
+
box and draw-order index per present side, pixels_equal and rig-space
|
|
94
|
+
pixel diff counts/bounds on changed parts, and the composite pixel diff.
|
|
95
|
+
|
|
85
96
|
|
|
86
97
|
rig-parts depth-prepare --parts <assembled-dir> --config <depth-recipe.json> --out <empty-dir>
|
|
87
98
|
Write per-part inference PNGs on neutral gray, upscaled and padded as
|
|
@@ -1102,6 +1113,14 @@ function cmdDiffComponents(args: string[]): number {
|
|
|
1102
1113
|
try { diffComponentsCommand(args); return EXIT_OK; } catch (err) { return printRefusal(err); }
|
|
1103
1114
|
}
|
|
1104
1115
|
|
|
1116
|
+
function cmdDiffDrafts(args: string[]): number {
|
|
1117
|
+
for (let i = 0; i < args.length; i += 2) {
|
|
1118
|
+
if (!takesValued('diff-drafts', args[i])) return usage(notTaken('diff-drafts', args[i]));
|
|
1119
|
+
if (args[i + 1] === undefined || args[i + 1].startsWith('--')) return usage(`diff-drafts ${args[i]} requires a value`);
|
|
1120
|
+
}
|
|
1121
|
+
try { diffDraftsCommand(args); return EXIT_OK; } catch (err) { return printRefusal(err); }
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1105
1124
|
/** `guide`: one argument, a rule name or a section; the slice printed, or the refusal. */
|
|
1106
1125
|
function cmdGuide(args: string[]): number {
|
|
1107
1126
|
if (args.length !== 1) return usage(`guide takes one rule name or one §<n> / §<n>.<m> / §<n>.<m>.<k>; got ${args.length} argument(s)`);
|
|
@@ -1190,33 +1209,35 @@ function printLayerTable(set: LayerSet): void {
|
|
|
1190
1209
|
* no row; `layers` takes one positional path beside its flags (issue #359).
|
|
1191
1210
|
*/
|
|
1192
1211
|
const TAKES = {
|
|
1193
|
-
'edited-part': { valued: ['--config', '--part', '--file', '--from', '--editor', '--rig-config'], switches: [] },
|
|
1194
|
-
'
|
|
1195
|
-
'
|
|
1196
|
-
'
|
|
1197
|
-
'
|
|
1198
|
-
'depth-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
'comfy
|
|
1210
|
-
'comfy
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1212
|
+
'edited-part': { valued: ['--config', '--part', '--file', '--from', '--editor', '--producer', '--parts', '--rig-config'], switches: ['--help'] },
|
|
1213
|
+
'external-receipt': { valued: ['--kind', '--file', '--painting', '--producer', '--out', '--verify'], switches: ['--help'] },
|
|
1214
|
+
'check-parts': { valued: ['--parts', '--out'], switches: ['--json', '--help'] },
|
|
1215
|
+
'diff-components': { valued: ['--stack', '--painting', '--parts', '--figure', '--floor', '--threshold', '--out', '--verify'], switches: ['--owners', '--help'] },
|
|
1216
|
+
'diff-drafts': { valued: ['--left', '--right', '--out'], switches: ['--help'] },
|
|
1217
|
+
'depth-bind': { valued: ['--map', '--input', '--part'], switches: ['--help'] },
|
|
1218
|
+
'depth-prepare': { valued: ['--parts', '--config', '--out'], switches: ['--help'] },
|
|
1219
|
+
'depth-apply': { valued: ['--parts', '--manifest', '--config', '--rig-config', '--out'], switches: ['--help'] },
|
|
1220
|
+
layers: { valued: ['--export', '--template', '--canvas', '--full', '--source', '--config'], switches: ['--help'] },
|
|
1221
|
+
sheet: { valued: ['--source', '--layers', '--out', '--cell', '--cols'], switches: ['--help'] },
|
|
1222
|
+
rig: { valued: ['--config', '--parts', '--out', '--idle-keys', '--page-edges', '--pack-shape', '--page-size'], switches: ['--help'] },
|
|
1223
|
+
propose: { valued: ['--parts', '--source', '--out', '--from-config', '--compare', '--full', '--head', '--canvas', '--keypoints', '--person', '--wrist-snap', '--grid-rule', '--cloth', '--write-config', '--from', '--bust-landmarks', '--no-bust'], switches: ['--head-box', '--no-back-hair', '--only-missing', '--help'] },
|
|
1224
|
+
compare: { valued: ['--left', '--right', '--map'], switches: ['--help'] },
|
|
1225
|
+
check: { valued: ['--rig', '--out', '--parts', '--source', '--page-edges', '--pack-shape', '--page-size', '--requirements', '--set', '--environment', '--wind-band'], switches: ['--seam-pairs', '--keep-stills', '--all-sets', '--no-extremes', '--json', '--help'] },
|
|
1226
|
+
loop: { valued: ['--frames', '--out'], switches: ['--palette', '--help'] },
|
|
1227
|
+
assemble: { valued: ['--source', '--full', '--head', '--config', '--out', '--emit-fill-masks', '--seam', '--project', '--alt', '--write-config', '--requirements'], switches: ['--propose-plan', '--help'] },
|
|
1228
|
+
'comfy seethrough': { valued: ['--image', '--out', '--resolution', '--steps', '--seed', '--prefix', '--host', '--wait', '--timeout', '--poll', '--config', '--depth-run'], switches: ['--offload', '--no-offload', '--lama', '--nf4', '--help'] },
|
|
1229
|
+
'comfy paint': { valued: ['--config', '--out', '--seeds', '--seed0', '--host', '--wait', '--timeout', '--poll'], switches: ['--help'] },
|
|
1230
|
+
'comfy matte': { valued: ['--painting', '--out', '--node', '--model', '--checkpoint-sha256', '--resolution', '--threshold', '--host', '--wait', '--timeout', '--poll'], switches: ['--help'] },
|
|
1231
|
+
'comfy plate': { valued: ['--mode', '--painting', '--mask-from', '--occluder', '--out', '--graph', '--model', '--checkpoint-sha256', '--seed', '--grow', '--steps', '--cfg', '--prompt', '--negative', '--host', '--wait', '--timeout', '--poll'], switches: ['--holes', '--help'] },
|
|
1232
|
+
inputs: { valued: ['--source', '--config', '--out'], switches: ['--help'] },
|
|
1233
|
+
build: { valued: ['--config', '--source', '--full', '--head', '--out', '--seam', '--project', '--page-edges', '--pack-shape', '--page-size', '--requirements', '--idle-keys', '--lead-in', '--alt', '--set', '--environment', '--wind-band'], switches: ['--loop', '--seam-pairs', '--keep-stills', '--all-sets', '--no-extremes', '--help'] },
|
|
1234
|
+
compose: { valued: ['--scene', '--out', '--requirements', '--accept', '--page-size'], switches: ['--help'] },
|
|
1235
|
+
'mesh-draft': { valued: ['--config', '--parts', '--out', '--requirements', '--idle-keys', '--page-edges', '--pack-shape', '--page-size'], switches: ['--more-triangles', '--help'] },
|
|
1236
|
+
'mesh-stats': { valued: ['--config', '--parts'], switches: ['--help'] },
|
|
1237
|
+
remesh: { valued: ['--rig', '--config', '--parts', '--part', '--mesh', '--delta', '--out', '--requirements', '--idle-keys', '--page-edges', '--pack-shape', '--page-size', '--input-check'], switches: ['--record-input-check', '--help'] },
|
|
1238
|
+
retune: { valued: ['--rig', '--config', '--parts', '--out', '--requirements', '--idle-keys', '--page-edges', '--pack-shape', '--page-size', '--input-check'], switches: ['--record-input-check', '--help'] },
|
|
1239
|
+
'head-crop-preflight': { valued: ['--full', '--canvas', '--head-box'], switches: ['--help'] },
|
|
1240
|
+
painting: { valued: ['--keypoints', '--person', '--form'], switches: ['--help'] },
|
|
1220
1241
|
} as const satisfies Record<string, { valued: readonly string[]; switches: readonly string[] }>;
|
|
1221
1242
|
|
|
1222
1243
|
type Command = keyof typeof TAKES;
|
|
@@ -1226,10 +1247,73 @@ function takesValued(command: Command, flag: string): boolean {
|
|
|
1226
1247
|
return (TAKES[command].valued as readonly string[]).includes(flag);
|
|
1227
1248
|
}
|
|
1228
1249
|
|
|
1229
|
-
/** The unknown-flag refusal: the flag, and every flag the command's {@link TAKES} row holds, valued then bare. */
|
|
1250
|
+
/** The unknown-flag refusal: the flag, and every flag the command's {@link TAKES} row holds, valued then bare (keeping `--help` out of non-compose refusals so no non-help output byte changes, issue #1360). */
|
|
1230
1251
|
function notTaken(command: Command, flag: string): string {
|
|
1231
1252
|
const row = TAKES[command];
|
|
1232
|
-
|
|
1253
|
+
const switches = command === 'compose' ? row.switches : row.switches.filter((f) => f !== '--help');
|
|
1254
|
+
return `${command} does not take "${flag}"; it takes ${[...row.valued, ...switches].join(', ')}`;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/** One command's (or comfy subcommand's) own usage section from {@link HELP}. */
|
|
1258
|
+
function commandUsage(target: string): string | null {
|
|
1259
|
+
const end = HELP.indexOf('\n rig-parts --version');
|
|
1260
|
+
const lines = (end < 0 ? HELP : HELP.slice(0, end)).split('\n');
|
|
1261
|
+
const head = ` rig-parts ${target} `;
|
|
1262
|
+
const from = lines.findIndex((l) => l.startsWith(head));
|
|
1263
|
+
if (from < 0) return null;
|
|
1264
|
+
let to = lines.length;
|
|
1265
|
+
for (let i = from + 1; i < lines.length; i++) {
|
|
1266
|
+
if (lines[i].startsWith(' rig-parts ') && !lines[i].startsWith(head)) {
|
|
1267
|
+
to = i;
|
|
1268
|
+
break;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
while (to > from && lines[to - 1] === '') to--;
|
|
1272
|
+
return lines.slice(from, to).join('\n');
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
/** Shared `--help` / `-h` path taken before any command's own flag parsing (issue #1360). */
|
|
1276
|
+
function maybeCommandHelp(command: string, args: readonly string[]): number | null {
|
|
1277
|
+
if (!args.includes('--help') && !args.includes('-h')) return null;
|
|
1278
|
+
if (command === 'guide') {
|
|
1279
|
+
if (args.length === 1 && (args[0] === '--help' || args[0] === '-h')) {
|
|
1280
|
+
console.log(commandUsage('guide'));
|
|
1281
|
+
return EXIT_OK;
|
|
1282
|
+
}
|
|
1283
|
+
return null;
|
|
1284
|
+
}
|
|
1285
|
+
if (command === 'comfy' && (args[0] === '--help' || args[0] === '-h')) {
|
|
1286
|
+
if (args.filter((a) => a === '--help' || a === '-h').length > 1) return usage('--help is given twice');
|
|
1287
|
+
const extra = args.find((a) => a !== '--help' && a !== '-h');
|
|
1288
|
+
if (extra !== undefined) return usage(`comfy takes seethrough, paint, plate or matte; got "${extra}"`);
|
|
1289
|
+
console.log(commandUsage('comfy'));
|
|
1290
|
+
return EXIT_OK;
|
|
1291
|
+
}
|
|
1292
|
+
const target: Command | null =
|
|
1293
|
+
command === 'comfy'
|
|
1294
|
+
? args[0] === 'seethrough' || args[0] === 'paint' || args[0] === 'plate' || args[0] === 'matte'
|
|
1295
|
+
? `comfy ${args[0]}`
|
|
1296
|
+
: null
|
|
1297
|
+
: Object.hasOwn(TAKES, command)
|
|
1298
|
+
? (command as Command)
|
|
1299
|
+
: null;
|
|
1300
|
+
if (target === null) return null;
|
|
1301
|
+
const cmdArgs = command === 'comfy' ? args.slice(1) : args;
|
|
1302
|
+
const help = cmdArgs.filter((a) => a === '--help' || a === '-h').length;
|
|
1303
|
+
if (help === 0) return null;
|
|
1304
|
+
if (help > 1) return usage('--help is given twice');
|
|
1305
|
+
const rest = cmdArgs.filter((a) => a !== '--help' && a !== '-h');
|
|
1306
|
+
const switches = (TAKES[target].switches as readonly string[]).filter((f) => f !== '--help');
|
|
1307
|
+
for (let i = 0; i < rest.length; i++) {
|
|
1308
|
+
const flag = rest[i];
|
|
1309
|
+
if (switches.includes(flag)) continue;
|
|
1310
|
+
if ((target === 'layers' || target === 'painting') && !flag.startsWith('--')) continue;
|
|
1311
|
+
if (!takesValued(target, flag)) return usage(notTaken(target, flag));
|
|
1312
|
+
if (rest[i + 1] === undefined) return usage(`${flag} needs a value`);
|
|
1313
|
+
i++;
|
|
1314
|
+
}
|
|
1315
|
+
console.log(commandUsage(target));
|
|
1316
|
+
return EXIT_OK;
|
|
1233
1317
|
}
|
|
1234
1318
|
|
|
1235
1319
|
|
|
@@ -1818,6 +1902,16 @@ function cmdPropose(args: string[]): number {
|
|
|
1818
1902
|
if (staged !== null) {
|
|
1819
1903
|
staged.commit();
|
|
1820
1904
|
if (target !== null) for (const line of configWriteLines(target, staged.changes)) console.error(line);
|
|
1905
|
+
const writtenPath = target?.path ?? written?.at;
|
|
1906
|
+
if (writtenPath !== undefined && P.manifest.assembly_config !== undefined) {
|
|
1907
|
+
try {
|
|
1908
|
+
const changes = assemblyConfigChanges(writtenPath, P.manifest);
|
|
1909
|
+
if (changes.length > 0) console.log(`note: ${assemblyChangeDetail(changes)}`);
|
|
1910
|
+
} catch (error) {
|
|
1911
|
+
if (!(error instanceof PartsError)) throw error;
|
|
1912
|
+
console.log('note: the written config is not ready for assemble; complete its assembly inputs and re-run assemble');
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1821
1915
|
}
|
|
1822
1916
|
console.log(`wrote proposal.json (${prop.bones.length} bone entries, ${Object.keys(prop.meshes).length} meshes) and render/landmarks.png (+_head) under ${out}`);
|
|
1823
1917
|
for (const n of prop.notes) console.log(n.startsWith('WARN PROPOSE_TORSO_ISLAND_LEFT_OUT:') ? n : `note: ${n}`);
|
|
@@ -2545,12 +2639,23 @@ function cmdDepthPrepare(args: string[]): number {
|
|
|
2545
2639
|
}
|
|
2546
2640
|
|
|
2547
2641
|
function cmdEditedPart(args: string[]): number {
|
|
2548
|
-
const f = flags(args, 'edited-part', ['--config', '--part', '--file', '--from'
|
|
2642
|
+
const f = flags(args, 'edited-part', ['--config', '--part', '--file', '--from']);
|
|
2549
2643
|
if (typeof f === 'string') return usage(f);
|
|
2644
|
+
if (!f.has('--editor') && !f.has('--producer')) return usage('edited-part needs --producer <json> or --editor <text>');
|
|
2550
2645
|
try {
|
|
2551
|
-
const { receipt, writes } = writeEditedPart({ config: f.get('--config')!, part: f.get('--part')!, file: f.get('--file')!, from: f.get('--from')!, editor: f.get('--editor')
|
|
2646
|
+
const { receipt, writes } = writeEditedPart({ config: f.get('--config')!, part: f.get('--part')!, file: f.get('--file')!, from: f.get('--from')!, editor: f.get('--editor'), producer: f.get('--producer'), rigConfig: f.get('--rig-config'), parts: f.get('--parts') });
|
|
2552
2647
|
for (const { target, changes } of writes) for (const line of configWriteLines(target, changes)) console.error(line);
|
|
2553
|
-
console.log(
|
|
2648
|
+
if (!f.has('--parts')) console.log('note: no assembly config check ran; pass --parts <parts.json> to check the assembled inputs');
|
|
2649
|
+
console.log(`edited-part: part ${JSON.stringify(receipt.part)} sha256=${receipt.sha256} from_sha256=${receipt.from_sha256} ${receipt.editor === undefined ? 'producer' : 'editor'}=${JSON.stringify(receipt.editor ?? receipt.producer)}`);
|
|
2650
|
+
return EXIT_OK;
|
|
2651
|
+
} catch (error) { return printRefusal(error); }
|
|
2652
|
+
}
|
|
2653
|
+
|
|
2654
|
+
function cmdExternalReceipt(args: string[]): number {
|
|
2655
|
+
const f = flags(args, 'external-receipt', []);
|
|
2656
|
+
if (typeof f === 'string') return usage(f);
|
|
2657
|
+
try {
|
|
2658
|
+
externalReceipt(f);
|
|
2554
2659
|
return EXIT_OK;
|
|
2555
2660
|
} catch (error) { return printRefusal(error); }
|
|
2556
2661
|
}
|
|
@@ -2587,10 +2692,14 @@ function main(argv: string[]): number | Promise<number> {
|
|
|
2587
2692
|
console.log(version());
|
|
2588
2693
|
return EXIT_OK;
|
|
2589
2694
|
}
|
|
2695
|
+
const helped = maybeCommandHelp(command, rest);
|
|
2696
|
+
if (helped !== null) return helped;
|
|
2590
2697
|
if (command === 'diff-components') return cmdDiffComponents(rest);
|
|
2698
|
+
if (command === 'diff-drafts') return cmdDiffDrafts(rest);
|
|
2591
2699
|
if (command === 'layers') return cmdLayers(rest);
|
|
2592
2700
|
if (command === 'depth-prepare') return cmdDepthPrepare(rest);
|
|
2593
2701
|
if (command === 'edited-part') return cmdEditedPart(rest);
|
|
2702
|
+
if (command === 'external-receipt') return cmdExternalReceipt(rest);
|
|
2594
2703
|
if (command === 'depth-bind') return cmdDepthBind(rest);
|
|
2595
2704
|
if (command === 'depth-apply') return cmdDepthApply(rest);
|
|
2596
2705
|
if (command === 'sheet') return cmdSheet(rest);
|