@oh-story/dsh 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -12
- package/lib/client.js +2692 -268
- package/lib/client.js.map +4 -4
- package/lib/drama/manifest.json +136 -101
- package/lib/drama/skills/short-drama/SKILL.md +61 -1
- package/lib/drama/skills/short-drama/references/contract-and-ownership.md +7 -4
- package/lib/drama/skills/short-drama/references/creator-documents.md +133 -8
- package/lib/drama/skills/short-drama/references/creator-workflow.md +38 -2
- package/lib/drama/skills/short-drama/references/knowhow-index.md +3 -0
- package/lib/drama/skills/short-drama/references/reference-roles.md +10 -7
- package/lib/drama/skills/short-drama/references/runtime-preflight.md +3 -0
- package/lib/drama/skills/short-drama/scripts/creator_markdown_check.py +1002 -0
- package/lib/drama/skills/short-drama/scripts/project_tool.py +485 -5
- package/lib/drama/skills/short-drama-assets/SKILL.md +13 -3
- package/lib/drama/skills/short-drama-assets/references/continuity-lock.md +116 -0
- package/lib/drama/skills/short-drama-assets/references/identity-vs-variant.md +2 -1
- package/lib/drama/skills/short-drama-assets/references/prop-and-state.md +19 -0
- package/lib/drama/skills/short-drama-assets/references/stage-contract.md +2 -0
- package/lib/drama/skills/short-drama-assets/scripts/asset_check.py +1 -1
- package/lib/drama/skills/short-drama-image-prompts/SKILL.md +6 -2
- package/lib/drama/skills/short-drama-image-prompts/references/common-recipe.md +4 -3
- package/lib/drama/skills/short-drama-image-prompts/references/lookdev-frame.md +1 -1
- package/lib/drama/skills/short-drama-image-prompts/references/review-and-fixtures.md +1 -1
- package/lib/drama/skills/short-drama-image-prompts/references/stage-contract.md +3 -1
- package/lib/drama/skills/short-drama-image-prompts/scripts/image_prompt_check.py +8 -8
- package/lib/drama/skills/short-drama-image-prompts/scripts/selftest.py +4 -2
- package/lib/drama/skills/short-drama-produce/SKILL.md +46 -10
- package/lib/drama/skills/short-drama-produce/references/adapter-contract.md +65 -8
- package/lib/drama/skills/short-drama-produce/references/providers/minimax-h3-video.md +85 -0
- package/lib/drama/skills/short-drama-produce/references/providers/seedance.md +27 -10
- package/lib/drama/skills/short-drama-produce/scripts/production_tool.py +362 -3
- package/lib/drama/skills/short-drama-produce/scripts/provider_adapters.py +627 -40
- package/lib/drama/skills/short-drama-produce/scripts/selftest.py +5 -4
- package/lib/drama/skills/short-drama-review/references/rubric-visual-motion.md +12 -0
- package/lib/drama/skills/short-drama-review/scripts/review_check.py +1 -1
- package/lib/drama/skills/short-drama-storyboard/SKILL.md +76 -7
- package/lib/drama/skills/short-drama-storyboard/assets/shot-template.jsonl +1 -1
- package/lib/drama/skills/short-drama-storyboard/references/keyframe-craft.md +6 -2
- package/lib/drama/skills/short-drama-storyboard/references/production-shot-grammar.md +19 -4
- package/lib/drama/skills/short-drama-storyboard/references/review-and-fixtures.md +5 -2
- package/lib/drama/skills/short-drama-storyboard/references/screenplay-to-keyframe-example.md +16 -0
- package/lib/drama/skills/short-drama-storyboard/references/stage-contract.md +8 -3
- package/lib/drama/skills/short-drama-storyboard/scripts/storyboard_check.py +1 -1
- package/lib/drama/skills/short-drama-video-prompts/SKILL.md +81 -13
- package/lib/drama/skills/short-drama-video-prompts/assets/motion-spec.jsonl.md +6 -1
- package/lib/drama/skills/short-drama-video-prompts/assets/video-prompts.md +17 -1
- package/lib/drama/skills/short-drama-video-prompts/references/delivery-profile.md +21 -1
- package/lib/drama/skills/short-drama-video-prompts/references/minimax-h3.md +154 -0
- package/lib/drama/skills/short-drama-video-prompts/references/motion-recipe.md +24 -6
- package/lib/drama/skills/short-drama-video-prompts/references/production-prompt-grammar.md +11 -7
- package/lib/drama/skills/short-drama-video-prompts/references/seedance-2.0.md +41 -0
- package/lib/drama/skills/short-drama-video-prompts/references/seedance-2.5.md +66 -0
- package/lib/drama/skills/short-drama-video-prompts/references/stage-contract.md +5 -2
- package/lib/drama/skills/short-drama-video-prompts/references/target-model-profile.md +115 -0
- package/lib/drama/skills/short-drama-video-prompts/scripts/container_check.py +1 -1
- package/lib/drama/skills/short-drama-video-prompts/scripts/music_spec_check.py +1 -1
- package/lib/drama/skills/short-drama-write/SKILL.md +3 -2
- package/lib/drama/skills/short-drama-write/scripts/duration_estimate.py +1 -1
- package/lib/drama/skills/short-drama-write/scripts/screenplay_index.py +2 -2
- package/lib/drama/skills/short-drama-write/scripts/voice_sheet_check.py +1 -1
- package/lib/index.js +865 -33
- package/lib/index.js.map +4 -4
- package/lib/novel-to-game/LICENSE +21 -0
- package/lib/novel-to-game/README.md +180 -0
- package/lib/novel-to-game/README_ZH.md +178 -0
- package/lib/novel-to-game/VERSION +1 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/BUILD_BRIEF.md +217 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/.vercelignore +3 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/RUN.md +130 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/bg/compound_new_guofeng.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/fate_coda.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/meng.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/pan.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/pinger.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/xuee.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/yue.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_accord_five.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_afterglow_five.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_alliance.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/public_day10.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/public_day15.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/public_day5.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/title_new_guofeng.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/pan_pinger.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/pan_xuee.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/yue_meng.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/yue_pan.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/yue_pinger.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/meng/explicit.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/meng/prelude.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/meng.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/pan.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/pinger.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/xuee.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/yue.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pan/explicit.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pan/prelude.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pinger/explicit.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pinger/prelude.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/xuee/explicit.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/xuee/prelude.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/yue/explicit.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/yue/prelude.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/meng/night.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/pan/night.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/pinger/night.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/xuee/night.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/yue/night.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/household/li_jiaoer.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/scene/gate_collector.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/css/new-guofeng.css +1105 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/css/style.css +2539 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/index.html +18 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/assets.js +147 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/audio.js +332 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/data.js +7472 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/engine.js +13077 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/main.js +3028 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/text.js +32 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/package.json +10 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/vercel.json +23 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/art/generated-art.json +161 -0
- package/lib/novel-to-game/examples/jin-ping-mei/example.json +12 -0
- package/lib/novel-to-game/examples/jin-ping-mei/qa/README.md +31 -0
- package/lib/novel-to-game/examples/jin-ping-mei/qa/playable-model.json +99 -0
- package/lib/novel-to-game/examples/jin-ping-mei/qa/verification.json +41 -0
- package/lib/novel-to-game/examples/jin-ping-mei/qa/verify_playable_model.mjs +129 -0
- package/lib/novel-to-game/manifest.json +508 -0
- package/lib/novel-to-game/skills/game-art-direction/SKILL.md +73 -0
- package/lib/novel-to-game/skills/game-art-direction/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/game-art-direction/references/art-direction-method.md +119 -0
- package/lib/novel-to-game/skills/game-build/SKILL.md +84 -0
- package/lib/novel-to-game/skills/game-build/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/game-build/references/build-brief-contract.md +109 -0
- package/lib/novel-to-game/skills/game-build/references/generative-media-pipeline.md +56 -0
- package/lib/novel-to-game/skills/game-build/references/playable-model-contract.md +81 -0
- package/lib/novel-to-game/skills/game-build/references/tts-production-contract.md +37 -0
- package/lib/novel-to-game/skills/game-concept/SKILL.md +72 -0
- package/lib/novel-to-game/skills/game-concept/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/game-concept/references/concept-method.md +94 -0
- package/lib/novel-to-game/skills/game-qa/SKILL.md +50 -0
- package/lib/novel-to-game/skills/game-qa/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/game-qa/references/qa-contract.md +66 -0
- package/lib/novel-to-game/skills/game-qa/references/test-design-method.md +45 -0
- package/lib/novel-to-game/skills/game-world-design/SKILL.md +63 -0
- package/lib/novel-to-game/skills/game-world-design/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/game-world-design/references/dialogue-design-method.md +59 -0
- package/lib/novel-to-game/skills/game-world-design/references/game-writing-craft.md +53 -0
- package/lib/novel-to-game/skills/game-world-design/references/narrative-design-method.md +84 -0
- package/lib/novel-to-game/skills/game-world-design/references/numeric-design-method.md +56 -0
- package/lib/novel-to-game/skills/game-world-design/references/world-design-method.md +124 -0
- package/lib/novel-to-game/skills/novel-game-analyze/SKILL.md +77 -0
- package/lib/novel-to-game/skills/novel-game-analyze/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/novel-game-analyze/references/gameability-protocol.md +65 -0
- package/lib/novel-to-game/skills/novel-to-game/SKILL.md +71 -0
- package/lib/novel-to-game/skills/novel-to-game/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/novel-to-game/references/intake-benchmark-reference.md +42 -0
- package/lib/novel-to-game/skills/novel-to-game/references/intake-method.md +51 -0
- package/lib/novel-to-game/skills/novel-to-game/references/pipeline-contract.md +65 -0
- package/lib/oh-story/manifest.json +415 -305
- package/lib/oh-story/roles/consistency-checker.md +1 -1
- package/lib/oh-story/roles/narrative-writer.md +32 -33
- package/lib/oh-story/roles/story-architect.md +16 -26
- package/lib/oh-story/skills/browser-cdp/SKILL.md +1 -1
- package/lib/oh-story/skills/story/SKILL.md +16 -9
- package/lib/oh-story/skills/story/VERSION +1 -1
- package/lib/oh-story/skills/story/references/author-memory.md +163 -0
- package/lib/oh-story/skills/story/scripts/author_memory_commit.py +871 -0
- package/lib/oh-story/skills/story-cover/SKILL.md +1 -1
- package/lib/oh-story/skills/story-deslop/SKILL.md +10 -5
- package/lib/oh-story/skills/story-deslop/references/anti-ai-writing.md +2 -1
- package/lib/oh-story/skills/story-deslop/references/author-memory.md +163 -0
- package/lib/oh-story/skills/story-deslop/references/banned-words.md +6 -4
- package/lib/oh-story/skills/story-deslop/scripts/author_memory_commit.py +871 -0
- package/lib/oh-story/skills/story-deslop/scripts/check-ai-patterns.js +64 -1
- package/lib/oh-story/skills/story-import/SKILL.md +19 -10
- package/lib/oh-story/skills/story-import/references/format-and-structure.md +9 -10
- package/lib/oh-story/skills/story-import/references/structure-mapping-long.md +2 -2
- package/lib/oh-story/skills/story-import/references/structure-mapping-short.md +1 -1
- package/lib/oh-story/skills/story-import/references/tracking-transaction.md +14 -6
- package/lib/oh-story/skills/story-import/scripts/check-outline-contract.js +251 -0
- package/lib/oh-story/skills/story-import/scripts/tracking_commit.py +98 -9
- package/lib/oh-story/skills/story-import/scripts/wordcount_core.py +246 -0
- package/lib/oh-story/skills/story-long-analyze/SKILL.md +4 -4
- package/lib/oh-story/skills/story-long-scan/SKILL.md +1 -1
- package/lib/oh-story/skills/story-long-write/SKILL.md +35 -21
- package/lib/oh-story/skills/story-long-write/references/anti-ai-writing.md +2 -1
- package/lib/oh-story/skills/story-long-write/references/artifact-protocols.md +7 -3
- package/lib/oh-story/skills/story-long-write/references/author-memory.md +163 -0
- package/lib/oh-story/skills/story-long-write/references/banned-words.md +6 -4
- package/lib/oh-story/skills/story-long-write/references/cross-book-recall.md +6 -6
- package/lib/oh-story/skills/story-long-write/references/genre-prose-cards.md +1 -1
- package/lib/oh-story/skills/story-long-write/references/genre-readers.md +1 -1
- package/lib/oh-story/skills/{story-setup/references/agent-references/hooks-chapter.md → story-long-write/references/long-chapter-hooks.md} +5 -5
- package/lib/oh-story/skills/story-long-write/references/{quality-checklist.md → long-chapter-quality.md} +2 -1
- package/lib/oh-story/skills/story-long-write/references/long-format.md +42 -0
- package/lib/oh-story/skills/{story-setup/references/agent-references/genre-catalog.md → story-long-write/references/long-genre-catalog.md} +11 -97
- package/lib/oh-story/skills/{story-setup/references/agent-references/genre-core-mechanics.md → story-long-write/references/long-genre-mechanics.md} +1 -1
- package/lib/oh-story/skills/{story-short-write/references/reversal-toolkit.md → story-long-write/references/long-reversal.md} +18 -32
- package/lib/oh-story/skills/story-long-write/references/{hooks-suspense.md → long-suspense.md} +6 -6
- package/lib/oh-story/skills/story-long-write/references/opening-design.md +1 -1
- package/lib/oh-story/skills/story-long-write/references/outline-structure-theory.md +1 -1
- package/lib/oh-story/skills/story-long-write/references/style-genre-modules.md +1 -1
- package/lib/oh-story/skills/story-long-write/references/tracking-transaction.md +14 -6
- package/lib/oh-story/skills/story-long-write/references/workflow-chapter.md +32 -27
- package/lib/oh-story/skills/story-long-write/references/workflow-daily.md +4 -4
- package/lib/oh-story/skills/story-long-write/references/workflow-revision.md +2 -2
- package/lib/oh-story/skills/story-long-write/references/workflow-setup.md +14 -14
- package/lib/oh-story/skills/story-long-write/references/writing-craft.md +54 -54
- package/lib/oh-story/skills/story-long-write/scripts/author_memory_commit.py +871 -0
- package/lib/oh-story/skills/story-long-write/scripts/check-ai-patterns.js +64 -1
- package/lib/oh-story/skills/story-long-write/scripts/check-outline-contract.js +251 -0
- package/lib/oh-story/skills/story-long-write/scripts/storyctl.py +303 -0
- package/lib/oh-story/skills/story-long-write/scripts/tracking_commit.py +98 -9
- package/lib/oh-story/skills/story-long-write/scripts/wordcount_core.py +246 -0
- package/lib/oh-story/skills/story-review/SKILL.md +26 -17
- package/lib/oh-story/skills/story-review/references/anti-ai-writing.md +2 -1
- package/lib/oh-story/skills/story-review/references/author-memory.md +163 -0
- package/lib/oh-story/skills/story-review/references/banned-words.md +6 -4
- package/lib/oh-story/skills/story-review/references/{quality-checklist.md → review-quality.md} +22 -21
- package/lib/oh-story/skills/story-review/references/tracking-transaction.md +14 -6
- package/lib/oh-story/skills/story-review/scripts/author_memory_commit.py +871 -0
- package/lib/oh-story/skills/story-review/scripts/check-ai-patterns.js +64 -1
- package/lib/oh-story/skills/story-review/scripts/tracking_commit.py +98 -9
- package/lib/oh-story/skills/story-review/scripts/wordcount_core.py +246 -0
- package/lib/oh-story/skills/story-setup/SKILL.md +74 -33
- package/lib/oh-story/skills/story-setup/references/agent-references/agent-quality.md +72 -0
- package/lib/oh-story/skills/story-setup/references/agent-references/agent-reference-profiles.md +55 -0
- package/lib/oh-story/skills/story-setup/references/agent-references/anti-ai-writing.md +2 -1
- package/lib/oh-story/skills/story-setup/references/agent-references/banned-words.md +6 -4
- package/lib/oh-story/skills/story-setup/references/agent-references/format-and-structure.md +9 -10
- package/lib/oh-story/skills/story-setup/references/agent-references/genre-prose-cards.md +1 -1
- package/lib/oh-story/skills/story-setup/references/agent-references/genre-readers.md +1 -1
- package/lib/oh-story/skills/{story-short-analyze/references/hooks-chapter.md → story-setup/references/agent-references/long-chapter-hooks.md} +5 -5
- package/lib/oh-story/skills/story-setup/references/agent-references/long-emotional-methods.md +209 -0
- package/lib/oh-story/skills/{story-long-write/references/genre-catalog.md → story-setup/references/agent-references/long-genre-catalog.md} +11 -97
- package/lib/oh-story/skills/{story-long-write/references/genre-core-mechanics.md → story-setup/references/agent-references/long-genre-mechanics.md} +1 -1
- package/lib/oh-story/skills/story-setup/references/agent-references/long-quality.md +40 -0
- package/lib/oh-story/skills/story-setup/references/agent-references/{reversal-toolkit.md → long-reversal.md} +18 -32
- package/lib/oh-story/skills/{story-short-write/references/hooks-suspense.md → story-setup/references/agent-references/long-suspense.md} +6 -6
- package/lib/oh-story/skills/story-setup/references/agent-references/opening-design.md +1 -1
- package/lib/oh-story/skills/story-setup/references/agent-references/{emotional-methods.md → short-emotional-methods.md} +4 -4
- package/lib/oh-story/skills/{story-long-write/references/genre-writing-formulas.md → story-setup/references/agent-references/short-genre-formulas.md} +32 -44
- package/lib/oh-story/skills/story-setup/references/agent-references/short-quality.md +39 -0
- package/lib/oh-story/skills/{story-long-write/references/reversal-toolkit.md → story-setup/references/agent-references/short-reversal.md} +29 -23
- package/lib/oh-story/skills/story-setup/references/agent-references/{hooks-suspense.md → short-suspense.md} +31 -31
- package/lib/oh-story/skills/story-setup/references/agent-references/style-genre-modules.md +1 -1
- package/lib/oh-story/skills/story-setup/references/agent-references/writing-craft.md +55 -55
- package/lib/oh-story/skills/story-short-analyze/SKILL.md +28 -28
- package/lib/oh-story/skills/story-short-analyze/references/{character-basics.md → analysis-character-basics.md} +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/{character-design-methods.md → analysis-character-design.md} +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/{character-relations.md → analysis-character-relations.md} +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/{hooks-paragraph.md → analysis-paragraph-hooks.md} +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/{genre-readers.md → analysis-reader-profile.md} +2 -2
- package/lib/oh-story/skills/story-short-analyze/references/analysis-report-style.md +45 -0
- package/lib/oh-story/skills/story-short-analyze/references/analysis-short-genres.md +65 -0
- package/lib/oh-story/skills/story-short-analyze/references/analysis-short-hooks.md +77 -0
- package/lib/oh-story/skills/story-short-analyze/references/analysis-short-mechanics.md +82 -0
- package/lib/oh-story/skills/story-short-analyze/references/analysis-short-patterns.md +50 -0
- package/lib/oh-story/skills/story-short-analyze/references/analysis-short-suspense.md +98 -0
- package/lib/oh-story/skills/story-short-analyze/references/{genre-writing-techniques.md → analysis-writing-techniques.md} +21 -19
- package/lib/oh-story/skills/story-short-analyze/references/deconstruction-examples.md +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/material-decomposition.md +21 -28
- package/lib/oh-story/skills/story-short-analyze/references/output-contract.md +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/output-templates.md +17 -17
- package/lib/oh-story/skills/story-short-analyze/references/{quality-checklist.md → source-story-quality.md} +28 -49
- package/lib/oh-story/skills/story-short-analyze/references/zhihu-style.md +2 -2
- package/lib/oh-story/skills/story-short-scan/SKILL.md +1 -1
- package/lib/oh-story/skills/story-short-write/SKILL.md +78 -55
- package/lib/oh-story/skills/story-short-write/references/author-memory.md +163 -0
- package/lib/oh-story/skills/story-short-write/references/banned-words.md +6 -4
- package/lib/oh-story/skills/story-short-write/references/cross-book-recall.md +3 -3
- package/lib/oh-story/skills/story-short-write/references/emotional-methods.md +4 -4
- 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
- package/lib/oh-story/skills/story-short-write/references/genre-styles//345/217/214/347/224/267/344/270/273.md +2 -2
- 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
- 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
- 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
- package/lib/oh-story/skills/story-short-write/references/genre-styles//346/202/254/347/226/221.md +4 -4
- 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
- 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
- package/lib/oh-story/skills/story-short-write/references/genre-styles//347/224/234/345/256/240.md +4 -4
- 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
- package/lib/oh-story/skills/story-short-write/references/genre-writing-formulas.md +32 -44
- package/lib/oh-story/skills/story-short-write/references/genre-writing-techniques.md +20 -18
- package/lib/oh-story/skills/story-short-write/references/output-contract.md +1 -1
- package/lib/oh-story/skills/story-short-write/references/short-craft.md +18 -18
- package/lib/oh-story/skills/story-short-write/references/short-deslop.md +1 -1
- package/lib/oh-story/skills/story-short-write/references/short-format.md +38 -8
- package/lib/oh-story/skills/story-short-write/references/{quality-checklist.md → short-prose-quality.md} +22 -21
- package/lib/oh-story/skills/story-short-write/references/short-reversal.md +355 -0
- package/lib/oh-story/skills/{story-short-analyze/references/hooks-suspense.md → story-short-write/references/short-suspense.md} +31 -31
- package/lib/oh-story/skills/story-short-write/references/submission-craft.md +2 -2
- package/lib/oh-story/skills/story-short-write/references/writing-workflow.md +31 -22
- package/lib/oh-story/skills/story-short-write/scripts/author_memory_commit.py +871 -0
- package/lib/oh-story/skills/story-short-write/scripts/check-ai-patterns.js +64 -1
- package/lib/oh-story/skills/story-short-write/scripts/check-delivery-contract.js +212 -0
- package/lib/oh-story/skills/story-short-write/scripts/check-phase2-contract.js +363 -0
- package/lib/types/client/drama-production-view.d.ts +34 -0
- package/lib/types/client/drama-production-view.d.ts.map +1 -0
- package/lib/types/client/drama-production.d.ts +92 -0
- package/lib/types/client/drama-production.d.ts.map +1 -0
- package/lib/types/client/file-activity.d.ts +4 -2
- package/lib/types/client/file-activity.d.ts.map +1 -1
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/production-intents.d.ts +9 -0
- package/lib/types/client/production-intents.d.ts.map +1 -0
- package/lib/types/client/production-prompts.d.ts +9 -0
- package/lib/types/client/production-prompts.d.ts.map +1 -0
- package/lib/types/client/production-runtime.d.ts +58 -0
- package/lib/types/client/production-runtime.d.ts.map +1 -0
- package/lib/types/client/video-studio.d.ts +41 -0
- package/lib/types/client/video-studio.d.ts.map +1 -0
- package/lib/types/client/workbench-ui.d.ts +5 -0
- package/lib/types/client/workbench-ui.d.ts.map +1 -0
- package/lib/types/game-verification.d.ts +16 -0
- package/lib/types/game-verification.d.ts.map +1 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/production-intent.d.ts +21 -0
- package/lib/types/production-intent.d.ts.map +1 -0
- package/lib/types/production-tool.d.ts +5 -0
- package/lib/types/production-tool.d.ts.map +1 -0
- package/lib/types/role-tool.d.ts.map +1 -1
- package/lib/types/skill-provider.d.ts +7 -0
- package/lib/types/skill-provider.d.ts.map +1 -1
- package/lib/types/video-project.d.ts +42 -0
- package/lib/types/video-project.d.ts.map +1 -0
- package/lib/types/workspace-request-trust.d.ts +6 -0
- package/lib/types/workspace-request-trust.d.ts.map +1 -1
- package/lib/types/workspace-route.d.ts +20 -0
- package/lib/types/workspace-route.d.ts.map +1 -1
- package/lib/video-recap/CHANGELOG.md +282 -0
- package/lib/video-recap/LICENSE +21 -0
- package/lib/video-recap/README.en.md +257 -0
- package/lib/video-recap/README.md +255 -0
- package/lib/video-recap/manifest.json +684 -0
- package/lib/video-recap/skills/video-assemble/SKILL.md +97 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/LICENSE.duo-video +21 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/SOURCE.md +15 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_draft_meta_info.json +69 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_combination_segment.json +84 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_combination_video_material.json +98 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_draft.json +204 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_material_video.json +83 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_meta_material_value.json +23 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_project_info.json +133 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_segment.json +70 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_text_styles.json +30 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_yj_material_audio.json +41 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_yj_material_text.json +109 -0
- package/lib/video-recap/skills/video-assemble/scripts/artifacts.py +88 -0
- package/lib/video-recap/skills/video-assemble/scripts/assemble.py +345 -0
- package/lib/video-recap/skills/video-assemble/scripts/assemble_constants.py +34 -0
- package/lib/video-recap/skills/video-assemble/scripts/assembly_contract.py +305 -0
- package/lib/video-recap/skills/video-assemble/scripts/assembly_settings.py +94 -0
- package/lib/video-recap/skills/video-assemble/scripts/audio_automation.py +205 -0
- package/lib/video-recap/skills/video-assemble/scripts/audio_mix.py +555 -0
- package/lib/video-recap/skills/video-assemble/scripts/export_jianying.py +261 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_builders.py +767 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_model.py +111 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_optional.py +24 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_schema.py +109 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_templates.py +37 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_timeline_contract.py +191 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_tracks.py +75 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_writer.py +394 -0
- package/lib/video-recap/skills/video-assemble/scripts/lib.py +239 -0
- package/lib/video-recap/skills/video-assemble/scripts/media.py +243 -0
- package/lib/video-recap/skills/video-assemble/scripts/narration_audio.py +477 -0
- package/lib/video-recap/skills/video-assemble/scripts/render_preflight.py +46 -0
- package/lib/video-recap/skills/video-assemble/scripts/source_subtitles.py +486 -0
- package/lib/video-recap/skills/video-assemble/scripts/subtitle_core.py +376 -0
- package/lib/video-recap/skills/video-assemble/scripts/subtitle_render.py +88 -0
- package/lib/video-recap/skills/video-assemble/scripts/timeline.py +248 -0
- package/lib/video-recap/skills/video-assemble/scripts/timeline_emit.py +89 -0
- package/lib/video-recap/skills/video-assemble/scripts/visual_render.py +512 -0
- package/lib/video-recap/skills/video-cut/SKILL.md +90 -0
- package/lib/video-recap/skills/video-cut/scripts/cut.py +67 -0
- package/lib/video-recap/skills/video-cut/scripts/cut_cli.py +320 -0
- package/lib/video-recap/skills/video-cut/scripts/cut_contract.py +545 -0
- package/lib/video-recap/skills/video-cut/scripts/cut_render.py +348 -0
- package/lib/video-recap/skills/video-cut/scripts/lib.py +77 -0
- package/lib/video-recap/skills/video-cut/scripts/media_geometry.py +341 -0
- package/lib/video-recap/skills/video-cut/scripts/narration_mapping.py +249 -0
- package/lib/video-recap/skills/video-cut/scripts/sentence_boundaries.py +745 -0
- package/lib/video-recap/skills/video-recap/SKILL.md +216 -0
- package/lib/video-recap/skills/video-recap/references/config-playbook.md +61 -0
- package/lib/video-recap/skills/video-recap/references/creative-editing-playbook.md +225 -0
- package/lib/video-recap/skills/video-recap/references/data-schema.md +534 -0
- package/lib/video-recap/skills/video-recap/references/research-guide.md +74 -0
- package/lib/video-recap/skills/video-recap/references/shift-left-qc-schema.md +23 -0
- package/lib/video-recap/skills/video-recap/references/timeline-and-jianying.md +251 -0
- package/lib/video-recap/skills/video-recap/scripts/doctor.py +483 -0
- package/lib/video-recap/skills/video-recap/scripts/final_qc.py +737 -0
- package/lib/video-recap/skills/video-recap/scripts/lib.py +242 -0
- package/lib/video-recap/skills/video-recap/scripts/materials.py +457 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc.py +95 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_client.py +18 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_contract.py +9 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_evidence.py +371 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_observations.py +201 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_payload.py +227 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_report.py +362 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_runner.py +129 -0
- package/lib/video-recap/skills/video-recap/scripts/qc_contract.py +338 -0
- package/lib/video-recap/skills/video-recap/scripts/recap.py +9 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_cli.py +140 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_inspect.py +550 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_review.py +77 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_runner.py +654 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_runtime.py +335 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_stage_qc.py +217 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_timeline.py +795 -0
- package/lib/video-recap/skills/video-script/SKILL.md +248 -0
- package/lib/video-recap/skills/video-script/references/creative-editing-playbook.md +225 -0
- package/lib/video-recap/skills/video-script/references/research-guide.md +75 -0
- package/lib/video-recap/skills/video-script/scripts/agent_brief.py +399 -0
- package/lib/video-recap/skills/video-script/scripts/agent_text.py +410 -0
- package/lib/video-recap/skills/video-script/scripts/brief_context.py +403 -0
- package/lib/video-recap/skills/video-script/scripts/brief_inputs.py +332 -0
- package/lib/video-recap/skills/video-script/scripts/brief_timeline.py +442 -0
- package/lib/video-recap/skills/video-script/scripts/deslop_qc.py +237 -0
- package/lib/video-recap/skills/video-script/scripts/evidence_bundle.py +492 -0
- package/lib/video-recap/skills/video-script/scripts/lib.py +327 -0
- package/lib/video-recap/skills/video-script/scripts/narration.py +12 -0
- package/lib/video-recap/skills/video-script/scripts/narration_lint.py +678 -0
- package/lib/video-recap/skills/video-script/scripts/review.py +42 -0
- package/lib/video-recap/skills/video-script/scripts/review_grounding.py +262 -0
- package/lib/video-recap/skills/video-script/scripts/review_response.py +761 -0
- package/lib/video-recap/skills/video-script/scripts/review_runner.py +200 -0
- package/lib/video-recap/skills/video-script/scripts/speech_ownership.py +204 -0
- package/lib/video-recap/skills/video-script/scripts/timeline_fusion.py +199 -0
- package/lib/video-recap/skills/video-script/scripts/validate.py +164 -0
- package/lib/video-recap/skills/video-understanding/SKILL.md +75 -0
- package/lib/video-recap/skills/video-understanding/references/data-schema.md +299 -0
- package/lib/video-recap/skills/video-understanding/references/prompt-templates.md +37 -0
- package/lib/video-recap/skills/video-understanding/references/research-guide.md +74 -0
- package/lib/video-recap/skills/video-understanding/scripts/agent_brief.py +399 -0
- package/lib/video-recap/skills/video-understanding/scripts/agent_text.py +410 -0
- package/lib/video-recap/skills/video-understanding/scripts/asr.py +260 -0
- package/lib/video-recap/skills/video-understanding/scripts/brief.py +12 -0
- package/lib/video-recap/skills/video-understanding/scripts/brief_context.py +403 -0
- package/lib/video-recap/skills/video-understanding/scripts/brief_inputs.py +332 -0
- package/lib/video-recap/skills/video-understanding/scripts/brief_timeline.py +442 -0
- package/lib/video-recap/skills/video-understanding/scripts/consolidate.py +647 -0
- package/lib/video-recap/skills/video-understanding/scripts/deslop_qc.py +237 -0
- package/lib/video-recap/skills/video-understanding/scripts/detect.py +513 -0
- package/lib/video-recap/skills/video-understanding/scripts/extract.py +62 -0
- package/lib/video-recap/skills/video-understanding/scripts/lib.py +470 -0
- package/lib/video-recap/skills/video-understanding/scripts/narration_lint.py +678 -0
- package/lib/video-recap/skills/video-understanding/scripts/speech_ownership.py +204 -0
- package/lib/video-recap/skills/video-understanding/scripts/storyboard.py +507 -0
- package/lib/video-recap/skills/video-understanding/scripts/timeline_fusion.py +199 -0
- package/lib/video-recap/skills/video-understanding/scripts/understand.py +9 -0
- package/lib/video-recap/skills/video-understanding/scripts/understanding_brief.py +216 -0
- package/lib/video-recap/skills/video-understanding/scripts/understanding_cache.py +327 -0
- package/lib/video-recap/skills/video-understanding/scripts/understanding_runner.py +367 -0
- package/lib/video-recap/skills/video-understanding/scripts/understanding_storyboard.py +162 -0
- package/lib/video-recap/skills/video-understanding/scripts/vlm.py +705 -0
- package/lib/video-recap/skills/video-voiceover/SKILL.md +81 -0
- package/lib/video-recap/skills/video-voiceover/scripts/dub.py +637 -0
- package/lib/video-recap/skills/video-voiceover/scripts/fish_audio.py +109 -0
- package/lib/video-recap/skills/video-voiceover/scripts/lib.py +421 -0
- package/lib/video-recap/skills/video-voiceover/scripts/tts_audio.py +113 -0
- package/lib/video-recap/skills/video-voiceover/scripts/voiceover.py +782 -0
- package/package.json +55 -40
- package/lib/oh-story/skills/story-deslop/scripts/check-outline-copy.js +0 -241
- package/lib/oh-story/skills/story-long-write/references/format-and-structure.md +0 -169
- package/lib/oh-story/skills/story-setup/references/agent-references/genre-writing-formulas.md +0 -444
- package/lib/oh-story/skills/story-setup/references/agent-references/quality-checklist.md +0 -247
- package/lib/oh-story/skills/story-short-analyze/references/anti-ai-writing.md +0 -582
- package/lib/oh-story/skills/story-short-analyze/references/banned-words.md +0 -147
- package/lib/oh-story/skills/story-short-analyze/references/genre-catalog.md +0 -490
- package/lib/oh-story/skills/story-short-analyze/references/genre-core-mechanics.md +0 -425
- package/lib/oh-story/skills/story-short-analyze/references/genre-writing-formulas.md +0 -453
- /package/lib/oh-story/skills/{story-long-write/references/hooks-chapter.md → story-setup/references/agent-references/short-chapter-hooks.md} +0 -0
- /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,647 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""video-understanding consolidation / 整理 (index build-up).
|
|
3
|
+
|
|
4
|
+
Optional, synchronous, in-pipeline. Two independent LLM passes over the video's own signal:
|
|
5
|
+
- Pass B (index, default): roll up per-scene vlm_analysis into a global
|
|
6
|
+
character / relationship / plot index -> understanding_index.json (+ .md).
|
|
7
|
+
- Pass A (asr cleanup, opt-in): clean/punctuate/lightly speaker-attribute the raw run-on
|
|
8
|
+
ASR text -> asr_clean.json. Timing is preserved BY CONSTRUCTION: the model returns cleaned
|
|
9
|
+
TEXT per segment index only; each segment's original start/end is re-attached here, so a
|
|
10
|
+
cleanup pass can never shift the timing-bearing spans downstream chunking depends on.
|
|
11
|
+
|
|
12
|
+
Both passes degrade gracefully (a chat-API failure logs and is skipped) and are idempotent
|
|
13
|
+
(a fresh artifact is reused). Mirrors review.py's pure-seam + thin-driver shape so it is
|
|
14
|
+
unit-testable with a mocked api_call. NON-required: the pipeline runs unchanged without it.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
import hashlib
|
|
19
|
+
import json
|
|
20
|
+
import re
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
from lib import CONFIG, log, api_call
|
|
24
|
+
from understanding_cache import _fresh
|
|
25
|
+
|
|
26
|
+
# Shared tolerance for the per-segment span check. The brief-side gate inlines the SAME
|
|
27
|
+
# literal (it cannot import this module without breaking the brief/narration byte-parity).
|
|
28
|
+
# Keep both in sync. Consolidate preserves spans exactly, so this only guards hand-edited files.
|
|
29
|
+
_ASR_SPAN_TOL = 0.05
|
|
30
|
+
ASR_CLEAN_POSTPROCESS_VERSION = 2
|
|
31
|
+
|
|
32
|
+
CLEAN_PROMPT = """你在清洗中文视频的 ASR 逐段转写。对【每一段】做:补标点、修明显同音/错别字、(能判断时)在句首轻标说话人,让长段连读文本变成清晰可读的句子。
|
|
33
|
+
铁律:
|
|
34
|
+
- 不要合并或拆分段落,输出段数必须与输入完全一致,顺序一致。
|
|
35
|
+
- 不要改时间,不要输出 start/end(时间由程序保留)。
|
|
36
|
+
- 只清洗 text,不要增删事实、不要脑补画面。
|
|
37
|
+
- 必须把相邻两段连起来检查标点是否连续;切窗处不是自然句尾时,不要凭单段补句号。
|
|
38
|
+
- 分段音频窗口互不重叠。相邻段首尾字面相同可能是合法复沓(例如“真的很难。难得让人想放弃”),不能仅凭文字相同删除任何一边的词;没有音频重叠证据时保留各段词汇内容。
|
|
39
|
+
只返回 JSON:{"segments":[{"i":0,"text":"清洗后的文本","speaker":"可选说话人"}, ...]},i 为输入段的下标。"""
|
|
40
|
+
|
|
41
|
+
INDEX_SCHEMA_VERSION = 2
|
|
42
|
+
|
|
43
|
+
INDEX_PROMPT = """你在根据逐场景画面分析、ASR对白、background_research术语表,为一个视频建立【全局理解索引】,供后续写解说词时保持人物/关系/主线一致。
|
|
44
|
+
规则:
|
|
45
|
+
- visual/asr 是当前视频事实证据;每个人物、关系、剧情节点、物件尽量给 evidence_ids。
|
|
46
|
+
- background_research 只能用于人名/别名/术语/身份消歧,默认 support=context_only;不能把后续剧情或未出现关系升级为当前画面事实。
|
|
47
|
+
- ASR 中出现但画面描述未命名的人名,应进入 characters[*].asr_mentions。
|
|
48
|
+
只返回 JSON:
|
|
49
|
+
{"characters":[{"name":"角色名或外观指代","description":"身份/特征","aliases":[],"visual_descriptions":[],"asr_mentions":[],"research_role":"","evidence_ids":[],"confidence":"high|medium|low"}],
|
|
50
|
+
"relationships":[{"a":"角色","b":"角色","relation":"关系","evidence_ids":[],"support":"direct|indirect|context_only"}],
|
|
51
|
+
"plot_points":[{"time":"00:00","text":"按时间顺序的关键剧情节点","evidence_ids":[]}],
|
|
52
|
+
"entities":[{"name":"重要物件/地点/线索","evidence_ids":[]}],
|
|
53
|
+
"research_glossary":[{"name":"名字/术语","aliases":[],"role":"说明","support":"context_only"}]}"""
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# ── pure seams (no I/O; unit-testable) ────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def build_clean_messages(asr_result):
|
|
60
|
+
lines = []
|
|
61
|
+
for i, seg in enumerate(asr_result or []):
|
|
62
|
+
if not isinstance(seg, dict):
|
|
63
|
+
continue
|
|
64
|
+
lines.append(f"{i}. {str(seg.get('text', '')).strip()}")
|
|
65
|
+
user = f"{CLEAN_PROMPT}\n\n## 逐段转写(共 {len(lines)} 段)\n" + "\n".join(lines)
|
|
66
|
+
return [{"role": "user", "content": user}]
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def parse_clean_response(text, asr_result):
|
|
70
|
+
"""Zip cleaned TEXT onto the original segments (start/end preserved by construction).
|
|
71
|
+
Returns the original asr_result UNCHANGED on any parse / shape / count problem."""
|
|
72
|
+
base = [s for s in (asr_result or []) if isinstance(s, dict)]
|
|
73
|
+
if not base:
|
|
74
|
+
return asr_result
|
|
75
|
+
data = _extract_json(text)
|
|
76
|
+
if not isinstance(data, dict):
|
|
77
|
+
return asr_result
|
|
78
|
+
segs = data.get("segments")
|
|
79
|
+
if not isinstance(segs, list) or len(segs) != len(base):
|
|
80
|
+
return asr_result # count mismatch -> reject wholesale (idempotent no-op)
|
|
81
|
+
by_index = {}
|
|
82
|
+
for item in segs:
|
|
83
|
+
if isinstance(item, dict) and isinstance(item.get("i"), int):
|
|
84
|
+
by_index[item["i"]] = item
|
|
85
|
+
if len(by_index) != len(base):
|
|
86
|
+
return asr_result
|
|
87
|
+
out = []
|
|
88
|
+
for i, seg in enumerate(base):
|
|
89
|
+
cleaned = by_index.get(i, {})
|
|
90
|
+
new_text = str(cleaned.get("text", "")).strip() or str(seg.get("text", ""))
|
|
91
|
+
merged = {"start": seg.get("start"), "end": seg.get("end"), "text": new_text}
|
|
92
|
+
speaker = str(cleaned.get("speaker", "")).strip()
|
|
93
|
+
if speaker:
|
|
94
|
+
merged["speaker"] = speaker
|
|
95
|
+
out.append(merged)
|
|
96
|
+
return out
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _json_md5_file(work_dir, name):
|
|
100
|
+
path = Path(work_dir) / name
|
|
101
|
+
return hashlib.md5(path.read_bytes()).hexdigest() if path.exists() else ""
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _asr_clean_source_md5(work_dir):
|
|
105
|
+
return _json_md5_file(work_dir, "asr_clean.json")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _research_source_md5(work_dir):
|
|
109
|
+
return _json_md5_file(work_dir, "background_research.json")
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _research_glossary_from_context(background_research):
|
|
113
|
+
glossary = []
|
|
114
|
+
if not isinstance(background_research, dict):
|
|
115
|
+
return glossary
|
|
116
|
+
chars = background_research.get("characters")
|
|
117
|
+
if isinstance(chars, dict):
|
|
118
|
+
for name, role in chars.items():
|
|
119
|
+
if str(name).strip():
|
|
120
|
+
glossary.append(
|
|
121
|
+
{
|
|
122
|
+
"name": str(name).strip(),
|
|
123
|
+
"aliases": [],
|
|
124
|
+
"role": str(role).strip(),
|
|
125
|
+
"support": "context_only",
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
details = background_research.get("character_details")
|
|
129
|
+
if isinstance(details, dict):
|
|
130
|
+
for name, info in details.items():
|
|
131
|
+
if not isinstance(info, dict):
|
|
132
|
+
continue
|
|
133
|
+
aliases = (
|
|
134
|
+
[str(a).strip() for a in (info.get("aliases") or []) if str(a).strip()]
|
|
135
|
+
if isinstance(info.get("aliases"), list)
|
|
136
|
+
else []
|
|
137
|
+
)
|
|
138
|
+
role = str(info.get("role", "")).strip()
|
|
139
|
+
if str(name).strip() or aliases or role:
|
|
140
|
+
glossary.append(
|
|
141
|
+
{
|
|
142
|
+
"name": str(name).strip(),
|
|
143
|
+
"aliases": aliases,
|
|
144
|
+
"role": role,
|
|
145
|
+
"support": "context_only",
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
return glossary
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def _dialogue_segments_for_index(asr_result=None, asr_clean=None):
|
|
152
|
+
clean_segments = (
|
|
153
|
+
(asr_clean or {}).get("segments") if isinstance(asr_clean, dict) else None
|
|
154
|
+
)
|
|
155
|
+
source = clean_segments if isinstance(clean_segments, list) else (asr_result or [])
|
|
156
|
+
out = []
|
|
157
|
+
for i, seg in enumerate(source or []):
|
|
158
|
+
if not isinstance(seg, dict):
|
|
159
|
+
continue
|
|
160
|
+
text = str(seg.get("text", "")).strip()
|
|
161
|
+
if not text:
|
|
162
|
+
continue
|
|
163
|
+
out.append(
|
|
164
|
+
{
|
|
165
|
+
"id": f"asr:{i}",
|
|
166
|
+
"start": seg.get("start"),
|
|
167
|
+
"end": seg.get("end"),
|
|
168
|
+
"text": text,
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
return out
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def _stable_unique(values):
|
|
175
|
+
seen = set()
|
|
176
|
+
out = []
|
|
177
|
+
for value in values or []:
|
|
178
|
+
key = (
|
|
179
|
+
json.dumps(value, ensure_ascii=False, sort_keys=True)
|
|
180
|
+
if isinstance(value, dict)
|
|
181
|
+
else str(value)
|
|
182
|
+
)
|
|
183
|
+
if key in seen:
|
|
184
|
+
continue
|
|
185
|
+
seen.add(key)
|
|
186
|
+
out.append(value)
|
|
187
|
+
return out
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def _apply_deterministic_asr_research_fallback(
|
|
191
|
+
index, asr_result=None, asr_clean=None, background_research=None
|
|
192
|
+
):
|
|
193
|
+
"""Guarantee ASR/research mentions survive even when the LLM omits them.
|
|
194
|
+
|
|
195
|
+
The LLM still owns synthesis, but cacheable deterministic fields make ASR contribution
|
|
196
|
+
observable: aliases/names from background_research are matched against ASR/asr_clean text
|
|
197
|
+
and written to characters[*].asr_mentions/evidence_ids without inventing relationships or
|
|
198
|
+
plot facts. Research remains context_only via research_glossary.
|
|
199
|
+
"""
|
|
200
|
+
index = dict(index or {})
|
|
201
|
+
for key in (
|
|
202
|
+
"characters",
|
|
203
|
+
"relationships",
|
|
204
|
+
"plot_points",
|
|
205
|
+
"entities",
|
|
206
|
+
"research_glossary",
|
|
207
|
+
):
|
|
208
|
+
index.setdefault(key, [])
|
|
209
|
+
glossary = index.get("research_glossary") or _research_glossary_from_context(
|
|
210
|
+
background_research
|
|
211
|
+
)
|
|
212
|
+
if not glossary:
|
|
213
|
+
glossary = _research_glossary_from_context(background_research)
|
|
214
|
+
for item in glossary:
|
|
215
|
+
if isinstance(item, dict):
|
|
216
|
+
item["support"] = "context_only"
|
|
217
|
+
index["research_glossary"] = glossary
|
|
218
|
+
|
|
219
|
+
segments = _dialogue_segments_for_index(asr_result=asr_result, asr_clean=asr_clean)
|
|
220
|
+
char_by_name = {}
|
|
221
|
+
for c in index.get("characters") or []:
|
|
222
|
+
if isinstance(c, dict) and str(c.get("name", "")).strip():
|
|
223
|
+
char_by_name[str(c.get("name")).strip()] = c
|
|
224
|
+
for g in glossary:
|
|
225
|
+
if not isinstance(g, dict):
|
|
226
|
+
continue
|
|
227
|
+
name = str(g.get("name", "")).strip()
|
|
228
|
+
aliases = [str(a).strip() for a in (g.get("aliases") or []) if str(a).strip()]
|
|
229
|
+
terms = [t for t in [name] + aliases if t]
|
|
230
|
+
if not terms:
|
|
231
|
+
continue
|
|
232
|
+
matches = []
|
|
233
|
+
evidence_ids = []
|
|
234
|
+
for seg in segments:
|
|
235
|
+
text = seg["text"]
|
|
236
|
+
hit_terms = [term for term in terms if term and term in text]
|
|
237
|
+
if hit_terms:
|
|
238
|
+
matches.append(
|
|
239
|
+
{
|
|
240
|
+
"text": text,
|
|
241
|
+
"evidence_id": seg["id"],
|
|
242
|
+
"matched_aliases": hit_terms,
|
|
243
|
+
}
|
|
244
|
+
)
|
|
245
|
+
evidence_ids.append(seg["id"])
|
|
246
|
+
if not matches:
|
|
247
|
+
continue
|
|
248
|
+
char = char_by_name.get(name)
|
|
249
|
+
if char is None:
|
|
250
|
+
char = {
|
|
251
|
+
"name": name or matches[0]["matched_aliases"][0],
|
|
252
|
+
"description": "",
|
|
253
|
+
"aliases": aliases,
|
|
254
|
+
"visual_descriptions": [],
|
|
255
|
+
"asr_mentions": [],
|
|
256
|
+
"research_role": str(g.get("role", "")).strip(),
|
|
257
|
+
"evidence_ids": [],
|
|
258
|
+
"confidence": "medium",
|
|
259
|
+
}
|
|
260
|
+
index["characters"].append(char)
|
|
261
|
+
char_by_name[char["name"]] = char
|
|
262
|
+
char.setdefault("aliases", [])
|
|
263
|
+
char["aliases"] = _stable_unique(list(char.get("aliases") or []) + aliases)
|
|
264
|
+
char.setdefault("asr_mentions", [])
|
|
265
|
+
char["asr_mentions"] = _stable_unique(
|
|
266
|
+
list(char.get("asr_mentions") or []) + matches
|
|
267
|
+
)
|
|
268
|
+
char.setdefault("evidence_ids", [])
|
|
269
|
+
char["evidence_ids"] = _stable_unique(
|
|
270
|
+
list(char.get("evidence_ids") or []) + evidence_ids
|
|
271
|
+
)
|
|
272
|
+
if not char.get("research_role"):
|
|
273
|
+
char["research_role"] = str(g.get("role", "")).strip()
|
|
274
|
+
char.setdefault("confidence", "medium")
|
|
275
|
+
return index
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def build_index_messages(
|
|
279
|
+
vlm_analysis, asr_result=None, asr_clean=None, background_research=None
|
|
280
|
+
):
|
|
281
|
+
lines = []
|
|
282
|
+
for i, scene in enumerate(vlm_analysis or []):
|
|
283
|
+
if not isinstance(scene, dict):
|
|
284
|
+
continue
|
|
285
|
+
sid = scene.get("scene_id", i)
|
|
286
|
+
start = float(scene.get("start", 0) or 0)
|
|
287
|
+
end = float(scene.get("end", 0) or 0)
|
|
288
|
+
desc = str(scene.get("description", "")).strip().replace("\n", " ")
|
|
289
|
+
facts = scene.get("frame_facts")
|
|
290
|
+
fact_txt = ""
|
|
291
|
+
if isinstance(facts, dict) and facts:
|
|
292
|
+
actions = []
|
|
293
|
+
|
|
294
|
+
def fact_key(x):
|
|
295
|
+
try:
|
|
296
|
+
return (0, float(x))
|
|
297
|
+
except (TypeError, ValueError):
|
|
298
|
+
return (1, str(x))
|
|
299
|
+
|
|
300
|
+
for ts in sorted(facts.keys(), key=fact_key):
|
|
301
|
+
vals = facts[ts]
|
|
302
|
+
actions.extend(vals if isinstance(vals, list) else [str(vals)])
|
|
303
|
+
if actions:
|
|
304
|
+
fact_txt = " | 帧实: " + ";".join(a for a in actions[:6] if a)
|
|
305
|
+
lines.append(f"[visual:{i} 场景{sid} {start:.0f}-{end:.0f}s] {desc}{fact_txt}")
|
|
306
|
+
asr_lines = []
|
|
307
|
+
clean_segments = (
|
|
308
|
+
(asr_clean or {}).get("segments") if isinstance(asr_clean, dict) else None
|
|
309
|
+
)
|
|
310
|
+
source_asr = (
|
|
311
|
+
clean_segments if isinstance(clean_segments, list) else (asr_result or [])
|
|
312
|
+
)
|
|
313
|
+
for i, seg in enumerate(source_asr or []):
|
|
314
|
+
if not isinstance(seg, dict):
|
|
315
|
+
continue
|
|
316
|
+
text = str(seg.get("text", "")).strip()
|
|
317
|
+
if not text:
|
|
318
|
+
continue
|
|
319
|
+
asr_lines.append(
|
|
320
|
+
f"[asr:{i} {float(seg.get('start', 0) or 0):.0f}-{float(seg.get('end', 0) or 0):.0f}s] {text}"
|
|
321
|
+
)
|
|
322
|
+
glossary = _research_glossary_from_context(background_research)
|
|
323
|
+
glossary_lines = []
|
|
324
|
+
for i, item in enumerate(glossary[:80]):
|
|
325
|
+
aliases = "/".join(item.get("aliases") or [])
|
|
326
|
+
alias_txt = f" aliases={aliases}" if aliases else ""
|
|
327
|
+
glossary_lines.append(
|
|
328
|
+
f"[research:{i} support=context_only] {item.get('name', '')}{alias_txt}: {item.get('role', '')}"
|
|
329
|
+
)
|
|
330
|
+
user = (
|
|
331
|
+
f"{INDEX_PROMPT}\n\n"
|
|
332
|
+
f"## 逐场景画面分析(共 {len(lines)} 段)\n" + "\n".join(lines) + "\n\n"
|
|
333
|
+
f"## ASR / cleaned dialogue(共 {len(asr_lines)} 段)\n"
|
|
334
|
+
+ ("\n".join(asr_lines) or "(无)")
|
|
335
|
+
+ "\n\n"
|
|
336
|
+
"## Research glossary(clock=null/context_only,不得升级为当前剧情事实)\n"
|
|
337
|
+
+ ("\n".join(glossary_lines) or "(无)")
|
|
338
|
+
)
|
|
339
|
+
return [{"role": "user", "content": user}]
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def parse_index_response(text):
|
|
343
|
+
data = _extract_json(text)
|
|
344
|
+
if not isinstance(data, dict):
|
|
345
|
+
return {
|
|
346
|
+
"schema_version": INDEX_SCHEMA_VERSION,
|
|
347
|
+
"characters": [],
|
|
348
|
+
"relationships": [],
|
|
349
|
+
"plot_points": [],
|
|
350
|
+
"entities": [],
|
|
351
|
+
"research_glossary": [],
|
|
352
|
+
}
|
|
353
|
+
out = {"schema_version": INDEX_SCHEMA_VERSION}
|
|
354
|
+
for key in (
|
|
355
|
+
"characters",
|
|
356
|
+
"relationships",
|
|
357
|
+
"plot_points",
|
|
358
|
+
"entities",
|
|
359
|
+
"research_glossary",
|
|
360
|
+
):
|
|
361
|
+
val = data.get(key)
|
|
362
|
+
out[key] = val if isinstance(val, list) else []
|
|
363
|
+
for item in out["research_glossary"]:
|
|
364
|
+
if isinstance(item, dict):
|
|
365
|
+
item["support"] = "context_only"
|
|
366
|
+
return out
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
def format_index_md(index):
|
|
370
|
+
out = ["# Understanding index (from consolidate.py)", ""]
|
|
371
|
+
chars = index.get("characters") or []
|
|
372
|
+
if chars:
|
|
373
|
+
out.append("## Characters")
|
|
374
|
+
for c in chars:
|
|
375
|
+
if isinstance(c, dict):
|
|
376
|
+
out.append(
|
|
377
|
+
f"- **{c.get('name', '?')}** — {c.get('description', '')}".rstrip()
|
|
378
|
+
)
|
|
379
|
+
else:
|
|
380
|
+
out.append(f"- {c}")
|
|
381
|
+
out.append("")
|
|
382
|
+
rels = index.get("relationships") or []
|
|
383
|
+
if rels:
|
|
384
|
+
out.append("## Relationships")
|
|
385
|
+
for r in rels:
|
|
386
|
+
if isinstance(r, dict):
|
|
387
|
+
out.append(
|
|
388
|
+
f"- {r.get('a', '?')} — {r.get('relation', '?')} — {r.get('b', '?')}"
|
|
389
|
+
)
|
|
390
|
+
else:
|
|
391
|
+
out.append(f"- {r}")
|
|
392
|
+
out.append("")
|
|
393
|
+
plot = index.get("plot_points") or []
|
|
394
|
+
if plot:
|
|
395
|
+
out.append("## Plot spine")
|
|
396
|
+
for i, p in enumerate(plot):
|
|
397
|
+
out.append(f"{i + 1}. {p.get('text', p) if isinstance(p, dict) else p}")
|
|
398
|
+
out.append("")
|
|
399
|
+
ents = index.get("entities") or []
|
|
400
|
+
if ents:
|
|
401
|
+
out.append("## Entities")
|
|
402
|
+
for e in ents:
|
|
403
|
+
out.append(f"- {e.get('name', e) if isinstance(e, dict) else e}")
|
|
404
|
+
out.append("")
|
|
405
|
+
glossary = index.get("research_glossary") or []
|
|
406
|
+
if glossary:
|
|
407
|
+
out.append("## Research glossary (context_only)")
|
|
408
|
+
for g in glossary:
|
|
409
|
+
if isinstance(g, dict):
|
|
410
|
+
aliases = "/".join(g.get("aliases") or [])
|
|
411
|
+
alias_txt = f" ({aliases})" if aliases else ""
|
|
412
|
+
out.append(
|
|
413
|
+
f"- {g.get('name', '?')}{alias_txt}: {g.get('role', '')} [{g.get('support', 'context_only')}]"
|
|
414
|
+
)
|
|
415
|
+
else:
|
|
416
|
+
out.append(f"- {g}")
|
|
417
|
+
out.append("")
|
|
418
|
+
return "\n".join(out).rstrip() + "\n"
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
def _extract_json(text):
|
|
422
|
+
raw = str(text or "")
|
|
423
|
+
fence = re.search(r"```(?:json)?\s*(\{.*?\})\s*```", raw, re.DOTALL)
|
|
424
|
+
candidate = fence.group(1) if fence else raw
|
|
425
|
+
if not fence:
|
|
426
|
+
first, last = candidate.find("{"), candidate.rfind("}")
|
|
427
|
+
if first != -1 and last > first:
|
|
428
|
+
candidate = candidate[first : last + 1]
|
|
429
|
+
try:
|
|
430
|
+
return json.loads(candidate)
|
|
431
|
+
except ValueError:
|
|
432
|
+
return None
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
def _asr_source_md5(work_dir):
|
|
436
|
+
"""Provenance: md5 of the on-disk asr_result.json BYTES (writer + reader hash the same thing)."""
|
|
437
|
+
path = Path(work_dir) / "asr_result.json"
|
|
438
|
+
return hashlib.md5(path.read_bytes()).hexdigest() if path.exists() else ""
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
def _vlm_source_md5(work_dir):
|
|
442
|
+
"""Provenance: md5 of the on-disk vlm_analysis.json bytes."""
|
|
443
|
+
path = Path(work_dir) / "vlm_analysis.json"
|
|
444
|
+
return hashlib.md5(path.read_bytes()).hexdigest() if path.exists() else ""
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
def _index_meta_path(work_dir):
|
|
448
|
+
return Path(work_dir) / "understanding_index.json.meta.json"
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def _prompt_fingerprint(prompt):
|
|
452
|
+
return hashlib.md5(str(prompt or "").encode("utf-8")).hexdigest()
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
def _write_index_meta(work_dir, vlm_analysis):
|
|
456
|
+
_index_meta_path(work_dir).write_text(
|
|
457
|
+
json.dumps(
|
|
458
|
+
{
|
|
459
|
+
"schema_version": INDEX_SCHEMA_VERSION,
|
|
460
|
+
"source_md5": _vlm_source_md5(work_dir),
|
|
461
|
+
"asr_md5": _asr_source_md5(work_dir),
|
|
462
|
+
"asr_clean_md5": _asr_clean_source_md5(work_dir),
|
|
463
|
+
"research_md5": _research_source_md5(work_dir),
|
|
464
|
+
"scene_count": len(
|
|
465
|
+
[s for s in (vlm_analysis or []) if isinstance(s, dict)]
|
|
466
|
+
),
|
|
467
|
+
"model": CONFIG.get("vlm_model", ""),
|
|
468
|
+
"prompt_md5": _prompt_fingerprint(INDEX_PROMPT),
|
|
469
|
+
},
|
|
470
|
+
ensure_ascii=False,
|
|
471
|
+
indent=2,
|
|
472
|
+
),
|
|
473
|
+
encoding="utf-8",
|
|
474
|
+
)
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
def _index_cache_matches(work_dir, vlm_analysis):
|
|
478
|
+
meta_path = _index_meta_path(work_dir)
|
|
479
|
+
if not meta_path.exists():
|
|
480
|
+
return False
|
|
481
|
+
try:
|
|
482
|
+
meta = json.loads(meta_path.read_text(encoding="utf-8"))
|
|
483
|
+
except (json.JSONDecodeError, OSError):
|
|
484
|
+
return False
|
|
485
|
+
return (
|
|
486
|
+
isinstance(meta, dict)
|
|
487
|
+
and meta.get("schema_version") == INDEX_SCHEMA_VERSION
|
|
488
|
+
and meta.get("source_md5") == _vlm_source_md5(work_dir)
|
|
489
|
+
and meta.get("asr_md5", "") == _asr_source_md5(work_dir)
|
|
490
|
+
and meta.get("asr_clean_md5", "") == _asr_clean_source_md5(work_dir)
|
|
491
|
+
and meta.get("research_md5", "") == _research_source_md5(work_dir)
|
|
492
|
+
and meta.get("scene_count")
|
|
493
|
+
== len([s for s in (vlm_analysis or []) if isinstance(s, dict)])
|
|
494
|
+
and meta.get("model") == CONFIG.get("vlm_model", "")
|
|
495
|
+
and meta.get("prompt_md5") == _prompt_fingerprint(INDEX_PROMPT)
|
|
496
|
+
)
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
# ── thin drivers (I/O + api_call) ─────────────────────────────────────────────
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
def _load(work_dir, name):
|
|
503
|
+
path = Path(work_dir) / name
|
|
504
|
+
if not path.exists():
|
|
505
|
+
return None
|
|
506
|
+
try:
|
|
507
|
+
return json.loads(path.read_text(encoding="utf-8"))
|
|
508
|
+
except (ValueError, OSError):
|
|
509
|
+
return None
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
def consolidate_transcript(work_dir):
|
|
513
|
+
work_dir = Path(work_dir)
|
|
514
|
+
asr_result = _load(work_dir, "asr_result.json")
|
|
515
|
+
if not asr_result:
|
|
516
|
+
log("consolidate(asr): 无 asr_result.json,跳过")
|
|
517
|
+
return None
|
|
518
|
+
out_path = work_dir / "asr_clean.json"
|
|
519
|
+
if _fresh(out_path, work_dir / "asr_result.json"):
|
|
520
|
+
existing = _load(work_dir, "asr_clean.json") or {}
|
|
521
|
+
if (
|
|
522
|
+
existing.get("source_md5") == _asr_source_md5(work_dir)
|
|
523
|
+
and existing.get("model") == CONFIG.get("vlm_model", "")
|
|
524
|
+
and existing.get("prompt_md5") == _prompt_fingerprint(CLEAN_PROMPT)
|
|
525
|
+
and existing.get("postprocess_version") == ASR_CLEAN_POSTPROCESS_VERSION
|
|
526
|
+
):
|
|
527
|
+
log("consolidate(asr): asr_clean.json 已最新,跳过")
|
|
528
|
+
return existing
|
|
529
|
+
resp = api_call(
|
|
530
|
+
{
|
|
531
|
+
"model": CONFIG.get("vlm_model", ""),
|
|
532
|
+
"messages": build_clean_messages(asr_result),
|
|
533
|
+
"max_tokens": 4000,
|
|
534
|
+
"temperature": 0.2,
|
|
535
|
+
}
|
|
536
|
+
)
|
|
537
|
+
content = _response_text(resp)
|
|
538
|
+
segments = parse_clean_response(content, asr_result)
|
|
539
|
+
payload = {
|
|
540
|
+
"source_md5": _asr_source_md5(work_dir),
|
|
541
|
+
"model": CONFIG.get("vlm_model", ""),
|
|
542
|
+
"prompt_md5": _prompt_fingerprint(CLEAN_PROMPT),
|
|
543
|
+
"postprocess_version": ASR_CLEAN_POSTPROCESS_VERSION,
|
|
544
|
+
"segments": segments,
|
|
545
|
+
}
|
|
546
|
+
out_path.write_text(
|
|
547
|
+
json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8"
|
|
548
|
+
)
|
|
549
|
+
log(f"consolidate(asr): 写出 asr_clean.json({len(segments)} 段)")
|
|
550
|
+
return payload
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
def consolidate_index(work_dir):
|
|
554
|
+
work_dir = Path(work_dir)
|
|
555
|
+
vlm_analysis = _load(work_dir, "vlm_analysis.json")
|
|
556
|
+
if not vlm_analysis:
|
|
557
|
+
log("consolidate(index): 无 vlm_analysis.json,跳过")
|
|
558
|
+
return None
|
|
559
|
+
out_path = work_dir / "understanding_index.json"
|
|
560
|
+
if _fresh(out_path, work_dir / "vlm_analysis.json") and _index_cache_matches(
|
|
561
|
+
work_dir, vlm_analysis
|
|
562
|
+
):
|
|
563
|
+
log("consolidate(index): understanding_index.json 已最新,跳过")
|
|
564
|
+
return _load(work_dir, "understanding_index.json")
|
|
565
|
+
asr_result = _load(work_dir, "asr_result.json") or []
|
|
566
|
+
asr_clean = _load(work_dir, "asr_clean.json") or {}
|
|
567
|
+
background_research = _load(work_dir, "background_research.json") or {}
|
|
568
|
+
resp = api_call(
|
|
569
|
+
{
|
|
570
|
+
"model": CONFIG.get("vlm_model", ""),
|
|
571
|
+
"messages": build_index_messages(
|
|
572
|
+
vlm_analysis,
|
|
573
|
+
asr_result=asr_result,
|
|
574
|
+
asr_clean=asr_clean,
|
|
575
|
+
background_research=background_research,
|
|
576
|
+
),
|
|
577
|
+
"max_tokens": 3000,
|
|
578
|
+
"temperature": 0.2,
|
|
579
|
+
}
|
|
580
|
+
)
|
|
581
|
+
index = parse_index_response(_response_text(resp))
|
|
582
|
+
index = _apply_deterministic_asr_research_fallback(
|
|
583
|
+
index,
|
|
584
|
+
asr_result=asr_result,
|
|
585
|
+
asr_clean=asr_clean,
|
|
586
|
+
background_research=background_research,
|
|
587
|
+
)
|
|
588
|
+
out_path.write_text(
|
|
589
|
+
json.dumps(index, ensure_ascii=False, indent=2), encoding="utf-8"
|
|
590
|
+
)
|
|
591
|
+
_write_index_meta(work_dir, vlm_analysis)
|
|
592
|
+
(work_dir / "understanding_index.md").write_text(
|
|
593
|
+
format_index_md(index), encoding="utf-8"
|
|
594
|
+
)
|
|
595
|
+
log(
|
|
596
|
+
f"consolidate(index): 写出 understanding_index.json(角色 {len(index['characters'])})"
|
|
597
|
+
)
|
|
598
|
+
return index
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
def consolidate(work_dir, do_asr=False, do_index=True):
|
|
602
|
+
"""Default = index-only (Pass B, zero timing risk). Pass A (asr) is opt-in."""
|
|
603
|
+
result = {}
|
|
604
|
+
if do_asr:
|
|
605
|
+
try:
|
|
606
|
+
result["asr_clean"] = consolidate_transcript(work_dir)
|
|
607
|
+
except Exception as e:
|
|
608
|
+
log(f"consolidate(asr) 跳过(忽略): {e}")
|
|
609
|
+
if do_index:
|
|
610
|
+
try:
|
|
611
|
+
result["index"] = consolidate_index(work_dir)
|
|
612
|
+
except Exception as e:
|
|
613
|
+
log(f"consolidate(index) 跳过(忽略): {e}")
|
|
614
|
+
return result
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
def _response_text(resp):
|
|
618
|
+
try:
|
|
619
|
+
return resp["choices"][0]["message"]["content"]
|
|
620
|
+
except (KeyError, IndexError, TypeError):
|
|
621
|
+
log("consolidate: API 返回结构异常")
|
|
622
|
+
return ""
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
def main():
|
|
626
|
+
ap = argparse.ArgumentParser(
|
|
627
|
+
description="Consolidate the understanding index (and optionally clean ASR)."
|
|
628
|
+
)
|
|
629
|
+
ap.add_argument("--work-dir", required=True)
|
|
630
|
+
ap.add_argument("--asr", action="store_true", help="also run Pass A (ASR cleanup)")
|
|
631
|
+
ap.add_argument("--no-index", action="store_true", help="skip Pass B (index)")
|
|
632
|
+
args = ap.parse_args()
|
|
633
|
+
res = consolidate(args.work_dir, do_asr=args.asr, do_index=not args.no_index)
|
|
634
|
+
print(
|
|
635
|
+
json.dumps(
|
|
636
|
+
{
|
|
637
|
+
"status": "consolidated",
|
|
638
|
+
"index": bool(res.get("index")),
|
|
639
|
+
"asr_clean": bool(res.get("asr_clean")),
|
|
640
|
+
},
|
|
641
|
+
ensure_ascii=False,
|
|
642
|
+
)
|
|
643
|
+
)
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
if __name__ == "__main__":
|
|
647
|
+
main()
|