@litfamily/litcodex 1.0.30 → 1.0.31

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 (376) hide show
  1. package/README-Ko-KR.md +11 -11
  2. package/README.md +11 -11
  3. package/dist/install/generated-skill-payload-hashes.d.ts +188 -82
  4. package/dist/install/generated-skill-payload-hashes.js +188 -82
  5. package/dist/install/skill-catalog.d.ts +1 -1
  6. package/dist/install/skill-catalog.js +12 -1
  7. package/dist/install/skill-resource-hashes.d.ts +1 -1
  8. package/dist/install/skill-resource-hashes.js +1 -1
  9. package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
  10. package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
  11. package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
  12. package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
  13. package/marketplace/plugins/litcodex/components/lit-loop/directive.md +10 -4
  14. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-adhd.md +191 -0
  15. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-handoff.md +2 -0
  16. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-hijack.md +219 -0
  17. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-recap.md +2 -0
  18. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-schematic.md +199 -0
  19. package/marketplace/plugins/litcodex/components/lit-loop/directives/litwork.md +2 -1
  20. package/marketplace/plugins/litcodex/components/lit-loop/dist/adhd-suggest.d.ts +10 -0
  21. package/marketplace/plugins/litcodex/components/lit-loop/dist/adhd-suggest.js +67 -0
  22. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-html.d.ts +1 -1
  23. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-html.js +128 -8
  24. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-looks.d.ts +19 -0
  25. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-looks.js +58 -0
  26. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.d.ts +27 -0
  27. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.js +94 -7
  28. package/marketplace/plugins/litcodex/components/lit-loop/dist/cli.js +13 -3
  29. package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.d.ts +2 -0
  30. package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.js +8 -9
  31. package/marketplace/plugins/litcodex/components/lit-loop/dist/control-chars.d.ts +5 -0
  32. package/marketplace/plugins/litcodex/components/lit-loop/dist/control-chars.js +23 -0
  33. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.d.ts +8 -0
  34. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +118 -11
  35. package/marketplace/plugins/litcodex/components/lit-loop/dist/hud.d.ts +1 -1
  36. package/marketplace/plugins/litcodex/components/lit-loop/dist/hud.js +29 -13
  37. package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-events.d.ts +13 -0
  38. package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-events.js +85 -0
  39. package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-state.d.ts +55 -0
  40. package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-state.js +227 -0
  41. package/marketplace/plugins/litcodex/components/lit-loop/dist/live-step.d.ts +5 -1
  42. package/marketplace/plugins/litcodex/components/lit-loop/dist/live-step.js +17 -1
  43. package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.d.ts +6 -0
  44. package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.js +6 -0
  45. package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.d.ts +1 -1
  46. package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.js +25 -1
  47. package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-gate.d.ts +79 -0
  48. package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-gate.js +310 -0
  49. package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-route.js +5 -1
  50. package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-persistence.js +10 -0
  51. package/marketplace/plugins/litcodex/components/lit-loop/dist/redaction.js +18 -0
  52. package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.d.ts +15 -0
  53. package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.js +46 -9
  54. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-cli.d.ts +10 -0
  55. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-cli.js +88 -0
  56. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-go.d.ts +20 -0
  57. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-go.js +84 -0
  58. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-look.d.ts +6 -0
  59. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-look.js +41 -0
  60. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-redact.d.ts +3 -0
  61. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-redact.js +40 -0
  62. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-rollout.d.ts +48 -0
  63. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-rollout.js +292 -0
  64. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind.d.ts +162 -0
  65. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind.js +773 -0
  66. package/marketplace/plugins/litcodex/components/lit-loop/dist/route-heads.js +44 -2
  67. package/marketplace/plugins/litcodex/components/lit-loop/dist/run-panel.js +1 -0
  68. package/marketplace/plugins/litcodex/components/lit-loop/dist/schematic-route.d.ts +6 -0
  69. package/marketplace/plugins/litcodex/components/lit-loop/dist/schematic-route.js +35 -0
  70. package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-card.d.ts +3 -0
  71. package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-card.js +15 -5
  72. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-mention-scope.js +6 -0
  73. package/marketplace/plugins/litcodex/components/lit-loop/dist/stack-hook.d.ts +8 -0
  74. package/marketplace/plugins/litcodex/components/lit-loop/dist/stack-hook.js +57 -0
  75. package/marketplace/plugins/litcodex/components/lit-loop/dist/statusline.js +8 -3
  76. package/marketplace/plugins/litcodex/components/lit-loop/dist/threads.d.ts +50 -0
  77. package/marketplace/plugins/litcodex/components/lit-loop/dist/threads.js +178 -0
  78. package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.d.ts +1 -1
  79. package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.js +29 -5
  80. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.d.ts +10 -0
  81. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.js +11 -1
  82. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-stack.d.ts +132 -0
  83. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-stack.js +488 -0
  84. package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
  85. package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
  86. package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
  87. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/codex-hook.d.ts +6 -0
  88. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/codex-hook.js +65 -0
  89. package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
  90. package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
  91. package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
  92. package/marketplace/plugins/litcodex/hooks/hooks.json +24 -0
  93. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/SKILL.md +6 -0
  94. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/components.css +414 -0
  95. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/fonts.json +22 -0
  96. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/layouts/landing.html +164 -0
  97. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/layouts/settings.html +114 -0
  98. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/layouts/workspace.html +115 -0
  99. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/computational-brutalism.json +227 -0
  100. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/field-notes.json +205 -0
  101. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/graphite.json +200 -0
  102. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/meadow.json +199 -0
  103. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/neo-brutalism.json +222 -0
  104. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/ui.js +228 -0
  105. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/brand-and-imagery.md +1 -1
  106. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/complete-contract.md +1 -0
  107. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/craft-floor.md +2 -2
  108. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/default-editorial-pixel.json +15 -8
  109. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/design-choice.md +19 -0
  110. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/house-styles.md +235 -0
  111. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/motion-guide.md +2 -2
  112. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/probe-and-review.md +6 -0
  113. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/production-interview.md +2 -0
  114. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/slop-register.md +4 -4
  115. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/design-lock.mjs +400 -0
  116. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/lock-probe.mjs +196 -0
  117. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/page-probe.mjs +22 -4
  118. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/pixel-art.mjs +60 -0
  119. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/probe.mjs +59 -13
  120. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/rule-data.mjs +38 -4
  121. package/marketplace/plugins/litcodex/skills/lit-adhd/SKILL.md +181 -0
  122. package/marketplace/plugins/litcodex/skills/lit-adhd/agents/openai.yaml +6 -0
  123. package/marketplace/plugins/litcodex/skills/lit-adhd/references/card-examples.md +147 -0
  124. package/marketplace/plugins/litcodex/skills/lit-adhd/references/status-taxonomy.md +37 -0
  125. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/SKILL.md +18 -7
  126. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/style-guide.md +20 -11
  127. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-architecture.md +3 -3
  128. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-dependency.md +1 -1
  129. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-swimlane.md +1 -1
  130. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-tree-block-decomposition.md +1 -1
  131. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-tree.md +3 -3
  132. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-wardley.md +1 -1
  133. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/verifier-guide.md +1 -0
  134. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/diagram-craft-rules.mjs +1 -2
  135. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/visual-quality.mjs +1 -2
  136. package/marketplace/plugins/litcodex/skills/lit-docx/SKILL.md +12 -3
  137. package/marketplace/plugins/litcodex/skills/lit-docx/references/direction-step.md +6 -3
  138. package/marketplace/plugins/litcodex/skills/lit-hijack/SKILL.md +449 -0
  139. package/marketplace/plugins/litcodex/skills/lit-hijack/agents/openai.yaml +6 -0
  140. package/marketplace/plugins/litcodex/skills/lit-hijack/references/capture-and-provenance.md +100 -0
  141. package/marketplace/plugins/litcodex/skills/lit-hijack/references/clean-room-build.md +111 -0
  142. package/marketplace/plugins/litcodex/skills/lit-hijack/references/distil-and-licence.md +102 -0
  143. package/marketplace/plugins/litcodex/skills/lit-hijack/references/gap-and-port-design.md +125 -0
  144. package/marketplace/plugins/litcodex/skills/lit-hijack/references/parity-and-report.md +108 -0
  145. package/marketplace/plugins/litcodex/skills/lit-hijack/scripts/hijack.mjs +1050 -0
  146. package/marketplace/plugins/litcodex/skills/lit-loop/SKILL.md +13 -4
  147. package/marketplace/plugins/litcodex/skills/lit-plan/SKILL.md +6 -0
  148. package/marketplace/plugins/litcodex/skills/lit-pptx/NOTICE +1 -0
  149. package/marketplace/plugins/litcodex/skills/lit-pptx/SKILL.md +35 -8
  150. package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Bold.ttf +0 -0
  151. package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf +0 -0
  152. package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/OFL.txt +93 -0
  153. package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/SOURCE.md +21 -0
  154. package/marketplace/plugins/litcodex/skills/lit-pptx/references/anti-slop-checklist.md +5 -2
  155. package/marketplace/plugins/litcodex/skills/lit-pptx/references/authoring-guide.md +3 -4
  156. package/marketplace/plugins/litcodex/skills/lit-pptx/references/density-and-fill.md +20 -6
  157. package/marketplace/plugins/litcodex/skills/lit-pptx/references/direction-step.md +26 -8
  158. package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/14-engineering-review-computational-brutalism-ko.md +173 -0
  159. package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/15-launch-pitch-neo-brutalism-ko.md +154 -0
  160. package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/16-design-lecture-bauhaus-ko.md +139 -0
  161. package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/17-community-programme-riso-ko.md +158 -0
  162. package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/18-public-data-briefing-newsroom-ko.md +179 -0
  163. package/marketplace/plugins/litcodex/skills/lit-pptx/references/layout-families.md +42 -27
  164. package/marketplace/plugins/litcodex/skills/lit-pptx/references/title-treatments.md +31 -27
  165. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/bauhaus.md +136 -0
  166. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/chalk.md +1 -1
  167. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/computational-brutalism.md +145 -0
  168. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/neo-brutalism.md +155 -0
  169. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/newsroom.md +141 -0
  170. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/riso.md +133 -0
  171. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/signal.md +1 -1
  172. package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/studio.md +1 -1
  173. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/compile-deck.js +1 -1
  174. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/craft_extras.py +136 -94
  175. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/embed_fonts.py +13 -1
  176. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/grid-resolver.js +101 -110
  177. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/layout-resolver.js +9 -15
  178. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/render-pack.js +386 -579
  179. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/slide-grid.js +104 -0
  180. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/template-registry.js +57 -6
  181. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/office-run.mjs +2 -1
  182. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/qa_deck.py +7 -13
  183. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/render_pages.py +124 -0
  184. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +1 -1
  185. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/bauhaus/pack.yaml +98 -0
  186. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +1 -1
  187. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/computational-brutalism/pack.yaml +100 -0
  188. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +1 -1
  189. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +1 -1
  190. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/neo-brutalism/pack.yaml +107 -0
  191. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/newsroom/pack.yaml +99 -0
  192. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/night/pack.yaml +1 -1
  193. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/paper/pack.yaml +1 -1
  194. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/riso/pack.yaml +99 -0
  195. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/signal/pack.yaml +2 -2
  196. package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/studio/pack.yaml +1 -1
  197. package/marketplace/plugins/litcodex/skills/lit-recap/SKILL.md +2 -0
  198. package/marketplace/plugins/litcodex/skills/lit-schematic/SKILL.md +198 -0
  199. package/marketplace/plugins/litcodex/skills/lit-schematic/agents/openai.yaml +6 -0
  200. package/marketplace/plugins/litcodex/skills/lit-schematic/examples/iso-heat-exchanger/build.mjs +38 -0
  201. package/marketplace/plugins/litcodex/skills/lit-schematic/examples/iso-heat-exchanger/scene.mjs +133 -0
  202. package/marketplace/plugins/litcodex/skills/lit-schematic/examples/journal-adsorption-rig/build.mjs +87 -0
  203. package/marketplace/plugins/litcodex/skills/lit-schematic/examples/pid-dosing-skid/build.mjs +85 -0
  204. package/marketplace/plugins/litcodex/skills/lit-schematic/references/cutaway-outputs.md +70 -0
  205. package/marketplace/plugins/litcodex/skills/lit-schematic/references/isometric-craft.md +101 -0
  206. package/marketplace/plugins/litcodex/skills/lit-schematic/references/journal-figures.md +72 -0
  207. package/marketplace/plugins/litcodex/skills/lit-schematic/references/kit-api.md +134 -0
  208. package/marketplace/plugins/litcodex/skills/lit-schematic/references/pfd-and-layout.md +53 -0
  209. package/marketplace/plugins/litcodex/skills/lit-schematic/references/pid-drafting.md +103 -0
  210. package/marketplace/plugins/litcodex/skills/lit-schematic/references/pid-symbols.md +163 -0
  211. package/marketplace/plugins/litcodex/skills/lit-schematic/references/verification.md +100 -0
  212. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/doctor.mjs +57 -0
  213. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/figure.mjs +81 -0
  214. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/fonts.mjs +28 -0
  215. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/geom.mjs +113 -0
  216. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/interactive.mjs +292 -0
  217. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/isa.mjs +115 -0
  218. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/iso.mjs +719 -0
  219. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/legend-sheet.mjs +162 -0
  220. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/pid.mjs +937 -0
  221. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/png.mjs +132 -0
  222. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/qa-core.mjs +658 -0
  223. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/route.mjs +218 -0
  224. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/sheet.mjs +890 -0
  225. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/svg.mjs +82 -0
  226. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/theme.mjs +115 -0
  227. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/motion.mjs +129 -0
  228. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/qa.mjs +92 -0
  229. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/render.mjs +233 -0
  230. package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/scaffold.mjs +60 -0
  231. package/marketplace/plugins/litcodex/skills/lit-scientific-visualization/SKILL.md +34 -8
  232. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/SKILL.md +18 -14
  233. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +12 -0
  234. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/assets.mjs +388 -0
  235. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/blender/runner.py +221 -0
  236. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/blender.mjs +132 -0
  237. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/board.mjs +142 -0
  238. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/constants.mjs +6 -0
  239. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-assets.mjs +7 -4
  240. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-capture.mjs +8 -7
  241. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-init.js +14 -2
  242. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-treatment.mjs +38 -3
  243. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover.mjs +19 -4
  244. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/driver.mjs +8 -8
  245. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/gallery.mjs +147 -0
  246. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/house.mjs +45 -0
  247. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/image.mjs +89 -0
  248. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/look.mjs +58 -25
  249. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/runtime.mjs +59 -14
  250. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/safe-read.mjs +32 -0
  251. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/scaffold.mjs +208 -0
  252. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/score.mjs +668 -0
  253. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/sound.mjs +174 -31
  254. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-gate.mjs +45 -3
  255. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-kit.js +99 -1
  256. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-qa.js +8 -1
  257. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-qa.mjs +180 -11
  258. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-render.mjs +42 -12
  259. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-worker.mjs +7 -4
  260. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage.mjs +96 -10
  261. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/styles.mjs +233 -0
  262. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/treatment.mjs +291 -14
  263. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/LICENSE +21 -0
  264. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/addons/environments/RoomEnvironment.js +144 -0
  265. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/addons/geometries/RoundedBoxGeometry.js +155 -0
  266. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/three.module.js +54571 -0
  267. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/hero-3d/expected.json +33 -0
  268. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/hero-3d/index.html +139 -0
  269. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/cover.md +44 -7
  270. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/depth.md +156 -0
  271. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/design-choice.md +22 -0
  272. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/quality-gate.md +29 -7
  273. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/runtime.md +1 -1
  274. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/sound.md +87 -0
  275. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/stage.md +19 -7
  276. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/studio.md +246 -0
  277. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/style-bibles.md +2 -2
  278. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/treatment.md +41 -21
  279. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/scripts/render.mjs +51 -4
  280. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/paper.json +185 -0
  281. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/swiss-signal.json +188 -0
  282. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/terminalcore.json +182 -0
  283. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/tidal.json +187 -0
  284. package/marketplace/plugins/litcodex/skills/litresearch/SKILL.md +7 -0
  285. package/marketplace/plugins/litcodex/skills/litwork/SKILL.md +2 -1
  286. package/marketplace/plugins/litcodex/skills/readme-studio/SKILL.md +10 -0
  287. package/marketplace/plugins/litcodex/skills/review-work/SKILL.md +7 -1
  288. package/marketplace/plugins/litcodex/skills/start-work/SKILL.md +10 -0
  289. package/node_modules/@litcodex/lit-loop/directive.md +10 -4
  290. package/node_modules/@litcodex/lit-loop/directives/lit-adhd.md +191 -0
  291. package/node_modules/@litcodex/lit-loop/directives/lit-handoff.md +2 -0
  292. package/node_modules/@litcodex/lit-loop/directives/lit-hijack.md +219 -0
  293. package/node_modules/@litcodex/lit-loop/directives/lit-recap.md +2 -0
  294. package/node_modules/@litcodex/lit-loop/directives/lit-schematic.md +199 -0
  295. package/node_modules/@litcodex/lit-loop/directives/litwork.md +2 -1
  296. package/node_modules/@litcodex/lit-loop/dist/adhd-suggest.d.ts +10 -0
  297. package/node_modules/@litcodex/lit-loop/dist/adhd-suggest.js +67 -0
  298. package/node_modules/@litcodex/lit-loop/dist/card-html.d.ts +1 -1
  299. package/node_modules/@litcodex/lit-loop/dist/card-html.js +128 -8
  300. package/node_modules/@litcodex/lit-loop/dist/card-looks.d.ts +19 -0
  301. package/node_modules/@litcodex/lit-loop/dist/card-looks.js +58 -0
  302. package/node_modules/@litcodex/lit-loop/dist/card-status.d.ts +27 -0
  303. package/node_modules/@litcodex/lit-loop/dist/card-status.js +94 -7
  304. package/node_modules/@litcodex/lit-loop/dist/cli.js +13 -3
  305. package/node_modules/@litcodex/lit-loop/dist/codex-hook.d.ts +2 -0
  306. package/node_modules/@litcodex/lit-loop/dist/codex-hook.js +8 -9
  307. package/node_modules/@litcodex/lit-loop/dist/control-chars.d.ts +5 -0
  308. package/node_modules/@litcodex/lit-loop/dist/control-chars.js +23 -0
  309. package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +8 -0
  310. package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +118 -11
  311. package/node_modules/@litcodex/lit-loop/dist/hud.d.ts +1 -1
  312. package/node_modules/@litcodex/lit-loop/dist/hud.js +29 -13
  313. package/node_modules/@litcodex/lit-loop/dist/lane-events.d.ts +13 -0
  314. package/node_modules/@litcodex/lit-loop/dist/lane-events.js +85 -0
  315. package/node_modules/@litcodex/lit-loop/dist/lane-state.d.ts +55 -0
  316. package/node_modules/@litcodex/lit-loop/dist/lane-state.js +227 -0
  317. package/node_modules/@litcodex/lit-loop/dist/live-step.d.ts +5 -1
  318. package/node_modules/@litcodex/lit-loop/dist/live-step.js +17 -1
  319. package/node_modules/@litcodex/lit-loop/dist/markers.d.ts +6 -0
  320. package/node_modules/@litcodex/lit-loop/dist/markers.js +6 -0
  321. package/node_modules/@litcodex/lit-loop/dist/modes.d.ts +1 -1
  322. package/node_modules/@litcodex/lit-loop/dist/modes.js +25 -1
  323. package/node_modules/@litcodex/lit-loop/dist/motion-gate.d.ts +79 -0
  324. package/node_modules/@litcodex/lit-loop/dist/motion-gate.js +310 -0
  325. package/node_modules/@litcodex/lit-loop/dist/motion-route.js +5 -1
  326. package/node_modules/@litcodex/lit-loop/dist/plan-persistence.js +10 -0
  327. package/node_modules/@litcodex/lit-loop/dist/redaction.js +18 -0
  328. package/node_modules/@litcodex/lit-loop/dist/reentry.d.ts +15 -0
  329. package/node_modules/@litcodex/lit-loop/dist/reentry.js +46 -9
  330. package/node_modules/@litcodex/lit-loop/dist/rewind-cli.d.ts +10 -0
  331. package/node_modules/@litcodex/lit-loop/dist/rewind-cli.js +88 -0
  332. package/node_modules/@litcodex/lit-loop/dist/rewind-go.d.ts +20 -0
  333. package/node_modules/@litcodex/lit-loop/dist/rewind-go.js +84 -0
  334. package/node_modules/@litcodex/lit-loop/dist/rewind-look.d.ts +6 -0
  335. package/node_modules/@litcodex/lit-loop/dist/rewind-look.js +41 -0
  336. package/node_modules/@litcodex/lit-loop/dist/rewind-redact.d.ts +3 -0
  337. package/node_modules/@litcodex/lit-loop/dist/rewind-redact.js +40 -0
  338. package/node_modules/@litcodex/lit-loop/dist/rewind-rollout.d.ts +48 -0
  339. package/node_modules/@litcodex/lit-loop/dist/rewind-rollout.js +292 -0
  340. package/node_modules/@litcodex/lit-loop/dist/rewind.d.ts +162 -0
  341. package/node_modules/@litcodex/lit-loop/dist/rewind.js +773 -0
  342. package/node_modules/@litcodex/lit-loop/dist/route-heads.js +44 -2
  343. package/node_modules/@litcodex/lit-loop/dist/run-panel.js +1 -0
  344. package/node_modules/@litcodex/lit-loop/dist/schematic-route.d.ts +6 -0
  345. package/node_modules/@litcodex/lit-loop/dist/schematic-route.js +35 -0
  346. package/node_modules/@litcodex/lit-loop/dist/screen-card.d.ts +3 -0
  347. package/node_modules/@litcodex/lit-loop/dist/screen-card.js +15 -5
  348. package/node_modules/@litcodex/lit-loop/dist/skill-mention-scope.js +6 -0
  349. package/node_modules/@litcodex/lit-loop/dist/stack-hook.d.ts +8 -0
  350. package/node_modules/@litcodex/lit-loop/dist/stack-hook.js +57 -0
  351. package/node_modules/@litcodex/lit-loop/dist/statusline.js +8 -3
  352. package/node_modules/@litcodex/lit-loop/dist/threads.d.ts +50 -0
  353. package/node_modules/@litcodex/lit-loop/dist/threads.js +178 -0
  354. package/node_modules/@litcodex/lit-loop/dist/trigger.d.ts +1 -1
  355. package/node_modules/@litcodex/lit-loop/dist/trigger.js +29 -5
  356. package/node_modules/@litcodex/lit-loop/dist/workflow-map.d.ts +10 -0
  357. package/node_modules/@litcodex/lit-loop/dist/workflow-map.js +11 -1
  358. package/node_modules/@litcodex/lit-loop/dist/workflow-stack.d.ts +132 -0
  359. package/node_modules/@litcodex/lit-loop/dist/workflow-stack.js +488 -0
  360. package/node_modules/@litcodex/lit-loop/package.json +1 -1
  361. package/node_modules/@litcodex/lit-loop/skills/lit-adhd/SKILL.md +181 -0
  362. package/node_modules/@litcodex/lit-loop/skills/lit-hijack/SKILL.md +449 -0
  363. package/node_modules/@litcodex/lit-loop/skills/lit-loop/SKILL.md +13 -4
  364. package/node_modules/@litcodex/lit-loop/skills/lit-plan/SKILL.md +6 -0
  365. package/node_modules/@litcodex/lit-loop/skills/lit-recap/SKILL.md +2 -0
  366. package/node_modules/@litcodex/lit-loop/skills/lit-schematic/SKILL.md +198 -0
  367. package/node_modules/@litcodex/lit-loop/skills/lit-scientific-visualization/SKILL.md +34 -8
  368. package/node_modules/@litcodex/lit-loop/skills/litresearch/SKILL.md +7 -0
  369. package/node_modules/@litcodex/lit-loop/skills/litwork/SKILL.md +2 -1
  370. package/node_modules/@litcodex/lit-loop/skills/review-work/SKILL.md +7 -1
  371. package/node_modules/@litcodex/lit-loop/skills/start-work/SKILL.md +10 -0
  372. package/package.json +2 -2
  373. package/readme-assets/badge-version.svg +1 -1
  374. package/readme-assets/skills/lit-adhd.webp +0 -0
  375. package/readme-assets/skills/lit-hijack.webp +0 -0
  376. package/readme-assets/skills/lit-schematic.webp +0 -0
