@gobing-ai/knowledge-kit 0.1.23 → 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 (84) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +117 -56
  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 +9 -9
  11. package/plugins/generations/image-gen/dist/index.js +9 -9
  12. package/plugins/generations/music-gen/dist/index.js +16 -16
  13. package/plugins/generations/news-report-gen/dist/index.js +12 -12
  14. package/plugins/generations/vibe-voice-tts/dist/index.js +9 -9
  15. package/plugins/generations/voice-gen/dist/index.js +9 -9
  16. package/plugins/generations/voxcpm-tts/dist/index.js +9 -9
  17. package/plugins/ingestions/aihot-ingest/dist/index.js +12 -12
  18. package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
  19. package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
  20. package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
  21. package/plugins/ingestions/web-search/dist/index.js +10 -10
  22. package/plugins/kk/plugin.json +1 -1
  23. package/plugins/kk/publish-presets/daily-ai-voice.json +16 -16
  24. package/plugins/kk/scripts/cover-compositor.ts +104 -26
  25. package/plugins/kk/scripts/daily-stages.ts +217 -33
  26. package/plugins/kk/scripts/kk-workflow-stages.ts +144 -6
  27. package/plugins/kk/scripts/series-names.ts +16 -3
  28. package/plugins/kk/skills/news-editorial/SKILL.md +1 -1
  29. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
  30. package/plugins/kk/workflows/kk-news-generate.yaml +3 -0
  31. package/plugins/publishings/bilibili-pub/dist/index.js +22 -22
  32. package/plugins/publishings/bilibili-pub/dist/profile-check.js +22 -22
  33. package/plugins/publishings/cnblogs-pub/dist/index.js +22 -22
  34. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +22 -22
  35. package/plugins/publishings/csdn-pub/dist/index.js +22 -22
  36. package/plugins/publishings/csdn-pub/dist/profile-check.js +22 -22
  37. package/plugins/publishings/emdash-pub/dist/index.js +9 -9
  38. package/plugins/publishings/infoq-pub/dist/index.js +22 -22
  39. package/plugins/publishings/infoq-pub/dist/profile-check.js +22 -22
  40. package/plugins/publishings/jike-pub/dist/index.js +22 -22
  41. package/plugins/publishings/jike-pub/dist/profile-check.js +22 -22
  42. package/plugins/publishings/juejin-pub/dist/index.js +22 -22
  43. package/plugins/publishings/juejin-pub/dist/profile-check.js +22 -22
  44. package/plugins/publishings/linkedin-pub/dist/index.js +82 -24
  45. package/plugins/publishings/linkedin-pub/dist/profile-check.js +22 -22
  46. package/plugins/publishings/linkedin-pub/src/index.ts +93 -6
  47. package/plugins/publishings/medium-pub/dist/index.js +9 -9
  48. package/plugins/publishings/podcast-pub/dist/index.js +240 -37
  49. package/plugins/publishings/podcast-pub/src/index.ts +154 -3
  50. package/plugins/publishings/podcast-pub/src/seo.ts +25 -8
  51. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +93 -23
  52. package/plugins/publishings/podcast-pub/src/show-notes.ts +26 -6
  53. package/plugins/publishings/qiita-pub/dist/index.js +9 -9
  54. package/plugins/publishings/shipinhao-pub/dist/index.js +23 -23
  55. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +23 -23
  56. package/plugins/publishings/shipinhao-pub/src/selectors.ts +2 -1
  57. package/plugins/publishings/sspai-pub/dist/index.js +22 -22
  58. package/plugins/publishings/sspai-pub/dist/profile-check.js +22 -22
  59. package/plugins/publishings/substack-pub/dist/index.js +22 -22
  60. package/plugins/publishings/substack-pub/dist/profile-check.js +22 -22
  61. package/plugins/publishings/surfdash-pub/dist/index.js +200 -92
  62. package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
  63. package/plugins/publishings/surfdash-pub/src/index.ts +94 -75
  64. package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
  65. package/plugins/publishings/surfdash-pub/src/patch.ts +28 -23
  66. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
  67. package/plugins/publishings/threads-pub/dist/index.js +36 -22
  68. package/plugins/publishings/threads-pub/dist/profile-check.js +27 -22
  69. package/plugins/publishings/threads-pub/src/post-rail.ts +20 -0
  70. package/plugins/publishings/wechatmp-pub/dist/index.js +180 -64
  71. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +27 -23
  72. package/plugins/publishings/wechatmp-pub/src/enrich.ts +56 -10
  73. package/plugins/publishings/wechatmp-pub/src/flow.ts +155 -43
  74. package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
  75. package/plugins/publishings/weibo-pub/dist/index.js +22 -22
  76. package/plugins/publishings/weibo-pub/dist/profile-check.js +22 -22
  77. package/plugins/publishings/x-pub/dist/index.js +51 -45
  78. package/plugins/publishings/x-pub/dist/profile-check.js +22 -22
  79. package/plugins/publishings/x-pub/src/post-rail.ts +40 -47
  80. package/plugins/publishings/xhs-pub/dist/index.js +22 -22
  81. package/plugins/publishings/xhs-pub/dist/profile-check.js +22 -22
  82. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +22 -22
  83. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +22 -22
  84. package/plugins/publishings/zenn-pub/dist/index.js +9 -9
