@mcptoolshop/style-dataset-lab 3.0.0 → 3.0.1

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +68 -15
  2. package/CODE_OF_CONDUCT.md +9 -0
  3. package/CONTRIBUTING.md +71 -0
  4. package/README.md +46 -1
  5. package/SECURITY.md +6 -5
  6. package/bin/sdlab.js +281 -62
  7. package/lib/adapters/diffusers-lora.js +7 -2
  8. package/lib/adapters/generic-image-caption.js +6 -1
  9. package/lib/args.js +200 -13
  10. package/lib/batch-compiler.js +7 -3
  11. package/lib/batch-runs.js +100 -31
  12. package/lib/batch-sheet-render.js +5 -2
  13. package/lib/brief-compiler.js +38 -11
  14. package/lib/card.js +11 -4
  15. package/lib/comfyui.js +100 -6
  16. package/lib/config.js +68 -3
  17. package/lib/deprecation.js +1 -1
  18. package/lib/eval-pack.js +94 -4
  19. package/lib/eval-runs.js +42 -3
  20. package/lib/export.js +144 -34
  21. package/lib/implementation-packs.js +15 -1
  22. package/lib/log.js +41 -4
  23. package/lib/paths.js +41 -3
  24. package/lib/refine-briefs.js +16 -9
  25. package/lib/reingest-selected.js +14 -3
  26. package/lib/reingest.js +15 -1
  27. package/lib/run-summary.js +3 -2
  28. package/lib/runtime-runs.js +59 -9
  29. package/lib/selections.js +54 -2
  30. package/lib/snapshot.js +100 -7
  31. package/lib/split.js +175 -17
  32. package/lib/training-manifests.js +17 -3
  33. package/lib/training-packages.js +28 -14
  34. package/package.json +8 -2
  35. package/scripts/batch-generate.js +16 -7
  36. package/scripts/batch-sheet.js +3 -3
  37. package/scripts/batch-show.js +3 -3
  38. package/scripts/brief-compile.js +8 -8
  39. package/scripts/brief-show.js +4 -3
  40. package/scripts/canon-bind.js +7 -9
  41. package/scripts/card.js +22 -25
  42. package/scripts/compare.js +38 -33
  43. package/scripts/critique-show.js +3 -3
  44. package/scripts/critique.js +3 -3
  45. package/scripts/curate.js +91 -46
  46. package/scripts/doctor.js +3 -5
  47. package/scripts/eligibility.js +17 -14
  48. package/scripts/eval-pack.js +13 -11
  49. package/scripts/eval-run.js +30 -29
  50. package/scripts/export.js +27 -31
  51. package/scripts/generate-controlnet.js +31 -17
  52. package/scripts/generate-identity.js +37 -20
  53. package/scripts/generate-ipadapter.js +22 -16
  54. package/scripts/generate.js +68 -13
  55. package/scripts/implementation-pack.js +19 -14
  56. package/scripts/init.js +115 -17
  57. package/scripts/painterly.js +8 -10
  58. package/scripts/refine.js +3 -3
  59. package/scripts/reingest-selected.js +3 -3
  60. package/scripts/reingest.js +33 -20
  61. package/scripts/run-generate.js +4 -4
  62. package/scripts/run-list.js +3 -3
  63. package/scripts/run-show.js +3 -3
  64. package/scripts/select.js +5 -4
  65. package/scripts/selection-show.js +3 -3
  66. package/scripts/snapshot.js +22 -24
  67. package/scripts/split.js +26 -31
  68. package/scripts/training-manifest.js +29 -24
  69. package/scripts/training-package.js +24 -20
  70. package/scripts/training-profile.js +13 -8
  71. package/scripts/workflow-list.js +2 -2
  72. package/scripts/workflow-show.js +4 -3
  73. package/templates/domains/architecture/inputs/prompts/example-wave.json +32 -0
  74. package/templates/domains/architecture/terminology.json +10 -8
  75. package/templates/domains/character-design/inputs/prompts/example-wave.json +32 -0
  76. package/templates/domains/character-design/project.json +4 -2
  77. package/templates/domains/creature-design/inputs/prompts/example-wave.json +32 -0
  78. package/templates/domains/creature-design/project.json +4 -2
  79. package/templates/domains/creature-design/terminology.json +1 -0
  80. package/templates/domains/game-art/inputs/prompts/example-wave.json +37 -0
  81. package/templates/domains/game-art/project.json +4 -2
  82. package/templates/domains/vehicle-mech/inputs/prompts/example-wave.json +37 -0
  83. package/templates/domains/vehicle-mech/project.json +4 -2
  84. package/scripts/bulk-curate-wave2-5.js +0 -138
  85. package/scripts/bulk-curate-waves11-18.js +0 -413
  86. package/scripts/curate-wave25.js +0 -209
  87. package/scripts/migrate-records.js +0 -141
  88. package/templates/inputs/prompts/example-wave.json +0 -27
