@gobing-ai/knowledge-kit 0.1.20 → 0.1.23

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 (149) 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 +13938 -8966
  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/gemini-tts/dist/index.js +47 -7
  13. package/plugins/generations/gemini-tts/src/gemini-client.ts +34 -6
  14. package/plugins/generations/music-gen/README.md +277 -0
  15. package/plugins/generations/music-gen/dist/index.js +23580 -0
  16. package/plugins/generations/music-gen/package.json +24 -0
  17. package/plugins/generations/music-gen/plugin.json +23 -0
  18. package/plugins/generations/music-gen/presets/SOURCE.md +39 -0
  19. package/plugins/generations/music-gen/presets/formats/clip.yaml +21 -0
  20. package/plugins/generations/music-gen/presets/formats/jingle.yaml +22 -0
  21. package/plugins/generations/music-gen/presets/formats/loop.yaml +21 -0
  22. package/plugins/generations/music-gen/presets/formats/song.yaml +36 -0
  23. package/plugins/generations/music-gen/presets/formats/underscore.yaml +22 -0
  24. package/plugins/generations/music-gen/presets/themes/ambient-tech.yaml +30 -0
  25. package/plugins/generations/music-gen/presets/themes/cinematic.yaml +30 -0
  26. package/plugins/generations/music-gen/presets/themes/lofi.yaml +30 -0
  27. package/plugins/generations/music-gen/presets/themes/synthwave.yaml +35 -0
  28. package/plugins/generations/music-gen/scripts/gen-preset-index.ts +181 -0
  29. package/plugins/generations/music-gen/scripts/resolve-preset.ts +64 -0
  30. package/plugins/generations/music-gen/src/adapter/index.ts +35 -0
  31. package/plugins/generations/music-gen/src/adapter/instance.ts +927 -0
  32. package/plugins/generations/music-gen/src/adapter/offline.ts +124 -0
  33. package/plugins/generations/music-gen/src/artifact.ts +223 -0
  34. package/plugins/generations/music-gen/src/audio/checks.ts +618 -0
  35. package/plugins/generations/music-gen/src/audio/master.ts +267 -0
  36. package/plugins/generations/music-gen/src/audio/measure.ts +507 -0
  37. package/plugins/generations/music-gen/src/audio/profile.ts +131 -0
  38. package/plugins/generations/music-gen/src/audio.ts +122 -0
  39. package/plugins/generations/music-gen/src/brief.ts +191 -0
  40. package/plugins/generations/music-gen/src/config.ts +451 -0
  41. package/plugins/generations/music-gen/src/content.ts +199 -0
  42. package/plugins/generations/music-gen/src/digest.ts +100 -0
  43. package/plugins/generations/music-gen/src/index.ts +147 -0
  44. package/plugins/generations/music-gen/src/job.ts +131 -0
  45. package/plugins/generations/music-gen/src/plugin.ts +371 -0
  46. package/plugins/generations/music-gen/src/presets.ts +951 -0
  47. package/plugins/generations/music-gen/src/render.ts +87 -0
  48. package/plugins/generations/music-gen/src/request.ts +102 -0
  49. package/plugins/generations/music-gen/src/spend.ts +495 -0
  50. package/plugins/generations/music-gen/tsconfig.json +8 -0
  51. package/plugins/generations/omni-voice-gen/uv.toml +5 -0
  52. package/plugins/generations/vibe-voice-tts/README.md +64 -0
  53. package/plugins/generations/vibe-voice-tts/dist/index.js +14259 -0
  54. package/plugins/generations/vibe-voice-tts/package.json +16 -0
  55. package/plugins/generations/vibe-voice-tts/plugin.json +6 -0
  56. package/plugins/generations/vibe-voice-tts/profiles.json +10 -0
  57. package/plugins/generations/vibe-voice-tts/pyproject.toml +9 -0
  58. package/plugins/generations/vibe-voice-tts/python/worker.py +566 -0
  59. package/plugins/generations/vibe-voice-tts/src/index.ts +88 -0
  60. package/plugins/generations/vibe-voice-tts/src/vibevoice-client.ts +828 -0
  61. package/plugins/generations/vibe-voice-tts/tsconfig.json +8 -0
  62. package/plugins/generations/vibe-voice-tts/uv.lock +1767 -0
  63. package/plugins/generations/vibe-voice-tts/uv.toml +4 -0
  64. package/plugins/generations/voice-gen/dist/index.js +31 -1
  65. package/plugins/generations/voice-gen/src/voicebox-client.ts +50 -1
  66. package/plugins/generations/voxcpm-tts/dist/index.js +81 -9
  67. package/plugins/generations/voxcpm-tts/python/worker.py +9 -0
  68. package/plugins/generations/voxcpm-tts/src/index.ts +41 -0
  69. package/plugins/generations/voxcpm-tts/src/voxcpm-client.ts +32 -11
  70. package/plugins/generations/voxcpm-tts/uv.toml +5 -0
  71. package/plugins/kk/README.md +21 -0
  72. package/plugins/kk/decisions/kk-safety.yaml +5 -2
  73. package/plugins/kk/plugin.json +1 -1
  74. package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +14 -2
  75. package/plugins/kk/scripts/cover-compositor.ts +380 -32
  76. package/plugins/kk/scripts/daily-cover-mock.ts +40 -3
  77. package/plugins/kk/scripts/daily-stages.ts +933 -60
  78. package/plugins/kk/scripts/episode-identity.ts +180 -0
  79. package/plugins/kk/scripts/kk-workflow-stages.ts +111 -12
  80. package/plugins/kk/scripts/music-stages.ts +624 -0
  81. package/plugins/kk/scripts/news-editorial-ledger.ts +906 -0
  82. package/plugins/kk/scripts/safety-artifact-check.ts +28 -5
  83. package/plugins/kk/scripts/source-citation.ts +187 -0
  84. package/plugins/kk/scripts/topic-selection-attempts.ts +446 -0
  85. package/plugins/kk/scripts/topic-selection-calibration.ts +161 -0
  86. package/plugins/kk/skills/content-judge/SKILL.md +11 -6
  87. package/plugins/kk/skills/content-judge/references/music-quality-rubric.md +147 -0
  88. package/plugins/kk/skills/content-judge/references/rubrics.md +15 -0
  89. package/plugins/kk/skills/content-safety/SKILL.md +12 -0
  90. package/plugins/kk/skills/music-authoring/SKILL.md +276 -0
  91. package/plugins/kk/skills/music-authoring/references/judge-input.md +117 -0
  92. package/plugins/kk/skills/news-editorial/SKILL.md +102 -15
  93. package/plugins/kk/skills/news-editorial/references/selection.md +4 -0
  94. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +58 -11
  95. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +12 -11
  96. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +13 -12
  97. package/plugins/kk/workflows/kk-daily-safety.yaml +12 -10
  98. package/plugins/kk/workflows/kk-music.yaml +332 -0
  99. package/plugins/kk/workflows/kk-news-generate.yaml +81 -6
  100. package/plugins/kk/workflows/kk-publish.yaml +4 -1
  101. package/plugins/publishings/bilibili-pub/dist/index.js +11 -1
  102. package/plugins/publishings/bilibili-pub/dist/profile-check.js +11 -1
  103. package/plugins/publishings/cnblogs-pub/dist/index.js +11 -1
  104. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +11 -1
  105. package/plugins/publishings/csdn-pub/dist/index.js +11 -1
  106. package/plugins/publishings/csdn-pub/dist/profile-check.js +11 -1
  107. package/plugins/publishings/infoq-pub/dist/index.js +11 -1
  108. package/plugins/publishings/infoq-pub/dist/profile-check.js +11 -1
  109. package/plugins/publishings/jike-pub/dist/index.js +11 -1
  110. package/plugins/publishings/jike-pub/dist/profile-check.js +11 -1
  111. package/plugins/publishings/juejin-pub/dist/index.js +11 -1
  112. package/plugins/publishings/juejin-pub/dist/profile-check.js +11 -1
  113. package/plugins/publishings/linkedin-pub/dist/index.js +62 -10
  114. package/plugins/publishings/linkedin-pub/dist/profile-check.js +16 -1
  115. package/plugins/publishings/linkedin-pub/src/index.ts +99 -12
  116. package/plugins/publishings/podcast-pub/dist/index.js +586 -20
  117. package/plugins/publishings/podcast-pub/src/corrections.ts +509 -0
  118. package/plugins/publishings/podcast-pub/src/index.ts +257 -5
  119. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +240 -0
  120. package/plugins/publishings/podcast-pub/src/show-notes.ts +69 -13
  121. package/plugins/publishings/shipinhao-pub/dist/index.js +59 -8
  122. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +11 -1
  123. package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +105 -6
  124. package/plugins/publishings/sspai-pub/dist/index.js +11 -1
  125. package/plugins/publishings/sspai-pub/dist/profile-check.js +11 -1
  126. package/plugins/publishings/substack-pub/dist/index.js +11 -1
  127. package/plugins/publishings/substack-pub/dist/profile-check.js +11 -1
  128. package/plugins/publishings/surfdash-pub/dist/index.js +80 -24
  129. package/plugins/publishings/surfdash-pub/src/digest-check.ts +7 -3
  130. package/plugins/publishings/surfdash-pub/src/index.ts +107 -18
  131. package/plugins/publishings/surfdash-pub/src/patch.ts +21 -3
  132. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +3 -1
  133. package/plugins/publishings/threads-pub/dist/index.js +58 -6
  134. package/plugins/publishings/threads-pub/dist/profile-check.js +18 -2
  135. package/plugins/publishings/threads-pub/src/post-rail.ts +101 -4
  136. package/plugins/publishings/wechatmp-pub/dist/index.js +105 -35
  137. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +11 -1
  138. package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +87 -53
  139. package/plugins/publishings/wechatmp-pub/src/enrich.ts +61 -3
  140. package/plugins/publishings/wechatmp-pub/src/flow.ts +28 -0
  141. package/plugins/publishings/weibo-pub/dist/index.js +11 -1
  142. package/plugins/publishings/weibo-pub/dist/profile-check.js +11 -1
  143. package/plugins/publishings/x-pub/dist/index.js +95 -10
  144. package/plugins/publishings/x-pub/dist/profile-check.js +11 -1
  145. package/plugins/publishings/x-pub/src/post-rail.ts +154 -12
  146. package/plugins/publishings/xhs-pub/dist/index.js +11 -1
  147. package/plugins/publishings/xhs-pub/dist/profile-check.js +11 -1
  148. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +11 -1
  149. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +11 -1