@@ -11,21 +11,25 @@ import { join } from "node:path";
11
11
  import { COVER, EXIT, Exit, MAX_ROUNDS } from "./constants.mjs";
12
12
  import { generatedLabels } from "./cover-assets.mjs";
13
13
  import { validateCoverTreatment } from "./cover-treatment.mjs";
14
+ import { readBounded, readBoundedText } from "./safe-read.mjs";
14
15
  import { loadTreatment, TreatmentError } from "./treatment.mjs";
15
16
 
16
17
  export const QUESTIONS = Object.freeze([
17
18
  "A stranger would say this film is for: <…>. Does that match the treatment's audience and idea?",
18
19
  "Does every beat show its onScreen plan?",
19
- "Is the craft at the level ambition asks for (transitions, rhythm, depth, hierarchy)?",
20
+ "Is it rich enough? Put the contact sheet beside the user's reference frames (none given: a studio launch film of a product). Does each shot carry as much labelled detail, layered depth, camera movement and accent colour as they do, with one hero move leading it and the style's hand-offs between shots? A minimal film answers for its restraint instead.",
20
21
  "Is any request text, meta label, placeholder, file name or internal term on screen?",
21
22
  "Does the ending land?",
22
- "Does the sound follow the cuts (from sound-cues.json)?",
23
+ "Does the sound follow the cuts and the events (from sound-cues.json): does each event cue's frame show what its `on` says?",
23
24
  "Name one thing a skilled motion designer, given only the request, would have shown that this film does not. Can you name one?",
24
25
  "Is any element on screen without a job in its beat?",
25
26
  "Could every copy line be pasted unchanged into a film about a different subject?",
27
+ "Does the turn land? Answer it on the turn shot's own still (story.beat): is story.turn visibly happening there, to the protagonist, as the film's largest change? A turn that only a caption announces is a no.",
26
28
  ]);
