spine-parts 2.23.4 → 2.24.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/docs/AUTHORING.md CHANGED
@@ -8228,8 +8228,8 @@ Internal `SeamSupport.drawings` never enters check JSON. Named requirement
8228
8228
  | `SEAM_OVER_MOTION.worlds.*.rows` | `SEAM_OVER_MOTION.worlds.*.rows` | 'pair' | evidence | [want.a, want.b] | [check.ts:5288](../src/check.ts#L5288) |
8229
8229
  | `SEAM_OVER_RANGE.joints` | `SEAM_OVER_RANGE.joints` | 'part' | evidence; finding when poses.some(p => p.status === 'FAIL'); otherwise evidence | [j.part] | [check.ts:4335](../src/check.ts#L4335), [check.ts:4381](../src/check.ts#L4381) |
8230
8230
  | `SEAM_OVER_RANGE.joints[].poses` | `SEAM_OVER_RANGE.joints[].poses` | 'part' | finding when fail; otherwise evidence | [j.part] | [check.ts:4379](../src/check.ts#L4379) |
8231
- | `SETUP_MATCHES_PAINTING.regions` | `SETUP_MATCHES_PAINTING.regions` | 'rig' | finding when status === 'FAIL'; otherwise evidence | [] | [setuppainting.ts:174](../src/setuppainting.ts#L174) |
8232
- | `SETUP_MATCHES_PAINTING.regions[].slots` | `SETUP_MATCHES_PAINTING.regions[].slots` | part when the supplied mapping resolves a piece; otherwise rig | evidence | resolved piece for slot; otherwise [] | [setuppainting.ts:175](../src/setuppainting.ts#L175) |
8231
+ | `SETUP_MATCHES_PAINTING.regions` | `SETUP_MATCHES_PAINTING.regions` | 'rig' | finding when status === 'FAIL'; otherwise evidence | [] | [setuppainting.ts:175](../src/setuppainting.ts#L175) |
8232
+ | `SETUP_MATCHES_PAINTING.regions[].slots` | `SETUP_MATCHES_PAINTING.regions[].slots` | part when the supplied mapping resolves a piece; otherwise rig | evidence | resolved piece for slot; otherwise [] | [setuppainting.ts:176](../src/setuppainting.ts#L176) |
8233
8233
  | `STILL_REGIONS_DARK.*.crossing` | `STILL_REGIONS_DARK.*.crossing` | part when the supplied mapping resolves a piece; otherwise rig | finding | resolved piece for sl.name; otherwise [] | [check.ts:8910](../src/check.ts#L8910) |
8234
8234
  | `STILL_REGIONS_DARK.*.still_slots` | `STILL_REGIONS_DARK.*.still_slots` | part when the supplied mapping resolves a piece; otherwise rig | evidence; finding when r.max > tolerance; otherwise evidence | resolved piece for slot; otherwise [] | [check.ts:8896](../src/check.ts#L8896), [check.ts:8901](../src/check.ts#L8901) |
8235
8235
  | `STRESS_OFF_CHAIN.not_read` | `STRESS_OFF_CHAIN.not_read` | 'part' | evidence | [r.part] | [check.ts:3939](../src/check.ts#L3939) |
@@ -8292,3 +8292,14 @@ Here `sourceConfig` is the absolute original config filename and `raw` is its
8292
8292
  JSON-parsed object. Serialize that object at the destination after copying any
8293
8293
  referenced files; callers that copy files can instead set their new relative
8294
8294
  paths. The enumerator derives membership from the loader's own declarations.
8295
+
8296
+ `checkFileReferences(raw, configFile, requirements?)` and `CheckFileReference`
8297
+ are exported from the same `@rig-c/parts/src/config.ts` subpath (issue #1138).
8298
+ Pass the original config filename and the result of `readRequirements` from
8299
+ `@rig-c/parts/src/requirements.ts`. Rows contain `at` and `value`, with config
8300
+ references first and then `requirements.setup_painting.figure_mask.path` and
8301
+ `requirements.setup_painting.backdrop.path` when declared. Every value is
8302
+ resolved relative to the config directory, including images declared relative
8303
+ to the requirements file. Enumeration leaves both parsed inputs unchanged.
8304
+ Rig/parts-directory inputs (including seam PNGs) and separately supplied CLI
8305
+ inputs remain the caller's responsibility when relocating a check.
package/docs/STABILITY.md CHANGED
@@ -42,6 +42,20 @@ The loader's file-field declarations determine membership; no separate list is
42
42
  maintained. Resolve `value` against the source config directory when relocating.
43
43
  Existing deep package paths remain available.
44
44
 
45
+ The same subpath exports `checkFileReferences(raw: unknown, configFile: string,
46
+ requirements?: RequirementsFile): CheckFileReference[]` and the
47
+ `CheckFileReference` type (issue #1138). `requirements` is the value returned by
48
+ `readRequirements` from `@rig-c/parts/src/requirements.ts`. The result lists every
49
+ file `check` reads from a config and its requirements. Each row has `at: string`
50
+ (the dotted field) and `value: string` (the path relative to the config's
51
+ directory). Rows come in this order: the `configFileReferences` rows, then
52
+ `requirements.setup_painting.figure_mask.path` and
53
+ `requirements.setup_painting.backdrop.path` when they are declared. Setup images
54
+ resolve through the same code the check's readers use. Enumeration neither reads
55
+ files nor changes its inputs. Inputs that resolve from the rig or parts directory
56
+ (seam and `cut_material` part images, `cut_material_sources.json`) are not listed,
57
+ because the caller already carries that directory with the check.
58
+
45
59
  ## Commands and flags
46
60
 
47
61
  Exit codes are part of the interface: **0** the command did what it says, **1** it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spine-parts",
3
- "version": "2.23.4",
3
+ "version": "2.24.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": {
package/src/config.ts CHANGED
@@ -92,11 +92,12 @@ import type { DepthConfig } from './depthsheets.ts';
92
92
  * the field is a non-empty string.
93
93
  */
94
94
  import { existsSync, readFileSync, statSync } from 'node:fs';
95
- import { dirname, resolve } from 'node:path';
95
+ import { dirname, relative, resolve } from 'node:path';
96
96
  import { RIG_BONE_INHERIT, RIG_SKIN_CONSTRAINT_KEYS, type RigBoneInherit, type RigConstraint, type RigSkinConstraintKey, type RigStop } from '@rig-c/core/rig';
97
97
  import { pyRound } from './round.ts';
98
98
  import { motionSeamProblems, type MotionSeamDeclaration } from './motionseams.ts';
99
- import { REQUIREMENTS_SPEC } from './requirements.ts';
99
+ import { REQUIREMENTS_SPEC, type RequirementsFile } from './requirements.ts';
100
+ import { setupPaintingFilePath } from './setuppainting.ts';
100
101
  import { CLOTH_TARGETS, type ClothRecipes, RECIPE_STRENGTH, RIGC_DEFAULT_DAMPING, springStable } from './cloth.ts';
101
102
  import { GRID, MAX_SIDE } from './contour.ts';
102
103
  import { type Problem, refuseIfAny } from './errors.ts';
@@ -1478,6 +1479,31 @@ export function configFileReferences(raw: unknown): ConfigFileReference[] {
1478
1479
  return out;
1479
1480
  }
1480
1481
 
1482
+ /** A declared check input, with its field and path relative to the config directory. */
1483
+ export interface CheckFileReference {
1484
+ at: string;
1485
+ value: string;
1486
+ }
1487
+
1488
+ /**
1489
+ * Config references followed by requirements-relative setup images. Pass the
1490
+ * real reader's RequirementsFile so its path identifies the declaration's base.
1491
+ * Rig/parts-directory inputs and separately supplied CLI inputs are not config
1492
+ * references. This function neither reads files nor changes the parsed inputs.
1493
+ */
1494
+ export function checkFileReferences(raw: unknown, configFile: string, requirements?: RequirementsFile): CheckFileReference[] {
1495
+ const base = dirname(resolve(configFile));
1496
+ const out = configFileReferences(raw).map(({ at, value }) => ({ at, value: relative(base, resolve(base, value)) }));
1497
+ const setup = requirements?.setup_painting;
1498
+ for (const key of ['figure_mask', 'backdrop'] as const) {
1499
+ const declared = setup?.[key];
1500
+ if (declared !== undefined && requirements !== undefined) {
1501
+ out.push({ at: `requirements.setup_painting.${key}.path`, value: relative(base, setupPaintingFilePath(requirements.path, declared.path)) });
1502
+ }
1503
+ }
1504
+ return out;
1505
+ }
1506
+
1481
1507
 
1482
1508
  class Check {
1483
1509
  readonly problems: Problem[] = [];
@@ -1,11 +1,10 @@
1
1
  /** Declared setup plate: hash the same bytes that are decoded, before builds. */
2
2
  import { createHash } from 'node:crypto';
3
3
  import { readFileSync } from 'node:fs';
4
- import { dirname, resolve } from 'node:path';
5
4
  import { refuseIfAny } from './errors.ts';
6
5
  import { decodePngBytes } from './raster/png.ts';
7
6
  import type { Raster } from './raster/types.ts';
8
- import type { SetupPainting } from './setuppainting.ts';
7
+ import { setupPaintingFilePath, type SetupPainting } from './setuppainting.ts';
9
8
 
10
9
  export function readSetupBackdrop(declared: SetupPainting, requirements: string, source: Raster | null): Raster | undefined {
11
10
  const plate = declared.backdrop;
@@ -15,7 +14,7 @@ export function readSetupBackdrop(declared: SetupPainting, requirements: string,
15
14
  throw new Error('unreachable');
16
15
  };
17
16
  let bytes: Uint8Array;
18
- try { bytes = new Uint8Array(readFileSync(resolve(dirname(requirements), plate.path))); }
17
+ try { bytes = new Uint8Array(readFileSync(setupPaintingFilePath(requirements, plate.path))); }
19
18
  catch { return fail(`cannot read declared PNG "${plate.path}"; requires the authored opaque backdrop, not a guessed colour`); }
20
19
  const hash = createHash('sha256').update(bytes).digest('hex');
21
20
  if (hash !== plate.sha256) return fail(`PNG "${plate.path}" has sha256 ${hash}; requires declared ${plate.sha256}`);
@@ -1,11 +1,10 @@
1
1
  /** Independent declared alpha support, verified before any candidate build. */
2
2
  import { createHash } from 'node:crypto';
3
3
  import { readFileSync } from 'node:fs';
4
- import { dirname, resolve } from 'node:path';
5
4
  import { refuseIfAny } from './errors.ts';
6
5
  import { decodePngBytes } from './raster/png.ts';
7
6
  import type { Raster } from './raster/types.ts';
8
- import type { SetupPainting } from './setuppainting.ts';
7
+ import { setupPaintingFilePath, type SetupPainting } from './setuppainting.ts';
9
8
 
10
9
  export function readSetupFigureMask(declared: SetupPainting, requirements: string, source: Raster | null, width: number, height: number): Uint8Array | undefined {
11
10
  const mask = declared.figure_mask;
@@ -15,7 +14,7 @@ export function readSetupFigureMask(declared: SetupPainting, requirements: strin
15
14
  throw new Error('unreachable');
16
15
  };
17
16
  let bytes: Uint8Array;
18
- try { bytes = new Uint8Array(readFileSync(resolve(dirname(requirements), mask.path))); }
17
+ try { bytes = new Uint8Array(readFileSync(setupPaintingFilePath(requirements, mask.path))); }
19
18
  catch { return fail(`cannot read declared PNG "${mask.path}"; requires independent figure alpha support`); }
20
19
  const hash = createHash('sha256').update(bytes).digest('hex');
21
20
  if (hash !== mask.sha256) return fail(`PNG "${mask.path}" has sha256 ${hash}; requires declared ${mask.sha256}`);
@@ -1,3 +1,4 @@
1
+ import { dirname, resolve } from 'node:path';
1
2
  import { checkRow, checkSlotRow } from './checkrow.ts';
2
3
  /** Authored source-painting limits over actual renderer setup pixels (#887). */
3
4
  import { refuseIfAny, type Problem } from './errors.ts';
@@ -191,3 +192,8 @@ export function setupPaintingLines(line: SetupPaintingObservation): string[] {
191
192
  ...line.regions.flatMap(r => [`${SETUP_PAINTING_LINE}: region "${r.name}" ${r.status} — box [${r.box.join(', ')}], pixelcount ${r.pixel_count}, limit ${r.limit ?? 'undeclared (SKIP)'}, RGB tolerance ${line.rgb_tolerance}`,
192
193
  ...r.slots.map(s => `${SETUP_PAINTING_LINE}: slot "${s.slot}" region "${r.name}" — box [${s.box.join(', ')}], pixelcount ${s.pixel_count}; region total ${r.pixel_count}, limit ${r.limit ?? 'undeclared (SKIP)'}`)])];
193
194
  }
195
+
196
+ /** Resolve an authored setup image against the requirements file that names it. */
197
+ export function setupPaintingFilePath(requirements: string, path: string): string {
198
+ return resolve(dirname(requirements), path);
199
+ }