@@ -0,0 +1,4 @@
1
+ # Hardlink wheels from the shared uv cache instead of duplicating multi-gigabyte torch trees
2
+ # across local plugin virtualenvs. Override with UV_LINK_MODE=copy if ~/.cache/uv lives on a
3
+ # separate filesystem.
4
+ link-mode = "hardlink"
@@ -12669,6 +12669,19 @@ async function auditVoiceSegments(script, segmentWavs, segmentMetadata, client)
12669
12669
  }
12670
12670
 
12671
12671
  // ../../plugins/generations/voice-gen/src/voicebox-client.ts
12672
+ init_dist();
12673
+ var GPU_BACKENDS = new Set(["gpu", "mps", "metal", "cuda"]);
12674
+ function detectCpuFallback(payload) {
12675
+ if (payload.gpu_available !== true)
12676
+ return;
12677
+ const variant = (payload.backend_variant ?? "").toLowerCase();
12678
+ if (!variant || GPU_BACKENDS.has(variant))
12679
+ return;
12680
+ return payload;
12681
+ }
12682
+ function requireGpu(env) {
12683
+ return ["1", "true", "yes"].includes((env.VOICEBOX_REQUIRE_GPU ?? "").toLowerCase());
12684
+ }
12672
12685
  function resolveVoiceboxTimeoutMs() {
12673
12686
  const raw = process.env.VOICEBOX_TIMEOUT_MS;
12674
12687
  const parsed = raw ? Number.parseInt(raw, 10) : Number.NaN;
@@ -12683,8 +12696,9 @@ function createVoiceboxClient(options = {}) {
12683
12696
  return {
12684
12697
  url,
12685
12698
  async health() {
12699
+ let res;
12686
12700
  try {
12687
- const res = await customFetch(`${url}/health`, { signal: AbortSignal.timeout(requestTimeoutMs) });
12701
+ res = await customFetch(`${url}/health`, { signal: AbortSignal.timeout(requestTimeoutMs) });
12688
12702
  if (!res.ok) {
12689
12703
  throw new Error(`HTTP ${res.status} ${res.statusText}`);
12690
12704
  }
@@ -12692,6 +12706,21 @@ function createVoiceboxClient(options = {}) {
12692
12706
  const reason = err instanceof Error ? err.message : String(err);
12693
12707
  throw new Error(`Voicebox health check failed at ${url}: ${reason} \u2014 is Voicebox.app running with its REST server enabled? (restart the app or fix VOICEBOX_URL)`);
12694
12708
  }
12709
+ let payload;
12710
+ try {
12711
+ payload = await res.json();
12712
+ } catch {
12713
+ payload = undefined;
12714
+ }
12715
+ const fallback = payload && detectCpuFallback(payload);
12716
+ if (fallback) {
12717
+ const detail = `backend_variant: "${fallback.backend_variant}", gpu_available: true, gpu_type: "${fallback.gpu_type ?? "unknown"}"`;
12718
+ const message = `Voicebox at ${url} is rendering on CPU (${detail}) \u2014 expect ~5.6x realtime degradation. Restart Voicebox.app while Metal is free, or set VOICEBOX_REQUIRE_GPU=0 to accept it.`;
12719
+ if (requireGpu(process.env)) {
12720
+ throw new Error(`voice-gen: ${message}`);
12721
+ }
12722
+ echoError(`voice-gen: warning: ${message}`);
12723
+ }
12695
12724
  },
12696
12725
  async resolveProfile(nameOrId) {
12697
12726
  let res;
@@ -13545,6 +13574,7 @@ export {
13545
13574
  computeExpectedDurationRange,
13546
13575
  concatWavs,
13547
13576
  createVoiceboxClient,
13577
+ detectCpuFallback,
13548
13578
  detectLoudnessDip,
13549
13579
  detectRepetitions,
13550
13580
  isMp3Requested,
@@ -1,3 +1,5 @@
1
+ import { echoError } from '@gobing-ai/ts-utils';
2
+
1
3
  export interface EffectConfig {
2
4
  type: string;
3
5
  enabled?: boolean;
@@ -54,6 +56,35 @@ export interface VoiceboxClientOptions {
54
56
  sleep?: (ms: number) => Promise<void>;
55
57
  }
56
58
 
59
+ /** `/health` fields the CPU-fallback guard reads (observed live shape, 2026-11-20). */
60
+ export interface VoiceboxHealth {
61
+ status?: string;
62
+ gpu_available?: boolean;
63
+ gpu_type?: string;
64
+ backend_type?: string;
65
+ backend_variant?: string;
66
+ }
67
+
68
+ /** Backend variants that mean the GPU path is actually executing renders. */
69
+ const GPU_BACKENDS = new Set(['gpu', 'mps', 'metal', 'cuda']);
70
+
71
+ /**
72
+ * Voicebox reports `gpu_available: true` while rendering on `backend_variant: "cpu"` (~5.6x RTF).
73
+ * Returns the payload when the GPU exists but is not used, so the degradation is surfaced instead of
74
+ * silently costing an hour per episode (0417 R2).
75
+ */
76
+ export function detectCpuFallback(payload: VoiceboxHealth): VoiceboxHealth | undefined {
77
+ if (payload.gpu_available !== true) return undefined;
78
+ const variant = (payload.backend_variant ?? '').toLowerCase();
79
+ if (!variant || GPU_BACKENDS.has(variant)) return undefined;
80
+ return payload;
81
+ }
82
+
83
+ /** `VOICEBOX_REQUIRE_GPU` turns the CPU-fallback warning into a hard failure. */
84
+ function requireGpu(env: Record<string, string | undefined>): boolean {
85
+ return ['1', 'true', 'yes'].includes((env.VOICEBOX_REQUIRE_GPU ?? '').toLowerCase());
86
+ }
87
+
57
88
  /**
58
89
  * Creates a client for the Voicebox local REST API.
59
90
  */
@@ -79,8 +110,9 @@ export function createVoiceboxClient(options: VoiceboxClientOptions = {}): Voice
79
110
  url,
80
111
 
81
112
  async health(): Promise<void> {
113
+ let res: Response;
82
114
  try {
83
- const res = await customFetch(`${url}/health`, { signal: AbortSignal.timeout(requestTimeoutMs) });
115
+ res = await customFetch(`${url}/health`, { signal: AbortSignal.timeout(requestTimeoutMs) });
84
116
  if (!res.ok) {
85
117
  throw new Error(`HTTP ${res.status} ${res.statusText}`);
86
118
  }
@@ -90,6 +122,23 @@ export function createVoiceboxClient(options: VoiceboxClientOptions = {}): Voice
90
122
  `Voicebox health check failed at ${url}: ${reason} — is Voicebox.app running with its REST server enabled? (restart the app or fix VOICEBOX_URL)`,
91
123
  );
92
124
  }
125
+ // body read is best-effort: an older/partial /health must not fail the run (its JSON shape
126
+ // is not part of the client contract), only the CPU-fallback signal matters here.
127
+ let payload: VoiceboxHealth | undefined;
128
+ try {
129
+ payload = (await res.json()) as VoiceboxHealth;
130
+ } catch {
131
+ payload = undefined;
132
+ }
133
+ const fallback = payload && detectCpuFallback(payload);
134
+ if (fallback) {
135
+ const detail = `backend_variant: "${fallback.backend_variant}", gpu_available: true, gpu_type: "${fallback.gpu_type ?? 'unknown'}"`;
136
+ const message = `Voicebox at ${url} is rendering on CPU (${detail}) — expect ~5.6x realtime degradation. Restart Voicebox.app while Metal is free, or set VOICEBOX_REQUIRE_GPU=0 to accept it.`;
137
+ if (requireGpu(process.env)) {
138
+ throw new Error(`voice-gen: ${message}`);
139
+ }
140
+ echoError(`voice-gen: warning: ${message}`);
141
+ }
93
142
  },
94
143
 
95
144
  async resolveProfile(nameOrId: string): Promise<VoiceboxProfile> {
@@ -12672,6 +12672,19 @@ async function auditVoiceSegments(script, segmentWavs, segmentMetadata, client)
12672
12672
  }
12673
12673
 
12674
12674
  // ../../plugins/generations/voice-gen/src/voicebox-client.ts
12675
+ init_dist();
12676
+ var GPU_BACKENDS = new Set(["gpu", "mps", "metal", "cuda"]);
12677
+ function detectCpuFallback(payload) {
12678
+ if (payload.gpu_available !== true)
12679
+ return;
12680
+ const variant = (payload.backend_variant ?? "").toLowerCase();
12681
+ if (!variant || GPU_BACKENDS.has(variant))
12682
+ return;
12683
+ return payload;
12684
+ }
12685
+ function requireGpu(env) {
12686
+ return ["1", "true", "yes"].includes((env.VOICEBOX_REQUIRE_GPU ?? "").toLowerCase());
12687
+ }
12675
12688
  function resolveVoiceboxTimeoutMs() {
12676
12689
  const raw = process.env.VOICEBOX_TIMEOUT_MS;
12677
12690
  const parsed = raw ? Number.parseInt(raw, 10) : Number.NaN;
@@ -12686,8 +12699,9 @@ function createVoiceboxClient(options = {}) {
12686
12699
  return {
12687
12700
  url,
12688
12701
  async health() {
12702
+ let res;
12689
12703
  try {
12690
- const res = await customFetch(`${url}/health`, { signal: AbortSignal.timeout(requestTimeoutMs) });
12704
+ res = await customFetch(`${url}/health`, { signal: AbortSignal.timeout(requestTimeoutMs) });
12691
12705
  if (!res.ok) {
12692
12706
  throw new Error(`HTTP ${res.status} ${res.statusText}`);
12693
12707
  }
@@ -12695,6 +12709,21 @@ function createVoiceboxClient(options = {}) {
12695
12709
  const reason = err instanceof Error ? err.message : String(err);
12696
12710
  throw new Error(`Voicebox health check failed at ${url}: ${reason} \u2014 is Voicebox.app running with its REST server enabled? (restart the app or fix VOICEBOX_URL)`);
12697
12711
  }
12712
+ let payload;
12713
+ try {
12714
+ payload = await res.json();
12715
+ } catch {
12716
+ payload = undefined;
12717
+ }
12718
+ const fallback = payload && detectCpuFallback(payload);
12719
+ if (fallback) {
12720
+ const detail = `backend_variant: "${fallback.backend_variant}", gpu_available: true, gpu_type: "${fallback.gpu_type ?? "unknown"}"`;
12721
+ const message = `Voicebox at ${url} is rendering on CPU (${detail}) \u2014 expect ~5.6x realtime degradation. Restart Voicebox.app while Metal is free, or set VOICEBOX_REQUIRE_GPU=0 to accept it.`;
12722
+ if (requireGpu(process.env)) {
12723
+ throw new Error(`voice-gen: ${message}`);
12724
+ }
12725
+ echoError(`voice-gen: warning: ${message}`);
12726
+ }
12698
12727
  },
12699
12728
  async resolveProfile(nameOrId) {
12700
12729
  let res;
@@ -13695,6 +13724,8 @@ function createVoxCpmClient(options = {}) {
13695
13724
  let fatal;
13696
13725
  let closed = false;
13697
13726
  let stderrTail = "";
13727
+ let stderrDone = Promise.resolve();
13728
+ let exitDetails;
13698
13729
  let stdoutBuffer = "";
13699
13730
  let renderInFlight;
13700
13731
  let warnedChunk = false;
@@ -13785,22 +13816,35 @@ function createVoxCpmClient(options = {}) {
13785
13816
  child = proc;
13786
13817
  proc.on("error", (err) => fail(new Error(`voxcpm-tts: worker process error: ${err.message}`)));
13787
13818
  proc.on("exit", (code, signal) => {
13819
+ exitDetails = { code, signal };
13788
13820
  if (!closed && !fatal) {
13789
- fail(new Error(`voxcpm-tts: worker exited unexpectedly (code ${code ?? "null"}, signal ${signal ?? "none"})${stderrTail ? `: ${stderrTail.slice(-400)}` : ""}`));
13821
+ Promise.race([stderrDone, new Promise((r) => setTimeout(r, 150))]).then(() => {
13822
+ if (!closed && !fatal) {
13823
+ fail(new Error(`voxcpm-tts: worker exited unexpectedly (code ${code ?? "null"}, signal ${signal ?? "none"})${stderrTail ? `: ${stderrTail.slice(-400)}` : ""}`));
13824
+ }
13825
+ });
13790
13826
  }
13791
13827
  });
13828
+ if (proc.stderr) {
13829
+ stderrDone = pump(proc.stderr, (text) => {
13830
+ stderrTail = (stderrTail + text).slice(-STDERR_MAX_CHARS);
13831
+ });
13832
+ }
13792
13833
  if (proc.stdout) {
13793
13834
  pump(proc.stdout, consumeStdout, () => {
13794
13835
  if (!fatal && !closed) {
13795
- fail(new Error("voxcpm-tts: worker closed stdout before settling all requests"));
13836
+ Promise.race([
13837
+ Promise.all([waitForExit(proc, 250), stderrDone]),
13838
+ new Promise((r) => setTimeout(r, 250))
13839
+ ]).then(() => {
13840
+ if (!fatal && !closed) {
13841
+ const detail = exitDetails ? ` (code ${exitDetails.code ?? "null"}, signal ${exitDetails.signal ?? "none"})` : " before settling all requests";
13842
+ fail(new Error(`voxcpm-tts: worker closed stdout${detail}${stderrTail ? `: ${stderrTail.slice(-400)}` : ""}`));
13843
+ }
13844
+ });
13796
13845
  }
13797
13846
  });
13798
13847
  }
13799
- if (proc.stderr) {
13800
- pump(proc.stderr, (text) => {
13801
- stderrTail = (stderrTail + text).slice(-STDERR_MAX_CHARS);
13802
- });
13803
- }
13804
13848
  for (const signal of SIGNAL_HANDLERS) {
13805
13849
  const handler = () => {
13806
13850
  close();
@@ -14136,9 +14180,37 @@ async function main2(argv = process.argv.slice(2), options = {}) {
14136
14180
  args: argv,
14137
14181
  options: {
14138
14182
  in: { type: "string" },
14139
- out: { type: "string" }
14183
+ out: { type: "string" },
14184
+ batch: { type: "string" }
14140
14185
  }
14141
14186
  });
14187
+ const env = options.env ?? process.env;
14188
+ const batchPath = values.batch ?? env.VOXCPM_BATCH_MANIFEST;
14189
+ if (batchPath) {
14190
+ let entries;
14191
+ try {
14192
+ const parsed = JSON.parse(await Bun.file(batchPath).text());
14193
+ if (!Array.isArray(parsed) || parsed.some((e) => !e || typeof e !== "object" || typeof e.in !== "string" || typeof e.out !== "string")) {
14194
+ throw new Error("batch manifest must be an array of { in, out } string pairs");
14195
+ }
14196
+ entries = parsed;
14197
+ } catch (err) {
14198
+ echoError(`voxcpm-tts failed: invalid batch manifest: ${err instanceof Error ? err.message : String(err)}`);
14199
+ return 1;
14200
+ }
14201
+ const handle = createVoxCpmClient(options);
14202
+ try {
14203
+ for (const entry of entries) {
14204
+ await processGeneratorIO(entry.in, entry.out, handle.client, undefined, VOXCPM_TTS_GENERATOR);
14205
+ }
14206
+ return 0;
14207
+ } catch (err) {
14208
+ echoError(`voxcpm-tts failed: ${err instanceof Error ? err.message : String(err)}`);
14209
+ return 1;
14210
+ } finally {
14211
+ await handle.close();
14212
+ }
14213
+ }
14142
14214
  if (!values.in || !values.out) {
14143
14215
  echoError("voxcpm-tts failed: Missing required arguments: --in and --out");
14144
14216
  return 1;
@@ -183,6 +183,15 @@ def load_backend(environ: dict[str, str]) -> dict:
183
183
  if device not in ("auto", "cpu", "cuda", "mps"):
184
184
  raise WorkerError(f"unsupported VOXCPM_DEVICE {device!r} (allowed: auto, cpu, cuda, mps)")
185
185
 
186
+ if device == "mps":
187
+ with contextlib.redirect_stdout(sys.stderr):
188
+ import torch # type: ignore
189
+
190
+ if not torch.backends.mps.is_available():
191
+ raise WorkerError(
192
+ "VOXCPM_DEVICE='mps' requested, but PyTorch MPS backend is unavailable (refusing CPU fallback)"
193
+ )
194
+
186
195
  with contextlib.redirect_stdout(sys.stderr):
187
196
  import voxcpm # type: ignore
188
197
  from huggingface_hub import snapshot_download # type: ignore
@@ -5,11 +5,19 @@ import { createVoxCpmClient, VOXCPM_TTS_GENERATOR, type VoxCpmClientOptions } fr
5
5
 
6
6
  export * from './voxcpm-client';
7
7
 
8
+ interface BatchManifestEntry {
9
+ in: string;
10
+ out: string;
11
+ }
12
+
8
13
  /**
9
14
  * `kk` plugin entry: render Doc[] into audio Content through the shared voice-gen pipeline,
10
15
  * injecting the invocation-scoped VoxCPM adapter and closing it (worker, signals, scratch) in
11
16
  * `finally`. The worker stays lazy until `health()` runs after shared Doc validation, so empty
12
17
  * input starts nothing (AC3).
18
+ *
19
+ * When `VOXCPM_BATCH_MANIFEST` (or `--batch <path>`) is set, renders every `{ in, out }` entry
20
+ * sequentially against one shared worker handle so the model loads at most once per episode.
13
21
  */
14
22
  export async function main(argv: string[] = process.argv.slice(2), options: VoxCpmClientOptions = {}): Promise<number> {
15
23
  const { values } = parseArgs({
@@ -17,9 +25,42 @@ export async function main(argv: string[] = process.argv.slice(2), options: VoxC
17
25
  options: {
18
26
  in: { type: 'string' },
19
27
  out: { type: 'string' },
28
+ batch: { type: 'string' },
20
29
  },
21
30
  });
22
31
 
32
+ const env = options.env ?? (process.env as Record<string, string | undefined>);
33
+ const batchPath = values.batch ?? env.VOXCPM_BATCH_MANIFEST;
34
+
35
+ if (batchPath) {
36
+ let entries: BatchManifestEntry[];
37
+ try {
38
+ const parsed = JSON.parse(await Bun.file(batchPath).text()) as unknown;
39
+ if (
40
+ !Array.isArray(parsed) ||
41
+ parsed.some((e) => !e || typeof e !== 'object' || typeof e.in !== 'string' || typeof e.out !== 'string')
42
+ ) {
43
+ throw new Error('batch manifest must be an array of { in, out } string pairs');
44
+ }
45
+ entries = parsed as BatchManifestEntry[];
46
+ } catch (err: unknown) {
47
+ echoError(`voxcpm-tts failed: invalid batch manifest: ${err instanceof Error ? err.message : String(err)}`);
48
+ return 1;
49
+ }
50
+ const handle = createVoxCpmClient(options);
51
+ try {
52
+ for (const entry of entries) {
53
+ await processGeneratorIO(entry.in, entry.out, handle.client, undefined, VOXCPM_TTS_GENERATOR);
54
+ }
55
+ return 0;
56
+ } catch (err: unknown) {
57
+ echoError(`voxcpm-tts failed: ${err instanceof Error ? err.message : String(err)}`);
58
+ return 1;
59
+ } finally {
60
+ await handle.close();
61
+ }
62
+ }
63
+
23
64
  if (!values.in || !values.out) {
24
65
  echoError('voxcpm-tts failed: Missing required arguments: --in and --out');
25
66
  return 1;
@@ -269,6 +269,8 @@ export function createVoxCpmClient(options: VoxCpmClientOptions = {}): VoxCpmCli
269
269
  let fatal: Error | undefined;
270
270
  let closed = false;
271
271
  let stderrTail = '';
272
+ let stderrDone: Promise<void> = Promise.resolve();
273
+ let exitDetails: { code: number | null; signal: NodeJS.Signals | null } | undefined;
272
274
  let stdoutBuffer = '';
273
275
  let renderInFlight: { id: number; dest: string } | undefined;
274
276
  let warnedChunk = false;
@@ -363,26 +365,45 @@ export function createVoxCpmClient(options: VoxCpmClientOptions = {}): VoxCpmCli
363
365
  child = proc;
364
366
  proc.on('error', (err) => fail(new Error(`voxcpm-tts: worker process error: ${err.message}`)));
365
367
  proc.on('exit', (code, signal) => {
368
+ exitDetails = { code, signal };
366
369
  if (!closed && !fatal) {
367
- fail(
368
- new Error(
369
- `voxcpm-tts: worker exited unexpectedly (code ${code ?? 'null'}, signal ${signal ?? 'none'})${stderrTail ? `: ${stderrTail.slice(-400)}` : ''}`,
370
- ),
371
- );
370
+ void Promise.race([stderrDone, new Promise((r) => setTimeout(r, 150))]).then(() => {
371
+ if (!closed && !fatal) {
372
+ fail(
373
+ new Error(
374
+ `voxcpm-tts: worker exited unexpectedly (code ${code ?? 'null'}, signal ${signal ?? 'none'})${stderrTail ? `: ${stderrTail.slice(-400)}` : ''}`,
375
+ ),
376
+ );
377
+ }
378
+ });
372
379
  }
373
380
  });
381
+ if (proc.stderr) {
382
+ stderrDone = pump(proc.stderr, (text) => {
383
+ stderrTail = (stderrTail + text).slice(-STDERR_MAX_CHARS);
384
+ });
385
+ }
374
386
  if (proc.stdout) {
375
387
  void pump(proc.stdout, consumeStdout, () => {
376
388
  if (!fatal && !closed) {
377
- fail(new Error('voxcpm-tts: worker closed stdout before settling all requests'));
389
+ void Promise.race([
390
+ Promise.all([waitForExit(proc, 250), stderrDone]),
391
+ new Promise((r) => setTimeout(r, 250)),
392
+ ]).then(() => {
393
+ if (!fatal && !closed) {
394
+ const detail = exitDetails
395
+ ? ` (code ${exitDetails.code ?? 'null'}, signal ${exitDetails.signal ?? 'none'})`
396
+ : ' before settling all requests';
397
+ fail(
398
+ new Error(
399
+ `voxcpm-tts: worker closed stdout${detail}${stderrTail ? `: ${stderrTail.slice(-400)}` : ''}`,
400
+ ),
401
+ );
402
+ }
403
+ });
378
404
  }
379
405
  });
380
406
  }
381
- if (proc.stderr) {
382
- void pump(proc.stderr, (text) => {
383
- stderrTail = (stderrTail + text).slice(-STDERR_MAX_CHARS);
384
- });
385
- }
386
407
  // Normal-signal teardown: SIGTERM/SIGINT close, terminate and reap owned workers.
387
408
  for (const signal of SIGNAL_HANDLERS) {
388
409
  const handler = () => {
@@ -0,0 +1,5 @@
1
+ # Hardlink wheels from the shared uv cache instead of copying them. Measured 2026-11-20: this
2
+ # env and omni-voice-gen's held 2.45 GiB with zero hardlinked bytes, so torch/scipy/llvmlite
3
+ # were stored twice on top of ~/.cache/uv/archive-v0. Hardlinks need both paths on one
4
+ # filesystem; override with UV_LINK_MODE=copy if the cache ever moves to another device.
5
+ link-mode = "hardlink"
@@ -97,6 +97,27 @@ whole day, and the daily run closes as no-content. A render without the key is s
97
97
  value is simply empty, which spur reads as "not set". The rendered artifact carries a live
98
98
  credential: keep it in `~/Library/LaunchAgents` (or your crontab), never in a committed file.
99
99
 
100
+ The `kk-serve` plist additionally binds **`NODE_PATH` to the module root that carries
101
+ `@gobing-ai/spur`** (resolved from the `spur` on `PATH`, else the bun-global default). The project's
102
+ decision catalogs (`decisions.paths` → `plugins/kk/decisions`) declare
103
+ `$schema: "@gobing-ai/spur/schemas/decision-catalog.schema.json"`, and Bun's resolver does not search
104
+ the global install — so every job the scheduler launches, and every nested `spur`/`kk` it launches,
105
+ loses the whole decision layer without it. Not hypothetical: on 2026-11-19 a `bun install` run in
106
+ `$HOME` pruned the checkout's `/Users/robin/node_modules/@gobing-ai/spur` shadow, after which
107
+ `kk store label` died at catalog load (empty label artifact → `kk-collect` closed `failed-check`)
108
+ and spur's `decide` action silently loaded **zero** project catalogs, so `kk-safety-verdict` produced
109
+ no row and the safety gate refused the day's drafts. Leave the key in place when you hand-edit the
110
+ plist; re-rendering restores it.
111
+
112
+ Neither owner covers a bare interactive `kk store label` / `spur decision` in your own shell, which is
113
+ why this checkout keeps a `node_modules/@gobing-ai/spur` symlink to the installed package — the only
114
+ resolver that exists before any of those wrappers run. Nothing declares the package as a dependency
115
+ (it has to stay a latest global tool), so `bun install` is free to prune the link; `bun run prepare`
116
+ re-creates it from the `spur` on `PATH` on every install (`scripts/link-spur.ts`). Check with
117
+ `spur --no-logo decision list | grep -c plugins/kk/decisions` (0 = the decision layer is invisible) and
118
+ repair with `bun scripts/link-spur.ts`. A global `NODE_PATH` export in your shell rc is not the fix:
119
+ it leaks one checkout's global tree into every project on the machine.
120
+
100
121
  `kk-collect` collects every ingestion source into the kk store and never publishes. Two ticks that
101
122
  overlap are **one** collection: the first state takes `kk store lock acquire --name collect` and a
102
123
  tick that finds the claim inside its TTL exits 0 (`skipped`) without collecting. Before relying on
@@ -3,8 +3,11 @@
3
3
  # `kk-daily-safety` used to read the judge's self-reported `confidence` field in a shell `jq`
4
4
  # filter on the accept edge. The verdict is now a catalog decision over the SAME artifacts as
5
5
  # evidence, so the outcome is calibrated, ledgered (`decision_logs`) and carries a declared
6
- # fallback. The fallback is `escalate`, never `pass`: a missing, unreadable or garbled report has
7
- # to land on a recorded human decision, not on a silent publish.
6
+ # fallback. The fallback is `escalate`, never `pass`: the decision can always refuse to publish.
7
+ # A JUDGED escalate (the model read the evidence and could not settle it) needs a human, and the
8
+ # accept guard refuses it for an unattended run; an ABSTAINED row (`source: "default"` — the maker
9
+ # refused or was unavailable, so nothing was judged) is named by `kk stage daily-safety-verdict` and
10
+ # leaves the gate's own verdict in charge, because an abstention is not a verdict.
8
11
  #
9
12
  # Resolution: registered through `decisions.paths` in `.spur/config.yaml`
10
13
  # (project-relative `plugins/kk/decisions`). No maker is named here on purpose — the project
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "kk",
3
- "version": "0.1.20",
3
+ "version": "0.1.23",
4
4
  "description": "knowledge-kit Claude Code plugin: skills, commands, subagents, hooks, and rules"
5
5
  }
@@ -3,7 +3,7 @@
3
3
  <!-- kk-serve — keeps the knowledge-kit Spur server alive whenever this user is logged in.
4
4
 
5
5
  WHY the keepalive is not optional: the daily job `kk-daily-ai-voice` (cron `30 4 * * *`) is
6
- enqueued by the job worker that lives INSIDE `spur serve` (`.spur/config.yaml`
6
+ enqueued by the job worker that lives INSIDE `spur self serve` (`.spur/config.yaml`
7
7
  `bootstrap.scheduler`). On 2026-10-12 that process was SIGTERM'd at 00:17 local and not
8
8
  restarted until 10:00, so the 04:30 tick never fired and the day produced no episode at all —
9
9
  no workspace, no ledger row, no run record. `crontab -l` is empty and nothing else supervises
@@ -34,6 +34,7 @@
34
34
  <key>ProgramArguments</key>
35
35
  <array>
36
36
  <string>spur</string>
37
+ <string>self</string>
37
38
  <string>serve</string>
38
39
  <string>--cwd</string>
39
40
  <string>{{repo}}</string>
@@ -45,9 +46,18 @@
45
46
  </array>
46
47
  <key>WorkingDirectory</key>
47
48
  <string>{{repo}}</string>
48
- <!-- The environment block is load-bearing twice over:
49
+ <!-- The environment block is load-bearing three times over:
49
50
  - PATH — launchd starts with /usr/bin:/bin:/usr/sbin:/sbin and the scheduler's job worker
50
51
  runs its commands through /bin/sh -c, so bare `spur`, `kk`, `jq` and `bun` must resolve.
52
+ - NODE_PATH — the module root carrying `@gobing-ai/spur`. Project decision catalogs
53
+ (`decisions.paths` → `plugins/kk/decisions`) declare `$schema:
54
+ "@gobing-ai/spur/schemas/decision-catalog.schema.json"`, and Bun's resolver does not
55
+ search the global install, so WITHOUT this every registered catalog fails to load: kk
56
+ answers `Decision catalog … Cannot find package '@gobing-ai/spur'` (2026-11-19: a whole
57
+ `kk-collect` tick lost its labels and the next 04:30 run lost its `kk-safety-verdict`
58
+ row, which the gate read as a refusal) and spur's `decide` action silently loads ZERO
59
+ project catalogs. `kk schedule render` binds the path from the `spur` on PATH that the
60
+ `Program` below names; render from a shell that has it.
51
61
  - TYPESAFE_API_KEY — spur keeps the decision-maker credential env-only, and a server
52
62
  started from launchd inherits nothing from the operator's shell; without the key every
53
63
  `typesafe`-routed decision (kk-item-china-politics, -sensitivity, -audience) falls back
@@ -61,6 +71,8 @@
61
71
  <dict>
62
72
  <key>PATH</key>
63
73
  <string>{{home}}/.bun/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
74
+ <key>NODE_PATH</key>
75
+ <string>{{spur_modules}}</string>
64
76
  <key>TYPESAFE_API_KEY</key>
65
77
  <string>{{typesafe_api_key}}</string>
66
78
  </dict>