@gobing-ai/knowledge-kit 0.1.20 → 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 (115) 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 +1279 -261
  4. package/dist/board/itc/index.js +1 -0
  5. package/dist/index.js +13893 -8995
  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/music-gen/README.md +277 -0
  13. package/plugins/generations/music-gen/dist/index.js +23544 -0
  14. package/plugins/generations/music-gen/package.json +24 -0
  15. package/plugins/generations/music-gen/plugin.json +23 -0
  16. package/plugins/generations/music-gen/presets/SOURCE.md +39 -0
  17. package/plugins/generations/music-gen/presets/formats/clip.yaml +21 -0
  18. package/plugins/generations/music-gen/presets/formats/jingle.yaml +22 -0
  19. package/plugins/generations/music-gen/presets/formats/loop.yaml +21 -0
  20. package/plugins/generations/music-gen/presets/formats/song.yaml +31 -0
  21. package/plugins/generations/music-gen/presets/formats/underscore.yaml +22 -0
  22. package/plugins/generations/music-gen/presets/themes/ambient-tech.yaml +30 -0
  23. package/plugins/generations/music-gen/presets/themes/cinematic.yaml +30 -0
  24. package/plugins/generations/music-gen/presets/themes/lofi.yaml +30 -0
  25. package/plugins/generations/music-gen/presets/themes/synthwave.yaml +30 -0
  26. package/plugins/generations/music-gen/scripts/gen-preset-index.ts +181 -0
  27. package/plugins/generations/music-gen/scripts/resolve-preset.ts +64 -0
  28. package/plugins/generations/music-gen/src/adapter/index.ts +35 -0
  29. package/plugins/generations/music-gen/src/adapter/instance.ts +904 -0
  30. package/plugins/generations/music-gen/src/adapter/offline.ts +124 -0
  31. package/plugins/generations/music-gen/src/artifact.ts +223 -0
  32. package/plugins/generations/music-gen/src/audio/checks.ts +618 -0
  33. package/plugins/generations/music-gen/src/audio/master.ts +267 -0
  34. package/plugins/generations/music-gen/src/audio/measure.ts +507 -0
  35. package/plugins/generations/music-gen/src/audio/profile.ts +131 -0
  36. package/plugins/generations/music-gen/src/audio.ts +122 -0
  37. package/plugins/generations/music-gen/src/brief.ts +191 -0
  38. package/plugins/generations/music-gen/src/config.ts +451 -0
  39. package/plugins/generations/music-gen/src/content.ts +199 -0
  40. package/plugins/generations/music-gen/src/digest.ts +100 -0
  41. package/plugins/generations/music-gen/src/index.ts +147 -0
  42. package/plugins/generations/music-gen/src/job.ts +131 -0
  43. package/plugins/generations/music-gen/src/plugin.ts +371 -0
  44. package/plugins/generations/music-gen/src/presets.ts +918 -0
  45. package/plugins/generations/music-gen/src/render.ts +87 -0
  46. package/plugins/generations/music-gen/src/request.ts +102 -0
  47. package/plugins/generations/music-gen/src/spend.ts +495 -0
  48. package/plugins/generations/music-gen/tsconfig.json +8 -0
  49. package/plugins/kk/plugin.json +1 -1
  50. package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +2 -1
  51. package/plugins/kk/scripts/cover-compositor.ts +380 -32
  52. package/plugins/kk/scripts/daily-cover-mock.ts +40 -3
  53. package/plugins/kk/scripts/daily-stages.ts +659 -20
  54. package/plugins/kk/scripts/episode-identity.ts +180 -0
  55. package/plugins/kk/scripts/kk-workflow-stages.ts +37 -1
  56. package/plugins/kk/scripts/music-stages.ts +624 -0
  57. package/plugins/kk/scripts/news-editorial-ledger.ts +906 -0
  58. package/plugins/kk/scripts/source-citation.ts +187 -0
  59. package/plugins/kk/scripts/topic-selection-attempts.ts +446 -0
  60. package/plugins/kk/scripts/topic-selection-calibration.ts +161 -0
  61. package/plugins/kk/skills/content-judge/SKILL.md +11 -6
  62. package/plugins/kk/skills/content-judge/references/music-quality-rubric.md +147 -0
  63. package/plugins/kk/skills/content-judge/references/rubrics.md +15 -0
  64. package/plugins/kk/skills/content-safety/SKILL.md +12 -0
  65. package/plugins/kk/skills/music-authoring/SKILL.md +276 -0
  66. package/plugins/kk/skills/music-authoring/references/judge-input.md +117 -0
  67. package/plugins/kk/skills/news-editorial/SKILL.md +102 -15
  68. package/plugins/kk/skills/news-editorial/references/selection.md +4 -0
  69. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +58 -11
  70. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +8 -8
  71. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +7 -7
  72. package/plugins/kk/workflows/kk-music.yaml +328 -0
  73. package/plugins/kk/workflows/kk-news-generate.yaml +58 -3
  74. package/plugins/publishings/bilibili-pub/dist/index.js +11 -1
  75. package/plugins/publishings/bilibili-pub/dist/profile-check.js +11 -1
  76. package/plugins/publishings/cnblogs-pub/dist/index.js +11 -1
  77. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +11 -1
  78. package/plugins/publishings/csdn-pub/dist/index.js +11 -1
  79. package/plugins/publishings/csdn-pub/dist/profile-check.js +11 -1
  80. package/plugins/publishings/infoq-pub/dist/index.js +11 -1
  81. package/plugins/publishings/infoq-pub/dist/profile-check.js +11 -1
  82. package/plugins/publishings/jike-pub/dist/index.js +11 -1
  83. package/plugins/publishings/jike-pub/dist/profile-check.js +11 -1
  84. package/plugins/publishings/juejin-pub/dist/index.js +11 -1
  85. package/plugins/publishings/juejin-pub/dist/profile-check.js +11 -1
  86. package/plugins/publishings/linkedin-pub/dist/index.js +11 -1
  87. package/plugins/publishings/linkedin-pub/dist/profile-check.js +11 -1
  88. package/plugins/publishings/podcast-pub/dist/index.js +586 -20
  89. package/plugins/publishings/podcast-pub/src/corrections.ts +509 -0
  90. package/plugins/publishings/podcast-pub/src/index.ts +257 -5
  91. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +240 -0
  92. package/plugins/publishings/podcast-pub/src/show-notes.ts +69 -13
  93. package/plugins/publishings/shipinhao-pub/dist/index.js +59 -8
  94. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +11 -1
  95. package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +105 -6
  96. package/plugins/publishings/sspai-pub/dist/index.js +11 -1
  97. package/plugins/publishings/sspai-pub/dist/profile-check.js +11 -1
  98. package/plugins/publishings/substack-pub/dist/index.js +11 -1
  99. package/plugins/publishings/substack-pub/dist/profile-check.js +11 -1
  100. package/plugins/publishings/surfdash-pub/dist/index.js +72 -20
  101. package/plugins/publishings/surfdash-pub/src/digest-check.ts +7 -3
  102. package/plugins/publishings/surfdash-pub/src/index.ts +100 -17
  103. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +3 -1
  104. package/plugins/publishings/threads-pub/dist/index.js +11 -1
  105. package/plugins/publishings/threads-pub/dist/profile-check.js +11 -1
  106. package/plugins/publishings/wechatmp-pub/dist/index.js +11 -1
  107. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +11 -1
  108. package/plugins/publishings/weibo-pub/dist/index.js +11 -1
  109. package/plugins/publishings/weibo-pub/dist/profile-check.js +11 -1
  110. package/plugins/publishings/x-pub/dist/index.js +11 -1
  111. package/plugins/publishings/x-pub/dist/profile-check.js +11 -1
  112. package/plugins/publishings/xhs-pub/dist/index.js +11 -1
  113. package/plugins/publishings/xhs-pub/dist/profile-check.js +11 -1
  114. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +11 -1
  115. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +11 -1