27
- // The answer that asks for another round, per question: "no" on 1, 2, 3, 5, 6; "yes" on 4, 7, 8, 9.
28
- const REVISE_ON = Object.freeze({ 1: "no", 2: "no", 3: "no", 4: "yes", 5: "no", 6: "no", 7: "yes", 8: "yes", 9: "yes" });
29
+ // Questions 1-9 are asked of every film; the tenth only of a film whose treatment carries a story.
30
+ const FILM_BASE = 9;
31
+ // The answer that asks for another round, per question: "no" on 1, 2, 3, 5, 6, 10; "yes" on 4, 7, 8, 9.
32
+ const REVISE_ON = Object.freeze({ 1: "no", 2: "no", 3: "no", 4: "yes", 5: "no", 6: "no", 7: "yes", 8: "yes", 9: "yes", 10: "no" });
29
33
  const COVERAGE_KINDS = new Set(["poster", "sheet", "beat", "strip"]);
30
34
  // Cover mode asks about motion, the seam and damage instead of purpose and beats (references/cover.md).
31
35
  export const COVER_QUESTIONS = Object.freeze([
@@ -49,19 +53,33 @@ const refuse = (message) => {
49
53
  export function latestStills(outDir) {
50
54
  const path = join(outDir, "stills", "manifest.json");
51
55
  if (!existsSync(path)) return null;
52
- const text = readFileSync(path, "utf8");
56
+ const text = readBoundedText(path);
53
57
  const manifest = JSON.parse(text);
54
58
  return { manifest, sha: sha256(text), files: new Map(manifest.files.map((f) => [f.file, f])) };
55
59
  }
56
60
 
57
61
  export function readLook(outDir) {
58
62
  const path = join(outDir, "look.json");
59
- return existsSync(path) ? JSON.parse(readFileSync(path, "utf8")) : { schema: 1, rounds: [] };
63
+ return existsSync(path) ? JSON.parse(readBoundedText(path)) : { schema: 1, rounds: [] };
60
64
  }
61
65
 
62
66
  const bare = /^\s*(?:yes|no|y|n|ok|okay|fine|good|none|n\/a|네|아니오|예)\s*[.!]?\s*$/iu;
63
67
  const sentence = (text) => typeof text === "string" && !bare.test(text) && text.trim().length >= 20 && text.trim().split(/\s+/u).length >= 5;
64
68
 
69
+ const readTreatmentRaw = (outDir) => {
70
+ try {
71
+ return JSON.parse(readBoundedText(join(outDir, "treatment.json")));
72
+ } catch {
73
+ return null;
74
+ }
75
+ };
76
+
77
+ /** The still of the story's turn beat (`beat-NN.png` for `story.beat`), or null when the treatment has no story. */
78
+ function turnStill(outDir) {
79
+ const beat = readTreatmentRaw(outDir)?.story?.beat;
80
+ return Number.isInteger(beat) && beat >= 0 ? `beat-${String(beat + 1).padStart(2, "0")}.png` : null;
81
+ }
82
+
65
83
  /** Validate an answers file against the latest stills set and append the round to look.json. */
66
84
  export function recordLook(outDir, round, answersPath) {
67
85
  if (!Number.isInteger(round) || round < 1 || round > MAX_ROUNDS) refuse(`--round must be 1..${MAX_ROUNDS}`);
@@ -85,27 +103,30 @@ export function recordLook(outDir, round, answersPath) {
85
103
  }
86
104
  if (stills.manifest.round !== round) refuse(`the latest stills set is from round ${stills.manifest.round}; look at the stills of round ${round} (render it first)`);
87
105
  if (stills.manifest.mode === "cover") return recordCoverLook({ outDir, round, body, stills, look });
88
- if (body.defects !== undefined) refuse("defects are a cover-mode record; a film round names its weakest beat instead");
89
106
  if (round === 1 && stills.manifest.kind !== "stills-only") refuse("round 1 is a stills round: run the render with --stills-only --round 1 first");
90
107
  const name = (file) => String(file ?? "").replace(/^stills\//u, "");
91
108
  const viewed = Array.isArray(body.viewed) ? body.viewed.map(name) : [];
92
109
  const listed = [...viewed];
93
110
  if (!Array.isArray(body.answers)) refuse("answers must be an array of { q, verdict, frame, observed }");
111
+ const turn = turnStill(outDir);
94
112
  const byQ = new Map();
95
113
  for (const answer of body.answers) {
96
114
  const q = Number(answer?.q);
97
- if (!Number.isInteger(q) || q < 1 || q > 9) refuse(`unknown question ${answer?.q}`);
115
+ if (!Number.isInteger(q) || q < 1 || q > QUESTIONS.length || (q > FILM_BASE && turn === null)) refuse(`unknown question ${answer?.q}${q > FILM_BASE ? " (question 10 belongs to a treatment with a story)" : ""}`);
98
116
  if (byQ.has(q)) refuse(`question ${q} answered twice`);
99
117
  if (answer.verdict !== "yes" && answer.verdict !== "no") refuse(`question ${q}: verdict must be "yes" or "no"`);
100
118
  if (!sentence(answer.observed)) refuse(`question ${q}: observed must be a sentence naming a concrete visible detail, not a bare yes/no`);
101
119
  if (q === 1 && !/for:\s*\S/iu.test(answer.observed)) refuse('question 1: observed must read "A stranger would say this film is for: <…>"');
102
120
  const frame = name(answer.frame);
121
+ if (q === 10 && frame !== turn) refuse(`question 10: answer it on the turn shot's still ${turn} (story.beat in treatment.json), not ${frame || "no frame"}`);
103
122
  if (frame === "sound-cues.json") {
104
123
  if (q !== 6 || !existsSync(join(outDir, "sound-cues.json"))) refuse(`question ${q}: sound-cues.json is only for question 6 and must exist`);
105
124
  } else listed.push(frame);
106
125
  byQ.set(q, { q, verdict: answer.verdict, frame, observed: answer.observed.trim(), ...(q === 1 ? { by: answer.by === "blind" ? "blind" : "self" } : {}) });
107
126
  }
108
- for (let q = 1; q <= 9; q++) if (!byQ.has(q)) refuse(`question ${q} is not answered (${QUESTIONS[q - 1]})`);
127
+ const defects = recordDefects(body.defects, stills, false, readTreatmentRaw(outDir)?.durationSec ?? null);
128
+ listed.push(...defects.map((d) => d.frame));
129
+ for (let q = 1; q <= (turn === null ? FILM_BASE : QUESTIONS.length); q++) if (!byQ.has(q)) refuse(`question ${q} is not answered (${QUESTIONS[q - 1]})`);
109
130
  const unknown = [...new Set(listed)].filter((file) => !stills.files.has(file));
110
131
  if (unknown.length) refuse(`not in the latest stills set: ${unknown.join(", ")}`);
111
132
  const frames = {};
@@ -120,7 +141,7 @@ export function recordLook(outDir, round, answersPath) {
120
141
  }
121
142
  const answers = [...byQ.values()].sort((a, b) => a.q - b.q);
122
143
  const openItems = answers.filter((a) => a.verdict === REVISE_ON[a.q]).map((a) => `Q${a.q}: ${a.observed}`);
123
- const entry = { round, at: new Date().toISOString(), kind: stills.manifest.kind, manifestSha256: stills.sha, frames, viewed: [...new Set(viewed)], answers, ...(round === 1 ? { weakestBeat: body.weakestBeat, change: body.change.trim() } : {}), needsAnotherRound: openItems.length > 0, openItems };
144
+ const entry = { round, at: new Date().toISOString(), kind: stills.manifest.kind, manifestSha256: stills.sha, frames, viewed: [...new Set(viewed)], answers, ...(defects.length ? { defects } : {}), ...(round === 1 ? { weakestBeat: body.weakestBeat, change: body.change.trim() } : {}), needsAnotherRound: openItems.length > 0, openItems };
124
145
  look.rounds.push(entry);
125
146
  writeFileSync(join(outDir, "look.json"), `${JSON.stringify(look, null, 2)}\n`);
126
147
  return entry;
@@ -140,22 +161,25 @@ function stampFrames(outDir, stills, files) {
140
161
  }
141
162
 
142
163
  /**
143
- * Cover defects: at most COVER.maxDefects per round, worst first, each { t, region, frame, observed,
144
- * cause, fix }: the loop time in seconds where it shows, the [x, y, w, h] it covers in cover pixels,
145
- * and a file of the current stills set that shows it. `render.mjs cover --window` checks the fix.
164
+ * Defects: at most COVER.maxDefects per round, worst first, each { t, region, frame, observed, cause,
165
+ * fix }: the time in seconds where it shows (the loop time for a cover), the [x, y, w, h] it covers in
166
+ * frame pixels, and a file of the current stills set that shows it. A cover checks the fix with
167
+ * `render.mjs cover --window`; a film fixes those seconds and renders again. Optional on a film round.
146
168
  */
147
- function coverDefects(list, stills) {
169
+ function recordDefects(list, stills, cover, treatmentDuration = null) {
148
170
  if (list === undefined) return [];
149
171
  if (!Array.isArray(list)) refuse("defects must be an array");
150
172
  if (list.length > COVER.maxDefects) refuse(`at most ${COVER.maxDefects} defects per round; fix the worst first`);
151
- const { width, height, durationSec } = stills.manifest;
173
+ const { width, height, fps, frameCount } = stills.manifest;
174
+ const durationSec = stills.manifest.durationSec ?? (frameCount && fps ? frameCount / fps : treatmentDuration);
175
+ const what = cover ? "cover" : "frame";
152
176
  const name = (file) => String(file ?? "").replace(/^stills\//u, "");
153
177
  return list.map((d, i) => {
154
178
  const at = `defect ${i + 1}`;
155
179
  if (!d || typeof d !== "object") refuse(`${at} must be an object`);
156
- if (typeof d.t !== "number" || !(d.t >= 0 && d.t < durationSec)) refuse(`${at}: t must be the loop time in seconds (0 to ${durationSec}) where the defect shows`);
180
+ if (typeof d.t !== "number" || !(d.t >= 0) || (durationSec && d.t >= durationSec)) refuse(`${at}: t must be the ${cover ? "loop " : ""}time in seconds${durationSec ? ` (0 to ${durationSec})` : ""} where the defect shows`);
157
181
  const r = d.region;
158
- if (!Array.isArray(r) || r.length !== 4 || !r.every(Number.isInteger) || r[0] < 0 || r[1] < 0 || r[2] <= 0 || r[3] <= 0 || r[0] + r[2] > width || r[1] + r[3] > height) refuse(`${at}: region must be [x, y, w, h] in whole pixels inside the ${width}x${height} cover`);
182
+ if (!Array.isArray(r) || r.length !== 4 || !r.every(Number.isInteger) || r[0] < 0 || r[1] < 0 || r[2] <= 0 || r[3] <= 0 || r[0] + r[2] > width || r[1] + r[3] > height) refuse(`${at}: region must be [x, y, w, h] in whole pixels inside the ${width}x${height} ${what}`);
159
183
  if (!stills.files.has(name(d.frame))) refuse(`${at}: frame ${JSON.stringify(d.frame)} is not in the latest stills set`);
160
184
  if (!sentence(d.observed)) refuse(`${at}: observed must be a sentence naming what is visible there`);
161
185
  if (![d.cause, d.fix].every((x) => typeof x === "string" && x.trim().split(/\s+/u).length >= 3)) refuse(`${at}: cause and fix must each say something concrete`);
@@ -180,7 +204,7 @@ function recordCoverLook({ outDir, round, body, stills, look }) {
180
204
  }
181
205
  for (let q = 1; q <= COVER_QUESTIONS.length; q++) if (!byQ.has(q)) refuse(`question ${q} is not answered (${COVER_QUESTIONS[q - 1]})`);
182
206
  const answers = [...byQ.values()].sort((a, b) => a.q - b.q);
183
- const defects = coverDefects(body.defects, stills);
207
+ const defects = recordDefects(body.defects, stills, true);
184
208
  const frames = stampFrames(outDir, stills, [...viewed, ...answers.map((a) => a.frame), ...defects.map((d) => d.frame)]);
185
209
  if (round === 1 && (typeof body.change !== "string" || body.change.trim().split(/\s+/u).length < 3)) refuse("round 1 must state the change you made (change)");
186
210
  const openItems = answers.filter((a) => a.verdict === COVER_REVISE_ON[a.q]).map((a) => `Q${a.q}: ${a.observed}`);
@@ -220,9 +244,18 @@ const PREVIEWS = ["preview.webp", "preview.gif"];
220
244
  * downgraded[], openItems[] }.
221
245
  */
222
246
  export function evaluateDone(outDir) {
247
+ try {
248
+ return judgeDone(outDir);
249
+ } catch (error) {
250
+ // A render folder the check cannot read (a pipe, a device link, an oversize or garbled file) is a verdict, not a crash.
251
+ return { status: "not complete", reason: `the render state in ${outDir} could not be read (${String(error?.message ?? error).split("\n")[0]})`, downgraded: [], openItems: [] };
252
+ }
253
+ }
254
+
255
+ function judgeDone(outDir) {
223
256
  const notDone = (reason) => ({ status: "not complete", reason, downgraded: [], openItems: [] });
224
257
  try {
225
- const raw = JSON.parse(readFileSync(join(outDir, "treatment.json"), "utf8"));
258
+ const raw = JSON.parse(readBoundedText(join(outDir, "treatment.json")));
226
259
  if (raw?.mode === "cover") return evaluateCoverDone(outDir, raw);
227
260
  } catch {
228
261
  // A missing or unreadable treatment is reported by the film checks below.
@@ -237,8 +270,8 @@ export function evaluateDone(outDir) {
237
270
  if (error instanceof TreatmentError) return notDone(`the treatment is not valid (${error.message})`);
238
271
  throw error;
239
272
  }
240
- const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
241
- const report = readFileSync(reportPath, "utf8");
273
+ const manifest = JSON.parse(readBoundedText(manifestPath));
274
+ const report = readBoundedText(reportPath);
242
275
  const rendered = statSync(manifestPath).mtimeMs;
243
276
  if (statSync(join(outDir, "treatment.json")).mtimeMs > rendered) return notDone("the treatment changed after the last render; render again");
244
277
  const page = join(outDir, "stage", "index.html");
@@ -251,7 +284,7 @@ export function evaluateDone(outDir) {
251
284
  if (!passed && round < MAX_ROUNDS) return notDone(`gate FAIL at round ${round} of ${MAX_ROUNDS}: fix the named cause and render round ${round + 1}`);
252
285
  if (withheld && (!delivered(join(outDir, "withheld")) || [...EXPORTS, ...PREVIEWS].some((n) => existsSync(join(outDir, n))))) return notDone("flash FAIL but the exports are not confined to withheld/");
253
286
  if (!withheld && !delivered(outDir)) return notDone("an export is missing at its deliverable name");
254
- const first = existsSync(join(outDir, ".run", "treatment-first.json")) ? JSON.parse(readFileSync(join(outDir, ".run", "treatment-first.json"), "utf8")) : null;
287
+ const first = existsSync(join(outDir, ".run", "treatment-first.json")) ? JSON.parse(readBoundedText(join(outDir, ".run", "treatment-first.json"))) : null;
255
288
  const downgraded = downgrades(first, treatment);
256
289
  const rounds = readLook(outDir).rounds;
257
290
  const last = rounds.at(-1);
@@ -288,10 +321,10 @@ export function evaluateCoverDone(outDir, raw) {
288
321
  const manifestPath = join(outDir, "manifest.json");
289
322
  const reportPath = join(outDir, "gate-report.txt");
290
323
  if (!existsSync(manifestPath) || !existsSync(reportPath)) return notDone("no finished cover render: manifest.json or gate-report.txt is missing");
291
- const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
324
+ const manifest = JSON.parse(readBoundedText(manifestPath));
292
325
  if (manifest.mode !== "cover") return notDone("the last render was not a cover render; run `render.mjs cover`");
293
- if (manifest.treatmentSha256 !== sha256(readFileSync(join(outDir, "treatment.json")))) return notDone("treatment.json changed after the last cover render; render again");
294
- if (!/^COVER gate --strict: PASS\+TARGET$/mu.test(readFileSync(reportPath, "utf8"))) return notDone("the decoded cover did not reach every TARGET gate on the last render (gate-report.txt)");
326
+ if (manifest.treatmentSha256 !== sha256(readBounded(join(outDir, "treatment.json")))) return notDone("treatment.json changed after the last cover render; render again");
327
+ if (!/^COVER gate --strict: PASS\+TARGET$/mu.test(readBoundedText(reportPath))) return notDone("the decoded cover did not reach every TARGET gate on the last render (gate-report.txt)");
295
328
  const rounds = readLook(outDir).rounds;
296
329
  const last = rounds.at(-1);
297
330
  if (last?.blocked) return { status: "DONE_UNVIEWED", reason: "every TARGET gate passed, but no image tool was reachable: nobody viewed the sheet. Say so plainly in the reply.", downgraded: [], openItems: [], labels, mode: "cover" };
@@ -85,16 +85,55 @@ export function resolveRuntime(env = process.env) {
85
85
  };
86
86
  }
87
87
 
88
- async function fetchPinned(item, mirror) {
88
+ const PIN_TIMEOUT_MS = 120_000;
89
+ const PIN_MAX_BYTES = 64 * 1024 * 1024;
90
+
91
+ /**
92
+ * One pinned file: from the local mirror, or over the network inside a deadline and a byte cap (the pin's
93
+ * own size, else maxBytes), hashed while it streams. The size and sha256 pin is checked either way.
94
+ * `fetchImpl`, `timeoutMs` and `maxBytes` are injectable for tests.
95
+ */
96
+ export async function fetchPinned(item, mirror, { fetchImpl = globalThis.fetch, timeoutMs = PIN_TIMEOUT_MS, maxBytes = PIN_MAX_BYTES } = {}) {
89
97
  let bytes;
90
- if (mirror) bytes = readFileSync(join(mirror, item.path));
91
- else {
92
- const response = await fetch(item.url, { redirect: "follow" });
93
- if (!response.ok) throw new Error(`fetch ${item.url}: HTTP ${response.status}`);
94
- bytes = Buffer.from(await response.arrayBuffer());
98
+ let digest;
99
+ if (mirror) {
100
+ bytes = readFileSync(join(mirror, item.path));
101
+ digest = sha256(bytes);
102
+ } else {
103
+ const limit = item.bytes ?? maxBytes;
104
+ const signal = AbortSignal.timeout(timeoutMs);
105
+ const tooLarge = () => new Error(`fetch ${item.url}: larger than ${limit} bytes`);
106
+ try {
107
+ const response = await fetchImpl(item.url, { redirect: "follow", signal });
108
+ if (!response.ok) throw new Error(`fetch ${item.url}: HTTP ${response.status}`);
109
+ if (Number(response.headers.get("content-length") ?? 0) > limit) {
110
+ await response.body?.cancel();
111
+ throw tooLarge();
112
+ }
113
+ const hash = createHash("sha256");
114
+ const chunks = [];
115
+ let total = 0;
116
+ const reader = response.body.getReader();
117
+ for (;;) {
118
+ const { done, value } = await reader.read();
119
+ if (done) break;
120
+ total += value.length;
121
+ if (total > limit) {
122
+ await reader.cancel();
123
+ throw tooLarge();
124
+ }
125
+ hash.update(value);
126
+ chunks.push(Buffer.from(value));
127
+ }
128
+ bytes = Buffer.concat(chunks);
129
+ digest = hash.digest("hex");
130
+ } catch (error) {
131
+ if (signal.aborted) throw new Error(`fetch ${item.url}: timed out after ${timeoutMs / 1000} s`);
132
+ throw error;
133
+ }
95
134
  }
96
135
  if (item.bytes !== undefined && bytes.length !== item.bytes) throw new Error(`${item.path}: ${bytes.length} bytes, pinned ${item.bytes}`);
97
- if (sha256(bytes) !== item.sha256) throw new Error(`${item.path}: sha256 mismatch against its pin`);
136
+ if (digest !== item.sha256) throw new Error(`${item.path}: sha256 mismatch against its pin`);
98
137
  return bytes;
99
138
  }
100
139
 
@@ -245,12 +284,18 @@ export function chromeLadder(platform = process.platform) {
245
284
  }
246
285
 
247
286
  /**
248
- * The stage path's one launch rung: the ladder's software rung (SwiftShader, CPU raster), the stage
249
- * determinism and network flags, and the frame size. There is no GPU rung on the stage path, so a
250
- * determinism mismatch is always a page leak.
287
+ * The stage path's launch flags: the software rung (SwiftShader, CPU raster) by default, or the
288
+ * platform's GPU rung for a 3D film (WebGL on the GPU through the platform's angle backend; page
289
+ * raster stays on the CPU on both), then the stage determinism and network flags and the frame size.
290
+ * A round uses one rung for the master and every replay, so a determinism mismatch is still a page
291
+ * leak. Accepts (width, height, platform, rung) or ({ width, height, rung, platform }).
251
292
  */
252
- export function stageFlags(width, height, platform = process.platform) {
253
- return [...chromeLadder(platform)[1], ...CHROME_STAGE_FLAGS, `--window-size=${width},${height}`];
293
+ export function stageFlags(width, height, platform = process.platform, rung = "software") {
294
+ if (width && typeof width === "object") return stageFlags(width.width, width.height, width.platform ?? process.platform, width.rung ?? "software");
295
+ if (rung !== "gpu" && rung !== "software") throw new Error(`stageFlags: rung is gpu or software (got ${rung})`);
296
+ const ladder = chromeLadder(platform);
297
+ const base = rung === "gpu" ? [...ladder[0].filter((flag) => flag !== "--enable-gpu-rasterization"), "--disable-gpu-rasterization", "--disable-partial-raster"] : ladder[1];
298
+ return [...base, ...CHROME_STAGE_FLAGS, `--window-size=${width},${height}`];
254
299
  }
255
300
 
256
301
  /**
@@ -258,8 +303,8 @@ export function stageFlags(width, height, platform = process.platform) {
258
303
  * and never partial: at 2x, glyph edges rastered in GPU tiles came out one level apart between fresh
259
304
  * browsers.
260
305
  */
261
- export function coverFlags(width, height, scale, platform = process.platform) {
262
- return [...stageFlags(width, height, platform).map((flag) => (flag === "--force-device-scale-factor=1" ? `--force-device-scale-factor=${scale}` : flag)), "--disable-gpu-rasterization", "--disable-partial-raster"];
306
+ export function coverFlags(width, height, scale, platform = process.platform, rung = "software") {
307
+ return [...stageFlags(width, height, platform, rung).map((flag) => (flag === "--force-device-scale-factor=1" ? `--force-device-scale-factor=${scale}` : flag)), "--disable-gpu-rasterization", "--disable-partial-raster"];
263
308
  }
264
309
 
265
310
  export const isSoftware = (renderer) => SOFTWARE_GL.some((needle) => String(renderer).toLowerCase().includes(needle));
@@ -0,0 +1,32 @@
1
+ // Bounded reads of files a model or a render wrote. The Stop hook runs the done-check synchronously inside a
2
+ // 5 s manifest timeout, so a path that is a named pipe, a link to a device, or a huge file must end in a
3
+ // refusal, never a blocked read. lstat first, open without following links and without blocking, check the
4
+ // opened descriptor again, and stop at the byte limit.
5
+ import { closeSync, constants, fstatSync, lstatSync, openSync, readSync } from "node:fs";
6
+
7
+ export const READ_LIMIT = 4 * 1024 * 1024;
8
+
9
+ export function readBounded(path, maxBytes = READ_LIMIT) {
10
+ if (!lstatSync(path).isFile()) throw new Error(`${path} is not a regular file`);
11
+ const fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
12
+ try {
13
+ const info = fstatSync(fd);
14
+ if (!info.isFile()) throw new Error(`${path} is not a regular file`);
15
+ if (info.size > maxBytes) throw new Error(`${path} is too large (${info.size} bytes; limit ${maxBytes})`);
16
+ const chunks = [];
17
+ let total = 0;
18
+ for (;;) {
19
+ const chunk = Buffer.allocUnsafe(Math.min(64 * 1024, maxBytes + 1 - total));
20
+ const got = readSync(fd, chunk, 0, chunk.length, null);
21
+ if (got === 0) break;
22
+ total += got;
23
+ if (total > maxBytes) throw new Error(`${path} is too large (over ${maxBytes} bytes)`);
24
+ chunks.push(chunk.subarray(0, got));
25
+ }
26
+ return Buffer.concat(chunks);
27
+ } finally {
28
+ closeSync(fd);
29
+ }
30
+ }
31
+
32
+ export const readBoundedText = (path, maxBytes = READ_LIMIT) => readBounded(path, maxBytes).toString("utf8");
@@ -0,0 +1,208 @@
1
+ // `render.mjs scaffold --out <dir>`: the starting stage page, written from the treatment, so every film
2
+ // has the same architecture: the COPY block, one <section> per shot with its type placed in the shot's
3
+ // type zone and an empty subject group in its subject zone, entrances and hand-offs on the house
4
+ // style's tokens, and one DRAW function per shot where the drawing goes. The page passes the style
5
+ // rules as written; the drawing is the model's. A 3D film (`depth: "3d"`) also gets the three.js world:
6
+ // an import map onto the vendored build, a full-frame canvas behind the shots, one persistent
7
+ // protagonist group lit and shadowed in the style's palette, and one WORLD function per shot. It never
8
+ // overwrites an existing page.
9
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
10
+ import { dirname, join } from "node:path";
11
+ import { findBlender } from "./blender.mjs";
12
+ import { EXIT, Exit, STAGE_FORMATS } from "./constants.mjs";
13
+ import { asksPathTraced, loadTreatment } from "./treatment.mjs";
14
+
15
+ const HANGUL = /[ㄱ-ㆎ가-힣]/u;
16
+
17
+ /**
18
+ * Which copy lines each shot shows: the treatment's `lines` when given; otherwise spread in order over
19
+ * the shots that have a type zone, the first line on the first and the last line on the last.
20
+ */
21
+ export function linesPerShot(treatment) {
22
+ const beats = treatment.beats;
23
+ if (beats.some((b) => Array.isArray(b.lines))) return beats.map((b) => (Array.isArray(b.lines) ? b.lines : []));
24
+ const lines = treatment.copy.lines.map((_, i) => i);
25
+ const textShots = beats.map((b, i) => (b.layout === "full" ? null : i)).filter((i) => i !== null);
26
+ const out = beats.map(() => []);
27
+ if (!textShots.length) return out;
28
+ lines.forEach((line, k) => {
29
+ const at = lines.length > 1 ? Math.round((k * (textShots.length - 1)) / (lines.length - 1)) : 0;
30
+ out[textShots[at]].push(line);
31
+ });
32
+ return out;
33
+ }
34
+
35
+ const WORLD_CODE = (width, height, worlds) => `
36
+ // The world: one scene for the whole film, drawn on the GPU rung (software when it is missing). The
37
+ // protagonist lives in HERO from the first frame to the last; each shot's WORLD function poses it,
38
+ // the camera and anything else as a function of the shot's progress. The camera is aimed so the
39
+ // world origin sits at the centre of the shot's subject zone. More parts of the vendored build:
40
+ // three/addons/geometries/RoundedBoxGeometry.js.
41
+ const PAL = LitStyle.palette;
42
+ const renderer = new THREE.WebGLRenderer({ canvas: document.getElementById("world"), antialias: true, alpha: true, preserveDrawingBuffer: true });
43
+ renderer.setPixelRatio(1);
44
+ renderer.setSize(${width}, ${height}, false);
45
+ renderer.setClearColor(0x000000, 0);
46
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
47
+ renderer.toneMapping = THREE.ACESFilmicToneMapping;
48
+ renderer.shadowMap.enabled = true;
49
+ renderer.shadowMap.type = THREE.PCFSoftShadowMap;
50
+ const scene = new THREE.Scene();
51
+ scene.environment = new THREE.PMREMGenerator(renderer).fromScene(new RoomEnvironment(), 0.04).texture;
52
+ const cam = new THREE.PerspectiveCamera(32, ${width} / ${height}, 0.1, 100);
53
+ const key = new THREE.DirectionalLight(0xffffff, 2.2);
54
+ key.position.set(3, 6, 4);
55
+ key.castShadow = true;
56
+ key.shadow.mapSize.set(2048, 2048);
57
+ key.shadow.radius = 4;
58
+ key.shadow.bias = -0.0004; // without these a turning object's shadow acne flickers as flashes
59
+ key.shadow.normalBias = 0.03;
60
+ scene.add(key, new THREE.HemisphereLight(PAL.surface ?? PAL.ground, PAL.ground, 0.6));
61
+ const floor = new THREE.Mesh(new THREE.PlaneGeometry(40, 40), new THREE.ShadowMaterial({ opacity: 0.18 }));
62
+ floor.rotation.x = -Math.PI / 2;
63
+ floor.receiveShadow = true;
64
+ scene.add(floor);
65
+ const HERO = new THREE.Group();
66
+ scene.add(HERO);
67
+
68
+ // Aim the camera so the origin lands on the centre of the shot's subject zone.
69
+ function aim(layout) {
70
+ const z = LitStage.zone(layout, "subject");
71
+ cam.setViewOffset(${width}, ${height}, ${width} / 2 - (z.x + z.w / 2), ${height} / 2 - (z.y + z.h / 2), ${width}, ${height});
72
+ return z.h / ${height};
73
+ }
74
+
75
+ const WORLD = [
76
+ ${worlds}
77
+ ];
78
+
79
+ function drawWorld(s, t) {
80
+ cam.position.set(0, 1.6, 7);
81
+ cam.lookAt(0, 0.6, 0);
82
+ aim(s.beat.layout);
83
+ WORLD[s.index](s, HERO, cam, t);
84
+ renderer.render(scene, cam);
85
+ }
86
+ `;
87
+
88
+ /** The scaffold page for a stage treatment. */
89
+ export function scaffoldHtml(treatment) {
90
+ const { width, height } = STAGE_FORMATS[treatment.format];
91
+ const perShot = linesPerShot(treatment);
92
+ const lang = treatment.copy.lines.some((l) => HANGUL.test(l)) ? "ko" : "en";
93
+ const sections = treatment.beats
94
+ .map((b, i) => {
95
+ const lines = perShot[i];
96
+ const roleOf = (k) => (k > 0 ? "lit-body lit-muted" : b.layout === "title" ? "lit-display lit-ink" : "lit-headline lit-ink");
97
+ const type = b.layout === "full" || !lines.length ? "" : `\n <div class="type" data-zone="type">${lines.map((line, k) => `\n <p class="${roleOf(k)}" data-copy="${line}"></p>`).join("")}\n </div>`;
98
+ return ` <!-- shot ${i + 1}: ${String(b.purpose).replace(/--/gu, "-")} -->\n <section class="shot" data-shot="${i}">\n <svg class="subject" data-zone="subject"></svg>${type}\n </section>`;
99
+ })
100
+ .join("\n");
101
+ const draws = treatment.beats.map((b, i) => ` // shot ${i + 1} (${b.layout}): ${String(b.hero).replace(/\*\//gu, "* /")}\n (s, svg, t) => {},`).join("\n");
102
+ const solid = treatment.depth === "3d";
103
+ const worlds = treatment.beats.map((b, i) => ` // shot ${i + 1} (${b.layout})\n (s, hero, cam, t) => {},`).join("\n");
104
+ const head3d = solid ? `\n<script type="importmap">{ "imports": { "three": "/lit/three/three.module.js", "three/addons/": "/lit/three/addons/" } }</script>` : "";
105
+ const canvas3d = solid ? `<canvas id="world" width="${width}" height="${height}"></canvas>\n` : "";
106
+ const style3d = solid ? `\n #world { position: absolute; left: 0; top: 0; width: ${width}px; height: ${height}px; }` : "";
107
+ const scriptOpen = solid ? `<script type="module">\n import * as THREE from "three";\n import { RoomEnvironment } from "three/addons/environments/RoomEnvironment.js";\n` : "<script>\n";
108
+ return `<!doctype html>
109
+ <html lang="${lang}">
110
+ <head>
111
+ <meta charset="utf-8">
112
+ <link rel="stylesheet" href="/lit/fonts.css">
113
+ <link rel="stylesheet" href="/lit/style.css">
114
+ <script src="/lit/style.js"></script>
115
+ <script src="/lit/stage-kit.js"></script>${head3d}
116
+ <style>
117
+ html, body { width: ${width}px; height: ${height}px; }
118
+ .shot { position: absolute; left: 0; top: 0; width: ${width}px; height: ${height}px; visibility: hidden; }
119
+ .subject { position: absolute; overflow: visible; }
120
+ .type { display: flex; flex-direction: column; justify-content: center; gap: 0.4em; }${style3d}
121
+ </style>
122
+ </head>
123
+ <body>
124
+ ${canvas3d}${sections}
125
+ ${scriptOpen} // The film's words: every copy line of treatment.json, verbatim. Edit them here.
126
+ const COPY = ${JSON.stringify(treatment.copy.lines, null, 2).replace(/\n/gu, "\n ")};
127
+
128
+ const { define, shot, place, tokens, text, clamp, clip } = LitStage;
129
+ const T = tokens();
130
+ const BEATS = LitTimeline.beats;
131
+ const SHOTS = [...document.querySelectorAll(".shot")];
132
+ SHOTS.forEach((el, i) => {
133
+ place(el.querySelector('[data-zone="subject"]'), BEATS[i].layout, "subject");
134
+ const type = el.querySelector('[data-zone="type"]');
135
+ if (type) place(type, BEATS[i].layout, "type");
136
+ });
137
+ for (const el of document.querySelectorAll("[data-copy]")) {
138
+ el.textContent = COPY[Number(el.dataset.copy)];
139
+ text(el);
140
+ }
141
+
142
+ // One function per shot: draw the subject into its svg (the subject zone) as a function of the
143
+ // shot's progress. s is LitStage.shot(t): s.p (0..1), s.local (seconds), s.enter(delay, dur).
144
+ const DRAW = [
145
+ ${draws}
146
+ ];
147
+
148
+ // How a shot hands off to the next, over the style's exit duration before the cut.
149
+ const HANDOFF = T.dur.exit;
150
+ const handoff = { wipe: (el, p) => clip.wipe(el, p, "right"), iris: (el, p) => clip.circle(el, p), dissolve: (el, p) => { el.style.opacity = String(p); } };
151
+
152
+ function paint(i, s, t) {
153
+ const el = SHOTS[i];
154
+ el.style.visibility = "visible";
155
+ const type = el.querySelector('[data-zone="type"]');
156
+ if (type) {
157
+ const e = s.enter(0.1);
158
+ type.style.opacity = String(e);
159
+ type.style.transform = \`translateY(\${(1 - e) * 24}px)\`;
160
+ }
161
+ DRAW[i](s, el.querySelector('[data-zone="subject"]'), t);
162
+ }
163
+ ${solid ? WORLD_CODE(width, height, worlds) : ""}
164
+ define({ width: ${width}, height: ${height}, fps: ${treatment.fps ?? 60}, duration: ${treatment.durationSec}, render(t) {
165
+ for (const el of SHOTS) Object.assign(el.style, { visibility: "hidden", opacity: "", clipPath: "", transform: "", zIndex: "" });
166
+ const s = shot(t);
167
+ paint(s.index, s, t);${solid ? "\n drawWorld(s, t);" : ""}
168
+ const next = SHOTS[s.index + 1];
169
+ const into = clamp((t - (s.beat.t1 - HANDOFF)) / HANDOFF);
170
+ if (next && into > 0) {
171
+ const p = T.ease.move(into);
172
+ const kind = s.beat.transition;
173
+ if (handoff[kind]) {
174
+ next.style.zIndex = "1";
175
+ paint(s.index + 1, shot(BEATS[s.index + 1].t0), t);
176
+ handoff[kind](next, p);
177
+ } else if (kind === "push") {
178
+ SHOTS[s.index].style.transform = \`translateX(\${-p * ${width}}px)\`;
179
+ paint(s.index + 1, shot(BEATS[s.index + 1].t0), t);
180
+ next.style.transform = \`translateX(\${(1 - p) * ${width}}px)\`;
181
+ }
182
+ }
183
+ } });
184
+ </script>
185
+ </body>
186
+ </html>
187
+ `;
188
+ }
189
+
190
+ // The scaffold's word on the 3D renderer: a Blender film draws its world in stage/scene.py; a film that
191
+ // asks for high-quality 3D on a machine with Blender is pointed at that rung before any drawing starts.
192
+ function rungNote(treatment, out, env) {
193
+ if (treatment.depth !== "3d") return "";
194
+ if (treatment.render3d === "blender") return ` This is a Blender film: write the world in ${join(out, "stage", "scene.py")}, look at the preview stills (blender --out ${out}), render the plate (--final), and show it under the type with LitStage.plate() in place of the three.js world (references/depth.md, The Blender rung).`;
195
+ const found = asksPathTraced(treatment.request) ? findBlender({ env }) : null;
196
+ return found ? `\nBLENDER: ${found.path} is installed and the request asks for high-quality 3D. Take the Blender rung: set render3d "blender" in the treatment, write stage/scene.py, and keep this page for the type, labels and panels over the plate (references/depth.md, The Blender rung).` : "";
197
+ }
198
+
199
+ /** Write `<out>/stage/index.html` from the treatment; refuses to replace a page. Returns the message. */
200
+ export function scaffoldCommand({ out, env = process.env }) {
201
+ const treatment = loadTreatment(join(out, "treatment.json"));
202
+ if (treatment.path !== "stage") throw new Exit(EXIT.USAGE, "scaffold writes a stage page; this treatment takes the type path (`render.mjs film`)");
203
+ const file = join(out, "stage", "index.html");
204
+ if (existsSync(file)) throw new Exit(EXIT.USAGE, `${file} exists; scaffold never overwrites a page (move it away to start again)`);
205
+ mkdirSync(dirname(file), { recursive: true });
206
+ writeFileSync(file, scaffoldHtml(treatment));
207
+ return `SCAFFOLD: ${file} (style ${treatment.style}, ${treatment.beats.length} shots). Draw each shot's subject in its DRAW function, then render the board: stage --out ${out} --round 1 --stills-only${rungNote(treatment, out, env)}`;
208
+ }