@gobing-ai/knowledge-kit 0.1.17 → 0.1.20

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 (95) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/board/daily-voice/index.js +40 -7
  3. package/dist/index.js +8428 -4448
  4. package/package.json +1 -1
  5. package/plugins/generations/image-gen/README.md +31 -31
  6. package/plugins/generations/image-gen/assets/sample/provenance.json +314 -0
  7. package/plugins/generations/image-gen/config.example.yaml +3 -0
  8. package/plugins/generations/image-gen/dist/index.js +154 -14
  9. package/plugins/generations/image-gen/presets/SOURCE.md +65 -0
  10. package/plugins/generations/image-gen/scripts/eval-style-presets.ts +513 -0
  11. package/plugins/generations/image-gen/scripts/gen-samples.ts +57 -7
  12. package/plugins/generations/image-gen/src/presets.ts +6 -5
  13. package/plugins/generations/image-gen/src/providers/h3-local.ts +196 -0
  14. package/plugins/generations/image-gen/src/providers/types.ts +11 -1
  15. package/plugins/kk/config.example.yaml +7 -2
  16. package/plugins/kk/decisions/extract/ai-news.yaml +5 -2
  17. package/plugins/kk/plugin.json +1 -1
  18. package/plugins/kk/publish-presets/chinese-article.json +8 -2
  19. package/plugins/kk/publish-presets/daily-ai-voice-migration.json +1 -1
  20. package/plugins/kk/publish-presets/daily-ai-voice.json +57 -16
  21. package/plugins/kk/publish-presets/itc-main.json +36 -9
  22. package/plugins/kk/publish-presets/technical-article.json +8 -2
  23. package/plugins/kk/schedules/kk-daily-ai-voice3.cron.tmpl +8 -9
  24. package/plugins/kk/schedules/kk-daily-publish3-cn-peak.cron.tmpl +13 -19
  25. package/plugins/kk/schedules/kk-daily-publish3-overseas.cron.tmpl +11 -9
  26. package/plugins/kk/scripts/daily-stages.ts +238 -14
  27. package/plugins/kk/scripts/daily-triage-core.ts +43 -25
  28. package/plugins/kk/scripts/daily-triage.ts +1 -1
  29. package/plugins/kk/skills/image-authoring/SKILL.md +7 -3
  30. package/plugins/kk/skills/image-authoring/references/providers.md +27 -0
  31. package/plugins/kk/skills/image-authoring/references/style-extraction.md +1 -1
  32. package/plugins/kk/skills/publish/SKILL.md +15 -2
  33. package/plugins/kk/skills/web-automation/SKILL.md +31 -1
  34. package/plugins/kk/workflows/kk-article-generate.yaml +485 -0
  35. package/plugins/kk/workflows/kk-collect.yaml +8 -4
  36. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +2 -1
  37. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +4 -2
  38. package/plugins/kk/workflows/kk-daily-safety.yaml +5 -7
  39. package/plugins/kk/workflows/kk-news-generate.yaml +410 -0
  40. package/plugins/kk/workflows/kk-publish.yaml +236 -0
  41. package/plugins/publishings/bilibili-pub/dist/profile-check.js +49 -10
  42. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +60 -10
  43. package/plugins/publishings/csdn-pub/dist/profile-check.js +60 -10
  44. package/plugins/publishings/infoq-pub/dist/profile-check.js +60 -10
  45. package/plugins/publishings/jike-pub/dist/profile-check.js +60 -10
  46. package/plugins/publishings/juejin-pub/dist/profile-check.js +60 -10
  47. package/plugins/publishings/linkedin-pub/dist/index.js +43 -6
  48. package/plugins/publishings/linkedin-pub/dist/profile-check.js +92 -15
  49. package/plugins/publishings/linkedin-pub/src/index.ts +52 -6
  50. package/plugins/publishings/shipinhao-pub/dist/index.js +391 -32
  51. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +52 -11
  52. package/plugins/publishings/shipinhao-pub/plugin.json +1 -1
  53. package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +393 -0
  54. package/plugins/publishings/shipinhao-pub/src/flow.ts +243 -14
  55. package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -0
  56. package/plugins/publishings/sspai-pub/dist/profile-check.js +60 -10
  57. package/plugins/publishings/substack-pub/dist/profile-check.js +60 -10
  58. package/plugins/publishings/surfdash-pub/dist/index.js +50 -8
  59. package/plugins/publishings/surfdash-pub/src/index.ts +59 -8
  60. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +34 -3
  61. package/plugins/publishings/threads-pub/dist/index.js +9196 -296
  62. package/plugins/publishings/threads-pub/dist/profile-check.js +21139 -0
  63. package/plugins/publishings/threads-pub/package.json +3 -1
  64. package/plugins/publishings/threads-pub/plugin.json +6 -1
  65. package/plugins/publishings/threads-pub/src/index.ts +8 -1
  66. package/plugins/publishings/threads-pub/src/post-rail.ts +357 -0
  67. package/plugins/publishings/threads-pub/src/profile-check.ts +17 -0
  68. package/plugins/publishings/wechatmp-pub/dist/index.js +454 -81
  69. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +401 -102
  70. package/plugins/publishings/wechatmp-pub/src/flow.ts +42 -4
  71. package/plugins/publishings/wechatmp-pub/src/index.ts +142 -102
  72. package/plugins/publishings/wechatmp-pub/src/profile-check.ts +36 -58
  73. package/plugins/publishings/weibo-pub/dist/index.js +136 -22
  74. package/plugins/publishings/weibo-pub/dist/profile-check.js +61 -11
  75. package/plugins/publishings/weibo-pub/src/index.ts +208 -22
  76. package/plugins/publishings/x-pub/dist/index.js +263 -43
  77. package/plugins/publishings/x-pub/dist/profile-check.js +63 -11
  78. package/plugins/publishings/x-pub/src/index.ts +15 -1
  79. package/plugins/publishings/x-pub/src/post-rail.ts +334 -0
  80. package/plugins/publishings/xhs-pub/dist/index.js +193 -201
  81. package/plugins/publishings/xhs-pub/dist/profile-check.js +380 -85
  82. package/plugins/publishings/xhs-pub/src/automation-guard.ts +2 -3
  83. package/plugins/publishings/xhs-pub/src/flow.ts +177 -205
  84. package/plugins/publishings/xhs-pub/src/index.ts +65 -59
  85. package/plugins/publishings/xhs-pub/src/modes.ts +1 -1
  86. package/plugins/publishings/xhs-pub/src/page.ts +2 -2
  87. package/plugins/publishings/xhs-pub/src/profile-check.ts +86 -150
  88. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +60 -10
  89. package/plugins/kk/scripts/daily-scheduled-run.ts +0 -581
  90. package/plugins/kk/scripts/voice3-publish-window.ts +0 -206
  91. package/plugins/kk/workflows/kk-daily-ai-voice3.yaml +0 -903
  92. package/plugins/kk/workflows/kk-daily-publish3.yaml +0 -353
  93. package/plugins/kk/workflows/kk-itc-author.yaml +0 -484
  94. package/plugins/kk/workflows/kk-itc-publish-tail.yaml +0 -112
  95. package/plugins/kk/workflows/kk-itc.yaml +0 -291