@@ -2196,6 +2196,74 @@ const WECHAT_BRAND = {
2196
2196
  coverSource: 'library',
2197
2197
  } as const;
2198
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
+
2199
2267
  /**
2200
2268
  * The 公众号 article payload (task 0327 R1): the article Content plus MP draft enrichment.
2201
2269
  *
@@ -2211,6 +2279,7 @@ export function buildWechatArticleContent(
2211
2279
  coverPath?: string;
2212
2280
  audioPath?: string;
2213
2281
  audioTitle?: string;
2282
+ keyPoints?: readonly WechatKeyPoint[];
2214
2283
  /**
2215
2284
  * The 咸话咸说 closer is an article-only sign-post (operator request 2026-09-29: "appended
2216
2285
  * to the wechat input body only, never the master article"). An audio-first 公众号 播客 post
@@ -2221,17 +2290,10 @@ export function buildWechatArticleContent(
2221
2290
  ): Record<string, unknown> {
2222
2291
  const wechatmp: Record<string, unknown> = {
2223
2292
  original: true,
2224
- // 赞赏 is NOT requested: measured 2026-11-20 on a fresh 文章 draft, this account's row renders
2225
- // `不开启 … 无法开启赞赏,因为还没有赞赏账户授权给本公众号` with a 0×0 box — the platform has not
2226
- // authorized a 赞赏 account for 咸话咸说, so no selector, probe or retry can enable it, and asking
2227
- // for it only converted a healthy draft into `ok:false` until `WECHATMP_ALLOW_PARTIAL_ENRICH=1`
2228
- // was set by hand (11-16, 11-18, 11-19). Evidence:
2229
- // `.spur/run/dogfood/2026-11-20-wechatmp-reward/survey-dom.json` (5806: reward row text + box).
2230
- // If the operator opens 赞赏 later, flip this line back together with the probe in
2231
- // `plugins/publishings/wechatmp-pub/src/enrich.ts` (`REWARD_STATE`).
2232
- // 2026-11-20 operator request: 赞赏 ON. `WECHATMP_ALLOW_PARTIAL_ENRICH=1` is set, so a
2233
- // still-unauthorized account warns once and keeps the healthy draft instead of failing it.
2234
- 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,
2235
2297
  author: WECHAT_BRAND.author,
2236
2298
  collection: options.collection,
2237
2299
  // 创作来源 is the platform's AI-declaration entry (WX-03); the label declares AI generation.
@@ -2248,12 +2310,34 @@ export function buildWechatArticleContent(
2248
2310
  audioCoverPath: options.coverPath ?? '',
2249
2311
  }),
2250
2312
  };
2251
- 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);
2252
2335
  return {
2253
2336
  ...article,
2254
- body: options.appendOutro === false ? body : `${body}${WECHAT_OUTRO}`,
2337
+ body: `${formattedBody}${WECHAT_OUTRO}`,
2255
2338
  metadata: {
2256
- ...metadataOf(article),
2339
+ ...existingMeta,
2340
+ ...(derivedDigest !== '' ? { digest: derivedDigest } : {}),
2257
2341
  // wechatmp-pub's 播客 operation resolves the episode mp3 through the generic media key
2258
2342
  // `metadata.audio` (`modes.ts` resolveMediaPath), while the 文章 audio-embed rail keeps
2259
2343
  // reading `wechatmp.audioPath` — carry both spellings so one variant serves both rows.
@@ -2410,19 +2494,23 @@ function weightedCharWeight(char: string): number {
2410
2494
  }
2411
2495
 
2412
2496
  /** Weighted length of `text` (code-point based, so an emoji counts once before its weight). */