package/CHANGELOG.md CHANGED
@@ -2,23 +2,57 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [2.6.0] - 2026-07-01
5
+ ## [3.0.1] - 2026-04-21
6
+
7
+ ### Fixed — Dogfood swarm health pass (Stage A: bugs & security)
8
+
9
+ - **Four Laws enforcement** (`lib/snapshot.js`, `lib/split.js`, `lib/export.js`):
10
+ - Export now inherits `snapshot.config_fingerprint` instead of recomputing; throws `FINGERPRINT_DRIFT` on mismatch (Law 4).
11
+ - Deterministic majority-lane per family with lexicographic tie-break, recorded in `audit.family_lane_decisions` (Law 3).
12
+ - Unassigned-family fallback now throws instead of silently landing in train.
13
+ - `existsSync` guards across snapshot/split/export/eval/training-manifest/training-package/impl-pack prevent ID collisions from overwriting frozen artifacts (Law 1).
14
+ - `included.jsonl` entries now carry `rules_checked`, `profile_id`, and `config_fingerprint` for explainable inclusion (Law 2).
15
+ - **Security hardening**: path-traversal rejection on `record.asset_path` and all user-supplied `--source`/`--guide`/`--anchor`/`--ref`/`--outputs`/`--prompt-file`/`--packet-file`/`--domain` flags; URL validation on ComfyUI endpoints; safe filename regex at selection boundaries.
16
+ - **CLI structured errors**: ~25 scripts converted from raw `throw new Error` to `inputError`/`runtimeError` so exit codes are correct (1 = user error, 2 = runtime).
17
+ - **Pipeline correctness**: brief fingerprint uses recursive `canonicalize()` — deterministic across nested key reordering; override precedence fixed (`||` → `??` so legit zero/empty overrides are preserved); negative-prompt dedup switched from substring to token-exact match; adapter output filenames keyed by `record.id` to prevent basename collisions silently dropping records.
18
+ - **Re-ingest**: now actually copies images to `outputs/candidates/` instead of writing records that point at missing files.
19
+ - **Curate ordering**: `curate.js` moves image first, then updates record; bulk-curate trio gained `--dry-run` and standard error handling.
20
+
21
+ ### Added — Dogfood swarm humanization pass (Stage B/C)
22
+
23
+ - **ComfyUI progress**: `submitAndWait` emits heartbeats every 15 s (queued → generating → completed); bails fast on `execution_error` or unknown status shapes instead of timing out silently.
24
+ - **Atomic manifest writes**: run/batch manifests use temp-file + rename; `checkpointRunManifest` saves progress after every slot so a crash no longer orphans GPU work.
25
+ - **`schema_version` enforcement**: every manifest (`snapshot`, `split`, `export`, `eval-pack`, `eval-run`, `training-manifest`, `training-package`, `implementation-pack`) now stamps `schema_version: '2.2.0'` with warn-on-mismatch loaders.
26
+ - **Export truthfulness**: tracks `expected`/`actual`/`failed` counts with per-record reasons and stderr warnings (no more silent-skip under `catch {}`).
27
+ - **Snapshot resilience**: malformed record JSON lands in `errors[]` instead of aborting the snapshot.
28
+ - **Split audit**: `deviation_from_target` per lane + `overall_deviation_score` in audit output.
29
+ - **Eval scorecards**: `sample_record_ids` up to 5 per failure bucket so operators can investigate.
30
+ - **CLI help**: `sdlab <cmd> --help` now works for 15 top commands via `HELP_TEXT` registry.
31
+ - **Did-you-mean**: hand-rolled Levenshtein suggestion for typo'd commands and flags.
32
+ - **`--project` fallback**: loud 2-line stderr warning when falling back to `star-freight` (silence with `SDLAB_QUIET_FALLBACK=1`).
33
+ - **Signal handling**: `SIGINT` (130), `SIGTERM` (143), `uncaughtException`, `unhandledRejection` handlers at `main()` so Ctrl+C surfaces a clean message.
34
+ - **ETA**: generate and batch-generate print ETA every 5 items with rolling averages.
35
+ - **`result()`/`success()` helpers**: artifact paths always print regardless of `--quiet`.
36
+ - **`sdlab init`**: scaffolded projects now get a `README.md` with quick commands, layout, and TODO sections.
37
+ - **Per-domain example waves**: all 5 domain templates ship `inputs/prompts/example-wave.json` with subjects matching their lane `id_patterns`.
38
+ - **Troubleshooting section**: README covers ComfyUI connection failure, missing weights, doctor errors, `--project` fallback, and bug reporting.
39
+ - **Install as primary CTA**: landing page leads with a copy-to-clipboard install command; `og:image`/`twitter:card` meta added via `SiteLayout`.
6
40
 
