@gobing-ai/knowledge-kit 0.1.19 → 0.1.22

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 (147) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/board/collect/index.js +1 -0
  3. package/dist/board/daily-voice/index.js +1315 -264
  4. package/dist/board/itc/index.js +1 -0
  5. package/dist/index.js +14674 -8775
  6. package/package.json +1 -1
  7. package/plugins/generations/dailynews-gen/dist/index.js +285 -16
  8. package/plugins/generations/dailynews-gen/src/editorial-claims.ts +215 -0
  9. package/plugins/generations/dailynews-gen/src/index.ts +23 -4
  10. package/plugins/generations/dailynews-gen/src/script-builder.ts +10 -3
  11. package/plugins/generations/dailynews-gen/src/script-plan.ts +74 -14
  12. package/plugins/generations/image-gen/README.md +31 -31
  13. package/plugins/generations/image-gen/assets/sample/provenance.json +314 -0
  14. package/plugins/generations/image-gen/config.example.yaml +3 -0
  15. package/plugins/generations/image-gen/dist/index.js +154 -14
  16. package/plugins/generations/image-gen/presets/SOURCE.md +65 -0
  17. package/plugins/generations/image-gen/scripts/eval-style-presets.ts +513 -0
  18. package/plugins/generations/image-gen/scripts/gen-samples.ts +57 -7
  19. package/plugins/generations/image-gen/src/presets.ts +6 -5
  20. package/plugins/generations/image-gen/src/providers/h3-local.ts +196 -0
  21. package/plugins/generations/image-gen/src/providers/types.ts +11 -1
  22. package/plugins/generations/music-gen/README.md +277 -0
  23. package/plugins/generations/music-gen/dist/index.js +23544 -0
  24. package/plugins/generations/music-gen/package.json +24 -0
  25. package/plugins/generations/music-gen/plugin.json +23 -0
  26. package/plugins/generations/music-gen/presets/SOURCE.md +39 -0
  27. package/plugins/generations/music-gen/presets/formats/clip.yaml +21 -0
  28. package/plugins/generations/music-gen/presets/formats/jingle.yaml +22 -0
  29. package/plugins/generations/music-gen/presets/formats/loop.yaml +21 -0
  30. package/plugins/generations/music-gen/presets/formats/song.yaml +31 -0
  31. package/plugins/generations/music-gen/presets/formats/underscore.yaml +22 -0
  32. package/plugins/generations/music-gen/presets/themes/ambient-tech.yaml +30 -0
  33. package/plugins/generations/music-gen/presets/themes/cinematic.yaml +30 -0
  34. package/plugins/generations/music-gen/presets/themes/lofi.yaml +30 -0
  35. package/plugins/generations/music-gen/presets/themes/synthwave.yaml +30 -0
  36. package/plugins/generations/music-gen/scripts/gen-preset-index.ts +181 -0
  37. package/plugins/generations/music-gen/scripts/resolve-preset.ts +64 -0
  38. package/plugins/generations/music-gen/src/adapter/index.ts +35 -0
  39. package/plugins/generations/music-gen/src/adapter/instance.ts +904 -0
  40. package/plugins/generations/music-gen/src/adapter/offline.ts +124 -0
  41. package/plugins/generations/music-gen/src/artifact.ts +223 -0
  42. package/plugins/generations/music-gen/src/audio/checks.ts +618 -0
  43. package/plugins/generations/music-gen/src/audio/master.ts +267 -0
  44. package/plugins/generations/music-gen/src/audio/measure.ts +507 -0
  45. package/plugins/generations/music-gen/src/audio/profile.ts +131 -0
  46. package/plugins/generations/music-gen/src/audio.ts +122 -0
  47. package/plugins/generations/music-gen/src/brief.ts +191 -0
  48. package/plugins/generations/music-gen/src/config.ts +451 -0
  49. package/plugins/generations/music-gen/src/content.ts +199 -0
  50. package/plugins/generations/music-gen/src/digest.ts +100 -0
  51. package/plugins/generations/music-gen/src/index.ts +147 -0
  52. package/plugins/generations/music-gen/src/job.ts +131 -0
  53. package/plugins/generations/music-gen/src/plugin.ts +371 -0
  54. package/plugins/generations/music-gen/src/presets.ts +918 -0
  55. package/plugins/generations/music-gen/src/render.ts +87 -0
  56. package/plugins/generations/music-gen/src/request.ts +102 -0
  57. package/plugins/generations/music-gen/src/spend.ts +495 -0
  58. package/plugins/generations/music-gen/tsconfig.json +8 -0
  59. package/plugins/kk/config.example.yaml +3 -0
  60. package/plugins/kk/decisions/extract/ai-news.yaml +5 -2
  61. package/plugins/kk/plugin.json +1 -1
  62. package/plugins/kk/publish-presets/daily-ai-voice.json +48 -7
  63. package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +2 -1
  64. package/plugins/kk/scripts/cover-compositor.ts +380 -32
  65. package/plugins/kk/scripts/daily-cover-mock.ts +40 -3
  66. package/plugins/kk/scripts/daily-stages.ts +897 -34
  67. package/plugins/kk/scripts/episode-identity.ts +180 -0
  68. package/plugins/kk/scripts/kk-workflow-stages.ts +37 -1
  69. package/plugins/kk/scripts/music-stages.ts +624 -0
  70. package/plugins/kk/scripts/news-editorial-ledger.ts +906 -0
  71. package/plugins/kk/scripts/source-citation.ts +187 -0
  72. package/plugins/kk/scripts/topic-selection-attempts.ts +446 -0
  73. package/plugins/kk/scripts/topic-selection-calibration.ts +161 -0
  74. package/plugins/kk/skills/content-judge/SKILL.md +11 -6
  75. package/plugins/kk/skills/content-judge/references/music-quality-rubric.md +147 -0
  76. package/plugins/kk/skills/content-judge/references/rubrics.md +15 -0
  77. package/plugins/kk/skills/content-safety/SKILL.md +12 -0
  78. package/plugins/kk/skills/image-authoring/SKILL.md +7 -3
  79. package/plugins/kk/skills/image-authoring/references/providers.md +27 -0
  80. package/plugins/kk/skills/image-authoring/references/style-extraction.md +1 -1
  81. package/plugins/kk/skills/music-authoring/SKILL.md +276 -0
  82. package/plugins/kk/skills/music-authoring/references/judge-input.md +117 -0
  83. package/plugins/kk/skills/news-editorial/SKILL.md +102 -15
  84. package/plugins/kk/skills/news-editorial/references/selection.md +4 -0
  85. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +58 -11
  86. package/plugins/kk/skills/publish/SKILL.md +11 -0
  87. package/plugins/kk/skills/web-automation/SKILL.md +31 -1
  88. package/plugins/kk/workflows/kk-collect.yaml +8 -4
  89. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +10 -9
  90. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +11 -9
  91. package/plugins/kk/workflows/kk-music.yaml +328 -0
  92. package/plugins/kk/workflows/kk-news-generate.yaml +58 -3
  93. package/plugins/publishings/bilibili-pub/dist/index.js +11 -1
  94. package/plugins/publishings/bilibili-pub/dist/profile-check.js +11 -1
  95. package/plugins/publishings/cnblogs-pub/dist/index.js +11 -1
  96. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +11 -1
  97. package/plugins/publishings/csdn-pub/dist/index.js +11 -1
  98. package/plugins/publishings/csdn-pub/dist/profile-check.js +11 -1
  99. package/plugins/publishings/infoq-pub/dist/index.js +11 -1
  100. package/plugins/publishings/infoq-pub/dist/profile-check.js +11 -1
  101. package/plugins/publishings/jike-pub/dist/index.js +11 -1
  102. package/plugins/publishings/jike-pub/dist/profile-check.js +11 -1
  103. package/plugins/publishings/juejin-pub/dist/index.js +11 -1
  104. package/plugins/publishings/juejin-pub/dist/profile-check.js +11 -1
  105. package/plugins/publishings/linkedin-pub/dist/index.js +54 -7
  106. package/plugins/publishings/linkedin-pub/dist/profile-check.js +43 -6
  107. package/plugins/publishings/linkedin-pub/src/index.ts +52 -6
  108. package/plugins/publishings/podcast-pub/dist/index.js +586 -20
  109. package/plugins/publishings/podcast-pub/src/corrections.ts +509 -0
  110. package/plugins/publishings/podcast-pub/src/index.ts +257 -5
  111. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +240 -0
  112. package/plugins/publishings/podcast-pub/src/show-notes.ts +69 -13
  113. package/plugins/publishings/shipinhao-pub/dist/index.js +437 -32
  114. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +14 -2
  115. package/plugins/publishings/shipinhao-pub/plugin.json +1 -1
  116. package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +492 -0
  117. package/plugins/publishings/shipinhao-pub/src/flow.ts +227 -12
  118. package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -0
  119. package/plugins/publishings/sspai-pub/dist/index.js +11 -1
  120. package/plugins/publishings/sspai-pub/dist/profile-check.js +11 -1
  121. package/plugins/publishings/substack-pub/dist/index.js +11 -1
  122. package/plugins/publishings/substack-pub/dist/profile-check.js +11 -1
  123. package/plugins/publishings/surfdash-pub/dist/index.js +122 -28
  124. package/plugins/publishings/surfdash-pub/src/digest-check.ts +7 -3
  125. package/plugins/publishings/surfdash-pub/src/index.ts +159 -25
  126. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +37 -4
  127. package/plugins/publishings/threads-pub/dist/index.js +9206 -296
  128. package/plugins/publishings/threads-pub/dist/profile-check.js +21149 -0
  129. package/plugins/publishings/threads-pub/package.json +3 -1
  130. package/plugins/publishings/threads-pub/plugin.json +6 -1
  131. package/plugins/publishings/threads-pub/src/index.ts +8 -1
  132. package/plugins/publishings/threads-pub/src/post-rail.ts +357 -0
  133. package/plugins/publishings/threads-pub/src/profile-check.ts +17 -0
  134. package/plugins/publishings/wechatmp-pub/dist/index.js +18 -1
  135. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +11 -1
  136. package/plugins/publishings/wechatmp-pub/src/flow.ts +13 -0
  137. package/plugins/publishings/weibo-pub/dist/index.js +57 -3
  138. package/plugins/publishings/weibo-pub/dist/profile-check.js +11 -1
  139. package/plugins/publishings/weibo-pub/src/index.ts +74 -2
  140. package/plugins/publishings/x-pub/dist/index.js +274 -44
  141. package/plugins/publishings/x-pub/dist/profile-check.js +14 -2
  142. package/plugins/publishings/x-pub/src/index.ts +15 -1
  143. package/plugins/publishings/x-pub/src/post-rail.ts +334 -0
  144. package/plugins/publishings/xhs-pub/dist/index.js +11 -1
  145. package/plugins/publishings/xhs-pub/dist/profile-check.js +11 -1
  146. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +11 -1
  147. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +11 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobing-ai/knowledge-kit",