@@ -0,0 +1,180 @@
1
+ /**
2
+ * 0385 R4 — the daily episode's canonical, frozen identity.
3
+ *
4
+ * One episode is identified by its run date plus one headline point (「当日要点」) anchored to the
5
+ * admitted lead story. Every publishing surface (Chinese title, cover headline, ID3/RSS title, show
6
+ * notes) reads that single frozen record instead of deriving its own title, so the episode cannot
7
+ * carry two identities. Two failure modes are explicit, never silent:
8
+ *
9
+ * - `support-removed`: admission dropped the source(s) the headline rests on. The headline — and
10
+ * every field derived from it — is withheld (`title: null`); the caller must regenerate the
11
+ * headline from an admitted story or refuse to publish. It never keeps a title it cannot support.
12
+ * - `no-headline`: no point was frozen at all (a legacy bundle or a run without a script plan).
13
+ * `legacyTitle` is carried through untouched, so replaying an old bundle reproduces what aired.
14
+ *
15
+ * Retries and historical replay reuse the record already stamped in the bundle's metadata
16
+ * ({@link identityFromMetadata}) verbatim: a replayed episode keeps the identity it shipped with
17
+ * even when today's admission would compute a different one.
18
+ *
19
+ * Pure string work, node builtins only — no I/O, so the render and publish seams share it.
20
+ */
21
+
22
+ /** The frozen record; `version` pins the shape so a future change fails loud instead of drifting. */
23
+ export interface EpisodeIdentity {
24
+ version: 1;
25
+ /** The run date exactly as the caller supplied it (the episode date is frozen, never re-derived). */
26
+ date: string;
27
+ /** ISO-ish issue number in the Chinese title: `20261120` / `2026-11-20` → `261120`. */
28
+ issue: string;
29
+ /** The frozen 当日要点 (one line, ≤ {@link MAX_HEADLINE_CHARS}), or null when withheld. */
30
+ headline: string | null;
31
+ /** `第<issue>期 · <headline>`, or null when the headline had to be withheld. */
32
+ title: string | null;
33
+ /** The cover reuses the same point — never a second wording of it. */
34
+ coverHeadline: string | null;
35
+ /** The admitted source ids the headline rests on (empty when the caller named none). */
36
+ supportingSourceIds: string[];
37
+ status: 'frozen' | 'no-headline' | 'support-removed';
38
+ }
39
+
40
+ export interface EpisodeIdentityInput {
41
+ /** Run date, `YYYYMMDD` or `YYYY-MM-DD`. */
42
+ date: string;
43
+ /** The candidate 当日要点 (may still carry line breaks from the writer). */
44
+ headline?: string | null;
45
+ /** Source ids the headline rests on. Omitted/empty means "no claim made about support". */
46
+ supportingSourceIds?: readonly string[] | null;
47
+ /** Source ids the settled plan (admission) actually keeps. */
48
+ admittedSourceIds?: readonly string[] | null;
49
+ /** Pre-0385 title of the same episode, preserved for legacy bundles and replay. */
50
+ legacyTitle?: string | null;
51
+ }
52
+
53
+ /** The style contract caps the cover headline at 25 chars per line (0347 R4); the point is one line. */
54
+ export const MAX_HEADLINE_CHARS = 25;
55
+
56
+ /** Trim, collapse whitespace (writers emit wrapped `\n`), and drop a trailing sentence stop. */
57
+ function normalizeHeadline(raw: string): string {
58
+ return raw
59
+ .replaceAll(/\s+/g, ' ')
60
+ .trim()
61
+ .replace(/[。..、,,;;::·]+$/u, '')
62
+ .trim();
63
+ }
64
+
65
+ /** Code-point slice — a UTF-16 slice could split a surrogate pair in the middle of the title. */
66
+ function clip(text: string, max: number): string {
67
+ const points = [...text];
68
+ return points.length <= max ? text : `${points.slice(0, max - 1).join('')}…`;
69
+ }
70
+
71
+ /** The issue number of the frozen episode date, or `''` when the date carries no digits at all. */
72
+ export function issueNumberOf(date: string): string {
73
+ const digits = date.replaceAll(/\D/g, '');
74
+ return digits.length >= 6 ? digits.slice(-6) : '';
75
+ }
76
+
77
+ /** `第261120期` — the title's stable prefix, derived from the episode date only. */
78
+ export function issueLabel(date: string): string {
79
+ const issue = issueNumberOf(date);
80
+ return issue === '' ? '' : `第${issue}期`;
81
+ }
82
+
83
+ /**
84
+ * The Chinese publish title of one episode: `第261120期 · 当日要点`. Returns `''` when the point
85
+ * is empty, so a caller can never emit a dangling `第261120期 · `.
86
+ */
87
+ export function composeEpisodeTitle(date: string, headline: string): string {
88
+ const label = issueLabel(date);
89
+ const point = clip(normalizeHeadline(headline), MAX_HEADLINE_CHARS);
90
+ return label === '' || point === '' ? '' : `${label} · ${point}`;
91
+ }
92
+
93
+ /**
94
+ * Freeze one episode's identity. Deterministic: the same inputs always produce the same record,
95
+ * and only admission can withhold the title — never a re-worded fallback.
96
+ */
97
+ export function freezeEpisodeIdentity(input: EpisodeIdentityInput): EpisodeIdentity {
98
+ const date = input.date.trim();
99
+ const issue = issueNumberOf(date);
100
+ const headline = normalizeHeadline(input.headline ?? '');
101
+ const supportingSourceIds = [...new Set((input.supportingSourceIds ?? []).map((id) => id.trim()))].filter(
102
+ (id) => id !== '',
103
+ );
104
+ const legacyTitle = (input.legacyTitle ?? '').trim();
105
+
106
+ if (headline === '' || issue === '') {
107
+ return {
108
+ version: 1,
109
+ date,
110
+ issue,
111
+ headline: null,
112
+ title: legacyTitle === '' ? null : legacyTitle,
113
+ coverHeadline: null,
114
+ supportingSourceIds: [],
115
+ status: 'no-headline',
116
+ };
117
+ }
118
+
119
+ // Admission is only consulted when the caller said what the headline rests on; "no ids named"
120
+ // is not evidence that the support vanished (legacy plans carry no id on the cover at all).
121
+ const admitted = new Set((input.admittedSourceIds ?? []).map((id) => id.trim()).filter((id) => id !== ''));
122
+ const supportRemoved = supportingSourceIds.length > 0 && !supportingSourceIds.some((id) => admitted.has(id));
123
+ if (supportRemoved) {
124
+ return {
125
+ version: 1,
126
+ date,
127
+ issue,
128
+ headline: null,
129
+ title: null,
130
+ coverHeadline: null,
131
+ supportingSourceIds,
132
+ status: 'support-removed',
133
+ };
134
+ }
135
+
136
+ const point = clip(headline, MAX_HEADLINE_CHARS);
137
+ return {
138
+ version: 1,
139
+ date,
140
+ issue,
141
+ headline: point,
142
+ title: `${issueLabel(date)} · ${point}`,
143
+ coverHeadline: point,
144
+ supportingSourceIds,
145
+ status: 'frozen',
146
+ };
147
+ }
148
+
149
+ /**
150
+ * The identity a bundle already ships, read back from its `metadata.episode-identity` — the retry
151
+ * and historical-replay path. Anything unrecognizable returns null (the caller freezes afresh)
152
+ * instead of throwing: an old bundle must still replay.
153
+ */
154
+ export function identityFromMetadata(metadata: unknown): EpisodeIdentity | null {
155
+ if (metadata === null || typeof metadata !== 'object') return null;
156
+ const raw = (metadata as Record<string, unknown>).episodeIdentity;
157
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return null;
158
+ const record = raw as Record<string, unknown>;
159
+ if (record.version !== 1) return null;
160
+ const status = record.status;
161
+ if (status !== 'frozen' && status !== 'no-headline' && status !== 'support-removed') return null;
162
+ if (typeof record.date !== 'string' || record.date.trim() === '') return null;
163
+ const text = (value: unknown): string | null => (typeof value === 'string' && value.trim() !== '' ? value : null);
164
+ const ids = Array.isArray(record.supportingSourceIds)
165
+ ? record.supportingSourceIds.filter((id): id is string => typeof id === 'string')
166
+ : [];
167
+ return {
168
+ version: 1,
169
+ date: record.date.trim(),
170
+ issue: typeof record.issue === 'string' ? record.issue : issueNumberOf(record.date),
171
+ headline: text(record.headline),
172
+ title: text(record.title),
173
+ coverHeadline: text(record.coverHeadline),
174
+ supportingSourceIds: ids,
175
+ status,
176
+ };
177
+ }
178
+
179
+ /** The metadata field the record is stamped under, so reader and writer cannot disagree. */
180
+ export const EPISODE_IDENTITY_KEY = 'episodeIdentity';
@@ -18,6 +18,8 @@
18
18
  * itc-publish-plan <work_dir> <targets> <source_locale> <publish_live> (0150, sibling)