@@ -12755,8 +12755,8 @@ function buildLocaleEntry(markdown, locale) {
12755
12755
  if (!parts) {
12756
12756
  return `${locale}: key_points must be "label \u2014 sentence"`;
12757
12757
  }
12758
- if (parts.labels.length !== headlines.length || parts.labels.some((label, i) => label !== headlines[i])) {
12759
- return `${locale}: title headlines do not match key_points labels`;
12758
+ if (headlines.length > parts.labels.length || headlines.some((headline, i) => headline !== parts.labels[i])) {
12759
+ return `${locale}: title headlines do not match the leading key_points labels`;
12760
12760
  }
12761
12761
  const claims = parts.sentences;
12762
12762
  const shortClaims = splitDescriptionParts(description, headlines.length) ?? claims;
@@ -12801,11 +12801,25 @@ async function upsertDailyTopicsEntry(mapPath, slug, entry, fileSystem = createN
12801
12801
  existing = parsed;
12802
12802
  }
12803
12803
  }
12804
- existing[slug] = entry;
12804
+ const prior = existing[slug];
12805
+ existing[slug] = prior === null || typeof prior !== "object" || Array.isArray(prior) ? entry : keepCurated(prior, entry);
12805
12806
  await fileSystem.ensureDir(dirname3(mapPath));
12806
12807
  await fileSystem.writeFile(mapPath, `${JSON.stringify(existing, null, "\t")}
12807
12808
  `);
12808
12809
  }