7
- ### Added
41
+ ### Changed
42
+
43
+ - Moved `HANDOFF.md`, `WAVE_PLAN.md`, `WAVE27A_SESSION_STATE.md` to `docs/internal/` with a README explaining the archive.
44
+ - `lib/deprecation.js`: `--game` deprecation target bumped from "v3.0" (lying, package is 3.0) to "v4.0".
45
+ - Handbook `reference.md` and `architecture.md` rewritten against the v3.0 CLI surface (`--project`, `projects/<name>/`); `--game` demoted to a Legacy section.
46
+ - One-off Star Freight wave-curate scripts excluded from the npm tarball via `files`-field negations (137 → 135 files, 179.3 → 173.9 kB).
47
+
48
+ ### Infrastructure
49
+
50
+ - **Test suite**: 0 → 98 tests across 12 files (`tests/lib-pipeline/`, `tests/lib-dataset/`, `tests/cli-scripts/`).
51
+ - **CI**: added `pull_request` trigger; `publish.yml` now runs `npm ci` + `npm run verify` + `npm test` + tag-vs-version guard before `npm publish`; `permissions: contents: read` and `persist-credentials: false` across all workflows; npm cache on every `setup-node`.
52
+ - **`package-lock.json`** regenerated from stale v2.2.1 to v3.0.1.
53
+ - **Governance**: added `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, `.github/ISSUE_TEMPLATE/{bug_report,feature_request}.md`, `.github/PULL_REQUEST_TEMPLATE.md`.
54
+ - **Dependabot**: groups restricted to `minor`/`patch` so breaking majors get individual PRs.
8
55
 
9
- - **Batch production modes (Phase 4D)** — coordinated multi-slot generation with reviewable sheet output
10
- - `sdlab batch generate --mode <id>` — execute a batch production mode (expression sheets, environment boards, etc.)
11
- - `sdlab batch show [batch-id]` — list all batches or show batch details
12
- - `sdlab batch sheet <batch-id>` — re-render batch sheet from saved manifest
13
- - `--dry-run` flag prepares batch directory and briefs without submitting to ComfyUI
14
- - **Batch modes** (`lib/batch-modes.js`) — load, validate, and list batch mode definitions from `workflows/batch-modes/`
15
- - **Batch compiler** (`lib/batch-compiler.js`) — expand one batch mode into multiple slot briefs with controlled per-slot deltas
16
- - **Batch runs** (`lib/batch-runs.js`) — batch directory creation (`batch_YYYY-MM-DD_NNN`), coordinated slot execution, manifest save/load
17
- - **Batch sheet renderer** (`lib/batch-sheet-render.js`) — HTML review surfaces with CSS grid layout, dark theme, zero dependencies
18
- - **4 starter batch modes** for Star Freight: expression-sheet, environment-board, silhouette-pack, continuity-variants
19
- - **JSON schemas** for batch mode definitions and batch manifests (`schemas/`)
20
- - Doctor validates batch mode definitions (batch_type, subject_mode, slot uniqueness, layout, workflow references)
21
- - Init scaffolds `workflows/batch-modes/` and `batches/` directories
22
56
  ## [3.0.0] - 2026-04-16
23
57
 
24
58
  ### Added
@@ -55,6 +89,25 @@ All notable changes to this project will be documented in this file.
55
89
  - **Handbook** updated: index shows production loop diagram, new [Production Loop](handbook/production-loop/) page with complete end-to-end walkthrough
56
90
  - **Package metadata** updated: description, keywords (`generation-workflow`, `batch-production`, `reintegration`), version badge
57
91
  - Version bumped to **v3.0.0** — the repo is now a full production workbench, not just a dataset preparation system
92
+
93
+ ## [2.6.0] - 2026-04-16
94
+
95
+ ### Added
96
+
97
+ - **Batch production modes (Phase 4D)** — coordinated multi-slot generation with reviewable sheet output
98
+ - `sdlab batch generate --mode <id>` — execute a batch production mode (expression sheets, environment boards, etc.)
99
+ - `sdlab batch show [batch-id]` — list all batches or show batch details
100
+ - `sdlab batch sheet <batch-id>` — re-render batch sheet from saved manifest
101
+ - `--dry-run` flag prepares batch directory and briefs without submitting to ComfyUI
102
+ - **Batch modes** (`lib/batch-modes.js`) — load, validate, and list batch mode definitions from `workflows/batch-modes/`
103
+ - **Batch compiler** (`lib/batch-compiler.js`) — expand one batch mode into multiple slot briefs with controlled per-slot deltas
104
+ - **Batch runs** (`lib/batch-runs.js`) — batch directory creation (`batch_YYYY-MM-DD_NNN`), coordinated slot execution, manifest save/load
105
+ - **Batch sheet renderer** (`lib/batch-sheet-render.js`) — HTML review surfaces with CSS grid layout, dark theme, zero dependencies
106
+ - **4 starter batch modes** for Star Freight: expression-sheet, environment-board, silhouette-pack, continuity-variants
107
+ - **JSON schemas** for batch mode definitions and batch manifests (`schemas/`)
108
+ - Doctor validates batch mode definitions (batch_type, subject_mode, slot uniqueness, layout, workflow references)
109
+ - Init scaffolds `workflows/batch-modes/` and `batches/` directories
110
+
58
111
  ## [2.5.0] - 2026-04-16
59
112
 
60
113
  ### Added
@@ -0,0 +1,9 @@
1
+ # Code of Conduct
2
+
3
+ This project follows the [Contributor Covenant v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
4
+
5
+ In short: be respectful, assume good faith, and focus discussion on the technical work. Harassment, personal attacks, and discrimination are not tolerated.
6
+
7
+ ## Reporting
8
+
9
+ Report concerns by emailing `64996768+mcp-tool-shop@users.noreply.github.com`. Reports are handled confidentially. The full Contributor Covenant enforcement ladder applies (correction → warning → temporary ban → permanent ban).
@@ -0,0 +1,71 @@
1
+ # Contributing to style-dataset-lab
2
+
3
+ Thanks for your interest. This repo is the canon-aware dataset pipeline for visual AI projects — it prioritizes determinism, auditability, and a single source of truth per project. Contributions that reinforce those properties are welcome.
4
+
5
+ ## Dev setup
6
+
7
+ ```bash
8
+ git clone https://github.com/mcp-tool-shop-org/style-dataset-lab
9
+ cd style-dataset-lab
10
+ npm install # zero runtime deps; installs dev-only tooling
11
+ npm test # runs the full node --test suite
12
+ npm run verify # sanity smoke: help output + project doctor on star-freight
13
+ ```
14
+
15
+ Requires Node.js 20+. ComfyUI is only needed for changes that touch the generation path (`lib/comfyui.js`, `scripts/generate.js`, `scripts/run-generate.js`). Doctrine, snapshot, split, export, and curation paths can all be exercised without a GPU — see the "Try it without ComfyUI" section of the README.
16
+
17
+ ## Coding style
18
+
19
+ - **ESM only.** Every file uses `import` / `export`. No CommonJS.
20
+ - **No TypeScript.** Plain JavaScript. Types live in JSDoc when they help.
21
+ - **Built-in test runner.** Tests use `node --test` from Node 20+ — no Jest, Vitest, Mocha.
22
+ - **No runtime dependencies.** `package.json` intentionally has zero `dependencies`. Dev-only tooling goes in `devDependencies`; a new runtime dep requires a very good reason.
23
+ - **Structured errors.** Errors follow the Structured Error Shape — `code`, `message`, `hint`, optional `cause`, optional `retryable`. See `lib/errors.js` (or equivalent) for helpers.
24
+ - **Canon is truth.** Never hand-edit generated artifacts (snapshots, splits, exports, runs, critiques, selections). Edit the upstream config or record and re-run.
25
+
26
+ ## Testing
27
+
28
+ Every change ships with tests. For bug fixes, add a regression test that would have failed before the fix.
29
+
30
+ ```bash
31
+ # Run the full suite
32
+ npm test
33
+
34
+ # Run a single file
35
+ node --test tests/path/to/file.test.js
36
+ ```
37
+
38
+ CI runs the same suite on Node 20 and Node 22 (see `.github/workflows/ci.yml`).
39
+
40
+ ## PR checklist
41
+
42
+ Before opening a PR:
43
+
44
+ - [ ] `npm test` passes locally
45
+ - [ ] `npm run verify` passes locally
46
+ - [ ] New features have test coverage
47
+ - [ ] `CHANGELOG.md` has an entry under `## [Unreleased]`
48
+ - [ ] If you touched `package.json`, you regenerated `package-lock.json` (`npm install --package-lock-only`)
49
+ - [ ] If you added or changed a config file schema, `schemas/` is updated too
50
+ - [ ] Commit message explains *why*, not just *what*
51
+
52
+ ## Shipcheck
53
+
54
+ Every release passes `npx @mcptoolshop/shipcheck audit` with all hard gates (A–D) green. Before we publish, we also re-read `SHIP_GATE.md` against the current repo state. If your change affects security posture, error handling, operator docs, or shipping hygiene, update `SHIP_GATE.md` in the same PR.
55
+
56
+ See the [shipcheck docs](https://github.com/mcp-tool-shop-org/shipcheck) for the full quality-gate definition.
57
+
58
+ ## Reporting bugs
59
+
60
+ File an issue using the bug-report template at https://github.com/mcp-tool-shop-org/style-dataset-lab/issues/new/choose. Minimum repro info:
61
+
62
+ - `sdlab --version`
63
+ - `node --version`
64
+ - ComfyUI version (if relevant)
65
+ - Project name and relevant config file excerpt
66
+ - `sdlab project doctor --project <name>` output
67
+ - The failing command and full structured error output
68
+
69
+ ## Code of conduct
70
+
71
+ Be decent. See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) — we use the Contributor Covenant.
package/README.md CHANGED
@@ -28,7 +28,8 @@ sdlab generate inputs/prompts/wave1.json --project my-project
28
28
  sdlab curate <id> approved "Strong silhouette, correct faction palette"