3
- "version": "0.1.19",
3
+ "version": "0.1.22",
4
4
  "description": "An ingest → create → publish content pipeline CLI (Bun).",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12258,9 +12258,241 @@ if (false) {}
12258
12258
  var CJK_TERMINATORS = new Set(["\u3002", "\uFF01", "\uFF1F"]);
12259
12259
  var LATIN_TERMINATORS = new Set([".", "!", "?"]);
12260
12260
  var ATTACHED_CLOSERS = new Set(["\u201D", "\u2019", "\u300D", "\u300F", "\uFF09", ")", '"', "'"]);
12261
+ var OPEN_PAIRS = {
12262
+ "\u300C": "\u300D",
12263
+ "\u300E": "\u300F",
12264
+ "\u201C": "\u201D",
12265
+ "\uFF08": "\uFF09",
12266
+ "(": ")"
12267
+ };
12268
+ var CLOSE_PAIRS = {
12269
+ "\u300D": "\u300C",
12270
+ "\u300F": "\u300E",
12271
+ "\u201D": "\u201C",
12272
+ "\uFF09": "\uFF08",
12273
+ ")": "("
12274
+ };
12275
+ function splitSentences(text, options = {}) {
12276
+ if (!text || typeof text !== "string")
12277
+ return [];
12278
+ const results = [];
12279
+ let sentenceStart = 0;
12280
+ let stack = [];
12281
+ let i = 0;
12282
+ const isTerminator = (c) => CJK_TERMINATORS.has(c) || options.cjkOnly !== true && LATIN_TERMINATORS.has(c);
12283
+ while (i < text.length) {
12284
+ const ch = text[i];
12285
+ if (isTerminator(ch)) {
12286
+ let termEnd = i;
12287
+ let hasCjkTerm = false;
12288
+ let hasLatinTerm = false;
12289
+ while (termEnd < text.length) {
12290
+ const termChar = text[termEnd];
12291
+ if (!termChar || !isTerminator(termChar)) {
12292
+ break;
12293
+ }
12294
+ if (CJK_TERMINATORS.has(termChar))
12295
+ hasCjkTerm = true;
12296
+ if (LATIN_TERMINATORS.has(termChar))
12297
+ hasLatinTerm = true;
12298
+ termEnd++;
12299
+ }
12300
+ let closerEnd = termEnd;
12301
+ const tempStack = [...stack];
12302
+ while (closerEnd < text.length) {
12303
+ const closer = text[closerEnd];
12304
+ if (!closer || !ATTACHED_CLOSERS.has(closer)) {
12305
+ break;
12306
+ }
12307
+ const top = tempStack[tempStack.length - 1];
12308
+ if (top !== undefined && top === closer) {
12309
+ tempStack.pop();
12310
+ } else if (CLOSE_PAIRS[closer]) {
12311
+ const idx = tempStack.lastIndexOf(closer);
12312
+ if (idx >= 0)
12313
+ tempStack.splice(idx, 1);
12314
+ }
12315
+ closerEnd++;
12316
+ }
12317
+ let isBoundary = false;
12318
+ if (tempStack.length === 0) {
12319
+ if (hasCjkTerm) {
12320
+ isBoundary = true;
12321
+ } else if (hasLatinTerm) {
12322
+ const nextChar = text[closerEnd];
12323
+ if (closerEnd === text.length || nextChar !== undefined && /\s/.test(nextChar)) {
12324
+ isBoundary = true;
12325
+ }
12326
+ }
12327
+ }
12328
+ if (isBoundary) {
12329
+ const sentence = text.slice(sentenceStart, closerEnd).trim();
12330
+ if (sentence.length > 0) {
12331
+ results.push(sentence);
12332
+ }
12333
+ sentenceStart = closerEnd;
12334
+ stack = tempStack;
12335
+ i = closerEnd;
12336
+ continue;
12337
+ }
12338
+ }
12339
+ const openMatch = OPEN_PAIRS[ch];
12340
+ const closeMatch = CLOSE_PAIRS[ch];
12341
+ if (openMatch) {
12342
+ stack.push(openMatch);
12343
+ } else if (closeMatch) {
12344
+ const idx = stack.lastIndexOf(ch);
12345
+ if (idx >= 0)
12346
+ stack.splice(idx, 1);
12347
+ }
12348
+ i++;
12349
+ }
12350
+ if (sentenceStart < text.length) {
12351
+ const tail = text.slice(sentenceStart).trim();
12352
+ if (tail.length > 0) {
12353
+ results.push(tail);
12354
+ }
12355
+ }
12356
+ return results;
12357
+ }
12261
12358
  // ../../plugins/generations/dailynews-gen/src/index.ts
