@litfamily/litcodex 1.0.28 → 1.0.29
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-Ko-KR.md +10 -10
- package/README.md +10 -10
- package/dist/cli.js +1 -1
- package/dist/config-migration/cli.js +11 -3
- package/dist/install/generated-skill-payload-hashes.d.ts +56 -28
- package/dist/install/generated-skill-payload-hashes.js +56 -28
- package/dist/install/index.js +1 -1
- package/dist/install/motion-runtime.d.ts +4 -1
- package/dist/install/motion-runtime.js +15 -4
- package/dist/install/office-runtime.d.ts +10 -11
- package/dist/install/office-runtime.js +8 -3
- package/dist/install/skill-catalog.d.ts +1 -1
- package/dist/install/skill-catalog.js +1 -0
- package/dist/postinstall.js +4 -2
- package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
- package/marketplace/plugins/litcodex/components/auto-update/dist/auto-update.d.ts +12 -0
- package/marketplace/plugins/litcodex/components/auto-update/dist/auto-update.js +31 -2
- package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
- package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
- package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/directive.md +2 -1
- package/marketplace/plugins/litcodex/components/lit-loop/directives/deep-interview.md +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-brainstorm.md +216 -0
- package/marketplace/plugins/litcodex/components/lit-loop/directives/litgoal.md +8 -1
- package/marketplace/plugins/litcodex/components/lit-loop/directives/review-work.md +12 -4
- package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.d.ts +6 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.js +16 -5
- package/marketplace/plugins/litcodex/components/lit-loop/dist/guards.d.ts +3 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/guards.js +5 -2
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.d.ts +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +26 -8
- package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.d.ts +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.js +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.d.ts +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.js +9 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-route.js +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-persistence.d.ts +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-persistence.js +8 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.d.ts +56 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.js +171 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/route-context.js +5 -2
- package/marketplace/plugins/litcodex/components/lit-loop/dist/route-heads.js +35 -15
- package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-mention-scope.js +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.d.ts +2 -2
- package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.js +15 -5
- package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.js +1 -0
- package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
- package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
- package/marketplace/plugins/litcodex/components/rules/dist/model-metadata.d.ts +16 -0
- package/marketplace/plugins/litcodex/components/rules/dist/model-metadata.js +37 -1
- package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
- package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
- package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
- package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
- package/marketplace/plugins/litcodex/skills/browser-drive/scripts/capability-probe.mjs +24 -4
- package/marketplace/plugins/litcodex/skills/deep-interview/SKILL.md +3 -1
- package/marketplace/plugins/litcodex/skills/lit-brainstorm/SKILL.md +271 -0
- package/marketplace/plugins/litcodex/skills/lit-brainstorm/agents/openai.yaml +6 -0
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/doctor.mjs +4 -3
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/export.mjs +6 -5
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/runtime-probes.mjs +25 -0
- package/marketplace/plugins/litcodex/skills/lit-docx/scripts/convert_md_to_pdf.py +31 -1
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/acs/template.tex +2 -0
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/elsevier/template.tex +2 -0
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/ieee/template.tex +2 -0
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/korean-generic/template.tex +2 -0
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/nature/template.tex +2 -0
- package/marketplace/plugins/litcodex/skills/lit-loop/SKILL.md +8 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/office-run.mjs +42 -10
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/SKILL.md +11 -9
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/agents/openai.yaml +3 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +4 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/constants.mjs +38 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-assets.mjs +113 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-capture.mjs +161 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-gate.mjs +327 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-image.mjs +136 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-init.js +43 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-sheet.mjs +69 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-treatment.mjs +102 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-worker.mjs +21 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover.mjs +352 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/driver.mjs +19 -1
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/fonts.mjs +11 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/look.mjs +128 -2
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/loop-kit.js +104 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/runtime.mjs +92 -18
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage.mjs +2 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/treatment.mjs +3 -2
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/webp.mjs +140 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/fonts/jetbrains-mono/JetBrainsMono-wght-latin.woff2 +0 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/fonts/jetbrains-mono/OFL.txt +93 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/card-scenes/expected.json +16 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/card-scenes/index.html +42 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/reset-sweep/expected.json +16 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/reset-sweep/index.html +27 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/still-glow/expected.json +17 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/still-glow/index.html +29 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/title-slam/expected.json +17 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/title-slam/index.html +44 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/orbit-loop/expected.json +67 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/orbit-loop/index.html +182 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/painted-light/expected.json +95 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/painted-light/index.html +231 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/weight-tide/expected.json +67 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/weight-tide/index.html +103 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/cover.md +389 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/quality-gate.md +4 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/runtime.md +7 -6
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/stage.md +3 -1
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/treatment.md +2 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/scripts/render.mjs +37 -5
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/scripts/runtime.mjs +1 -1
- package/marketplace/plugins/litcodex/skills/litgoal/SKILL.md +8 -3
- package/marketplace/plugins/litcodex/skills/lsp-setup/scripts/verify-lsp.ts +43 -7
- package/marketplace/plugins/litcodex/skills/review-work/SKILL.md +21 -4
- package/node_modules/@litcodex/lit-loop/CHANGELOG.md +7 -0
- package/node_modules/@litcodex/lit-loop/README.md +6 -0
- package/node_modules/@litcodex/lit-loop/directive.md +2 -1
- package/node_modules/@litcodex/lit-loop/directives/deep-interview.md +2 -0
- package/node_modules/@litcodex/lit-loop/directives/lit-brainstorm.md +216 -0
- package/node_modules/@litcodex/lit-loop/directives/litgoal.md +8 -1
- package/node_modules/@litcodex/lit-loop/directives/review-work.md +12 -4
- package/node_modules/@litcodex/lit-loop/dist/codex-hook.d.ts +6 -1
- package/node_modules/@litcodex/lit-loop/dist/codex-hook.js +16 -5
- package/node_modules/@litcodex/lit-loop/dist/guards.d.ts +3 -1
- package/node_modules/@litcodex/lit-loop/dist/guards.js +5 -2
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +2 -0
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +26 -8
- package/node_modules/@litcodex/lit-loop/dist/markers.d.ts +2 -0
- package/node_modules/@litcodex/lit-loop/dist/markers.js +2 -0
- package/node_modules/@litcodex/lit-loop/dist/modes.d.ts +1 -1
- package/node_modules/@litcodex/lit-loop/dist/modes.js +9 -1
- package/node_modules/@litcodex/lit-loop/dist/motion-route.js +2 -0
- package/node_modules/@litcodex/lit-loop/dist/plan-persistence.d.ts +2 -0
- package/node_modules/@litcodex/lit-loop/dist/plan-persistence.js +8 -0
- package/node_modules/@litcodex/lit-loop/dist/reentry.d.ts +56 -0
- package/node_modules/@litcodex/lit-loop/dist/reentry.js +171 -0
- package/node_modules/@litcodex/lit-loop/dist/route-context.js +5 -2
- package/node_modules/@litcodex/lit-loop/dist/route-heads.js +35 -15
- package/node_modules/@litcodex/lit-loop/dist/skill-mention-scope.js +2 -0
- package/node_modules/@litcodex/lit-loop/dist/trigger.d.ts +2 -2
- package/node_modules/@litcodex/lit-loop/dist/trigger.js +15 -5
- package/node_modules/@litcodex/lit-loop/dist/workflow-map.js +1 -0
- package/node_modules/@litcodex/lit-loop/package.json +1 -1
- package/node_modules/@litcodex/lit-loop/skills/browser-drive/scripts/capability-probe.mjs +24 -4
- package/node_modules/@litcodex/lit-loop/skills/deep-interview/SKILL.md +3 -1
- package/node_modules/@litcodex/lit-loop/skills/lit-brainstorm/SKILL.md +271 -0
- package/node_modules/@litcodex/lit-loop/skills/lit-loop/SKILL.md +8 -1
- package/node_modules/@litcodex/lit-loop/skills/litgoal/SKILL.md +8 -3
- package/node_modules/@litcodex/lit-loop/skills/review-work/SKILL.md +21 -4
- package/package.json +2 -2
- package/readme-assets/badge-version.svg +1 -1
- package/readme-assets/cover-motion-still.webp +0 -0
- package/readme-assets/cover-motion.webp +0 -0
- package/readme-assets/cover.webp +0 -0
- package/readme-assets/litfamily-machines.png +0 -0
- package/readme-assets/skills/lit-brainstorm.webp +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: lit-typographic-motion
|
|
3
|
-
description: Direct a film (MP4
|
|
3
|
+
description: Direct a film (MP4) or a seamless README cover loop: treatment first, stage page or typography engine, gated and viewed. Use for 영상, 모션그래픽, video, lyric video.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## #contract.activation
|
|
@@ -31,16 +31,18 @@ The request, optional audio and optional explicit style. Under `lit`, ask no que
|
|
|
31
31
|
| Treatment | Always first | Load only `references/treatment.md`; write `treatment.json` in the output dir |
|
|
32
32
|
| Stage | `path: stage` | `references/stage.md`: author the page (`index.html` in the output's `stage` folder), then `stage` |
|
|
33
33
|
| Type | `path: type` | `references/style-bibles.md`, `references/type-and-timing.md`, `references/scene-author.md`, then `film` |
|
|
34
|
+
| Cover | README, hero, banner or cover loop | `references/cover.md`; a `recipes/` page, then `cover` |
|
|
34
35
|
| Look | Every stills set | View the PNGs, then `look` (`references/quality-gate.md`) |
|
|
35
|
-
| Blocked | Exit 10-12, 14-
|
|
36
|
+
| Blocked | Exit 10-12, 14-22 | Name the state and its fix |
|
|
36
37
|
|
|
37
38
|
## #contract.procedure
|
|
38
39
|
|
|
39
40
|
1. `R` = absolute path of `scripts/render.mjs` beside this SKILL.md; `O` = the output dir.
|
|
40
41
|
2. Write `treatment.json` in `O`; the path reference loads only after `path` is set.
|
|
41
|
-
3. Round 1: `node "$R" stage --out O --stills-only --round 1` (type path: `film`). Open every PNG
|
|
42
|
-
4. Full render: `node "$R" stage --out O --round 2`. Give the call a timeout of at least 600 s; never shorten the film to save time. View the new stills, record `look --round 2`;
|
|
42
|
+
3. Round 1: `node "$R" stage --out O --stills-only --round 1` (type path: `film`). Open every PNG in the stills `manifest.json` with `view_image`; write answers; `node "$R" look --out O --round 1 --answers <file>` names the weakest beat and the change you made.
|
|
43
|
+
4. Full render: `node "$R" stage --out O --round 2`. Give the call a timeout of at least 600 s; never shorten the film to save time. View the new stills, record `look --round 2`; at most round 3.
|
|
43
44
|
5. Sound: the generated bed is the default; `sound --out O` previews it.
|
|
45
|
+
6. Cover: `node "$R" cover --out O --round N`; view sheet, poster and seam, then `look`.
|
|
44
46
|
|
|
45
47
|
Hand-encoded films are not the deliverable; every frame and track goes through `$R`.
|
|
46
48
|
|
|
@@ -51,8 +53,8 @@ Hand-encoded films are not the deliverable; every frame and track goes through `
|
|
|
51
53
|
"contract_schema_version": 1,
|
|
52
54
|
"output_schema": {
|
|
53
55
|
"film": "film.mp4, or withheld after a flash FAIL",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
+
"cover": "cover.webp, gated on the decoded file",
|
|
57
|
+
"stills": "stills/ with manifest.json",
|
|
56
58
|
"treatment": "treatment.json with every invention listed",
|
|
57
59
|
"report": "gate-report.txt and look.json",
|
|
58
60
|
"limitations": ["blocked state, failed rule, open look item or downgrade"]
|
|
@@ -62,12 +64,12 @@ Hand-encoded films are not the deliverable; every frame and track goes through `
|
|
|
62
64
|
|
|
63
65
|
## #contract.evidence
|
|
64
66
|
|
|
65
|
-
`node "$R" completion --out O` must print `complete` (or `DONE_UNVIEWED`, said plainly) before you call the
|
|
67
|
+
`node "$R" completion --out O` must print `complete` (or `DONE_UNVIEWED`, said plainly) before you call the work finished. Reply in plain words: the defaults chosen; every invention, generated sound and `label:` asset, labelled; what was checked; where the copy lives and the command that re-renders; any downgrade or open look item.
|
|
66
68
|
|
|
67
69
|
## #contract.hard_stops
|
|
68
70
|
|
|
69
|
-
Exit 10 no Chrome, 11 no WebGL2, 12 no ffmpeg
|
|
71
|
+
Exit 10 no Chrome, 11 no WebGL2, 12 no ffmpeg, 13 gate FAIL, 14 not pre-warmed, 15 font pin, 16 treatment, 17 stage contract, 18 nondeterministic, 19 network, 20 sound, 21 no cover encoder, 22 asset missing. For 14 or 15 run `litcodex motion-runtime install` outside the sandbox. A flash FAIL withholds the output. Details: `references/runtime.md`.
|
|
70
72
|
|
|
71
73
|
## #contract.anti_patterns
|
|
72
74
|
|
|
73
|
-
Never answer a failure by shortening
|
|
75
|
+
Never answer a failure by shortening, dropping a beat, layer or subject, muting, switching path, raising a gate number or drawing a stand-in asset; fix the cause or state the failure. No network, installs or third-party libraries in a render.
|
|
@@ -10,6 +10,9 @@ interface:
|
|
|
10
10
|
- "title sequence"
|
|
11
11
|
- "모션그래픽"
|
|
12
12
|
- "타이포그래피 영상"
|
|
13
|
+
- "README cover loop"
|
|
14
|
+
- "motion cover"
|
|
15
|
+
- "모션 커버"
|
|
13
16
|
default_prompt: "Use $litcodex:lit-typographic-motion to direct, render and verify a film."
|
|
14
17
|
policy:
|
|
15
18
|
allow_implicit_invocation: true
|
package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES
CHANGED
|
@@ -12,6 +12,10 @@ Fonts bundled in this skill (paths relative to the skill directory)
|
|
|
12
12
|
variable font; recipe and hashes in fonts/archivo/SHA256SUMS.
|
|
13
13
|
- VT323 Regular: fonts/vt323/VT323-Regular.ttf; licence fonts/vt323/OFL.txt (SIL Open Font
|
|
14
14
|
License 1.1, The VT323 Project Authors).
|
|
15
|
+
- JetBrains Mono, variable wght 100-800, latin subset: fonts/jetbrains-mono/JetBrainsMono-wght-latin.woff2;
|
|
16
|
+
licence fonts/jetbrains-mono/OFL.txt (SIL Open Font License 1.1, Copyright 2020 The JetBrains Mono
|
|
17
|
+
Project Authors; no Reserved Font Name). The unmodified file
|
|
18
|
+
files/jetbrains-mono-latin-wght-normal.woff2 of @fontsource-variable/jetbrains-mono 5.3.0.
|
|
15
19
|
- EMS Allure, EMS Felix, EMS Osmotron, EMS Readability, EMS Tech single-stroke SVG fonts:
|
|
16
20
|
fonts/stroke/*.svg; licence fonts/stroke/OFL.txt (SIL Open Font License 1.1) and
|
|
17
21
|
fonts/stroke/CREDITS (per-font creator, converter and base font).
|
|
@@ -243,6 +243,8 @@ export const EXIT = Object.freeze({
|
|
|
243
243
|
STAGE_NONDETERMINISTIC: 18,
|
|
244
244
|
STAGE_NETWORK_REQUEST: 19,
|
|
245
245
|
SOUND_INVALID: 20,
|
|
246
|
+
BLOCKED_NO_COVER_ENCODER: 21,
|
|
247
|
+
BLOCKED_ASSET_MISSING: 22,
|
|
246
248
|
USAGE: 2,
|
|
247
249
|
});
|
|
248
250
|
|
|
@@ -262,3 +264,39 @@ export const STAGE_FORMATS = Object.freeze({ "16:9": Object.freeze({ width: 1920
|
|
|
262
264
|
// Generated sound bed: the documented timbre palettes a treatment's sound.palette selects.
|
|
263
265
|
export const SOUND_PALETTES = Object.freeze(["air", "felt", "glass", "pulse"]);
|
|
264
266
|
export const MAX_ROUNDS = 3;
|
|
267
|
+
|
|
268
|
+
// Cover mode (references/cover.md): a silent, seamless README loop gated on the DECODED file.
|
|
269
|
+
// Calibrated on eight earlier painted covers (all pass FLOOR, all miss TARGET: a 1.9 s hold and a
|
|
270
|
+
// flash at the seam), four slide-like negatives (all fail FLOOR) and three pilot loops (all reach
|
|
271
|
+
// TARGET). A threshold moves only with a new calibration table, never to let a cover pass.
|
|
272
|
+
export const COVER = Object.freeze({
|
|
273
|
+
maxBytes: 3 * 1024 * 1024,
|
|
274
|
+
targetBytes: 2 * 1024 * 1024,
|
|
275
|
+
minSec: 6,
|
|
276
|
+
maxSec: 12,
|
|
277
|
+
gridMs: 50, // metrics sample a fixed grid of max(gridMs, shortest decoded frame)
|
|
278
|
+
stillEps: 0.0005, // a grid step whose mean |dY| (0..1, luma about 300 px wide) is below this is still
|
|
279
|
+
lumaWidth: 300,
|
|
280
|
+
floor: Object.freeze({ medianD: 0.0004, movingFrac: 0.45, stillSec: 2.0, seamLocal: 8 }),
|
|
281
|
+
target: Object.freeze({ medianD: 0.0015, movingFrac: 0.95, stillSec: 0.5, spike: 6, seamLow: 0.25, seamHigh: 2.0 }),
|
|
282
|
+
minContrast: 4.5,
|
|
283
|
+
// G6: the title's cap height at the width a README column shows a full-width image (about 830 px).
|
|
284
|
+
minCapPx: 24,
|
|
285
|
+
displayWidth: 830,
|
|
286
|
+
// ART: frame 0 shows the base art (SSIM of its check box against the source scaled into the box).
|
|
287
|
+
artSsim: 0.9,
|
|
288
|
+
artMinShare: 0.1,
|
|
289
|
+
seekFrames: 16, // re-rendered in a fresh page in a seeded shuffled order
|
|
290
|
+
seekLevels: 1, // the software rasterizer's own rounding when opacity and transform change together
|
|
291
|
+
windowPadSec: 0.5,
|
|
292
|
+
maxDefects: 3,
|
|
293
|
+
captureScale: 2,
|
|
294
|
+
sheetTiles: 12,
|
|
295
|
+
fps: Object.freeze([16, 20, 25]),
|
|
296
|
+
// The page is laid out at `page` CSS px, captured at captureScale and Lanczos-downsampled to `size`.
|
|
297
|
+
aspects: Object.freeze({
|
|
298
|
+
"2:1": Object.freeze({ page: Object.freeze([1200, 600]), size: Object.freeze([1000, 500]) }),
|
|
299
|
+
"3:2": Object.freeze({ page: Object.freeze([1200, 800]), size: Object.freeze([960, 640]) }),
|
|
300
|
+
}),
|
|
301
|
+
encode: Object.freeze({ q: 86, edgeQ: 97, edgeFrames: 15, method: 4 }),
|
|
302
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Cover assets. Every raster a cover page can load (base art, logo, wordmark, texture) is listed in
|
|
2
|
+
// `<out>/assets.json` with its path, role, source (user or generated) and SHA-256, and the renderer
|
|
3
|
+
// checks the list before the first capture. A listed file that is missing stops the run as
|
|
4
|
+
// BLOCKED_ASSET_MISSING (exit 22): the art is supplied or generated, never replaced by a drawn
|
|
5
|
+
// stand-in, and the painted-light recipe cannot run without its base art. After the render, frame 0
|
|
6
|
+
// must show that art: the SSIM of its check box in decoded frame 0 against the source scaled into
|
|
7
|
+
// the art's box.
|
|
8
|
+
import { spawnSync } from "node:child_process";
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
10
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
11
|
+
import { extname, join, sep } from "node:path";
|
|
12
|
+
import { COVER, EXIT, Exit } from "./constants.mjs";
|
|
13
|
+
import { readPngRgba } from "./cover-gate.mjs";
|
|
14
|
+
import { crop, lanczosResize, ssim } from "./cover-image.mjs";
|
|
15
|
+
import { which } from "./runtime.mjs";
|
|
16
|
+
import { rasterInfo } from "./stage.mjs";
|
|
17
|
+
|
|
18
|
+
export const ASSETS_FILE = "assets.json";
|
|
19
|
+
export const ASSET_ROLES = Object.freeze(["base-art", "logo", "wordmark", "texture"]);
|
|
20
|
+
const RASTERS = new Set([".png", ".jpg", ".jpeg", ".webp", ".gif"]);
|
|
21
|
+
|
|
22
|
+
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
23
|
+
const invalid = (field, message) => new Exit(EXIT.BLOCKED_TREATMENT_INVALID, `BLOCKED_TREATMENT_INVALID: assets.json ${field}: ${message}`);
|
|
24
|
+
const isBox = (b) => Array.isArray(b) && b.length === 4 && b.every((v) => typeof v === "number" && v >= 0 && v <= 1) && b[2] > 0 && b[3] > 0 && b[0] + b[2] <= 1 + 1e-9 && b[1] + b[3] <= 1 + 1e-9;
|
|
25
|
+
const inside = (inner, outer) => inner[0] >= outer[0] - 1e-9 && inner[1] >= outer[1] - 1e-9 && inner[0] + inner[2] <= outer[0] + outer[2] + 1e-9 && inner[1] + inner[3] <= outer[1] + outer[3] + 1e-9;
|
|
26
|
+
|
|
27
|
+
function entry(raw, i, coverDir) {
|
|
28
|
+
const at = `assets[${i}]`;
|
|
29
|
+
if (!raw || typeof raw !== "object") throw invalid(at, "must be an object");
|
|
30
|
+
if (typeof raw.path !== "string" || !raw.path.startsWith(`${coverDir}/`) || raw.path.split("/").includes("..")) throw invalid(`${at}.path`, `must be a path inside ${coverDir}/, relative to the output directory`);
|
|
31
|
+
if (!ASSET_ROLES.includes(raw.role)) throw invalid(`${at}.role`, `must be one of ${ASSET_ROLES.join(", ")}`);
|
|
32
|
+
if (!["user", "generated"].includes(raw.source)) throw invalid(`${at}.source`, "must be user (supplied) or generated (made for this cover)");
|
|
33
|
+
if (!/^[0-9a-f]{64}$/u.test(raw.sha256 ?? "")) throw invalid(`${at}.sha256`, "must be the file's SHA-256 (64 hex digits)");
|
|
34
|
+
if ("box" in raw && !isBox(raw.box)) throw invalid(`${at}.box`, "must be [x, y, w, h] as fractions of the cover, inside it");
|
|
35
|
+
if (raw.role === "base-art" && !raw.box) throw invalid(`${at}.box`, "base art needs the box it fills on the cover");
|
|
36
|
+
if ("checkBox" in raw) {
|
|
37
|
+
if (!isBox(raw.checkBox)) throw invalid(`${at}.checkBox`, "must be [x, y, w, h] as fractions of the cover, inside it");
|
|
38
|
+
if (!raw.box) throw invalid(`${at}.checkBox`, "needs the art's box");
|
|
39
|
+
if (!inside(raw.checkBox, raw.box)) throw invalid(`${at}.checkBox`, "must lie inside the art's box");
|
|
40
|
+
if (raw.checkBox[2] * raw.checkBox[3] < COVER.artMinShare * raw.box[2] * raw.box[3]) throw invalid(`${at}.checkBox`, `must cover at least ${COVER.artMinShare * 100} % of the art's box`);
|
|
41
|
+
}
|
|
42
|
+
return { path: raw.path, role: raw.role, source: raw.source, sha256: raw.sha256, box: raw.box ?? null, checkBox: raw.checkBox ?? null, title: raw.title === true };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Check `<outDir>/assets.json` against the cover folder before any capture. `files` is the static
|
|
47
|
+
* scan's file list (paths relative to the cover folder). Exit 22 for a missing listed file or a
|
|
48
|
+
* painted recipe with no base art; exit 17 for a raster the list does not name or a file whose hash
|
|
49
|
+
* changed; exit 16 for a malformed entry. Returns { assets } (empty when there is no list).
|
|
50
|
+
*/
|
|
51
|
+
export function checkAssets({ outDir, treatment, files, coverDir = "cover" }) {
|
|
52
|
+
const file = join(outDir, ASSETS_FILE);
|
|
53
|
+
let assets = [];
|
|
54
|
+
if (existsSync(file)) {
|
|
55
|
+
let doc;
|
|
56
|
+
try {
|
|
57
|
+
doc = JSON.parse(readFileSync(file, "utf8"));
|
|
58
|
+
} catch (error) {
|
|
59
|
+
throw invalid("", `not valid JSON (${error.message})`);
|
|
60
|
+
}
|
|
61
|
+
if (!doc || !Array.isArray(doc.assets)) throw invalid("assets", "must be an array of { path, role, source, sha256 }");
|
|
62
|
+
assets = doc.assets.map((raw, i) => entry(raw, i, coverDir));
|
|
63
|
+
for (const asset of assets) {
|
|
64
|
+
const path = join(outDir, asset.path);
|
|
65
|
+
if (!existsSync(path)) throw new Exit(EXIT.BLOCKED_ASSET_MISSING, `BLOCKED_ASSET_MISSING: ${asset.path} is listed in assets.json and missing; supply it or generate it, never draw a stand-in`);
|
|
66
|
+
if (sha256(readFileSync(path)) !== asset.sha256) throw new Exit(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${asset.path} no longer matches its sha256 in assets.json; list it again after changing it`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (treatment.recipe === "painted-light" && !assets.some((a) => a.role === "base-art")) throw new Exit(EXIT.BLOCKED_ASSET_MISSING, "BLOCKED_ASSET_MISSING: the painted-light recipe needs its base art listed in assets.json ({ path, role: base-art, source, sha256, box }); supply or generate the painting, never draw a stand-in");
|
|
70
|
+
const listed = new Set(assets.map((a) => a.path));
|
|
71
|
+
for (const f of files.filter((f) => RASTERS.has(extname(f.rel).toLowerCase()))) {
|
|
72
|
+
const rel = `${coverDir}/${f.rel.split(sep).join("/")}`;
|
|
73
|
+
if (!listed.has(rel)) throw new Exit(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${rel} is a raster the page can load but assets.json does not list; add it with its role, source and sha256`);
|
|
74
|
+
}
|
|
75
|
+
return { assets };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** A raster's pixels: PNG decoded here, any other format (or a PNG this decoder cannot read) through ffmpeg. */
|
|
79
|
+
export function readRaster(file, env = process.env) {
|
|
80
|
+
try {
|
|
81
|
+
return readPngRgba(file);
|
|
82
|
+
} catch {
|
|
83
|
+
const info = rasterInfo(readFileSync(file), extname(file).toLowerCase());
|
|
84
|
+
const ffmpeg = which("ffmpeg", env);
|
|
85
|
+
if (!info || !ffmpeg) return null;
|
|
86
|
+
const raw = spawnSync(ffmpeg, ["-v", "error", "-i", file, "-frames:v", "1", "-f", "rawvideo", "-pix_fmt", "rgba", "pipe:1"], { maxBuffer: 2 ** 30, env });
|
|
87
|
+
return raw.status === 0 ? { width: info.width, height: info.height, rgba: raw.stdout } : null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const toPx = (box, width, height) => box.map((v, k) => Math.round(v * (k % 2 ? height : width)));
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* ART: crop the check box (default: the art's whole box) out of decoded frame 0 and compare it with
|
|
95
|
+
* the same region of the source scaled into the art's box. Boxes are fractions of the cover.
|
|
96
|
+
*/
|
|
97
|
+
export function artCheck({ frame0, width, height, art, box, checkBox = null }) {
|
|
98
|
+
const [bx, by, bw, bh] = toPx(box, width, height);
|
|
99
|
+
const scaled = lanczosResize(art.rgba, art.width, art.height, bw, bh);
|
|
100
|
+
const [cx, cy, cw, ch] = toPx(checkBox ?? box, width, height);
|
|
101
|
+
const value = ssim(crop(frame0, width, [cx, cy, cw, ch]), crop(scaled, bw, [cx - bx, cy - by, cw, ch]), cw, ch);
|
|
102
|
+
return { ssim: value, pass: value >= COVER.artSsim, box: [bx, by, bw, bh], checked: [cx, cy, cw, ch] };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The reply labels a generated asset needs; `completion` prints them for the finished cover. */
|
|
106
|
+
export function generatedLabels(outDir) {
|
|
107
|
+
try {
|
|
108
|
+
const doc = JSON.parse(readFileSync(join(outDir, ASSETS_FILE), "utf8"));
|
|
109
|
+
return (doc.assets ?? []).filter((a) => a?.source === "generated" && typeof a.path === "string").map((a) => `the ${String(a.role ?? "asset").replace("-", " ")} ${a.path} is generated, not supplied: label it as generated in the reply`);
|
|
110
|
+
} catch {
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// Cover capture, the browser side. One headless Chrome per pass on the stage path's software rung, its
|
|
2
|
+
// viewport the cover page's CSS size at device scale 2, the cover folder served on the synthetic
|
|
3
|
+
// stage origin (kit, loop kit, faces, nothing else), and the cover init script injected before any page
|
|
4
|
+
// script. The renderer SEEKS: it calls window.renderFrame(t, { mask }) for any t in [0, 1) in any
|
|
5
|
+
// order, captures the surface, and a worker pool downsamples each capture to the cover size. The
|
|
6
|
+
// master, the replay (G0) and the seek-order check each open their own CoverSession.
|
|
7
|
+
import { readFileSync, rmSync } from "node:fs";
|
|
8
|
+
import { availableParallelism } from "node:os";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { Worker } from "node:worker_threads";
|
|
11
|
+
import { EXIT, Exit, STAGE_ORIGIN } from "./constants.mjs";
|
|
12
|
+
import { launchCover } from "./driver.mjs";
|
|
13
|
+
import { SKILL_ROOT } from "./fonts.mjs";
|
|
14
|
+
import { firstLine } from "./runtime.mjs";
|
|
15
|
+
import { stageRouter } from "./stage.mjs";
|
|
16
|
+
|
|
17
|
+
const COVER_INIT = () => readFileSync(join(SKILL_ROOT, "engine", "cover-init.js"), "utf8");
|
|
18
|
+
const pause = (ms) => new Promise((done) => setTimeout(done, ms));
|
|
19
|
+
|
|
20
|
+
export class CoverSession {
|
|
21
|
+
/** Open the cover page and wait until it sets window.ready and defines window.renderFrame. */
|
|
22
|
+
static async open({ runtime, scan, fonts, width, height, scale, profileDir, env = process.env }) {
|
|
23
|
+
const { context, page } = await launchCover({ runtime, width, height, scale, profileDir, env });
|
|
24
|
+
const session = new CoverSession({ context, page, width, height, scale, profileDir });
|
|
25
|
+
try {
|
|
26
|
+
await context.route("**/*", stageRouter({ root: scan.root, fonts, record: session.record }));
|
|
27
|
+
await context.addInitScript({ content: COVER_INIT() });
|
|
28
|
+
page.on("pageerror", (error) => session.record.pageErrors.push(firstLine(error.message)));
|
|
29
|
+
await page.goto(`${STAGE_ORIGIN}/index.html`, { waitUntil: "load", timeout: 60000 });
|
|
30
|
+
session.cdp = await context.newCDPSession(page);
|
|
31
|
+
await session.#waitReady();
|
|
32
|
+
return session;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
await session.close();
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
constructor({ context, page, width, height, scale, profileDir }) {
|
|
40
|
+
Object.assign(this, { context, page, width, height, scale, profileDir });
|
|
41
|
+
this.record = { blocked: [], rejected: [], missing: [], pageErrors: [] };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async #waitReady() {
|
|
45
|
+
const deadline = Date.now() + 60000;
|
|
46
|
+
for (;;) {
|
|
47
|
+
const state = await this.page.evaluate(() => [document.readyState, window.ready === true, typeof window.renderFrame]).catch(() => ["loading", false, "undefined"]);
|
|
48
|
+
if (state[0] === "complete" && state[1]) {
|
|
49
|
+
await this.check("while loading");
|
|
50
|
+
if (state[2] !== "function") throw new Exit(EXIT.STAGE_CONTRACT_ERROR, "STAGE_CONTRACT_ERROR: the cover page set window.ready but defines no window.renderFrame(t)");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// A page that threw before it was ready never recovers; say why now, not after the 60 s wait.
|
|
54
|
+
if (this.record.pageErrors.length) {
|
|
55
|
+
await this.check("while loading");
|
|
56
|
+
throw new Exit(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: the cover page threw before it was ready; first page error: ${this.record.pageErrors[0]}`);
|
|
57
|
+
}
|
|
58
|
+
if (Date.now() > deadline) {
|
|
59
|
+
await this.check("while loading");
|
|
60
|
+
const why = this.record.pageErrors[0] ? `; first page error: ${this.record.pageErrors[0]}` : state[0] === "complete" ? "; it never set window.ready = true" : "";
|
|
61
|
+
throw new Exit(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: the cover page was not ready within 60 s${why}`);
|
|
62
|
+
}
|
|
63
|
+
await pause(50);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Raise the named exit for anything the page did that a cover page may not do. */
|
|
68
|
+
async check(context) {
|
|
69
|
+
if (this.record.blocked.length) throw new Exit(EXIT.STAGE_NETWORK_REQUEST, `STAGE_NETWORK_REQUEST: the cover page requested ${this.record.blocked[0].slice(0, 160)}; every asset is a local file in cover/`);
|
|
70
|
+
if (this.record.rejected.length) throw new Exit(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: the cover page requested ${this.record.rejected[0]}, which is outside the cover folder or not an allowed asset`);
|
|
71
|
+
const calls = await this.page.evaluate(() => (window.__litCoverCalls ? window.__litCoverCalls() : [])).catch(() => []);
|
|
72
|
+
if (calls.length) throw new Exit(EXIT.STAGE_NONDETERMINISTIC, `STAGE_NONDETERMINISTIC: the cover page called ${calls.join(", ")} ${context}; a cover frame is a function of t alone (LitLoop.rng(seed) for layout)`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Draw loop time t (or its title mask) and let fonts settle. */
|
|
76
|
+
async frame(t, { mask = false } = {}) {
|
|
77
|
+
try {
|
|
78
|
+
await this.page.evaluate(
|
|
79
|
+
async ({ time, asMask }) => {
|
|
80
|
+
await window.renderFrame(time, { mask: asMask });
|
|
81
|
+
await document.fonts.ready;
|
|
82
|
+
},
|
|
83
|
+
{ time: t, asMask: mask },
|
|
84
|
+
);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
await this.check(`at t = ${t.toFixed(4)}`);
|
|
87
|
+
throw new Exit(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: renderFrame(${t.toFixed(4)}${mask ? ", { mask: true }" : ""}) threw: ${firstLine(error.message)}`);
|
|
88
|
+
}
|
|
89
|
+
await this.check(`at t = ${t.toFixed(4)}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The surface as composited: a PNG of (width x scale) by (height x scale). */
|
|
93
|
+
async capture() {
|
|
94
|
+
const shot = await this.cdp.send("Page.captureScreenshot", { format: "png", optimizeForSpeed: true, captureBeyondViewport: false, fromSurface: true, clip: { x: 0, y: 0, width: this.width, height: this.height, scale: 1 } });
|
|
95
|
+
return Buffer.from(shot.data, "base64");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async close() {
|
|
99
|
+
await this.context?.close().catch(() => {});
|
|
100
|
+
rmSync(this.profileDir, { recursive: true, force: true });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Worker threads that downsample and write captures; each job resolves with its PNG's hash. */
|
|
105
|
+
export class CoverPool {
|
|
106
|
+
constructor(size = Math.max(2, Math.min(6, availableParallelism() - 2))) {
|
|
107
|
+
this.workers = Array.from({ length: size }, () => new Worker(new URL("./cover-worker.mjs", import.meta.url)));
|
|
108
|
+
this.next = 0;
|
|
109
|
+
this.id = 0;
|
|
110
|
+
this.waiting = new Map();
|
|
111
|
+
for (const worker of this.workers) {
|
|
112
|
+
worker.on("message", (message) => {
|
|
113
|
+
const waiter = this.waiting.get(message.id);
|
|
114
|
+
this.waiting.delete(message.id);
|
|
115
|
+
if (message.error) waiter.reject(new Error(message.error));
|
|
116
|
+
else waiter.resolve(message);
|
|
117
|
+
});
|
|
118
|
+
worker.on("error", (error) => {
|
|
119
|
+
for (const waiter of this.waiting.values()) waiter.reject(error);
|
|
120
|
+
this.waiting.clear();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
downsample(png, width, height, file) {
|
|
126
|
+
const id = this.id++;
|
|
127
|
+
const worker = this.workers[this.next++ % this.workers.length];
|
|
128
|
+
const copy = png.buffer.slice(png.byteOffset, png.byteOffset + png.byteLength);
|
|
129
|
+
return new Promise((resolve, reject) => {
|
|
130
|
+
this.waiting.set(id, { resolve, reject });
|
|
131
|
+
worker.postMessage({ id, png: copy, width, height, file }, [copy]);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async close() {
|
|
136
|
+
await Promise.all(this.workers.map((worker) => worker.terminate()));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Capture `times` ([index, t] pairs, in the order given) into `dir` as `<prefix>NNNN.png` at the
|
|
142
|
+
* cover size. Returns Map index -> SHA-256 of the written PNG.
|
|
143
|
+
*/
|
|
144
|
+
export async function capturePass({ session, pool, times, dir, prefix = "f", mask = false, size: [width, height] }) {
|
|
145
|
+
const hashes = new Map();
|
|
146
|
+
const pending = [];
|
|
147
|
+
const expected = `${session.width * session.scale}x${session.height * session.scale}`;
|
|
148
|
+
for (const [index, t] of times) {
|
|
149
|
+
await session.frame(t, { mask });
|
|
150
|
+
const png = await session.capture();
|
|
151
|
+
const job = pool.downsample(png, width, height, join(dir, `${prefix}${String(index).padStart(4, "0")}.png`)).then((done) => {
|
|
152
|
+
if (done.captured !== expected) throw new Exit(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: captured ${done.captured}, expected ${expected} (the page must not resize its viewport)`);
|
|
153
|
+
hashes.set(index, done.sha256);
|
|
154
|
+
});
|
|
155
|
+
job.catch(() => {});
|
|
156
|
+
pending.push(job);
|
|
157
|
+
while (pending.length > 8) await pending.shift();
|
|
158
|
+
}
|
|
159
|
+
await Promise.all(pending);
|
|
160
|
+
return hashes;
|
|
161
|
+
}
|