@oh-story/dsh 0.1.4 → 0.1.6

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 (479) hide show
  1. package/README.md +56 -12
  2. package/lib/client.js +2707 -268
  3. package/lib/client.js.map +4 -4
  4. package/lib/drama/manifest.json +136 -101
  5. package/lib/drama/skills/short-drama/SKILL.md +61 -1
  6. package/lib/drama/skills/short-drama/references/contract-and-ownership.md +7 -4
  7. package/lib/drama/skills/short-drama/references/creator-documents.md +133 -8
  8. package/lib/drama/skills/short-drama/references/creator-workflow.md +38 -2
  9. package/lib/drama/skills/short-drama/references/knowhow-index.md +3 -0
  10. package/lib/drama/skills/short-drama/references/reference-roles.md +10 -7
  11. package/lib/drama/skills/short-drama/references/runtime-preflight.md +3 -0
  12. package/lib/drama/skills/short-drama/scripts/creator_markdown_check.py +1002 -0
  13. package/lib/drama/skills/short-drama/scripts/project_tool.py +485 -5
  14. package/lib/drama/skills/short-drama-assets/SKILL.md +13 -3
  15. package/lib/drama/skills/short-drama-assets/references/continuity-lock.md +116 -0
  16. package/lib/drama/skills/short-drama-assets/references/identity-vs-variant.md +2 -1
  17. package/lib/drama/skills/short-drama-assets/references/prop-and-state.md +19 -0
  18. package/lib/drama/skills/short-drama-assets/references/stage-contract.md +2 -0
  19. package/lib/drama/skills/short-drama-assets/scripts/asset_check.py +1 -1
  20. package/lib/drama/skills/short-drama-image-prompts/SKILL.md +6 -2
  21. package/lib/drama/skills/short-drama-image-prompts/references/common-recipe.md +4 -3
  22. package/lib/drama/skills/short-drama-image-prompts/references/lookdev-frame.md +1 -1
  23. package/lib/drama/skills/short-drama-image-prompts/references/review-and-fixtures.md +1 -1
  24. package/lib/drama/skills/short-drama-image-prompts/references/stage-contract.md +3 -1
  25. package/lib/drama/skills/short-drama-image-prompts/scripts/image_prompt_check.py +8 -8
  26. package/lib/drama/skills/short-drama-image-prompts/scripts/selftest.py +4 -2
  27. package/lib/drama/skills/short-drama-produce/SKILL.md +46 -10
  28. package/lib/drama/skills/short-drama-produce/references/adapter-contract.md +65 -8
  29. package/lib/drama/skills/short-drama-produce/references/providers/minimax-h3-video.md +85 -0
  30. package/lib/drama/skills/short-drama-produce/references/providers/seedance.md +27 -10
  31. package/lib/drama/skills/short-drama-produce/scripts/production_tool.py +362 -3
  32. package/lib/drama/skills/short-drama-produce/scripts/provider_adapters.py +627 -40
  33. package/lib/drama/skills/short-drama-produce/scripts/selftest.py +5 -4
  34. package/lib/drama/skills/short-drama-review/references/rubric-visual-motion.md +12 -0
  35. package/lib/drama/skills/short-drama-review/scripts/review_check.py +1 -1
  36. package/lib/drama/skills/short-drama-storyboard/SKILL.md +76 -7
  37. package/lib/drama/skills/short-drama-storyboard/assets/shot-template.jsonl +1 -1
  38. package/lib/drama/skills/short-drama-storyboard/references/keyframe-craft.md +6 -2
  39. package/lib/drama/skills/short-drama-storyboard/references/production-shot-grammar.md +19 -4
  40. package/lib/drama/skills/short-drama-storyboard/references/review-and-fixtures.md +5 -2
  41. package/lib/drama/skills/short-drama-storyboard/references/screenplay-to-keyframe-example.md +16 -0
  42. package/lib/drama/skills/short-drama-storyboard/references/stage-contract.md +8 -3
  43. package/lib/drama/skills/short-drama-storyboard/scripts/storyboard_check.py +1 -1
  44. package/lib/drama/skills/short-drama-video-prompts/SKILL.md +81 -13
  45. package/lib/drama/skills/short-drama-video-prompts/assets/motion-spec.jsonl.md +6 -1
  46. package/lib/drama/skills/short-drama-video-prompts/assets/video-prompts.md +17 -1
  47. package/lib/drama/skills/short-drama-video-prompts/references/delivery-profile.md +21 -1
  48. package/lib/drama/skills/short-drama-video-prompts/references/minimax-h3.md +154 -0
  49. package/lib/drama/skills/short-drama-video-prompts/references/motion-recipe.md +24 -6
  50. package/lib/drama/skills/short-drama-video-prompts/references/production-prompt-grammar.md +11 -7
  51. package/lib/drama/skills/short-drama-video-prompts/references/seedance-2.0.md +41 -0
  52. package/lib/drama/skills/short-drama-video-prompts/references/seedance-2.5.md +66 -0
  53. package/lib/drama/skills/short-drama-video-prompts/references/stage-contract.md +5 -2
  54. package/lib/drama/skills/short-drama-video-prompts/references/target-model-profile.md +115 -0
  55. package/lib/drama/skills/short-drama-video-prompts/scripts/container_check.py +1 -1
  56. package/lib/drama/skills/short-drama-video-prompts/scripts/music_spec_check.py +1 -1
  57. package/lib/drama/skills/short-drama-write/SKILL.md +3 -2
  58. package/lib/drama/skills/short-drama-write/scripts/duration_estimate.py +1 -1
  59. package/lib/drama/skills/short-drama-write/scripts/screenplay_index.py +2 -2
  60. package/lib/drama/skills/short-drama-write/scripts/voice_sheet_check.py +1 -1
  61. package/lib/index.js +865 -33
  62. package/lib/index.js.map +4 -4
  63. package/lib/novel-to-game/LICENSE +21 -0
  64. package/lib/novel-to-game/README.md +180 -0
  65. package/lib/novel-to-game/README_ZH.md +178 -0
  66. package/lib/novel-to-game/VERSION +1 -0
  67. package/lib/novel-to-game/examples/jin-ping-mei/build/BUILD_BRIEF.md +217 -0
  68. package/lib/novel-to-game/examples/jin-ping-mei/build/app/.vercelignore +3 -0
  69. package/lib/novel-to-game/examples/jin-ping-mei/build/app/RUN.md +130 -0
  70. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/bg/compound_new_guofeng.webp +0 -0
  71. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/fate_coda.webp +0 -0
  72. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/meng.webp +0 -0
  73. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/pan.webp +0 -0
  74. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/pinger.webp +0 -0
  75. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/xuee.webp +0 -0
  76. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/yue.webp +0 -0
  77. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_accord_five.webp +0 -0
  78. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_afterglow_five.webp +0 -0
  79. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_alliance.webp +0 -0
  80. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/public_day10.webp +0 -0
  81. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/public_day15.webp +0 -0
  82. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/public_day5.webp +0 -0
  83. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/title_new_guofeng.webp +0 -0
  84. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/pan_pinger.webp +0 -0
  85. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/pan_xuee.webp +0 -0
  86. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/yue_meng.webp +0 -0
  87. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/yue_pan.webp +0 -0
  88. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/yue_pinger.webp +0 -0
  89. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/meng/explicit.webp +0 -0
  90. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/meng/prelude.webp +0 -0
  91. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/meng.webp +0 -0
  92. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/pan.webp +0 -0
  93. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/pinger.webp +0 -0
  94. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/xuee.webp +0 -0
  95. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/yue.webp +0 -0
  96. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pan/explicit.webp +0 -0
  97. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pan/prelude.webp +0 -0
  98. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pinger/explicit.webp +0 -0
  99. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pinger/prelude.webp +0 -0
  100. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/xuee/explicit.webp +0 -0
  101. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/xuee/prelude.webp +0 -0
  102. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/yue/explicit.webp +0 -0
  103. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/yue/prelude.webp +0 -0
  104. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/meng/night.webp +0 -0
  105. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/pan/night.webp +0 -0
  106. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/pinger/night.webp +0 -0
  107. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/xuee/night.webp +0 -0
  108. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/yue/night.webp +0 -0
  109. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/household/li_jiaoer.webp +0 -0
  110. package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/scene/gate_collector.webp +0 -0
  111. package/lib/novel-to-game/examples/jin-ping-mei/build/app/css/new-guofeng.css +1105 -0
  112. package/lib/novel-to-game/examples/jin-ping-mei/build/app/css/style.css +2539 -0
  113. package/lib/novel-to-game/examples/jin-ping-mei/build/app/index.html +18 -0
  114. package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/assets.js +147 -0
  115. package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/audio.js +332 -0
  116. package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/data.js +7472 -0
  117. package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/engine.js +13077 -0
  118. package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/main.js +3028 -0
  119. package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/text.js +32 -0
  120. package/lib/novel-to-game/examples/jin-ping-mei/build/app/package.json +10 -0
  121. package/lib/novel-to-game/examples/jin-ping-mei/build/app/vercel.json +23 -0
  122. package/lib/novel-to-game/examples/jin-ping-mei/build/art/generated-art.json +161 -0
  123. package/lib/novel-to-game/examples/jin-ping-mei/example.json +12 -0
  124. package/lib/novel-to-game/examples/jin-ping-mei/qa/README.md +31 -0
  125. package/lib/novel-to-game/examples/jin-ping-mei/qa/playable-model.json +99 -0
  126. package/lib/novel-to-game/examples/jin-ping-mei/qa/verification.json +41 -0
  127. package/lib/novel-to-game/examples/jin-ping-mei/qa/verify_playable_model.mjs +129 -0
  128. package/lib/novel-to-game/manifest.json +508 -0
  129. package/lib/novel-to-game/skills/game-art-direction/SKILL.md +73 -0
  130. package/lib/novel-to-game/skills/game-art-direction/agents/openai.yaml +4 -0
  131. package/lib/novel-to-game/skills/game-art-direction/references/art-direction-method.md +119 -0
  132. package/lib/novel-to-game/skills/game-build/SKILL.md +84 -0
  133. package/lib/novel-to-game/skills/game-build/agents/openai.yaml +4 -0
  134. package/lib/novel-to-game/skills/game-build/references/build-brief-contract.md +109 -0
  135. package/lib/novel-to-game/skills/game-build/references/generative-media-pipeline.md +56 -0
  136. package/lib/novel-to-game/skills/game-build/references/playable-model-contract.md +81 -0
  137. package/lib/novel-to-game/skills/game-build/references/tts-production-contract.md +37 -0
  138. package/lib/novel-to-game/skills/game-concept/SKILL.md +72 -0
  139. package/lib/novel-to-game/skills/game-concept/agents/openai.yaml +4 -0
  140. package/lib/novel-to-game/skills/game-concept/references/concept-method.md +94 -0
  141. package/lib/novel-to-game/skills/game-qa/SKILL.md +50 -0
  142. package/lib/novel-to-game/skills/game-qa/agents/openai.yaml +4 -0
  143. package/lib/novel-to-game/skills/game-qa/references/qa-contract.md +66 -0
  144. package/lib/novel-to-game/skills/game-qa/references/test-design-method.md +45 -0
  145. package/lib/novel-to-game/skills/game-world-design/SKILL.md +63 -0
  146. package/lib/novel-to-game/skills/game-world-design/agents/openai.yaml +4 -0
  147. package/lib/novel-to-game/skills/game-world-design/references/dialogue-design-method.md +59 -0
  148. package/lib/novel-to-game/skills/game-world-design/references/game-writing-craft.md +53 -0
  149. package/lib/novel-to-game/skills/game-world-design/references/narrative-design-method.md +84 -0
  150. package/lib/novel-to-game/skills/game-world-design/references/numeric-design-method.md +56 -0
  151. package/lib/novel-to-game/skills/game-world-design/references/world-design-method.md +124 -0
  152. package/lib/novel-to-game/skills/novel-game-analyze/SKILL.md +77 -0
  153. package/lib/novel-to-game/skills/novel-game-analyze/agents/openai.yaml +4 -0
  154. package/lib/novel-to-game/skills/novel-game-analyze/references/gameability-protocol.md +65 -0
  155. package/lib/novel-to-game/skills/novel-to-game/SKILL.md +71 -0
  156. package/lib/novel-to-game/skills/novel-to-game/agents/openai.yaml +4 -0
  157. package/lib/novel-to-game/skills/novel-to-game/references/intake-benchmark-reference.md +42 -0
  158. package/lib/novel-to-game/skills/novel-to-game/references/intake-method.md +51 -0
  159. package/lib/novel-to-game/skills/novel-to-game/references/pipeline-contract.md +65 -0
  160. package/lib/oh-story/manifest.json +415 -305
  161. package/lib/oh-story/roles/consistency-checker.md +1 -1
  162. package/lib/oh-story/roles/narrative-writer.md +32 -33
  163. package/lib/oh-story/roles/story-architect.md +16 -26
  164. package/lib/oh-story/skills/browser-cdp/SKILL.md +1 -1
  165. package/lib/oh-story/skills/story/SKILL.md +16 -9
  166. package/lib/oh-story/skills/story/VERSION +1 -1
  167. package/lib/oh-story/skills/story/references/author-memory.md +163 -0
  168. package/lib/oh-story/skills/story/scripts/author_memory_commit.py +871 -0
  169. package/lib/oh-story/skills/story-cover/SKILL.md +1 -1
  170. package/lib/oh-story/skills/story-deslop/SKILL.md +10 -5
  171. package/lib/oh-story/skills/story-deslop/references/anti-ai-writing.md +2 -1
  172. package/lib/oh-story/skills/story-deslop/references/author-memory.md +163 -0
  173. package/lib/oh-story/skills/story-deslop/references/banned-words.md +6 -4
  174. package/lib/oh-story/skills/story-deslop/scripts/author_memory_commit.py +871 -0
  175. package/lib/oh-story/skills/story-deslop/scripts/check-ai-patterns.js +64 -1
  176. package/lib/oh-story/skills/story-import/SKILL.md +19 -10
  177. package/lib/oh-story/skills/story-import/references/format-and-structure.md +9 -10
  178. package/lib/oh-story/skills/story-import/references/structure-mapping-long.md +2 -2
  179. package/lib/oh-story/skills/story-import/references/structure-mapping-short.md +1 -1
  180. package/lib/oh-story/skills/story-import/references/tracking-transaction.md +14 -6
  181. package/lib/oh-story/skills/story-import/scripts/check-outline-contract.js +251 -0
  182. package/lib/oh-story/skills/story-import/scripts/tracking_commit.py +98 -9
  183. package/lib/oh-story/skills/story-import/scripts/wordcount_core.py +246 -0
  184. package/lib/oh-story/skills/story-long-analyze/SKILL.md +4 -4
  185. package/lib/oh-story/skills/story-long-scan/SKILL.md +1 -1
  186. package/lib/oh-story/skills/story-long-write/SKILL.md +35 -21
  187. package/lib/oh-story/skills/story-long-write/references/anti-ai-writing.md +2 -1
  188. package/lib/oh-story/skills/story-long-write/references/artifact-protocols.md +7 -3
  189. package/lib/oh-story/skills/story-long-write/references/author-memory.md +163 -0
  190. package/lib/oh-story/skills/story-long-write/references/banned-words.md +6 -4
  191. package/lib/oh-story/skills/story-long-write/references/cross-book-recall.md +6 -6
  192. package/lib/oh-story/skills/story-long-write/references/genre-prose-cards.md +1 -1
  193. package/lib/oh-story/skills/story-long-write/references/genre-readers.md +1 -1
  194. package/lib/oh-story/skills/{story-setup/references/agent-references/hooks-chapter.md → story-long-write/references/long-chapter-hooks.md} +5 -5
  195. package/lib/oh-story/skills/story-long-write/references/{quality-checklist.md → long-chapter-quality.md} +2 -1
  196. package/lib/oh-story/skills/story-long-write/references/long-format.md +42 -0
  197. package/lib/oh-story/skills/{story-setup/references/agent-references/genre-catalog.md → story-long-write/references/long-genre-catalog.md} +11 -97
  198. package/lib/oh-story/skills/{story-setup/references/agent-references/genre-core-mechanics.md → story-long-write/references/long-genre-mechanics.md} +1 -1
  199. package/lib/oh-story/skills/{story-short-write/references/reversal-toolkit.md → story-long-write/references/long-reversal.md} +18 -32
  200. package/lib/oh-story/skills/story-long-write/references/{hooks-suspense.md → long-suspense.md} +6 -6
  201. package/lib/oh-story/skills/story-long-write/references/opening-design.md +1 -1
  202. package/lib/oh-story/skills/story-long-write/references/outline-structure-theory.md +1 -1
  203. package/lib/oh-story/skills/story-long-write/references/style-genre-modules.md +1 -1
  204. package/lib/oh-story/skills/story-long-write/references/tracking-transaction.md +14 -6
  205. package/lib/oh-story/skills/story-long-write/references/workflow-chapter.md +32 -27
  206. package/lib/oh-story/skills/story-long-write/references/workflow-daily.md +4 -4
  207. package/lib/oh-story/skills/story-long-write/references/workflow-revision.md +2 -2
  208. package/lib/oh-story/skills/story-long-write/references/workflow-setup.md +14 -14
  209. package/lib/oh-story/skills/story-long-write/references/writing-craft.md +54 -54
  210. package/lib/oh-story/skills/story-long-write/scripts/author_memory_commit.py +871 -0
  211. package/lib/oh-story/skills/story-long-write/scripts/check-ai-patterns.js +64 -1
  212. package/lib/oh-story/skills/story-long-write/scripts/check-outline-contract.js +251 -0
  213. package/lib/oh-story/skills/story-long-write/scripts/storyctl.py +303 -0
  214. package/lib/oh-story/skills/story-long-write/scripts/tracking_commit.py +98 -9
  215. package/lib/oh-story/skills/story-long-write/scripts/wordcount_core.py +246 -0
  216. package/lib/oh-story/skills/story-review/SKILL.md +26 -17
  217. package/lib/oh-story/skills/story-review/references/anti-ai-writing.md +2 -1
  218. package/lib/oh-story/skills/story-review/references/author-memory.md +163 -0
  219. package/lib/oh-story/skills/story-review/references/banned-words.md +6 -4
  220. package/lib/oh-story/skills/story-review/references/{quality-checklist.md → review-quality.md} +22 -21
  221. package/lib/oh-story/skills/story-review/references/tracking-transaction.md +14 -6
  222. package/lib/oh-story/skills/story-review/scripts/author_memory_commit.py +871 -0
  223. package/lib/oh-story/skills/story-review/scripts/check-ai-patterns.js +64 -1
  224. package/lib/oh-story/skills/story-review/scripts/tracking_commit.py +98 -9
  225. package/lib/oh-story/skills/story-review/scripts/wordcount_core.py +246 -0
  226. package/lib/oh-story/skills/story-setup/SKILL.md +74 -33
  227. package/lib/oh-story/skills/story-setup/references/agent-references/agent-quality.md +72 -0
  228. package/lib/oh-story/skills/story-setup/references/agent-references/agent-reference-profiles.md +55 -0
  229. package/lib/oh-story/skills/story-setup/references/agent-references/anti-ai-writing.md +2 -1
  230. package/lib/oh-story/skills/story-setup/references/agent-references/banned-words.md +6 -4
  231. package/lib/oh-story/skills/story-setup/references/agent-references/format-and-structure.md +9 -10
  232. package/lib/oh-story/skills/story-setup/references/agent-references/genre-prose-cards.md +1 -1
  233. package/lib/oh-story/skills/story-setup/references/agent-references/genre-readers.md +1 -1
  234. package/lib/oh-story/skills/{story-short-analyze/references/hooks-chapter.md → story-setup/references/agent-references/long-chapter-hooks.md} +5 -5
  235. package/lib/oh-story/skills/story-setup/references/agent-references/long-emotional-methods.md +209 -0
  236. package/lib/oh-story/skills/{story-long-write/references/genre-catalog.md → story-setup/references/agent-references/long-genre-catalog.md} +11 -97
  237. package/lib/oh-story/skills/{story-long-write/references/genre-core-mechanics.md → story-setup/references/agent-references/long-genre-mechanics.md} +1 -1
  238. package/lib/oh-story/skills/story-setup/references/agent-references/long-quality.md +40 -0
  239. package/lib/oh-story/skills/story-setup/references/agent-references/{reversal-toolkit.md → long-reversal.md} +18 -32
  240. package/lib/oh-story/skills/{story-short-write/references/hooks-suspense.md → story-setup/references/agent-references/long-suspense.md} +6 -6
  241. package/lib/oh-story/skills/story-setup/references/agent-references/opening-design.md +1 -1
  242. package/lib/oh-story/skills/story-setup/references/agent-references/{emotional-methods.md → short-emotional-methods.md} +4 -4
  243. package/lib/oh-story/skills/{story-long-write/references/genre-writing-formulas.md → story-setup/references/agent-references/short-genre-formulas.md} +32 -44
  244. package/lib/oh-story/skills/story-setup/references/agent-references/short-quality.md +39 -0
  245. package/lib/oh-story/skills/{story-long-write/references/reversal-toolkit.md → story-setup/references/agent-references/short-reversal.md} +29 -23
  246. package/lib/oh-story/skills/story-setup/references/agent-references/{hooks-suspense.md → short-suspense.md} +31 -31
  247. package/lib/oh-story/skills/story-setup/references/agent-references/style-genre-modules.md +1 -1
  248. package/lib/oh-story/skills/story-setup/references/agent-references/writing-craft.md +55 -55
  249. package/lib/oh-story/skills/story-short-analyze/SKILL.md +28 -28
  250. package/lib/oh-story/skills/story-short-analyze/references/{character-basics.md → analysis-character-basics.md} +1 -1
  251. package/lib/oh-story/skills/story-short-analyze/references/{character-design-methods.md → analysis-character-design.md} +1 -1
  252. package/lib/oh-story/skills/story-short-analyze/references/{character-relations.md → analysis-character-relations.md} +1 -1
  253. package/lib/oh-story/skills/story-short-analyze/references/{hooks-paragraph.md → analysis-paragraph-hooks.md} +1 -1
  254. package/lib/oh-story/skills/story-short-analyze/references/{genre-readers.md → analysis-reader-profile.md} +2 -2
  255. package/lib/oh-story/skills/story-short-analyze/references/analysis-report-style.md +45 -0
  256. package/lib/oh-story/skills/story-short-analyze/references/analysis-short-genres.md +65 -0
  257. package/lib/oh-story/skills/story-short-analyze/references/analysis-short-hooks.md +77 -0
  258. package/lib/oh-story/skills/story-short-analyze/references/analysis-short-mechanics.md +82 -0
  259. package/lib/oh-story/skills/story-short-analyze/references/analysis-short-patterns.md +50 -0
  260. package/lib/oh-story/skills/story-short-analyze/references/analysis-short-suspense.md +98 -0
  261. package/lib/oh-story/skills/story-short-analyze/references/{genre-writing-techniques.md → analysis-writing-techniques.md} +21 -19
  262. package/lib/oh-story/skills/story-short-analyze/references/deconstruction-examples.md +1 -1
  263. package/lib/oh-story/skills/story-short-analyze/references/material-decomposition.md +21 -28
  264. package/lib/oh-story/skills/story-short-analyze/references/output-contract.md +1 -1
  265. package/lib/oh-story/skills/story-short-analyze/references/output-templates.md +17 -17
  266. package/lib/oh-story/skills/story-short-analyze/references/{quality-checklist.md → source-story-quality.md} +28 -49
  267. package/lib/oh-story/skills/story-short-analyze/references/zhihu-style.md +2 -2
  268. package/lib/oh-story/skills/story-short-scan/SKILL.md +1 -1
  269. package/lib/oh-story/skills/story-short-write/SKILL.md +78 -55
  270. package/lib/oh-story/skills/story-short-write/references/author-memory.md +163 -0
  271. package/lib/oh-story/skills/story-short-write/references/banned-words.md +6 -4
  272. package/lib/oh-story/skills/story-short-write/references/cross-book-recall.md +3 -3
  273. package/lib/oh-story/skills/story-short-write/references/emotional-methods.md +4 -4
  274. package/lib/oh-story/skills/story-short-write/references/genre-styles//344/270/226/346/203/205/346/211/223/350/204/270.md +3 -3
  275. package/lib/oh-story/skills/story-short-write/references/genre-styles//345/217/214/347/224/267/344/270/273.md +2 -2
  276. package/lib/oh-story/skills/story-short-write/references/genre-styles//345/244/215/344/273/207/346/211/223/350/204/270.md +3 -3
  277. package/lib/oh-story/skills/story-short-write/references/genre-styles//345/256/205/346/226/227/345/256/253/346/226/227.md +6 -6
  278. package/lib/oh-story/skills/story-short-write/references/genre-styles//346/200/273/350/243/201/350/261/252/351/227/250.md +3 -3
  279. package/lib/oh-story/skills/story-short-write/references/genre-styles//346/202/254/347/226/221.md +4 -4
  280. package/lib/oh-story/skills/story-short-write/references/genre-styles//346/260/221/344/277/227/346/200/252/350/260/210.md +7 -7
  281. package/lib/oh-story/skills/story-short-write/references/genre-styles//346/262/231/351/233/225/350/204/221/346/264/236.md +5 -5
  282. package/lib/oh-story/skills/story-short-write/references/genre-styles//347/224/234/345/256/240.md +4 -4
  283. package/lib/oh-story/skills/story-short-write/references/genre-styles//350/277/275/345/246/273/347/201/253/350/221/254/345/234/272.md +3 -3
  284. package/lib/oh-story/skills/story-short-write/references/genre-writing-formulas.md +32 -44
  285. package/lib/oh-story/skills/story-short-write/references/genre-writing-techniques.md +20 -18
  286. package/lib/oh-story/skills/story-short-write/references/output-contract.md +1 -1
  287. package/lib/oh-story/skills/story-short-write/references/short-craft.md +18 -18
  288. package/lib/oh-story/skills/story-short-write/references/short-deslop.md +1 -1
  289. package/lib/oh-story/skills/story-short-write/references/short-format.md +38 -8
  290. package/lib/oh-story/skills/story-short-write/references/{quality-checklist.md → short-prose-quality.md} +22 -21
  291. package/lib/oh-story/skills/story-short-write/references/short-reversal.md +355 -0
  292. package/lib/oh-story/skills/{story-short-analyze/references/hooks-suspense.md → story-short-write/references/short-suspense.md} +31 -31
  293. package/lib/oh-story/skills/story-short-write/references/submission-craft.md +2 -2
  294. package/lib/oh-story/skills/story-short-write/references/writing-workflow.md +31 -22
  295. package/lib/oh-story/skills/story-short-write/scripts/author_memory_commit.py +871 -0
  296. package/lib/oh-story/skills/story-short-write/scripts/check-ai-patterns.js +64 -1
  297. package/lib/oh-story/skills/story-short-write/scripts/check-delivery-contract.js +212 -0
  298. package/lib/oh-story/skills/story-short-write/scripts/check-phase2-contract.js +363 -0
  299. package/lib/types/client/drama-production-view.d.ts +34 -0
  300. package/lib/types/client/drama-production-view.d.ts.map +1 -0
  301. package/lib/types/client/drama-production.d.ts +92 -0
  302. package/lib/types/client/drama-production.d.ts.map +1 -0
  303. package/lib/types/client/file-activity.d.ts +4 -2
  304. package/lib/types/client/file-activity.d.ts.map +1 -1
  305. package/lib/types/client/index.d.ts +1 -1
  306. package/lib/types/client/index.d.ts.map +1 -1
  307. package/lib/types/client/production-intents.d.ts +9 -0
  308. package/lib/types/client/production-intents.d.ts.map +1 -0
  309. package/lib/types/client/production-prompts.d.ts +9 -0
  310. package/lib/types/client/production-prompts.d.ts.map +1 -0
  311. package/lib/types/client/production-runtime.d.ts +58 -0
  312. package/lib/types/client/production-runtime.d.ts.map +1 -0
  313. package/lib/types/client/video-studio.d.ts +41 -0
  314. package/lib/types/client/video-studio.d.ts.map +1 -0
  315. package/lib/types/client/workbench-ui.d.ts +5 -0
  316. package/lib/types/client/workbench-ui.d.ts.map +1 -0
  317. package/lib/types/game-verification.d.ts +16 -0
  318. package/lib/types/game-verification.d.ts.map +1 -0
  319. package/lib/types/index.d.ts +3 -1
  320. package/lib/types/index.d.ts.map +1 -1
  321. package/lib/types/production-intent.d.ts +21 -0
  322. package/lib/types/production-intent.d.ts.map +1 -0
  323. package/lib/types/production-tool.d.ts +5 -0
  324. package/lib/types/production-tool.d.ts.map +1 -0
  325. package/lib/types/role-tool.d.ts.map +1 -1
  326. package/lib/types/skill-provider.d.ts +7 -0
  327. package/lib/types/skill-provider.d.ts.map +1 -1
  328. package/lib/types/video-project.d.ts +42 -0
  329. package/lib/types/video-project.d.ts.map +1 -0
  330. package/lib/types/workspace-request-trust.d.ts +6 -0
  331. package/lib/types/workspace-request-trust.d.ts.map +1 -1
  332. package/lib/types/workspace-route.d.ts +20 -0
  333. package/lib/types/workspace-route.d.ts.map +1 -1
  334. package/lib/video-recap/CHANGELOG.md +282 -0
  335. package/lib/video-recap/LICENSE +21 -0
  336. package/lib/video-recap/README.en.md +257 -0
  337. package/lib/video-recap/README.md +255 -0
  338. package/lib/video-recap/manifest.json +684 -0
  339. package/lib/video-recap/skills/video-assemble/SKILL.md +97 -0
  340. package/lib/video-recap/skills/video-assemble/references/jianying/LICENSE.duo-video +21 -0
  341. package/lib/video-recap/skills/video-assemble/references/jianying/SOURCE.md +15 -0
  342. package/lib/video-recap/skills/video-assemble/references/jianying/empty_draft_meta_info.json +69 -0
  343. package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_combination_segment.json +84 -0
  344. package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_combination_video_material.json +98 -0
  345. package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_draft.json +204 -0
  346. package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_material_video.json +83 -0
  347. package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_meta_material_value.json +23 -0
  348. package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_project_info.json +133 -0
  349. package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_segment.json +70 -0
  350. package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_text_styles.json +30 -0
  351. package/lib/video-recap/skills/video-assemble/references/jianying/empty_yj_material_audio.json +41 -0
  352. package/lib/video-recap/skills/video-assemble/references/jianying/empty_yj_material_text.json +109 -0
  353. package/lib/video-recap/skills/video-assemble/scripts/artifacts.py +88 -0
  354. package/lib/video-recap/skills/video-assemble/scripts/assemble.py +345 -0
  355. package/lib/video-recap/skills/video-assemble/scripts/assemble_constants.py +34 -0
  356. package/lib/video-recap/skills/video-assemble/scripts/assembly_contract.py +305 -0
  357. package/lib/video-recap/skills/video-assemble/scripts/assembly_settings.py +94 -0
  358. package/lib/video-recap/skills/video-assemble/scripts/audio_automation.py +205 -0
  359. package/lib/video-recap/skills/video-assemble/scripts/audio_mix.py +555 -0
  360. package/lib/video-recap/skills/video-assemble/scripts/export_jianying.py +261 -0
  361. package/lib/video-recap/skills/video-assemble/scripts/jianying_builders.py +767 -0
  362. package/lib/video-recap/skills/video-assemble/scripts/jianying_model.py +111 -0
  363. package/lib/video-recap/skills/video-assemble/scripts/jianying_optional.py +24 -0
  364. package/lib/video-recap/skills/video-assemble/scripts/jianying_schema.py +109 -0
  365. package/lib/video-recap/skills/video-assemble/scripts/jianying_templates.py +37 -0
  366. package/lib/video-recap/skills/video-assemble/scripts/jianying_timeline_contract.py +191 -0
  367. package/lib/video-recap/skills/video-assemble/scripts/jianying_tracks.py +75 -0
  368. package/lib/video-recap/skills/video-assemble/scripts/jianying_writer.py +394 -0
  369. package/lib/video-recap/skills/video-assemble/scripts/lib.py +239 -0
  370. package/lib/video-recap/skills/video-assemble/scripts/media.py +243 -0
  371. package/lib/video-recap/skills/video-assemble/scripts/narration_audio.py +477 -0
  372. package/lib/video-recap/skills/video-assemble/scripts/render_preflight.py +46 -0
  373. package/lib/video-recap/skills/video-assemble/scripts/source_subtitles.py +486 -0
  374. package/lib/video-recap/skills/video-assemble/scripts/subtitle_core.py +376 -0
  375. package/lib/video-recap/skills/video-assemble/scripts/subtitle_render.py +88 -0
  376. package/lib/video-recap/skills/video-assemble/scripts/timeline.py +248 -0
  377. package/lib/video-recap/skills/video-assemble/scripts/timeline_emit.py +89 -0
  378. package/lib/video-recap/skills/video-assemble/scripts/visual_render.py +512 -0
  379. package/lib/video-recap/skills/video-cut/SKILL.md +90 -0
  380. package/lib/video-recap/skills/video-cut/scripts/cut.py +67 -0
  381. package/lib/video-recap/skills/video-cut/scripts/cut_cli.py +320 -0
  382. package/lib/video-recap/skills/video-cut/scripts/cut_contract.py +545 -0
  383. package/lib/video-recap/skills/video-cut/scripts/cut_render.py +348 -0
  384. package/lib/video-recap/skills/video-cut/scripts/lib.py +77 -0
  385. package/lib/video-recap/skills/video-cut/scripts/media_geometry.py +341 -0
  386. package/lib/video-recap/skills/video-cut/scripts/narration_mapping.py +249 -0
  387. package/lib/video-recap/skills/video-cut/scripts/sentence_boundaries.py +745 -0
  388. package/lib/video-recap/skills/video-recap/SKILL.md +216 -0
  389. package/lib/video-recap/skills/video-recap/references/config-playbook.md +61 -0
  390. package/lib/video-recap/skills/video-recap/references/creative-editing-playbook.md +225 -0
  391. package/lib/video-recap/skills/video-recap/references/data-schema.md +534 -0
  392. package/lib/video-recap/skills/video-recap/references/research-guide.md +74 -0
  393. package/lib/video-recap/skills/video-recap/references/shift-left-qc-schema.md +23 -0
  394. package/lib/video-recap/skills/video-recap/references/timeline-and-jianying.md +251 -0
  395. package/lib/video-recap/skills/video-recap/scripts/doctor.py +483 -0
  396. package/lib/video-recap/skills/video-recap/scripts/final_qc.py +737 -0
  397. package/lib/video-recap/skills/video-recap/scripts/lib.py +242 -0
  398. package/lib/video-recap/skills/video-recap/scripts/materials.py +457 -0
  399. package/lib/video-recap/skills/video-recap/scripts/mimo_qc.py +95 -0
  400. package/lib/video-recap/skills/video-recap/scripts/mimo_qc_client.py +18 -0
  401. package/lib/video-recap/skills/video-recap/scripts/mimo_qc_contract.py +9 -0
  402. package/lib/video-recap/skills/video-recap/scripts/mimo_qc_evidence.py +371 -0
  403. package/lib/video-recap/skills/video-recap/scripts/mimo_qc_observations.py +201 -0
  404. package/lib/video-recap/skills/video-recap/scripts/mimo_qc_payload.py +227 -0
  405. package/lib/video-recap/skills/video-recap/scripts/mimo_qc_report.py +362 -0
  406. package/lib/video-recap/skills/video-recap/scripts/mimo_qc_runner.py +129 -0
  407. package/lib/video-recap/skills/video-recap/scripts/qc_contract.py +338 -0
  408. package/lib/video-recap/skills/video-recap/scripts/recap.py +9 -0
  409. package/lib/video-recap/skills/video-recap/scripts/recap_cli.py +140 -0
  410. package/lib/video-recap/skills/video-recap/scripts/recap_inspect.py +550 -0
  411. package/lib/video-recap/skills/video-recap/scripts/recap_review.py +77 -0
  412. package/lib/video-recap/skills/video-recap/scripts/recap_runner.py +654 -0
  413. package/lib/video-recap/skills/video-recap/scripts/recap_runtime.py +335 -0
  414. package/lib/video-recap/skills/video-recap/scripts/recap_stage_qc.py +217 -0
  415. package/lib/video-recap/skills/video-recap/scripts/recap_timeline.py +795 -0
  416. package/lib/video-recap/skills/video-script/SKILL.md +248 -0
  417. package/lib/video-recap/skills/video-script/references/creative-editing-playbook.md +225 -0
  418. package/lib/video-recap/skills/video-script/references/research-guide.md +75 -0
  419. package/lib/video-recap/skills/video-script/scripts/agent_brief.py +399 -0
  420. package/lib/video-recap/skills/video-script/scripts/agent_text.py +410 -0
  421. package/lib/video-recap/skills/video-script/scripts/brief_context.py +403 -0
  422. package/lib/video-recap/skills/video-script/scripts/brief_inputs.py +332 -0
  423. package/lib/video-recap/skills/video-script/scripts/brief_timeline.py +442 -0
  424. package/lib/video-recap/skills/video-script/scripts/deslop_qc.py +237 -0
  425. package/lib/video-recap/skills/video-script/scripts/evidence_bundle.py +492 -0
  426. package/lib/video-recap/skills/video-script/scripts/lib.py +327 -0
  427. package/lib/video-recap/skills/video-script/scripts/narration.py +12 -0
  428. package/lib/video-recap/skills/video-script/scripts/narration_lint.py +678 -0
  429. package/lib/video-recap/skills/video-script/scripts/review.py +42 -0
  430. package/lib/video-recap/skills/video-script/scripts/review_grounding.py +262 -0
  431. package/lib/video-recap/skills/video-script/scripts/review_response.py +761 -0
  432. package/lib/video-recap/skills/video-script/scripts/review_runner.py +200 -0
  433. package/lib/video-recap/skills/video-script/scripts/speech_ownership.py +204 -0
  434. package/lib/video-recap/skills/video-script/scripts/timeline_fusion.py +199 -0
  435. package/lib/video-recap/skills/video-script/scripts/validate.py +164 -0
  436. package/lib/video-recap/skills/video-understanding/SKILL.md +75 -0
  437. package/lib/video-recap/skills/video-understanding/references/data-schema.md +299 -0
  438. package/lib/video-recap/skills/video-understanding/references/prompt-templates.md +37 -0
  439. package/lib/video-recap/skills/video-understanding/references/research-guide.md +74 -0
  440. package/lib/video-recap/skills/video-understanding/scripts/agent_brief.py +399 -0
  441. package/lib/video-recap/skills/video-understanding/scripts/agent_text.py +410 -0
  442. package/lib/video-recap/skills/video-understanding/scripts/asr.py +260 -0
  443. package/lib/video-recap/skills/video-understanding/scripts/brief.py +12 -0
  444. package/lib/video-recap/skills/video-understanding/scripts/brief_context.py +403 -0
  445. package/lib/video-recap/skills/video-understanding/scripts/brief_inputs.py +332 -0
  446. package/lib/video-recap/skills/video-understanding/scripts/brief_timeline.py +442 -0
  447. package/lib/video-recap/skills/video-understanding/scripts/consolidate.py +647 -0
  448. package/lib/video-recap/skills/video-understanding/scripts/deslop_qc.py +237 -0
  449. package/lib/video-recap/skills/video-understanding/scripts/detect.py +513 -0
  450. package/lib/video-recap/skills/video-understanding/scripts/extract.py +62 -0
  451. package/lib/video-recap/skills/video-understanding/scripts/lib.py +470 -0
  452. package/lib/video-recap/skills/video-understanding/scripts/narration_lint.py +678 -0
  453. package/lib/video-recap/skills/video-understanding/scripts/speech_ownership.py +204 -0
  454. package/lib/video-recap/skills/video-understanding/scripts/storyboard.py +507 -0
  455. package/lib/video-recap/skills/video-understanding/scripts/timeline_fusion.py +199 -0
  456. package/lib/video-recap/skills/video-understanding/scripts/understand.py +9 -0
  457. package/lib/video-recap/skills/video-understanding/scripts/understanding_brief.py +216 -0
  458. package/lib/video-recap/skills/video-understanding/scripts/understanding_cache.py +327 -0
  459. package/lib/video-recap/skills/video-understanding/scripts/understanding_runner.py +367 -0
  460. package/lib/video-recap/skills/video-understanding/scripts/understanding_storyboard.py +162 -0
  461. package/lib/video-recap/skills/video-understanding/scripts/vlm.py +705 -0
  462. package/lib/video-recap/skills/video-voiceover/SKILL.md +81 -0
  463. package/lib/video-recap/skills/video-voiceover/scripts/dub.py +637 -0
  464. package/lib/video-recap/skills/video-voiceover/scripts/fish_audio.py +109 -0
  465. package/lib/video-recap/skills/video-voiceover/scripts/lib.py +421 -0
  466. package/lib/video-recap/skills/video-voiceover/scripts/tts_audio.py +113 -0
  467. package/lib/video-recap/skills/video-voiceover/scripts/voiceover.py +782 -0
  468. package/package.json +55 -40
  469. package/lib/oh-story/skills/story-deslop/scripts/check-outline-copy.js +0 -241
  470. package/lib/oh-story/skills/story-long-write/references/format-and-structure.md +0 -169
  471. package/lib/oh-story/skills/story-setup/references/agent-references/genre-writing-formulas.md +0 -444
  472. package/lib/oh-story/skills/story-setup/references/agent-references/quality-checklist.md +0 -247
  473. package/lib/oh-story/skills/story-short-analyze/references/anti-ai-writing.md +0 -582
  474. package/lib/oh-story/skills/story-short-analyze/references/banned-words.md +0 -147
  475. package/lib/oh-story/skills/story-short-analyze/references/genre-catalog.md +0 -490
  476. package/lib/oh-story/skills/story-short-analyze/references/genre-core-mechanics.md +0 -425
  477. package/lib/oh-story/skills/story-short-analyze/references/genre-writing-formulas.md +0 -453
  478. /package/lib/oh-story/skills/{story-long-write/references/hooks-chapter.md → story-setup/references/agent-references/short-chapter-hooks.md} +0 -0
  479. /package/lib/oh-story/skills/{story-long-write/references/hooks-paragraph.md → story-setup/references/agent-references/short-paragraph-hooks.md} +0 -0
