@tikomni/skills 0.1.2 → 0.1.4
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 +1 -3
- package/README.md +41 -49
- package/README.zh-CN.md +43 -51
- package/bin/tikomni-skills.js +2 -2
- package/env.example +37 -56
- package/package.json +7 -3
- package/skills/social-media-crawl/SKILL.md +53 -0
- package/skills/social-media-crawl/agents/openai.yaml +5 -0
- package/skills/social-media-crawl/references/contracts/output-envelope.md +22 -0
- package/skills/social-media-crawl/references/contracts/work-fact-card-fields.md +48 -0
- package/skills/social-media-crawl/references/guides/generic-mcp-objects.md +30 -0
- package/skills/social-media-crawl/references/mcp-usage-contract.md +30 -0
- package/skills/social-media-crawl/references/pipelines/douyin-creator-home.md +7 -0
- package/skills/social-media-crawl/references/pipelines/douyin-single-work.md +7 -0
- package/skills/social-media-crawl/references/pipelines/xiaohongshu-creator-home.md +7 -0
- package/skills/social-media-crawl/references/pipelines/xiaohongshu-single-work.md +7 -0
- package/skills/social-media-crawl/references/schemas/creator-profile.schema.json +33 -0
- package/skills/social-media-crawl/references/schemas/output-envelope.schema.json +41 -0
- package/skills/social-media-crawl/references/schemas/work-collection.schema.json +29 -0
- package/skills/social-media-crawl/references/schemas/work-fact-card.schema.json +67 -0
- package/skills/social-media-crawl/references/service-guides/u2-u3-mandatory-fallback.md +21 -0
- package/skills/social-media-crawl/scripts/__init__.py +2 -0
- package/skills/social-media-crawl/scripts/core/__init__.py +2 -0
- package/skills/{creator-analysis/scripts/pipeline/asr → social-media-crawl/scripts/core}/asr_pipeline.py +252 -9
- package/skills/social-media-crawl/scripts/core/completeness.py +83 -0
- package/skills/{single-work-analysis → social-media-crawl}/scripts/core/config_loader.py +108 -167
- package/skills/social-media-crawl/scripts/core/mcp_dispatch.py +145 -0
- package/skills/social-media-crawl/scripts/core/object_detection.py +63 -0
- package/skills/{creator-analysis/scripts/pipeline/asr → social-media-crawl/scripts/core}/poll_u2_task.py +6 -2
- package/skills/{single-work-analysis → social-media-crawl}/scripts/core/progress_report.py +32 -0
- package/skills/social-media-crawl/scripts/core/storage_router.py +160 -0
- package/skills/{creator-analysis → social-media-crawl}/scripts/core/tikomni_common.py +13 -3
- package/skills/social-media-crawl/scripts/core/u3_fallback.py +328 -0
- package/skills/social-media-crawl/scripts/pipelines/__init__.py +2 -0
- package/skills/social-media-crawl/scripts/pipelines/douyin_creator_home_helpers.py +35 -0
- package/skills/social-media-crawl/scripts/pipelines/douyin_platform_adapter.py +7 -0
- package/skills/{creator-analysis/scripts/author_home/asr → social-media-crawl/scripts/pipelines}/home_asr.py +1 -1
- package/skills/{creator-analysis/scripts/author_home/adapters → social-media-crawl/scripts/pipelines}/platform_adapters.py +8 -2
- package/skills/social-media-crawl/scripts/pipelines/run_douyin_creator_home.py +237 -0
- package/skills/{single-work-analysis/scripts/platform/douyin/run_douyin_single_video.py → social-media-crawl/scripts/pipelines/run_douyin_single_work.py} +282 -174
- package/skills/social-media-crawl/scripts/pipelines/run_xiaohongshu_creator_home.py +237 -0
- package/skills/{single-work-analysis/scripts/platform/xiaohongshu/run_xiaohongshu_extract.py → social-media-crawl/scripts/pipelines/run_xiaohongshu_single_work.py} +290 -141
- package/skills/{creator-analysis/scripts/author_home → social-media-crawl/scripts/pipelines}/schema.py +1 -1
- package/skills/social-media-crawl/scripts/pipelines/xiaohongshu_creator_home_helpers.py +35 -0
- package/skills/social-media-crawl/scripts/pipelines/xiaohongshu_platform_adapter.py +7 -0
- package/skills/social-media-crawl/scripts/writers/__init__.py +1 -0
- package/skills/social-media-crawl/scripts/writers/write_work_fact_card.py +391 -0
- package/skills/creator-analysis/SKILL.md +0 -95
- package/skills/creator-analysis/agents/openai.yaml +0 -4
- package/skills/creator-analysis/env.example +0 -36
- package/skills/creator-analysis/references/api-capability-index.md +0 -92
- package/skills/creator-analysis/references/api-contracts/asr-api.md +0 -130
- package/skills/creator-analysis/references/api-contracts/bilibili-app-api.md +0 -776
- package/skills/creator-analysis/references/api-contracts/bilibili-web-api.md +0 -2017
- package/skills/creator-analysis/references/api-contracts/demo-api.md +0 -717
- package/skills/creator-analysis/references/api-contracts/douyin-app-v3-api.md +0 -3594
- package/skills/creator-analysis/references/api-contracts/douyin-billboard-api.md +0 -2274
- package/skills/creator-analysis/references/api-contracts/douyin-creator-api.md +0 -1575
- package/skills/creator-analysis/references/api-contracts/douyin-creator-v2-api.md +0 -3254
- package/skills/creator-analysis/references/api-contracts/douyin-search-api.md +0 -4118
- package/skills/creator-analysis/references/api-contracts/douyin-web-api.md +0 -5544
- package/skills/creator-analysis/references/api-contracts/douyin-xingtu-api.md +0 -1916
- package/skills/creator-analysis/references/api-contracts/douyin-xingtu-v2-api.md +0 -1540
- package/skills/creator-analysis/references/api-contracts/health-check.md +0 -69
- package/skills/creator-analysis/references/api-contracts/hybrid-parsing.md +0 -78
- package/skills/creator-analysis/references/api-contracts/instagram-v1-api.md +0 -2256
- package/skills/creator-analysis/references/api-contracts/instagram-v2-api.md +0 -2011
- package/skills/creator-analysis/references/api-contracts/instagram-v3-api.md +0 -2630
- package/skills/creator-analysis/references/api-contracts/ios-shortcut.md +0 -44
- package/skills/creator-analysis/references/api-contracts/kuaishou-app-api.md +0 -1518
- package/skills/creator-analysis/references/api-contracts/kuaishou-web-api.md +0 -1242
- package/skills/creator-analysis/references/api-contracts/lemon8-app-api.md +0 -1088
- package/skills/creator-analysis/references/api-contracts/linkedin-web-api.md +0 -1949
- package/skills/creator-analysis/references/api-contracts/media-ingest-api.md +0 -126
- package/skills/creator-analysis/references/api-contracts/pipixia-app-api.md +0 -1142
- package/skills/creator-analysis/references/api-contracts/reddit-app-api.md +0 -2025
- package/skills/creator-analysis/references/api-contracts/sora2-api.md +0 -2266
- package/skills/creator-analysis/references/api-contracts/temp-mail-api.md +0 -208
- package/skills/creator-analysis/references/api-contracts/threads-web-api.md +0 -897
- package/skills/creator-analysis/references/api-contracts/tikhub-downloader-api.md +0 -134
- package/skills/creator-analysis/references/api-contracts/tikhub-user-api.md +0 -494
- package/skills/creator-analysis/references/api-contracts/tiktok-ads-api.md +0 -5947
- package/skills/creator-analysis/references/api-contracts/tiktok-analytics-api.md +0 -968
- package/skills/creator-analysis/references/api-contracts/tiktok-app-v3-api.md +0 -5735
- package/skills/creator-analysis/references/api-contracts/tiktok-creator-api.md +0 -1951
- package/skills/creator-analysis/references/api-contracts/tiktok-interaction-api.md +0 -742
- package/skills/creator-analysis/references/api-contracts/tiktok-shop-web-api.md +0 -1890
- package/skills/creator-analysis/references/api-contracts/tiktok-web-api.md +0 -4448
- package/skills/creator-analysis/references/api-contracts/toutiao-app-api.md +0 -342
- package/skills/creator-analysis/references/api-contracts/toutiao-web-api.md +0 -143
- package/skills/creator-analysis/references/api-contracts/twitter-web-api.md +0 -989
- package/skills/creator-analysis/references/api-contracts/wechat-channels-api.md +0 -809
- package/skills/creator-analysis/references/api-contracts/wechat-media-platform-web-api.md +0 -677
- package/skills/creator-analysis/references/api-contracts/weibo-app-api.md +0 -1547
- package/skills/creator-analysis/references/api-contracts/weibo-web-api.md +0 -798
- package/skills/creator-analysis/references/api-contracts/weibo-web-v2-api.md +0 -2459
- package/skills/creator-analysis/references/api-contracts/xiaohongshu-app-api.md +0 -1291
- package/skills/creator-analysis/references/api-contracts/xiaohongshu-app-v2-api.md +0 -1683
- package/skills/creator-analysis/references/api-contracts/xiaohongshu-web-api.md +0 -1324
- package/skills/creator-analysis/references/api-contracts/xiaohongshu-web-v2-api.md +0 -1209
- package/skills/creator-analysis/references/api-contracts/xigua-app-v2-api.md +0 -489
- package/skills/creator-analysis/references/api-contracts/youtube-web-api.md +0 -2636
- package/skills/creator-analysis/references/api-contracts/youtube-web-v2-api.md +0 -2660
- package/skills/creator-analysis/references/api-contracts/zhihu-web-api.md +0 -2315
- package/skills/creator-analysis/references/api-tags/asr-api.md +0 -100
- package/skills/creator-analysis/references/api-tags/bilibili-app-api.md +0 -482
- package/skills/creator-analysis/references/api-tags/bilibili-web-api.md +0 -1267
- package/skills/creator-analysis/references/api-tags/demo-api.md +0 -365
- package/skills/creator-analysis/references/api-tags/douyin-app-v3-api.md +0 -2012
- package/skills/creator-analysis/references/api-tags/douyin-billboard-api.md +0 -1428
- package/skills/creator-analysis/references/api-tags/douyin-creator-api.md +0 -694
- package/skills/creator-analysis/references/api-tags/douyin-creator-v2-api.md +0 -694
- package/skills/creator-analysis/references/api-tags/douyin-search-api.md +0 -1059
- package/skills/creator-analysis/references/api-tags/douyin-web-api.md +0 -3314
- package/skills/creator-analysis/references/api-tags/douyin-xingtu-api.md +0 -935
- package/skills/creator-analysis/references/api-tags/douyin-xingtu-v2-api.md +0 -925
- package/skills/creator-analysis/references/api-tags/health-check.md +0 -40
- package/skills/creator-analysis/references/api-tags/hybrid-parsing.md +0 -57
- package/skills/creator-analysis/references/api-tags/instagram-v1-api.md +0 -1224
- package/skills/creator-analysis/references/api-tags/instagram-v2-api.md +0 -1147
- package/skills/creator-analysis/references/api-tags/instagram-v3-api.md +0 -1123
- package/skills/creator-analysis/references/api-tags/ios-shortcut.md +0 -45
- package/skills/creator-analysis/references/api-tags/kuaishou-app-api.md +0 -846
- package/skills/creator-analysis/references/api-tags/kuaishou-web-api.md +0 -551
- package/skills/creator-analysis/references/api-tags/lemon8-app-api.md +0 -687
- package/skills/creator-analysis/references/api-tags/linkedin-web-api.md +0 -1105
- package/skills/creator-analysis/references/api-tags/media-ingest-api.md +0 -112
- package/skills/creator-analysis/references/api-tags/pipixia-app-api.md +0 -721
- package/skills/creator-analysis/references/api-tags/reddit-app-api.md +0 -1057
- package/skills/creator-analysis/references/api-tags/sora2-api.md +0 -737
- package/skills/creator-analysis/references/api-tags/temp-mail-api.md +0 -136
- package/skills/creator-analysis/references/api-tags/threads-web-api.md +0 -472
- package/skills/creator-analysis/references/api-tags/tikhub-downloader-api.md +0 -65
- package/skills/creator-analysis/references/api-tags/tikhub-user-api.md +0 -253
- package/skills/creator-analysis/references/api-tags/tiktok-ads-api.md +0 -1393
- package/skills/creator-analysis/references/api-tags/tiktok-analytics-api.md +0 -179
- package/skills/creator-analysis/references/api-tags/tiktok-app-v3-api.md +0 -3264
- package/skills/creator-analysis/references/api-tags/tiktok-creator-api.md +0 -709
- package/skills/creator-analysis/references/api-tags/tiktok-interaction-api.md +0 -366
- package/skills/creator-analysis/references/api-tags/tiktok-shop-web-api.md +0 -663
- package/skills/creator-analysis/references/api-tags/tiktok-web-api.md +0 -2516
- package/skills/creator-analysis/references/api-tags/toutiao-app-api.md +0 -220
- package/skills/creator-analysis/references/api-tags/toutiao-web-api.md +0 -96
- package/skills/creator-analysis/references/api-tags/twitter-web-api.md +0 -562
- package/skills/creator-analysis/references/api-tags/wechat-channels-api.md +0 -405
- package/skills/creator-analysis/references/api-tags/wechat-media-platform-web-api.md +0 -431
- package/skills/creator-analysis/references/api-tags/weibo-app-api.md +0 -851
- package/skills/creator-analysis/references/api-tags/weibo-web-api.md +0 -470
- package/skills/creator-analysis/references/api-tags/weibo-web-v2-api.md +0 -1405
- package/skills/creator-analysis/references/api-tags/xiaohongshu-app-api.md +0 -534
- package/skills/creator-analysis/references/api-tags/xiaohongshu-app-v2-api.md +0 -934
- package/skills/creator-analysis/references/api-tags/xiaohongshu-web-api.md +0 -757
- package/skills/creator-analysis/references/api-tags/xiaohongshu-web-v2-api.md +0 -762
- package/skills/creator-analysis/references/api-tags/xigua-app-v2-api.md +0 -308
- package/skills/creator-analysis/references/api-tags/youtube-web-api.md +0 -934
- package/skills/creator-analysis/references/api-tags/youtube-web-v2-api.md +0 -717
- package/skills/creator-analysis/references/api-tags/zhihu-web-api.md +0 -1384
- package/skills/creator-analysis/references/asr-orchestration.md +0 -33
- package/skills/creator-analysis/references/config-templates/defaults.yaml +0 -60
- package/skills/creator-analysis/references/contracts/creator-card-fields.md +0 -25
- package/skills/creator-analysis/references/contracts/work-card-fields.md +0 -68
- package/skills/creator-analysis/references/platform-guides/douyin.md +0 -54
- package/skills/creator-analysis/references/platform-guides/generic.md +0 -50
- package/skills/creator-analysis/references/platform-guides/xiaohongshu.md +0 -69
- package/skills/creator-analysis/references/prompt-contracts/asr-clean.md +0 -28
- package/skills/creator-analysis/references/prompt-contracts/author-analysis-v2.md +0 -46
- package/skills/creator-analysis/references/prompt-contracts/author-analysis.md +0 -49
- package/skills/creator-analysis/references/prompt-contracts/cta.md +0 -24
- package/skills/creator-analysis/references/prompt-contracts/hook.md +0 -25
- package/skills/creator-analysis/references/prompt-contracts/insight.md +0 -47
- package/skills/creator-analysis/references/prompt-contracts/sampled-work-batch-explanations.md +0 -30
- package/skills/creator-analysis/references/prompt-contracts/structure.md +0 -25
- package/skills/creator-analysis/references/prompt-contracts/style.md +0 -27
- package/skills/creator-analysis/references/prompt-contracts/summary.md +0 -29
- package/skills/creator-analysis/references/prompt-contracts/topic.md +0 -29
- package/skills/creator-analysis/references/schemas/author-analysis-input-v1.schema.json +0 -325
- package/skills/creator-analysis/references/schemas/author-analysis-v2.schema.json +0 -287
- package/skills/creator-analysis/references/schemas/sampled-work-batch-explanations.schema.json +0 -41
- package/skills/creator-analysis/references/service-guides/asr-u2-u3-fallback.md +0 -75
- package/skills/creator-analysis/references/workflow.md +0 -23
- 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/analyzers/__init__.py +0 -0
- package/skills/creator-analysis/scripts/author_home/analyzers/author_analysis_v2_support.py +0 -1165
- package/skills/creator-analysis/scripts/author_home/analyzers/prompt_first_analyzers.py +0 -447
- package/skills/creator-analysis/scripts/author_home/analyzers/sampled_work_batch_explainer.py +0 -331
- package/skills/creator-analysis/scripts/author_home/asr/__init__.py +0 -5
- package/skills/creator-analysis/scripts/author_home/builders/__init__.py +0 -0
- package/skills/creator-analysis/scripts/author_home/builders/home_builders.py +0 -213
- package/skills/creator-analysis/scripts/author_home/collectors/__init__.py +0 -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 +0 -834
- package/skills/creator-analysis/scripts/author_home/orchestrator/work_analysis_artifacts.py +0 -609
- package/skills/creator-analysis/scripts/core/__init__.py +0 -0
- package/skills/creator-analysis/scripts/core/analysis_pipeline.py +0 -133
- package/skills/creator-analysis/scripts/core/config_loader.py +0 -418
- package/skills/creator-analysis/scripts/core/progress_report.py +0 -111
- package/skills/creator-analysis/scripts/core/storage_router.py +0 -256
- 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/platform/__init__.py +0 -0
- package/skills/creator-analysis/scripts/platform/douyin/__init__.py +0 -0
- package/skills/creator-analysis/scripts/platform/douyin/run_douyin_single_video.py +0 -1208
- package/skills/creator-analysis/scripts/platform/xiaohongshu/__init__.py +0 -0
- package/skills/creator-analysis/scripts/platform/xiaohongshu/run_xiaohongshu_extract.py +0 -2128
- package/skills/creator-analysis/scripts/writers/__init__.py +0 -0
- package/skills/creator-analysis/scripts/writers/write_author_homepage_samples.py +0 -107
- package/skills/creator-analysis/scripts/writers/write_benchmark_card.py +0 -1579
- package/skills/meta-capability/SKILL.md +0 -69
- package/skills/meta-capability/agents/openai.yaml +0 -4
- package/skills/meta-capability/env.example +0 -42
- package/skills/meta-capability/references/api-capability-index.md +0 -92
- package/skills/meta-capability/references/api-contracts/asr-api.md +0 -130
- package/skills/meta-capability/references/api-contracts/bilibili-app-api.md +0 -776
- package/skills/meta-capability/references/api-contracts/bilibili-web-api.md +0 -2017
- package/skills/meta-capability/references/api-contracts/demo-api.md +0 -717
- package/skills/meta-capability/references/api-contracts/douyin-app-v3-api.md +0 -3594
- package/skills/meta-capability/references/api-contracts/douyin-billboard-api.md +0 -2274
- package/skills/meta-capability/references/api-contracts/douyin-creator-api.md +0 -1575
- package/skills/meta-capability/references/api-contracts/douyin-creator-v2-api.md +0 -3254
- package/skills/meta-capability/references/api-contracts/douyin-search-api.md +0 -4118
- package/skills/meta-capability/references/api-contracts/douyin-web-api.md +0 -5544
- package/skills/meta-capability/references/api-contracts/douyin-xingtu-api.md +0 -1916
- package/skills/meta-capability/references/api-contracts/douyin-xingtu-v2-api.md +0 -1540
- package/skills/meta-capability/references/api-contracts/health-check.md +0 -69
- package/skills/meta-capability/references/api-contracts/hybrid-parsing.md +0 -78
- package/skills/meta-capability/references/api-contracts/instagram-v1-api.md +0 -2256
- package/skills/meta-capability/references/api-contracts/instagram-v2-api.md +0 -2011
- package/skills/meta-capability/references/api-contracts/instagram-v3-api.md +0 -2630
- package/skills/meta-capability/references/api-contracts/ios-shortcut.md +0 -44
- package/skills/meta-capability/references/api-contracts/kuaishou-app-api.md +0 -1518
- package/skills/meta-capability/references/api-contracts/kuaishou-web-api.md +0 -1242
- package/skills/meta-capability/references/api-contracts/lemon8-app-api.md +0 -1088
- package/skills/meta-capability/references/api-contracts/linkedin-web-api.md +0 -1949
- package/skills/meta-capability/references/api-contracts/media-ingest-api.md +0 -126
- package/skills/meta-capability/references/api-contracts/pipixia-app-api.md +0 -1142
- package/skills/meta-capability/references/api-contracts/reddit-app-api.md +0 -2025
- package/skills/meta-capability/references/api-contracts/sora2-api.md +0 -2266
- package/skills/meta-capability/references/api-contracts/temp-mail-api.md +0 -208
- package/skills/meta-capability/references/api-contracts/threads-web-api.md +0 -897
- package/skills/meta-capability/references/api-contracts/tikhub-downloader-api.md +0 -134
- package/skills/meta-capability/references/api-contracts/tikhub-user-api.md +0 -494
- package/skills/meta-capability/references/api-contracts/tiktok-ads-api.md +0 -5947
- package/skills/meta-capability/references/api-contracts/tiktok-analytics-api.md +0 -968
- package/skills/meta-capability/references/api-contracts/tiktok-app-v3-api.md +0 -5735
- package/skills/meta-capability/references/api-contracts/tiktok-creator-api.md +0 -1951
- package/skills/meta-capability/references/api-contracts/tiktok-interaction-api.md +0 -742
- package/skills/meta-capability/references/api-contracts/tiktok-shop-web-api.md +0 -1890
- package/skills/meta-capability/references/api-contracts/tiktok-web-api.md +0 -4448
- package/skills/meta-capability/references/api-contracts/toutiao-app-api.md +0 -342
- package/skills/meta-capability/references/api-contracts/toutiao-web-api.md +0 -143
- package/skills/meta-capability/references/api-contracts/twitter-web-api.md +0 -989
- package/skills/meta-capability/references/api-contracts/wechat-channels-api.md +0 -809
- package/skills/meta-capability/references/api-contracts/wechat-media-platform-web-api.md +0 -677
- package/skills/meta-capability/references/api-contracts/weibo-app-api.md +0 -1547
- package/skills/meta-capability/references/api-contracts/weibo-web-api.md +0 -798
- package/skills/meta-capability/references/api-contracts/weibo-web-v2-api.md +0 -2459
- package/skills/meta-capability/references/api-contracts/xiaohongshu-app-api.md +0 -1291
- package/skills/meta-capability/references/api-contracts/xiaohongshu-app-v2-api.md +0 -1683
- package/skills/meta-capability/references/api-contracts/xiaohongshu-web-api.md +0 -1324
- package/skills/meta-capability/references/api-contracts/xiaohongshu-web-v2-api.md +0 -1209
- package/skills/meta-capability/references/api-contracts/xigua-app-v2-api.md +0 -489
- package/skills/meta-capability/references/api-contracts/youtube-web-api.md +0 -2636
- package/skills/meta-capability/references/api-contracts/youtube-web-v2-api.md +0 -2660
- package/skills/meta-capability/references/api-contracts/zhihu-web-api.md +0 -2315
- package/skills/meta-capability/references/api-tags/asr-api.md +0 -100
- package/skills/meta-capability/references/api-tags/bilibili-app-api.md +0 -482
- package/skills/meta-capability/references/api-tags/bilibili-web-api.md +0 -1267
- package/skills/meta-capability/references/api-tags/demo-api.md +0 -365
- package/skills/meta-capability/references/api-tags/douyin-app-v3-api.md +0 -2012
- package/skills/meta-capability/references/api-tags/douyin-billboard-api.md +0 -1428
- package/skills/meta-capability/references/api-tags/douyin-creator-api.md +0 -694
- package/skills/meta-capability/references/api-tags/douyin-creator-v2-api.md +0 -694
- package/skills/meta-capability/references/api-tags/douyin-search-api.md +0 -1059
- package/skills/meta-capability/references/api-tags/douyin-web-api.md +0 -3314
- package/skills/meta-capability/references/api-tags/douyin-xingtu-api.md +0 -935
- package/skills/meta-capability/references/api-tags/douyin-xingtu-v2-api.md +0 -925
- package/skills/meta-capability/references/api-tags/health-check.md +0 -40
- package/skills/meta-capability/references/api-tags/hybrid-parsing.md +0 -57
- package/skills/meta-capability/references/api-tags/instagram-v1-api.md +0 -1224
- package/skills/meta-capability/references/api-tags/instagram-v2-api.md +0 -1147
- package/skills/meta-capability/references/api-tags/instagram-v3-api.md +0 -1123
- package/skills/meta-capability/references/api-tags/ios-shortcut.md +0 -45
- package/skills/meta-capability/references/api-tags/kuaishou-app-api.md +0 -846
- package/skills/meta-capability/references/api-tags/kuaishou-web-api.md +0 -551
- package/skills/meta-capability/references/api-tags/lemon8-app-api.md +0 -687
- package/skills/meta-capability/references/api-tags/linkedin-web-api.md +0 -1105
- package/skills/meta-capability/references/api-tags/media-ingest-api.md +0 -112
- package/skills/meta-capability/references/api-tags/pipixia-app-api.md +0 -721
- package/skills/meta-capability/references/api-tags/reddit-app-api.md +0 -1057
- package/skills/meta-capability/references/api-tags/sora2-api.md +0 -737
- package/skills/meta-capability/references/api-tags/temp-mail-api.md +0 -136
- package/skills/meta-capability/references/api-tags/threads-web-api.md +0 -472
- package/skills/meta-capability/references/api-tags/tikhub-downloader-api.md +0 -65
- package/skills/meta-capability/references/api-tags/tikhub-user-api.md +0 -253
- package/skills/meta-capability/references/api-tags/tiktok-ads-api.md +0 -1393
- package/skills/meta-capability/references/api-tags/tiktok-analytics-api.md +0 -179
- package/skills/meta-capability/references/api-tags/tiktok-app-v3-api.md +0 -3264
- package/skills/meta-capability/references/api-tags/tiktok-creator-api.md +0 -709
- package/skills/meta-capability/references/api-tags/tiktok-interaction-api.md +0 -366
- package/skills/meta-capability/references/api-tags/tiktok-shop-web-api.md +0 -663
- package/skills/meta-capability/references/api-tags/tiktok-web-api.md +0 -2516
- package/skills/meta-capability/references/api-tags/toutiao-app-api.md +0 -220
- package/skills/meta-capability/references/api-tags/toutiao-web-api.md +0 -96
- package/skills/meta-capability/references/api-tags/twitter-web-api.md +0 -562
- package/skills/meta-capability/references/api-tags/wechat-channels-api.md +0 -405
- package/skills/meta-capability/references/api-tags/wechat-media-platform-web-api.md +0 -431
- package/skills/meta-capability/references/api-tags/weibo-app-api.md +0 -851
- package/skills/meta-capability/references/api-tags/weibo-web-api.md +0 -470
- package/skills/meta-capability/references/api-tags/weibo-web-v2-api.md +0 -1405
- package/skills/meta-capability/references/api-tags/xiaohongshu-app-api.md +0 -534
- package/skills/meta-capability/references/api-tags/xiaohongshu-app-v2-api.md +0 -934
- package/skills/meta-capability/references/api-tags/xiaohongshu-web-api.md +0 -757
- package/skills/meta-capability/references/api-tags/xiaohongshu-web-v2-api.md +0 -762
- package/skills/meta-capability/references/api-tags/xigua-app-v2-api.md +0 -308
- package/skills/meta-capability/references/api-tags/youtube-web-api.md +0 -934
- package/skills/meta-capability/references/api-tags/youtube-web-v2-api.md +0 -717
- package/skills/meta-capability/references/api-tags/zhihu-web-api.md +0 -1384
- package/skills/meta-capability/references/config-templates/defaults.yaml +0 -18
- package/skills/meta-capability/references/dispatch.md +0 -27
- package/skills/meta-capability/references/execution-guidelines.md +0 -25
- package/skills/meta-capability/references/implemented-route-map.md +0 -177
- package/skills/meta-capability/references/service-guides/asr-u2-u3-fallback.md +0 -75
- package/skills/meta-capability/scripts/__init__.py +0 -1
- package/skills/meta-capability/scripts/call_route.py +0 -141
- package/skills/meta-capability/scripts/core/__init__.py +0 -1
- package/skills/meta-capability/scripts/core/bootstrap_env.py +0 -32
- package/skills/meta-capability/scripts/core/config_loader.py +0 -204
- package/skills/meta-capability/scripts/core/tikomni_common.py +0 -443
- package/skills/meta-capability/scripts/test_auth.py +0 -98
- package/skills/single-work-analysis/SKILL.md +0 -62
- package/skills/single-work-analysis/agents/openai.yaml +0 -4
- package/skills/single-work-analysis/env.example +0 -36
- package/skills/single-work-analysis/references/api-capability-index.md +0 -92
- package/skills/single-work-analysis/references/api-contracts/asr-api.md +0 -130
- package/skills/single-work-analysis/references/api-contracts/bilibili-app-api.md +0 -776
- package/skills/single-work-analysis/references/api-contracts/bilibili-web-api.md +0 -2017
- package/skills/single-work-analysis/references/api-contracts/demo-api.md +0 -717
- package/skills/single-work-analysis/references/api-contracts/douyin-app-v3-api.md +0 -3594
- package/skills/single-work-analysis/references/api-contracts/douyin-billboard-api.md +0 -2274
- package/skills/single-work-analysis/references/api-contracts/douyin-creator-api.md +0 -1575
- package/skills/single-work-analysis/references/api-contracts/douyin-creator-v2-api.md +0 -3254
- package/skills/single-work-analysis/references/api-contracts/douyin-search-api.md +0 -4118
- package/skills/single-work-analysis/references/api-contracts/douyin-web-api.md +0 -5544
- package/skills/single-work-analysis/references/api-contracts/douyin-xingtu-api.md +0 -1916
- package/skills/single-work-analysis/references/api-contracts/douyin-xingtu-v2-api.md +0 -1540
- package/skills/single-work-analysis/references/api-contracts/health-check.md +0 -69
- package/skills/single-work-analysis/references/api-contracts/hybrid-parsing.md +0 -78
- package/skills/single-work-analysis/references/api-contracts/instagram-v1-api.md +0 -2256
- package/skills/single-work-analysis/references/api-contracts/instagram-v2-api.md +0 -2011
- package/skills/single-work-analysis/references/api-contracts/instagram-v3-api.md +0 -2630
- package/skills/single-work-analysis/references/api-contracts/ios-shortcut.md +0 -44
- package/skills/single-work-analysis/references/api-contracts/kuaishou-app-api.md +0 -1518
- package/skills/single-work-analysis/references/api-contracts/kuaishou-web-api.md +0 -1242
- package/skills/single-work-analysis/references/api-contracts/lemon8-app-api.md +0 -1088
- package/skills/single-work-analysis/references/api-contracts/linkedin-web-api.md +0 -1949
- package/skills/single-work-analysis/references/api-contracts/media-ingest-api.md +0 -126
- package/skills/single-work-analysis/references/api-contracts/pipixia-app-api.md +0 -1142
- package/skills/single-work-analysis/references/api-contracts/reddit-app-api.md +0 -2025
- package/skills/single-work-analysis/references/api-contracts/sora2-api.md +0 -2266
- package/skills/single-work-analysis/references/api-contracts/temp-mail-api.md +0 -208
- package/skills/single-work-analysis/references/api-contracts/threads-web-api.md +0 -897
- package/skills/single-work-analysis/references/api-contracts/tikhub-downloader-api.md +0 -134
- package/skills/single-work-analysis/references/api-contracts/tikhub-user-api.md +0 -494
- package/skills/single-work-analysis/references/api-contracts/tiktok-ads-api.md +0 -5947
- package/skills/single-work-analysis/references/api-contracts/tiktok-analytics-api.md +0 -968
- package/skills/single-work-analysis/references/api-contracts/tiktok-app-v3-api.md +0 -5735
- package/skills/single-work-analysis/references/api-contracts/tiktok-creator-api.md +0 -1951
- package/skills/single-work-analysis/references/api-contracts/tiktok-interaction-api.md +0 -742
- package/skills/single-work-analysis/references/api-contracts/tiktok-shop-web-api.md +0 -1890
- package/skills/single-work-analysis/references/api-contracts/tiktok-web-api.md +0 -4448
- package/skills/single-work-analysis/references/api-contracts/toutiao-app-api.md +0 -342
- package/skills/single-work-analysis/references/api-contracts/toutiao-web-api.md +0 -143
- package/skills/single-work-analysis/references/api-contracts/twitter-web-api.md +0 -989
- package/skills/single-work-analysis/references/api-contracts/wechat-channels-api.md +0 -809
- package/skills/single-work-analysis/references/api-contracts/wechat-media-platform-web-api.md +0 -677
- package/skills/single-work-analysis/references/api-contracts/weibo-app-api.md +0 -1547
- package/skills/single-work-analysis/references/api-contracts/weibo-web-api.md +0 -798
- package/skills/single-work-analysis/references/api-contracts/weibo-web-v2-api.md +0 -2459
- package/skills/single-work-analysis/references/api-contracts/xiaohongshu-app-api.md +0 -1291
- package/skills/single-work-analysis/references/api-contracts/xiaohongshu-app-v2-api.md +0 -1683
- package/skills/single-work-analysis/references/api-contracts/xiaohongshu-web-api.md +0 -1324
- package/skills/single-work-analysis/references/api-contracts/xiaohongshu-web-v2-api.md +0 -1209
- package/skills/single-work-analysis/references/api-contracts/xigua-app-v2-api.md +0 -489
- package/skills/single-work-analysis/references/api-contracts/youtube-web-api.md +0 -2636
- package/skills/single-work-analysis/references/api-contracts/youtube-web-v2-api.md +0 -2660
- package/skills/single-work-analysis/references/api-contracts/zhihu-web-api.md +0 -2315
- package/skills/single-work-analysis/references/api-tags/asr-api.md +0 -100
- package/skills/single-work-analysis/references/api-tags/bilibili-app-api.md +0 -482
- package/skills/single-work-analysis/references/api-tags/bilibili-web-api.md +0 -1267
- package/skills/single-work-analysis/references/api-tags/demo-api.md +0 -365
- package/skills/single-work-analysis/references/api-tags/douyin-app-v3-api.md +0 -2012
- package/skills/single-work-analysis/references/api-tags/douyin-billboard-api.md +0 -1428
- package/skills/single-work-analysis/references/api-tags/douyin-creator-api.md +0 -694
- package/skills/single-work-analysis/references/api-tags/douyin-creator-v2-api.md +0 -694
- package/skills/single-work-analysis/references/api-tags/douyin-search-api.md +0 -1059
- package/skills/single-work-analysis/references/api-tags/douyin-web-api.md +0 -3314
- package/skills/single-work-analysis/references/api-tags/douyin-xingtu-api.md +0 -935
- package/skills/single-work-analysis/references/api-tags/douyin-xingtu-v2-api.md +0 -925
- package/skills/single-work-analysis/references/api-tags/health-check.md +0 -40
- package/skills/single-work-analysis/references/api-tags/hybrid-parsing.md +0 -57
- package/skills/single-work-analysis/references/api-tags/instagram-v1-api.md +0 -1224
- package/skills/single-work-analysis/references/api-tags/instagram-v2-api.md +0 -1147
- package/skills/single-work-analysis/references/api-tags/instagram-v3-api.md +0 -1123
- package/skills/single-work-analysis/references/api-tags/ios-shortcut.md +0 -45
- package/skills/single-work-analysis/references/api-tags/kuaishou-app-api.md +0 -846
- package/skills/single-work-analysis/references/api-tags/kuaishou-web-api.md +0 -551
- package/skills/single-work-analysis/references/api-tags/lemon8-app-api.md +0 -687
- package/skills/single-work-analysis/references/api-tags/linkedin-web-api.md +0 -1105
- package/skills/single-work-analysis/references/api-tags/media-ingest-api.md +0 -112
- package/skills/single-work-analysis/references/api-tags/pipixia-app-api.md +0 -721
- package/skills/single-work-analysis/references/api-tags/reddit-app-api.md +0 -1057
- package/skills/single-work-analysis/references/api-tags/sora2-api.md +0 -737
- package/skills/single-work-analysis/references/api-tags/temp-mail-api.md +0 -136
- package/skills/single-work-analysis/references/api-tags/threads-web-api.md +0 -472
- package/skills/single-work-analysis/references/api-tags/tikhub-downloader-api.md +0 -65
- package/skills/single-work-analysis/references/api-tags/tikhub-user-api.md +0 -253
- package/skills/single-work-analysis/references/api-tags/tiktok-ads-api.md +0 -1393
- package/skills/single-work-analysis/references/api-tags/tiktok-analytics-api.md +0 -179
- package/skills/single-work-analysis/references/api-tags/tiktok-app-v3-api.md +0 -3264
- package/skills/single-work-analysis/references/api-tags/tiktok-creator-api.md +0 -709
- package/skills/single-work-analysis/references/api-tags/tiktok-interaction-api.md +0 -366
- package/skills/single-work-analysis/references/api-tags/tiktok-shop-web-api.md +0 -663
- package/skills/single-work-analysis/references/api-tags/tiktok-web-api.md +0 -2516
- package/skills/single-work-analysis/references/api-tags/toutiao-app-api.md +0 -220
- package/skills/single-work-analysis/references/api-tags/toutiao-web-api.md +0 -96
- package/skills/single-work-analysis/references/api-tags/twitter-web-api.md +0 -562
- package/skills/single-work-analysis/references/api-tags/wechat-channels-api.md +0 -405
- package/skills/single-work-analysis/references/api-tags/wechat-media-platform-web-api.md +0 -431
- package/skills/single-work-analysis/references/api-tags/weibo-app-api.md +0 -851
- package/skills/single-work-analysis/references/api-tags/weibo-web-api.md +0 -470
- package/skills/single-work-analysis/references/api-tags/weibo-web-v2-api.md +0 -1405
- package/skills/single-work-analysis/references/api-tags/xiaohongshu-app-api.md +0 -534
- package/skills/single-work-analysis/references/api-tags/xiaohongshu-app-v2-api.md +0 -934
- package/skills/single-work-analysis/references/api-tags/xiaohongshu-web-api.md +0 -757
- package/skills/single-work-analysis/references/api-tags/xiaohongshu-web-v2-api.md +0 -762
- package/skills/single-work-analysis/references/api-tags/xigua-app-v2-api.md +0 -308
- package/skills/single-work-analysis/references/api-tags/youtube-web-api.md +0 -934
- package/skills/single-work-analysis/references/api-tags/youtube-web-v2-api.md +0 -717
- package/skills/single-work-analysis/references/api-tags/zhihu-web-api.md +0 -1384
- package/skills/single-work-analysis/references/asr-and-fallback.md +0 -20
- package/skills/single-work-analysis/references/config-templates/defaults.yaml +0 -58
- package/skills/single-work-analysis/references/contracts/work-card-fields.md +0 -41
- package/skills/single-work-analysis/references/platform-guides/douyin.md +0 -47
- package/skills/single-work-analysis/references/platform-guides/generic.md +0 -43
- package/skills/single-work-analysis/references/platform-guides/xiaohongshu.md +0 -54
- package/skills/single-work-analysis/references/prompt-contracts/asr-clean.md +0 -28
- package/skills/single-work-analysis/references/prompt-contracts/cta.md +0 -24
- package/skills/single-work-analysis/references/prompt-contracts/hook.md +0 -25
- package/skills/single-work-analysis/references/prompt-contracts/insight.md +0 -47
- package/skills/single-work-analysis/references/prompt-contracts/structure.md +0 -25
- package/skills/single-work-analysis/references/prompt-contracts/style.md +0 -27
- package/skills/single-work-analysis/references/prompt-contracts/summary.md +0 -29
- package/skills/single-work-analysis/references/prompt-contracts/topic.md +0 -29
- package/skills/single-work-analysis/references/schemas/work-card.schema.json +0 -39
- package/skills/single-work-analysis/references/service-guides/asr-u2-u3-fallback.md +0 -75
- 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 +0 -133
- package/skills/single-work-analysis/scripts/core/bootstrap_env.py +0 -35
- package/skills/single-work-analysis/scripts/core/extract_pipeline.py +0 -173
- package/skills/single-work-analysis/scripts/core/storage_router.py +0 -253
- package/skills/single-work-analysis/scripts/core/tikomni_common.py +0 -588
- 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 +0 -1189
- package/skills/single-work-analysis/scripts/pipeline/asr/poll_u2_task.py +0 -95
- 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 +0 -224
- package/skills/single-work-analysis/scripts/platform/douyin/select_low_quality_video_url.py +0 -200
- package/skills/single-work-analysis/scripts/platform/xiaohongshu/__init__.py +0 -0
- package/skills/single-work-analysis/scripts/writers/__init__.py +0 -0
- package/skills/single-work-analysis/scripts/writers/write_benchmark_card.py +0 -1402
- /package/skills/{creator-analysis → social-media-crawl}/scripts/core/bootstrap_env.py +0 -0
- /package/skills/{creator-analysis → social-media-crawl}/scripts/core/extract_pipeline.py +0 -0
- /package/skills/{creator-analysis/scripts/platform/douyin → social-media-crawl/scripts/pipelines}/douyin_video_type_matrix.py +0 -0
- /package/skills/{creator-analysis/scripts/author_home/collectors → social-media-crawl/scripts/pipelines}/homepage_collectors.py +0 -0
- /package/skills/{creator-analysis/scripts/platform/douyin → social-media-crawl/scripts/pipelines}/select_low_quality_video_url.py +0 -0
|
@@ -1,834 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
if __package__ in {None, ""}:
|
|
4
|
-
import sys
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
|
|
7
|
-
_self = Path(__file__).resolve()
|
|
8
|
-
for _parent in _self.parents:
|
|
9
|
-
if (_parent / "scripts" / "core" / "bootstrap_env.py").is_file():
|
|
10
|
-
sys.path.insert(0, str(_parent))
|
|
11
|
-
break
|
|
12
|
-
|
|
13
|
-
"""Componentized author-home orchestrator."""
|
|
14
|
-
|
|
15
|
-
import hashlib
|
|
16
|
-
import json
|
|
17
|
-
from datetime import datetime
|
|
18
|
-
from pathlib import Path
|
|
19
|
-
from typing import Any, Callable, Dict, List, Optional
|
|
20
|
-
|
|
21
|
-
from scripts.core.config_loader import resolve_storage_paths
|
|
22
|
-
from scripts.core.storage_router import render_output_filename, resolve_json_filename_pattern
|
|
23
|
-
|
|
24
|
-
from scripts.author_home.adapters.platform_adapters import adapt_douyin_author_home, adapt_xhs_author_home
|
|
25
|
-
from scripts.author_home.analyzers.author_analysis_v2_support import prepare_author_analysis_bundle
|
|
26
|
-
from scripts.author_home.orchestrator.work_analysis_artifacts import orchestrate_work_analysis_artifacts
|
|
27
|
-
from scripts.core.progress_report import ProgressReporter
|
|
28
|
-
from scripts.author_home.analyzers.prompt_first_analyzers import run_prompt_first_author_analysis
|
|
29
|
-
from scripts.author_home.asr.home_asr import enrich_author_home_asr
|
|
30
|
-
from scripts.author_home.builders.home_builders import build_author_card, build_work_cards
|
|
31
|
-
from scripts.author_home.collectors.homepage_collectors import collect_douyin_author_home_raw, collect_xhs_author_home_raw
|
|
32
|
-
|
|
33
|
-
CollectorFn = Callable[..., Dict[str, Any]]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def _stage_status(*, status: str, ok_count: int, failed_count: int, degraded_count: int, reason_codes: List[str], failure_kind: str = "") -> Dict[str, Any]:
|
|
37
|
-
return {
|
|
38
|
-
"status": status,
|
|
39
|
-
"ok_count": ok_count,
|
|
40
|
-
"failed_count": failed_count,
|
|
41
|
-
"degraded_count": degraded_count,
|
|
42
|
-
"reason_codes": list(dict.fromkeys([code for code in reason_codes if code])),
|
|
43
|
-
"failure_kind": failure_kind or None,
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def _reason_codes_from_failed_items(items: List[Dict[str, Any]]) -> List[str]:
|
|
48
|
-
reason_codes: List[str] = []
|
|
49
|
-
for item in items:
|
|
50
|
-
if not isinstance(item, dict):
|
|
51
|
-
continue
|
|
52
|
-
reason = str(item.get("error_reason") or "").strip()
|
|
53
|
-
if not reason:
|
|
54
|
-
continue
|
|
55
|
-
reason_codes.append(reason.split(":", 1)[0])
|
|
56
|
-
return list(dict.fromkeys(reason_codes))
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def _merge_normalized_works(*, works: List[Dict[str, Any]], normalized_works: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
|
60
|
-
normalized_map = {
|
|
61
|
-
str(item.get("platform_work_id") or "").strip(): item
|
|
62
|
-
for item in normalized_works
|
|
63
|
-
if isinstance(item, dict) and str(item.get("platform_work_id") or "").strip()
|
|
64
|
-
}
|
|
65
|
-
merged: List[Dict[str, Any]] = []
|
|
66
|
-
for work in works:
|
|
67
|
-
if not isinstance(work, dict):
|
|
68
|
-
continue
|
|
69
|
-
platform_work_id = str(work.get("platform_work_id") or "").strip()
|
|
70
|
-
normalized = normalized_map.get(platform_work_id)
|
|
71
|
-
if not isinstance(normalized, dict):
|
|
72
|
-
merged.append(work)
|
|
73
|
-
continue
|
|
74
|
-
merged_work = dict(work)
|
|
75
|
-
for field in (
|
|
76
|
-
"primary_text",
|
|
77
|
-
"primary_text_source",
|
|
78
|
-
"digg_count",
|
|
79
|
-
"comment_count",
|
|
80
|
-
"collect_count",
|
|
81
|
-
"share_count",
|
|
82
|
-
"play_count",
|
|
83
|
-
"performance_score",
|
|
84
|
-
"performance_score_norm",
|
|
85
|
-
"bucket",
|
|
86
|
-
"hook_type",
|
|
87
|
-
"structure_type",
|
|
88
|
-
"cta_type",
|
|
89
|
-
"content_form",
|
|
90
|
-
"style_markers",
|
|
91
|
-
"analysis_eligibility",
|
|
92
|
-
"analysis_exclusion_reason",
|
|
93
|
-
"published_date",
|
|
94
|
-
"publish_time",
|
|
95
|
-
):
|
|
96
|
-
if field in normalized:
|
|
97
|
-
merged_work[field] = normalized.get(field)
|
|
98
|
-
merged.append(merged_work)
|
|
99
|
-
return merged
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def _build_card_stage_status(*, expected_count: int, results: Dict[str, Any], failure_kind: str = "runtime") -> Dict[str, Any]:
|
|
103
|
-
if not isinstance(results, dict) or not results.get("enabled", True):
|
|
104
|
-
return _stage_status(status="skipped", ok_count=0, failed_count=0, degraded_count=0, reason_codes=["write_card_disabled"])
|
|
105
|
-
ok_count = int(results.get("count") or len(results.get("results") or []))
|
|
106
|
-
failed_items = results.get("failed_items") if isinstance(results.get("failed_items"), list) else []
|
|
107
|
-
degraded_count = len(failed_items) if ok_count > 0 else 0
|
|
108
|
-
failed_count = len(failed_items) if ok_count == 0 and expected_count > 0 else 0
|
|
109
|
-
if failed_count > 0:
|
|
110
|
-
return _stage_status(
|
|
111
|
-
status="failed",
|
|
112
|
-
ok_count=ok_count,
|
|
113
|
-
failed_count=failed_count,
|
|
114
|
-
degraded_count=0,
|
|
115
|
-
reason_codes=_reason_codes_from_failed_items(failed_items) or ["card_write_failed"],
|
|
116
|
-
failure_kind=failure_kind,
|
|
117
|
-
)
|
|
118
|
-
if degraded_count > 0:
|
|
119
|
-
return _stage_status(
|
|
120
|
-
status="degraded",
|
|
121
|
-
ok_count=ok_count,
|
|
122
|
-
failed_count=0,
|
|
123
|
-
degraded_count=degraded_count,
|
|
124
|
-
reason_codes=_reason_codes_from_failed_items(failed_items) or ["card_write_degraded"],
|
|
125
|
-
failure_kind=failure_kind,
|
|
126
|
-
)
|
|
127
|
-
return _stage_status(status="full", ok_count=ok_count, failed_count=0, degraded_count=0, reason_codes=[])
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def _build_persist_stage_status(persist_result: Dict[str, Any]) -> Dict[str, Any]:
|
|
131
|
-
if not isinstance(persist_result, dict) or not persist_result.get("enabled", True):
|
|
132
|
-
return _stage_status(status="skipped", ok_count=0, failed_count=0, degraded_count=0, reason_codes=["persist_disabled"])
|
|
133
|
-
if persist_result.get("ok"):
|
|
134
|
-
return _stage_status(status="full", ok_count=1, failed_count=0, degraded_count=0, reason_codes=[])
|
|
135
|
-
error_reason = str(persist_result.get("error") or persist_result.get("failure_reason") or "persist_failed")
|
|
136
|
-
return _stage_status(
|
|
137
|
-
status="failed",
|
|
138
|
-
ok_count=0,
|
|
139
|
-
failed_count=1,
|
|
140
|
-
degraded_count=0,
|
|
141
|
-
reason_codes=[error_reason.split(":", 1)[0]],
|
|
142
|
-
failure_kind="configuration" if error_reason.startswith("resolve_storage_paths_failed:") else "runtime",
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def _build_overall_status(stage_status: Dict[str, Dict[str, Any]]) -> Dict[str, Any]:
|
|
147
|
-
ordered = [
|
|
148
|
-
"fetch",
|
|
149
|
-
"asr",
|
|
150
|
-
"sampled_explanations",
|
|
151
|
-
"author_analysis",
|
|
152
|
-
"author_sample_card",
|
|
153
|
-
"sample_work_card",
|
|
154
|
-
"author_card",
|
|
155
|
-
]
|
|
156
|
-
stages = [stage_status.get(key) if isinstance(stage_status.get(key), dict) else {} for key in ordered]
|
|
157
|
-
if any(stage.get("failure_kind") == "configuration" or stage.get("status") == "failed" and stage.get("failure_kind") == "configuration" for stage in stages):
|
|
158
|
-
reason_codes: List[str] = []
|
|
159
|
-
for stage in stages:
|
|
160
|
-
if stage.get("failure_kind") == "configuration":
|
|
161
|
-
reason_codes.extend(stage.get("reason_codes") or [])
|
|
162
|
-
return _stage_status(status="failed", ok_count=0, failed_count=1, degraded_count=0, reason_codes=reason_codes or ["configuration_failed"], failure_kind="configuration")
|
|
163
|
-
author_analysis = stage_status.get("author_analysis") if isinstance(stage_status.get("author_analysis"), dict) else {}
|
|
164
|
-
author_card = stage_status.get("author_card") if isinstance(stage_status.get("author_card"), dict) else {}
|
|
165
|
-
if author_analysis.get("status") == "fallback" and author_card.get("status") in {"full", "degraded", "fallback"}:
|
|
166
|
-
return _stage_status(status="fallback", ok_count=0, failed_count=0, degraded_count=0, reason_codes=author_analysis.get("reason_codes") or ["author_analysis_fallback"], failure_kind=author_analysis.get("failure_kind") or "runtime")
|
|
167
|
-
if any((stage.get("failed_count") or 0) > 0 or (stage.get("degraded_count") or 0) > 0 or stage.get("status") in {"degraded", "failed"} for stage in stages):
|
|
168
|
-
reason_codes = []
|
|
169
|
-
for stage in stages:
|
|
170
|
-
reason_codes.extend(stage.get("reason_codes") or [])
|
|
171
|
-
return _stage_status(status="degraded", ok_count=0, failed_count=0, degraded_count=1, reason_codes=reason_codes or ["stage_degraded"])
|
|
172
|
-
return _stage_status(status="full", ok_count=1, failed_count=0, degraded_count=0, reason_codes=[])
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
def _unsupported(platform: str) -> Dict[str, Any]:
|
|
176
|
-
return {
|
|
177
|
-
"platform": platform,
|
|
178
|
-
"content_kind": "author_home",
|
|
179
|
-
"raw_content": "",
|
|
180
|
-
"summary": "",
|
|
181
|
-
"insights": ["source=author_home_orchestrator", "unsupported_platform"],
|
|
182
|
-
"confidence": "low",
|
|
183
|
-
"error_reason": f"unsupported_platform:{platform}",
|
|
184
|
-
"missing_fields": [],
|
|
185
|
-
"extract_trace": [],
|
|
186
|
-
"fallback_trace": [],
|
|
187
|
-
"stage_status": {
|
|
188
|
-
"fetch": _stage_status(status="failed", ok_count=0, failed_count=1, degraded_count=0, reason_codes=["unsupported_platform"]),
|
|
189
|
-
"asr": _stage_status(status="skipped", ok_count=0, failed_count=0, degraded_count=0, reason_codes=["unsupported_platform"]),
|
|
190
|
-
"author_sample_card": _stage_status(status="skipped", ok_count=0, failed_count=0, degraded_count=0, reason_codes=["unsupported_platform"]),
|
|
191
|
-
"sample_work_card": _stage_status(status="skipped", ok_count=0, failed_count=0, degraded_count=0, reason_codes=["unsupported_platform"]),
|
|
192
|
-
"sampled_explanations": _stage_status(status="skipped", ok_count=0, failed_count=0, degraded_count=0, reason_codes=["unsupported_platform"]),
|
|
193
|
-
"author_analysis": _stage_status(status="skipped", ok_count=0, failed_count=0, degraded_count=0, reason_codes=["unsupported_platform"]),
|
|
194
|
-
"author_card": _stage_status(status="skipped", ok_count=0, failed_count=0, degraded_count=0, reason_codes=["unsupported_platform"]),
|
|
195
|
-
"persist": _stage_status(status="skipped", ok_count=0, failed_count=0, degraded_count=0, reason_codes=["unsupported_platform"]),
|
|
196
|
-
"overall": _stage_status(status="failed", ok_count=0, failed_count=1, degraded_count=0, reason_codes=["unsupported_platform"]),
|
|
197
|
-
},
|
|
198
|
-
"quality_tier": "failed",
|
|
199
|
-
"request_id": None,
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
def _enforce_fixed_pipeline_persistence(*, platform: str, content_kind: str, write_card: bool, persist_output: bool) -> None:
|
|
204
|
-
if write_card and persist_output:
|
|
205
|
-
return
|
|
206
|
-
raise ValueError(
|
|
207
|
-
f"fixed_pipeline_requires_full_persistence:{platform}:{content_kind}:write_card={bool(write_card)}:persist_output={bool(persist_output)}"
|
|
208
|
-
)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
def _safe_slug(value: Any, fallback: str = "unknown") -> str:
|
|
212
|
-
text = str(value or "").strip().lower()
|
|
213
|
-
if not text:
|
|
214
|
-
return fallback
|
|
215
|
-
filtered = "".join(ch if ch.isalnum() or ch in {"-", "_"} else "-" for ch in text).strip("-")
|
|
216
|
-
return filtered[:64] or fallback
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
def _resolve_identifier(input_value: str, result: Dict[str, Any]) -> str:
|
|
220
|
-
for key in ("platform_work_id", "note_id", "request_id"):
|
|
221
|
-
hit = _safe_slug(result.get(key), fallback="")
|
|
222
|
-
if hit:
|
|
223
|
-
return hit
|
|
224
|
-
|
|
225
|
-
source = result.get("source")
|
|
226
|
-
if isinstance(source, dict):
|
|
227
|
-
for key in ("share_url", "share_text", "note_id"):
|
|
228
|
-
candidate = str(source.get(key) or "").strip()
|
|
229
|
-
if candidate:
|
|
230
|
-
return f"url-{hashlib.sha1(candidate.encode('utf-8')).hexdigest()[:10]}"
|
|
231
|
-
|
|
232
|
-
fallback = str(input_value or "").strip()
|
|
233
|
-
if fallback:
|
|
234
|
-
return f"url-{hashlib.sha1(fallback.encode('utf-8')).hexdigest()[:10]}"
|
|
235
|
-
return "missing_input"
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
def _build_persist_payload(*, result: Dict[str, Any], status: str, written_at: datetime, identifier: str) -> Dict[str, Any]:
|
|
239
|
-
platform = str(result.get("platform") or "unknown")
|
|
240
|
-
content_kind = str(result.get("content_kind") or "unknown")
|
|
241
|
-
summary = {
|
|
242
|
-
"summary": result.get("summary", ""),
|
|
243
|
-
"insights": result.get("insights", []),
|
|
244
|
-
"confidence": result.get("confidence"),
|
|
245
|
-
"error_reason": result.get("error_reason"),
|
|
246
|
-
}
|
|
247
|
-
normalized = {
|
|
248
|
-
"platform": platform,
|
|
249
|
-
"content_kind": content_kind,
|
|
250
|
-
"platform_work_id": result.get("platform_work_id") or result.get("note_id"),
|
|
251
|
-
"request_id": result.get("request_id"),
|
|
252
|
-
"source": result.get("source") if isinstance(result.get("source"), dict) else {},
|
|
253
|
-
}
|
|
254
|
-
return {
|
|
255
|
-
"meta": {
|
|
256
|
-
"written_at": written_at.isoformat(timespec="seconds"),
|
|
257
|
-
"status": status,
|
|
258
|
-
"platform": platform,
|
|
259
|
-
"identifier": identifier,
|
|
260
|
-
},
|
|
261
|
-
"summary": summary,
|
|
262
|
-
"normalized": normalized,
|
|
263
|
-
"raw": result,
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
def _persist_output_artifact(*, result: Dict[str, Any], input_value: str, storage_config: Dict[str, Any], persist_output: bool, card_root: Optional[str]) -> Dict[str, Any]:
|
|
268
|
-
if not persist_output:
|
|
269
|
-
return {"enabled": False, "skipped": True, "reason": "disabled_by_flag"}
|
|
270
|
-
|
|
271
|
-
diagnostics = {
|
|
272
|
-
"effective_card_root": str(card_root or ""),
|
|
273
|
-
"results_root": "",
|
|
274
|
-
"errors_root": "",
|
|
275
|
-
}
|
|
276
|
-
try:
|
|
277
|
-
paths = resolve_storage_paths(storage_config or {})
|
|
278
|
-
except Exception as error:
|
|
279
|
-
return {
|
|
280
|
-
"enabled": True,
|
|
281
|
-
"ok": False,
|
|
282
|
-
"error": f"resolve_storage_paths_failed:{error}",
|
|
283
|
-
"failure_reason": f"resolve_storage_paths_failed:{error}",
|
|
284
|
-
"paths": diagnostics,
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
diagnostics["effective_card_root"] = str(card_root or paths.get("root_dir") or "")
|
|
288
|
-
diagnostics["results_root"] = str(paths.get("results_root") or "")
|
|
289
|
-
diagnostics["errors_root"] = str(paths.get("errors_root") or "")
|
|
290
|
-
|
|
291
|
-
now = datetime.now()
|
|
292
|
-
date_key = now.strftime("%Y%m%d")
|
|
293
|
-
timestamp = now.strftime("%Y%m%dT%H%M%S")
|
|
294
|
-
platform = _safe_slug(result.get("platform"), fallback="unknown")
|
|
295
|
-
identifier = _resolve_identifier(input_value, result)
|
|
296
|
-
has_error = bool(result.get("error_reason"))
|
|
297
|
-
status = "error" if has_error else "success"
|
|
298
|
-
|
|
299
|
-
if has_error:
|
|
300
|
-
target_dir = Path(paths.get("errors_root", "")) / date_key
|
|
301
|
-
else:
|
|
302
|
-
target_dir = Path(paths.get("results_root", "")) / date_key
|
|
303
|
-
|
|
304
|
-
try:
|
|
305
|
-
target_dir.mkdir(parents=True, exist_ok=True)
|
|
306
|
-
except Exception as error:
|
|
307
|
-
return {
|
|
308
|
-
"enabled": True,
|
|
309
|
-
"ok": False,
|
|
310
|
-
"error": f"persist_target_dir_failed:{type(error).__name__}:{error}",
|
|
311
|
-
"failure_reason": f"persist_target_dir_failed:{type(error).__name__}:{error}",
|
|
312
|
-
"paths": diagnostics,
|
|
313
|
-
"target_dir": str(target_dir),
|
|
314
|
-
}
|
|
315
|
-
file_name = render_output_filename(
|
|
316
|
-
pattern=resolve_json_filename_pattern(storage_config),
|
|
317
|
-
context={
|
|
318
|
-
"prefix": status,
|
|
319
|
-
"platform": platform,
|
|
320
|
-
"card_type": "author_home_result",
|
|
321
|
-
"author_slug": identifier,
|
|
322
|
-
"title_slug": identifier,
|
|
323
|
-
"identifier": identifier,
|
|
324
|
-
"timestamp": timestamp,
|
|
325
|
-
"date": date_key,
|
|
326
|
-
"ext": ".json",
|
|
327
|
-
},
|
|
328
|
-
default_filename=f"{timestamp}-{platform}-{identifier}.json",
|
|
329
|
-
default_ext=".json",
|
|
330
|
-
)
|
|
331
|
-
file_path = target_dir / file_name
|
|
332
|
-
payload = _build_persist_payload(
|
|
333
|
-
result=result,
|
|
334
|
-
status=status,
|
|
335
|
-
written_at=now,
|
|
336
|
-
identifier=identifier,
|
|
337
|
-
)
|
|
338
|
-
try:
|
|
339
|
-
file_path.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
340
|
-
except Exception as error:
|
|
341
|
-
return {
|
|
342
|
-
"enabled": True,
|
|
343
|
-
"ok": False,
|
|
344
|
-
"error": f"persist_write_failed:{type(error).__name__}:{error}",
|
|
345
|
-
"failure_reason": f"persist_write_failed:{type(error).__name__}:{error}",
|
|
346
|
-
"paths": diagnostics,
|
|
347
|
-
"path": str(file_path),
|
|
348
|
-
}
|
|
349
|
-
return {
|
|
350
|
-
"enabled": True,
|
|
351
|
-
"ok": True,
|
|
352
|
-
"status": status,
|
|
353
|
-
"path": str(file_path),
|
|
354
|
-
"paths": diagnostics,
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
def run_author_home_analysis(
|
|
359
|
-
*,
|
|
360
|
-
platform: str,
|
|
361
|
-
input_value: str,
|
|
362
|
-
base_url: str,
|
|
363
|
-
token: str,
|
|
364
|
-
timeout_ms: int,
|
|
365
|
-
page_size: int = 20,
|
|
366
|
-
pages_max: int = 50,
|
|
367
|
-
max_items: int = 200,
|
|
368
|
-
poll_interval_sec: float = 3.0,
|
|
369
|
-
max_polls: int = 30,
|
|
370
|
-
douyin_u2_submit_max_retries: int = 2,
|
|
371
|
-
douyin_u2_submit_backoff_ms: int = 1500,
|
|
372
|
-
xhs_u2_submit_max_retries: int = 0,
|
|
373
|
-
xhs_u2_submit_backoff_ms: int = 0,
|
|
374
|
-
u2_timeout_retry_enabled: bool = True,
|
|
375
|
-
u2_timeout_retry_max_retries: int = 3,
|
|
376
|
-
asr_batch_size: int = 20,
|
|
377
|
-
checkpoint: Optional[Dict[str, Any]] = None,
|
|
378
|
-
write_card: bool = True,
|
|
379
|
-
persist_output: bool = True,
|
|
380
|
-
card_root: Optional[str] = None,
|
|
381
|
-
storage_config: Optional[Dict[str, Any]] = None,
|
|
382
|
-
collector_override: Optional[CollectorFn] = None,
|
|
383
|
-
progress: Optional[ProgressReporter] = None,
|
|
384
|
-
) -> Dict[str, Any]:
|
|
385
|
-
_enforce_fixed_pipeline_persistence(
|
|
386
|
-
platform=platform,
|
|
387
|
-
content_kind="author_home",
|
|
388
|
-
write_card=bool(write_card),
|
|
389
|
-
persist_output=bool(persist_output),
|
|
390
|
-
)
|
|
391
|
-
|
|
392
|
-
# hard default policy: latest + cursor loop + max 200 across all platforms
|
|
393
|
-
capped_max_items = min(max(max_items, 1), 200)
|
|
394
|
-
capped_page_size = min(max(page_size, 1), 20)
|
|
395
|
-
if progress is not None:
|
|
396
|
-
progress.started(
|
|
397
|
-
stage="author_home.workflow",
|
|
398
|
-
message="author_home workflow started",
|
|
399
|
-
data={"page_size": capped_page_size, "max_items": capped_max_items},
|
|
400
|
-
)
|
|
401
|
-
|
|
402
|
-
if platform == "douyin":
|
|
403
|
-
collector = collector_override or collect_douyin_author_home_raw
|
|
404
|
-
raw = collector(
|
|
405
|
-
input_value=input_value,
|
|
406
|
-
base_url=base_url,
|
|
407
|
-
token=token,
|
|
408
|
-
timeout_ms=timeout_ms,
|
|
409
|
-
page_size=capped_page_size,
|
|
410
|
-
pages_max=max(pages_max, 1),
|
|
411
|
-
max_items=capped_max_items,
|
|
412
|
-
progress=progress.child(scope="author_home.collect") if progress is not None else None,
|
|
413
|
-
)
|
|
414
|
-
profile, works, adapter_missing = adapt_douyin_author_home(raw)
|
|
415
|
-
elif platform == "xiaohongshu":
|
|
416
|
-
collector = collector_override or collect_xhs_author_home_raw
|
|
417
|
-
raw = collector(
|
|
418
|
-
input_value=input_value,
|
|
419
|
-
base_url=base_url,
|
|
420
|
-
token=token,
|
|
421
|
-
timeout_ms=timeout_ms,
|
|
422
|
-
page_size=capped_page_size,
|
|
423
|
-
pages_max=max(pages_max, 1),
|
|
424
|
-
max_items=capped_max_items,
|
|
425
|
-
progress=progress.child(scope="author_home.collect") if progress is not None else None,
|
|
426
|
-
)
|
|
427
|
-
profile, works, adapter_missing = adapt_xhs_author_home(raw)
|
|
428
|
-
else:
|
|
429
|
-
return _unsupported(platform)
|
|
430
|
-
|
|
431
|
-
# Defensive cap enforcement at orchestrator layer.
|
|
432
|
-
works = works[:capped_max_items]
|
|
433
|
-
if progress is not None:
|
|
434
|
-
progress.progress(
|
|
435
|
-
stage="author_home.adapt",
|
|
436
|
-
message="author_home raw payload adapted",
|
|
437
|
-
data={"works_count": len(works), "missing_fields": len(adapter_missing)},
|
|
438
|
-
)
|
|
439
|
-
|
|
440
|
-
asr_bundle = enrich_author_home_asr(
|
|
441
|
-
platform=platform,
|
|
442
|
-
works=works,
|
|
443
|
-
base_url=base_url,
|
|
444
|
-
token=token,
|
|
445
|
-
timeout_ms=timeout_ms,
|
|
446
|
-
poll_interval_sec=poll_interval_sec,
|
|
447
|
-
max_polls=max_polls,
|
|
448
|
-
douyin_submit_max_retries=douyin_u2_submit_max_retries,
|
|
449
|
-
douyin_submit_backoff_ms=douyin_u2_submit_backoff_ms,
|
|
450
|
-
xhs_submit_max_retries=xhs_u2_submit_max_retries,
|
|
451
|
-
xhs_submit_backoff_ms=xhs_u2_submit_backoff_ms,
|
|
452
|
-
timeout_retry_enabled=u2_timeout_retry_enabled,
|
|
453
|
-
timeout_retry_max_retries=u2_timeout_retry_max_retries,
|
|
454
|
-
batch_size=asr_batch_size,
|
|
455
|
-
checkpoint=checkpoint,
|
|
456
|
-
progress=progress.child(scope="author_home.asr") if progress is not None else None,
|
|
457
|
-
)
|
|
458
|
-
works = list(asr_bundle.get("works") or [])[:capped_max_items]
|
|
459
|
-
prepared_analysis_bundle = prepare_author_analysis_bundle(
|
|
460
|
-
profile=profile,
|
|
461
|
-
works=works,
|
|
462
|
-
platform=platform,
|
|
463
|
-
)
|
|
464
|
-
works = _merge_normalized_works(
|
|
465
|
-
works=works,
|
|
466
|
-
normalized_works=prepared_analysis_bundle.get("normalized_works") if isinstance(prepared_analysis_bundle.get("normalized_works"), list) else [],
|
|
467
|
-
)
|
|
468
|
-
prepared_analysis_bundle = prepare_author_analysis_bundle(
|
|
469
|
-
profile=profile,
|
|
470
|
-
works=works,
|
|
471
|
-
platform=platform,
|
|
472
|
-
)
|
|
473
|
-
sampled_work_ids = prepared_analysis_bundle.get("sampled_work_ids") if isinstance(prepared_analysis_bundle.get("sampled_work_ids"), list) else []
|
|
474
|
-
|
|
475
|
-
if write_card:
|
|
476
|
-
work_analysis_bundle = orchestrate_work_analysis_artifacts(
|
|
477
|
-
platform=platform,
|
|
478
|
-
profile=profile,
|
|
479
|
-
works=works,
|
|
480
|
-
storage_config=storage_config,
|
|
481
|
-
progress=progress.child(scope="author_home.work_analysis") if progress is not None else None,
|
|
482
|
-
)
|
|
483
|
-
else:
|
|
484
|
-
work_analysis_bundle = {
|
|
485
|
-
"render_payloads": {},
|
|
486
|
-
"artifact_manifest": {},
|
|
487
|
-
"stats": {
|
|
488
|
-
"total_count": len(works),
|
|
489
|
-
"cache_hit_count": 0,
|
|
490
|
-
"queued_count": 0,
|
|
491
|
-
"running_workers": 0,
|
|
492
|
-
"running_workers_peak": 0,
|
|
493
|
-
"finished_count": 0,
|
|
494
|
-
"failed_count": 0,
|
|
495
|
-
"max_workers": 0,
|
|
496
|
-
},
|
|
497
|
-
"failed_items": [],
|
|
498
|
-
"trace": [],
|
|
499
|
-
"artifact_root": None,
|
|
500
|
-
"analysis_logic_version": None,
|
|
501
|
-
"prompt_contract_hash": None,
|
|
502
|
-
"normalization_version": None,
|
|
503
|
-
}
|
|
504
|
-
work_analysis_stats = work_analysis_bundle.get("stats") if isinstance(work_analysis_bundle.get("stats"), dict) else {}
|
|
505
|
-
work_analysis_failed = work_analysis_bundle.get("failed_items") if isinstance(work_analysis_bundle.get("failed_items"), list) else []
|
|
506
|
-
work_analysis_trace = list(work_analysis_bundle.get("trace") or [])
|
|
507
|
-
artifact_manifest = work_analysis_bundle.get("artifact_manifest") if isinstance(work_analysis_bundle.get("artifact_manifest"), dict) else {}
|
|
508
|
-
render_payloads = work_analysis_bundle.get("render_payloads") if isinstance(work_analysis_bundle.get("render_payloads"), dict) else {}
|
|
509
|
-
failed_work_ids = {str(item.get("platform_work_id") or "").strip() for item in work_analysis_failed if isinstance(item, dict)}
|
|
510
|
-
for work in works:
|
|
511
|
-
if not isinstance(work, dict):
|
|
512
|
-
continue
|
|
513
|
-
platform_work_id = str(work.get("platform_work_id") or "").strip()
|
|
514
|
-
manifest = artifact_manifest.get(platform_work_id) if platform_work_id else None
|
|
515
|
-
if isinstance(manifest, dict):
|
|
516
|
-
work["analysis_artifact_status"] = "cache_hit" if manifest.get("from_cache") else "generated"
|
|
517
|
-
work["analysis_artifact_path"] = manifest.get("artifact_path")
|
|
518
|
-
elif platform_work_id in failed_work_ids:
|
|
519
|
-
work["analysis_artifact_status"] = "failed"
|
|
520
|
-
work["analysis_artifact_path"] = None
|
|
521
|
-
|
|
522
|
-
if progress is not None:
|
|
523
|
-
progress.progress(stage="author_home.analysis", message="running author analysis")
|
|
524
|
-
analysis, analysis_missing, analysis_trace = run_prompt_first_author_analysis(
|
|
525
|
-
profile,
|
|
526
|
-
works,
|
|
527
|
-
analysis_bundle=prepared_analysis_bundle,
|
|
528
|
-
)
|
|
529
|
-
if progress is not None:
|
|
530
|
-
progress.done(
|
|
531
|
-
stage="author_home.analysis",
|
|
532
|
-
message="author analysis finished",
|
|
533
|
-
data={"missing_fields": len(analysis_missing)},
|
|
534
|
-
)
|
|
535
|
-
|
|
536
|
-
if progress is not None:
|
|
537
|
-
progress.progress(
|
|
538
|
-
stage="author_home.card_write",
|
|
539
|
-
message="writing author and work cards",
|
|
540
|
-
data={"write_card": bool(write_card)},
|
|
541
|
-
)
|
|
542
|
-
work_card_write = build_work_cards(
|
|
543
|
-
platform=platform,
|
|
544
|
-
profile=profile,
|
|
545
|
-
works=works,
|
|
546
|
-
render_payloads=render_payloads,
|
|
547
|
-
sampled_work_ids=sampled_work_ids,
|
|
548
|
-
sampled_work_explanations=(
|
|
549
|
-
analysis.get("sampled_work_explanations", {}).get("sampled_work_explanations")
|
|
550
|
-
if isinstance(analysis.get("sampled_work_explanations"), dict)
|
|
551
|
-
else {}
|
|
552
|
-
),
|
|
553
|
-
card_root=card_root,
|
|
554
|
-
storage_config=storage_config,
|
|
555
|
-
write_card=write_card,
|
|
556
|
-
failed_items=work_analysis_failed,
|
|
557
|
-
)
|
|
558
|
-
|
|
559
|
-
asr_trace = list(asr_bundle.get("trace") or [])
|
|
560
|
-
all_extract_trace = list(raw.get("extract_trace") or []) + asr_trace + work_analysis_trace + analysis_trace
|
|
561
|
-
|
|
562
|
-
fallback_trace: List[Dict[str, Any]] = []
|
|
563
|
-
for step in all_extract_trace:
|
|
564
|
-
if not isinstance(step, dict):
|
|
565
|
-
continue
|
|
566
|
-
name = str(step.get("step") or "")
|
|
567
|
-
try:
|
|
568
|
-
has_retry = int(step.get("retry_attempt") or 0) > 0
|
|
569
|
-
except Exception:
|
|
570
|
-
has_retry = False
|
|
571
|
-
if "fallback" in name or not step.get("ok", True) or step.get("fallback_trigger_reason") or has_retry:
|
|
572
|
-
fallback_trace.append(step)
|
|
573
|
-
|
|
574
|
-
asr_missing: List[Dict[str, str]] = []
|
|
575
|
-
for item in works:
|
|
576
|
-
if not isinstance(item, dict):
|
|
577
|
-
continue
|
|
578
|
-
if str(item.get("analysis_eligibility") or "") == "eligible":
|
|
579
|
-
continue
|
|
580
|
-
asr_missing.append(
|
|
581
|
-
{
|
|
582
|
-
"field": f"works[{item.get('platform_work_id') or 'unknown'}].asr",
|
|
583
|
-
"reason": str(item.get("analysis_exclusion_reason") or item.get("asr_error_reason") or "asr_failed"),
|
|
584
|
-
}
|
|
585
|
-
)
|
|
586
|
-
|
|
587
|
-
asr_stats = asr_bundle.get("stats") if isinstance(asr_bundle.get("stats"), dict) else {}
|
|
588
|
-
asr_checkpoint = asr_bundle.get("checkpoint") if isinstance(asr_bundle.get("checkpoint"), dict) else {}
|
|
589
|
-
author_sample_cards = work_card_write.get("author_sample_cards") if isinstance(work_card_write.get("author_sample_cards"), dict) else {}
|
|
590
|
-
sample_work_cards = work_card_write.get("sample_work_cards") if isinstance(work_card_write.get("sample_work_cards"), dict) else {}
|
|
591
|
-
|
|
592
|
-
eligible_count = len([item for item in works if isinstance(item, dict) and str(item.get("analysis_eligibility") or "") == "eligible"])
|
|
593
|
-
incomplete_count = len([item for item in works if isinstance(item, dict) and str(item.get("analysis_eligibility") or "") != "eligible"])
|
|
594
|
-
if works and eligible_count == 0:
|
|
595
|
-
asr_stage = _stage_status(
|
|
596
|
-
status="failed",
|
|
597
|
-
ok_count=0,
|
|
598
|
-
failed_count=incomplete_count or len(works),
|
|
599
|
-
degraded_count=0,
|
|
600
|
-
reason_codes=["asr_unavailable_for_all_works"],
|
|
601
|
-
failure_kind="runtime",
|
|
602
|
-
)
|
|
603
|
-
elif incomplete_count > 0:
|
|
604
|
-
asr_stage = _stage_status(
|
|
605
|
-
status="degraded",
|
|
606
|
-
ok_count=eligible_count,
|
|
607
|
-
failed_count=0,
|
|
608
|
-
degraded_count=incomplete_count,
|
|
609
|
-
reason_codes=["partial_asr_unavailable"],
|
|
610
|
-
failure_kind="runtime",
|
|
611
|
-
)
|
|
612
|
-
else:
|
|
613
|
-
asr_stage = _stage_status(
|
|
614
|
-
status="full",
|
|
615
|
-
ok_count=eligible_count,
|
|
616
|
-
failed_count=0,
|
|
617
|
-
degraded_count=0,
|
|
618
|
-
reason_codes=[],
|
|
619
|
-
)
|
|
620
|
-
|
|
621
|
-
stage_status: Dict[str, Dict[str, Any]] = {
|
|
622
|
-
"fetch": _stage_status(
|
|
623
|
-
status="full",
|
|
624
|
-
ok_count=len(works),
|
|
625
|
-
failed_count=0,
|
|
626
|
-
degraded_count=0,
|
|
627
|
-
reason_codes=[],
|
|
628
|
-
),
|
|
629
|
-
"asr": asr_stage,
|
|
630
|
-
"author_sample_card": _build_card_stage_status(
|
|
631
|
-
expected_count=len(works),
|
|
632
|
-
results=author_sample_cards,
|
|
633
|
-
),
|
|
634
|
-
"sample_work_card": _build_card_stage_status(
|
|
635
|
-
expected_count=len(sampled_work_ids),
|
|
636
|
-
results=sample_work_cards,
|
|
637
|
-
),
|
|
638
|
-
"sampled_explanations": analysis.get("sampled_explanations_status") if isinstance(analysis.get("sampled_explanations_status"), dict) else _stage_status(
|
|
639
|
-
status="failed",
|
|
640
|
-
ok_count=0,
|
|
641
|
-
failed_count=1,
|
|
642
|
-
degraded_count=0,
|
|
643
|
-
reason_codes=["missing_sampled_explanations_status"],
|
|
644
|
-
),
|
|
645
|
-
"author_analysis": analysis.get("author_analysis_status") if isinstance(analysis.get("author_analysis_status"), dict) else _stage_status(
|
|
646
|
-
status="failed",
|
|
647
|
-
ok_count=0,
|
|
648
|
-
failed_count=1,
|
|
649
|
-
degraded_count=0,
|
|
650
|
-
reason_codes=["missing_author_analysis_status"],
|
|
651
|
-
),
|
|
652
|
-
"author_card": _stage_status(
|
|
653
|
-
status="skipped",
|
|
654
|
-
ok_count=0,
|
|
655
|
-
failed_count=0,
|
|
656
|
-
degraded_count=0,
|
|
657
|
-
reason_codes=["pending"],
|
|
658
|
-
),
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
author_analysis_payload = dict(analysis)
|
|
662
|
-
author_analysis_payload["stage_status"] = stage_status
|
|
663
|
-
author_analysis_payload["quality_tier"] = analysis.get("quality_tier")
|
|
664
|
-
author_analysis_payload["sampled_work_ids"] = sampled_work_ids
|
|
665
|
-
|
|
666
|
-
try:
|
|
667
|
-
author_card_write = build_author_card(
|
|
668
|
-
platform=platform,
|
|
669
|
-
profile=profile,
|
|
670
|
-
analysis_payload=author_analysis_payload,
|
|
671
|
-
card_root=card_root,
|
|
672
|
-
storage_config=storage_config,
|
|
673
|
-
write_card=write_card,
|
|
674
|
-
)
|
|
675
|
-
except Exception as error:
|
|
676
|
-
author_card_write = {
|
|
677
|
-
"ok": False,
|
|
678
|
-
"card_type": "author",
|
|
679
|
-
"card_role": "author_card",
|
|
680
|
-
"error_reason": f"author_card_write_failed:{type(error).__name__}:{error}",
|
|
681
|
-
"routing": {
|
|
682
|
-
"card_role": "author_card",
|
|
683
|
-
"route_key": "author",
|
|
684
|
-
"primary_route_parts": "",
|
|
685
|
-
"explicit_override": False,
|
|
686
|
-
"storage_routes_configured": bool(isinstance(storage_config, dict) and isinstance(storage_config.get("storage_routes"), dict)),
|
|
687
|
-
},
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
stage_status["author_card"] = (
|
|
691
|
-
_stage_status(status="full", ok_count=1, failed_count=0, degraded_count=0, reason_codes=[])
|
|
692
|
-
if author_card_write.get("ok")
|
|
693
|
-
else _stage_status(
|
|
694
|
-
status="failed",
|
|
695
|
-
ok_count=0,
|
|
696
|
-
failed_count=1,
|
|
697
|
-
degraded_count=0,
|
|
698
|
-
reason_codes=[str(author_card_write.get("error_reason") or "author_card_write_failed").split(":", 1)[0]],
|
|
699
|
-
failure_kind="runtime",
|
|
700
|
-
)
|
|
701
|
-
)
|
|
702
|
-
stage_status["overall"] = _build_overall_status(stage_status)
|
|
703
|
-
if author_card_write.get("ok"):
|
|
704
|
-
author_analysis_payload["stage_status"] = stage_status
|
|
705
|
-
try:
|
|
706
|
-
author_card_write = build_author_card(
|
|
707
|
-
platform=platform,
|
|
708
|
-
profile=profile,
|
|
709
|
-
analysis_payload=author_analysis_payload,
|
|
710
|
-
card_root=card_root,
|
|
711
|
-
storage_config=storage_config,
|
|
712
|
-
write_card=write_card,
|
|
713
|
-
)
|
|
714
|
-
except Exception:
|
|
715
|
-
pass
|
|
716
|
-
|
|
717
|
-
if progress is not None:
|
|
718
|
-
progress.done(
|
|
719
|
-
stage="author_home.card_write",
|
|
720
|
-
message="author_home card writing finished",
|
|
721
|
-
data={
|
|
722
|
-
"author_card_ok": bool(author_card_write.get("ok")),
|
|
723
|
-
"author_sample_cards_count": int(author_sample_cards.get("count") or 0),
|
|
724
|
-
"sample_work_cards_count": int(sample_work_cards.get("count") or 0),
|
|
725
|
-
},
|
|
726
|
-
)
|
|
727
|
-
|
|
728
|
-
result = {
|
|
729
|
-
"platform": platform,
|
|
730
|
-
"content_kind": "author_home",
|
|
731
|
-
"raw_content": "",
|
|
732
|
-
"summary": analysis.get("author_portrait", ""),
|
|
733
|
-
"insights": [
|
|
734
|
-
"source=author_home_componentized",
|
|
735
|
-
f"works_count={len(works)}",
|
|
736
|
-
f"business_score={analysis.get('business_score', 0)}",
|
|
737
|
-
f"benchmark_gap_score={analysis.get('benchmark_gap_score', 0)}",
|
|
738
|
-
f"asr_success={asr_stats.get('success', 0)}",
|
|
739
|
-
"analysis_strategy=prompt_first",
|
|
740
|
-
f"work_cache_hit={work_analysis_stats.get('cache_hit_count', 0)}",
|
|
741
|
-
f"work_queued={work_analysis_stats.get('queued_count', 0)}",
|
|
742
|
-
f"work_failed={work_analysis_stats.get('failed_count', 0)}",
|
|
743
|
-
],
|
|
744
|
-
"confidence": (
|
|
745
|
-
"low"
|
|
746
|
-
if analysis.get("quality_tier") in {"fallback", "failed"} or analysis_missing
|
|
747
|
-
else "medium"
|
|
748
|
-
),
|
|
749
|
-
"error_reason": (
|
|
750
|
-
((stage_status.get("overall") or {}).get("reason_codes") or [None])[0]
|
|
751
|
-
if (stage_status.get("overall") or {}).get("status") == "failed"
|
|
752
|
-
else None
|
|
753
|
-
),
|
|
754
|
-
"missing_fields": adapter_missing + analysis_missing + asr_missing,
|
|
755
|
-
"extract_trace": all_extract_trace,
|
|
756
|
-
"fallback_trace": fallback_trace,
|
|
757
|
-
"request_id": raw.get("request_id"),
|
|
758
|
-
"author_profile": profile,
|
|
759
|
-
"works": works,
|
|
760
|
-
"sampled_work_ids": sampled_work_ids,
|
|
761
|
-
"pagination": {
|
|
762
|
-
**(raw.get("pagination") or {}),
|
|
763
|
-
"total_collected": len(works),
|
|
764
|
-
"max_items": capped_max_items,
|
|
765
|
-
},
|
|
766
|
-
"analysis_output": analysis,
|
|
767
|
-
"author_analysis_v2": analysis.get("author_analysis_v2") if isinstance(analysis.get("author_analysis_v2"), dict) else {},
|
|
768
|
-
"author_analysis_input_v1": analysis.get("author_analysis_input_v1") if isinstance(analysis.get("author_analysis_input_v1"), dict) else {},
|
|
769
|
-
"analysis_validation": analysis.get("validation") if isinstance(analysis.get("validation"), dict) else {},
|
|
770
|
-
"stage_status": stage_status,
|
|
771
|
-
"quality_tier": analysis.get("quality_tier"),
|
|
772
|
-
"asr_stats": asr_stats,
|
|
773
|
-
"work_analysis": {
|
|
774
|
-
"stats": work_analysis_stats,
|
|
775
|
-
"failed_items": work_analysis_failed,
|
|
776
|
-
"artifact_root": work_analysis_bundle.get("artifact_root"),
|
|
777
|
-
"analysis_logic_version": work_analysis_bundle.get("analysis_logic_version"),
|
|
778
|
-
"prompt_contract_hash": work_analysis_bundle.get("prompt_contract_hash"),
|
|
779
|
-
"normalization_version": work_analysis_bundle.get("normalization_version"),
|
|
780
|
-
},
|
|
781
|
-
"card_write": {
|
|
782
|
-
"author": author_card_write,
|
|
783
|
-
"author_sample_cards": author_sample_cards,
|
|
784
|
-
"sample_work_cards": sample_work_cards,
|
|
785
|
-
"works": {
|
|
786
|
-
**author_sample_cards,
|
|
787
|
-
"legacy_alias_of": "author_sample_cards",
|
|
788
|
-
},
|
|
789
|
-
},
|
|
790
|
-
"checkpoint": {
|
|
791
|
-
"last_cursor": ((raw.get("pagination") or {}).get("pages") or [{}])[-1].get("cursor_out") if isinstance((raw.get("pagination") or {}).get("pages"), list) and (raw.get("pagination") or {}).get("pages") else "",
|
|
792
|
-
"pages": len((raw.get("pagination") or {}).get("pages") or []),
|
|
793
|
-
"total_collected": len(works),
|
|
794
|
-
"max_items": capped_max_items,
|
|
795
|
-
"sort": "latest",
|
|
796
|
-
"cursor_mode": (raw.get("pagination") or {}).get("cursor_mode", "cursor"),
|
|
797
|
-
"asr": asr_checkpoint,
|
|
798
|
-
"work_analysis": {
|
|
799
|
-
"cache_hit_count": work_analysis_stats.get("cache_hit_count", 0),
|
|
800
|
-
"queued_count": work_analysis_stats.get("queued_count", 0),
|
|
801
|
-
"finished_count": work_analysis_stats.get("finished_count", 0),
|
|
802
|
-
"failed_count": work_analysis_stats.get("failed_count", 0),
|
|
803
|
-
"artifact_root": work_analysis_bundle.get("artifact_root"),
|
|
804
|
-
"failed_items": work_analysis_failed,
|
|
805
|
-
},
|
|
806
|
-
},
|
|
807
|
-
}
|
|
808
|
-
result["output_persist"] = _persist_output_artifact(
|
|
809
|
-
result=result,
|
|
810
|
-
input_value=input_value,
|
|
811
|
-
storage_config=storage_config or {},
|
|
812
|
-
persist_output=bool(persist_output),
|
|
813
|
-
card_root=card_root,
|
|
814
|
-
)
|
|
815
|
-
stage_status["persist"] = _build_persist_stage_status(result.get("output_persist") if isinstance(result.get("output_persist"), dict) else {})
|
|
816
|
-
result["stage_status"] = stage_status
|
|
817
|
-
if progress is not None:
|
|
818
|
-
final_event = progress.failed if result.get("error_reason") else progress.done
|
|
819
|
-
final_event(
|
|
820
|
-
stage="author_home.workflow",
|
|
821
|
-
message="author_home workflow finished" if not result.get("error_reason") else "author_home workflow failed",
|
|
822
|
-
data={
|
|
823
|
-
"works_count": len(works),
|
|
824
|
-
"request_id": result.get("request_id"),
|
|
825
|
-
"author_card_ok": bool((result.get("card_write") or {}).get("author", {}).get("ok")),
|
|
826
|
-
"author_sample_cards_count": int(((result.get("card_write") or {}).get("author_sample_cards") or {}).get("count") or 0),
|
|
827
|
-
"sample_work_cards_count": int(((result.get("card_write") or {}).get("sample_work_cards") or {}).get("count") or 0),
|
|
828
|
-
"cache_hit_count": work_analysis_stats.get("cache_hit_count", 0),
|
|
829
|
-
"queued_count": work_analysis_stats.get("queued_count", 0),
|
|
830
|
-
"failed_count": work_analysis_stats.get("failed_count", 0),
|
|
831
|
-
"output_persist_ok": bool((result.get("output_persist") or {}).get("ok")),
|
|
832
|
-
},
|
|
833
|
-
)
|
|
834
|
-
return result
|