@oh-story/dsh 0.1.10 → 0.1.12

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 (444) hide show
  1. package/README.md +11 -11
  2. package/lib/client.js +7 -3
  3. package/lib/client.js.map +2 -2
  4. package/lib/drama/manifest.json +212 -142
  5. package/lib/drama/skills/short-drama/SKILL.md +14 -2
  6. package/lib/drama/skills/short-drama/assets/project-template/short-drama.json +3 -0
  7. package/lib/drama/skills/short-drama/references/creator-documents.md +3 -0
  8. package/lib/drama/skills/short-drama/references/knowhow-index.md +15 -0
  9. package/lib/drama/skills/short-drama/scripts/project_tool.py +131 -0
  10. package/lib/drama/skills/short-drama-assets/SKILL.md +2 -1
  11. package/lib/drama/skills/short-drama-assets/references/asset-review-checklist.md +2 -0
  12. package/lib/drama/skills/short-drama-assets/references/era-anchors.md +37 -0
  13. package/lib/drama/skills/short-drama-assets/references/stage-contract.md +2 -0
  14. package/lib/drama/skills/short-drama-develop/SKILL.md +10 -4
  15. package/lib/drama/skills/short-drama-develop/assets/adaptation-map.example.jsonl +1 -1
  16. package/lib/drama/skills/short-drama-develop/assets/creative-brief.md +8 -0
  17. package/lib/drama/skills/short-drama-develop/references/adaptation-craft.md +80 -13
  18. package/lib/drama/skills/short-drama-develop/references/episode-design.md +95 -12
  19. package/lib/drama/skills/short-drama-develop/references/genre-and-hook-playbook.md +9 -5
  20. package/lib/drama/skills/short-drama-develop/references/genre-cards//345/244/215/344/273/207/346/211/223/350/204/270.md +1 -1
  21. package/lib/drama/skills/short-drama-develop/references/genre-cards//347/263/273/347/273/237/346/265/201.md +51 -0
  22. package/lib/drama/skills/short-drama-develop/references/genre-cards//351/200/206/350/242/255.md +51 -0
  23. package/lib/drama/skills/short-drama-develop/references/genre-cards//351/207/215/347/224/237/347/251/277/350/266/212.md +51 -0
  24. package/lib/drama/skills/short-drama-develop/references/genre-cards.md +10 -7
  25. package/lib/drama/skills/short-drama-develop/references/premise-devices.md +15 -9
  26. package/lib/drama/skills/short-drama-develop/references/serial-character-and-memory.md +3 -2
  27. package/lib/drama/skills/short-drama-develop/references/stage-contract.md +14 -7
  28. package/lib/drama/skills/short-drama-develop/references/story-craft.md +7 -3
  29. package/lib/drama/skills/short-drama-edit/SKILL.md +43 -20
  30. package/lib/drama/skills/short-drama-edit/assets/remotion/README.md +49 -13
  31. package/lib/drama/skills/short-drama-edit/assets/remotion/package.json +4 -2
  32. package/lib/drama/skills/short-drama-edit/assets/remotion/src/Overlay.tsx +31 -0
  33. package/lib/drama/skills/short-drama-edit/assets/remotion/src/Root.tsx +5 -5
  34. package/lib/drama/skills/short-drama-edit/assets/remotion/src/Subtitles.tsx +68 -69
  35. package/lib/drama/skills/short-drama-edit/assets/remotion/src/font.ts +39 -29
  36. package/lib/drama/skills/short-drama-edit/assets/remotion/src/rules.mjs +188 -0
  37. package/lib/drama/skills/short-drama-edit/assets/remotion/src/schema.ts +26 -13
  38. package/lib/drama/skills/short-drama-edit/assets/remotion/src/screen/Card.tsx +72 -0
  39. package/lib/drama/skills/short-drama-edit/assets/remotion/src/screen/CornerChip.tsx +39 -0
  40. package/lib/drama/skills/short-drama-edit/assets/remotion/src/screen/ScreenText.tsx +36 -0
  41. package/lib/drama/skills/short-drama-edit/assets/remotion/src/screen/SystemPanel.tsx +44 -0
  42. package/lib/drama/skills/short-drama-edit/assets/remotion/src/screen/TaskPanel.tsx +100 -0
  43. package/lib/drama/skills/short-drama-edit/assets/remotion/src/screen/chrome.tsx +197 -0
  44. package/lib/drama/skills/short-drama-edit/assets/remotion/src/screen/tokens.ts +62 -0
  45. package/lib/drama/skills/short-drama-edit/assets/remotion/tsconfig.json +1 -0
  46. package/lib/drama/skills/short-drama-edit/assets//345/211/252/350/276/221/345/215/225.md +4 -2
  47. package/lib/drama/skills/short-drama-edit/references/cut-craft.md +3 -1
  48. package/lib/drama/skills/short-drama-edit/references/delivery-verify.md +6 -2
  49. package/lib/drama/skills/short-drama-edit/references/generated-footage.md +12 -6
  50. package/lib/drama/skills/short-drama-edit/references/sound-and-subtitles.md +13 -8
  51. package/lib/drama/skills/short-drama-edit/references/stage-contract.md +2 -0
  52. package/lib/drama/skills/short-drama-edit/scripts/edit_tool.py +1153 -121
  53. package/lib/drama/skills/short-drama-edit/scripts/selftest.py +49 -9
  54. package/lib/drama/skills/short-drama-novel-analyze/SKILL.md +3 -3
  55. package/lib/drama/skills/short-drama-novel-analyze/assets/episode-candidate.example.jsonl +2 -2
  56. package/lib/drama/skills/short-drama-novel-analyze/references/adaptation-triage.md +8 -4
  57. package/lib/drama/skills/short-drama-novel-analyze/references/adaptation-value.md +10 -3
  58. package/lib/drama/skills/short-drama-novel-analyze/references/aggregation-and-entities.md +25 -1
  59. package/lib/drama/skills/short-drama-novel-analyze/references/stage-contract.md +1 -0
  60. package/lib/drama/skills/short-drama-review/SKILL.md +2 -2
  61. package/lib/drama/skills/short-drama-review/references/review-method.md +6 -1
  62. package/lib/drama/skills/short-drama-review/references/rubric-assets-prompts.md +11 -0
  63. package/lib/drama/skills/short-drama-review/references/rubric-story-script.md +77 -3
  64. package/lib/drama/skills/short-drama-review/references/rubric-visual-motion.md +15 -0
  65. package/lib/drama/skills/short-drama-review/references/stage-contract.md +3 -0
  66. package/lib/drama/skills/short-drama-storyboard/SKILL.md +13 -5
  67. package/lib/drama/skills/short-drama-storyboard/references/blocking-playbooks.md +1 -1
  68. package/lib/drama/skills/short-drama-storyboard/references/production-shot-grammar.md +2 -2
  69. package/lib/drama/skills/short-drama-storyboard/references/shot-craft.md +82 -14
  70. package/lib/drama/skills/short-drama-storyboard/references/stage-contract.md +4 -2
  71. package/lib/drama/skills/short-drama-video-prompts/SKILL.md +5 -3
  72. package/lib/drama/skills/short-drama-video-prompts/references/camera-audio-continuity.md +12 -0
  73. package/lib/drama/skills/short-drama-video-prompts/references/delivery-profile.md +4 -5
  74. package/lib/drama/skills/short-drama-video-prompts/references/generability.md +4 -2
  75. package/lib/drama/skills/short-drama-video-prompts/references/minimax-h3.md +40 -1
  76. package/lib/drama/skills/short-drama-video-prompts/references/motion-recipe.md +20 -14
  77. package/lib/drama/skills/short-drama-video-prompts/references/performance-action-timing.md +1 -1
  78. package/lib/drama/skills/short-drama-video-prompts/references/production-prompt-grammar.md +8 -7
  79. package/lib/drama/skills/short-drama-video-prompts/references/review-and-fixtures.md +1 -1
  80. package/lib/drama/skills/short-drama-video-prompts/references/stage-contract.md +1 -0
  81. package/lib/drama/skills/short-drama-video-prompts/references/target-model-profile.md +8 -1
  82. package/lib/drama/skills/short-drama-video-prompts/references/wan-3.0.md +103 -0
  83. package/lib/drama/skills/short-drama-video-prompts/scripts/motion_timing_check.py +8 -7
  84. package/lib/drama/skills/short-drama-write/SKILL.md +8 -3
  85. package/lib/drama/skills/short-drama-write/references/dialogue-craft.md +1 -1
  86. package/lib/drama/skills/short-drama-write/references/script-craft.md +56 -3
  87. package/lib/drama/skills/short-drama-write/references/stage-contract.md +4 -0
  88. package/lib/drama/skills/short-drama-write/scripts/duration_estimate.py +48 -2
  89. package/lib/index.js +71 -21
  90. package/lib/index.js.map +3 -3
  91. package/lib/oh-story/manifest.json +545 -310
  92. package/lib/oh-story/roles/chapter-extractor.md +11 -11
  93. package/lib/oh-story/roles/character-designer.md +1 -2
  94. package/lib/oh-story/roles/consistency-checker.md +11 -9
  95. package/lib/oh-story/roles/narrative-writer.md +24 -25
  96. package/lib/oh-story/roles/story-architect.md +9 -61
  97. package/lib/oh-story/roles/story-explorer.md +20 -125
  98. package/lib/oh-story/roles/story-researcher.md +0 -1
  99. package/lib/oh-story/skills/story/SKILL.md +6 -6
  100. package/lib/oh-story/skills/story/VERSION +1 -1
  101. package/lib/oh-story/skills/story/references/author-memory-maintenance.md +75 -0
  102. package/lib/oh-story/skills/story/references/author-memory.md +40 -118
  103. package/lib/oh-story/skills/story/scripts/author_memory_commit.py +3 -3
  104. package/lib/oh-story/skills/story-deslop/SKILL.md +24 -25
  105. package/lib/oh-story/skills/story-deslop/references/agent-calls.md +5 -0
  106. package/lib/oh-story/skills/story-deslop/references/anti-ai-writing.md +1 -1
  107. package/lib/oh-story/skills/story-deslop/references/author-memory-maintenance.md +75 -0
  108. package/lib/oh-story/skills/story-deslop/references/author-memory.md +40 -118
  109. package/lib/oh-story/skills/story-deslop/references/banned-words.md +2 -2
  110. package/lib/oh-story/skills/story-deslop/references/deslop-gates.md +21 -4
  111. package/lib/oh-story/skills/story-deslop/references/style-resolution.md +4 -4
  112. package/lib/oh-story/skills/story-deslop/scripts/author_memory_commit.py +3 -3
  113. package/lib/oh-story/skills/story-deslop/scripts/check-ai-patterns.js +155 -8
  114. package/lib/oh-story/skills/story-import/SKILL.md +63 -579
  115. package/lib/oh-story/skills/story-import/references/deep-analysis.md +47 -0
  116. package/lib/oh-story/skills/story-import/references/format-and-structure.md +1 -1
  117. package/lib/oh-story/skills/story-import/references/import-report.md +64 -0
  118. package/lib/oh-story/skills/story-import/references/import-special-cases.md +34 -0
  119. package/lib/oh-story/skills/story-import/references/import-tracking.md +95 -0
  120. package/lib/oh-story/skills/story-import/references/length-routing.md +1 -1
  121. package/lib/oh-story/skills/story-import/references/outline-reverse-rules.md +79 -0
  122. package/lib/oh-story/skills/story-import/references/outline-reverse.md +24 -0
  123. package/lib/oh-story/skills/story-import/references/structure-mapping-long.md +95 -91
  124. package/lib/oh-story/skills/story-import/references/structure-mapping-short.md +24 -12
  125. package/lib/oh-story/skills/story-import/references/tracking-initialization.md +1 -1
  126. package/lib/oh-story/skills/story-import/references/tracking-transaction.md +11 -9
  127. package/lib/oh-story/skills/story-import/scripts/build_outline_brief.py +332 -0
  128. package/lib/oh-story/skills/story-import/scripts/check-outline-contract.js +101 -14
  129. package/lib/oh-story/skills/story-import/scripts/tracking_commit.py +278 -23
  130. package/lib/oh-story/skills/story-import/scripts/wordcount_core.py +179 -23
  131. package/lib/oh-story/skills/story-long-analyze/SKILL.md +28 -50
  132. package/lib/oh-story/skills/story-long-analyze/references/author-facing.md +12 -5
  133. package/lib/oh-story/skills/story-long-analyze/references/deconstruction-notes.md +1 -1
  134. package/lib/oh-story/skills/story-long-analyze/references/final-checks.md +19 -0
  135. package/lib/oh-story/skills/story-long-analyze/references/index-rebuild.md +11 -0
  136. package/lib/oh-story/skills/story-long-analyze/references/pipeline-ops.md +21 -55
  137. package/lib/oh-story/skills/story-long-analyze/references/stage1-golden-chapters.md +128 -0
  138. package/lib/oh-story/skills/story-long-analyze/references/stage2-extraction.md +229 -0
  139. package/lib/oh-story/skills/story-long-analyze/references/stage3-plot-rhythm.md +480 -0
  140. package/lib/oh-story/skills/story-long-analyze/references/stage4-characters-settings.md +195 -0
  141. package/lib/oh-story/skills/story-long-analyze/references/stage5-report.md +33 -0
  142. package/lib/oh-story/skills/story-long-analyze/references/style-profile-generator.md +17 -0
  143. package/lib/oh-story/skills/story-long-analyze/references/style-profile-protocol.md +1 -1
  144. package/lib/oh-story/skills/story-long-analyze/references/synthesis-inputs.md +39 -0
  145. package/lib/oh-story/skills/story-long-analyze/scripts/manage_analysis_run.py +47 -8
  146. package/lib/oh-story/skills/story-long-scan/SKILL.md +41 -193
  147. package/lib/oh-story/skills/story-long-scan/references/platform-ciweimao.md +19 -0
  148. package/lib/oh-story/skills/story-long-scan/references/platform-fanqie.md +45 -0
  149. package/lib/oh-story/skills/story-long-scan/references/platform-jjwxc.md +28 -0
  150. package/lib/oh-story/skills/story-long-scan/references/platform-qidian.md +35 -0
  151. package/lib/oh-story/skills/story-long-scan/references/platform-qimao.md +27 -0
  152. package/lib/oh-story/skills/story-long-scan/references/topic-decision.md +6 -2
  153. package/lib/oh-story/skills/story-long-write/SKILL.md +32 -73
  154. package/lib/oh-story/skills/story-long-write/references/agent-calls.md +47 -0
  155. package/lib/oh-story/skills/story-long-write/references/anti-ai-writing.md +1 -1
  156. package/lib/oh-story/skills/story-long-write/references/artifact-protocols.md +18 -201
  157. package/lib/oh-story/skills/story-long-write/references/author-memory-maintenance.md +75 -0
  158. package/lib/oh-story/skills/story-long-write/references/author-memory.md +40 -118
  159. package/lib/oh-story/skills/story-long-write/references/banned-words.md +2 -2
  160. package/lib/oh-story/skills/story-long-write/references/benchmark-recall.md +6 -10
  161. package/lib/oh-story/skills/story-long-write/references/character-relations.md +49 -1
  162. package/lib/oh-story/skills/story-long-write/references/deslop-gates.md +171 -0
  163. package/lib/oh-story/skills/story-long-write/references/emotion-on-page.md +116 -0
  164. package/lib/oh-story/skills/story-long-write/references/emotional-arc-design.md +1 -114
  165. package/lib/oh-story/skills/story-long-write/references/genre-prose-cards.md +1 -1
  166. package/lib/oh-story/skills/story-long-write/references/long-chapter-quality.md +3 -2
  167. package/lib/oh-story/skills/story-long-write/references/long-format.md +0 -8
  168. package/lib/oh-story/skills/story-long-write/references/long-genre-catalog.md +1 -1
  169. package/lib/oh-story/skills/story-long-write/references/long-genre-mechanics.md +3 -3
  170. package/lib/oh-story/skills/story-long-write/references/opening-design.md +2 -2
  171. package/lib/oh-story/skills/story-long-write/references/outline-conflict.md +4 -4
  172. package/lib/oh-story/skills/story-long-write/references/outline-methods.md +7 -7
  173. package/lib/oh-story/skills/story-long-write/references/outline-rhythm.md +3 -3
  174. package/lib/oh-story/skills/story-long-write/references/outline-structure-theory.md +14 -69
  175. package/lib/oh-story/skills/story-long-write/references/plot-frameworks.md +1 -1
  176. package/lib/oh-story/skills/story-long-write/references/plot-special-topics.md +2 -2
  177. package/lib/oh-story/skills/story-long-write/references/project-files.md +10 -6
  178. package/lib/oh-story/skills/story-long-write/references/reader-contract-and-progression.md +1 -1
  179. package/lib/oh-story/skills/story-long-write/references/reference-index.md +4 -4
  180. package/lib/oh-story/skills/story-long-write/references/stop-and-fix.md +9 -0
  181. package/lib/oh-story/skills/story-long-write/references/style-combat-face.md +1 -58
  182. package/lib/oh-story/skills/story-long-write/references/style-genre-modules.md +1 -1
  183. package/lib/oh-story/skills/story-long-write/references/style-resolution.md +4 -4
  184. package/lib/oh-story/skills/story-long-write/references/tracking-initialization.md +1 -1
  185. package/lib/oh-story/skills/story-long-write/references/tracking-transaction.md +11 -9
  186. package/lib/oh-story/skills/story-long-write/references/workflow-chapter.md +33 -44
  187. package/lib/oh-story/skills/story-long-write/references/workflow-daily.md +18 -51
  188. package/lib/oh-story/skills/story-long-write/references/workflow-outline.md +157 -0
  189. package/lib/oh-story/skills/story-long-write/references/workflow-revision.md +53 -67
  190. package/lib/oh-story/skills/story-long-write/references/workflow-setup.md +112 -251
  191. package/lib/oh-story/skills/story-long-write/references/workflow-volume.md +142 -0
  192. package/lib/oh-story/skills/story-long-write/references/writer-prompt-fallback.md +5 -3
  193. package/lib/oh-story/skills/story-long-write/references/writing-craft.md +18 -56
  194. package/lib/oh-story/skills/story-long-write/scripts/author_memory_commit.py +3 -3
  195. package/lib/oh-story/skills/story-long-write/scripts/build_architect_brief.py +260 -0
  196. package/lib/oh-story/skills/story-long-write/scripts/build_writer_prompt.py +96 -16
  197. package/lib/oh-story/skills/story-long-write/scripts/check-ai-patterns.js +155 -8
  198. package/lib/oh-story/skills/story-long-write/scripts/check-outline-contract.js +101 -14
  199. package/lib/oh-story/skills/story-long-write/scripts/check-outline-copy.js +7 -2
  200. package/lib/oh-story/skills/story-long-write/scripts/outline_view.py +2 -1
  201. package/lib/oh-story/skills/story-long-write/scripts/storyctl.py +250 -50
  202. package/lib/oh-story/skills/story-long-write/scripts/tracking_commit.py +278 -23
  203. package/lib/oh-story/skills/story-long-write/scripts/wordcount_core.py +179 -23
  204. package/lib/oh-story/skills/story-review/SKILL.md +19 -273
  205. package/lib/oh-story/skills/story-review/references/agent-prompts.md +184 -0
  206. package/lib/oh-story/skills/story-review/references/anti-ai-writing.md +1 -1
  207. package/lib/oh-story/skills/story-review/references/author-memory-maintenance.md +75 -0
  208. package/lib/oh-story/skills/story-review/references/author-memory.md +40 -118
  209. package/lib/oh-story/skills/story-review/references/banned-words.md +2 -2
  210. package/lib/oh-story/skills/story-review/references/batch-review.md +19 -0
  211. package/lib/oh-story/skills/story-review/references/character-relations.md +49 -1
  212. package/lib/oh-story/skills/story-review/references/review-quality.md +2 -1
  213. package/lib/oh-story/skills/story-review/references/review-tracking.md +10 -0
  214. package/lib/oh-story/skills/story-review/references/solo.md +52 -0
  215. package/lib/oh-story/skills/story-review/references/style-resolution.md +4 -4
  216. package/lib/oh-story/skills/story-review/references/tracking-initialization.md +1 -1
  217. package/lib/oh-story/skills/story-review/references/tracking-transaction.md +11 -9
  218. package/lib/oh-story/skills/story-review/scripts/author_memory_commit.py +3 -3
  219. package/lib/oh-story/skills/story-review/scripts/check-ai-patterns.js +155 -8
  220. package/lib/oh-story/skills/story-review/scripts/tracking_commit.py +278 -23
  221. package/lib/oh-story/skills/story-review/scripts/wordcount_core.py +179 -23
  222. package/lib/oh-story/skills/story-setup/SKILL.md +69 -458
  223. package/lib/oh-story/skills/story-setup/references/agent-references/agent-quality.md +4 -4
  224. package/lib/oh-story/skills/story-setup/references/agent-references/anti-ai-writing.md +1 -1
  225. package/lib/oh-story/skills/story-setup/references/agent-references/banned-words.md +2 -2
  226. package/lib/oh-story/skills/story-setup/references/agent-references/benchmark-style-load.md +107 -0
  227. package/lib/oh-story/skills/story-setup/references/agent-references/character-relations.md +49 -1
  228. package/lib/oh-story/skills/story-setup/references/agent-references/deslop-gates.md +21 -4
  229. package/lib/oh-story/skills/story-setup/references/agent-references/emotion-on-page.md +116 -0
  230. package/lib/oh-story/skills/story-setup/references/agent-references/emotional-arc-design.md +1 -114
  231. package/lib/oh-story/skills/story-setup/references/agent-references/format-and-structure.md +1 -1
  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/long-genre-catalog.md +1 -1
  234. package/lib/oh-story/skills/story-setup/references/agent-references/long-genre-mechanics.md +3 -3
  235. package/lib/oh-story/skills/story-setup/references/agent-references/long-quality.md +7 -5
  236. package/lib/oh-story/skills/story-setup/references/agent-references/opening-design.md +2 -2
  237. package/lib/oh-story/skills/story-setup/references/agent-references/outline-conflict.md +4 -4
  238. package/lib/oh-story/skills/story-setup/references/agent-references/outline-methods.md +7 -7
  239. package/lib/oh-story/skills/story-setup/references/agent-references/outline-rhythm.md +3 -3
  240. package/lib/oh-story/skills/story-setup/references/agent-references/short-emotional-methods.md +1 -1
  241. package/lib/oh-story/skills/story-setup/references/agent-references/short-genre-formulas.md +0 -15
  242. package/lib/oh-story/skills/story-setup/references/agent-references/short-reversal.md +1 -1
  243. package/lib/oh-story/skills/story-setup/references/agent-references/style-combat-face.md +1 -58
  244. package/lib/oh-story/skills/story-setup/references/agent-references/style-genre-modules.md +1 -1
  245. package/lib/oh-story/skills/story-setup/references/agent-references/style-resolution.md +4 -4
  246. package/lib/oh-story/skills/story-setup/references/agent-references/writing-craft.md +18 -56
  247. package/lib/oh-story/skills/story-setup/references/diagnostics.md +3 -3
  248. package/lib/oh-story/skills/story-short-analyze/SKILL.md +37 -110
  249. package/lib/oh-story/skills/story-short-analyze/references/analysis-character-relations.md +1 -1
  250. package/lib/oh-story/skills/story-short-analyze/references/analysis-method.md +42 -0
  251. package/lib/oh-story/skills/story-short-analyze/references/optional-modules.md +97 -0
  252. package/lib/oh-story/skills/story-short-analyze/references/output-contract.md +9 -47
  253. package/lib/oh-story/skills/story-short-analyze/references/quality-checklist.md +80 -0
  254. package/lib/oh-story/skills/story-short-analyze/references/source-story-quality.md +4 -4
  255. package/lib/oh-story/skills/story-short-analyze/references/stage2-3-structure-emotion.md +308 -0
  256. package/lib/oh-story/skills/story-short-analyze/references/{material-decomposition.md → stage4-6-reversal-summary.md} +303 -374
  257. package/lib/oh-story/skills/story-short-scan/SKILL.md +30 -64
  258. package/lib/oh-story/skills/story-short-scan/references/manual-rank-input.md +36 -0
  259. package/lib/oh-story/skills/story-short-scan/references/platform-dianzhong.md +24 -0
  260. package/lib/oh-story/skills/story-short-scan/references/platform-heiyan.md +21 -0
  261. package/lib/oh-story/skills/story-short-scan/references/topic-match.md +38 -0
  262. package/lib/oh-story/skills/story-short-write/SKILL.md +23 -34
  263. package/lib/oh-story/skills/story-short-write/references/agent-calls.md +13 -0
  264. package/lib/oh-story/skills/story-short-write/references/author-memory-maintenance.md +75 -0
  265. package/lib/oh-story/skills/story-short-write/references/author-memory.md +40 -118
  266. package/lib/oh-story/skills/story-short-write/references/banned-words.md +2 -2
  267. package/lib/oh-story/skills/story-short-write/references/benchmark-recall.md +1 -21
  268. package/lib/oh-story/skills/story-short-write/references/emotional-methods.md +1 -1
  269. package/lib/oh-story/skills/story-short-write/references/genre-writing-formulas.md +0 -15
  270. package/lib/oh-story/skills/story-short-write/references/output-contract.md +9 -47
  271. package/lib/oh-story/skills/story-short-write/references/reference-index.md +17 -49
  272. package/lib/oh-story/skills/story-short-write/references/scene-craft.md +40 -0
  273. package/lib/oh-story/skills/story-short-write/references/short-craft.md +7 -43
  274. package/lib/oh-story/skills/story-short-write/references/short-format.md +3 -3
  275. package/lib/oh-story/skills/story-short-write/references/short-prose-quality.md +2 -1
  276. package/lib/oh-story/skills/story-short-write/references/short-reversal.md +1 -1
  277. package/lib/oh-story/skills/story-short-write/references/style-resolution.md +4 -4
  278. package/lib/oh-story/skills/story-short-write/references/submission-craft.md +1 -1
  279. package/lib/oh-story/skills/story-short-write/references/villain-and-reveal.md +5 -10
  280. package/lib/oh-story/skills/story-short-write/references/workflow-design.md +19 -12
  281. package/lib/oh-story/skills/story-short-write/references/workflow-draft.md +22 -32
  282. package/lib/oh-story/skills/story-short-write/references/workflow-revision.md +84 -17
  283. package/lib/oh-story/skills/story-short-write/references/writing-workflow.md +7 -119
  284. package/lib/oh-story/skills/story-short-write/scripts/author_memory_commit.py +3 -3
  285. package/lib/oh-story/skills/story-short-write/scripts/check-ai-patterns.js +155 -8
  286. package/lib/oh-story/skills/story-short-write/scripts/check-outline-copy.js +7 -2
  287. package/lib/types/client/video-studio.d.ts.map +1 -1
  288. package/lib/types/native-hooks.d.ts +2 -2
  289. package/lib/types/native-hooks.d.ts.map +1 -1
  290. package/lib/types/role-tool.d.ts.map +1 -1
  291. package/lib/types/skill-provider.d.ts.map +1 -1
  292. package/lib/types/video-project.d.ts.map +1 -1
  293. package/lib/types/workspace-route.d.ts.map +1 -1
  294. package/lib/video-recap/CHANGELOG.md +60 -1
  295. package/lib/video-recap/README.en.md +348 -137
  296. package/lib/video-recap/README.md +340 -136
  297. package/lib/video-recap/manifest.json +406 -251
  298. package/lib/video-recap/skills/video-assemble/SKILL.md +30 -15
  299. package/lib/video-recap/skills/video-assemble/references/audio-modes.md +63 -0
  300. package/lib/video-recap/skills/video-assemble/references/explicit-audio-mix.md +75 -0
  301. package/lib/video-recap/skills/video-assemble/references/foreground-compose.md +118 -0
  302. package/lib/video-recap/skills/video-assemble/references/narration-adoption.md +103 -0
  303. package/lib/video-recap/skills/video-assemble/references/packaging.md +45 -0
  304. package/lib/video-recap/skills/video-assemble/references/pair-media.md +74 -0
  305. package/lib/video-recap/skills/video-assemble/references/source-score.md +147 -0
  306. package/lib/video-recap/skills/video-assemble/references/subtitle-track.md +202 -0
  307. package/lib/video-recap/skills/video-assemble/scripts/adoption/__init__.py +1 -0
  308. package/lib/video-recap/skills/video-assemble/scripts/adoption/audio_mix_binding.py +279 -0
  309. package/lib/video-recap/skills/video-assemble/scripts/adoption/frozen_audio.py +187 -0
  310. package/lib/video-recap/skills/video-assemble/scripts/adoption/narration_binding.py +323 -0
  311. package/lib/video-recap/skills/video-assemble/scripts/adoption/strict_inputs.py +109 -0
  312. package/lib/video-recap/skills/video-assemble/scripts/adoption/strict_publish.py +130 -0
  313. package/lib/video-recap/skills/video-assemble/scripts/artifacts.py +10 -46
  314. package/lib/video-recap/skills/video-assemble/scripts/assemble.py +378 -119
  315. package/lib/video-recap/skills/video-assemble/scripts/assemble_constants.py +29 -12
  316. package/lib/video-recap/skills/video-assemble/scripts/assembly_contract.py +95 -44
  317. package/lib/video-recap/skills/video-assemble/scripts/assembly_settings.py +75 -32
  318. package/lib/video-recap/skills/video-assemble/scripts/audio_mix.py +11 -11
  319. package/lib/video-recap/skills/video-assemble/scripts/compose_foreground.py +293 -0
  320. package/lib/video-recap/skills/video-assemble/scripts/export_jianying.py +71 -78
  321. package/lib/video-recap/skills/video-assemble/scripts/jianying/__init__.py +1 -0
  322. package/lib/video-recap/skills/video-assemble/scripts/{jianying_builders.py → jianying/builders.py} +39 -67
  323. package/lib/video-recap/skills/video-assemble/scripts/{jianying_model.py → jianying/model.py} +3 -11
  324. package/lib/video-recap/skills/video-assemble/scripts/{jianying_optional.py → jianying/optional.py} +1 -1
  325. package/lib/video-recap/skills/video-assemble/scripts/jianying/schema.py +53 -0
  326. package/lib/video-recap/skills/video-assemble/scripts/{jianying_templates.py → jianying/templates.py} +1 -1
  327. package/lib/video-recap/skills/video-assemble/scripts/{jianying_timeline_contract.py → jianying/timeline_contract.py} +34 -13
  328. package/lib/video-recap/skills/video-assemble/scripts/{jianying_writer.py → jianying/writer.py} +7 -17
  329. package/lib/video-recap/skills/video-assemble/scripts/lib.py +37 -4
  330. package/lib/video-recap/skills/video-assemble/scripts/media.py +12 -21
  331. package/lib/video-recap/skills/video-assemble/scripts/narration_audio.py +64 -34
  332. package/lib/video-recap/skills/video-assemble/scripts/packaging.py +122 -0
  333. package/lib/video-recap/skills/video-assemble/scripts/pair_media.py +216 -0
  334. package/lib/video-recap/skills/video-assemble/scripts/render_preflight.py +1 -3
  335. package/lib/video-recap/skills/video-assemble/scripts/source_score.py +469 -0
  336. package/lib/video-recap/skills/video-assemble/scripts/source_subtitles.py +25 -9
  337. package/lib/video-recap/skills/video-assemble/scripts/subtitles/__init__.py +1 -0
  338. package/lib/video-recap/skills/video-assemble/scripts/{subtitle_core.py → subtitles/core.py} +13 -6
  339. package/lib/video-recap/skills/video-assemble/scripts/{subtitle_render.py → subtitles/render.py} +5 -4
  340. package/lib/video-recap/skills/video-assemble/scripts/subtitles/track.py +324 -0
  341. package/lib/video-recap/skills/video-assemble/scripts/subtitles/track_binding.py +200 -0
  342. package/lib/video-recap/skills/video-assemble/scripts/timeline.py +30 -46
  343. package/lib/video-recap/skills/video-assemble/scripts/timeline_emit.py +91 -7
  344. package/lib/video-recap/skills/video-assemble/scripts/visual_render.py +22 -8
  345. package/lib/video-recap/skills/video-cut/SKILL.md +34 -16
  346. package/lib/video-recap/skills/video-cut/references/shot-review.md +50 -0
  347. package/lib/video-recap/skills/video-cut/scripts/cut.py +2 -28
  348. package/lib/video-recap/skills/video-cut/scripts/cut_cli.py +58 -62
  349. package/lib/video-recap/skills/video-cut/scripts/cut_contract.py +21 -106
  350. package/lib/video-recap/skills/video-cut/scripts/cut_render.py +14 -9
  351. package/lib/video-recap/skills/video-cut/scripts/lib.py +39 -0
  352. package/lib/video-recap/skills/video-cut/scripts/narration_mapping.py +2 -155
  353. package/lib/video-recap/skills/video-cut/scripts/narrative_selection.py +244 -0
  354. package/lib/video-recap/skills/video-cut/scripts/shot_review.py +357 -0
  355. package/lib/video-recap/skills/video-recap/SKILL.md +86 -42
  356. package/lib/video-recap/skills/video-recap/references/audio-routing.md +126 -0
  357. package/lib/video-recap/skills/video-recap/references/config-playbook.md +12 -8
  358. package/lib/video-recap/skills/video-recap/references/data-schema.md +44 -33
  359. package/lib/video-recap/skills/video-recap/references/resource-library.md +151 -0
  360. package/lib/video-recap/skills/video-recap/references/shift-left-qc-schema.md +1 -1
  361. package/lib/video-recap/skills/video-recap/scripts/doctor.py +123 -30
  362. package/lib/video-recap/skills/video-recap/scripts/final_qc.py +22 -75
  363. package/lib/video-recap/skills/video-recap/scripts/lib.py +3 -3
  364. package/lib/video-recap/skills/video-recap/scripts/library.py +509 -0
  365. package/lib/video-recap/skills/video-recap/scripts/materials.py +63 -91
  366. package/lib/video-recap/skills/video-recap/scripts/mimo_qc.py +8 -70
  367. package/lib/video-recap/skills/video-recap/scripts/project_binding.py +286 -0
  368. package/lib/video-recap/skills/video-recap/scripts/qc/__init__.py +1 -0
  369. package/lib/video-recap/skills/video-recap/scripts/{mimo_qc_client.py → qc/mimo_client.py} +1 -1
  370. package/lib/video-recap/skills/video-recap/scripts/{mimo_qc_evidence.py → qc/mimo_evidence.py} +33 -66
  371. package/lib/video-recap/skills/video-recap/scripts/{mimo_qc_observations.py → qc/mimo_observations.py} +3 -11
  372. package/lib/video-recap/skills/video-recap/scripts/{mimo_qc_payload.py → qc/mimo_payload.py} +4 -7
  373. package/lib/video-recap/skills/video-recap/scripts/{mimo_qc_report.py → qc/mimo_report.py} +17 -28
  374. package/lib/video-recap/skills/video-recap/scripts/{mimo_qc_runner.py → qc/mimo_runner.py} +2 -2
  375. package/lib/video-recap/skills/video-recap/scripts/qc_contract.py +0 -19
  376. package/lib/video-recap/skills/video-recap/scripts/recap_cli.py +119 -50
  377. package/lib/video-recap/skills/video-recap/scripts/recap_inspect.py +32 -114
  378. package/lib/video-recap/skills/video-recap/scripts/recap_review.py +9 -23
  379. package/lib/video-recap/skills/video-recap/scripts/recap_runner.py +387 -334
  380. package/lib/video-recap/skills/video-recap/scripts/recap_runtime.py +23 -23
  381. package/lib/video-recap/skills/video-recap/scripts/recap_source.py +278 -0
  382. package/lib/video-recap/skills/video-recap/scripts/recap_stage_qc.py +25 -12
  383. package/lib/video-recap/skills/video-recap/scripts/recap_timeline.py +59 -52
  384. package/lib/video-recap/skills/video-recap/scripts/resource_lock.py +162 -0
  385. package/lib/video-recap/skills/video-script/SKILL.md +16 -13
  386. package/lib/video-recap/skills/video-script/references/creative-editing-playbook.md +9 -5
  387. package/lib/video-recap/skills/video-script/references/promotional-copy.md +68 -0
  388. package/lib/video-recap/skills/video-script/references/research-guide.md +1 -1
  389. package/lib/video-recap/skills/video-script/scripts/evidence_bundle.py +24 -76
  390. package/lib/video-recap/skills/video-script/scripts/lib.py +10 -87
  391. package/lib/video-recap/skills/video-script/scripts/narration_lint.py +63 -39
  392. package/lib/video-recap/skills/video-script/scripts/review.py +0 -2
  393. package/lib/video-recap/skills/video-script/scripts/review_grounding.py +35 -59
  394. package/lib/video-recap/skills/video-script/scripts/review_response.py +66 -128
  395. package/lib/video-recap/skills/video-script/scripts/review_runner.py +12 -20
  396. package/lib/video-recap/skills/video-script/scripts/speech_ownership.py +4 -4
  397. package/lib/video-recap/skills/video-script/scripts/validate.py +53 -42
  398. package/lib/video-recap/skills/video-understanding/SKILL.md +6 -4
  399. package/lib/video-recap/skills/video-understanding/references/data-schema.md +50 -156
  400. package/lib/video-recap/skills/video-understanding/references/research-guide.md +4 -4
  401. package/lib/video-recap/skills/video-understanding/scripts/asr.py +85 -65
  402. package/lib/video-recap/skills/video-understanding/scripts/asr_timing_evidence.py +270 -0
  403. package/lib/video-recap/skills/video-understanding/scripts/brief.py +2 -5
  404. package/lib/video-recap/skills/video-understanding/scripts/briefing/__init__.py +1 -0
  405. package/lib/video-recap/skills/video-understanding/scripts/{agent_brief.py → briefing/builder.py} +38 -35
  406. package/lib/video-recap/skills/{video-script/scripts/brief_context.py → video-understanding/scripts/briefing/context.py} +4 -35
  407. package/lib/video-recap/skills/{video-script/scripts/brief_inputs.py → video-understanding/scripts/briefing/inputs.py} +9 -31
  408. package/lib/video-recap/skills/video-understanding/scripts/{brief_timeline.py → briefing/timeline.py} +5 -6
  409. package/lib/video-recap/skills/video-understanding/scripts/consolidate.py +65 -116
  410. package/lib/video-recap/skills/video-understanding/scripts/detect.py +31 -40
  411. package/lib/video-recap/skills/video-understanding/scripts/lib.py +30 -86
  412. package/lib/video-recap/skills/video-understanding/scripts/narration_lint.py +63 -39
  413. package/lib/video-recap/skills/video-understanding/scripts/speech_ownership.py +4 -4
  414. package/lib/video-recap/skills/video-understanding/scripts/storyboard.py +17 -79
  415. package/lib/video-recap/skills/video-understanding/scripts/understanding_brief.py +14 -40
  416. package/lib/video-recap/skills/video-understanding/scripts/understanding_cache.py +64 -46
  417. package/lib/video-recap/skills/video-understanding/scripts/understanding_runner.py +31 -11
  418. package/lib/video-recap/skills/video-understanding/scripts/understanding_storyboard.py +19 -14
  419. package/lib/video-recap/skills/video-understanding/scripts/vlm.py +80 -108
  420. package/lib/video-recap/skills/video-voiceover/SKILL.md +29 -19
  421. package/lib/video-recap/skills/video-voiceover/references/index-tts.md +31 -0
  422. package/lib/video-recap/skills/video-voiceover/scripts/approved_text_policy.py +123 -0
  423. package/lib/video-recap/skills/video-voiceover/scripts/dub.py +51 -59
  424. package/lib/video-recap/skills/video-voiceover/scripts/lib.py +8 -44
  425. package/lib/video-recap/skills/video-voiceover/scripts/providers/__init__.py +1 -0
  426. package/lib/video-recap/skills/video-voiceover/scripts/providers/index_tts.py +184 -0
  427. package/lib/video-recap/skills/video-voiceover/scripts/voiceover.py +212 -134
  428. package/package.json +41 -41
  429. package/lib/oh-story/skills/story-long-analyze/references/material-decomposition.md +0 -538
  430. package/lib/oh-story/skills/story-long-analyze/references/output-templates.md +0 -603
  431. package/lib/oh-story/skills/story-long-scan/references/scan-output-format.md +0 -207
  432. package/lib/oh-story/skills/story-short-analyze/references/output-templates.md +0 -561
  433. package/lib/video-recap/skills/video-assemble/scripts/jianying_schema.py +0 -98
  434. package/lib/video-recap/skills/video-recap/references/creative-editing-playbook.md +0 -225
  435. package/lib/video-recap/skills/video-recap/references/research-guide.md +0 -74
  436. package/lib/video-recap/skills/video-recap/references/timeline-and-jianying.md +0 -250
  437. package/lib/video-recap/skills/video-script/scripts/agent_brief.py +0 -399
  438. package/lib/video-recap/skills/video-script/scripts/brief_timeline.py +0 -327
  439. package/lib/video-recap/skills/video-script/scripts/narration.py +0 -12
  440. package/lib/video-recap/skills/video-understanding/scripts/brief_context.py +0 -348
  441. package/lib/video-recap/skills/video-understanding/scripts/brief_inputs.py +0 -290
  442. /package/lib/video-recap/skills/video-assemble/scripts/{jianying_tracks.py → jianying/tracks.py} +0 -0
  443. /package/lib/video-recap/skills/video-recap/scripts/{mimo_qc_contract.py → qc/mimo_contract.py} +0 -0
  444. /package/lib/video-recap/skills/video-voiceover/scripts/{fish_audio.py → providers/fish_audio.py} +0 -0