12262
12359
  init_dist();
12263
12360
 
12361
+ // ../../plugins/generations/dailynews-gen/src/editorial-claims.ts
12362
+ var COMMENTARY_MARKERS = [
12363
+ "\u6211\u770B",
12364
+ "\u6211\u89C9\u5F97",
12365
+ "\u6211\u8BA4\u4E3A",
12366
+ "\u5728\u6211\u770B\u6765",
12367
+ "\u4E2A\u4EBA\u89C9\u5F97",
12368
+ "\u6211\u4F1A",
12369
+ "\u6211\u5EFA\u8BAE",
12370
+ "\u6211\u503E\u5411"
12371
+ ];
12372
+ var EXPLANATION_MARKERS = ["\u4E5F\u5C31\u662F\u8BF4", "\u4E5F\u5C31\u662F", "\u5373", "\u76F8\u5F53\u4E8E", "\u7B80\u5355\u8BF4", "\u901A\u4FD7\u8BB2", "\u610F\u601D\u662F"];
12373
+ var JARGON_TERMS = [
12374
+ "\u63A8\u7406\u5F15\u64CE",
12375
+ "\u63A8\u7406\u6210\u672C",
12376
+ "\u4E0A\u4E0B\u6587\u7F13\u5B58",
12377
+ "KV cache",
12378
+ "\u5FAE\u8C03",
12379
+ "\u84B8\u998F",
12380
+ "distillation",
12381
+ "token",
12382
+ "\u7B97\u5B50",
12383
+ "\u53C2\u6570\u91CF",
12384
+ "embedding"
12385
+ ];
12386
+ var ATTRIBUTION_MARKERS = [
12387
+ "\u636E",
12388
+ "\u6765\u6E90",
12389
+ "\u5B98\u65B9",
12390
+ "\u516C\u544A",
12391
+ "\u8D22\u62A5",
12392
+ "\u8BC9\u72B6",
12393
+ "\u91C7\u8BBF",
12394
+ "\u62A5\u9053",
12395
+ "\u8868\u793A",
12396
+ "\u79F0",
12397
+ "\u5BA3\u5E03",
12398
+ "\u62AB\u9732",
12399
+ "\u56DE\u5E94",
12400
+ "\u62A5\u544A",
12401
+ "\u65B0\u95FB\u7A3F",
12402
+ "\u535A\u5BA2",
12403
+ "\u63F4\u5F15",
12404
+ "\u8DEF\u900F",
12405
+ "\u5F6D\u535A",
12406
+ "The Information",
12407
+ "http"
12408
+ ];
12409
+ var QUANTIFIED_RE = /\d+(?:[.,]\d+)*\s*(?:%|\uFF05|\u4EBF\u7F8E\u5143|\u4E07\u7F8E\u5143|\u4EBF\u5143|\u4E07\u5143|\u4EBF|\u4E07|\u500D|\u7F8E\u5143|\u5143|\u4EBA|\u5BB6|\u6B21|\u4E2A\u6708|\u5E74|\u5929|\u53F0)/u;
12410
+ var SUPERLATIVE_RE = /\u6700[\u9AD8\u4F4E\u5927\u5F3A\u5FEB\u591A\u597D\u65B0]|\u7B2C\u4E00|\u552F\u4E00|\u9996\u4E2A|\u9996\u6B3E|\u9996\u5BB6|\u9996\u5EA6|\u5168\u7403\u9996|\u53F2\u4E0A/iu;
12411
+ function hasAttribution(sentence) {
12412
+ const lower = sentence.toLowerCase();
12413
+ return ATTRIBUTION_MARKERS.some((marker) => lower.includes(marker.toLowerCase()));
12414
+ }
12415
+ function hasClaim(sentence) {
12416
+ return QUANTIFIED_RE.test(sentence) || SUPERLATIVE_RE.test(sentence);
12417
+ }
12418
+ function hasGloss(sentence) {
12419
+ if (EXPLANATION_MARKERS.some((marker) => sentence.includes(marker)))
12420
+ return true;
12421
+ return /\uFF08[^\uFF09]{2,}\uFF09|\([^)]{2,}\)/u.test(sentence) || /\u2014\u2014[^\u2014]{2,}/u.test(sentence);
12422
+ }
12423
+ function commentaryHits(text) {
12424
+ const hits = [];
12425
+ for (const marker of COMMENTARY_MARKERS) {
12426
+ let from = text.indexOf(marker);
12427
+ while (from !== -1) {
12428
+ hits.push({ marker });
12429
+ from = text.indexOf(marker, from + marker.length);
12430
+ }
12431
+ }
12432
+ return hits;
12433
+ }
12434
+ function analyzeEditorialClaims(plan) {
12435
+ const findings = [];
12436
+ for (const item of plan.items) {
12437
+ const lead = item.lead.trim();
12438
+ const insight = item.insight?.trim() ?? "";
12439
+ const hits = commentaryHits(`${lead}${insight}`);
12440
+ if (hits.length > 1) {
12441
+ findings.push({
12442
+ code: "r3:commentary-repeat",
12443
+ itemId: item.id,
12444
+ message: `commentary markers used ${hits.length} times (${hits.map((hit) => hit.marker).join(", ")}); at most one per item`
12445
+ });
12446
+ }
12447
+ const leaked = commentaryHits(lead);
12448
+ if (leaked.length > 0) {
12449
+ findings.push({
12450
+ code: "r3:commentary-in-facts",
12451
+ itemId: item.id,
12452
+ message: `commentary marker (${leaked.map((hit) => hit.marker).join(", ")}) in the fact sentence; move the judgement into insight`
12453
+ });
12454
+ }
12455
+ if (insight !== "") {
12456
+ const sentences = splitSentences(insight, { cjkOnly: true });
12457
+ if (sentences.length > 1) {
12458
+ findings.push({
12459
+ code: "r3:insight-multi-sentence",
12460
+ itemId: item.id,
12461
+ message: `insight is ${sentences.length} sentences; the per-item comment is at most one`
12462
+ });
12463
+ }
12464
+ }
12465
+ for (const sentence of splitSentences(lead, { cjkOnly: true })) {
12466
+ if (hasClaim(sentence) && !hasAttribution(sentence)) {
12467
+ findings.push({
12468
+ code: "r3:unattributed-claim",
12469
+ itemId: item.id,
12470
+ message: `claim without attribution: \u300C${sentence}\u300D \u2014 name the source (\u636E/\u516C\u544A/\u8D22\u62A5/\u516C\u53F8\u79F0) or drop the figure`
12471
+ });
12472
+ }
12473
+ }
12474
+ for (const [slot, text] of [
12475
+ ["lead", lead],
12476
+ ["insight", insight]
12477
+ ]) {
12478
+ if (text === "")
12479
+ continue;
12480
+ for (const sentence of splitSentences(text, { cjkOnly: true })) {
12481
+ const lowered = sentence.toLowerCase();
12482
+ const term = JARGON_TERMS.find((candidate) => lowered.includes(candidate.toLowerCase()));
12483
+ if (term !== undefined && !hasGloss(sentence)) {
12484
+ findings.push({
12485
+ code: "r2:unexplained-jargon",
12486
+ itemId: item.id,
12487
+ message: `${slot} introduces \u300C${term}\u300D with no plain-language gloss (\u4E5F\u5C31\u662F\u8BF4/\u5373/\u76F8\u5F53\u4E8E, or a \u62EC\u53F7/\u7834\u6298\u53F7 explanation)`
12488
+ });
12489
+ }
12490
+ }
12491
+ }
12492
+ }
12493
+ return findings;
12494
+ }
12495
+
12264
12496
  // ../../plugins/generations/dailynews-gen/src/script-builder.ts