19
19
  * itc-publish-fanout <work_dir> [--retry] (0151, sibling)
20
20
  * itc-publish-next <work_dir> (0151, sibling)
21
+ * music-* (0403, body in the sibling music-stages.ts): prepare/explore/select/
22
+ * analyze/judge-input/finalize for plugins/kk/workflows/kk-music.yaml
21
23
  *
22
24
  * `validate` / `wrap` / `render-storm` resolve the shipped sibling sidecars and delegate to them;
23
25
  * nothing about those sidecars changed. The `prepare-*` verbs and `duration` keep the logic that
@@ -175,6 +177,19 @@ async function loadAudioQuality(): Promise<typeof import('./audio-quality.ts')>
175
177
  );
176
178
  }
177
179
  }
180
+ /**
181
+ * Load the music-* helper sibling lazily (task 0403): it owns the kk-music workflow's fan-out and
182
+ * artifact assembly, and an install that still ships only the core runner must not break on load.
183
+ */
184
+ async function loadMusicStages(): Promise<typeof import('./music-stages.ts')> {
185
+ try {
186
+ return await import('./music-stages.ts');
187
+ } catch {
188
+ return fail(
189
+ 'music-stages.ts not found next to kk-workflow-stages.ts — install or refresh the kk package (bun link in a checkout)',
190
+ );
191
+ }
192
+ }
178
193
  export const ERRNO_REASONS: Record<string, string> = {
179
194
  EACCES: 'Permission denied',
180
195
  EROFS: 'Read-only file system',
@@ -1922,6 +1937,12 @@ if (import.meta.main)
1922
1937
  dailyEditorialRender(rest);
1923
1938
  break;
1924
1939
  }
