@tikomni/skills 0.1.0
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/.skill-package-allowlist.txt +4 -0
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/README.zh-CN.md +167 -0
- package/bin/tikomni-skills.js +127 -0
- package/env.example +160 -0
- package/lib/installer.js +176 -0
- package/package.json +44 -0
- package/skills/creator-analysis/SKILL.md +71 -0
- package/skills/creator-analysis/agents/openai.yaml +4 -0
- package/skills/creator-analysis/env.example +36 -0
- package/skills/creator-analysis/references/api-capability-index.md +92 -0
- package/skills/creator-analysis/references/api-contracts/asr-api.md +130 -0
- package/skills/creator-analysis/references/api-contracts/bilibili-app-api.md +776 -0
- package/skills/creator-analysis/references/api-contracts/bilibili-web-api.md +2017 -0
- package/skills/creator-analysis/references/api-contracts/demo-api.md +717 -0
- package/skills/creator-analysis/references/api-contracts/douyin-app-v3-api.md +3594 -0
- package/skills/creator-analysis/references/api-contracts/douyin-billboard-api.md +2274 -0
- package/skills/creator-analysis/references/api-contracts/douyin-creator-api.md +1575 -0
- package/skills/creator-analysis/references/api-contracts/douyin-creator-v2-api.md +3254 -0
- package/skills/creator-analysis/references/api-contracts/douyin-search-api.md +4118 -0
- package/skills/creator-analysis/references/api-contracts/douyin-web-api.md +5544 -0
- package/skills/creator-analysis/references/api-contracts/douyin-xingtu-api.md +1916 -0
- package/skills/creator-analysis/references/api-contracts/douyin-xingtu-v2-api.md +1540 -0
- package/skills/creator-analysis/references/api-contracts/health-check.md +69 -0
- package/skills/creator-analysis/references/api-contracts/hybrid-parsing.md +78 -0
- package/skills/creator-analysis/references/api-contracts/instagram-v1-api.md +2256 -0
- package/skills/creator-analysis/references/api-contracts/instagram-v2-api.md +2011 -0
- package/skills/creator-analysis/references/api-contracts/instagram-v3-api.md +2630 -0
- package/skills/creator-analysis/references/api-contracts/ios-shortcut.md +44 -0
- package/skills/creator-analysis/references/api-contracts/kuaishou-app-api.md +1518 -0
- package/skills/creator-analysis/references/api-contracts/kuaishou-web-api.md +1242 -0
- package/skills/creator-analysis/references/api-contracts/lemon8-app-api.md +1088 -0
- package/skills/creator-analysis/references/api-contracts/linkedin-web-api.md +1949 -0
- package/skills/creator-analysis/references/api-contracts/media-ingest-api.md +126 -0
- package/skills/creator-analysis/references/api-contracts/pipixia-app-api.md +1142 -0
- package/skills/creator-analysis/references/api-contracts/reddit-app-api.md +2025 -0
- package/skills/creator-analysis/references/api-contracts/sora2-api.md +2266 -0
- package/skills/creator-analysis/references/api-contracts/temp-mail-api.md +208 -0
- package/skills/creator-analysis/references/api-contracts/threads-web-api.md +897 -0
- package/skills/creator-analysis/references/api-contracts/tikhub-downloader-api.md +134 -0
- package/skills/creator-analysis/references/api-contracts/tikhub-user-api.md +494 -0
- package/skills/creator-analysis/references/api-contracts/tiktok-ads-api.md +5947 -0
- package/skills/creator-analysis/references/api-contracts/tiktok-analytics-api.md +968 -0
- package/skills/creator-analysis/references/api-contracts/tiktok-app-v3-api.md +5735 -0
- package/skills/creator-analysis/references/api-contracts/tiktok-creator-api.md +1951 -0
- package/skills/creator-analysis/references/api-contracts/tiktok-interaction-api.md +742 -0
- package/skills/creator-analysis/references/api-contracts/tiktok-shop-web-api.md +1890 -0
- package/skills/creator-analysis/references/api-contracts/tiktok-web-api.md +4448 -0
- package/skills/creator-analysis/references/api-contracts/toutiao-app-api.md +342 -0
- package/skills/creator-analysis/references/api-contracts/toutiao-web-api.md +143 -0
- package/skills/creator-analysis/references/api-contracts/twitter-web-api.md +989 -0
- package/skills/creator-analysis/references/api-contracts/wechat-channels-api.md +809 -0
- package/skills/creator-analysis/references/api-contracts/wechat-media-platform-web-api.md +677 -0
- package/skills/creator-analysis/references/api-contracts/weibo-app-api.md +1547 -0
- package/skills/creator-analysis/references/api-contracts/weibo-web-api.md +798 -0
- package/skills/creator-analysis/references/api-contracts/weibo-web-v2-api.md +2459 -0
- package/skills/creator-analysis/references/api-contracts/xiaohongshu-app-api.md +1291 -0
- package/skills/creator-analysis/references/api-contracts/xiaohongshu-app-v2-api.md +1683 -0
- package/skills/creator-analysis/references/api-contracts/xiaohongshu-web-api.md +1324 -0
- package/skills/creator-analysis/references/api-contracts/xiaohongshu-web-v2-api.md +1209 -0
- package/skills/creator-analysis/references/api-contracts/xigua-app-v2-api.md +489 -0
- package/skills/creator-analysis/references/api-contracts/youtube-web-api.md +2636 -0
- package/skills/creator-analysis/references/api-contracts/youtube-web-v2-api.md +2660 -0
- package/skills/creator-analysis/references/api-contracts/zhihu-web-api.md +2315 -0
- package/skills/creator-analysis/references/api-tags/asr-api.md +100 -0
- package/skills/creator-analysis/references/api-tags/bilibili-app-api.md +482 -0
- package/skills/creator-analysis/references/api-tags/bilibili-web-api.md +1267 -0
- package/skills/creator-analysis/references/api-tags/demo-api.md +365 -0
- package/skills/creator-analysis/references/api-tags/douyin-app-v3-api.md +2012 -0
- package/skills/creator-analysis/references/api-tags/douyin-billboard-api.md +1428 -0
- package/skills/creator-analysis/references/api-tags/douyin-creator-api.md +694 -0
- package/skills/creator-analysis/references/api-tags/douyin-creator-v2-api.md +694 -0
- package/skills/creator-analysis/references/api-tags/douyin-search-api.md +1059 -0
- package/skills/creator-analysis/references/api-tags/douyin-web-api.md +3314 -0
- package/skills/creator-analysis/references/api-tags/douyin-xingtu-api.md +935 -0
- package/skills/creator-analysis/references/api-tags/douyin-xingtu-v2-api.md +925 -0
- package/skills/creator-analysis/references/api-tags/health-check.md +40 -0
- package/skills/creator-analysis/references/api-tags/hybrid-parsing.md +57 -0
- package/skills/creator-analysis/references/api-tags/instagram-v1-api.md +1224 -0
- package/skills/creator-analysis/references/api-tags/instagram-v2-api.md +1147 -0
- package/skills/creator-analysis/references/api-tags/instagram-v3-api.md +1123 -0
- package/skills/creator-analysis/references/api-tags/ios-shortcut.md +45 -0
- package/skills/creator-analysis/references/api-tags/kuaishou-app-api.md +846 -0
- package/skills/creator-analysis/references/api-tags/kuaishou-web-api.md +551 -0
- package/skills/creator-analysis/references/api-tags/lemon8-app-api.md +687 -0
- package/skills/creator-analysis/references/api-tags/linkedin-web-api.md +1105 -0
- package/skills/creator-analysis/references/api-tags/media-ingest-api.md +112 -0
- package/skills/creator-analysis/references/api-tags/pipixia-app-api.md +721 -0
- package/skills/creator-analysis/references/api-tags/reddit-app-api.md +1057 -0
- package/skills/creator-analysis/references/api-tags/sora2-api.md +737 -0
- package/skills/creator-analysis/references/api-tags/temp-mail-api.md +136 -0
- package/skills/creator-analysis/references/api-tags/threads-web-api.md +472 -0
- package/skills/creator-analysis/references/api-tags/tikhub-downloader-api.md +65 -0
- package/skills/creator-analysis/references/api-tags/tikhub-user-api.md +253 -0
- package/skills/creator-analysis/references/api-tags/tiktok-ads-api.md +1393 -0
- package/skills/creator-analysis/references/api-tags/tiktok-analytics-api.md +179 -0
- package/skills/creator-analysis/references/api-tags/tiktok-app-v3-api.md +3264 -0
- package/skills/creator-analysis/references/api-tags/tiktok-creator-api.md +709 -0
- package/skills/creator-analysis/references/api-tags/tiktok-interaction-api.md +366 -0
- package/skills/creator-analysis/references/api-tags/tiktok-shop-web-api.md +663 -0
- package/skills/creator-analysis/references/api-tags/tiktok-web-api.md +2516 -0
- package/skills/creator-analysis/references/api-tags/toutiao-app-api.md +220 -0
- package/skills/creator-analysis/references/api-tags/toutiao-web-api.md +96 -0
- package/skills/creator-analysis/references/api-tags/twitter-web-api.md +562 -0
- package/skills/creator-analysis/references/api-tags/wechat-channels-api.md +405 -0
- package/skills/creator-analysis/references/api-tags/wechat-media-platform-web-api.md +431 -0
- package/skills/creator-analysis/references/api-tags/weibo-app-api.md +851 -0
- package/skills/creator-analysis/references/api-tags/weibo-web-api.md +470 -0
- package/skills/creator-analysis/references/api-tags/weibo-web-v2-api.md +1405 -0
- package/skills/creator-analysis/references/api-tags/xiaohongshu-app-api.md +534 -0
- package/skills/creator-analysis/references/api-tags/xiaohongshu-app-v2-api.md +934 -0
- package/skills/creator-analysis/references/api-tags/xiaohongshu-web-api.md +757 -0
- package/skills/creator-analysis/references/api-tags/xiaohongshu-web-v2-api.md +762 -0
- package/skills/creator-analysis/references/api-tags/xigua-app-v2-api.md +308 -0
- package/skills/creator-analysis/references/api-tags/youtube-web-api.md +934 -0
- package/skills/creator-analysis/references/api-tags/youtube-web-v2-api.md +717 -0
- package/skills/creator-analysis/references/api-tags/zhihu-web-api.md +1384 -0
- package/skills/creator-analysis/references/asr-orchestration.md +33 -0
- package/skills/creator-analysis/references/config-templates/defaults.yaml +60 -0
- package/skills/creator-analysis/references/contracts/creator-card-fields.md +23 -0
- package/skills/creator-analysis/references/contracts/work-card-fields.md +32 -0
- package/skills/creator-analysis/references/platform-guides/douyin.md +49 -0
- package/skills/creator-analysis/references/platform-guides/generic.md +46 -0
- package/skills/creator-analysis/references/platform-guides/xiaohongshu.md +54 -0
- package/skills/creator-analysis/references/prompt-contracts/asr-clean.md +28 -0
- package/skills/creator-analysis/references/prompt-contracts/author-analysis-v2.md +46 -0
- package/skills/creator-analysis/references/prompt-contracts/author-analysis.md +49 -0
- package/skills/creator-analysis/references/prompt-contracts/cta.md +24 -0
- package/skills/creator-analysis/references/prompt-contracts/hook.md +25 -0
- package/skills/creator-analysis/references/prompt-contracts/insight.md +47 -0
- package/skills/creator-analysis/references/prompt-contracts/sampled-work-batch-explanations.md +30 -0
- package/skills/creator-analysis/references/prompt-contracts/structure.md +25 -0
- package/skills/creator-analysis/references/prompt-contracts/style.md +27 -0
- package/skills/creator-analysis/references/prompt-contracts/summary.md +29 -0
- package/skills/creator-analysis/references/prompt-contracts/topic.md +29 -0
- package/skills/creator-analysis/references/schemas/author-analysis-input-v1.schema.json +325 -0
- package/skills/creator-analysis/references/schemas/author-analysis-v2.schema.json +158 -0
- package/skills/creator-analysis/references/schemas/sampled-work-batch-explanations.schema.json +41 -0
- package/skills/creator-analysis/references/service-guides/asr-u2-u3-fallback.md +75 -0
- package/skills/creator-analysis/references/workflow.md +18 -0
- package/skills/creator-analysis/scripts/__init__.py +0 -0
- package/skills/creator-analysis/scripts/author_home/__init__.py +0 -0
- package/skills/creator-analysis/scripts/author_home/adapters/__init__.py +0 -0
- package/skills/creator-analysis/scripts/author_home/adapters/platform_adapters.py +299 -0
- package/skills/creator-analysis/scripts/author_home/analyzers/__init__.py +0 -0
- package/skills/creator-analysis/scripts/author_home/analyzers/author_analysis_v2_support.py +1122 -0
- package/skills/creator-analysis/scripts/author_home/analyzers/prompt_first_analyzers.py +260 -0
- package/skills/creator-analysis/scripts/author_home/analyzers/sampled_work_batch_explainer.py +260 -0
- package/skills/creator-analysis/scripts/author_home/asr/__init__.py +5 -0
- package/skills/creator-analysis/scripts/author_home/asr/home_asr.py +961 -0
- package/skills/creator-analysis/scripts/author_home/builders/__init__.py +0 -0
- package/skills/creator-analysis/scripts/author_home/builders/home_builders.py +149 -0
- package/skills/creator-analysis/scripts/author_home/collectors/__init__.py +0 -0
- package/skills/creator-analysis/scripts/author_home/collectors/homepage_collectors.py +636 -0
- package/skills/creator-analysis/scripts/author_home/orchestrator/__init__.py +0 -0
- package/skills/creator-analysis/scripts/author_home/orchestrator/run_author_analysis.py +491 -0
- package/skills/creator-analysis/scripts/author_home/orchestrator/work_analysis_artifacts.py +553 -0
- package/skills/creator-analysis/scripts/author_home/schema.py +417 -0
- package/skills/creator-analysis/scripts/core/__init__.py +0 -0
- package/skills/creator-analysis/scripts/core/analysis_pipeline.py +133 -0
- package/skills/creator-analysis/scripts/core/bootstrap_env.py +35 -0
- package/skills/creator-analysis/scripts/core/config_loader.py +418 -0
- package/skills/creator-analysis/scripts/core/extract_pipeline.py +173 -0
- package/skills/creator-analysis/scripts/core/progress_report.py +111 -0
- package/skills/creator-analysis/scripts/core/storage_router.py +253 -0
- package/skills/creator-analysis/scripts/core/tikomni_common.py +588 -0
- package/skills/creator-analysis/scripts/pipeline/__init__.py +0 -0
- package/skills/creator-analysis/scripts/pipeline/asr/__init__.py +0 -0
- package/skills/creator-analysis/scripts/pipeline/asr/asr_pipeline.py +1189 -0
- package/skills/creator-analysis/scripts/pipeline/asr/poll_u2_task.py +95 -0
- package/skills/creator-analysis/scripts/platform/__init__.py +0 -0
- package/skills/creator-analysis/scripts/platform/douyin/__init__.py +0 -0
- package/skills/creator-analysis/scripts/platform/douyin/douyin_video_type_matrix.py +224 -0
- package/skills/creator-analysis/scripts/platform/douyin/run_douyin_single_video.py +1208 -0
- package/skills/creator-analysis/scripts/platform/douyin/select_low_quality_video_url.py +200 -0
- package/skills/creator-analysis/scripts/platform/xiaohongshu/__init__.py +0 -0
- package/skills/creator-analysis/scripts/platform/xiaohongshu/run_xiaohongshu_extract.py +2128 -0
- package/skills/creator-analysis/scripts/writers/__init__.py +0 -0
- package/skills/creator-analysis/scripts/writers/write_author_homepage_samples.py +106 -0
- package/skills/creator-analysis/scripts/writers/write_benchmark_card.py +1402 -0
- package/skills/meta-capability/SKILL.md +69 -0
- package/skills/meta-capability/agents/openai.yaml +4 -0
- package/skills/meta-capability/env.example +42 -0
- package/skills/meta-capability/references/api-capability-index.md +92 -0
- package/skills/meta-capability/references/api-contracts/asr-api.md +130 -0
- package/skills/meta-capability/references/api-contracts/bilibili-app-api.md +776 -0
- package/skills/meta-capability/references/api-contracts/bilibili-web-api.md +2017 -0
- package/skills/meta-capability/references/api-contracts/demo-api.md +717 -0
- package/skills/meta-capability/references/api-contracts/douyin-app-v3-api.md +3594 -0
- package/skills/meta-capability/references/api-contracts/douyin-billboard-api.md +2274 -0
- package/skills/meta-capability/references/api-contracts/douyin-creator-api.md +1575 -0
- package/skills/meta-capability/references/api-contracts/douyin-creator-v2-api.md +3254 -0
- package/skills/meta-capability/references/api-contracts/douyin-search-api.md +4118 -0
- package/skills/meta-capability/references/api-contracts/douyin-web-api.md +5544 -0
- package/skills/meta-capability/references/api-contracts/douyin-xingtu-api.md +1916 -0
- package/skills/meta-capability/references/api-contracts/douyin-xingtu-v2-api.md +1540 -0
- package/skills/meta-capability/references/api-contracts/health-check.md +69 -0
- package/skills/meta-capability/references/api-contracts/hybrid-parsing.md +78 -0
- package/skills/meta-capability/references/api-contracts/instagram-v1-api.md +2256 -0
- package/skills/meta-capability/references/api-contracts/instagram-v2-api.md +2011 -0
- package/skills/meta-capability/references/api-contracts/instagram-v3-api.md +2630 -0
- package/skills/meta-capability/references/api-contracts/ios-shortcut.md +44 -0
- package/skills/meta-capability/references/api-contracts/kuaishou-app-api.md +1518 -0
- package/skills/meta-capability/references/api-contracts/kuaishou-web-api.md +1242 -0
- package/skills/meta-capability/references/api-contracts/lemon8-app-api.md +1088 -0
- package/skills/meta-capability/references/api-contracts/linkedin-web-api.md +1949 -0
- package/skills/meta-capability/references/api-contracts/media-ingest-api.md +126 -0
- package/skills/meta-capability/references/api-contracts/pipixia-app-api.md +1142 -0
- package/skills/meta-capability/references/api-contracts/reddit-app-api.md +2025 -0
- package/skills/meta-capability/references/api-contracts/sora2-api.md +2266 -0
- package/skills/meta-capability/references/api-contracts/temp-mail-api.md +208 -0
- package/skills/meta-capability/references/api-contracts/threads-web-api.md +897 -0
- package/skills/meta-capability/references/api-contracts/tikhub-downloader-api.md +134 -0
- package/skills/meta-capability/references/api-contracts/tikhub-user-api.md +494 -0
- package/skills/meta-capability/references/api-contracts/tiktok-ads-api.md +5947 -0
- package/skills/meta-capability/references/api-contracts/tiktok-analytics-api.md +968 -0
- package/skills/meta-capability/references/api-contracts/tiktok-app-v3-api.md +5735 -0
- package/skills/meta-capability/references/api-contracts/tiktok-creator-api.md +1951 -0
- package/skills/meta-capability/references/api-contracts/tiktok-interaction-api.md +742 -0
- package/skills/meta-capability/references/api-contracts/tiktok-shop-web-api.md +1890 -0
- package/skills/meta-capability/references/api-contracts/tiktok-web-api.md +4448 -0
- package/skills/meta-capability/references/api-contracts/toutiao-app-api.md +342 -0
- package/skills/meta-capability/references/api-contracts/toutiao-web-api.md +143 -0
- package/skills/meta-capability/references/api-contracts/twitter-web-api.md +989 -0
- package/skills/meta-capability/references/api-contracts/wechat-channels-api.md +809 -0
- package/skills/meta-capability/references/api-contracts/wechat-media-platform-web-api.md +677 -0
- package/skills/meta-capability/references/api-contracts/weibo-app-api.md +1547 -0
- package/skills/meta-capability/references/api-contracts/weibo-web-api.md +798 -0
- package/skills/meta-capability/references/api-contracts/weibo-web-v2-api.md +2459 -0
- package/skills/meta-capability/references/api-contracts/xiaohongshu-app-api.md +1291 -0
- package/skills/meta-capability/references/api-contracts/xiaohongshu-app-v2-api.md +1683 -0
- package/skills/meta-capability/references/api-contracts/xiaohongshu-web-api.md +1324 -0
- package/skills/meta-capability/references/api-contracts/xiaohongshu-web-v2-api.md +1209 -0
- package/skills/meta-capability/references/api-contracts/xigua-app-v2-api.md +489 -0
- package/skills/meta-capability/references/api-contracts/youtube-web-api.md +2636 -0
- package/skills/meta-capability/references/api-contracts/youtube-web-v2-api.md +2660 -0
- package/skills/meta-capability/references/api-contracts/zhihu-web-api.md +2315 -0
- package/skills/meta-capability/references/api-tags/asr-api.md +100 -0
- package/skills/meta-capability/references/api-tags/bilibili-app-api.md +482 -0
- package/skills/meta-capability/references/api-tags/bilibili-web-api.md +1267 -0
- package/skills/meta-capability/references/api-tags/demo-api.md +365 -0
- package/skills/meta-capability/references/api-tags/douyin-app-v3-api.md +2012 -0
- package/skills/meta-capability/references/api-tags/douyin-billboard-api.md +1428 -0
- package/skills/meta-capability/references/api-tags/douyin-creator-api.md +694 -0
- package/skills/meta-capability/references/api-tags/douyin-creator-v2-api.md +694 -0
- package/skills/meta-capability/references/api-tags/douyin-search-api.md +1059 -0
- package/skills/meta-capability/references/api-tags/douyin-web-api.md +3314 -0
- package/skills/meta-capability/references/api-tags/douyin-xingtu-api.md +935 -0
- package/skills/meta-capability/references/api-tags/douyin-xingtu-v2-api.md +925 -0
- package/skills/meta-capability/references/api-tags/health-check.md +40 -0
- package/skills/meta-capability/references/api-tags/hybrid-parsing.md +57 -0
- package/skills/meta-capability/references/api-tags/instagram-v1-api.md +1224 -0
- package/skills/meta-capability/references/api-tags/instagram-v2-api.md +1147 -0
- package/skills/meta-capability/references/api-tags/instagram-v3-api.md +1123 -0
- package/skills/meta-capability/references/api-tags/ios-shortcut.md +45 -0
- package/skills/meta-capability/references/api-tags/kuaishou-app-api.md +846 -0
- package/skills/meta-capability/references/api-tags/kuaishou-web-api.md +551 -0
- package/skills/meta-capability/references/api-tags/lemon8-app-api.md +687 -0
- package/skills/meta-capability/references/api-tags/linkedin-web-api.md +1105 -0
- package/skills/meta-capability/references/api-tags/media-ingest-api.md +112 -0
- package/skills/meta-capability/references/api-tags/pipixia-app-api.md +721 -0
- package/skills/meta-capability/references/api-tags/reddit-app-api.md +1057 -0
- package/skills/meta-capability/references/api-tags/sora2-api.md +737 -0
- package/skills/meta-capability/references/api-tags/temp-mail-api.md +136 -0
- package/skills/meta-capability/references/api-tags/threads-web-api.md +472 -0
- package/skills/meta-capability/references/api-tags/tikhub-downloader-api.md +65 -0
- package/skills/meta-capability/references/api-tags/tikhub-user-api.md +253 -0
- package/skills/meta-capability/references/api-tags/tiktok-ads-api.md +1393 -0
- package/skills/meta-capability/references/api-tags/tiktok-analytics-api.md +179 -0
- package/skills/meta-capability/references/api-tags/tiktok-app-v3-api.md +3264 -0
- package/skills/meta-capability/references/api-tags/tiktok-creator-api.md +709 -0
- package/skills/meta-capability/references/api-tags/tiktok-interaction-api.md +366 -0
- package/skills/meta-capability/references/api-tags/tiktok-shop-web-api.md +663 -0
- package/skills/meta-capability/references/api-tags/tiktok-web-api.md +2516 -0
- package/skills/meta-capability/references/api-tags/toutiao-app-api.md +220 -0
- package/skills/meta-capability/references/api-tags/toutiao-web-api.md +96 -0
- package/skills/meta-capability/references/api-tags/twitter-web-api.md +562 -0
- package/skills/meta-capability/references/api-tags/wechat-channels-api.md +405 -0
- package/skills/meta-capability/references/api-tags/wechat-media-platform-web-api.md +431 -0
- package/skills/meta-capability/references/api-tags/weibo-app-api.md +851 -0
- package/skills/meta-capability/references/api-tags/weibo-web-api.md +470 -0
- package/skills/meta-capability/references/api-tags/weibo-web-v2-api.md +1405 -0
- package/skills/meta-capability/references/api-tags/xiaohongshu-app-api.md +534 -0
- package/skills/meta-capability/references/api-tags/xiaohongshu-app-v2-api.md +934 -0
- package/skills/meta-capability/references/api-tags/xiaohongshu-web-api.md +757 -0
- package/skills/meta-capability/references/api-tags/xiaohongshu-web-v2-api.md +762 -0
- package/skills/meta-capability/references/api-tags/xigua-app-v2-api.md +308 -0
- package/skills/meta-capability/references/api-tags/youtube-web-api.md +934 -0
- package/skills/meta-capability/references/api-tags/youtube-web-v2-api.md +717 -0
- package/skills/meta-capability/references/api-tags/zhihu-web-api.md +1384 -0
- package/skills/meta-capability/references/config-templates/defaults.yaml +18 -0
- package/skills/meta-capability/references/dispatch.md +27 -0
- package/skills/meta-capability/references/execution-guidelines.md +25 -0
- package/skills/meta-capability/references/implemented-route-map.md +177 -0
- package/skills/meta-capability/references/service-guides/asr-u2-u3-fallback.md +75 -0
- package/skills/meta-capability/scripts/__init__.py +1 -0
- package/skills/meta-capability/scripts/call_route.py +141 -0
- package/skills/meta-capability/scripts/core/__init__.py +1 -0
- package/skills/meta-capability/scripts/core/bootstrap_env.py +32 -0
- package/skills/meta-capability/scripts/core/config_loader.py +204 -0
- package/skills/meta-capability/scripts/core/tikomni_common.py +443 -0
- package/skills/meta-capability/scripts/test_auth.py +98 -0
- package/skills/single-work-analysis/SKILL.md +62 -0
- package/skills/single-work-analysis/agents/openai.yaml +4 -0
- package/skills/single-work-analysis/env.example +36 -0
- package/skills/single-work-analysis/references/api-capability-index.md +92 -0
- package/skills/single-work-analysis/references/api-contracts/asr-api.md +130 -0
- package/skills/single-work-analysis/references/api-contracts/bilibili-app-api.md +776 -0
- package/skills/single-work-analysis/references/api-contracts/bilibili-web-api.md +2017 -0
- package/skills/single-work-analysis/references/api-contracts/demo-api.md +717 -0
- package/skills/single-work-analysis/references/api-contracts/douyin-app-v3-api.md +3594 -0
- package/skills/single-work-analysis/references/api-contracts/douyin-billboard-api.md +2274 -0
- package/skills/single-work-analysis/references/api-contracts/douyin-creator-api.md +1575 -0
- package/skills/single-work-analysis/references/api-contracts/douyin-creator-v2-api.md +3254 -0
- package/skills/single-work-analysis/references/api-contracts/douyin-search-api.md +4118 -0
- package/skills/single-work-analysis/references/api-contracts/douyin-web-api.md +5544 -0
- package/skills/single-work-analysis/references/api-contracts/douyin-xingtu-api.md +1916 -0
- package/skills/single-work-analysis/references/api-contracts/douyin-xingtu-v2-api.md +1540 -0
- package/skills/single-work-analysis/references/api-contracts/health-check.md +69 -0
- package/skills/single-work-analysis/references/api-contracts/hybrid-parsing.md +78 -0
- package/skills/single-work-analysis/references/api-contracts/instagram-v1-api.md +2256 -0
- package/skills/single-work-analysis/references/api-contracts/instagram-v2-api.md +2011 -0
- package/skills/single-work-analysis/references/api-contracts/instagram-v3-api.md +2630 -0
- package/skills/single-work-analysis/references/api-contracts/ios-shortcut.md +44 -0
- package/skills/single-work-analysis/references/api-contracts/kuaishou-app-api.md +1518 -0
- package/skills/single-work-analysis/references/api-contracts/kuaishou-web-api.md +1242 -0
- package/skills/single-work-analysis/references/api-contracts/lemon8-app-api.md +1088 -0
- package/skills/single-work-analysis/references/api-contracts/linkedin-web-api.md +1949 -0
- package/skills/single-work-analysis/references/api-contracts/media-ingest-api.md +126 -0
- package/skills/single-work-analysis/references/api-contracts/pipixia-app-api.md +1142 -0
- package/skills/single-work-analysis/references/api-contracts/reddit-app-api.md +2025 -0
- package/skills/single-work-analysis/references/api-contracts/sora2-api.md +2266 -0
- package/skills/single-work-analysis/references/api-contracts/temp-mail-api.md +208 -0
- package/skills/single-work-analysis/references/api-contracts/threads-web-api.md +897 -0
- package/skills/single-work-analysis/references/api-contracts/tikhub-downloader-api.md +134 -0
- package/skills/single-work-analysis/references/api-contracts/tikhub-user-api.md +494 -0
- package/skills/single-work-analysis/references/api-contracts/tiktok-ads-api.md +5947 -0
- package/skills/single-work-analysis/references/api-contracts/tiktok-analytics-api.md +968 -0
- package/skills/single-work-analysis/references/api-contracts/tiktok-app-v3-api.md +5735 -0
- package/skills/single-work-analysis/references/api-contracts/tiktok-creator-api.md +1951 -0
- package/skills/single-work-analysis/references/api-contracts/tiktok-interaction-api.md +742 -0
- package/skills/single-work-analysis/references/api-contracts/tiktok-shop-web-api.md +1890 -0
- package/skills/single-work-analysis/references/api-contracts/tiktok-web-api.md +4448 -0
- package/skills/single-work-analysis/references/api-contracts/toutiao-app-api.md +342 -0
- package/skills/single-work-analysis/references/api-contracts/toutiao-web-api.md +143 -0
- package/skills/single-work-analysis/references/api-contracts/twitter-web-api.md +989 -0
- package/skills/single-work-analysis/references/api-contracts/wechat-channels-api.md +809 -0
- package/skills/single-work-analysis/references/api-contracts/wechat-media-platform-web-api.md +677 -0
- package/skills/single-work-analysis/references/api-contracts/weibo-app-api.md +1547 -0
- package/skills/single-work-analysis/references/api-contracts/weibo-web-api.md +798 -0
- package/skills/single-work-analysis/references/api-contracts/weibo-web-v2-api.md +2459 -0
- package/skills/single-work-analysis/references/api-contracts/xiaohongshu-app-api.md +1291 -0
- package/skills/single-work-analysis/references/api-contracts/xiaohongshu-app-v2-api.md +1683 -0
- package/skills/single-work-analysis/references/api-contracts/xiaohongshu-web-api.md +1324 -0
- package/skills/single-work-analysis/references/api-contracts/xiaohongshu-web-v2-api.md +1209 -0
- package/skills/single-work-analysis/references/api-contracts/xigua-app-v2-api.md +489 -0
- package/skills/single-work-analysis/references/api-contracts/youtube-web-api.md +2636 -0
- package/skills/single-work-analysis/references/api-contracts/youtube-web-v2-api.md +2660 -0
- package/skills/single-work-analysis/references/api-contracts/zhihu-web-api.md +2315 -0
- package/skills/single-work-analysis/references/api-tags/asr-api.md +100 -0
- package/skills/single-work-analysis/references/api-tags/bilibili-app-api.md +482 -0
- package/skills/single-work-analysis/references/api-tags/bilibili-web-api.md +1267 -0
- package/skills/single-work-analysis/references/api-tags/demo-api.md +365 -0
- package/skills/single-work-analysis/references/api-tags/douyin-app-v3-api.md +2012 -0
- package/skills/single-work-analysis/references/api-tags/douyin-billboard-api.md +1428 -0
- package/skills/single-work-analysis/references/api-tags/douyin-creator-api.md +694 -0
- package/skills/single-work-analysis/references/api-tags/douyin-creator-v2-api.md +694 -0
- package/skills/single-work-analysis/references/api-tags/douyin-search-api.md +1059 -0
- package/skills/single-work-analysis/references/api-tags/douyin-web-api.md +3314 -0
- package/skills/single-work-analysis/references/api-tags/douyin-xingtu-api.md +935 -0
- package/skills/single-work-analysis/references/api-tags/douyin-xingtu-v2-api.md +925 -0
- package/skills/single-work-analysis/references/api-tags/health-check.md +40 -0
- package/skills/single-work-analysis/references/api-tags/hybrid-parsing.md +57 -0
- package/skills/single-work-analysis/references/api-tags/instagram-v1-api.md +1224 -0
- package/skills/single-work-analysis/references/api-tags/instagram-v2-api.md +1147 -0
- package/skills/single-work-analysis/references/api-tags/instagram-v3-api.md +1123 -0
- package/skills/single-work-analysis/references/api-tags/ios-shortcut.md +45 -0
- package/skills/single-work-analysis/references/api-tags/kuaishou-app-api.md +846 -0
- package/skills/single-work-analysis/references/api-tags/kuaishou-web-api.md +551 -0
- package/skills/single-work-analysis/references/api-tags/lemon8-app-api.md +687 -0
- package/skills/single-work-analysis/references/api-tags/linkedin-web-api.md +1105 -0
- package/skills/single-work-analysis/references/api-tags/media-ingest-api.md +112 -0
- package/skills/single-work-analysis/references/api-tags/pipixia-app-api.md +721 -0
- package/skills/single-work-analysis/references/api-tags/reddit-app-api.md +1057 -0
- package/skills/single-work-analysis/references/api-tags/sora2-api.md +737 -0
- package/skills/single-work-analysis/references/api-tags/temp-mail-api.md +136 -0
- package/skills/single-work-analysis/references/api-tags/threads-web-api.md +472 -0
- package/skills/single-work-analysis/references/api-tags/tikhub-downloader-api.md +65 -0
- package/skills/single-work-analysis/references/api-tags/tikhub-user-api.md +253 -0
- package/skills/single-work-analysis/references/api-tags/tiktok-ads-api.md +1393 -0
- package/skills/single-work-analysis/references/api-tags/tiktok-analytics-api.md +179 -0
- package/skills/single-work-analysis/references/api-tags/tiktok-app-v3-api.md +3264 -0
- package/skills/single-work-analysis/references/api-tags/tiktok-creator-api.md +709 -0
- package/skills/single-work-analysis/references/api-tags/tiktok-interaction-api.md +366 -0
- package/skills/single-work-analysis/references/api-tags/tiktok-shop-web-api.md +663 -0
- package/skills/single-work-analysis/references/api-tags/tiktok-web-api.md +2516 -0
- package/skills/single-work-analysis/references/api-tags/toutiao-app-api.md +220 -0
- package/skills/single-work-analysis/references/api-tags/toutiao-web-api.md +96 -0
- package/skills/single-work-analysis/references/api-tags/twitter-web-api.md +562 -0
- package/skills/single-work-analysis/references/api-tags/wechat-channels-api.md +405 -0
- package/skills/single-work-analysis/references/api-tags/wechat-media-platform-web-api.md +431 -0
- package/skills/single-work-analysis/references/api-tags/weibo-app-api.md +851 -0
- package/skills/single-work-analysis/references/api-tags/weibo-web-api.md +470 -0
- package/skills/single-work-analysis/references/api-tags/weibo-web-v2-api.md +1405 -0
- package/skills/single-work-analysis/references/api-tags/xiaohongshu-app-api.md +534 -0
- package/skills/single-work-analysis/references/api-tags/xiaohongshu-app-v2-api.md +934 -0
- package/skills/single-work-analysis/references/api-tags/xiaohongshu-web-api.md +757 -0
- package/skills/single-work-analysis/references/api-tags/xiaohongshu-web-v2-api.md +762 -0
- package/skills/single-work-analysis/references/api-tags/xigua-app-v2-api.md +308 -0
- package/skills/single-work-analysis/references/api-tags/youtube-web-api.md +934 -0
- package/skills/single-work-analysis/references/api-tags/youtube-web-v2-api.md +717 -0
- package/skills/single-work-analysis/references/api-tags/zhihu-web-api.md +1384 -0
- package/skills/single-work-analysis/references/asr-and-fallback.md +20 -0
- package/skills/single-work-analysis/references/config-templates/defaults.yaml +58 -0
- package/skills/single-work-analysis/references/contracts/work-card-fields.md +41 -0
- package/skills/single-work-analysis/references/platform-guides/douyin.md +47 -0
- package/skills/single-work-analysis/references/platform-guides/generic.md +43 -0
- package/skills/single-work-analysis/references/platform-guides/xiaohongshu.md +54 -0
- package/skills/single-work-analysis/references/prompt-contracts/asr-clean.md +28 -0
- package/skills/single-work-analysis/references/prompt-contracts/cta.md +24 -0
- package/skills/single-work-analysis/references/prompt-contracts/hook.md +25 -0
- package/skills/single-work-analysis/references/prompt-contracts/insight.md +47 -0
- package/skills/single-work-analysis/references/prompt-contracts/structure.md +25 -0
- package/skills/single-work-analysis/references/prompt-contracts/style.md +27 -0
- package/skills/single-work-analysis/references/prompt-contracts/summary.md +29 -0
- package/skills/single-work-analysis/references/prompt-contracts/topic.md +29 -0
- package/skills/single-work-analysis/references/schemas/work-card.schema.json +39 -0
- package/skills/single-work-analysis/references/service-guides/asr-u2-u3-fallback.md +75 -0
- package/skills/single-work-analysis/scripts/__init__.py +0 -0
- package/skills/single-work-analysis/scripts/core/__init__.py +0 -0
- package/skills/single-work-analysis/scripts/core/analysis_pipeline.py +133 -0
- package/skills/single-work-analysis/scripts/core/bootstrap_env.py +35 -0
- package/skills/single-work-analysis/scripts/core/config_loader.py +418 -0
- package/skills/single-work-analysis/scripts/core/extract_pipeline.py +173 -0
- package/skills/single-work-analysis/scripts/core/progress_report.py +111 -0
- package/skills/single-work-analysis/scripts/core/storage_router.py +253 -0
- package/skills/single-work-analysis/scripts/core/tikomni_common.py +588 -0
- package/skills/single-work-analysis/scripts/pipeline/__init__.py +0 -0
- package/skills/single-work-analysis/scripts/pipeline/asr/__init__.py +0 -0
- package/skills/single-work-analysis/scripts/pipeline/asr/asr_pipeline.py +1189 -0
- package/skills/single-work-analysis/scripts/pipeline/asr/poll_u2_task.py +95 -0
- package/skills/single-work-analysis/scripts/platform/__init__.py +0 -0
- package/skills/single-work-analysis/scripts/platform/douyin/__init__.py +0 -0
- package/skills/single-work-analysis/scripts/platform/douyin/douyin_video_type_matrix.py +224 -0
- package/skills/single-work-analysis/scripts/platform/douyin/run_douyin_single_video.py +1233 -0
- package/skills/single-work-analysis/scripts/platform/douyin/select_low_quality_video_url.py +200 -0
- package/skills/single-work-analysis/scripts/platform/xiaohongshu/__init__.py +0 -0
- package/skills/single-work-analysis/scripts/platform/xiaohongshu/run_xiaohongshu_extract.py +2156 -0
- package/skills/single-work-analysis/scripts/writers/__init__.py +0 -0
- package/skills/single-work-analysis/scripts/writers/write_benchmark_card.py +1402 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Author-home work analysis artifact cache + worker orchestration."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import hashlib
|
|
7
|
+
import json
|
|
8
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
9
|
+
from copy import deepcopy
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
13
|
+
import re
|
|
14
|
+
|
|
15
|
+
from scripts.core.analysis_pipeline import DEFAULT_INSIGHT_SECTION, DEFAULT_MODULE_SECTIONS, PROMPT_CONTRACT_FILES, contracts_dir
|
|
16
|
+
from scripts.core.config_loader import config_get, resolve_storage_paths
|
|
17
|
+
from scripts.core.progress_report import ProgressReporter
|
|
18
|
+
from scripts.writers.write_benchmark_card import build_card_analysis_artifact
|
|
19
|
+
|
|
20
|
+
WORK_ANALYSIS_ARTIFACT_VERSION = "creator_analysis.work_analysis_artifact@v3"
|
|
21
|
+
DEFAULT_MAX_WORKERS = 3
|
|
22
|
+
MAX_MAX_WORKERS = 5
|
|
23
|
+
PERF_FIELDS = ("digg_count", "comment_count", "collect_count", "share_count", "play_count")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _safe_text(value: Any) -> str:
|
|
27
|
+
if value is None:
|
|
28
|
+
return ""
|
|
29
|
+
if isinstance(value, str):
|
|
30
|
+
return value.strip()
|
|
31
|
+
return str(value).strip()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _safe_int(value: Any, default: int = 0) -> int:
|
|
35
|
+
try:
|
|
36
|
+
if value is None:
|
|
37
|
+
return default
|
|
38
|
+
if isinstance(value, bool):
|
|
39
|
+
return int(value)
|
|
40
|
+
if isinstance(value, (int, float)):
|
|
41
|
+
return int(value)
|
|
42
|
+
text = _safe_text(value).replace(",", "")
|
|
43
|
+
return int(float(text)) if text else default
|
|
44
|
+
except Exception:
|
|
45
|
+
return default
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _coerce_unix_sec(value: Any) -> int:
|
|
49
|
+
parsed = _safe_int(value, default=0)
|
|
50
|
+
if parsed > 1_000_000_000_000:
|
|
51
|
+
parsed //= 1000
|
|
52
|
+
return parsed if parsed > 0 else 0
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _prompt_contract_hash() -> str:
|
|
56
|
+
directory = Path(contracts_dir())
|
|
57
|
+
sections = list(DEFAULT_MODULE_SECTIONS) + [DEFAULT_INSIGHT_SECTION]
|
|
58
|
+
filenames = [PROMPT_CONTRACT_FILES.get(section, "") for section in sections if PROMPT_CONTRACT_FILES.get(section, "")]
|
|
59
|
+
digest = hashlib.sha1()
|
|
60
|
+
for filename in filenames:
|
|
61
|
+
path = directory / filename
|
|
62
|
+
digest.update(filename.encode("utf-8"))
|
|
63
|
+
try:
|
|
64
|
+
digest.update(path.read_text(encoding="utf-8").encode("utf-8"))
|
|
65
|
+
except Exception:
|
|
66
|
+
digest.update(b"missing")
|
|
67
|
+
return digest.hexdigest()[:16]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
PROMPT_CONTRACT_HASH = _prompt_contract_hash()
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _first_sentence(text: Any) -> str:
|
|
74
|
+
clean = _safe_text(text)
|
|
75
|
+
if not clean:
|
|
76
|
+
return ""
|
|
77
|
+
for chunk in clean.replace("\r", "\n").split("\n"):
|
|
78
|
+
row = _safe_text(chunk)
|
|
79
|
+
if row:
|
|
80
|
+
return row
|
|
81
|
+
units = [part.strip() for part in re.split(r"[。!?!?;;]+", clean) if part.strip()]
|
|
82
|
+
return units[0] if units else clean[:80]
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _format_metric_summary(work: Dict[str, Any]) -> str:
|
|
86
|
+
metrics = _metrics_from_work(work)
|
|
87
|
+
return (
|
|
88
|
+
f"赞 {metrics['digg_count']} / 评 {metrics['comment_count']} / 藏 {metrics['collect_count']} / "
|
|
89
|
+
f"转 {metrics['share_count']} / 播 {metrics['play_count']}"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _author_home_structural_sections(work: Dict[str, Any]) -> Dict[str, Any]:
|
|
94
|
+
tags = [item for item in (work.get("tags") or []) if _safe_text(item)] if isinstance(work.get("tags"), list) else []
|
|
95
|
+
style_markers = [item for item in (work.get("style_markers") or []) if _safe_text(item)] if isinstance(work.get("style_markers"), list) else []
|
|
96
|
+
first_sentence = _first_sentence(work.get("primary_text") or work.get("asr_raw") or work.get("caption_raw") or work.get("title"))
|
|
97
|
+
bucket = _safe_text(work.get("bucket")) or "unknown"
|
|
98
|
+
all_time_rank = work.get("all_time_score_rank")
|
|
99
|
+
recent_rank = work.get("recent_30d_score_rank")
|
|
100
|
+
recent_rank_text = recent_rank if recent_rank is not None else "NA"
|
|
101
|
+
work_modality = _safe_text(work.get("work_modality")) or "unknown"
|
|
102
|
+
primary_text_source = _safe_text(work.get("primary_text_source"))
|
|
103
|
+
if primary_text_source not in {"asr_clean", "caption_raw"}:
|
|
104
|
+
primary_text_source = "asr_clean" if work_modality == "video" else "caption_raw"
|
|
105
|
+
primary_text_label = "视频口播清洗文本" if primary_text_source == "asr_clean" else "作者原始文案"
|
|
106
|
+
has_primary_text = bool(_safe_text(work.get("primary_text")))
|
|
107
|
+
modules = {
|
|
108
|
+
"选题": [
|
|
109
|
+
f"- 原始 tags:{'、'.join(tags[:6]) if tags else '无'}。",
|
|
110
|
+
f"- 分桶/排名:bucket={bucket} / all_time_rank={all_time_rank or 'NA'} / recent_30d_rank={recent_rank_text}。",
|
|
111
|
+
f"- 主文本载体:{primary_text_label}。",
|
|
112
|
+
],
|
|
113
|
+
"文风": [
|
|
114
|
+
f"- 内容形态:work_modality={work_modality} / content_form={_safe_text(work.get('content_form')) or 'unknown'}。",
|
|
115
|
+
f"- 表达标记:{'、'.join(style_markers[:6]) if style_markers else '未命中显著 style_markers'}。",
|
|
116
|
+
f"- 数据状态:{'主文本已就绪' if has_primary_text else '主文本缺失,仅保留事实字段'}。",
|
|
117
|
+
],
|
|
118
|
+
"Hook": [
|
|
119
|
+
f"- hook_type:{_safe_text(work.get('hook_type')) or 'unknown'}。",
|
|
120
|
+
f"- 开头原句:{first_sentence or '无可用主文本'}",
|
|
121
|
+
],
|
|
122
|
+
"结构": [
|
|
123
|
+
f"- structure_type:{_safe_text(work.get('structure_type')) or 'unknown'}。",
|
|
124
|
+
f"- cta_type:{_safe_text(work.get('cta_type')) or 'unknown'}。",
|
|
125
|
+
f"- performance_score_norm:{work.get('performance_score_norm') if work.get('performance_score_norm') is not None else 'NA'}。",
|
|
126
|
+
],
|
|
127
|
+
}
|
|
128
|
+
insight = [
|
|
129
|
+
f"- 表现摘要:{_format_metric_summary(work)}。",
|
|
130
|
+
f"- 样本定位:这是作者主页样本卡,只保留事实字段与结构标签;不做逐条 rigid 语义赛道分类。",
|
|
131
|
+
f"- 可复用观察:优先参考 bucket / hook_type / structure_type / cta_type / content_form 的组合,而不是把单条作品硬归为某个固定 topic。",
|
|
132
|
+
]
|
|
133
|
+
return {"modules": modules, "insight": insight}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _metrics_from_work(work: Dict[str, Any]) -> Dict[str, int]:
|
|
137
|
+
metrics = work.get("metrics") if isinstance(work.get("metrics"), dict) else {}
|
|
138
|
+
return {
|
|
139
|
+
"digg_count": _safe_int(metrics.get("like"), default=0),
|
|
140
|
+
"comment_count": _safe_int(metrics.get("comment"), default=0),
|
|
141
|
+
"collect_count": _safe_int(metrics.get("collect"), default=0),
|
|
142
|
+
"share_count": _safe_int(metrics.get("share"), default=0),
|
|
143
|
+
"play_count": _safe_int(metrics.get("play"), default=0),
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def build_single_work_payload(
|
|
148
|
+
*,
|
|
149
|
+
platform: str,
|
|
150
|
+
profile: Dict[str, Any],
|
|
151
|
+
work: Dict[str, Any],
|
|
152
|
+
) -> Dict[str, Any]:
|
|
153
|
+
author_platform_id = _safe_text(profile.get("author_platform_id") or profile.get("platform_author_id"))
|
|
154
|
+
author_handle = _safe_text(profile.get("author_handle"))
|
|
155
|
+
author = {
|
|
156
|
+
"nickname": profile.get("nickname"),
|
|
157
|
+
"platform_author_id": author_platform_id,
|
|
158
|
+
"author_handle": author_handle,
|
|
159
|
+
}
|
|
160
|
+
payload: Dict[str, Any] = {
|
|
161
|
+
"content_kind": "single_video" if platform == "douyin" else "note",
|
|
162
|
+
"platform_work_id": work.get("platform_work_id"),
|
|
163
|
+
"title": work.get("title") or work.get("desc"),
|
|
164
|
+
"caption_raw": work.get("caption_raw") or work.get("desc") or "",
|
|
165
|
+
"desc": work.get("caption_raw") or work.get("desc") or work.get("title"),
|
|
166
|
+
"source_url": work.get("source_url"),
|
|
167
|
+
"share_url": work.get("share_url"),
|
|
168
|
+
"cover_image": work.get("cover_image"),
|
|
169
|
+
"video_download_url": work.get("video_download_url") or work.get("video_down_url"),
|
|
170
|
+
"author": author,
|
|
171
|
+
"author_handle": author_handle,
|
|
172
|
+
"platform_author_id": author_platform_id,
|
|
173
|
+
"publish_time": work.get("publish_time"),
|
|
174
|
+
"published_date": work.get("published_date"),
|
|
175
|
+
"duration_ms": _safe_int(work.get("duration_ms"), default=0),
|
|
176
|
+
"summary": _safe_text(work.get("summary")),
|
|
177
|
+
"insights": ["source=author_home_work_analysis_artifact", "analysis_strategy=structural_sample_card"],
|
|
178
|
+
"raw_content": _safe_text(work.get("asr_raw")),
|
|
179
|
+
"primary_text": _safe_text(work.get("primary_text")),
|
|
180
|
+
"primary_text_source": _safe_text(work.get("primary_text_source")),
|
|
181
|
+
"asr_clean": _safe_text(work.get("asr_clean")),
|
|
182
|
+
"tags": list(work.get("tags") or []) if isinstance(work.get("tags"), list) else [],
|
|
183
|
+
"work_modality": _safe_text(work.get("work_modality")) or ("video" if platform == "douyin" else "text"),
|
|
184
|
+
"analysis_eligibility": _safe_text(work.get("analysis_eligibility")) or "eligible",
|
|
185
|
+
"analysis_exclusion_reason": _safe_text(work.get("analysis_exclusion_reason")),
|
|
186
|
+
"platform_native_refs": dict(work.get("platform_native_refs") or {}),
|
|
187
|
+
"request_id": work.get("request_id"),
|
|
188
|
+
"confidence": "medium" if _safe_text(work.get("primary_text") or work.get("title") or work.get("caption_raw")) else "low",
|
|
189
|
+
"error_reason": None,
|
|
190
|
+
"extract_trace": [],
|
|
191
|
+
}
|
|
192
|
+
payload.update(_metrics_from_work(work))
|
|
193
|
+
payload["analysis_sections"] = _author_home_structural_sections(work)
|
|
194
|
+
return payload
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _artifact_cache_key(*, platform: str, content_kind: str, platform_work_id: str) -> str:
|
|
198
|
+
raw = "|".join(
|
|
199
|
+
[
|
|
200
|
+
platform,
|
|
201
|
+
content_kind,
|
|
202
|
+
platform_work_id,
|
|
203
|
+
WORK_ANALYSIS_ARTIFACT_VERSION,
|
|
204
|
+
PROMPT_CONTRACT_HASH,
|
|
205
|
+
]
|
|
206
|
+
)
|
|
207
|
+
return hashlib.sha1(raw.encode("utf-8")).hexdigest()[:20]
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def _resolve_artifact_root(storage_config: Optional[Dict[str, Any]]) -> Optional[Path]:
|
|
211
|
+
try:
|
|
212
|
+
paths = resolve_storage_paths(storage_config or {})
|
|
213
|
+
except Exception:
|
|
214
|
+
return None
|
|
215
|
+
runs_root = Path(str(paths.get("runs_root") or "").strip())
|
|
216
|
+
if not str(runs_root):
|
|
217
|
+
return None
|
|
218
|
+
return runs_root / "author_home_work_analysis_artifacts"
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def _artifact_path(*, artifact_root: Optional[Path], platform: str, platform_work_id: str, content_kind: str) -> Tuple[Optional[Path], Optional[str]]:
|
|
222
|
+
if artifact_root is None or not platform_work_id:
|
|
223
|
+
return None, None
|
|
224
|
+
cache_key = _artifact_cache_key(platform=platform, content_kind=content_kind, platform_work_id=platform_work_id)
|
|
225
|
+
safe_work_id = hashlib.sha1(platform_work_id.encode("utf-8")).hexdigest()[:12]
|
|
226
|
+
return artifact_root / platform / f"{safe_work_id}-{cache_key}.json", cache_key
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def _load_cached_artifact(
|
|
230
|
+
*,
|
|
231
|
+
artifact_root: Optional[Path],
|
|
232
|
+
platform: str,
|
|
233
|
+
content_kind: str,
|
|
234
|
+
platform_work_id: str,
|
|
235
|
+
) -> Optional[Dict[str, Any]]:
|
|
236
|
+
path, cache_key = _artifact_path(
|
|
237
|
+
artifact_root=artifact_root,
|
|
238
|
+
platform=platform,
|
|
239
|
+
platform_work_id=platform_work_id,
|
|
240
|
+
content_kind=content_kind,
|
|
241
|
+
)
|
|
242
|
+
if path is None or cache_key is None or not path.is_file():
|
|
243
|
+
return None
|
|
244
|
+
try:
|
|
245
|
+
payload = json.loads(path.read_text(encoding="utf-8"))
|
|
246
|
+
except Exception:
|
|
247
|
+
return None
|
|
248
|
+
meta = payload.get("meta") if isinstance(payload.get("meta"), dict) else {}
|
|
249
|
+
if meta.get("cache_key") != cache_key:
|
|
250
|
+
return None
|
|
251
|
+
if meta.get("analysis_logic_version") != WORK_ANALYSIS_ARTIFACT_VERSION:
|
|
252
|
+
return None
|
|
253
|
+
if meta.get("prompt_contract_hash") != PROMPT_CONTRACT_HASH:
|
|
254
|
+
return None
|
|
255
|
+
return payload if isinstance(payload, dict) else None
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def _write_cached_artifact(
|
|
259
|
+
*,
|
|
260
|
+
artifact_root: Optional[Path],
|
|
261
|
+
artifact: Dict[str, Any],
|
|
262
|
+
) -> Optional[str]:
|
|
263
|
+
meta = artifact.get("meta") if isinstance(artifact.get("meta"), dict) else {}
|
|
264
|
+
path, _ = _artifact_path(
|
|
265
|
+
artifact_root=artifact_root,
|
|
266
|
+
platform=_safe_text(meta.get("platform")),
|
|
267
|
+
platform_work_id=_safe_text(meta.get("platform_work_id")),
|
|
268
|
+
content_kind=_safe_text(meta.get("content_kind")),
|
|
269
|
+
)
|
|
270
|
+
if path is None:
|
|
271
|
+
return None
|
|
272
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
273
|
+
path.write_text(json.dumps(artifact, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
274
|
+
return str(path)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def _refresh_cached_payload(
|
|
278
|
+
*,
|
|
279
|
+
artifact: Dict[str, Any],
|
|
280
|
+
profile: Dict[str, Any],
|
|
281
|
+
work: Dict[str, Any],
|
|
282
|
+
from_cache: bool,
|
|
283
|
+
artifact_path: Optional[str],
|
|
284
|
+
) -> Dict[str, Any]:
|
|
285
|
+
payload = deepcopy(artifact.get("payload") if isinstance(artifact.get("payload"), dict) else {})
|
|
286
|
+
payload["analysis_sections"] = deepcopy(
|
|
287
|
+
artifact.get("analysis_sections") if isinstance(artifact.get("analysis_sections"), dict) else {}
|
|
288
|
+
)
|
|
289
|
+
payload["extract_trace"] = list(payload.get("extract_trace") or [])
|
|
290
|
+
payload["extract_trace"].append(
|
|
291
|
+
{
|
|
292
|
+
"step": "author_home.work_analysis.cache_hit" if from_cache else "author_home.work_analysis.generated",
|
|
293
|
+
"platform_work_id": work.get("platform_work_id"),
|
|
294
|
+
"ok": True,
|
|
295
|
+
"artifact_cache_key": ((artifact.get("meta") or {}).get("cache_key") if isinstance(artifact.get("meta"), dict) else None),
|
|
296
|
+
"artifact_path": artifact_path,
|
|
297
|
+
"from_cache": from_cache,
|
|
298
|
+
}
|
|
299
|
+
)
|
|
300
|
+
payload["request_id"] = work.get("request_id") or payload.get("request_id")
|
|
301
|
+
payload["author"] = {
|
|
302
|
+
"nickname": profile.get("nickname"),
|
|
303
|
+
"platform_author_id": profile.get("author_platform_id") or profile.get("platform_author_id"),
|
|
304
|
+
"author_handle": profile.get("author_handle") or "",
|
|
305
|
+
}
|
|
306
|
+
payload["author_handle"] = profile.get("author_handle") or ""
|
|
307
|
+
payload["platform_author_id"] = profile.get("author_platform_id") or profile.get("platform_author_id")
|
|
308
|
+
for field, value in _metrics_from_work(work).items():
|
|
309
|
+
payload[field] = value
|
|
310
|
+
return payload
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
def _build_artifact(
|
|
314
|
+
*,
|
|
315
|
+
platform: str,
|
|
316
|
+
profile: Dict[str, Any],
|
|
317
|
+
work: Dict[str, Any],
|
|
318
|
+
) -> Dict[str, Any]:
|
|
319
|
+
payload = build_single_work_payload(platform=platform, profile=profile, work=work)
|
|
320
|
+
analysis_artifact = build_card_analysis_artifact(payload=payload, platform=platform, card_type="work")
|
|
321
|
+
payload["analysis_sections"] = deepcopy(analysis_artifact.get("analysis_sections") or {})
|
|
322
|
+
payload["extract_trace"] = list(payload.get("extract_trace") or [])
|
|
323
|
+
payload["extract_trace"].append(
|
|
324
|
+
{
|
|
325
|
+
"step": "author_home.work_analysis.generated",
|
|
326
|
+
"platform_work_id": work.get("platform_work_id"),
|
|
327
|
+
"ok": True,
|
|
328
|
+
"prompt_contract_hash": PROMPT_CONTRACT_HASH,
|
|
329
|
+
}
|
|
330
|
+
)
|
|
331
|
+
platform_work_id = _safe_text(work.get("platform_work_id"))
|
|
332
|
+
return {
|
|
333
|
+
"meta": {
|
|
334
|
+
"platform": platform,
|
|
335
|
+
"platform_work_id": platform_work_id,
|
|
336
|
+
"content_kind": _safe_text(payload.get("content_kind")) or "single_video",
|
|
337
|
+
"analysis_logic_version": WORK_ANALYSIS_ARTIFACT_VERSION,
|
|
338
|
+
"prompt_contract_hash": PROMPT_CONTRACT_HASH,
|
|
339
|
+
"cache_key": _artifact_cache_key(
|
|
340
|
+
platform=platform,
|
|
341
|
+
content_kind=_safe_text(payload.get("content_kind")) or "single_video",
|
|
342
|
+
platform_work_id=platform_work_id,
|
|
343
|
+
) if platform_work_id else None,
|
|
344
|
+
"written_at": datetime.now().isoformat(timespec="seconds"),
|
|
345
|
+
},
|
|
346
|
+
"payload": payload,
|
|
347
|
+
"analysis_sections": analysis_artifact.get("analysis_sections") if isinstance(analysis_artifact.get("analysis_sections"), dict) else {},
|
|
348
|
+
"required_fields": analysis_artifact.get("fields") if isinstance(analysis_artifact.get("fields"), dict) else {},
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
def _resolve_max_workers(storage_config: Optional[Dict[str, Any]]) -> int:
|
|
353
|
+
configured = config_get(storage_config or {}, "author_home.work_analysis.max_workers", DEFAULT_MAX_WORKERS)
|
|
354
|
+
try:
|
|
355
|
+
value = int(configured)
|
|
356
|
+
except Exception:
|
|
357
|
+
value = DEFAULT_MAX_WORKERS
|
|
358
|
+
return min(max(value, 1), MAX_MAX_WORKERS)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def orchestrate_work_analysis_artifacts(
|
|
362
|
+
*,
|
|
363
|
+
platform: str,
|
|
364
|
+
profile: Dict[str, Any],
|
|
365
|
+
works: List[Dict[str, Any]],
|
|
366
|
+
storage_config: Optional[Dict[str, Any]],
|
|
367
|
+
progress: Optional[ProgressReporter] = None,
|
|
368
|
+
) -> Dict[str, Any]:
|
|
369
|
+
artifact_root = _resolve_artifact_root(storage_config)
|
|
370
|
+
max_workers = _resolve_max_workers(storage_config)
|
|
371
|
+
stats = {
|
|
372
|
+
"total_count": len(works),
|
|
373
|
+
"cache_hit_count": 0,
|
|
374
|
+
"queued_count": 0,
|
|
375
|
+
"running_workers": 0,
|
|
376
|
+
"running_workers_peak": 0,
|
|
377
|
+
"finished_count": 0,
|
|
378
|
+
"failed_count": 0,
|
|
379
|
+
"max_workers": max_workers,
|
|
380
|
+
}
|
|
381
|
+
trace: List[Dict[str, Any]] = []
|
|
382
|
+
failed_items: List[Dict[str, Any]] = []
|
|
383
|
+
render_payloads: Dict[str, Dict[str, Any]] = {}
|
|
384
|
+
artifact_manifest: Dict[str, Dict[str, Any]] = {}
|
|
385
|
+
queue: List[Dict[str, Any]] = []
|
|
386
|
+
|
|
387
|
+
if progress is not None:
|
|
388
|
+
progress.started(
|
|
389
|
+
stage="author_home.work_analysis",
|
|
390
|
+
message="preparing work analysis artifacts",
|
|
391
|
+
data={"total_count": len(works), "max_workers": max_workers},
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
for work in works:
|
|
395
|
+
platform_work_id = _safe_text(work.get("platform_work_id"))
|
|
396
|
+
content_kind = "single_video" if platform == "douyin" else "note"
|
|
397
|
+
if not platform_work_id:
|
|
398
|
+
stats["failed_count"] += 1
|
|
399
|
+
failed_items.append({"platform_work_id": "", "error_reason": "missing_platform_work_id"})
|
|
400
|
+
trace.append(
|
|
401
|
+
{
|
|
402
|
+
"step": "author_home.work_analysis.failed",
|
|
403
|
+
"platform_work_id": "",
|
|
404
|
+
"ok": False,
|
|
405
|
+
"error_reason": "missing_platform_work_id",
|
|
406
|
+
}
|
|
407
|
+
)
|
|
408
|
+
continue
|
|
409
|
+
cached = _load_cached_artifact(
|
|
410
|
+
artifact_root=artifact_root,
|
|
411
|
+
platform=platform,
|
|
412
|
+
content_kind=content_kind,
|
|
413
|
+
platform_work_id=platform_work_id,
|
|
414
|
+
) if platform_work_id else None
|
|
415
|
+
if cached is not None:
|
|
416
|
+
artifact_path, _ = _artifact_path(
|
|
417
|
+
artifact_root=artifact_root,
|
|
418
|
+
platform=platform,
|
|
419
|
+
platform_work_id=platform_work_id,
|
|
420
|
+
content_kind=content_kind,
|
|
421
|
+
)
|
|
422
|
+
payload = _refresh_cached_payload(
|
|
423
|
+
artifact=cached,
|
|
424
|
+
profile=profile,
|
|
425
|
+
work=work,
|
|
426
|
+
from_cache=True,
|
|
427
|
+
artifact_path=str(artifact_path) if artifact_path is not None else None,
|
|
428
|
+
)
|
|
429
|
+
render_payloads[platform_work_id] = payload
|
|
430
|
+
artifact_manifest[platform_work_id] = {
|
|
431
|
+
"from_cache": True,
|
|
432
|
+
"artifact_path": str(artifact_path) if artifact_path is not None else None,
|
|
433
|
+
}
|
|
434
|
+
stats["cache_hit_count"] += 1
|
|
435
|
+
trace.append(
|
|
436
|
+
{
|
|
437
|
+
"step": "author_home.work_analysis.cache_hit",
|
|
438
|
+
"platform_work_id": platform_work_id,
|
|
439
|
+
"ok": True,
|
|
440
|
+
"artifact_path": str(artifact_path) if artifact_path is not None else None,
|
|
441
|
+
}
|
|
442
|
+
)
|
|
443
|
+
continue
|
|
444
|
+
queue.append(work)
|
|
445
|
+
|
|
446
|
+
stats["queued_count"] = len(queue)
|
|
447
|
+
if progress is not None:
|
|
448
|
+
progress.progress(
|
|
449
|
+
stage="author_home.work_analysis.queue",
|
|
450
|
+
message="work analysis queue prepared",
|
|
451
|
+
data={
|
|
452
|
+
"cache_hit_count": stats["cache_hit_count"],
|
|
453
|
+
"queued_count": stats["queued_count"],
|
|
454
|
+
"running_workers": stats["running_workers"],
|
|
455
|
+
"finished_count": stats["finished_count"],
|
|
456
|
+
"failed_count": stats["failed_count"],
|
|
457
|
+
},
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
if queue:
|
|
461
|
+
queued_failed_count = 0
|
|
462
|
+
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
|
463
|
+
future_map = {
|
|
464
|
+
executor.submit(_build_artifact, platform=platform, profile=profile, work=work): work
|
|
465
|
+
for work in queue
|
|
466
|
+
}
|
|
467
|
+
stats["running_workers"] = min(len(future_map), max_workers)
|
|
468
|
+
stats["running_workers_peak"] = min(len(future_map), max_workers)
|
|
469
|
+
for future in as_completed(future_map):
|
|
470
|
+
work = future_map[future]
|
|
471
|
+
platform_work_id = _safe_text(work.get("platform_work_id"))
|
|
472
|
+
try:
|
|
473
|
+
artifact = future.result()
|
|
474
|
+
artifact_path = _write_cached_artifact(artifact_root=artifact_root, artifact=artifact)
|
|
475
|
+
payload = _refresh_cached_payload(
|
|
476
|
+
artifact=artifact,
|
|
477
|
+
profile=profile,
|
|
478
|
+
work=work,
|
|
479
|
+
from_cache=False,
|
|
480
|
+
artifact_path=artifact_path,
|
|
481
|
+
)
|
|
482
|
+
if platform_work_id:
|
|
483
|
+
render_payloads[platform_work_id] = payload
|
|
484
|
+
artifact_manifest[platform_work_id] = {
|
|
485
|
+
"from_cache": False,
|
|
486
|
+
"artifact_path": artifact_path,
|
|
487
|
+
}
|
|
488
|
+
stats["finished_count"] += 1
|
|
489
|
+
trace.append(
|
|
490
|
+
{
|
|
491
|
+
"step": "author_home.work_analysis.generated",
|
|
492
|
+
"platform_work_id": platform_work_id,
|
|
493
|
+
"ok": True,
|
|
494
|
+
"artifact_path": artifact_path,
|
|
495
|
+
}
|
|
496
|
+
)
|
|
497
|
+
except Exception as error:
|
|
498
|
+
queued_failed_count += 1
|
|
499
|
+
stats["failed_count"] += 1
|
|
500
|
+
failed_items.append(
|
|
501
|
+
{
|
|
502
|
+
"platform_work_id": platform_work_id,
|
|
503
|
+
"error_reason": f"{type(error).__name__}:{error}",
|
|
504
|
+
}
|
|
505
|
+
)
|
|
506
|
+
trace.append(
|
|
507
|
+
{
|
|
508
|
+
"step": "author_home.work_analysis.failed",
|
|
509
|
+
"platform_work_id": platform_work_id,
|
|
510
|
+
"ok": False,
|
|
511
|
+
"error_reason": f"{type(error).__name__}:{error}",
|
|
512
|
+
}
|
|
513
|
+
)
|
|
514
|
+
finally:
|
|
515
|
+
remaining = max(stats["queued_count"] - stats["finished_count"] - queued_failed_count, 0)
|
|
516
|
+
stats["running_workers"] = min(remaining, max_workers)
|
|
517
|
+
if progress is not None:
|
|
518
|
+
progress.progress(
|
|
519
|
+
stage="author_home.work_analysis.progress",
|
|
520
|
+
message="work analysis artifact progress updated",
|
|
521
|
+
data={
|
|
522
|
+
"cache_hit_count": stats["cache_hit_count"],
|
|
523
|
+
"queued_count": stats["queued_count"],
|
|
524
|
+
"running_workers": stats["running_workers"],
|
|
525
|
+
"finished_count": stats["finished_count"],
|
|
526
|
+
"failed_count": stats["failed_count"],
|
|
527
|
+
},
|
|
528
|
+
)
|
|
529
|
+
|
|
530
|
+
if progress is not None:
|
|
531
|
+
final_event = progress.failed if stats["failed_count"] else progress.done
|
|
532
|
+
final_event(
|
|
533
|
+
stage="author_home.work_analysis",
|
|
534
|
+
message="work analysis artifacts ready" if not stats["failed_count"] else "work analysis artifacts partially failed",
|
|
535
|
+
data={
|
|
536
|
+
"cache_hit_count": stats["cache_hit_count"],
|
|
537
|
+
"queued_count": stats["queued_count"],
|
|
538
|
+
"running_workers": stats["running_workers"],
|
|
539
|
+
"finished_count": stats["finished_count"],
|
|
540
|
+
"failed_count": stats["failed_count"],
|
|
541
|
+
},
|
|
542
|
+
)
|
|
543
|
+
|
|
544
|
+
return {
|
|
545
|
+
"render_payloads": render_payloads,
|
|
546
|
+
"artifact_manifest": artifact_manifest,
|
|
547
|
+
"stats": stats,
|
|
548
|
+
"failed_items": failed_items,
|
|
549
|
+
"trace": trace,
|
|
550
|
+
"artifact_root": str(artifact_root) if artifact_root is not None else None,
|
|
551
|
+
"analysis_logic_version": WORK_ANALYSIS_ARTIFACT_VERSION,
|
|
552
|
+
"prompt_contract_hash": PROMPT_CONTRACT_HASH,
|
|
553
|
+
}
|