2413
- function weightedLength(text: string): number {
2497
+ export function weightedLength(text: string): number {
2414
2498
  let total = 0;
2415
2499
  for (const char of text) total += weightedCharWeight(char);
2416
2500
  return total;
2417
2501
  }
2418
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
+
2419
2506
  /**
2420
- * One channel's short copy as a Content (task 0327 R3): the body is the authored post text and the
2421
- * 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).
2422
2510
  *
2423
- * The cap is a backstop, not the author: the prompt owns the limit, so an over-length draft is
2424
- * truncated rather than rejected, and `truncatedFrom` records what was cut. Truncation respects the
2425
- * 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`.
2426
2514
  */
2427
2515
  export function buildSocialContent(
2428
2516
  copy: string,
@@ -2431,35 +2519,58 @@ export function buildSocialContent(
2431
2519
  limit: SocialLimit;
2432
2520
  coverPath?: string;
2433
2521
  cardPath?: string;
2522
+ episodeTitle?: string;
2523
+ listenUrl?: string;
2434
2524
  },
2435
2525
  ): Record<string, unknown> {
2436
2526
  const trimmed = copy.trim();
2437
- const measure = (text: string): number => (options.limit.weighted === true ? weightedLength(text) : text.length);
2438
- let body = trimmed;
2439
- if (measure(trimmed) > options.limit.max) {
2440
- // Walk code points, adding while the budget holds: a slice by code units could split a
2441
- // 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));
2442
2550
  let kept = '';
2443
2551
  let used = 0;
2444
2552
  for (const char of trimmed) {
2445
2553
  const weight = options.limit.weighted === true ? weightedCharWeight(char) : 1;
2446
- if (used + weight > options.limit.max) break;
2554
+ if (used + weight > copyBudget) break;
2447
2555
  kept += char;
2448
2556
  used += weight;
2449
2557
  }
2450
- body = kept;
2558
+ keptCopy = kept;
2451
2559
  }
2452
- 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;
2453
2564
  return {
2454
- title: `${options.platform} · 每日AI乱炖`,
2565
+ title: episodeTitle !== '' ? episodeTitle : `${options.platform} · 每日AI乱炖`,
2455
2566
  format: 'text',
2456
2567
  body,
2457
2568
  metadata: {
2458
2569
  platform: options.platform,
2459
- ...(body === trimmed
2570
+ ...(keptCopy === trimmed
2460
2571
  ? {}
2461
2572
  : {
2462
- truncatedFrom: measure(trimmed),
2573
+ truncatedFrom: fullMeasure,
2463
2574
  truncatedUnit: options.limit.weighted === true ? 'weighted' : 'code_units',
2464
2575
  }),
2465
2576
  ...(attachedImage === undefined ? {} : { coverImage: attachedImage }),
@@ -2500,6 +2611,35 @@ function variantFileName(key: string): string {
2500
2611
  * variant file is wiped before writing, so `30-variants/` after this stage contains only what
2501
2612
  * THIS pass produced.
2502
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
+
2503
2643
  export function dailyBundleVariants(args: string[]): void {
2504
2644
  const [workDir = '', runDate = '', _pluginsPath = '', cardsEnabledArg = '', coverEnabledArg = ''] = args;
2505
2645
  timed(workDir, 'bundle-variants', () => {
@@ -2514,14 +2654,18 @@ export function dailyBundleVariants(args: string[]): void {
2514
2654
  const notesPath = join(workDir, '31-publish', `${runDate}_15_show-notes_show-notes.md`);
2515
2655
  const cardsPath = join(workDir, '25-xhs', 'content.json');
2516
2656
  const coverPath = join(workDir, '23-cover', `${runDate}_07_cover_cover.png`);
2657
+ const socialCoverPath = join(workDir, '23-cover', `${runDate}_07_cover_social.jpg`);
2517
2658
  const socialDir = join(workDir, '26-social');
2518
2659
  const cover = coverEnabledArg !== 'false' && isFile(coverPath) ? resolve(coverPath) : undefined;
2660
+ const socialCover =
2661
+ coverEnabledArg !== 'false' && isFile(socialCoverPath) ? resolve(socialCoverPath) : undefined;
2519
2662
  const links = PLACEHOLDER_LINKS;
2520
2663
  const written: string[] = [];
2521
2664
  const skipped: string[] = [];
2522
2665
 
2523
2666
  const article = readJson(articlePath);
2524
2667
  const prep = readJson(prepPath);
2668
+ const planItems = planItemsForPodcast(workDir, runDate);
2525
2669
  const write = (key: string, content: Record<string, unknown>): void => {
2526
2670
  const file = join(outDir, variantFileName(key));
2527
2671
  sted('write', file, () => writeJsonText(file, content));
@@ -2553,12 +2697,18 @@ export function dailyBundleVariants(args: string[]): void {
2553
2697
  prep !== null && typeof metadataOf(prep).audioFile === 'string'
2554
2698
  ? String(metadataOf(prep).audioFile)
2555
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);
2556
2705
  write(
2557
2706
  'article@wechatmp-pub',
2558
2707
  buildWechatArticleContent(article, {
2559
2708
  links,
2560
2709
  publishStatus: 'draft',
2561
2710
  collection: '每日AI资讯',
2711
+ keyPoints: wechatKeyPoints,
2562
2712
  ...(cover === undefined ? {} : { coverPath: cover }),
2563
2713
  ...(articleAudio === undefined ? {} : { audioPath: articleAudio, audioTitle: firstArticleLine }),
2564
2714
  }),
@@ -2568,8 +2718,16 @@ export function dailyBundleVariants(args: string[]): void {
2568
2718
  if (prep === null) skipped.push('episode (no publish-prep content)');
2569
2719
  else {
2570
2720
  const showNotes = isFile(notesPath) ? readFileSync(notesPath, 'utf-8') : '';
2571
- write('episode', buildPodcastContent(prep, { showNotes }));
2572
- 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));
2573
2731
  write('episode@xhs-pub', buildXhsEpisodeContent(prep, { publishStatus: 'draft', links }));
2574
2732
  // 公众号 播客 shares the episode with podcast-pub: same audio, same cover, no article body.
2575
2733
  write(
@@ -2620,6 +2778,8 @@ export function dailyBundleVariants(args: string[]): void {
2620
2778
  limit,
2621
2779
  ...(cover === undefined ? {} : { coverPath: cover }),
2622
2780
  ...(cardImage === undefined ? {} : { cardPath: cardImage }),
2781
+ ...(firstArticleLine !== '' ? { episodeTitle: firstArticleLine } : {}),
2782
+ ...(prep !== null ? { listenUrl: links.podcastUrl } : {}),
2623
2783
  }),
2624
2784
  );
2625
2785
  }
@@ -2940,6 +3100,11 @@ export function dailyPublishPrep(args: string[]): void {
2940
3100
  : {}),
2941
3101
  ...(hasCover ? { coverImage: resolvedCover } : {}),
2942
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
+ : {}),
2943
3108
  },
2944
3109
  options: {
2945
3110
  audioFile,
@@ -6119,6 +6284,25 @@ export function newsLocalizeValidate(args: string[]): void {
6119
6284
  );
6120
6285
  continue;
6121
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
+ }
6122
6306
  accepted.push(locale);
6123
6307
  }
6124
6308
  if (problems.length > 0) {
@@ -58,7 +58,7 @@ import {
58
58
  } from 'node:fs';
59
59
  import { homedir } from 'node:os';
60
60
  import { basename, dirname, join, relative, resolve } from 'node:path';
61
- import { compositeCover } from './cover-compositor';
61
+ import { compositeCover, compositeSocialCover } from './cover-compositor';
62
62
 
63
63
  export const SCRIPTS_DIR = import.meta.dir;
64
64
  export const VALIDATE_SIDECAR = 'validate-voicescript.ts';
@@ -1093,7 +1093,10 @@ export function coverNormalizeBody(workDir: string, runDate: string): void {
1093
1093
  const briefPath = join(workDir, '23-cover', `${runDate}_07_cover-brief.json`);
1094
1094
  const headline = briefHeadline(briefPath);
1095
1095
  if (headline !== '') {
1096
+ const socialOut = join(workDir, '23-cover', `${runDate}_07_cover_social.jpg`);
1096
1097
  try {
1098
+ // Render the 1200×630 OG card FIRST from the raw AI background before overwriting `out`.
1099
+ compositeSocialCover({ backgroundImagePath: out, headline, outputPath: socialOut });
1097
1100
  compositeCover({ backgroundImagePath: out, headline, outputPath: out });
1098
1101
  } catch (error) {
1099
1102
  failWith(1, `cover composite: ${(error as Error).message}`);
@@ -1612,6 +1615,23 @@ function publishMatrixPatchSurfdash(args: string[]): void {
1612
1615
  );
1613
1616
  const podMeta = (podTarget.metadata ?? {}) as Record<string, unknown>;
1614
1617
  const runDate = String(readJson(join(publishDir, `outcome.${window}.json`))?.runDate ?? '');
1618
+ const compactDate = runDate.replaceAll('-', '');
1619
+ const bundle = readJson(join(workDir, 'bundle.json')) as { episode?: { title?: unknown } } | null;
1620
+ const identity =
1621
+ compactDate.length === 8
1622
+ ? (readJson(join(workDir, '21-plan', `${compactDate}_05_script_identity.json`)) as {
1623
+ title?: unknown;
1624
+ status?: unknown;
1625
+ } | null)
1626
+ : null;
1627
+ const episodeTitle =
1628
+ typeof podMeta.episodeTitle === 'string' && podMeta.episodeTitle !== ''
1629
+ ? podMeta.episodeTitle
1630
+ : identity?.status === 'frozen' && typeof identity.title === 'string'
1631
+ ? identity.title
1632
+ : typeof bundle?.episode?.title === 'string'
1633
+ ? bundle.episode.title
1634
+ : '';
1615
1635
  const payload = join(publishDir, 'patch-surfdash.payload.json');
1616
1636
  sted('write', payload, () =>
1617
1637
  writeJqText(payload, {
@@ -1621,11 +1641,12 @@ function publishMatrixPatchSurfdash(args: string[]): void {
1621
1641
  postPath,
1622
1642
  coverUrl: podReal && typeof podMeta.imageUrl === 'string' ? podMeta.imageUrl : '',
1623
1643
  showNotesUrl: podReal && typeof podTarget.url === 'string' ? podTarget.url : '',
1624
- ...(runDate.length === 8
1625
- ? { dateIso: `${runDate.slice(0, 4)}-${runDate.slice(4, 6)}-${runDate.slice(6, 8)}` }
1626
- : runDate.length === 10
1627
- ? { dateIso: runDate }
1628
- : {}),
1644
+ ...(episodeTitle !== '' ? { episodeTitle } : {}),
1645
+ ...(compactDate.length === 8
1646
+ ? {
1647
+ dateIso: `${compactDate.slice(0, 4)}-${compactDate.slice(4, 6)}-${compactDate.slice(6, 8)}`,
1648
+ }
1649
+ : {}),
1629
1650
  },
1630
1651
  }),
1631
1652
  );
@@ -1661,6 +1682,120 @@ function publishMatrixPatchSurfdash(args: string[]): void {
1661
1682
  });
1662
1683
  }
1663
1684
 
1685
+ /**
1686
+ * `publish-matrix-patch-podcast`: patch the real surfdash article URL into an already-published
1687
+ * podcast microfeed item (`complete-article` link), once both Tier 0 targets have real succeeded
1688
+ * receipts in the window. Derives `4-publish/patch-podcast.payload.json` + `.result.json`.
1689
+ */
1690
+ function publishMatrixPatchPodcast(args: string[]): void {
1691
+ const flag = (name: string): string | undefined => {
1692
+ const i = args.indexOf(name);
1693
+ return i >= 0 ? args[i + 1] : undefined;
1694
+ };
1695
+ const workDir = args[0] ?? '';
1696
+ const window = flag('--window');
1697
+ if (workDir === '' || window === undefined || window === '') {
1698
+ failWith(1, 'usage: publish-matrix-patch-podcast <work_dir> --window <w>');
1699
+ }
1700
+ const publishDir = join(workDir, '4-publish');
1701
+ const resultPath = join(publishDir, 'patch-podcast.result.json');
1702
+ const writeResult = (value: Record<string, unknown>): void => {
1703
+ sted('write', resultPath, () => writeJqText(resultPath, value));
1704
+ };
1705
+ const receipt = (id: string): Record<string, unknown> | null =>
1706
+ readJson(join(publishDir, 'receipts', `${id}.json`));
1707
+ const aggregateTarget = (receiptPath: string | undefined): Record<string, unknown> => {
1708
+ const aggregate = receiptPath === undefined ? null : readJson(receiptPath);
1709
+ const targets = aggregate?.targets;
1710
+ if (!Array.isArray(targets) || targets.length === 0 || targets[0] === null || typeof targets[0] !== 'object') {
1711
+ return {};
1712
+ }
1713
+ return targets[0] as Record<string, unknown>;
1714
+ };
1715
+ timed(workDir, 'publish-matrix-patch-podcast', () => {
1716
+ const outcome = readJson(join(publishDir, `outcome.${window}.json`)) as {
1717
+ rows?: Array<{ id?: string }>;
1718
+ } | null;
1719
+ const rowId = (prefix: string): string | undefined =>
1720
+ (outcome?.rows ?? []).map((row) => row.id ?? '').find((id) => id.startsWith(prefix));
1721
+ const podId = rowId('podcast-pub');
1722
+ const sdId = rowId('surfdash-pub');
1723
+ if (podId === undefined || sdId === undefined) {
1724
+ const error = 'skipped: requires both podcast-pub and surfdash-pub targets in this window';
1725
+ writeResult({ ok: false, target: 'podcast-pub', error });
1726
+ console.error(`patch-podcast: ${error}`);
1727
+ return;
1728
+ }
1729
+ const podReceipt = receipt(podId);
1730
+ const podReal = podReceipt !== null && podReceipt?.dummy !== true && podReceipt?.status === 'succeeded';
1731
+ const podTarget = aggregateTarget(
1732
+ typeof podReceipt?.aggregatePath === 'string' ? podReceipt.aggregatePath : undefined,
1733
+ );
1734
+ const podMeta = (podTarget.metadata ?? {}) as Record<string, unknown>;
1735
+ const itemId =
1736
+ typeof podTarget.id === 'string' && podTarget.id !== ''
1737
+ ? podTarget.id
1738
+ : typeof podMeta.itemId === 'string' && podMeta.itemId !== ''
1739
+ ? podMeta.itemId
1740
+ : '';
1741
+ const sdReceipt = receipt(sdId);
1742
+ const sdReal = sdReceipt !== null && sdReceipt?.dummy !== true && sdReceipt?.status === 'succeeded';
1743
+ const sdTarget = aggregateTarget(
1744
+ typeof sdReceipt?.aggregatePath === 'string' ? sdReceipt.aggregatePath : undefined,
1745
+ );
1746
+ const sdMeta = (sdTarget.metadata ?? {}) as Record<string, unknown>;
1747
+ const postPath = typeof sdMeta.postPath === 'string' ? sdMeta.postPath : '';
1748
+ const articleUrl =
1749
+ typeof sdMeta.articleUrl === 'string' && /^https?:\/\//i.test(sdMeta.articleUrl)
1750
+ ? sdMeta.articleUrl
1751
+ : typeof sdTarget.url === 'string' && /^https?:\/\//i.test(sdTarget.url)
1752
+ ? sdTarget.url
1753
+ : '';
1754
+ if (!podReal || itemId === '' || !sdReal || (postPath === '' && articleUrl === '')) {
1755
+ const error =
1756
+ !podReal || itemId === ''
1757
+ ? 'skipped: no real podcast publish receipt/itemId — nothing to patch'
1758
+ : 'skipped: no real surfdash publish receipt/postPath — nothing to patch';
1759
+ writeResult({ ok: false, target: 'podcast-pub', error });
1760
+ console.error(`patch-podcast: ${error}`);
1761
+ return;
1762
+ }
1763
+ const payload = join(publishDir, 'patch-podcast.payload.json');
1764
+ sted('write', payload, () =>
1765
+ writeJqText(payload, {
1766
+ title: 'patch-article-link',
1767
+ format: 'markdown',
1768
+ body: '',
1769
+ options: {
1770
+ operation: 'patch-article-link',
1771
+ itemId,
1772
+ ...(postPath !== '' ? { postPath } : {}),
1773
+ ...(articleUrl !== '' ? { articleUrl } : {}),
1774
+ },
1775
+ }),
1776
+ );
1777
+ if (process.env.KK_PODCAST_PATCH_OFFLINE === '1') {
1778
+ writeResult({ ok: false, target: 'podcast-pub', error: 'skipped: offline (KK_PODCAST_PATCH_OFFLINE=1)' });
1779
+ console.error(
1780
+ 'patch-podcast: offline — payload derived, plugin patch skipped (KK_PODCAST_PATCH_OFFLINE=1)',
1781
+ );
1782
+ return;
1783
+ }
1784
+ const status = kk(['executor', 'run', 'podcast-pub', '--in', payload, '--out', resultPath], {
1785
+ unset: NESTED_SPUR_UNSET,
1786
+ soft: true,
1787
+ });
1788
+ const result = readJson(resultPath);
1789
+ if (result?.ok === true) {
1790
+ console.error(`patch-podcast: ${String(result.message ?? 'patched')}`);
1791
+ return;
1792
+ }
1793
+ console.error(
1794
+ `patch-podcast: WARNING: ${String(result?.error ?? `podcast-pub patch-article-link exited ${status}`)}`,
1795
+ );
1796
+ });
1797
+ }
1798
+
1664
1799
  /**
1665
1800
  * The day's zh post path when this run's content sits uncommitted in the surfdash checkout.
1666
1801
  *
@@ -2139,6 +2274,9 @@ if (import.meta.main)
2139
2274
  case 'publish-matrix-patch-surfdash':
2140
2275
  publishMatrixPatchSurfdash(rest);
2141
2276
  break;
2277
+ case 'publish-matrix-patch-podcast':
2278
+ publishMatrixPatchPodcast(rest);
2279
+ break;
2142
2280
  case 'daily-run-report':
2143
2281
  dailyRunReport(rest);
2144
2282
  break;
@@ -34,7 +34,19 @@ export const DAILY_SERIES_NAMES: Record<DailyLocale, DailySeriesNames> = {
34
34
  * Retired series spellings that must never be emitted in any locale. ごった煮 is deliberately absent:
35
35
  * it is ordinary ja vocabulary, so rewriting or failing on it would butcher legitimate prose.
36
36
  */
37
- const RETIRED_SERIES_NAMES = ['毎日AIブレンド', 'Daily AI Medley', 'Daily AI Briefing'] as const;
37
+ const RETIRED_SERIES_NAMES = [
38
+ '毎日AIブレンド',
39
+ '毎日AIごった煮',
40
+ 'AIごった煮',
41
+ '毎日AI寄せ鍋',
42
+ 'デイリーAIニュース',
43
+ 'Daily AI Medley',
44
+ 'Daily AI Briefing',
45
+ 'Daily AI Hotchpotch',
46
+ 'Daily AI Hodgepodge',
47
+ '每日AI资讯',
48
+ '每日 AI 资讯',
49
+ ] as const;
38
50
 
39
51
  /** All canonical series tokens — each locale's own name is correct there, wrong-locale elsewhere. */
40
52
  const SERIES_TOKENS = ['每日AI乱炖', 'Daily AI Stew', 'デイリーAIシチュー'] as const;
@@ -66,6 +78,7 @@ function retiredIn(text: string, locale: DailyLocale): string[] {
66
78
  ...SERIES_TOKENS.filter((token) => token !== canonical).map(tokenRe),
67
79
  SHORT_ZH_FORM,
68
80
  /\bhodgepodge\b/gi,
81
+ /\bhotchpotch\b/gi,
69
82
  ];
70
83
  const found: string[] = [];
71
84
  for (const pattern of patterns) {
@@ -112,8 +125,8 @@ export function normalizeSeriesNames(
112
125
  if (locale === 'en') {
113
126
  // The observed en intro phrase — rewritten as a phrase first so the bare word never
114
127
  // produces "daily AI Daily AI Stew".
115
- out = out.replace(/\byour daily AI hodgepodge\b/gi, 'Your Daily AI Stew');
116
- out = out.replace(/\bdaily AI hodgepodge\b/gi, 'Daily AI Stew');
128
+ out = out.replace(/\byour daily AI h(?:odge|otch)podge\b/gi, 'Your Daily AI Stew');
129
+ out = out.replace(/\bdaily AI h(?:odge|otch)podge\b/gi, 'Daily AI Stew');
117
130
  }
118
131
  for (const token of [...RETIRED_SERIES_NAMES, ...SERIES_TOKENS.filter((name) => name !== canonical)]) {
119
132
  out = out.replace(tokenRe(token), () => canonical);
@@ -102,7 +102,7 @@ At the episode level, write:
102
102
  admission drops every one of them the point is withheld instead of being published unsupported. Omitting
103
103
  `sourceIds` means "the admitted lead", which is the usual case.
104
104
  - `cards`: `{ "title": "≤20字总标题", "body": "中文导语段落 + 3-5个话题标签" }` for the episode card series.
105
- - `social`: `{ "short": "≤140字 X/Threads 短帖", "long": "≤500字 微博/LinkedIn 长帖" }` (plain text, no markdown headings, no emoji spam, grounded in the plan).
105
+ - `social`: `{ "short": "≤100字 X/Threads/微博推广短帖钩子(bundle-variants 会统一前置节目标题、末尾注入 {{podcast_url}};微博附首张卡片图,X/Threads 仅发链接以展示 1200×630 OG 卡片)", "long": "≤300字 LinkedIn 精选要点推广(禁止长文 Digest,bundle-variants 会前置标题与 {{podcast_url}} 并仅发链接以展示 OG 卡片)" }` (plain text, no markdown headings, no emoji spam, grounded in the plan).
106
106
 
107
107
  Output:
108
108
 
@@ -82,7 +82,7 @@
82
82
  - `outro`:简短收束语,接在固定致谢之前,不超过 150 字。跨条目的综评也在这里:当天有真实可归纳的共性才写,价值不够或时长紧张时省略,只留一句收束;不为了「串起来」生造主题,不把综评写成第二个开场。
83
83
  - `cover`:头版具象视觉内容。字符串形态是英文画面场景(不超过 240 字符,不含文字、数字、商标、旗帜或可辨识真人);0385 R4 起要冻结节目标题就必须写对象形态 `{ "scene": "…", "headline": "…", "sourceIds": ["<计划条目 id>"] }`:`headline`(必填,不超过 25 字)是本期冻结的**当日要点**,单行白话,不带日期、期号、栏目名;`scene` 可选,沿用同一英文画面契约(缺省时封面图回落默认画面主题);`sourceIds` 可选,写明这条要点依据的计划条目 id(通常是头条),一旦准入把这些条目全部丢弃,这条要点就被撤下而不是带着无依据的标题发布;不写 `sourceIds` 时默认取准入后的头条条目。只写字符串形态不会冻结要点,标题只能回落旧标题。
84
84
  - `cards`:小红书图文笔记总标题 `title`(不超过 20 字)与导语 `body`,单条卡片标题 `card.copy`(不超过 12 字)、2–4 条短要点 `card.points`、英文画面 `card.subject`。
85
- - `social`:面向 X / Threads 的短帖 `short`(不超过 140 字)与面向微博 / LinkedIn 的长帖 `long`(不超过 500 字)。
85
+ - `social`:面向 X / Threads / 微博 的推广短帖钩子 `short`(不超过 100 字)与面向 LinkedIn 的精选要点推广 `long`(不超过 300 字;禁止写成多段长文摘要),`bundle-variants` 会统一前置冻结节目标题、末尾注入 `{{podcast_url}}` 播客页链接;仅微博附首张卡片图,X / Threads / LinkedIn 不附图片以触发 `1200×630` Open Graph 链接预览卡。
86
86
 
87
87
  ## 节目标题与节目身份(0385 R4)
88
88
 
@@ -116,8 +116,8 @@
116
116
  "coverHeadline": 25,
117
117
  "cardCopy": 12,
118
118
  "cardTitle": 20,
119
- "socialShort": 140,
120
- "socialLong": 500
119
+ "socialShort": 100,
120
+ "socialLong": 300
121
121
  },
122
122
  "banned": [
123
123
  "在各种技术光环背后,正是这样专注而不知疲倦的底层攻坚者,为今天整个大模型生态奠定了最坚实的技术基石。",