1940
+ case 'news-editorial-commit': {
1941
+ // 0384 R4/R10: the judgment commit is async (the ledger's LockPort is promise-shaped).
1942
+ const { newsEditorialCommit } = await loadDailyStages();
1943
+ await newsEditorialCommit(rest);
1944
+ break;
1945
+ }
1925
1946
  case 'daily-script': {
1926
1947
  const { dailyScript } = await loadDailyStages();
1927
1948
  dailyScript(rest);
@@ -2078,6 +2099,11 @@ if (import.meta.main)
2078
2099
  dailyTranslateValidate(rest);
2079
2100
  break;
2080
2101
  }
2102
+ case 'news-localize-validate': {
2103
+ const { newsLocalizeValidate } = await loadDailyStages();
2104
+ newsLocalizeValidate(rest);
2105
+ break;
2106
+ }
2081
2107
  case 'itc-outline-pick': {
2082
2108
  const { itcOutlinePick } = await loadItcStages();
2083
2109
  itcOutlinePick(rest);
@@ -2113,6 +2139,16 @@ if (import.meta.main)
2113
2139
  itcAdaptVerify(rest);
2114
2140
  break;
2115
2141
  }
2142
+ case 'music-prepare':
2143
+ case 'music-explore':
2144
+ case 'music-select':
2145
+ case 'music-analyze':
2146
+ case 'music-judge-input':
2147
+ case 'music-finalize': {
2148
+ const { runMusicStage } = await loadMusicStages();
2149
+ runMusicStage(stage, rest);
2150
+ break;
2151
+ }
2116
2152
  case 'seo-preflight':
2117
2153
  case 'seo-collect':
2118
2154
  case 'seo-check':
@@ -2132,6 +2168,6 @@ if (import.meta.main)
2132
2168
  }
2133
2169
  default:
2134
2170
  fail(
2135
- `unknown stage: ${stage ?? '(none)'} (expected prepare-itc|prepare-solo|prepare-storm|validate|wrap|duration|render-storm|itc-*|daily-*|seo-*)`,
2171
+ `unknown stage: ${stage ?? '(none)'} (expected prepare-itc|prepare-solo|prepare-storm|validate|wrap|duration|render-storm|itc-*|daily-*|seo-*|music-*)`,
2136
2172
  );
2137
2173
  }