29
29
 
30
30
  # Bind approved work to constitution rules
31
- sdlab bind --project my-project
31
+ # (`sdlab bind` is a shorter alias for `canon-bind`)
32
+ sdlab canon-bind --project my-project
32
33
 
33
34
  # Freeze a versioned dataset
34
35
  sdlab snapshot create --project my-project
@@ -158,6 +159,50 @@ npm install -g @mcptoolshop/style-dataset-lab
158
159
 
159
160
  Requires Node.js 20+ and [ComfyUI](https://github.com/comfyanonymous/ComfyUI) on localhost:8188 for generation.
160
161
 
162
+ ### Try it without ComfyUI
163
+
164
+ You can explore the full non-generation surface — inspection, curation, snapshot, split, export — using the bundled Star Freight project without installing ComfyUI or downloading any SDXL weights.
165
+
166
+ ```bash
167
+ # Scaffold a fresh project (no ComfyUI needed)
168
+ sdlab init test --domain game-art
169
+
170
+ # Run the canonical health check (no ComfyUI needed)
171
+ sdlab project doctor --project test
172
+
173
+ # Dry-run a snapshot against the bundled Star Freight corpus
174
+ sdlab snapshot create --dry-run --project star-freight
175
+ ```
176
+
177
+ `sdlab project doctor` validates every project config (constitution, lanes, rubric, terminology) and reports eligibility without touching the GPU. Any command that mutates generated state accepts `--dry-run` to preview the effect first.
178
+
179
+ If you forget `--project`, the CLI falls back to the first project it finds under `projects/` and prints a warning — pass `--project` explicitly to silence it.
180
+
181
+ ## Troubleshooting
182
+
183
+ Common failure modes and fixes:
184
+
185
+ **`ECONNREFUSED 127.0.0.1:8188` on any `sdlab generate` / `sdlab run generate` / `sdlab batch generate`**
186
+ ComfyUI isn't running. Start ComfyUI (`python main.py --listen 127.0.0.1 --port 8188`) and confirm with `curl http://127.0.0.1:8188/system_stats`. To point at a different host/port, set `COMFY_URL=http://host:port`.
187
+
188
+ **`missing checkpoint` / `LoRA weight not found`**
189
+ Your workflow profile names a model file that isn't in ComfyUI's `models/checkpoints/` or `models/loras/` folder. Open `projects/<project>/workflows/profiles/<profile>.json`, locate the `checkpoint` or `lora` field, and either download the referenced weight or swap it for one you already have. Re-run `sdlab project doctor --project <project>` to confirm the fix.
190
+
191
+ **`sdlab project doctor` errors**
192
+ Doctor returns structured error codes. Common ones:
193
+ - `E_PROJECT_NOT_FOUND` — the project directory doesn't exist under `projects/`. Check spelling.
194
+ - `E_CONFIG_INVALID` — one of the five JSON config files failed schema validation. The `hint` field names the bad file and field.
195
+ - `E_RECORD_DRIFT` — a record's config fingerprint no longer matches its source. Re-curate or re-bind as the hint suggests.
196
+
197
+ **`No --project specified, falling back to <name>`**
198
+ A soft warning. Pass `--project <name>` explicitly to select the right project and silence the warning.
199
+
200
+ **Painterly / VRAM out-of-memory issues**
201
+ See `docs/internal/HANDOFF.md` for the painterly denoise tuning notes. In short: lower the denoise strength, reduce batch size, or switch to a smaller checkpoint in your workflow profile.
202
+
203
+ **Reporting bugs**
204
+ File an issue at https://github.com/mcp-tool-shop-org/style-dataset-lab/issues with your sdlab version (`sdlab --version`), Node version (`node -v`), the full command, and the structured error output. A bug-report template prefills the fields.
205
+
161
206
  ## Security
162
207
 
163
208
  Local-only. No telemetry, no analytics, no external requests. Images stay on your GPU and filesystem.
package/SECURITY.md CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  ## Supported Versions
4
4
 
5
- | Version | Supported |
6
- |---------|-----------|
7
- | 2.x | Yes |
8
- | 1.x | No |
9
- | 0.x | No |
5
+ | Version | Supported |
6
+ |---------|------------------------|
7
+ | 3.x | Yes |
8
+ | 2.x | Yes (transitional) |
9
+ | 1.x | No |
10
+ | 0.x | No |
10
11
 
11
12
  ## Threat Model
12
13