12810
+ function keepCurated(curated, derived) {
12811
+ const merged = { ...derived, ...curated };
12812
+ const isEmpty = (value) => value === undefined || value === null || value === "" || Array.isArray(value) && value.length === 0;
12813
+ for (const [key, value] of Object.entries(derived)) {
12814
+ const current = curated[key];
12815
+ if (isEmpty(current))
12816
+ continue;
12817
+ if (value !== null && typeof value === "object" && !Array.isArray(value) && !isEmpty(current)) {
12818
+ merged[key] = keepCurated(current, value);
12819
+ }
12820
+ }
12821
+ return merged;
12822
+ }
12809
12823
 
12810
12824
  // ../../plugins/publishings/surfdash-pub/src/index.ts
12811
12825
  var TARGET = "surfdash";
@@ -13008,6 +13022,32 @@ function digestCheckGate(filePath, locale) {
13008
13022
  }
13009
13023
  return `digest frontmatter check failed: ${problems.join("; ")}`;
13010
13024
  }
13025
+ function localeSiblings(postPath) {
13026
+ const segments = postPath.split(sep2);
13027
+ let index = -1;
13028
+ for (let i = segments.length - 1;i >= 0; i--) {
13029
+ if (segments[i] === "zh" || segments[i] === "en" || segments[i] === "ja") {
13030
+ index = i;
13031
+ break;
13032
+ }
13033
+ }
13034
+ if (index < 0)
13035
+ return [];
13036
+ return PATCH_LOCALES.map((locale) => ({
13037
+ filePath: [...segments.slice(0, index), locale, ...segments.slice(index + 1)].join(sep2),
13038
+ locale
13039
+ }));
13040
+ }
13041
+ function digestCheckLocaleSet(postPath) {
13042
+ for (const { filePath, locale } of localeSiblings(postPath)) {
13043
+ if (!existsSync2(filePath))
13044
+ continue;
13045
+ const problem = digestCheckGate(filePath, locale);
13046
+ if (problem)
13047
+ return `${locale}: ${problem}`;
13048
+ }
13049
+ return;
13050
+ }
13011
13051
  function parsePorcelainPaths(stdout) {
13012
13052
  return stdout.split(`
13013
13053
  `).map((line) => line.trimEnd()).filter((line) => line.length > 3).map((line) => {
@@ -13091,7 +13131,9 @@ async function runDailyTopicsSync(surfdashRoot, zhPostPath) {
13091
13131
  }
13092
13132
  var SITE_GATE_COMMANDS = [
13093
13133
  ["bun", "run", "sd", "check", "digest"],
13094
- ["bun", "run", "check:content"]
13134
+ ["bun", "run", "check:content"],
13135
+ ["bun", "run", "check:body"],
13136
+ ["bun", "run", "check:seo"]
13095
13137
  ];
13096
13138
  function extractFailingPostHint(text) {
13097
13139
  const match = text.match(/(?:content[\\/])?posts[\\/][^\s:)]+/);
@@ -13353,9 +13395,8 @@ async function syncPost(options) {
13353
13395
  if (spawned.exitCode !== 0) {
13354
13396
  return fail(`publish-orchestrator sync failed (exit ${spawned.exitCode}): ${withEmdashTokenHint(cliErrorText(spawned))}`);
13355
13397
  }
13356
- const localeInPath = postPath.postPath.match(/[\\/]content[\\/]posts[\\/]articles[\\/](zh|en|ja)[\\/]/);
13357
- if (localeInPath) {
13358
- const digestProblem = digestCheckGate(postPath.postPath, localeInPath[1]);
13398
+ if (/[\\/]content[\\/]posts[\\/]articles[\\/](?:zh|en|ja)[\\/]/.test(postPath.postPath)) {
13399
+ const digestProblem = digestCheckLocaleSet(postPath.postPath);
13359
13400
  if (digestProblem)
13360
13401
  return fail(digestProblem);
13361
13402
  }
@@ -13694,7 +13735,7 @@ async function publishPreparedFile(prepared, identity) {
13694
13735
  const notRefined = requireRefined(filePath);
13695
13736
  if (notRefined)
13696
13737
  return failUncertain(notRefined);
13697
- const digestProblem = digestCheckGate(filePath, locale);
13738
+ const digestProblem = digestCheckLocaleSet(filePath);
13698
13739
  if (digestProblem)
13699
13740
  return failUncertain(digestProblem);
13700
13741
  const refined = readRefinedSnapshot(filePath);
@@ -13883,6 +13924,7 @@ export {
13883
13924
  commitPostPaths,
13884
13925
  contentTags,
13885
13926
  digestCheckGate,
13927
+ digestCheckLocaleSet,
13886
13928
  extractFailingPostHint,
13887
13929
  fastForwardToOrigin,
13888
13930
  getPublishTransport,
@@ -434,6 +434,46 @@ export function digestCheckGate(filePath: string, locale: DigestLocale): string
434
434
  return `digest frontmatter check failed: ${problems.join('; ')}`;
435
435
  }
436
436
 
437
+ /**
438
+ * Every locale file of one post that exists on disk, in `PATCH_LOCALES` order.
439
+ * The locale is the last `zh`/`en`/`ja` directory in the path; no such segment → []
440
+ * (a path outside the locale tree has no set to check).
441
+ */
442
+ function localeSiblings(postPath: string): Array<{ filePath: string; locale: DigestLocale }> {
443
+ const segments = postPath.split(sep);
444
+ let index = -1;
445
+ for (let i = segments.length - 1; i >= 0; i--) {
446
+ if (segments[i] === 'zh' || segments[i] === 'en' || segments[i] === 'ja') {
447
+ index = i;
448
+ break;
449
+ }
450
+ }
451
+ if (index < 0) return [];
452
+ return PATCH_LOCALES.map((locale) => ({
453
+ filePath: [...segments.slice(0, index), locale, ...segments.slice(index + 1)].join(sep),
454
+ locale,
455
+ }));
456
+ }
457
+
458
+ /**
459
+ * Digest gate over the whole locale set instead of the primary file alone (2026-11-16, GH #191).
460
+ *
461
+ * An untranslated sibling — the zh title, description and key points sitting under `/en/` or `/ja/`
462
+ * — passes a zh-only check here and then fails the site's check-digest three ways: the locale's own
463
+ * series name, the body language, and the regenerated-frontmatter drift. `sync` hands all three
464
+ * locales to the CMS and a prepared publish commits all three, so every existing file is checked.
465
+ * Missing files stay skipped (the pre-translation `prepare` path has no siblings yet), and
466
+ * `SURFDASH_DIGEST_CHECK` keeps governing the gate itself.
467
+ */
468
+ export function digestCheckLocaleSet(postPath: string): string | undefined {
469
+ for (const { filePath, locale } of localeSiblings(postPath)) {
470
+ if (!existsSync(filePath)) continue;
471
+ const problem = digestCheckGate(filePath, locale);
472
+ if (problem) return `${locale}: ${problem}`;
473
+ }
474
+ return undefined;
475
+ }
476
+
437
477
  /**
438
478
  * Helper to parse file paths from `git status --porcelain` output.
439
479
  */
@@ -560,10 +600,20 @@ export async function runDailyTopicsSync(surfdashRoot: string, zhPostPath: strin
560
600
  /** Outcome of {@link runSiteGate}. */
561
601
  export type SiteGateOutcome = { ok: true } | { ok: false; error: string };
562
602
 
563
- /** Commands executed by the surfdash site gate before commit and push to main. */
603
+ /**
604
+ * Commands executed by the surfdash site gate before commit and push to main.
605
+ *
606
+ * This list must stay equal to the content suite surfdash's own deploy gate runs
607
+ * (`bun run check:all` = check:content + check:body + check:seo) plus the digest reporter.
608
+ * It used to stop at `check:content`, so a body-rule violation or a localized cover asset that
609
+ * `check:seo` reports as `image-asset-missing` passed here and failed the site's CI right after
610
+ * the push (GH #191, `docs(articles): add more articles`, 2026-11-15).
611
+ */
564
612
  const SITE_GATE_COMMANDS: readonly (readonly string[])[] = [
565
613
  ['bun', 'run', 'sd', 'check', 'digest'],
566
614
  ['bun', 'run', 'check:content'],
615
+ ['bun', 'run', 'check:body'],
616
+ ['bun', 'run', 'check:seo'],
567
617
  ];
568
618
 
569
619
  /**
@@ -932,11 +982,11 @@ async function syncPost(options: SurfdashPubOptions): Promise<Result> {
932
982
  `publish-orchestrator sync failed (exit ${spawned.exitCode}): ${withEmdashTokenHint(cliErrorText(spawned))}`,
933
983
  );
934
984
  }
935
- // Digest contract (2026-10-24): verify the synced post's frontmatter for its own locale;
936
- // paths outside content/posts/articles/<zh|en|ja>/ carry no digest series to check.
937
- const localeInPath = postPath.postPath.match(/[\\/]content[\\/]posts[\\/]articles[\\/](zh|en|ja)[\\/]/);
938
- if (localeInPath) {
939
- const digestProblem = digestCheckGate(postPath.postPath, localeInPath[1] as DigestLocale);
985
+ // Digest contract (2026-10-24; locale set 2026-11-16): the orchestrator syncs all three
986
+ // locale files to the CMS, so verify the synced post AND its siblings. Paths outside
987
+ // content/posts/articles/<zh|en|ja>/ carry no digest series to check.
988
+ if (/[\\/]content[\\/]posts[\\/]articles[\\/](?:zh|en|ja)[\\/]/.test(postPath.postPath)) {
989
+ const digestProblem = digestCheckLocaleSet(postPath.postPath);
940
990
  if (digestProblem) return fail(digestProblem);
941
991
  }
942
992
  return ResultSchema.parse({
@@ -1389,8 +1439,9 @@ async function publishPreparedFile(
1389
1439
  // Contract check (ADR-008): the site, not this plugin, owns SEO metadata.
1390
1440
  const notRefined = requireRefined(filePath);
1391
1441
  if (notRefined) return failUncertain(notRefined);
1392
- // Digest contract (2026-10-24): the refined values themselves must hold, before any push.
1393
- const digestProblem = digestCheckGate(filePath, locale);
1442
+ // Digest contract (2026-10-24; locale set 2026-11-16): the refined values themselves must
1443
+ // hold for every locale this publish commits, before any push.
1444
+ const digestProblem = digestCheckLocaleSet(filePath);
1394
1445
  if (digestProblem) return failUncertain(digestProblem);
1395
1446
  const refined = readRefinedSnapshot(filePath);
1396
1447
 
@@ -120,8 +120,12 @@ function buildLocaleEntry(markdown: string, locale: PatchLocale): DailyTopicsLoc
120
120
  if (!parts) {
121
121
  return `${locale}: key_points must be "label — sentence"`;
122
122
  }
123
- if (parts.labels.length !== headlines.length || parts.labels.some((label, i) => label !== headlines[i])) {
124
- return `${locale}: title headlines do not match key_points labels`;
123
+ // The title names the TOP stories; the key-point box carries up to four. The site's own
124
+ // generator emits exactly that shape (`scripts/commands/seo/retitle.ts`: title = "top story 1,
125
+ // story 2", key_points = up to four bullets), so demanding a one-to-one match made every
126
+ // crefitable digest fail the sync. The title must be the leading labels, in order.
127
+ if (headlines.length > parts.labels.length || headlines.some((headline, i) => headline !== parts.labels[i])) {
128
+ return `${locale}: title headlines do not match the leading key_points labels`;
125
129
  }
126
130
  const claims = parts.sentences;
127
131
  const shortClaims = splitDescriptionParts(description, headlines.length) ?? claims;
@@ -183,7 +187,34 @@ export async function upsertDailyTopicsEntry(
183
187
  existing = parsed as Record<string, unknown>;
184
188
  }
185
189
  }
186
- existing[slug] = entry;
190
+ // A curated entry WINS. The site's runbook (docs/runbook-seo-geo-operations.md §10) sanctions
191
+ // editing a slug's claims/short_claims by hand, and re-deriving them from the posts on every
192
+ // publish silently reverted that fix (2026-11-16: a curated 20261116 entry was replaced, retitle
193
+ // then re-broke the descriptions, and the gate failed again on the next attempt). Derivation only
194
+ // fills what the map does not already state.
195
+ const prior = existing[slug];
196
+ existing[slug] =
197
+ prior === null || typeof prior !== 'object' || Array.isArray(prior)
198
+ ? entry
199
+ : keepCurated(prior as Record<string, unknown>, entry as unknown as Record<string, unknown>);
187
200
  await fileSystem.ensureDir(dirname(mapPath));
188
201
  await fileSystem.writeFile(mapPath, `${JSON.stringify(existing, null, '\t')}\n`);
189
202
  }
203
+
204
+ /**
205
+ * Merges a derived entry under an existing one, keeping every non-empty curated value and taking the
206
+ * derived value only where the map states nothing (a missing locale, a new field).
207
+ */
208
+ function keepCurated(curated: Record<string, unknown>, derived: Record<string, unknown>): Record<string, unknown> {
209
+ const merged: Record<string, unknown> = { ...derived, ...curated };
210
+ const isEmpty = (value: unknown): boolean =>
211
+ value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0);
212
+ for (const [key, value] of Object.entries(derived)) {
213
+ const current = curated[key];
214
+ if (isEmpty(current)) continue;
215
+ if (value !== null && typeof value === 'object' && !Array.isArray(value) && !isEmpty(current)) {
216
+ merged[key] = keepCurated(current as Record<string, unknown>, value as Record<string, unknown>);
217
+ }
218
+ }
219
+ return merged;
220
+ }