@@ -0,0 +1,509 @@
1
+ #!/usr/bin/env python3
2
+ """Read-only resource / template / sample library for video-recap.
3
+
4
+ The library shares its root with the material library (``--material-library-dir``):
5
+
6
+ <library>/library.json
7
+ <library>/resources/<kind>/<id>/resource.json
8
+ <library>/templates/<kind>/<id>/v<version>/template.json
9
+ <library>/samples/<id>/sample.json
10
+
11
+ Nothing here writes to the library. ``check`` reports errors (the entry cannot be used)
12
+ and warnings (usable, but a person should look: unknown licence, missing consent, a
13
+ resource that changed since a template was adopted). The record format lives in
14
+ ``references/resource-library.md``.
15
+ """
16
+ from __future__ import annotations
17
+
18
+ import argparse
19
+ import json
20
+ import os
21
+ import re
22
+ import stat
23
+ import sys
24
+ from pathlib import Path
25
+
26
+ from materials import file_identity
27
+
28
+ LIBRARY_ENV = "VIDEO_RECAP_MATERIAL_LIBRARY_DIR"
29
+ LIBRARY_SCHEMA = "video-recap.library.v1"
30
+ RESOURCE_SCHEMA = "video-recap.resource.v1"
31
+ TEMPLATE_SCHEMA = "video-recap.template.v1"
32
+ SAMPLE_SCHEMA = "video-recap.sample.v1"
33
+
34
+ AUDIO_EXTS = {".wav", ".mp3", ".m4a", ".aac", ".flac", ".ogg"}
35
+ RESOURCE_EXTS = {
36
+ "bgm": AUDIO_EXTS,
37
+ "sfx": AUDIO_EXTS,
38
+ "voice": AUDIO_EXTS,
39
+ "font": {".ttf", ".otf", ".ttc"},
40
+ "image": {".png", ".jpg", ".jpeg", ".webp"},
41
+ }
42
+ TEMPLATE_KINDS = ("subtitle_style", "packaging")
43
+ LICENSE_STATUSES = ("unknown", "owned", "licensed", "restricted")
44
+ CONSENT_STATUSES = ("unknown", "granted", "denied")
45
+ TEMPLATE_STATUSES = ("draft", "adopted", "retired")
46
+ PROVENANCES = ("measured", "fitted", "specified", "unknown")
47
+ SUBTITLE_SIDE_MARGIN = 40 # video-assemble's default left/right subtitle margin at PlayRes = canvas
48
+ SUBTITLE_PARAMS = {
49
+ "font", "size_px", "outline_px", "shadow_px", "primary_color", "outline_color",
50
+ "max_chars", "max_lines", "band",
51
+ }
52
+ VOICE_PROVIDERS = ("mimo-tts", "fish-audio", "index-tts")
53
+ SAMPLE_EXTS = {".mp4", ".mov", ".mkv", ".webm"}
54
+
55
+ RESOURCE_KEYS = {
56
+ "schema", "id", "kind", "title", "files", "origin", "license", "tags", "notes",
57
+ "voice", "consent", "font",
58
+ }
59
+ TEMPLATE_KEYS = {
60
+ "schema", "id", "version", "kind", "title", "canvas", "params", "samples", "status",
61
+ "adoption", "notes",
62
+ }
63
+ SAMPLE_KEYS = {
64
+ "schema", "id", "title", "file", "canvas", "demonstrates", "not_reusable", "templates",
65
+ "notes",
66
+ }
67
+ ID_RE = re.compile(r"^[a-z0-9][a-z0-9._-]{0,63}$")
68
+ DATE_RE = re.compile(r"^\d{4}-\d{2}-\d{2}$")
69
+
70
+
71
+ class Report:
72
+ def __init__(self, root: Path):
73
+ self.root = root
74
+ self.errors: list[dict] = []
75
+ self.warnings: list[dict] = []
76
+
77
+ def _rel(self, path) -> str:
78
+ try:
79
+ return Path(path).relative_to(self.root).as_posix()
80
+ except ValueError:
81
+ return str(path)
82
+
83
+ def error(self, path, code, message):
84
+ self.errors.append({"path": self._rel(path), "code": code, "message": message})
85
+
86
+ def warn(self, path, code, message):
87
+ self.warnings.append({"path": self._rel(path), "code": code, "message": message})
88
+
89
+
90
+ MAX_RECORD_BYTES = 2 * 1024 * 1024
91
+
92
+
93
+ def _load(path: Path, schema: str, keys: set, report: Report):
94
+ try:
95
+ st = os.stat(path)
96
+ if not stat.S_ISREG(st.st_mode) or st.st_size > MAX_RECORD_BYTES:
97
+ report.error(path, "unreadable", "记录必须是不超过 2 MB 的普通文件")
98
+ return None
99
+ data = json.loads(path.read_text(encoding="utf-8"))
100
+ except (OSError, ValueError) as exc:
101
+ report.error(path, "unreadable", f"无法解析: {exc}")
102
+ return None
103
+ if not isinstance(data, dict):
104
+ report.error(path, "not_object", "顶层必须是 JSON object")
105
+ return None
106
+ if data.get("schema") != schema:
107
+ report.error(path, "schema", f"schema 必须是 {schema}")
108
+ return None
109
+ unknown = sorted(set(data) - keys)
110
+ if unknown:
111
+ report.error(path, "unknown_keys", f"未知字段: {', '.join(unknown)}")
112
+ return data
113
+
114
+
115
+ def _nonempty_str(value) -> bool:
116
+ return isinstance(value, str) and bool(value.strip())
117
+
118
+
119
+ def resolve_inside(root: Path, base: Path, rel) -> Path | None:
120
+ """Resolve a record-relative path; None when it is absolute or escapes the library."""
121
+ if not _nonempty_str(rel) or Path(rel).is_absolute():
122
+ return None
123
+ resolved = (base / rel).resolve()
124
+ try:
125
+ resolved.relative_to(root.resolve())
126
+ except ValueError:
127
+ return None
128
+ return resolved
129
+
130
+
131
+ def _check_resource(path: Path, data: dict, report: Report) -> dict | None:
132
+ rdir = path.parent
133
+ kind = rdir.parent.name
134
+ if data.get("id") != rdir.name or not ID_RE.match(str(data.get("id", ""))):
135
+ report.error(path, "id", f"id 必须与目录名 {rdir.name} 一致,且只用小写字母、数字、. _ -")
136
+ return None
137
+ if data.get("kind") != kind or kind not in RESOURCE_EXTS:
138
+ report.error(path, "kind", f"kind 必须是所在目录 {kind},且属于 {sorted(RESOURCE_EXTS)}")
139
+ return None
140
+ if not _nonempty_str(data.get("title")):
141
+ report.error(path, "title", "缺少 title")
142
+ files = data.get("files", [])
143
+ if not isinstance(files, list):
144
+ report.error(path, "files", "files 必须是数组")
145
+ files = []
146
+ resolved = []
147
+ for index, item in enumerate(files):
148
+ rel = item.get("path") if isinstance(item, dict) else None
149
+ target = resolve_inside(report.root, rdir, rel)
150
+ if target is None:
151
+ report.error(path, "file_path", f"files[{index}].path 必须是库内相对路径")
152
+ continue
153
+ if not _nonempty_str(item.get("role")):
154
+ report.error(path, "file_role", f"files[{index}] 缺少 role")
155
+ if target.suffix.lower() not in RESOURCE_EXTS[kind]:
156
+ report.error(path, "file_ext", f"files[{index}] 扩展名不适用于 {kind}: {target.name}")
157
+ if not target.is_file():
158
+ report.error(path, "file_missing", f"文件不存在: {rel}")
159
+ continue
160
+ resolved.append({"role": item.get("role"), "path": str(target), **file_identity(target)})
161
+ if kind != "voice" and not files:
162
+ report.error(path, "files", f"{kind} 资源至少需要一个文件")
163
+ licence = data.get("license")
164
+ status = licence.get("status") if isinstance(licence, dict) else None
165
+ if status not in LICENSE_STATUSES:
166
+ report.error(path, "license", f"license.status 必须是 {LICENSE_STATUSES} 之一")
167
+ elif status in {"unknown", "restricted"}:
168
+ report.warn(path, f"license_{status}", f"授权状态为 {status},交付前需要人工确认")
169
+ if kind == "voice":
170
+ voice = data.get("voice")
171
+ if not isinstance(voice, dict) or voice.get("provider") not in VOICE_PROVIDERS:
172
+ report.error(path, "voice", f"voice.provider 必须是 {VOICE_PROVIDERS} 之一")
173
+ elif voice["provider"] != "mimo-tts" and not _nonempty_str(voice.get("voice_id")):
174
+ report.error(path, "voice", f"{voice['provider']} 音色需要 voice.voice_id(只有 mimo-tts 支持参考音频克隆)")
175
+ elif not (_nonempty_str(voice.get("voice_id")) or files):
176
+ report.error(path, "voice", "voice 资源需要 voice.voice_id 或一个参考音频文件")
177
+ if files:
178
+ consent = data.get("consent")
179
+ consent_status = consent.get("status") if isinstance(consent, dict) else None
180
+ if consent_status not in CONSENT_STATUSES:
181
+ report.error(path, "consent", f"参考音频需要 consent.status({CONSENT_STATUSES})")
182
+ elif consent_status != "granted":
183
+ report.warn(path, f"consent_{consent_status}", "参考音频的声音授权未确认")
184
+ return {"id": data["id"], "kind": kind, "title": data.get("title", ""),
185
+ "license": status, "files": resolved, "record": str(path)}
186
+
187
+
188
+ def _param_values(node, where="params"):
189
+ """Yield (where, dict) for every nested dict in a template's params."""
190
+ if isinstance(node, dict):
191
+ yield where, node
192
+ for key, value in node.items():
193
+ yield from _param_values(value, f"{where}.{key}")
194
+ elif isinstance(node, list):
195
+ for index, value in enumerate(node):
196
+ yield from _param_values(value, f"{where}[{index}]")
197
+
198
+
199
+ def _check_rect(path, where, rect, canvas, report):
200
+ fields = ("x", "y", "width", "height")
201
+ if not isinstance(rect, dict) or not all(_is_int(rect.get(f)) for f in fields):
202
+ report.error(path, "rect", f"{where} 需要整数 x / y / width / height")
203
+ return
204
+ if (rect["x"] < 0 or rect["y"] < 0 or rect["width"] <= 0 or rect["height"] <= 0
205
+ or rect["x"] + rect["width"] > canvas["width"]
206
+ or rect["y"] + rect["height"] > canvas["height"]):
207
+ report.error(path, "rect_outside_canvas", f"{where} 超出画布 {canvas['width']}x{canvas['height']}")
208
+
209
+
210
+ def _is_int(value) -> bool:
211
+ return isinstance(value, int) and not isinstance(value, bool)
212
+
213
+
214
+ def _param_number(params, key):
215
+ node = params.get(key)
216
+ value = node.get("value") if isinstance(node, dict) else None
217
+ return value if isinstance(value, (int, float)) and not isinstance(value, bool) and value > 0 else None
218
+
219
+
220
+ def _check_template(path: Path, data: dict, report: Report) -> dict | None:
221
+ vdir = path.parent
222
+ tid, kind = vdir.parent.name, vdir.parent.parent.name
223
+ version = data.get("version")
224
+ if data.get("id") != tid or not ID_RE.match(str(tid)):
225
+ report.error(path, "id", f"id 必须与目录名 {tid} 一致")
226
+ return None
227
+ if not isinstance(version, int) or isinstance(version, bool) or version < 1 or vdir.name != f"v{version}":
228
+ report.error(path, "version", f"version 必须是正整数,且目录名为 v<version>(当前 {vdir.name})")
229
+ return None
230
+ if data.get("kind") != kind or kind not in TEMPLATE_KINDS:
231
+ report.error(path, "kind", f"kind 必须是所在目录 {kind},且属于 {TEMPLATE_KINDS}")
232
+ return None
233
+ canvas = data.get("canvas")
234
+ if not (isinstance(canvas, dict) and all(isinstance(canvas.get(k), int) and canvas[k] > 0
235
+ for k in ("width", "height"))):
236
+ report.error(path, "canvas", "canvas 需要正整数 width / height")
237
+ canvas = None
238
+ params = data.get("params")
239
+ if not isinstance(params, dict):
240
+ report.error(path, "params", "params 必须是 object")
241
+ params = {}
242
+ refs = []
243
+ for where, node in _param_values(params):
244
+ if "provenance" in node:
245
+ if node["provenance"] not in PROVENANCES or "value" not in node:
246
+ report.error(path, "provenance", f"{where} 需要 value 与 provenance({PROVENANCES})")
247
+ if "resource" in node:
248
+ if _nonempty_str(node["resource"]):
249
+ refs.append((where, node["resource"]))
250
+ else:
251
+ report.error(path, "resource_ref", f"{where}.resource 必须是资源 id")
252
+ if kind == "subtitle_style":
253
+ unknown = sorted(set(params) - SUBTITLE_PARAMS)
254
+ if unknown:
255
+ report.error(path, "unknown_params", f"subtitle_style 不认识的参数: {', '.join(unknown)}")
256
+ font = params.get("font")
257
+ if not (isinstance(font, dict) and (_nonempty_str(font.get("resource")) or _nonempty_str(font.get("family")))):
258
+ report.error(path, "font", "subtitle_style 需要 params.font.resource 或 params.font.family")
259
+ if not isinstance(params.get("size_px"), dict):
260
+ report.error(path, "size_px", "subtitle_style 需要 params.size_px")
261
+ for key in ("size_px", "max_chars", "max_lines"):
262
+ node = params.get(key)
263
+ if node is not None and not (isinstance(node, dict) and _is_int(node.get("value")) and node["value"] > 0):
264
+ report.error(path, "integer", f"params.{key}.value 必须是正整数(渲染按整数像素与字数处理)")
265
+ for key in ("outline_px", "shadow_px"):
266
+ node = params.get(key)
267
+ value = node.get("value") if isinstance(node, dict) else None
268
+ if node is not None and not (isinstance(value, (int, float)) and not isinstance(value, bool) and value >= 0):
269
+ report.error(path, "number", f"params.{key}.value 必须是非负数")
270
+ size, per_line = (_param_number(params, "size_px"), _param_number(params, "max_chars"))
271
+ if per_line is None:
272
+ report.error(path, "max_chars", "subtitle_style 需要 params.max_chars:按最长一行在这块画布上校准")
273
+ elif canvas and size and size * per_line > canvas["width"] - 2 * SUBTITLE_SIDE_MARGIN:
274
+ report.error(path, "line_too_wide",
275
+ f"{per_line} 字 × {size}px 超过画布宽 {canvas['width']} 减去两侧各 "
276
+ f"{SUBTITLE_SIDE_MARGIN}px 边距;减小字号或每行字数")
277
+ band = params.get("band", {}).get("value") if isinstance(params.get("band"), dict) else None
278
+ if band is not None and canvas and not (
279
+ isinstance(band, dict) and _is_int(band.get("y_top")) and _is_int(band.get("y_bot"))
280
+ and 0 <= band["y_top"] < band["y_bot"] <= canvas["height"]
281
+ ):
282
+ report.error(path, "band", "params.band.value 需要 0 <= y_top < y_bot <= 画布高度")
283
+ if kind == "packaging":
284
+ layers = params.get("layers")
285
+ if not isinstance(layers, list) or not layers:
286
+ report.error(path, "layers", "packaging 需要非空 params.layers")
287
+ layers = []
288
+ names = [layer.get("name") for layer in layers if isinstance(layer, dict)]
289
+ if len(names) != len(set(names)) or not all(_nonempty_str(n) for n in names):
290
+ report.error(path, "layers", "每个图层需要唯一的 name")
291
+ for index, layer in enumerate(layers):
292
+ if not (isinstance(layer, dict) and isinstance(layer.get("image"), dict)
293
+ and _nonempty_str(layer["image"].get("resource"))):
294
+ report.error(path, "layer", f"params.layers[{index}] 需要 image.resource")
295
+ continue
296
+ if canvas:
297
+ _check_rect(path, f"params.layers[{index}].rect", layer.get("rect"), canvas, report)
298
+ if canvas and "safe_rect" in params:
299
+ _check_rect(path, "params.safe_rect", params["safe_rect"], canvas, report)
300
+ status = data.get("status")
301
+ if status not in TEMPLATE_STATUSES:
302
+ report.error(path, "status", f"status 必须是 {TEMPLATE_STATUSES} 之一")
303
+ adoption = data.get("adoption")
304
+ if status == "adopted":
305
+ if not (isinstance(adoption, dict) and DATE_RE.match(str(adoption.get("date", "")))
306
+ and all(_nonempty_str(adoption.get(k)) for k in ("by", "statement", "scope"))):
307
+ report.error(path, "adoption", "adopted 模板需要 adoption.date(YYYY-MM-DD) / by / statement / scope")
308
+ samples = data.get("samples", [])
309
+ if not (isinstance(samples, list) and all(_nonempty_str(x) for x in samples)):
310
+ report.error(path, "samples", "samples 必须是样片 id 数组")
311
+ samples = []
312
+ snapshot = adoption.get("resources") if isinstance(adoption, dict) else None
313
+ if snapshot is not None and not (
314
+ isinstance(snapshot, dict)
315
+ and all(isinstance(v, list) and all(isinstance(f, dict) for f in v) for v in snapshot.values())
316
+ ):
317
+ report.error(path, "adoption_resources", "adoption.resources 必须是 {资源 id: [{path, size, mtime_ns}]}")
318
+ adoption = {k: v for k, v in adoption.items() if k != "resources"}
319
+ return {"id": tid, "version": version, "kind": kind, "title": data.get("title", ""),
320
+ "status": status, "canvas": canvas, "refs": refs,
321
+ "samples": samples, "adoption": adoption, "record": str(path)}
322
+
323
+
324
+ def _check_sample(path: Path, data: dict, report: Report) -> dict | None:
325
+ sdir = path.parent
326
+ if data.get("id") != sdir.name or not ID_RE.match(sdir.name):
327
+ report.error(path, "id", f"id 必须与目录名 {sdir.name} 一致")
328
+ return None
329
+ for key in ("title", "not_reusable"):
330
+ if not _nonempty_str(data.get(key)):
331
+ report.error(path, key, f"缺少 {key}")
332
+ if not (isinstance(data.get("demonstrates"), list) and data["demonstrates"]
333
+ and all(_nonempty_str(x) for x in data["demonstrates"])):
334
+ report.error(path, "demonstrates", "demonstrates 需要非空字符串数组")
335
+ rel = data.get("file", {}).get("path") if isinstance(data.get("file"), dict) else None
336
+ target = None
337
+ if _nonempty_str(rel) and Path(rel).is_absolute():
338
+ target = Path(rel)
339
+ if not target.is_file():
340
+ report.warn(path, "sample_offline", f"样片不在本机: {rel}")
341
+ target = None
342
+ else:
343
+ target = resolve_inside(report.root, sdir, rel)
344
+ if target is None:
345
+ report.error(path, "file_path", "file.path 必须是库内相对路径或绝对路径")
346
+ elif not target.is_file():
347
+ report.error(path, "file_missing", f"样片不存在: {rel}")
348
+ target = None
349
+ if target is not None and target.suffix.lower() not in SAMPLE_EXTS:
350
+ report.error(path, "file_ext", f"样片扩展名不支持: {target.name}")
351
+ templates = data.get("templates", [])
352
+ if not (isinstance(templates, list) and all(_nonempty_str(x) for x in templates)):
353
+ report.error(path, "templates", "templates 必须是 id@vN 字符串数组")
354
+ templates = []
355
+ return {"id": data["id"], "title": data.get("title", ""), "file": str(target) if target else None,
356
+ "templates": templates, "record": str(path)}
357
+
358
+
359
+ def _check_links(index: dict, report: Report):
360
+ resources = {r["id"]: r for r in index["resources"]}
361
+ templates = {f"{t['id']}@v{t['version']}": t for t in index["templates"]}
362
+ samples = {s["id"] for s in index["samples"]}
363
+ expected_kind = {"params.font": "font"}
364
+ for template in index["templates"]:
365
+ path = Path(template["record"])
366
+ for where, ref in template["refs"]:
367
+ resource = resources.get(ref)
368
+ want = expected_kind.get(where) or ("image" if where.endswith(".image") else None)
369
+ if resource is None:
370
+ report.error(path, "resource_missing", f"{where} 引用的资源不存在: {ref}")
371
+ elif want and resource["kind"] != want:
372
+ report.error(path, "resource_kind", f"{where} 需要 {want} 资源,{ref} 是 {resource['kind']}")
373
+ elif want == "font" and not _nonempty_str(
374
+ (json.loads(Path(resource["record"]).read_text(encoding="utf-8")).get("font") or {}).get("family")
375
+ ):
376
+ report.error(path, "font_family", f"字体资源 {ref} 需要 font.family,渲染才能按名字找到这份字体")
377
+ for sample_id in template["samples"]:
378
+ if sample_id not in samples:
379
+ report.error(path, "sample_missing", f"引用的样片不存在: {sample_id}")
380
+ snapshot = (template["adoption"] or {}).get("resources") if isinstance(template["adoption"], dict) else None
381
+ for res_id, files in (snapshot or {}).items():
382
+ current = {Path(f["path"]).relative_to(report.root.resolve()).as_posix(): f
383
+ for f in resources.get(res_id, {}).get("files", [])}
384
+ for recorded in files if isinstance(files, list) else []:
385
+ now = current.get(recorded.get("path"))
386
+ if now is None or (now["size"], now["mtime_ns"]) != (recorded.get("size"), recorded.get("mtime_ns")):
387
+ report.warn(path, "changed_since_adoption",
388
+ f"采用后资源已变化: {res_id} {recorded.get('path')},需重新采用或出新版本")
389
+ for sample in index["samples"]:
390
+ for ref in sample["templates"]:
391
+ if ref not in templates:
392
+ report.error(Path(sample["record"]), "template_missing", f"引用的模板不存在: {ref}")
393
+
394
+
395
+ def _guarded(check, path, data, report):
396
+ """Run one record check; a shape the checks did not anticipate becomes an error, never a crash."""
397
+ if not data:
398
+ return None
399
+ try:
400
+ return check(path, data, report)
401
+ except (TypeError, KeyError, AttributeError, ValueError, IndexError) as exc:
402
+ report.error(path, "malformed", f"记录结构无法识别: {type(exc).__name__}: {exc}")
403
+ return None
404
+
405
+
406
+ def scan_library(root) -> tuple[dict, Report]:
407
+ """Load and validate every record under ``root``; never writes."""
408
+ root = Path(root).resolve()
409
+ report = Report(root)
410
+ index = {"resources": [], "templates": [], "samples": []}
411
+ meta = root / "library.json"
412
+ if meta.is_file():
413
+ _load(meta, LIBRARY_SCHEMA, {"schema", "name", "notes"}, report)
414
+ else:
415
+ report.warn(meta, "no_library_json", "缺少 library.json(仍会扫描资源、模板与样片)")
416
+ for path in sorted(root.glob("resources/*/*/resource.json")):
417
+ data = _load(path, RESOURCE_SCHEMA, RESOURCE_KEYS, report)
418
+ entry = _guarded(_check_resource, path, data, report)
419
+ if entry:
420
+ index["resources"].append(entry)
421
+ for path in sorted(root.glob("templates/*/*/v*/template.json")):
422
+ data = _load(path, TEMPLATE_SCHEMA, TEMPLATE_KEYS, report)
423
+ entry = _guarded(_check_template, path, data, report)
424
+ if entry:
425
+ index["templates"].append(entry)
426
+ for path in sorted(root.glob("samples/*/sample.json")):
427
+ data = _load(path, SAMPLE_SCHEMA, SAMPLE_KEYS, report)
428
+ entry = _guarded(_check_sample, path, data, report)
429
+ if entry:
430
+ index["samples"].append(entry)
431
+ try:
432
+ _check_links(index, report)
433
+ except (TypeError, KeyError, AttributeError, ValueError, IndexError, OSError) as exc:
434
+ report.error(root, "malformed_links", f"交叉引用无法核对: {type(exc).__name__}: {exc}")
435
+ return index, report
436
+
437
+
438
+ def _library_root(value):
439
+ root = value or os.environ.get(LIBRARY_ENV)
440
+ if not root:
441
+ raise SystemExit(f"需要 --library-dir 或环境变量 {LIBRARY_ENV}")
442
+ root = Path(root).expanduser().resolve()
443
+ if not root.is_dir():
444
+ raise SystemExit(f"库目录不存在: {root}")
445
+ return root
446
+
447
+
448
+ def _print_issues(report: Report):
449
+ for level, items in (("ERROR", report.errors), ("WARN", report.warnings)):
450
+ for item in items:
451
+ print(f"{level} {item['path']} [{item['code']}] {item['message']}")
452
+
453
+
454
+ def main(argv=None):
455
+ ap = argparse.ArgumentParser(description="video-recap 资源库:只读列出、查看与校验。")
456
+ ap.add_argument("--library-dir", help=f"库根目录(默认读取 {LIBRARY_ENV})")
457
+ sub = ap.add_subparsers(dest="command", required=True)
458
+ list_cmd = sub.add_parser("list", help="列出资源、模板与样片")
459
+ list_cmd.add_argument("--kind", help="只看某一类,如 bgm / font / subtitle_style")
460
+ list_cmd.add_argument("--json", action="store_true")
461
+ show_cmd = sub.add_parser("show", help="查看一个条目(模板可写 id 或 id@vN)")
462
+ show_cmd.add_argument("id")
463
+ check_cmd = sub.add_parser("check", help="校验整个库;有错误时退出码为 1")
464
+ check_cmd.add_argument("--json", action="store_true")
465
+ args = ap.parse_args(argv)
466
+ index, report = scan_library(_library_root(args.library_dir))
467
+
468
+ if args.command == "check":
469
+ if args.json:
470
+ print(json.dumps({"ok": not report.errors, "errors": report.errors,
471
+ "warnings": report.warnings,
472
+ "counts": {k: len(v) for k, v in index.items()}},
473
+ ensure_ascii=False, indent=2))
474
+ else:
475
+ _print_issues(report)
476
+ print(f"{len(report.errors)} error(s), {len(report.warnings)} warning(s); "
477
+ + ", ".join(f"{k} {len(v)}" for k, v in index.items()))
478
+ return 1 if report.errors else 0
479
+
480
+ rows = [{"type": "resource", "kind": r["kind"], "id": r["id"], "title": r["title"],
481
+ "status": r["license"]} for r in index["resources"]]
482
+ rows += [{"type": "template", "kind": t["kind"], "id": f"{t['id']}@v{t['version']}",
483
+ "title": t["title"], "status": t["status"]} for t in index["templates"]]
484
+ rows += [{"type": "sample", "kind": "sample", "id": s["id"], "title": s["title"],
485
+ "status": "online" if s["file"] else "offline"} for s in index["samples"]]
486
+ if args.command == "list":
487
+ rows = [r for r in rows if not args.kind or r["kind"] == args.kind]
488
+ if args.json:
489
+ print(json.dumps(rows, ensure_ascii=False, indent=2))
490
+ else:
491
+ for r in rows:
492
+ print(f"{r['type']:<9} {r['kind']:<15} {r['id']:<36} {r['status']:<10} {r['title']}")
493
+ return 0
494
+
495
+ matches = [e for group in index.values() for e in group
496
+ if args.id in {e["id"], f"{e['id']}@v{e.get('version')}"}]
497
+ if not matches:
498
+ print(f"未找到: {args.id}", file=sys.stderr)
499
+ return 1
500
+ for entry in matches:
501
+ record = json.loads(Path(entry["record"]).read_text(encoding="utf-8"))
502
+ print(json.dumps({"record": entry["record"], **record,
503
+ **({"resolved_files": entry["files"]} if "files" in entry else {})},
504
+ ensure_ascii=False, indent=2))
505
+ return 0
506
+
507
+
508
+ if __name__ == "__main__":
509
+ sys.exit(main())