@gobing-ai/knowledge-kit 0.1.22 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +282 -147
  3. package/package.json +5 -5
  4. package/plugins/generations/content-gen/dist/index.js +9 -9
  5. package/plugins/generations/core-facts-gen/dist/index.js +12 -12
  6. package/plugins/generations/daily-article-gen/dist/index.js +12 -12
  7. package/plugins/generations/dailynews-gen/dist/index.js +11 -11
  8. package/plugins/generations/dailynews-gen/src/script-plan.ts +2 -2
  9. package/plugins/generations/episode-plan-gen/dist/index.js +12 -12
  10. package/plugins/generations/gemini-tts/dist/index.js +56 -16
  11. package/plugins/generations/gemini-tts/src/gemini-client.ts +34 -6
  12. package/plugins/generations/image-gen/dist/index.js +9 -9
  13. package/plugins/generations/music-gen/README.md +2 -2
  14. package/plugins/generations/music-gen/dist/index.js +62 -26
  15. package/plugins/generations/music-gen/presets/formats/song.yaml +6 -1
  16. package/plugins/generations/music-gen/presets/themes/synthwave.yaml +6 -1
  17. package/plugins/generations/music-gen/src/adapter/instance.ts +34 -11
  18. package/plugins/generations/music-gen/src/presets.ts +36 -3
  19. package/plugins/generations/news-report-gen/dist/index.js +12 -12
  20. package/plugins/generations/omni-voice-gen/uv.toml +5 -0
  21. package/plugins/generations/vibe-voice-tts/README.md +64 -0
  22. package/plugins/generations/vibe-voice-tts/dist/index.js +14259 -0
  23. package/plugins/generations/vibe-voice-tts/package.json +16 -0
  24. package/plugins/generations/vibe-voice-tts/plugin.json +6 -0
  25. package/plugins/generations/vibe-voice-tts/profiles.json +10 -0
  26. package/plugins/generations/vibe-voice-tts/pyproject.toml +9 -0
  27. package/plugins/generations/vibe-voice-tts/python/worker.py +566 -0
  28. package/plugins/generations/vibe-voice-tts/src/index.ts +88 -0
  29. package/plugins/generations/vibe-voice-tts/src/vibevoice-client.ts +828 -0
  30. package/plugins/generations/vibe-voice-tts/tsconfig.json +8 -0
  31. package/plugins/generations/vibe-voice-tts/uv.lock +1767 -0
  32. package/plugins/generations/vibe-voice-tts/uv.toml +4 -0
  33. package/plugins/generations/voice-gen/dist/index.js +40 -10
  34. package/plugins/generations/voice-gen/src/voicebox-client.ts +50 -1
  35. package/plugins/generations/voxcpm-tts/dist/index.js +90 -18
  36. package/plugins/generations/voxcpm-tts/python/worker.py +9 -0
  37. package/plugins/generations/voxcpm-tts/src/index.ts +41 -0
  38. package/plugins/generations/voxcpm-tts/src/voxcpm-client.ts +32 -11
  39. package/plugins/generations/voxcpm-tts/uv.toml +5 -0
  40. package/plugins/ingestions/aihot-ingest/dist/index.js +12 -12
  41. package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
  42. package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
  43. package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
  44. package/plugins/ingestions/web-search/dist/index.js +10 -10
  45. package/plugins/kk/README.md +21 -0
  46. package/plugins/kk/decisions/kk-safety.yaml +5 -2
  47. package/plugins/kk/plugin.json +1 -1
  48. package/plugins/kk/publish-presets/daily-ai-voice.json +16 -16
  49. package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +12 -1
  50. package/plugins/kk/scripts/cover-compositor.ts +104 -26
  51. package/plugins/kk/scripts/daily-stages.ts +481 -63
  52. package/plugins/kk/scripts/kk-workflow-stages.ts +218 -17
  53. package/plugins/kk/scripts/safety-artifact-check.ts +28 -5
  54. package/plugins/kk/scripts/series-names.ts +16 -3
  55. package/plugins/kk/skills/news-editorial/SKILL.md +1 -1
  56. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
  57. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +4 -3
  58. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -5
  59. package/plugins/kk/workflows/kk-daily-safety.yaml +12 -10
  60. package/plugins/kk/workflows/kk-music.yaml +20 -16
  61. package/plugins/kk/workflows/kk-news-generate.yaml +26 -3
  62. package/plugins/kk/workflows/kk-publish.yaml +4 -1
  63. package/plugins/publishings/bilibili-pub/dist/index.js +22 -22
  64. package/plugins/publishings/bilibili-pub/dist/profile-check.js +22 -22
  65. package/plugins/publishings/cnblogs-pub/dist/index.js +22 -22
  66. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +22 -22
  67. package/plugins/publishings/csdn-pub/dist/index.js +22 -22
  68. package/plugins/publishings/csdn-pub/dist/profile-check.js +22 -22
  69. package/plugins/publishings/emdash-pub/dist/index.js +9 -9
  70. package/plugins/publishings/infoq-pub/dist/index.js +22 -22
  71. package/plugins/publishings/infoq-pub/dist/profile-check.js +22 -22
  72. package/plugins/publishings/jike-pub/dist/index.js +22 -22
  73. package/plugins/publishings/jike-pub/dist/profile-check.js +22 -22
  74. package/plugins/publishings/juejin-pub/dist/index.js +22 -22
  75. package/plugins/publishings/juejin-pub/dist/profile-check.js +22 -22
  76. package/plugins/publishings/linkedin-pub/dist/index.js +133 -33
  77. package/plugins/publishings/linkedin-pub/dist/profile-check.js +27 -22
  78. package/plugins/publishings/linkedin-pub/src/index.ts +192 -18
  79. package/plugins/publishings/medium-pub/dist/index.js +9 -9
  80. package/plugins/publishings/podcast-pub/dist/index.js +240 -37
  81. package/plugins/publishings/podcast-pub/src/index.ts +154 -3
  82. package/plugins/publishings/podcast-pub/src/seo.ts +25 -8
  83. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +93 -23
  84. package/plugins/publishings/podcast-pub/src/show-notes.ts +26 -6
  85. package/plugins/publishings/qiita-pub/dist/index.js +9 -9
  86. package/plugins/publishings/shipinhao-pub/dist/index.js +23 -23
  87. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +23 -23
  88. package/plugins/publishings/shipinhao-pub/src/selectors.ts +2 -1
  89. package/plugins/publishings/sspai-pub/dist/index.js +22 -22
  90. package/plugins/publishings/sspai-pub/dist/profile-check.js +22 -22
  91. package/plugins/publishings/substack-pub/dist/index.js +22 -22
  92. package/plugins/publishings/substack-pub/dist/profile-check.js +22 -22
  93. package/plugins/publishings/surfdash-pub/dist/index.js +207 -95
  94. package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
  95. package/plugins/publishings/surfdash-pub/src/index.ts +101 -76
  96. package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
  97. package/plugins/publishings/surfdash-pub/src/patch.ts +49 -26
  98. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
  99. package/plugins/publishings/threads-pub/dist/index.js +83 -27
  100. package/plugins/publishings/threads-pub/dist/profile-check.js +34 -23
  101. package/plugins/publishings/threads-pub/src/post-rail.ts +121 -4
  102. package/plugins/publishings/wechatmp-pub/dist/index.js +274 -98
  103. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +27 -23
  104. package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +87 -53
  105. package/plugins/publishings/wechatmp-pub/src/enrich.ts +117 -13
  106. package/plugins/publishings/wechatmp-pub/src/flow.ts +183 -43
  107. package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
  108. package/plugins/publishings/weibo-pub/dist/index.js +22 -22
  109. package/plugins/publishings/weibo-pub/dist/profile-check.js +22 -22
  110. package/plugins/publishings/x-pub/dist/index.js +113 -32
  111. package/plugins/publishings/x-pub/dist/profile-check.js +22 -22
  112. package/plugins/publishings/x-pub/src/post-rail.ts +155 -20
  113. package/plugins/publishings/xhs-pub/dist/index.js +22 -22
  114. package/plugins/publishings/xhs-pub/dist/profile-check.js +22 -22
  115. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +22 -22
  116. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +22 -22
  117. package/plugins/publishings/zenn-pub/dist/index.js +9 -9