@@ -0,0 +1,327 @@
1
+ """Own understanding-stage cache keys, provenance, and statuses."""
2
+
3
+ import hashlib
4
+
5
+ import json
6
+
7
+ from pathlib import Path
8
+
9
+ from extract import FRAME_TIME_CONVENTION_VERSION
10
+ from lib import CONFIG, log, file_fingerprint, load_prompt
11
+
12
+
13
+ from vlm import (
14
+ _is_mimo_chunk_usable,
15
+ )
16
+
17
+
18
+ def _fresh(out, *inputs):
19
+ out = Path(out)
20
+ if not out.exists():
21
+ return False
22
+ ins = [Path(p) for p in inputs if p and Path(p).exists()]
23
+ if not ins:
24
+ return out.stat().st_size > 0
25
+ return out.stat().st_mtime >= max(p.stat().st_mtime for p in ins)
26
+
27
+
28
+ def _artifact_meta_path(artifact_path):
29
+ artifact_path = Path(artifact_path)
30
+ return artifact_path.with_name(f"{artifact_path.name}.meta.json")
31
+
32
+
33
+ def _load_json(path):
34
+ return json.loads(Path(path).read_text(encoding="utf-8"))
35
+
36
+
37
+ def _artifact_fingerprint(path):
38
+ path = Path(path)
39
+ return file_fingerprint(path) if path.exists() else None
40
+
41
+
42
+ def _stage_cache_valid(artifact_path, expected_meta):
43
+ artifact_path = Path(artifact_path)
44
+ if not artifact_path.exists():
45
+ return False
46
+ meta_path = _artifact_meta_path(artifact_path)
47
+ if not meta_path.exists():
48
+ return False
49
+ try:
50
+ meta = _load_json(meta_path)
51
+ except (OSError, ValueError, TypeError):
52
+ return False
53
+ recorded = meta.get("artifact_fingerprint") if isinstance(meta, dict) else None
54
+ if not recorded or recorded != _artifact_fingerprint(artifact_path):
55
+ return False
56
+ expected = dict(expected_meta)
57
+ expected["artifact_fingerprint"] = recorded
58
+ return meta == expected
59
+
60
+
61
+ def _write_stage_meta(artifact_path, meta):
62
+ meta_path = _artifact_meta_path(artifact_path)
63
+ payload = dict(meta)
64
+ payload["artifact_fingerprint"] = _artifact_fingerprint(artifact_path)
65
+ meta_path.write_text(
66
+ json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8"
67
+ )
68
+
69
+
70
+ def _remove_stage_meta(artifact_path):
71
+ _artifact_meta_path(artifact_path).unlink(missing_ok=True)
72
+
73
+
74
+ def _short_status_message(message, limit=240):
75
+ """Compact optional-stage messages for sidecars; no tracebacks or bulky payloads."""
76
+ text = " ".join(str(message or "").split())
77
+ return text[:limit]
78
+
79
+
80
+ def _write_optional_stage_status(work_dir, filename, payload):
81
+ path = Path(work_dir) / filename
82
+ safe = dict(payload)
83
+ safe["message"] = _short_status_message(safe.get("message", ""))
84
+ path.write_text(json.dumps(safe, ensure_ascii=False, indent=2), encoding="utf-8")
85
+ return path
86
+
87
+
88
+ def _write_mimo_overview_status(
89
+ work_dir, status, message="", artifact=None, *, enabled=None
90
+ ):
91
+ return _write_optional_stage_status(
92
+ work_dir,
93
+ "mimo_video_overview.status.json",
94
+ {
95
+ "stage": "mimo_video_overview",
96
+ "enabled": bool(CONFIG.get("mimo_video_overview", False))
97
+ if enabled is None
98
+ else bool(enabled),
99
+ "status": status,
100
+ "message": message,
101
+ "artifact": artifact,
102
+ },
103
+ )
104
+
105
+
106
+ def _merge_overview_into_scenes(scenes, overview_path):
107
+ """Make the MiMo video-overview the PRIMARY per-scene description when present.
108
+
109
+ The frame VLM still provides `frame_facts` (timestamped grounding) and `depth_analysis`;
110
+ this only replaces the per-scene `description` with the motion-aware video-overview analysis,
111
+ keeping the original frame description under `frame_description` for provenance/fallback.
112
+ Scenes whose overview chunk was missing or moderation-rejected keep the frame description.
113
+
114
+ In-memory only — `vlm_analysis.json` on disk stays the pure frame-VLM product, so the VLM
115
+ cache stays coherent and the merge is re-derived (frames + overview) every run. Because
116
+ `frame_facts` is untouched, `assess_understanding_substrate` (which grades on frame_facts +
117
+ ASR) cannot regress; richer descriptions can only help.
118
+ """
119
+ overview = _load_json(overview_path) if Path(overview_path).exists() else None
120
+ if not isinstance(overview, dict):
121
+ return scenes
122
+ by_scene = {}
123
+ for chunk in overview.get("chunks") or []:
124
+ if not isinstance(chunk, dict):
125
+ continue
126
+ content = str(chunk.get("content", "")).strip()
127
+ if content and _is_mimo_chunk_usable(content):
128
+ by_scene.setdefault(chunk.get("scene_id"), []).append(content)
129
+ if not by_scene:
130
+ return scenes
131
+ enriched = 0
132
+ for scene in scenes or []:
133
+ if not isinstance(scene, dict):
134
+ continue
135
+ contents = by_scene.get(scene.get("scene_id"))
136
+ if not contents:
137
+ continue
138
+ scene.setdefault("frame_description", scene.get("description", ""))
139
+ scene["description"] = "\n".join(contents)
140
+ scene["description_source"] = "mimo_video_overview"
141
+ enriched += 1
142
+ if enriched:
143
+ log(
144
+ f"已用 MiMo 视频概览增强 {enriched} 个场景的描述(逐帧 frame_facts 保留作锚点)"
145
+ )
146
+ return scenes
147
+
148
+
149
+ def _write_consolidation_status(
150
+ work_dir,
151
+ status,
152
+ message="",
153
+ artifacts=None,
154
+ *,
155
+ enabled=True,
156
+ do_asr=False,
157
+ do_index=True,
158
+ ):
159
+ return _write_optional_stage_status(
160
+ work_dir,
161
+ "consolidation.status.json",
162
+ {
163
+ "stage": "consolidation",
164
+ "enabled": bool(enabled),
165
+ "do_asr": bool(do_asr),
166
+ "do_index": bool(do_index),
167
+ "status": status,
168
+ "message": message,
169
+ "artifacts": list(artifacts or []),
170
+ },
171
+ )
172
+
173
+
174
+ def _present_consolidation_artifacts(work_dir):
175
+ work_dir = Path(work_dir)
176
+ return [
177
+ name
178
+ for name in ("understanding_index.json", "asr_clean.json")
179
+ if (work_dir / name).exists()
180
+ ]
181
+
182
+
183
+ def _scene_cache_payload(video_path):
184
+ return {
185
+ "schema_version": 1,
186
+ "stage": "scenes",
187
+ "source_video_fingerprint": file_fingerprint(video_path),
188
+ "settings": {
189
+ "scene_threshold": CONFIG.get("scene_threshold"),
190
+ "scene_junk_filter": CONFIG.get("scene_junk_filter"),
191
+ "scene_merge_min": CONFIG.get("scene_merge_min"),
192
+ "scene_junk_dark_luma": CONFIG.get("scene_junk_dark_luma"),
193
+ "scene_junk_bright_luma": CONFIG.get("scene_junk_bright_luma"),
194
+ "scene_junk_pixel_ratio": CONFIG.get("scene_junk_pixel_ratio"),
195
+ },
196
+ }
197
+
198
+
199
+ def _asr_cache_payload(video_path, *, skip_asr=False):
200
+ return {
201
+ "schema_version": 1,
202
+ "stage": "asr",
203
+ "source_video_fingerprint": file_fingerprint(video_path),
204
+ "settings": {
205
+ "skip_asr": bool(skip_asr),
206
+ "mimo_asr_api_key_present": bool(CONFIG.get("mimo_asr_api_key")),
207
+ "mimo_asr_api_url": CONFIG.get("mimo_asr_api_url"),
208
+ "mimo_asr_model": CONFIG.get("mimo_asr_model"),
209
+ "mimo_asr_language": CONFIG.get("mimo_asr_language"),
210
+ "mimo_asr_base64_max_mb": CONFIG.get("mimo_asr_base64_max_mb"),
211
+ "asr_segment_seconds": CONFIG.get("asr_segment_seconds"),
212
+ },
213
+ }
214
+
215
+
216
+ def _silence_cache_payload(video_path, asr_json):
217
+ return {
218
+ "schema_version": 1,
219
+ "stage": "silence",
220
+ "source_video_fingerprint": file_fingerprint(video_path),
221
+ "asr_result_fingerprint": _artifact_fingerprint(asr_json),
222
+ "asr_meta": _load_json(_artifact_meta_path(asr_json))
223
+ if _artifact_meta_path(asr_json).exists()
224
+ else None,
225
+ "settings": {
226
+ "silence_noise_threshold": CONFIG.get("silence_noise_threshold"),
227
+ "silence_min_duration": CONFIG.get("silence_min_duration"),
228
+ "quiet_window_min": CONFIG.get("quiet_window_min"),
229
+ "silence_merge_gap": CONFIG.get("silence_merge_gap"),
230
+ "source_boundary_noise_threshold": CONFIG.get(
231
+ "source_boundary_noise_threshold"
232
+ ),
233
+ "source_boundary_min_pause": CONFIG.get("source_boundary_min_pause"),
234
+ "source_boundary_max_alignment_error": CONFIG.get(
235
+ "source_boundary_max_alignment_error"
236
+ ),
237
+ },
238
+ }
239
+
240
+
241
+ def _vlm_prompt_fingerprint():
242
+ prompt = load_prompt("VLM_DEPTH_PROMPT")
243
+ if not prompt:
244
+ prompt = (
245
+ "仔细观察这些视频帧。分两部分输出:\n"
246
+ "【描述】不超过80字,描述画面中正在发生什么。\n"
247
+ "【深层分析】不超过120字,分析角色情绪、关系动态、潜台词。"
248
+ )
249
+ context = CONFIG.get("context_info", "")
250
+ if context:
251
+ prompt = f"已知信息:{context}\n\n{prompt}"
252
+ return {
253
+ "prompt_text_fingerprint": _text_fingerprint(prompt),
254
+ "context_info_fingerprint": _text_fingerprint(context),
255
+ }
256
+
257
+
258
+ def _text_fingerprint(value):
259
+ return hashlib.md5(str(value or "").encode("utf-8")).hexdigest()
260
+
261
+
262
+ def _vlm_cache_payload(video_path, work_dir, scenes_json, frames):
263
+ return {
264
+ "schema_version": 1,
265
+ "stage": "vlm",
266
+ "source_video_fingerprint": file_fingerprint(video_path),
267
+ "scenes_fingerprint": _artifact_fingerprint(scenes_json),
268
+ "frames": _frame_cache_payload(video_path, CONFIG.get("fps"), frames),
269
+ "prompt": _vlm_prompt_fingerprint(),
270
+ "settings": {
271
+ "fps": CONFIG.get("fps"),
272
+ "vlm_model": CONFIG.get("vlm_model"),
273
+ "api_url": CONFIG.get("api_url"),
274
+ "mimo_disable_thinking": CONFIG.get("mimo_disable_thinking", True),
275
+ "mimo_media_resolution": CONFIG.get("mimo_media_resolution"),
276
+ "background_research_fingerprint": _artifact_fingerprint(
277
+ Path(work_dir) / "background_research.json"
278
+ ),
279
+ },
280
+ }
281
+
282
+
283
+ def _frames_manifest_path(work_dir):
284
+ return Path(work_dir) / "frames" / "frames_manifest.json"
285
+
286
+
287
+ def _frame_cache_payload(video_path, fps, frames):
288
+ frame_names = [Path(frame).name for frame in frames]
289
+ return {
290
+ # v2: frame number→time is (n-1)/fps, not n/fps. Bumping invalidates frames/VLM
291
+ # artifacts produced under the old off-by-one so they are recomputed, not reused.
292
+ "schema_version": FRAME_TIME_CONVENTION_VERSION,
293
+ "source_video_fingerprint": file_fingerprint(video_path),
294
+ "fps": float(fps),
295
+ "frame_count": len(frames),
296
+ "frames": frame_names,
297
+ "frame_fingerprints": {
298
+ name: file_fingerprint(frame) for name, frame in zip(frame_names, frames)
299
+ },
300
+ }
301
+
302
+
303
+ def _write_frames_manifest(work_dir, video_path, fps, frames):
304
+ manifest_path = _frames_manifest_path(work_dir)
305
+ manifest_path.parent.mkdir(parents=True, exist_ok=True)
306
+ manifest_path.write_text(
307
+ json.dumps(
308
+ _frame_cache_payload(video_path, fps, frames), ensure_ascii=False, indent=2
309
+ ),
310
+ encoding="utf-8",
311
+ )
312
+
313
+
314
+ def _frames_cache_valid(video_path, work_dir, fps):
315
+ frames_dir = Path(work_dir) / "frames"
316
+ frames = sorted(frames_dir.glob("frame_*.jpg"))
317
+ if not frames:
318
+ return False
319
+ manifest_path = _frames_manifest_path(work_dir)
320
+ if not manifest_path.exists():
321
+ return False
322
+ try:
323
+ manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
324
+ expected = _frame_cache_payload(video_path, fps, frames)
325
+ except (OSError, ValueError, TypeError):
326
+ return False
327
+ return manifest == expected
@@ -0,0 +1,367 @@
1
+ """Orchestrate the video-understanding stages."""
2
+
3
+ import argparse
4
+
5
+
6
+ import json
7
+
8
+ from pathlib import Path
9
+
10
+ from lib import CONFIG, log, get_video_duration, api_call
11
+
12
+ from extract import extract_frames
13
+
14
+ from detect import detect_scenes, detect_silence_periods, detect_speech_boundary_anchors
15
+
16
+ from asr import transcribe_audio
17
+
18
+ from vlm import (
19
+ analyze_scenes,
20
+ analyze_video_overview,
21
+ mimo_video_overview_cache_fresh,
22
+ )
23
+
24
+ from brief import build_agent_brief, assess_understanding_substrate
25
+
26
+
27
+ from understanding_brief import _research_context, _write_brief_from_existing_artifacts
28
+ from understanding_cache import (
29
+ _asr_cache_payload,
30
+ _frames_cache_valid,
31
+ _load_json,
32
+ _merge_overview_into_scenes,
33
+ _present_consolidation_artifacts,
34
+ _remove_stage_meta,
35
+ _scene_cache_payload,
36
+ _silence_cache_payload,
37
+ _stage_cache_valid,
38
+ _vlm_cache_payload,
39
+ _write_consolidation_status,
40
+ _write_frames_manifest,
41
+ _write_mimo_overview_status,
42
+ _write_stage_meta,
43
+ )
44
+ from understanding_storyboard import (
45
+ _generate_edited_storyboard,
46
+ _generate_source_storyboard,
47
+ _prepend_storyboard_brief_header,
48
+ )
49
+
50
+
51
+ def main():
52
+ ap = argparse.ArgumentParser(
53
+ description="Analyze a video into an understanding index + narration brief."
54
+ )
55
+ ap.add_argument("video")
56
+ ap.add_argument("--work-dir", required=True)
57
+ ap.add_argument(
58
+ "--context", default="", help="extra context (show name, character names, ...)"
59
+ )
60
+ ap.add_argument("--scene-threshold", type=float, default=None)
61
+ ap.add_argument("--style", default="纪录片")
62
+ ap.add_argument(
63
+ "--edit-mode",
64
+ default=None,
65
+ choices=["full", "cut"],
66
+ help="recap mode to document in the writing brief",
67
+ )
68
+ ap.add_argument(
69
+ "--target-duration",
70
+ default=None,
71
+ help="cut-mode target duration to document in the writing brief",
72
+ )
73
+ ap.add_argument("--skip-asr", action="store_true")
74
+ ap.add_argument("--mimo-video-overview", action="store_true")
75
+ ap.add_argument(
76
+ "--force", action="store_true", help="ignore cached artifacts and recompute"
77
+ )
78
+ ap.add_argument(
79
+ "--brief-only",
80
+ action="store_true",
81
+ help="rebuild agent_narration_brief.md from existing artifacts only; no extraction/API",
82
+ )
83
+ ap.add_argument(
84
+ "--consolidate",
85
+ action=argparse.BooleanOptionalAction,
86
+ default=True,
87
+ help="build the global understanding story index (Pass B); default ON, --no-consolidate to skip",
88
+ )
89
+ ap.add_argument(
90
+ "--consolidate-asr",
91
+ action="store_true",
92
+ help="also clean the ASR transcript (Pass A)",
93
+ )
94
+ args = ap.parse_args()
95
+
96
+ video = args.video
97
+ work_dir = Path(args.work_dir)
98
+ work_dir.mkdir(parents=True, exist_ok=True)
99
+ # Story research (if the agent wrote background_research.json first) feeds the VLM
100
+ # context, so scene analysis can name characters and read scenes with plot knowledge.
101
+ research_ctx = _research_context(work_dir)
102
+ context_parts = [p for p in (research_ctx, args.context) if p and p.strip()]
103
+ if context_parts:
104
+ CONFIG["context_info"] = " ".join(context_parts)
105
+ if research_ctx:
106
+ log(f"已并入 background_research.json 到理解上下文({len(research_ctx)} 字)")
107
+ if args.scene_threshold is not None:
108
+ CONFIG["scene_threshold"] = args.scene_threshold
109
+ if args.edit_mode is not None:
110
+ CONFIG["edit_mode"] = args.edit_mode
111
+ if args.target_duration is not None:
112
+ CONFIG["target_duration"] = args.target_duration
113
+ if args.mimo_video_overview:
114
+ CONFIG["mimo_video_overview"] = True
115
+ scene_threshold = CONFIG.get("scene_threshold")
116
+
117
+ video_duration = get_video_duration(video)
118
+ if CONFIG["fps"] <= 0:
119
+ CONFIG["fps"] = (
120
+ 2 if video_duration <= 60 else (1.5 if video_duration <= 300 else 1)
121
+ )
122
+ log(f"FPS: {CONFIG['fps']} (视频时长: {video_duration:.1f}s)")
123
+
124
+ if args.brief_only:
125
+ _write_brief_from_existing_artifacts(video, work_dir, args, video_duration)
126
+ return
127
+
128
+ scenes_json = work_dir / "scenes.json"
129
+ asr_json = work_dir / "asr_result.json"
130
+ silence_json = work_dir / "silence_periods.json"
131
+ vlm_json = work_dir / "vlm_analysis.json"
132
+ frames_dir = work_dir / "frames"
133
+
134
+ # Step 1: frame extraction
135
+ if not args.force and _frames_cache_valid(video, work_dir, CONFIG["fps"]):
136
+ frames = sorted(frames_dir.glob("frame_*.jpg"))
137
+ log(f"跳过帧提取(缓存匹配 {len(frames)} 帧)")
138
+ else:
139
+ frames = extract_frames(video, work_dir)
140
+ _write_frames_manifest(work_dir, video, CONFIG["fps"], frames)
141
+
142
+ # Step 2: scene detection
143
+ scenes_meta = _scene_cache_payload(video)
144
+ if not args.force and _stage_cache_valid(scenes_json, scenes_meta):
145
+ scenes = _load_json(scenes_json)
146
+ log(f"跳过场景检测(已存在 {len(scenes)} 个场景)")
147
+ else:
148
+ scenes = detect_scenes(video, work_dir, scene_threshold)
149
+ _write_stage_meta(scenes_json, scenes_meta)
150
+
151
+ # Step 3: ASR
152
+ asr_meta = _asr_cache_payload(video, skip_asr=args.skip_asr)
153
+ if args.skip_asr:
154
+ asr_result = []
155
+ asr_json.write_text(
156
+ json.dumps(asr_result, ensure_ascii=False, indent=2), encoding="utf-8"
157
+ )
158
+ _write_stage_meta(asr_json, asr_meta)
159
+ log("跳过 ASR(--skip-asr)")
160
+ elif not args.force and _stage_cache_valid(asr_json, asr_meta):
161
+ asr_result = _load_json(asr_json)
162
+ log(f"跳过 ASR(已存在 {len(asr_result)} 段)")
163
+ else:
164
+ try:
165
+ asr_result = transcribe_audio(video, work_dir)
166
+ except Exception as e:
167
+ _remove_stage_meta(asr_json)
168
+ asr_json.unlink(missing_ok=True)
169
+ raise RuntimeError(
170
+ f"ASR 失败;未写入可复用缓存,请修复后重试或显式使用 --skip-asr: {e}"
171
+ ) from e
172
+ _write_stage_meta(asr_json, asr_meta)
173
+
174
+ # Step 3.5: silence detection
175
+ silence_meta = _silence_cache_payload(video, asr_json)
176
+ if not args.force and _stage_cache_valid(silence_json, silence_meta):
177
+ silence_periods = _load_json(silence_json)
178
+ log(f"跳过静音检测(已存在 {len(silence_periods)} 个窗口)")
179
+ if not (work_dir / "speech_boundary_anchors.json").exists():
180
+ detect_speech_boundary_anchors(work_dir, asr_result)
181
+ else:
182
+ silence_periods = detect_silence_periods(video, work_dir, asr_result)
183
+ _write_stage_meta(silence_json, silence_meta)
184
+
185
+ # Step 4: VLM analysis (the only stage that requires the chat API key)
186
+ vlm_meta = _vlm_cache_payload(video, work_dir, scenes_json, frames)
187
+ if not args.force and _stage_cache_valid(vlm_json, vlm_meta):
188
+ vlm_analysis = _load_json(vlm_json)
189
+ log(f"跳过 VLM 分析(已存在 {len(vlm_analysis)} 个场景)")
190
+ else:
191
+ if not CONFIG.get("api_key"):
192
+ key_name = CONFIG.get("api_key_source", "MIMO_API_KEY")
193
+ raise SystemExit(f"请设置 {key_name} 环境变量(VLM 画面分析需要)")
194
+ log("VLM API 连通性预检...")
195
+ api_call(
196
+ {
197
+ "model": CONFIG.get("vlm_model", ""),
198
+ "messages": [{"role": "user", "content": "hi"}],
199
+ "max_tokens": 5,
200
+ }
201
+ )
202
+ vlm_analysis = analyze_scenes(scenes, frames, work_dir, resume=not args.force)
203
+ _write_stage_meta(vlm_json, vlm_meta)
204
+
205
+ # Step 4.1: optional MiMo scene-chunk video understanding
206
+ overview_path = work_dir / "mimo_video_overview.json"
207
+ if CONFIG.get("mimo_video_overview", False):
208
+ if not CONFIG.get("mimo_video_api_key"):
209
+ log("跳过 MiMo 分片视频概览:未设置 MIMO_API_KEY")
210
+ overview_path.unlink(missing_ok=True)
211
+ _write_mimo_overview_status(
212
+ work_dir,
213
+ "skipped_no_key",
214
+ "未设置 MIMO_API_KEY,MiMo 分片视频概览未运行",
215
+ None,
216
+ )
217
+ elif mimo_video_overview_cache_fresh(overview_path, video, scenes):
218
+ log("跳过 MiMo 分片视频概览(缓存匹配)")
219
+ _write_mimo_overview_status(
220
+ work_dir, "cached", "缓存匹配", overview_path.name
221
+ )
222
+ else:
223
+ overview_path.unlink(missing_ok=True)
224
+ try:
225
+ overview = analyze_video_overview(video, work_dir, scenes)
226
+ except Exception as e:
227
+ log(f"MiMo 分片视频概览失败(忽略): {e}")
228
+ _write_mimo_overview_status(work_dir, "failed", e, None)
229
+ else:
230
+ if overview_path.exists() and overview:
231
+ _write_mimo_overview_status(
232
+ work_dir, "ok", "MiMo 分片视频概览完成", overview_path.name
233
+ )
234
+ else:
235
+ _write_mimo_overview_status(
236
+ work_dir, "failed", "MiMo 分片视频概览未产出有效 artifact", None
237
+ )
238
+ else:
239
+ overview_path.unlink(missing_ok=True)
240
+ _write_mimo_overview_status(
241
+ work_dir, "disabled", "MiMo 分片视频概览未启用", None, enabled=False
242
+ )
243
+
244
+ # Make the video-overview the primary per-scene description (frame_facts stay the anchor).
245
+ # No-op/revert when overview is absent, so disabling it cleanly returns to frame descriptions.
246
+ vlm_analysis = _merge_overview_into_scenes(vlm_analysis, overview_path)
247
+
248
+ # optional consolidation (整理): build the understanding index before the brief folds it in
249
+ if args.consolidate or args.consolidate_asr:
250
+ from consolidate import consolidate
251
+
252
+ try:
253
+ consolidate(
254
+ work_dir, do_asr=args.consolidate_asr, do_index=args.consolidate
255
+ )
256
+ except Exception as e:
257
+ log(f"consolidate 跳过(忽略): {e}")
258
+ _write_consolidation_status(
259
+ work_dir,
260
+ "failed",
261
+ e,
262
+ _present_consolidation_artifacts(work_dir),
263
+ do_asr=args.consolidate_asr,
264
+ do_index=args.consolidate,
265
+ )
266
+ else:
267
+ expected = []
268
+ skipped = []
269
+ if args.consolidate:
270
+ if vlm_analysis:
271
+ expected.append("understanding_index.json")
272
+ else:
273
+ skipped.append("无 vlm_analysis,跳过 index")
274
+ if args.consolidate_asr:
275
+ if asr_result:
276
+ expected.append("asr_clean.json")
277
+ else:
278
+ skipped.append("无 ASR 文本,跳过 ASR 清洗")
279
+ artifacts = _present_consolidation_artifacts(work_dir)
280
+ missing = [name for name in expected if name not in artifacts]
281
+ if missing:
282
+ _write_consolidation_status(
283
+ work_dir,
284
+ "failed",
285
+ f"未产出预期 artifact: {', '.join(missing)}",
286
+ artifacts,
287
+ do_asr=args.consolidate_asr,
288
+ do_index=args.consolidate,
289
+ )
290
+ elif expected:
291
+ _write_consolidation_status(
292
+ work_dir,
293
+ "ok",
294
+ "consolidation 完成",
295
+ artifacts,
296
+ do_asr=args.consolidate_asr,
297
+ do_index=args.consolidate,
298
+ )
299
+ else:
300
+ _write_consolidation_status(
301
+ work_dir,
302
+ "skipped",
303
+ ";".join(skipped) or "无可整理输入",
304
+ artifacts,
305
+ do_asr=args.consolidate_asr,
306
+ do_index=args.consolidate,
307
+ )
308
+ else:
309
+ _write_consolidation_status(
310
+ work_dir,
311
+ "disabled",
312
+ "consolidation 未启用",
313
+ [],
314
+ enabled=False,
315
+ do_asr=False,
316
+ do_index=False,
317
+ )
318
+
319
+ # Storyboard contact sheets (advisory, never blocking). Source uses scene anchors over the
320
+ # source timeline; edited is gated on clip_plan_validated.json file-presence (NOT edit_mode —
321
+ # recap.py forwards --edit-mode cut in BOTH passes, so the validated plan is the only reliable
322
+ # pass2 signal). Both cache via _write_stage_meta/_stage_cache_valid with fps + frame-set in the key.
323
+ source_storyboard = _generate_source_storyboard(
324
+ work_dir, Path(video), scenes, scenes_json, force=args.force
325
+ )
326
+ edited_storyboard = _generate_edited_storyboard(work_dir, video, force=args.force)
327
+ cut_mode = (work_dir / "clip_plan_validated.json").exists()
328
+
329
+ # understanding substrate warning + writing brief
330
+ substrate = assess_understanding_substrate(vlm_analysis, asr_result)
331
+ if substrate["level"] != "rich":
332
+ banner = "理解素材为空" if substrate["level"] == "empty" else "理解素材偏薄"
333
+ log(
334
+ f"⚠️ {banner}:ASR {substrate['asr_chars']} 字 | 场景 {substrate['scene_count']} | "
335
+ f"带 frame_facts 的场景 {substrate['scenes_with_frame_facts']} | 平均画面描述 {substrate['avg_description_len']} 字"
336
+ )
337
+ brief_path = build_agent_brief(
338
+ vlm_analysis,
339
+ asr_result,
340
+ silence_periods,
341
+ video_duration,
342
+ work_dir,
343
+ args.style,
344
+ mimo_overview_enabled=CONFIG.get("mimo_video_overview", False),
345
+ mimo_overview_video_path=video,
346
+ )
347
+ # C1: post-process the RETURNED brief FILE (not brief.py) so the brief⇄narration twin stays
348
+ # byte-identical. Prepends a storyboard header pointing the agent at the sheet(s).
349
+ _prepend_storyboard_brief_header(
350
+ brief_path, source_storyboard, edited_storyboard, cut_mode=cut_mode
351
+ )
352
+
353
+ log("=" * 50)
354
+ log(f"理解完成。写作 brief: {brief_path}")
355
+ print(
356
+ json.dumps(
357
+ {
358
+ "status": "analyzed",
359
+ "work_dir": str(work_dir),
360
+ "brief": str(brief_path),
361
+ "substrate": substrate["level"],
362
+ "scenes": len(scenes),
363
+ "asr_segments": len(asr_result),
364
+ },
365
+ ensure_ascii=False,
366
+ )
367
+ )