12265
12497
  init_zod();
12266
12498
  var EffectConfigSchema = object({
@@ -12530,7 +12762,8 @@ function buildNewsVoiceScript(docs, options) {
12530
12762
  const lead = planItem ? `${planItem.lead}\u3010${cleanTitle}\u3011\u3002` : isZh ? idx === 0 ? `\u9996\u5148\u6765\u804A\u804A\u5927\u5BB6\u975E\u5E38\u5173\u6CE8\u7684\u3010${cleanTitle}\u3011\u3002` : isLast ? `\u6700\u540E\uFF0C\u6765\u770B\u770B\u4ECA\u5929\u7684\u6700\u540E\u4E00\u6761\u8D44\u8BAF\uFF0C\u3010${cleanTitle}\u3011\u3002` : `\u63A5\u7740\u6211\u4EEC\u628A\u76EE\u5149\u8F6C\u5411\u53E6\u4E00\u6761\u91CD\u8981\u8FDB\u5C55\uFF0C\u3010${cleanTitle}\u3011\u3002` : idx === 0 ? `First up today, let's look at ${cleanTitle}.` : isLast ? `And finally today, let's wrap up with ${cleanTitle}.` : `Next, turning our attention to ${cleanTitle}.`;
12531
12763
  const normalizedLead = normalizeBroadcastText(lead, isZh);
12532
12764
  const normalizedBody = cleanBody === "" ? "" : normalizeBroadcastText(cleanBody, isZh);
12533
- const insight = planItem?.insight ?? synthesizePersonalUnderstanding(cleanTitle, cleanBody, isZh, usedInsights);
12765
+ const plannedInsight = planItem?.insight?.trim() ?? "";
12766
+ const insight = planItem !== undefined ? plannedInsight === "" ? null : plannedInsight : synthesizePersonalUnderstanding(cleanTitle, cleanBody, isZh, usedInsights);
12534
12767
  const normalizedInsight = insight === null ? null : normalizeBroadcastText(insight, isZh);
12535
12768
  const factText = isZh ? `${normalizedLead}${normalizedBody}` : `${normalizedLead} ${normalizedBody}`;
12536
12769
  for (const chunk of splitFactText(factText)) {
@@ -12701,9 +12934,15 @@ var ScriptPlanItemCardSchema = object({
12701
12934
  var ScriptPlanItemSchema = object({
12702
12935
  id: string2().min(1),
12703
12936
  lead: string2().min(1),
12704
- insight: string2().min(1),
12937
+ insight: string2().optional(),
12705
12938
  card: ScriptPlanItemCardSchema.optional()
12706
12939
  });
12940
+ var ScriptPlanCoverObjectSchema = object({
12941
+ scene: string2().min(1).optional(),
12942
+ headline: string2().min(1),
12943
+ sourceIds: array(string2().min(1)).optional()
12944
+ });
12945
+ var ScriptPlanCoverSchema = union([string2().min(1), ScriptPlanCoverObjectSchema]);
12707
12946
  var ScriptPlanExclusionSchema = object({
12708
12947
  id: string2().min(1),
12709
12948
  reason: string2().min(1)
@@ -12722,7 +12961,7 @@ var ScriptPlanSchema = object({
12722
12961
  outro: string2().min(1),
12723
12962
  items: array(ScriptPlanItemSchema),
12724
12963
  excluded: array(ScriptPlanExclusionSchema).optional(),
12725
- cover: string2().min(1).optional(),
12964
+ cover: ScriptPlanCoverSchema.optional(),
12726
12965
  cards: ScriptPlanCardsSchema.optional(),
12727
12966
  social: ScriptPlanSocialSchema.optional()
12728
12967
  });
@@ -12733,6 +12972,7 @@ var StyleContractSchema = object({
12733
12972
  lead: number2().int().positive(),
12734
12973
  insight: number2().int().positive(),
12735
12974
  cover: number2().int().positive().optional(),
12975
+ coverHeadline: number2().int().positive().optional(),
12736
12976
  cardCopy: number2().int().positive().optional(),
12737
12977
  cardTitle: number2().int().positive().optional(),
12738
12978
  socialShort: number2().int().positive().optional(),
@@ -12801,8 +13041,16 @@ function validateScriptPlan(plan, docs, style, preExcludedIds) {
12801
13041
  errors.push({ itemId: "episode", rule: "cap:intro" });
12802
13042
  if (valid.outro.length > style.caps.outro)
12803
13043
  errors.push({ itemId: "episode", rule: "cap:outro" });
12804
- if (valid.cover !== undefined && valid.cover.length > (style.caps.cover ?? 240)) {
12805
- errors.push({ itemId: "episode", rule: "cap:cover" });
13044
+ if (typeof valid.cover === "string") {
13045
+ if (valid.cover.length > (style.caps.cover ?? 240))
13046
+ errors.push({ itemId: "episode", rule: "cap:cover" });
13047
+ } else if (valid.cover !== undefined) {
13048
+ if (valid.cover.scene !== undefined && valid.cover.scene.length > (style.caps.cover ?? 240)) {
13049
+ errors.push({ itemId: "episode", rule: "cap:cover" });
13050
+ }
13051
+ if (valid.cover.headline.length > (style.caps.coverHeadline ?? 25)) {
13052
+ errors.push({ itemId: "episode", rule: "cap:coverHeadline" });
13053
+ }
12806
13054
  }
12807
13055
  if (valid.cards !== undefined && valid.cards.title.length > (style.caps.cardTitle ?? 20)) {
12808
13056
  errors.push({ itemId: "episode", rule: "cap:cardTitle" });
@@ -12818,20 +13066,24 @@ function validateScriptPlan(plan, docs, style, preExcludedIds) {
12818
13066
  for (const item of valid.items) {
12819
13067
  if (item.lead.length > style.caps.lead)
12820
13068
  errors.push({ itemId: item.id, rule: "cap:lead" });
12821
- if (item.insight.length > style.caps.insight)
13069
+ const insight = item.insight?.trim() ?? "";
13070
+ if (insight.length > style.caps.insight)
12822
13071
  errors.push({ itemId: item.id, rule: "cap:insight" });
12823
13072
  if (item.card !== undefined && item.card.copy.length > (style.caps.cardCopy ?? 12)) {
12824
13073
  errors.push({ itemId: item.id, rule: "cap:cardCopy" });
12825
13074
  }
12826
13075
  const doc = docs.find((entry) => entry.id === item.id);
12827
- if (doc !== undefined && redundantInsightClauses(item.insight, `${item.lead}${doc.body}`) >= REDUNDANT_INSIGHT_CLAUSE_LIMIT) {
13076
+ if (doc !== undefined && insight !== "" && redundantInsightClauses(insight, `${item.lead}${doc.body}`) >= REDUNDANT_INSIGHT_CLAUSE_LIMIT) {
12828
13077
  errors.push({ itemId: item.id, rule: "redundant-insight" });
12829
13078
  }
12830
13079
  }
12831
13080
  const fields = [
12832
13081
  { itemId: "episode", text: valid.intro },
12833
13082
  { itemId: "episode", text: valid.outro },
12834
- ...valid.cover !== undefined ? [{ itemId: "episode", text: valid.cover }] : [],
13083
+ ...typeof valid.cover === "string" ? [{ itemId: "episode", text: valid.cover }] : valid.cover !== undefined ? [
13084
+ { itemId: "episode", text: valid.cover.headline },
13085
+ ...valid.cover.scene !== undefined ? [{ itemId: "episode", text: valid.cover.scene }] : []
13086
+ ] : [],
12835
13087
  ...valid.cards !== undefined ? [
12836
13088
  { itemId: "episode", text: valid.cards.title },
12837
13089
  { itemId: "episode", text: valid.cards.body }
@@ -12842,7 +13094,7 @@ function validateScriptPlan(plan, docs, style, preExcludedIds) {
12842
13094
  ] : [],
12843
13095
  ...valid.items.flatMap((item) => [
12844
13096
  { itemId: item.id, text: item.lead },
12845
- { itemId: item.id, text: item.insight },
13097
+ ...(item.insight?.trim() ?? "") !== "" ? [{ itemId: item.id, text: item.insight }] : [],
12846
13098
  ...item.card !== undefined ? [
12847
13099
  { itemId: item.id, text: item.card.copy },
12848
13100
  ...item.card.points.map((point) => ({ itemId: item.id, text: point }))
@@ -12857,10 +13109,13 @@ function validateScriptPlan(plan, docs, style, preExcludedIds) {
12857
13109
  }
12858
13110
  const seenInsights = new Set;
12859
13111
  for (const item of valid.items) {
12860
- if (seenInsights.has(item.insight))
13112
+ const insight = item.insight?.trim() ?? "";
13113
+ if (insight === "")
13114
+ continue;
13115
+ if (seenInsights.has(insight))
12861
13116
  errors.push({ itemId: item.id, rule: "duplicate-insight" });
12862
13117
  else
12863
- seenInsights.add(item.insight);
13118
+ seenInsights.add(insight);
12864
13119
  }
12865
13120
  return errors.length > 0 ? { ok: false, errors } : { ok: true, plan: valid };
12866
13121
  }
@@ -12869,12 +13124,12 @@ function validateScriptPlan(plan, docs, style, preExcludedIds) {
12869
13124
  async function resolveScriptPlan(fs, docs) {
12870
13125
  const planPath = process.env.DAILYNEWS_SCRIPT_PLAN;
12871
13126
  if (!planPath) {
12872
- return { scriptSource: "template", scriptPlanErrors: [] };
13127
+ return { scriptSource: "template", scriptPlanErrors: [], scriptPlanAdvisories: [] };
12873
13128
  }
12874
13129
  const fallback = (errors) => {
12875
13130
  const reason = errors.map((error) => `${error.itemId}:${error.rule}`).join(", ");
12876
13131
  echoError(`dailynews-gen: script plan rejected, falling back to templates (${reason})`);
12877
- return { scriptSource: "template", scriptPlanErrors: errors };
13132
+ return { scriptSource: "template", scriptPlanErrors: errors, scriptPlanAdvisories: [] };
12878
13133
  };
12879
13134
  if (!await fs.exists(planPath)) {
12880
13135
  return fallback([{ itemId: "episode", rule: "missing-plan" }]);
@@ -12905,7 +13160,11 @@ async function resolveScriptPlan(fs, docs) {
12905
13160
  if (!validated.ok) {
12906
13161
  return fallback(validated.errors);
12907
13162
  }
12908
- return { scriptPlan: validated.plan, scriptSource: "plan", scriptPlanErrors: [] };
13163
+ const advisories = analyzeEditorialClaims(validated.plan);
13164
+ if (advisories.length > 0) {
13165
+ echoError(`dailynews-gen: script plan accepted with ${advisories.length} advisory finding(s) (${advisories.map((finding) => `${finding.itemId}:${finding.code}`).join(", ")})`);
13166
+ }
13167
+ return { scriptPlan: validated.plan, scriptSource: "plan", scriptPlanErrors: [], scriptPlanAdvisories: advisories };
12909
13168
  }
12910
13169
  function broadcastDateFromEnv(raw) {
12911
13170
  if (!raw)
@@ -12943,7 +13202,11 @@ async function processGeneratorIO(inputPath, outputPath, options) {
12943
13202
  }
12944
13203
  }
12945
13204
  const isZh = (options?.language || "zh").toLowerCase() === "zh";
12946
- const planOutcome = isZh ? await resolveScriptPlan(fs, docs) : { scriptSource: "template", scriptPlanErrors: [] };
13205
+ const planOutcome = isZh ? await resolveScriptPlan(fs, docs) : {
13206
+ scriptSource: "template",
13207
+ scriptPlanErrors: [],
13208
+ scriptPlanAdvisories: []
13209
+ };
12947
13210
  const excludedIds = new Set(planOutcome.scriptPlan?.excluded?.map((ex) => ex.id) ?? []);
12948
13211
  if (excludedIds.size > 0) {
12949
13212
  echoError(`dailynews-gen: topic boundary excludes ${excludedIds.size} doc(s): ${[...excludedIds].join(", ")}`);
@@ -12971,7 +13234,8 @@ async function processGeneratorIO(inputPath, outputPath, options) {
12971
13234
  sourceUri: d.sourceUri
12972
13235
  })),
12973
13236
  scriptSource: planOutcome.scriptSource,
12974
- scriptPlanErrors: planOutcome.scriptPlanErrors
13237
+ scriptPlanErrors: planOutcome.scriptPlanErrors,
13238
+ scriptPlanAdvisories: planOutcome.scriptPlanAdvisories
12975
13239
  }
12976
13240
  };
12977
13241
  const validatedContent = ContentSchema.parse(content);
@@ -13018,11 +13282,16 @@ if (import.meta.main) {
13018
13282
  process.exit(await main2());
13019
13283
  }
13020
13284
  export {
13285
+ ATTRIBUTION_MARKERS,
13286
+ COMMENTARY_MARKERS,
13287
+ EXPLANATION_MARKERS,
13021
13288
  EffectConfigSchema,
13289
+ JARGON_TERMS,
13022
13290
  MAX_FACT_SEGMENT_CHARS,
13023
13291
  VoiceScriptSchema,
13024
13292
  VoiceScriptSegmentSchema,
13025
13293
  VoiceSpeakerSchema,
13294
+ analyzeEditorialClaims,
13026
13295
  broadcastDateFromEnv,
13027
13296
  buildNewsVoiceScript,
13028
13297
  formatBroadcastDate,
@@ -0,0 +1,215 @@
1
+ import { splitSentences } from '@gobing-ai/kk-core';
2
+ import type { ScriptPlan } from './script-plan';
3
+
4
+ /**
5
+ * Advisory editorial checks for the two 0385 acceptance criteria the schema cannot express on its
6
+ * own — audience explanation (0385 AC R2) and commercial-claim / commentary evidence (0385 AC R3).
7
+ *
8
+ * Boundary: these are findings, never rejections. `validateScriptPlan` keeps sole authority over
9
+ * whether a plan is usable (a rejected plan silently ships the template fallback), so a plan that
10
+ * validates today still validates after this file exists — the findings ride alongside it.
11
+ * Every rule below quotes the clause it enforces from
12
+ * `plugins/kk/skills/news-editorial/references/style-contract.zh.md` (ADR-045), which is the single
13
+ * vocabulary owner: nothing here invents a new marker or term list.
14
+ */
15
+
16
+ /** One advisory finding — the same `{itemId, code}` keying the validator's `{itemId, rule}` uses. */
17
+ export interface EditorialFinding {
18
+ /** Rule id, prefixed with the AC it backs (`r2:`/`r3:`) so a fix pass can route on it. */
19
+ code: string;
20
+ itemId: string;
21
+ /** Human/agent-facing explanation, printed as-is. */
22
+ message: string;
23
+ }
24
+
25
+ /**
26
+ * First-person commentary markers (0385 R3). Contract:53 「评论…可以带主语「我看」一次,不连用」;
27
+ * contract:39 不连用多个「我会/我建议/我倾向」. The synonyms below are the same 第一人称评论 class the
28
+ * contract's own banned canned-insight lines use (e.g. 「我个人觉得,这次最大的看点是…」), kept in
29
+ * one list so "once per item" is enforceable across them instead of being evaded by a synonym.
30
+ */
31
+ export const COMMENTARY_MARKERS = [
32
+ '我看',
33
+ '我觉得',
34
+ '我认为',
35
+ '在我看来',
36
+ '个人觉得',
37
+ '我会',
38
+ '我建议',
39
+ '我倾向',
40
+ ] as const;
41
+
42
+ /**
43
+ * Explanation markers for an introduced term (0385 R2). Contract:30 「术语先给白话再说名词:必要术语
44
+ * 用一句「也就是说……」解释(例如「推理成本——也就是每次调用模型要付的钱」)」.
45
+ */
46
+ export const EXPLANATION_MARKERS = ['也就是说', '也就是', '即', '相当于', '简单说', '通俗讲', '意思是'] as const;
47
+
48
+ /**
49
+ * Terms that must be explained in the same breath (0385 R2, contract:30, contract:44). The list is
50
+ * deliberately small and drawn from the contract's own examples — 推理成本 (contract:30) and
51
+ * KV cache (contract:44) — plus the same 术语 class the daily items actually use. A term absent
52
+ * from this list is never a finding: the check is "explain the jargon we know we use", not a
53
+ * general terminology linter.
54
+ */
55
+ export const JARGON_TERMS = [
56
+ '推理引擎',
57
+ '推理成本',
58
+ '上下文缓存',
59
+ 'KV cache',
60
+ '微调',
61
+ '蒸馏',
62
+ 'distillation',
63
+ 'token',
64
+ '算子',
65
+ '参数量',
66
+ 'embedding',
67
+ ] as const;
68
+
69
+ /**
70
+ * Attribution markers (0385 R3). Contract:53 「可归因事实…并交代来源(谁说的、在哪个公告/采访/财报/
71
+ * 诉状里)」 and 「商业声明(融资金额、用户数、性能提升、合规资质)尤其要核查来源」.
72
+ */
73
+ export const ATTRIBUTION_MARKERS = [
74
+ '据',
75
+ '来源',
76
+ '官方',
77
+ '公告',
78
+ '财报',
79
+ '诉状',
80
+ '采访',
81
+ '报道',
82
+ '表示',
83
+ '称',
84
+ '宣布',
85
+ '披露',
86
+ '回应',
87
+ '报告',
88
+ '新闻稿',
89
+ '博客',
90
+ '援引',
91
+ '路透',
92
+ '彭博',
93
+ 'The Information',
94
+ 'http',
95
+ ] as const;
96
+
97
+ /** Quantified claim: a number that carries a unit of money, scale, count or a multiple (contract:53). */
98
+ const QUANTIFIED_RE = /\d+(?:[.,]\d+)*\s*(?:%|%|亿美元|万美元|亿元|万元|亿|万|倍|美元|元|人|家|次|个月|年|天|台)/u;
99
+ /** Superlative claim: 最/第一/唯一/首个 class (contract:53 「不夸大…意义」, contract:39). */
100
+ const SUPERLATIVE_RE = /最[高低大强快多好新]|第一|唯一|首个|首款|首家|首度|全球首|史上/iu;
101
+
102
+ /**
103
+ * A claim in a fact sentence has to name who said it (contract:53). True when the sentence carries
104
+ * an attribution marker or an explicit link.
105
+ */
106
+ function hasAttribution(sentence: string): boolean {
107
+ const lower = sentence.toLowerCase();
108
+ return ATTRIBUTION_MARKERS.some((marker) => lower.includes(marker.toLowerCase()));
109
+ }
110
+
111
+ /** True when the sentence contains one of the quantified/superlative claim shapes above. */
112
+ function hasClaim(sentence: string): boolean {
113
+ return QUANTIFIED_RE.test(sentence) || SUPERLATIVE_RE.test(sentence);
114
+ }
115
+
116
+ /**
117
+ * A gloss counts when the term is followed in the same sentence by an explanation marker, or when
118
+ * the sentence carries a parenthetical/dash gloss at all — 「推理成本——也就是每次调用模型要付的钱」
119
+ * and 「推理成本(每次调用要付的钱)」 are both the contract's shape (contract:30).
120
+ */
121
+ function hasGloss(sentence: string): boolean {
122
+ if (EXPLANATION_MARKERS.some((marker) => sentence.includes(marker))) return true;
123
+ return /([^)]{2,})|\([^)]{2,}\)/u.test(sentence) || /——[^—]{2,}/u.test(sentence);
124
+ }
125
+
126
+ /** Occurrences of every commentary marker in `text`, as `[marker, offset]` pairs (deduped by offset). */
127
+ function commentaryHits(text: string): { marker: string }[] {
128
+ const hits: { marker: string }[] = [];
129
+ for (const marker of COMMENTARY_MARKERS) {
130
+ let from = text.indexOf(marker);
131
+ while (from !== -1) {
132
+ hits.push({ marker });
133
+ from = text.indexOf(marker, from + marker.length);
134
+ }
135
+ }
136
+ return hits;
137
+ }
138
+
139
+ /**
140
+ * Analyse a validated master script plan for the 0385 AC R2/R3 editorial rules and return advisory
141
+ * findings in plan order. `insight` is the commentary slot and `lead` the narration slot
142
+ * (style contract 段落角色), so the two are treated asymmetrically on purpose:
143
+ *
144
+ * - `r3:commentary-repeat` — more than one 第一人称评论 marker in one item (contract:39, contract:53).
145
+ * - `r3:commentary-in-facts` — a commentary marker in the fact sentence `lead` instead of `insight`
146
+ * (contract:49 「三种话必须分得开」).
147
+ * - `r3:insight-multi-sentence` — the per-item comment runs past one sentence (0385 AC R3 「至多一句」).
148
+ * - `r3:unattributed-claim` — a number/superlative in `lead` with no attribution in that sentence
149
+ * (contract:53 「商业声明…尤其要核查来源」).
150
+ * - `r2:unexplained-jargon` — a `JARGON_TERMS` hit in either slot with no same-sentence gloss
151
+ * (contract:30 「术语先给白话再说名词」).
152
+ */
153
+ export function analyzeEditorialClaims(plan: ScriptPlan): EditorialFinding[] {
154
+ const findings: EditorialFinding[] = [];
155
+ for (const item of plan.items) {
156
+ const lead = item.lead.trim();
157
+ const insight = item.insight?.trim() ?? '';
158
+
159
+ const hits = commentaryHits(`${lead}${insight}`);
160
+ if (hits.length > 1) {
161
+ findings.push({
162
+ code: 'r3:commentary-repeat',
163
+ itemId: item.id,
164
+ message: `commentary markers used ${hits.length} times (${hits
165
+ .map((hit) => hit.marker)
166
+ .join(', ')}); at most one per item`,
167
+ });
168
+ }
169
+ const leaked = commentaryHits(lead);
170
+ if (leaked.length > 0) {
171
+ findings.push({
172
+ code: 'r3:commentary-in-facts',
173
+ itemId: item.id,
174
+ message: `commentary marker (${leaked.map((hit) => hit.marker).join(', ')}) in the fact sentence; move the judgement into insight`,
175
+ });
176
+ }
177
+ if (insight !== '') {
178
+ const sentences = splitSentences(insight, { cjkOnly: true });
179
+ if (sentences.length > 1) {
180
+ findings.push({
181
+ code: 'r3:insight-multi-sentence',
182
+ itemId: item.id,
183
+ message: `insight is ${sentences.length} sentences; the per-item comment is at most one`,
184
+ });
185
+ }
186
+ }
187
+ for (const sentence of splitSentences(lead, { cjkOnly: true })) {
188
+ if (hasClaim(sentence) && !hasAttribution(sentence)) {
189
+ findings.push({
190
+ code: 'r3:unattributed-claim',
191
+ itemId: item.id,
192
+ message: `claim without attribution: 「${sentence}」 — name the source (据/公告/财报/公司称) or drop the figure`,
193
+ });
194
+ }
195
+ }
196
+ for (const [slot, text] of [
197
+ ['lead', lead],
198
+ ['insight', insight],
199
+ ] as const) {
200
+ if (text === '') continue;
201
+ for (const sentence of splitSentences(text, { cjkOnly: true })) {
202
+ const lowered = sentence.toLowerCase();
203
+ const term = JARGON_TERMS.find((candidate) => lowered.includes(candidate.toLowerCase()));
204
+ if (term !== undefined && !hasGloss(sentence)) {
205
+ findings.push({
206
+ code: 'r2:unexplained-jargon',
207
+ itemId: item.id,
208
+ message: `${slot} introduces 「${term}」 with no plain-language gloss (也就是说/即/相当于, or a 括号/破折号 explanation)`,
209
+ });
210
+ }
211
+ }
212
+ }
213
+ }
214
+ return findings;
215
+ }