@@ -667,9 +667,22 @@ function formatWindowMs(ms: number): string {
667
667
  * and dedup), so it is an upper bound: the ladder can stop one step early, never one late.
668
668
  */
669
669
  export function dailyExtract(args: string[]): void {
670
- const [workDir = '', topic = '', window = '', minMinutes = '', vdriver = ''] = args;
670
+ const [workDir = '', topic = '', window = '', minMinutes = '', vdriver = '', limitArg = ''] = args;
671
671
  if (!workDir) fail('missing work_dir');
672
672
  if (!topic) fail('missing topic');
673
+ // 2026-11-20: `kk store extract --limit` defaults to the profile's cap (else 20), and this stage
674
+ // passed no `--limit` at all — so the plan cap (`plan_max_items`, 40) never reached the store and
675
+ // the pool was pre-trimmed to the default before the quota existed. Measured on the production
676
+ // store: 56 category-allowed, importance>=3, unpublished items sat in the 168h window, the
677
+ // extract returned 24, QC admitted 13, the writer kept 3 and the day refused at the TTS gate;
678
+ // at `--limit 40` the same window yields 30 items and 23 survive QC. The extract bound must be
679
+ // at least the plan bound or the plan can never fill.
680
+ const extractedLimit = Number(limitArg);
681
+ const limit =
682
+ limitArg !== '' && Number.isInteger(extractedLimit) && extractedLimit > 0
683
+ ? ['--limit', String(extractedLimit)]
684
+ : [];
685
+ if (limitArg !== '' && limit.length === 0) fail(`extract: invalid limit: ${limitArg}`);
673
686
  const poolPath = join(workDir, '10-collect', 'pool.json');
674
687
  const base = parseWindowMs(window === '' ? '24h' : window);
675
688
  if (base === null) fail(`extract: invalid window: ${window || '(empty)'}`);
@@ -706,7 +719,7 @@ export function dailyExtract(args: string[]): void {
706
719
  for (const ms of windows) {
707
720
  const label = formatWindowMs(ms);
708
721
  const attempt = join(workDir, '10-collect', `.pool-${label}.json`);
709
- kk(['store', 'extract', '--topic', topic, '--window', label, '--out', attempt]);
722
+ kk(['store', 'extract', '--topic', topic, '--window', label, '--out', attempt, ...limit]);
710
723
  const parsed = readJson(attempt);
711
724
  const docs = Array.isArray(parsed) ? (parsed as unknown[]) : [];
712
725
  const estimate = estimateSpokenMinutes(docs, vdriver, ratio.ratio);
@@ -1366,6 +1379,8 @@ export function dailyGenerate(args: string[]): void {
1366
1379
  voicebox: 'voice-gen',
1367
1380
  gemini: 'gemini-tts',
1368
1381
  voxcpm: 'voxcpm-tts',
1382
+ 'vibe-voice': 'vibe-voice-tts',
1383
+ vibevoice: 'vibe-voice-tts',
1369
1384
  };
1370
1385
  let voiceGenerator = VOICE_DRIVERS[vdriver];
1371
1386
  if (!voiceGenerator) {
@@ -1687,13 +1702,18 @@ export function dailyGenerate(args: string[]): void {
1687
1702
  plans = computePlans(voiceGenerator);
1688
1703
  }
1689
1704
 
1690
- // Synthesize sections sequentially (concurrency 1)
1691
- for (const plan of plans) {
1692
- if (!plan.needsSynthesis) {
1693
- console.log(`generate: section cached: ${plan.def.stem}`);
1694
- continue;
1695
- }
1696
- console.log(`generate: synthesizing section: ${plan.def.stem}`);
1705
+ const stampSidecarHash = (plan: (typeof plans)[number]): void => {
1706
+ try {
1707
+ const sidecar = readJson(plan.jsonPath) as Record<string, unknown>;
1708
+ sidecar.hash = plan.hash;
1709
+ if (sidecar.metadata && typeof sidecar.metadata === 'object') {
1710
+ (sidecar.metadata as Record<string, unknown>).hash = plan.hash;
1711
+ }
1712
+ writeJsonText(plan.jsonPath, sidecar);
1713
+ } catch {}
1714
+ };
1715
+
1716
+ const buildSectionDocIn = (plan: (typeof plans)[number]): string => {
1697
1717
  const secScript = { ...script, segments: plan.def.segments };
1698
1718
  const secDocIn = join(secDir, `.${plan.def.stem}_in.json`);
1699
1719
  const doc = {
@@ -1705,40 +1725,111 @@ export function dailyGenerate(args: string[]): void {
1705
1725
  metadata: { voiceProfile },
1706
1726
  };
1707
1727
  writeJsonText(secDocIn, [doc]);
1708
- try {
1709
- // 0269-shaped hardening (20261012): one retry for a failed section. The design already
1710
- // bounds the episode's risk with the pre-flight quota probe and the per-section cache,
1711
- // but a failure that arrives MID-render (a 429 once the window drains, a network blip)
1712
- // still cost the whole episode — the one step nothing can publish without. The retry is
1713
- // cheap and bounded: the successful sections are cache hits, so at most one extra
1714
- // request per failed section is issued, and a persistent failure still fails loud.
1715
- let status = kk(voiceExecutorArgs(voiceGenerator, secDocIn, plan.jsonPath, pluginsPath), {
1716
- env: { VOICE_GEN_MP3: transcodeMp3 },
1728
+ return secDocIn;
1729
+ };
1730
+
1731
+ const BATCH_MANIFEST_CONFIG: Record<string, { envKey: string; filename: string; label: string }> = {
1732
+ 'voxcpm-tts': { envKey: 'VOXCPM_BATCH_MANIFEST', filename: '.voxcpm_batch.json', label: 'voxcpm' },
1733
+ 'vibe-voice-tts': {
1734
+ envKey: 'VIBEVOICE_BATCH_MANIFEST',
1735
+ filename: '.vibe-voice_batch.json',
1736
+ label: 'vibe-voice',
1737
+ },
1738
+ };
1739
+ const batchConfig = BATCH_MANIFEST_CONFIG[voiceGenerator];
1740
+ if (batchConfig && anySynthesisNeeded) {
1741
+ const pendingPlans = plans.filter((p) => p.needsSynthesis);
1742
+ for (const plan of plans) {
1743
+ if (!plan.needsSynthesis) {
1744
+ console.log(`generate: section cached: ${plan.def.stem}`);
1745
+ }
1746
+ }
1747
+ const secInputs = pendingPlans.map((p) => ({ plan: p, inPath: buildSectionDocIn(p) }));
1748
+ const batchManifestPath = join(secDir, batchConfig.filename);
1749
+ const runBatch = (items: typeof secInputs): number => {
1750
+ writeJsonText(
1751
+ batchManifestPath,
1752
+ items.map((item) => ({ in: item.inPath, out: item.plan.jsonPath })),
1753
+ );
1754
+ return kk(voiceExecutorArgs(voiceGenerator, items[0].inPath, items[0].plan.jsonPath, pluginsPath), {
1755
+ env: { VOICE_GEN_MP3: transcodeMp3, [batchConfig.envKey]: batchManifestPath },
1717
1756
  soft: true,
1718
1757
  });
1758
+ };
1759
+ try {
1760
+ console.log(
1761
+ `generate: synthesizing ${secInputs.length} ${batchConfig.label} section(s) in single-worker batch: ${secInputs.map((i) => i.plan.def.stem).join(', ')}`,
1762
+ );
1763
+ let status = runBatch(secInputs);
1764
+ for (const item of secInputs) {
1765
+ if (existsSync(item.plan.jsonPath) && validNativeAudio(item.plan.wavPath)) {
1766
+ stampSidecarHash(item.plan);
1767
+ }
1768
+ }
1719
1769
  if (status !== 0) {
1720
- console.log(
1721
- `generate: section ${plan.def.stem} synthesis failed (exit ${status}) — retrying it once`,
1770
+ const remaining = secInputs.filter(
1771
+ (item) => !existsSync(item.plan.jsonPath) || !validNativeAudio(item.plan.wavPath),
1722
1772
  );
1723
- status = kk(voiceExecutorArgs(voiceGenerator, secDocIn, plan.jsonPath, pluginsPath), {
1724
- env: { VOICE_GEN_MP3: transcodeMp3 },
1725
- soft: true,
1726
- });
1773
+ if (remaining.length > 0) {
1774
+ console.log(
1775
+ `generate: ${batchConfig.label} batch failed (exit ${status}) — retrying ${remaining.length} remaining section(s) once`,
1776
+ );
1777
+ status = runBatch(remaining);
1778
+ for (const item of remaining) {
1779
+ if (existsSync(item.plan.jsonPath) && validNativeAudio(item.plan.wavPath)) {
1780
+ stampSidecarHash(item.plan);
1781
+ }
1782
+ }
1783
+ } else {
1784
+ status = 0;
1785
+ }
1727
1786
  }
1728
1787
  if (status !== 0) {
1729
- failWith(status, `generate: section synthesis failed for ${plan.def.stem}`);
1788
+ failWith(status, `generate: ${batchConfig.label} batch section synthesis failed`);
1730
1789
  }
1731
1790
  } finally {
1732
- rmSync(secDocIn, { force: true });
1791
+ rmSync(batchManifestPath, { force: true });
1792
+ for (const item of secInputs) {
1793
+ rmSync(item.inPath, { force: true });
1794
+ }
1733
1795
  }
1734
- try {
1735
- const sidecar = readJson(plan.jsonPath) as Record<string, unknown>;
1736
- sidecar.hash = plan.hash;
1737
- if (sidecar.metadata && typeof sidecar.metadata === 'object') {
1738
- (sidecar.metadata as Record<string, unknown>).hash = plan.hash;
1796
+ } else {
1797
+ // Synthesize sections sequentially (concurrency 1)
1798
+ for (const plan of plans) {
1799
+ if (!plan.needsSynthesis) {
1800
+ console.log(`generate: section cached: ${plan.def.stem}`);
1801
+ continue;
1739
1802
  }
1740
- writeJsonText(plan.jsonPath, sidecar);
1741
- } catch {}
1803
+ console.log(`generate: synthesizing section: ${plan.def.stem}`);
1804
+ const secDocIn = buildSectionDocIn(plan);
1805
+ try {
1806
+ // 0269-shaped hardening (20261012): one retry for a failed section. The design already
1807
+ // bounds the episode's risk with the pre-flight quota probe and the per-section cache,
1808
+ // but a failure that arrives MID-render (a 429 once the window drains, a network blip)
1809
+ // still cost the whole episode — the one step nothing can publish without. The retry is
1810
+ // cheap and bounded: the successful sections are cache hits, so at most one extra
1811
+ // request per failed section is issued, and a persistent failure still fails loud.
1812
+ let status = kk(voiceExecutorArgs(voiceGenerator, secDocIn, plan.jsonPath, pluginsPath), {
1813
+ env: { VOICE_GEN_MP3: transcodeMp3 },
1814
+ soft: true,
1815
+ });
1816
+ if (status !== 0) {
1817
+ console.log(
1818
+ `generate: section ${plan.def.stem} synthesis failed (exit ${status}) — retrying it once`,
1819
+ );
1820
+ status = kk(voiceExecutorArgs(voiceGenerator, secDocIn, plan.jsonPath, pluginsPath), {
1821
+ env: { VOICE_GEN_MP3: transcodeMp3 },
1822
+ soft: true,
1823
+ });
1824
+ }
1825
+ if (status !== 0) {
1826
+ failWith(status, `generate: section synthesis failed for ${plan.def.stem}`);
1827
+ }
1828
+ } finally {
1829
+ rmSync(secDocIn, { force: true });
1830
+ }
1831
+ stampSidecarHash(plan);
1832
+ }
1742
1833
  }
1743
1834
 
1744
1835
  // Join sections with ffmpeg
@@ -1832,6 +1923,62 @@ export function dailyGenerate(args: string[]): void {
1832
1923
  });
1833
1924
  }
1834
1925
 
1926
+ /**
1927
+ * Delete a published episode's lossless audio intermediates: every section render (the synthesis
1928
+ * cache `dailyGenerate` reads), the joined final, and the `<stem>.intro.wav` merge output.
1929
+ *
1930
+ * Measured 2026-11-20: 987 MB of WAV across six daily runs — 80% of `.works/kk-news-generate` — for
1931
+ * 13–20 MB of MP3 per day. Nothing outside the run reads them: the podcast enclosure, `publish-prep`
1932
+ * and every retry window read the MP3, and `daily-intro` merged its copy inside the run.
1933
+ *
1934
+ * Guarded on the delivered artifact, never on a run status: a missing MP3 means the transcode
1935
+ * failed, and pruning then would turn the rebuild into a paid re-synthesis. Re-entering
1936
+ * `daily-generate` after a prune re-synthesizes the sections — the intended trade, since a
1937
+ * published day is not regenerated.
1938
+ */
1939
+ export function dailyAudioPrune(args: string[]): void {
1940
+ const [workDir = ''] = args;
1941
+ if (!workDir) fail('missing work_dir');
1942
+ const audioDir = join(workDir, '30-audio');
1943
+ if (!existsSync(audioDir)) {
1944
+ console.log(`audio-prune: no ${audioDir} — nothing to prune`);
1945
+ return;
1946
+ }
1947
+ const contentName = readdirSync(audioDir)
1948
+ .filter((entry) => /^\d{8}_11_generate_content\.json$/.test(entry))
1949
+ .sort()
1950
+ .at(-1);
1951
+ if (contentName === undefined) {
1952
+ console.log('audio-prune: no episode content in 30-audio — nothing to prune');
1953
+ return;
1954
+ }
1955
+ const content = readJson(join(audioDir, contentName));
1956
+ const recorded = [metadataOf(content).mp3Path, content?.mp3Path].find(
1957
+ (candidate): candidate is string => typeof candidate === 'string' && candidate !== '',
1958
+ );
1959
+ if (recorded === undefined || !isFile(resolve(recorded))) {
1960
+ console.log('audio-prune: publish MP3 not on disk — keeping the WAV intermediates');
1961
+ return;
1962
+ }
1963
+ const wavs: string[] = [];
1964
+ const collect = (dir: string): void => {
1965
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
1966
+ const path = join(dir, entry.name);
1967
+ if (entry.isDirectory()) collect(path);
1968
+ else if (entry.name.endsWith('.wav')) wavs.push(path);
1969
+ }
1970
+ };
1971
+ collect(audioDir);
1972
+ let freed = 0;
1973
+ for (const wav of wavs) {
1974
+ freed += statSync(wav).size;
1975
+ sted('remove', wav, () => rmSync(wav, { force: true }));
1976
+ }
1977
+ console.log(
1978
+ `audio-prune: removed ${wavs.length} WAV intermediate${wavs.length === 1 ? '' : 's'} (${(freed / 1048576).toFixed(1)} MB), kept ${basename(resolve(recorded))}`,
1979
+ );
1980
+ }
1981
+
1835
1982
  /**
1836
1983
  * 20260917 review #7: prepend the show's 8s intro sting to the generated audio.
1837
1984
  * `intro_music` empty -> skip. Writes `<stem>.intro.wav` (original render kept), points
@@ -2049,6 +2196,74 @@ const WECHAT_BRAND = {
2049
2196
  coverSource: 'library',
2050
2197
  } as const;
2051
2198
 
2199
+ /** A concise key-point bullet injected into the top-of-article `## 今日要点` summary for 公众号. */
2200
+ export interface WechatKeyPoint {
2201
+ label: string;
2202
+ text: string;
2203
+ }
2204
+
2205
+ function stripLeadingH1Heading(body: string): string {
2206
+ return body.replace(/^\s*# +[^\n]+\n+/, '');
2207
+ }
2208
+
2209
+ function wechatKeyPointLabel(title: string): string {
2210
+ const clean = title.replace(/^#+\s+/, '').trim();
2211
+ const firstClause = clean.split(/[::,,。!?!?\-—|]/)[0]?.trim() ?? clean;
2212
+ const chars = Array.from(firstClause);
2213
+ if (chars.length > 0 && chars.length <= 18) return firstClause;
2214
+ return Array.from(clean).slice(0, 18).join('');
2215
+ }
2216
+
2217
+ function extractWechatKeyPoints(
2218
+ planItems: ReadonlyArray<{ title: string; brief?: string }>,
2219
+ articleBody: string,
2220
+ ): WechatKeyPoint[] {
2221
+ const out: WechatKeyPoint[] = [];
2222
+ for (const item of planItems.slice(0, 5)) {
2223
+ const text = (item.brief ?? item.title).replace(/\s+/g, ' ').trim();
2224
+ const label = wechatKeyPointLabel(item.title);
2225
+ if (label !== '' && text !== '') out.push({ label, text });
2226
+ }
2227
+ if (out.length > 0) return out;
2228
+ const sections = stripLeadingH1Heading(articleBody).split(/\n(?=##\s+)/);
2229
+ for (const section of sections) {
2230
+ const match = section.match(/^##\s+(.+)\n+([\s\S]+)$/);
2231
+ if (!match?.[1] || !match[2]) continue;
2232
+ const firstPara = match[2]
2233
+ .split(/\n{2,}/)
2234
+ .map((p) => p.replace(/\s+/g, ' ').trim())
2235
+ .find((p) => p !== '' && !p.startsWith('#') && !p.startsWith('-'));
2236
+ if (!firstPara) continue;
2237
+ const firstSentence = (splitSentences(firstPara, { cjkOnly: true })[0] ?? firstPara).trim();
2238
+ const label = wechatKeyPointLabel(match[1]);
2239
+ if (label !== '' && firstSentence !== '') out.push({ label, text: firstSentence });
2240
+ if (out.length >= 5) break;
2241
+ }
2242
+ return out;
2243
+ }
2244
+
2245
+ function cleanWechatDigest(body: string, keyPoints?: readonly WechatKeyPoint[]): string {
2246
+ const stripMd = (s: string): string =>
2247
+ s
2248
+ .replace(/^#{1,6}\s+/gm, '')
2249
+ .replace(/\*\*([^*]+)\*\*/g, '$1')
2250
+ .replace(/\[([^\]]+)\]\([^)]*\)/g, '$1')
2251
+ .replace(/\s+/g, ' ')
2252
+ .trim();
2253
+ const paragraphs = stripLeadingH1Heading(body)
2254
+ .split(/\n{2,}/)
2255
+ .map((p) => stripMd(p))
2256
+ .filter((p) => p !== '' && !p.startsWith('今日要点') && !p.startsWith('- '));
2257
+ const candidate =
2258
+ paragraphs[0] ??
2259
+ (keyPoints ?? [])
2260
+ .slice(0, 2)
2261
+ .map((kp) => `${kp.label}:${kp.text}`)
2262
+ .join(' ');
2263
+ if (candidate === '') return '';
2264
+ return Array.from(candidate).slice(0, 120).join('');
2265
+ }
2266
+
2052
2267
  /**
2053
2268
  * The 公众号 article payload (task 0327 R1): the article Content plus MP draft enrichment.
2054
2269
  *
@@ -2064,6 +2279,7 @@ export function buildWechatArticleContent(
2064
2279
  coverPath?: string;
2065
2280
  audioPath?: string;
2066
2281
  audioTitle?: string;
2282
+ keyPoints?: readonly WechatKeyPoint[];
2067
2283
  /**
2068
2284
  * The 咸话咸说 closer is an article-only sign-post (operator request 2026-09-29: "appended
2069
2285
  * to the wechat input body only, never the master article"). An audio-first 公众号 播客 post
@@ -2074,9 +2290,10 @@ export function buildWechatArticleContent(
2074
2290
  ): Record<string, unknown> {
2075
2291
  const wechatmp: Record<string, unknown> = {
2076
2292
  original: true,
2077
- // 赞赏 is enabled per episode; the plugin fills the 赞赏账户 only when the platform leaves it
2078
- // empty (it defaults from 作者, operator walk 2026-10-10).
2079
- reward: true,
2293
+ // 2026-11-21 operator decision (A3): keep `reward: false` while the 咸话咸说 account lacks
2294
+ // an authorized 赞赏账户, so WECHATMP_ALLOW_PARTIAL_ENRICH=1 is no longer needed and real
2295
+ // enrichment failures (音频, 原创, 原文链接) fail loud.
2296
+ reward: false,
2080
2297
  author: WECHAT_BRAND.author,
2081
2298
  collection: options.collection,
2082
2299
  // 创作来源 is the platform's AI-declaration entry (WX-03); the label declares AI generation.
@@ -2093,12 +2310,34 @@ export function buildWechatArticleContent(
2093
2310
  audioCoverPath: options.coverPath ?? '',
2094
2311
  }),
2095
2312
  };
2096
- const body = typeof article.body === 'string' ? article.body : '';
2313
+ const rawBody = typeof article.body === 'string' ? article.body : '';
2314
+ const existingMeta = metadataOf(article);
2315
+ if (options.appendOutro === false) {
2316
+ return {
2317
+ ...article,
2318
+ body: rawBody,
2319
+ metadata: {
2320
+ ...existingMeta,
2321
+ ...(options.audioPath === undefined ? {} : { audio: options.audioPath }),
2322
+ publishStatus: options.publishStatus,
2323
+ wechatmp,
2324
+ },
2325
+ };
2326
+ }
2327
+ let formattedBody = stripLeadingH1Heading(rawBody);
2328
+ const keyPoints = (options.keyPoints ?? []).filter((kp) => kp.label.trim() !== '' && kp.text.trim() !== '');
2329
+ if (keyPoints.length > 0 && !/^\s*##\s+今日要点\b/m.test(formattedBody)) {
2330
+ const bullets = keyPoints.map((kp) => `- **${kp.label.trim()}** — ${kp.text.trim()}`).join('\n');
2331
+ formattedBody = `## 今日要点\n\n${bullets}\n\n${formattedBody.trimStart()}`;
2332
+ }
2333
+ const existingDigest = typeof existingMeta.digest === 'string' ? existingMeta.digest.trim() : '';
2334
+ const derivedDigest = existingDigest !== '' ? existingDigest : cleanWechatDigest(rawBody, keyPoints);
2097
2335
  return {
2098
2336
  ...article,
2099
- body: options.appendOutro === false ? body : `${body}${WECHAT_OUTRO}`,
2337
+ body: `${formattedBody}${WECHAT_OUTRO}`,
2100
2338
  metadata: {
2101
- ...metadataOf(article),
2339
+ ...existingMeta,
2340
+ ...(derivedDigest !== '' ? { digest: derivedDigest } : {}),
2102
2341
  // wechatmp-pub's 播客 operation resolves the episode mp3 through the generic media key
2103
2342
  // `metadata.audio` (`modes.ts` resolveMediaPath), while the 文章 audio-embed rail keeps
2104
2343
  // reading `wechatmp.audioPath` — carry both spellings so one variant serves both rows.
@@ -2255,19 +2494,23 @@ function weightedCharWeight(char: string): number {
2255
2494
  }
2256
2495
 
2257
2496
  /** Weighted length of `text` (code-point based, so an emoji counts once before its weight). */
2258
- function weightedLength(text: string): number {
2497
+ export function weightedLength(text: string): number {
2259
2498
  let total = 0;
2260
2499
  for (const char of text) total += weightedCharWeight(char);
2261
2500
  return total;
2262
2501
  }
2263
2502
 
2503
+ /** Platforms where attaching a native image suppresses the URL's clickable Open Graph preview card. */
2504
+ const OG_CARD_PLATFORMS = new Set(['x', 'threads', 'linkedin']);
2505
+
2264
2506
  /**
2265
- * One channel's short copy as a Content (task 0327 R3): the body is the authored post text and the
2266
- * episode cover rides along as `metadata.coverImage`.
2507
+ * One channel's short promo copy as a Content (task 0327 R3; task 0410 episode promo framing):
2508
+ * prepends the frozen episode title and appends the episode listen URL (`{{podcast_url}}`) when
2509
+ * supplied, reserving header/footer budget before truncating copy (X counts URLs at t.co weight 23).
2267
2510
  *
2268
- * The cap is a backstop, not the author: the prompt owns the limit, so an over-length draft is
2269
- * truncated rather than rejected, and `truncatedFrom` records what was cut. Truncation respects the
2270
- * channel's own unit — see {@link SocialLimit}.
2511
+ * Platforms in `OG_CARD_PLATFORMS` (`x`, `threads`, `linkedin`) omit `coverImage` when linking a
2512
+ * podcast URL so their native Open Graph card renders cleanly instead of being suppressed by an
2513
+ * attached image; image-first rails (`weibo`, `jike`) keep `coverImage`.
2271
2514
  */
2272
2515
  export function buildSocialContent(
2273
2516
  copy: string,
@@ -2276,35 +2519,58 @@ export function buildSocialContent(
2276
2519
  limit: SocialLimit;
2277
2520
  coverPath?: string;
2278
2521
  cardPath?: string;
2522
+ episodeTitle?: string;
2523
+ listenUrl?: string;
2279
2524
  },
2280
2525
  ): Record<string, unknown> {
2281
2526
  const trimmed = copy.trim();
2282
- const measure = (text: string): number => (options.limit.weighted === true ? weightedLength(text) : text.length);
2283
- let body = trimmed;
2284
- if (measure(trimmed) > options.limit.max) {
2285
- // Walk code points, adding while the budget holds: a slice by code units could split a
2286
- // surrogate pair or bust the weighted budget on CJK text.
2527
+ const episodeTitle = options.episodeTitle?.trim() ?? '';
2528
+ const listenUrl = options.listenUrl?.trim() ?? '';
2529
+ const header = episodeTitle !== '' && !trimmed.startsWith(episodeTitle) ? `${episodeTitle}\n\n` : '';
2530
+ const footer =
2531
+ listenUrl !== '' && !trimmed.includes(listenUrl)
2532
+ ? options.platform === 'x'
2533
+ ? `\n\n🎧 ${listenUrl}`
2534
+ : `\n\n🎧 完整节目:${listenUrl}`
2535
+ : '';
2536
+
2537
+ const measure = (text: string): number => {
2538
+ if (options.limit.weighted === true) {
2539
+ // X counts URLs via t.co (23 units); reserve 23 for placeholders and full URLs alike.
2540
+ const normalized = text.replace(/(?:https?:\/\/\S+|\{\{(?:podcast|article)_url\}\})/g, 'x'.repeat(23));
2541
+ return weightedLength(normalized);
2542
+ }
2543
+ return text.replace(/\{\{(?:podcast|article)_url\}\}/g, 'x'.repeat(60)).length;
2544
+ };
2545
+
2546
+ const fullMeasure = measure(`${header}${trimmed}${footer}`);
2547
+ let keptCopy = trimmed;
2548
+ if (fullMeasure > options.limit.max) {
2549
+ const copyBudget = Math.max(0, options.limit.max - measure(header) - measure(footer));
2287
2550
  let kept = '';
2288
2551
  let used = 0;
2289
2552
  for (const char of trimmed) {
2290
2553
  const weight = options.limit.weighted === true ? weightedCharWeight(char) : 1;
2291
- if (used + weight > options.limit.max) break;
2554
+ if (used + weight > copyBudget) break;
2292
2555
  kept += char;
2293
2556
  used += weight;
2294
2557
  }
2295
- body = kept;
2558
+ keptCopy = kept;
2296
2559
  }
2297
- const attachedImage = options.cardPath ?? options.coverPath;
2560
+
2561
+ const body = `${header}${keptCopy}${footer}`;
2562
+ const attachCover = !(listenUrl !== '' && OG_CARD_PLATFORMS.has(options.platform));
2563
+ const attachedImage = attachCover ? (options.cardPath ?? options.coverPath) : undefined;
2298
2564
  return {
2299
- title: `${options.platform} · 每日AI乱炖`,
2565
+ title: episodeTitle !== '' ? episodeTitle : `${options.platform} · 每日AI乱炖`,
2300
2566
  format: 'text',
2301
2567
  body,
2302
2568
  metadata: {
2303
2569
  platform: options.platform,
2304
- ...(body === trimmed
2570
+ ...(keptCopy === trimmed
2305
2571
  ? {}
2306
2572
  : {
2307
- truncatedFrom: measure(trimmed),
2573
+ truncatedFrom: fullMeasure,
2308
2574
  truncatedUnit: options.limit.weighted === true ? 'weighted' : 'code_units',
2309
2575
  }),
2310
2576
  ...(attachedImage === undefined ? {} : { coverImage: attachedImage }),
@@ -2345,6 +2611,35 @@ function variantFileName(key: string): string {
2345
2611
  * variant file is wiped before writing, so `30-variants/` after this stage contains only what
2346
2612
  * THIS pass produced.
2347
2613
  */
2614
+ function cardsForPodcast(
2615
+ workDir: string,
2616
+ cardsEnabled: boolean,
2617
+ ): Array<{ index: string; copy: string; status?: string; imagePath?: string }> {
2618
+ if (!cardsEnabled) return [];
2619
+ const parsed = readJson(join(workDir, '25-xhs', 'cards.json'));
2620
+ const rawCards = (parsed as { cards?: unknown } | null)?.cards;
2621
+ if (!Array.isArray(rawCards)) return [];
2622
+ const out: Array<{ index: string; copy: string; status?: string; imagePath?: string }> = [];
2623
+ for (const entry of rawCards) {
2624
+ if (entry === null || typeof entry !== 'object') continue;
2625
+ const card = entry as Record<string, unknown>;
2626
+ const index = typeof card.index === 'string' ? card.index.trim() : String(card.index ?? '').trim();
2627
+ const copy = typeof card.copy === 'string' ? card.copy.trim() : '';
2628
+ if (index === '' || copy === '') continue;
2629
+ const status = typeof card.status === 'string' ? card.status.trim() : undefined;
2630
+ const rawPath = typeof card.imagePath === 'string' ? card.imagePath.trim() : '';
2631
+ const resolvedImg = rawPath !== '' ? (rawPath.startsWith('/') ? rawPath : resolve(workDir, rawPath)) : '';
2632
+ const validImg = resolvedImg !== '' && isFile(resolvedImg) ? resolvedImg : undefined;
2633
+ out.push({
2634
+ index,
2635
+ copy,
2636
+ ...(status === undefined ? {} : { status }),
2637
+ ...(validImg === undefined ? {} : { imagePath: validImg }),
2638
+ });
2639
+ }
2640
+ return out;
2641
+ }
2642
+
2348
2643
  export function dailyBundleVariants(args: string[]): void {
2349
2644
  const [workDir = '', runDate = '', _pluginsPath = '', cardsEnabledArg = '', coverEnabledArg = ''] = args;
2350
2645
  timed(workDir, 'bundle-variants', () => {
@@ -2359,14 +2654,18 @@ export function dailyBundleVariants(args: string[]): void {
2359
2654
  const notesPath = join(workDir, '31-publish', `${runDate}_15_show-notes_show-notes.md`);
2360
2655
  const cardsPath = join(workDir, '25-xhs', 'content.json');
2361
2656
  const coverPath = join(workDir, '23-cover', `${runDate}_07_cover_cover.png`);
2657
+ const socialCoverPath = join(workDir, '23-cover', `${runDate}_07_cover_social.jpg`);
2362
2658
  const socialDir = join(workDir, '26-social');
2363
2659
  const cover = coverEnabledArg !== 'false' && isFile(coverPath) ? resolve(coverPath) : undefined;
2660
+ const socialCover =
2661
+ coverEnabledArg !== 'false' && isFile(socialCoverPath) ? resolve(socialCoverPath) : undefined;
2364
2662
  const links = PLACEHOLDER_LINKS;
2365
2663
  const written: string[] = [];
2366
2664
  const skipped: string[] = [];
2367
2665
 
2368
2666
  const article = readJson(articlePath);
2369
2667
  const prep = readJson(prepPath);
2668
+ const planItems = planItemsForPodcast(workDir, runDate);
2370
2669
  const write = (key: string, content: Record<string, unknown>): void => {
2371
2670
  const file = join(outDir, variantFileName(key));
2372
2671
  sted('write', file, () => writeJsonText(file, content));
@@ -2398,12 +2697,18 @@ export function dailyBundleVariants(args: string[]): void {
2398
2697
  prep !== null && typeof metadataOf(prep).audioFile === 'string'
2399
2698
  ? String(metadataOf(prep).audioFile)
2400
2699
  : undefined;
2700
+ const rawArticleBody =
2701
+ typeof (article as Record<string, unknown>).body === 'string'
2702
+ ? String((article as Record<string, unknown>).body)
2703
+ : '';
2704
+ const wechatKeyPoints = extractWechatKeyPoints(planItems, rawArticleBody);
2401
2705
  write(
2402
2706
  'article@wechatmp-pub',
2403
2707
  buildWechatArticleContent(article, {
2404
2708
  links,
2405
2709
  publishStatus: 'draft',
2406
2710
  collection: '每日AI资讯',
2711
+ keyPoints: wechatKeyPoints,
2407
2712
  ...(cover === undefined ? {} : { coverPath: cover }),
2408
2713
  ...(articleAudio === undefined ? {} : { audioPath: articleAudio, audioTitle: firstArticleLine }),
2409
2714
  }),
@@ -2413,8 +2718,16 @@ export function dailyBundleVariants(args: string[]): void {
2413
2718
  if (prep === null) skipped.push('episode (no publish-prep content)');
2414
2719
  else {
2415
2720
  const showNotes = isFile(notesPath) ? readFileSync(notesPath, 'utf-8') : '';
2416
- write('episode', buildPodcastContent(prep, { showNotes }));
2417
- write('episode@podcast-pub', buildPodcastContent(prep, { showNotes }));
2721
+ const podcastCards = cardsForPodcast(workDir, cardsEnabledArg !== 'false');
2722
+ const podcastMeta: Record<string, unknown> = {
2723
+ ...(planItems.length > 0 ? { planItems } : {}),
2724
+ ...(podcastCards.length > 0 ? { cards: podcastCards } : {}),
2725
+ ...(socialCover === undefined ? {} : { socialImage: socialCover, socialImageEnabled: true }),
2726
+ };
2727
+ const podcastOpts =
2728
+ Object.keys(podcastMeta).length > 0 ? { showNotes, podcast: podcastMeta } : { showNotes };
2729
+ write('episode', buildPodcastContent(prep, podcastOpts));
2730
+ write('episode@podcast-pub', buildPodcastContent(prep, podcastOpts));
2418
2731
  write('episode@xhs-pub', buildXhsEpisodeContent(prep, { publishStatus: 'draft', links }));
2419
2732
  // 公众号 播客 shares the episode with podcast-pub: same audio, same cover, no article body.
2420
2733
  write(
@@ -2465,6 +2778,8 @@ export function dailyBundleVariants(args: string[]): void {
2465
2778
  limit,
2466
2779
  ...(cover === undefined ? {} : { coverPath: cover }),
2467
2780
  ...(cardImage === undefined ? {} : { cardPath: cardImage }),
2781
+ ...(firstArticleLine !== '' ? { episodeTitle: firstArticleLine } : {}),
2782
+ ...(prep !== null ? { listenUrl: links.podcastUrl } : {}),
2468
2783
  }),
2469
2784
  );
2470
2785
  }
@@ -2785,6 +3100,11 @@ export function dailyPublishPrep(args: string[]): void {
2785
3100
  : {}),
2786
3101
  ...(hasCover ? { coverImage: resolvedCover } : {}),
2787
3102
  ...(episode > 0 ? { itunes: { season, episode } } : {}),
3103
+ ...(typeof audioMeta.duration === 'number' &&
3104
+ Number.isFinite(audioMeta.duration) &&
3105
+ audioMeta.duration > 0
3106
+ ? { durationSeconds: audioMeta.duration }
3107
+ : {}),
2788
3108
  },
2789
3109
  options: {
2790
3110
  audioFile,
@@ -3986,8 +4306,9 @@ export function dailyPreflight(args: string[]): void {
3986
4306
  *
3987
4307
  * The gate stays authoritative on `block`/`revise`; the decision can only refuse an outcome the gate
3988
4308
  * already admitted. The decision replaced the judge's self-reported `confidence` field, which the
3989
- * accept guard used to re-parse in shell: its fallback is `escalate`, so missing or garbled evidence
3990
- * lands on a recorded human decision instead of a silent publish.
4309
+ * accept guard used to re-parse in shell: a JUDGED `escalate` now needs a human (the accept guard
4310
+ * refuses it for an unattended run), while an ABSTAINED row (`source: "default"` — the maker failed
4311
+ * and nothing was judged) is named on stderr and leaves the gate's own verdict in charge.
3991
4312
  *
3992
4313
  * Writes `24-script/<date>_09_safety-verdict.status` = `accept`, or `refuse` after naming the
3993
4314
  * offending value on stderr. Never exits non-zero: routing belongs to the transitions.
@@ -4006,9 +4327,22 @@ export function dailySafetyVerdict(args: string[]): void {
4006
4327
  // A missing/unreadable decision row is a refusal, never an approval: `onError: continue` on
4007
4328
  // the decide action is what can leave it absent.
4008
4329
  let verdict = '';
4330
+ // A maker that cannot answer does not silently vanish: it lands on the catalog fallback with
4331
+ // `source: "default"`, so name the abstention where the run report and triage can see it.
4332
+ // (2026-11-20: fm-local refuses safety-report text, so this is the caveat, not an edge case.)
4333
+ let abstention = '';
4009
4334
  if (isFile(decisionFile)) {
4010
- const row = JSON.parse(readFileSync(decisionFile, 'utf-8')) as { value?: unknown };
4335
+ const row = JSON.parse(readFileSync(decisionFile, 'utf-8')) as {
4336
+ value?: unknown;
4337
+ source?: unknown;
4338
+ degraded?: unknown;
4339
+ backend?: unknown;
4340
+ reason?: unknown;
4341
+ };
4011
4342
  verdict = String(row.value ?? '');
4343
+ if (row.source === 'default' || row.degraded === true) {
4344
+ abstention = `kk-daily-safety.judge.decision-abstained: kk-safety-verdict fell back to [${verdict}] (${String(row.backend ?? 'maker')}: ${String(row.reason ?? 'unknown')}) — nothing was judged, so the gate's [${status}] verdict stands alone`;
4345
+ }
4012
4346
  }
4013
4347
  let refusal = '';
4014
4348
  if (!ADMITTED.has(status)) {
@@ -4057,6 +4391,7 @@ export function dailySafetyVerdict(args: string[]): void {
4057
4391
  }
4058
4392
  }
4059
4393
  if (refusal !== '') console.error(refusal);
4394
+ else if (abstention !== '') console.error(abstention);
4060
4395
  sted('write', token, () => writeRaw(token, refusal === '' ? 'accept' : 'refuse'));
4061
4396
  if (evidence !== null) {
4062
4397
  const evidencePath = join(scopeDirOf(workDir, scopeDir), 'safety.json');
@@ -4196,6 +4531,63 @@ export function dailySafetyManifest(args: string[]): void {
4196
4531
  * skill's reference files, never here. 0331: an optional trailing scope_dir re-roots the whole
4197
4532
  * artifact set for the variants review (see the scope machinery above).
4198
4533
  */
4534
+ function buildSafetyDigest(
4535
+ workDir: string,
4536
+ scopeDir: string,
4537
+ runDate: string,
4538
+ targets: string[],
4539
+ digest: string,
4540
+ content: unknown[],
4541
+ ): string {
4542
+ const drafts = isDraftsScope(scopeDir);
4543
+ const lines: string[] = [
4544
+ `# Safety Review Digest (${runDate})`,
4545
+ '',
4546
+ `- Scope: ${drafts ? 'drafts' : 'variants'}`,
4547
+ `- Platforms: ${targets.join(', ')}`,
4548
+ `- Digest: \`${digest}\``,
4549
+ '',
4550
+ ];
4551
+ const maxCharsPerItem = 4000;
4552
+ for (const entry of content) {
4553
+ if (typeof entry === 'string') {
4554
+ if (!isFile(entry)) continue;
4555
+ const raw = readFileSync(entry, 'utf-8');
4556
+ let body = raw;
4557
+ if (entry.endsWith('.yaml') || entry.endsWith('.yml')) {
4558
+ try {
4559
+ const parsed = Bun.YAML.parse(raw) as {
4560
+ title?: string;
4561
+ segments?: Array<{ text?: string; speaker?: string }>;
4562
+ };
4563
+ const segs = Array.isArray(parsed?.segments)
4564
+ ? parsed.segments.map((s, idx) => `${idx + 1}. ${s.text ?? ''}`).join('\n')
4565
+ : raw;
4566
+ body = `${parsed?.title ? `Title: ${parsed.title}\n\n` : ''}${segs}`;
4567
+ } catch {}
4568
+ }
4569
+ const truncated = body.length > maxCharsPerItem ? `${body.slice(0, maxCharsPerItem)}\n…[truncated]` : body;
4570
+ lines.push(`## ${entry} (${raw.length} chars)`, '', truncated, '');
4571
+ } else if (entry && typeof entry === 'object') {
4572
+ const item = entry as { key?: string; path?: string };
4573
+ const rel = item.path ?? '';
4574
+ const abs = rel ? join(workDir, rel) : '';
4575
+ if (!abs || !isFile(abs)) continue;
4576
+ const raw = readFileSync(abs, 'utf-8');
4577
+ let summary = raw;
4578
+ try {
4579
+ const parsed = JSON.parse(raw) as { title?: string; body?: string; format?: string };
4580
+ const text = typeof parsed.body === 'string' ? parsed.body : raw;
4581
+ summary = `Title: ${parsed.title ?? ''}\nFormat: ${parsed.format ?? ''}\n\n${text}`;
4582
+ } catch {}
4583
+ const truncated =
4584
+ summary.length > maxCharsPerItem ? `${summary.slice(0, maxCharsPerItem)}\n…[truncated]` : summary;
4585
+ lines.push(`## ${item.key ?? rel} (${rel}, ${raw.length} chars)`, '', truncated, '');
4586
+ }
4587
+ }
4588
+ return lines.join('\n');
4589
+ }
4590
+
4199
4591
  export function dailySafetyPrep(args: string[]): void {
4200
4592
  const [workDir = '', runDate = '', platforms = '', scopeDir = ''] = args;
4201
4593
  const drafts = isDraftsScope(scopeDir);
@@ -4224,6 +4616,7 @@ export function dailySafetyPrep(args: string[]): void {
4224
4616
  }
4225
4617
  for (const name of [
4226
4618
  'safety-review_report.json',
4619
+ 'safety-review_digest.md',
4227
4620
  'safety-judge_verdict.json',
4228
4621
  'safety-judge_status.txt',
4229
4622
  'safety-judge_stamp.json',
@@ -4241,17 +4634,23 @@ export function dailySafetyPrep(args: string[]): void {
4241
4634
  if (isFile(stale)) unlinkSync(stale);
4242
4635
  }
4243
4636
  const request = scopeArtifact(workDir, scopeDir, runDate, 'safety-review_request.json');
4637
+ const digestFile = scopeArtifact(workDir, scopeDir, runDate, 'safety-review_digest.md');
4244
4638
  const targets = platforms
4245
4639
  .split(',')
4246
4640
  .map((platform) => platform.trim())
4247
4641
  .filter(Boolean);
4642
+ const content = scopeContent(workDir, scopeDir, runDate);
4643
+ sted('write', digestFile, () =>
4644
+ writeRaw(digestFile, buildSafetyDigest(workDir, scopeDir, runDate, targets, digest, content)),
4645
+ );
4248
4646
  sted('write', request, () =>
4249
4647
  writeJsonText(request, {
4250
4648
  digest,
4649
+ digestFile,
4251
4650
  platforms: targets,
4252
4651
  mode: 'detect-only',
4253
4652
  scope: drafts ? 'drafts' : 'variants',
4254
- content: scopeContent(workDir, scopeDir, runDate),
4653
+ content,
4255
4654
  }),
4256
4655
  );
4257
4656
  });
@@ -4465,7 +4864,7 @@ function spokenCharRate(vdriver: string): number {
4465
4864
  // voxcpm measured the same day on a 12-section zh+en episode: 6,772 chars / 1,297.7 s speech
4466
4865
  // (5.19 字/秒). The provisional 5.6 borrowed from voicebox let the fit budget reach 7,683 chars
4467
4866
  // — 24.6 min of audio, 18 s inside the 25-min gate. 5.2 puts a full-budget script at ~22.9 min.
4468
- if (vdriver === 'voxcpm') return 5.2;
4867
+ if (vdriver === 'voxcpm' || vdriver === 'vibe-voice' || vdriver === 'vibevoice') return 5.2;
4469
4868
  return 5.6;
4470
4869
  }
4471
4870
 
@@ -5885,6 +6284,25 @@ export function newsLocalizeValidate(args: string[]): void {
5885
6284
  );
5886
6285
  continue;
5887
6286
  }
6287
+ // Rewrite safe compound retired/wrong-locale series brands before freezing and refuse
6288
+ // any unrewritable retired brand or wrong-language show name that check:seo rejects.
6289
+ const normalized = normalizeSeriesNames(raw, locale);
6290
+ const activeText = normalized.markdown;
6291
+ if (activeText !== raw) {
6292
+ sted('write', file, () => writeRaw(file, activeText));
6293
+ }
6294
+ if (normalized.remaining.length > 0) {
6295
+ problems.push(`${locale}: retired series name (${normalized.remaining.join(', ')})`);
6296
+ continue;
6297
+ }
6298
+ if (locale === 'ja' && /ごった煮|寄せ鍋|咸话咸说|Salty Talk/i.test(activeText)) {
6299
+ problems.push(`${locale}: retired series or wrong-language show name in translated body`);
6300
+ continue;
6301
+ }
6302
+ if (locale === 'en' && /咸话咸说|咸話咸説/.test(activeText)) {
6303
+ problems.push(`${locale}: wrong-language show name in translated body`);
6304
+ continue;
6305
+ }
5888
6306
  accepted.push(locale);
5889
6307
  }
5890
6308
  if (problems.length > 0) {