@gobing-ai/knowledge-kit 0.0.7 → 0.0.8
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.
- package/dist/index.js +21639 -11931
- package/package.json +4 -1
- package/plugins/generations/content-gen/package.json +2 -1
- package/plugins/generations/content-gen/src/index.ts +9 -8
- package/plugins/generations/content-gen/src/storm.ts +12 -4
- package/plugins/generations/voice-gen/package.json +17 -0
- package/plugins/generations/voice-gen/plugin.json +6 -0
- package/plugins/generations/voice-gen/src/concat.ts +218 -0
- package/plugins/generations/voice-gen/src/index.ts +213 -0
- package/plugins/generations/voice-gen/src/voicebox-client.ts +223 -0
- package/plugins/generations/voice-gen/src/voicescript.ts +365 -0
- package/plugins/generations/voice-gen/tsconfig.json +8 -0
- package/plugins/ingestions/karakeep-local/package.json +17 -0
- package/plugins/ingestions/karakeep-local/src/index.ts +31 -26
- package/plugins/ingestions/karakeep-local/tsconfig.json +4 -0
- package/plugins/ingestions/web-search/package.json +4 -1
- package/plugins/ingestions/web-search/src/index.ts +137 -15
- package/plugins/kk/README.md +9 -3
- package/plugins/kk/commands/workflow-run.md +100 -28
- package/plugins/kk/config.example.yaml +34 -0
- package/plugins/kk/scripts/render-md.ts +8 -3
- package/plugins/kk/skills/{judge → content-judge}/SKILL.md +13 -14
- package/plugins/kk/skills/{judge → content-judge}/references/workflow-integration.md +13 -11
- package/plugins/kk/skills/itc-generating/SKILL.md +147 -0
- package/plugins/kk/skills/itc-generating/references/generic-craft.md +80 -0
- package/plugins/kk/skills/itc-generating/references/platform-english.md +72 -0
- package/plugins/kk/skills/itc-generating/references/platform-wechat.md +60 -0
- package/plugins/kk/skills/itc-generating/references/skill-authoring.md +62 -0
- package/plugins/kk/skills/storm-research/SKILL.md +10 -3
- package/plugins/kk/workflows/judge-gated-publish-example.yaml +101 -0
- package/plugins/kk/workflows/kk-ingest-generate-publish.yaml +72 -0
- package/plugins/kk/workflows/kk-itc.yaml +285 -0
- package/plugins/kk/workflows/kk-solo-podcast.yaml +374 -0
- package/plugins/kk/workflows/validate-voicescript.ts +226 -0
- package/plugins/publishings/emdash-pub/package.json +17 -0
- package/plugins/publishings/emdash-pub/plugin.json +7 -0
- package/plugins/publishings/emdash-pub/src/index.ts +450 -0
- package/plugins/publishings/emdash-pub/tsconfig.json +4 -0
- package/plugins/publishings/qiita-pub/package.json +2 -1
- package/plugins/publishings/qiita-pub/src/index.ts +9 -9
- package/plugins/publishings/surfdash-pub/package.json +2 -1
- package/plugins/publishings/surfdash-pub/src/index.ts +16 -11
- package/plugins/publishings/zenn-pub/package.json +2 -1
- package/plugins/publishings/zenn-pub/src/index.ts +11 -11
- package/plugins/kk/agents/judge-compliance.md +0 -37
- package/plugins/kk/agents/judge-tech.md +0 -35
- package/plugins/kk/agents/judge-tone.md +0 -37
- /package/plugins/kk/skills/{judge → content-judge}/references/rubrics.md +0 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
---
|
|
2
|
+
"$schema": "@gobing-ai/spur/schemas/state-machine-workflow.schema.json"
|
|
3
|
+
name: kk-solo-podcast
|
|
4
|
+
kind: state-machine
|
|
5
|
+
description: >-
|
|
6
|
+
Solo podcast authoring pipeline using VoiceScript authoring, Spur HITL gates, and voice-gen audio generation
|
|
7
|
+
initialState: prepare
|
|
8
|
+
terminalStates:
|
|
9
|
+
- done
|
|
10
|
+
- failed
|
|
11
|
+
failureStates:
|
|
12
|
+
- failed
|
|
13
|
+
|
|
14
|
+
vars:
|
|
15
|
+
topic: ""
|
|
16
|
+
input_file: ""
|
|
17
|
+
work_dir: ""
|
|
18
|
+
force: "false"
|
|
19
|
+
outline: ""
|
|
20
|
+
script_approved: ""
|
|
21
|
+
target_duration_min: "8"
|
|
22
|
+
words_per_min: "150"
|
|
23
|
+
cjk_chars_per_min: "220"
|
|
24
|
+
voice_profile: ""
|
|
25
|
+
language: "en"
|
|
26
|
+
plugins_path: ""
|
|
27
|
+
validate_script: ""
|
|
28
|
+
agent: ""
|
|
29
|
+
__runId: "solo"
|
|
30
|
+
__hitlAnswer: ""
|
|
31
|
+
__hitlInput: ""
|
|
32
|
+
|
|
33
|
+
states:
|
|
34
|
+
- id: prepare
|
|
35
|
+
description: "mkdir work_dir and stage subdirectories; validate XOR topic/input_file and voice_profile; write brief.md"
|
|
36
|
+
onEnter:
|
|
37
|
+
- kind: shell
|
|
38
|
+
options:
|
|
39
|
+
command: >-
|
|
40
|
+
set -e;
|
|
41
|
+
if [ -z "${vars.work_dir}" ]; then
|
|
42
|
+
echo "missing work_dir" >&2; exit 1;
|
|
43
|
+
fi;
|
|
44
|
+
mkdir -p "${vars.work_dir}" "${vars.work_dir}/1-briefing" "${vars.work_dir}/2-outline" "${vars.work_dir}/3-script" "${vars.work_dir}/4-audio";
|
|
45
|
+
if [ -n "${vars.topic}" ] && [ -n "${vars.input_file}" ]; then
|
|
46
|
+
echo "XOR violation: both topic and input_file set" >&2; exit 1;
|
|
47
|
+
fi;
|
|
48
|
+
if [ -z "${vars.topic}" ] && [ -z "${vars.input_file}" ]; then
|
|
49
|
+
echo "XOR violation: neither topic nor input_file set" >&2; exit 1;
|
|
50
|
+
fi;
|
|
51
|
+
if [ -z "${vars.voice_profile}" ] && [ -z "$VOICEBOX_DEFAULT_PROFILE" ]; then
|
|
52
|
+
echo "missing voice_profile (set vars.voice_profile or VOICEBOX_DEFAULT_PROFILE)" >&2; exit 1;
|
|
53
|
+
fi;
|
|
54
|
+
if [ -f "${vars.work_dir}/brief.md" ] && [ "${vars.force}" != "true" ]; then
|
|
55
|
+
echo "initialization target already exists at ${vars.work_dir}/brief.md; pass force=true to replace" >&2; exit 1;
|
|
56
|
+
fi;
|
|
57
|
+
if [ -n "${vars.topic}" ]; then
|
|
58
|
+
printf '%s\n' "${vars.topic}" > "${vars.work_dir}/brief.md";
|
|
59
|
+
else
|
|
60
|
+
if [ ! -f "${vars.input_file}" ]; then
|
|
61
|
+
echo "input file not found: ${vars.input_file}" >&2; exit 1;
|
|
62
|
+
fi;
|
|
63
|
+
cp "${vars.input_file}" "${vars.work_dir}/brief.md";
|
|
64
|
+
fi;
|
|
65
|
+
|
|
66
|
+
- id: understand
|
|
67
|
+
description: "Analyze brief and generate podcast briefing (agent.run)"
|
|
68
|
+
onEnter:
|
|
69
|
+
- kind: agent.run
|
|
70
|
+
options:
|
|
71
|
+
role: scribe
|
|
72
|
+
agent: ${vars.agent}
|
|
73
|
+
input: |
|
|
74
|
+
Read the source brief at ${vars.work_dir}/brief.md.
|
|
75
|
+
Write a concise podcast briefing at ${vars.work_dir}/1-briefing/briefing.md.
|
|
76
|
+
Identify core thesis, key listener takeaways, audience profile, target spoken duration (${vars.target_duration_min} minutes), tone, and what material from the brief to emphasize or cut.
|
|
77
|
+
expectFile: ${vars.work_dir}/1-briefing/briefing.md
|
|
78
|
+
|
|
79
|
+
- id: outline-write
|
|
80
|
+
description: "Generate spoken podcast outline options (agent.run)"
|
|
81
|
+
onEnter:
|
|
82
|
+
- kind: agent.run
|
|
83
|
+
options:
|
|
84
|
+
role: scribe
|
|
85
|
+
agent: ${vars.agent}
|
|
86
|
+
input: |
|
|
87
|
+
Read the briefing at ${vars.work_dir}/1-briefing/briefing.md and brief at ${vars.work_dir}/brief.md.
|
|
88
|
+
Generate spoken podcast outline options in ${vars.work_dir}/2-outline/:
|
|
89
|
+
- outline-option-a.md (e.g. narrative / storytelling arc)
|
|
90
|
+
- outline-option-b.md (e.g. analytical / explainer breakdown)
|
|
91
|
+
- optional outline-option-c.md
|
|
92
|
+
Target total episode spoken duration is ${vars.target_duration_min} minutes.
|
|
93
|
+
Do not wait for operator selection; write the option files.
|
|
94
|
+
expectFile: ${vars.work_dir}/2-outline/outline-option-a.md
|
|
95
|
+
- kind: shell
|
|
96
|
+
options:
|
|
97
|
+
command: >-
|
|
98
|
+
test -f "${vars.work_dir}/2-outline/outline-option-b.md" || { echo "missing required outline-option-b.md" >&2; exit 1; }
|
|
99
|
+
|
|
100
|
+
- id: outline-select
|
|
101
|
+
description: "Operator selects preferred outline option"
|
|
102
|
+
pause: true
|
|
103
|
+
onEnter:
|
|
104
|
+
- kind: hitl.select
|
|
105
|
+
options:
|
|
106
|
+
prompt: "Select an approved outline option from ${vars.work_dir}/2-outline/ (outline-option-a.md, outline-option-b.md, or outline-option-c.md):"
|
|
107
|
+
options:
|
|
108
|
+
- a
|
|
109
|
+
- b
|
|
110
|
+
- c
|
|
111
|
+
var: __hitlAnswer
|
|
112
|
+
|
|
113
|
+
- id: outline-commit
|
|
114
|
+
description: "Copy selected outline to outline-approved.md"
|
|
115
|
+
onEnter:
|
|
116
|
+
- kind: shell
|
|
117
|
+
options:
|
|
118
|
+
command: >-
|
|
119
|
+
sel="${vars.outline}";
|
|
120
|
+
if [ -z "$sel" ]; then sel="${vars.__hitlAnswer}"; fi;
|
|
121
|
+
if [ -z "$sel" ]; then sel="a"; fi;
|
|
122
|
+
src="${vars.work_dir}/2-outline/outline-option-$sel.md";
|
|
123
|
+
if [ ! -f "$src" ]; then
|
|
124
|
+
echo "selected outline file not found: $src" >&2; exit 1;
|
|
125
|
+
fi;
|
|
126
|
+
cp "$src" "${vars.work_dir}/2-outline/outline-approved.md";
|
|
127
|
+
|
|
128
|
+
- id: script-write
|
|
129
|
+
description: "Author complete VoiceScript YAML from approved outline (agent.run)"
|
|
130
|
+
onEnter:
|
|
131
|
+
- kind: agent.run
|
|
132
|
+
options:
|
|
133
|
+
role: scribe
|
|
134
|
+
agent: ${vars.agent}
|
|
135
|
+
input: |
|
|
136
|
+
Read the approved outline at ${vars.work_dir}/2-outline/outline-approved.md and briefing at ${vars.work_dir}/1-briefing/briefing.md.
|
|
137
|
+
Target duration is ${vars.target_duration_min} minutes.
|
|
138
|
+
Spoken budget: if language (${vars.language}) is zh, ja, or ko, target characters = ${vars.target_duration_min} * ${vars.cjk_chars_per_min}; otherwise target words = ${vars.target_duration_min} * ${vars.words_per_min}. Land inside ±20%, spoken prose, one speaker.
|
|
139
|
+
Author the complete solo-podcast VoiceScript YAML at ${vars.work_dir}/3-script/voicescript.yaml.
|
|
140
|
+
Emit ONLY valid YAML (no markdown fences, no repo/docs paths). Contract:
|
|
141
|
+
title: string
|
|
142
|
+
language: "${vars.language}"
|
|
143
|
+
default_profile: "${vars.voice_profile}"
|
|
144
|
+
default_engine: qwen|qwen_custom_voice|luxtts|chatterbox|chatterbox_turbo|tada|kokoro # optional
|
|
145
|
+
segments:
|
|
146
|
+
- text: "spoken sentence" # required, 1..50000 characters
|
|
147
|
+
gap_ms: 400 # optional, >= 0, silence before next clip
|
|
148
|
+
instruct: "warm" # optional, <= 500 characters
|
|
149
|
+
Do not invent fields. Revision feedback: ${vars.__hitlInput}
|
|
150
|
+
expectFile: ${vars.work_dir}/3-script/voicescript.yaml
|
|
151
|
+
|
|
152
|
+
- id: script-validate
|
|
153
|
+
description: "Validate authored VoiceScript YAML structure and constraints"
|
|
154
|
+
onEnter:
|
|
155
|
+
- kind: shell
|
|
156
|
+
options:
|
|
157
|
+
command: >-
|
|
158
|
+
set -e;
|
|
159
|
+
vs="${vars.validate_script}";
|
|
160
|
+
if [ -z "$vs" ]; then
|
|
161
|
+
if [ -n "$KK_WORKFLOWS_DIR" ]; then vs="$KK_WORKFLOWS_DIR/validate-voicescript.ts";
|
|
162
|
+
else vs="$HOME/.config/kk/workflows/validate-voicescript.ts"; fi;
|
|
163
|
+
fi;
|
|
164
|
+
if [ ! -f "$vs" ]; then
|
|
165
|
+
echo "validate_script not found: $vs (install with /workflow-run kk-solo-podcast into $HOME/.config/kk/workflows)" >&2;
|
|
166
|
+
exit 1;
|
|
167
|
+
fi;
|
|
168
|
+
bun "$vs" --in "${vars.work_dir}/3-script/voicescript.yaml"
|
|
169
|
+
|
|
170
|
+
- id: script-review
|
|
171
|
+
description: "Operator reviews and approves VoiceScript before live TTS generation"
|
|
172
|
+
pause: true
|
|
173
|
+
onEnter:
|
|
174
|
+
- kind: hitl.confirm
|
|
175
|
+
options:
|
|
176
|
+
prompt: "Review VoiceScript at ${vars.work_dir}/3-script/voicescript.yaml. Approve for voice generation?"
|
|
177
|
+
var: __hitlAnswer
|
|
178
|
+
|
|
179
|
+
- id: script-revise
|
|
180
|
+
description: "Collect revision feedback from operator (bounded by 3 rounds)"
|
|
181
|
+
pause: true
|
|
182
|
+
onEnter:
|
|
183
|
+
- kind: shell
|
|
184
|
+
options:
|
|
185
|
+
command: >-
|
|
186
|
+
mkdir -p .spur/run;
|
|
187
|
+
run_id="${vars.__runId}";
|
|
188
|
+
if [ -z "$run_id" ]; then run_id="solo"; fi;
|
|
189
|
+
count_file=".spur/run/$run_id-solo-revise-count";
|
|
190
|
+
curr=$(cat "$count_file" 2>/dev/null || echo 0);
|
|
191
|
+
echo $((curr + 1)) > "$count_file";
|
|
192
|
+
- kind: hitl.input
|
|
193
|
+
options:
|
|
194
|
+
prompt: "Provide specific revision feedback for ${vars.work_dir}/3-script/voicescript.yaml:"
|
|
195
|
+
var: __hitlInput
|
|
196
|
+
|
|
197
|
+
- id: wrap-docs
|
|
198
|
+
description: "Wrap VoiceScript into Doc[] JSON for voice-gen generator plugin"
|
|
199
|
+
onEnter:
|
|
200
|
+
- kind: shell
|
|
201
|
+
options:
|
|
202
|
+
command: >-
|
|
203
|
+
bun -e '
|
|
204
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
205
|
+
import { createHash } from "node:crypto";
|
|
206
|
+
import { resolve } from "node:path";
|
|
207
|
+
const scriptPath = resolve(process.argv[1]);
|
|
208
|
+
const outPath = resolve(process.argv[2]);
|
|
209
|
+
const voiceProfile = process.argv[3] || process.env.VOICEBOX_DEFAULT_PROFILE || "";
|
|
210
|
+
const body = readFileSync(scriptPath, "utf-8");
|
|
211
|
+
const sourceUri = "file://" + scriptPath;
|
|
212
|
+
const id = createHash("sha256").update(sourceUri).digest("hex").slice(0, 16);
|
|
213
|
+
const doc = {
|
|
214
|
+
id,
|
|
215
|
+
title: "Podcast VoiceScript",
|
|
216
|
+
sourceUri,
|
|
217
|
+
body,
|
|
218
|
+
mediaType: "application/yaml",
|
|
219
|
+
metadata: voiceProfile ? { voiceProfile } : {},
|
|
220
|
+
};
|
|
221
|
+
writeFileSync(outPath, JSON.stringify([doc], null, 2));
|
|
222
|
+
' "${vars.work_dir}/3-script/voicescript.yaml" "${vars.work_dir}/4-audio/docs.json" "${vars.voice_profile}"
|
|
223
|
+
|
|
224
|
+
- id: generate
|
|
225
|
+
description: "Invoke voice-gen generator plugin to generate audio"
|
|
226
|
+
onEnter:
|
|
227
|
+
- kind: shell
|
|
228
|
+
options:
|
|
229
|
+
command: >-
|
|
230
|
+
set -e;
|
|
231
|
+
extra="";
|
|
232
|
+
if [ -n "${vars.plugins_path}" ]; then extra="--plugins-path ${vars.plugins_path}"; fi;
|
|
233
|
+
kk executor run voice-gen --in "${vars.work_dir}/4-audio/docs.json" --out "${vars.work_dir}/4-audio/content.json" $extra
|
|
234
|
+
|
|
235
|
+
- id: duration-check
|
|
236
|
+
description: "Validate generated audio duration against target budget"
|
|
237
|
+
|
|
238
|
+
- id: done
|
|
239
|
+
description: "Terminal — Solo podcast VoiceScript and audio generated successfully"
|
|
240
|
+
- id: failed
|
|
241
|
+
description: "Terminal — Solo podcast workflow failed or rejected"
|
|
242
|
+
|
|
243
|
+
transitions:
|
|
244
|
+
- from: prepare
|
|
245
|
+
to: understand
|
|
246
|
+
description: "Prepare completed -> begin briefing analysis"
|
|
247
|
+
guard:
|
|
248
|
+
kind: always
|
|
249
|
+
|
|
250
|
+
- from: understand
|
|
251
|
+
to: outline-write
|
|
252
|
+
description: "Briefing completed -> generate outline options"
|
|
253
|
+
guard:
|
|
254
|
+
kind: always
|
|
255
|
+
|
|
256
|
+
- from: outline-write
|
|
257
|
+
to: outline-select
|
|
258
|
+
description: "Outline not pre-selected -> pause for operator selection"
|
|
259
|
+
guard:
|
|
260
|
+
kind: shell
|
|
261
|
+
options:
|
|
262
|
+
command: 'test -z "${vars.outline}"'
|
|
263
|
+
|
|
264
|
+
- from: outline-write
|
|
265
|
+
to: outline-commit
|
|
266
|
+
description: "Outline pre-selected -> skip interactive selection"
|
|
267
|
+
guard:
|
|
268
|
+
kind: shell
|
|
269
|
+
options:
|
|
270
|
+
command: 'test -n "${vars.outline}"'
|
|
271
|
+
|
|
272
|
+
- from: outline-select
|
|
273
|
+
to: outline-commit
|
|
274
|
+
description: "Outline selected -> commit approved outline"
|
|
275
|
+
guard:
|
|
276
|
+
kind: always
|
|
277
|
+
|
|
278
|
+
- from: outline-commit
|
|
279
|
+
to: script-write
|
|
280
|
+
description: "Approved outline committed -> write VoiceScript"
|
|
281
|
+
guard:
|
|
282
|
+
kind: always
|
|
283
|
+
|
|
284
|
+
- from: script-write
|
|
285
|
+
to: script-validate
|
|
286
|
+
description: "VoiceScript written -> validate structure and caps"
|
|
287
|
+
guard:
|
|
288
|
+
kind: always
|
|
289
|
+
|
|
290
|
+
- from: script-validate
|
|
291
|
+
to: wrap-docs
|
|
292
|
+
description: "script_approved pre-set -> skip script review (CI/dry-run)"
|
|
293
|
+
guard:
|
|
294
|
+
kind: shell
|
|
295
|
+
options:
|
|
296
|
+
command: 'test "${vars.script_approved}" = "true"'
|
|
297
|
+
- from: script-validate
|
|
298
|
+
to: script-review
|
|
299
|
+
description: "VoiceScript validation passed -> pause for operator review"
|
|
300
|
+
guard:
|
|
301
|
+
kind: always
|
|
302
|
+
|
|
303
|
+
- from: script-review
|
|
304
|
+
to: wrap-docs
|
|
305
|
+
description: "VoiceScript approved -> wrap into Doc[] for generation"
|
|
306
|
+
guard:
|
|
307
|
+
kind: shell
|
|
308
|
+
options:
|
|
309
|
+
command: '{ test -z "${vars.__hitlAnswer}" || test "${vars.__hitlAnswer}" = "yes"; }'
|
|
310
|
+
|
|
311
|
+
- from: script-review
|
|
312
|
+
to: script-revise
|
|
313
|
+
description: "VoiceScript rejected with revision budget remaining -> collect feedback"
|
|
314
|
+
guard:
|
|
315
|
+
kind: shell
|
|
316
|
+
options:
|
|
317
|
+
command: 'test "${vars.__hitlAnswer}" = "no" && { run_id="${vars.__runId}"; if [ -z "$run_id" ]; then run_id="solo"; fi; test "$(cat .spur/run/$run_id-solo-revise-count 2>/dev/null || echo 0)" -lt 3; }'
|
|
318
|
+
|
|
319
|
+
- from: script-review
|
|
320
|
+
to: failed
|
|
321
|
+
description: "VoiceScript rejected with revision budget exhausted -> fail"
|
|
322
|
+
guard:
|
|
323
|
+
kind: shell
|
|
324
|
+
options:
|
|
325
|
+
command: 'test "${vars.__hitlAnswer}" = "no" && { run_id="${vars.__runId}"; if [ -z "$run_id" ]; then run_id="solo"; fi; test "$(cat .spur/run/$run_id-solo-revise-count 2>/dev/null || echo 0)" -ge 3; }'
|
|
326
|
+
|
|
327
|
+
- from: script-revise
|
|
328
|
+
to: script-write
|
|
329
|
+
description: "Feedback collected -> rewrite VoiceScript"
|
|
330
|
+
guard:
|
|
331
|
+
kind: always
|
|
332
|
+
|
|
333
|
+
- from: wrap-docs
|
|
334
|
+
to: generate
|
|
335
|
+
description: "Doc[] wrapped -> invoke voice-gen"
|
|
336
|
+
guard:
|
|
337
|
+
kind: always
|
|
338
|
+
|
|
339
|
+
- from: generate
|
|
340
|
+
to: duration-check
|
|
341
|
+
description: "Voice generation finished -> verify duration"
|
|
342
|
+
guard:
|
|
343
|
+
kind: always
|
|
344
|
+
|
|
345
|
+
- from: duration-check
|
|
346
|
+
to: done
|
|
347
|
+
description: "Audio duration within [0.5x, 2.0x] band or missing content.json in dry-run -> complete"
|
|
348
|
+
guard:
|
|
349
|
+
kind: shell
|
|
350
|
+
options:
|
|
351
|
+
command: >-
|
|
352
|
+
test ! -f "${vars.work_dir}/4-audio/content.json" || {
|
|
353
|
+
dur=$(jq -r '.metadata.duration // empty' "${vars.work_dir}/4-audio/content.json" 2>/dev/null);
|
|
354
|
+
test -n "$dur" && target_s=$((${vars.target_duration_min} * 60)) && min_s=$(awk -v t="$target_s" 'BEGIN {print t * 0.5}') && max_s=$(awk -v t="$target_s" 'BEGIN {print t * 2.0}') && awk -v d="$dur" -v min="$min_s" -v max="$max_s" 'BEGIN { if (d >= min && d <= max) exit 0; else exit 1 }';
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
- from: duration-check
|
|
358
|
+
to: failed
|
|
359
|
+
description: "Audio duration missing or outside [0.5x, 2.0x] target range -> fail"
|
|
360
|
+
guard:
|
|
361
|
+
kind: shell
|
|
362
|
+
options:
|
|
363
|
+
command: >-
|
|
364
|
+
test -f "${vars.work_dir}/4-audio/content.json" && {
|
|
365
|
+
dur=$(jq -r '.metadata.duration // empty' "${vars.work_dir}/4-audio/content.json" 2>/dev/null);
|
|
366
|
+
if [ -z "$dur" ]; then
|
|
367
|
+
echo "duration-check failed: metadata.duration missing or not a number" >&2;
|
|
368
|
+
exit 0;
|
|
369
|
+
fi;
|
|
370
|
+
target_s=$((${vars.target_duration_min} * 60));
|
|
371
|
+
min_s=$(awk -v t="$target_s" 'BEGIN {print t * 0.5}');
|
|
372
|
+
max_s=$(awk -v t="$target_s" 'BEGIN {print t * 2.0}');
|
|
373
|
+
awk -v d="$dur" -v min="$min_s" -v max="$max_s" -v ts="$target_s" 'BEGIN { if (d < min || d > max) { printf "duration-check failed: duration %ss outside 0.5x–2x of %ss\n", d, ts > "/dev/stderr"; exit 0 } else exit 1 }';
|
|
374
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Runtime VoiceScript checker for kk-solo-podcast.
|
|
4
|
+
*
|
|
5
|
+
* Copied with the workflow YAML into $KK_WORKFLOWS_DIR (default
|
|
6
|
+
* ~/.config/kk/workflows). Node/Bun builtins only — no @gobing-ai/* and no
|
|
7
|
+
* relative imports into generations/voice-gen (those paths do not exist next
|
|
8
|
+
* to the runtime copy).
|
|
9
|
+
*
|
|
10
|
+
* SYNC: plugins/generations/voice-gen/src/voicescript.ts (validateVoiceScript
|
|
11
|
+
* + engine/language enums + text/instruct/chunk/crossfade caps). Keep error
|
|
12
|
+
* substrings stable — apps/cli/tests/validate-voicescript.test.ts matches them.
|
|
13
|
+
*/
|
|
14
|
+
import { readFileSync } from 'node:fs';
|
|
15
|
+
import { parseArgs } from 'node:util';
|
|
16
|
+
|
|
17
|
+
const VOICEBOX_TEXT_MAX = 50_000;
|
|
18
|
+
const VOICEBOX_INSTRUCT_MAX = 500;
|
|
19
|
+
const VOICEBOX_CHUNK_CHARS_MIN = 100;
|
|
20
|
+
const VOICEBOX_CHUNK_CHARS_MAX = 5_000;
|
|
21
|
+
const VOICEBOX_CROSSFADE_MS_MIN = 0;
|
|
22
|
+
const VOICEBOX_CROSSFADE_MS_MAX = 500;
|
|
23
|
+
|
|
24
|
+
const VOICEBOX_ENGINES = [
|
|
25
|
+
'qwen',
|
|
26
|
+
'qwen_custom_voice',
|
|
27
|
+
'luxtts',
|
|
28
|
+
'chatterbox',
|
|
29
|
+
'chatterbox_turbo',
|
|
30
|
+
'tada',
|
|
31
|
+
'kokoro',
|
|
32
|
+
] as const;
|
|
33
|
+
|
|
34
|
+
const VOICEBOX_LANGUAGES = [
|
|
35
|
+
'zh',
|
|
36
|
+
'en',
|
|
37
|
+
'ja',
|
|
38
|
+
'ko',
|
|
39
|
+
'de',
|
|
40
|
+
'fr',
|
|
41
|
+
'ru',
|
|
42
|
+
'pt',
|
|
43
|
+
'es',
|
|
44
|
+
'it',
|
|
45
|
+
'he',
|
|
46
|
+
'ar',
|
|
47
|
+
'da',
|
|
48
|
+
'el',
|
|
49
|
+
'fi',
|
|
50
|
+
'hi',
|
|
51
|
+
'ms',
|
|
52
|
+
'nl',
|
|
53
|
+
'no',
|
|
54
|
+
'pl',
|
|
55
|
+
'sv',
|
|
56
|
+
'sw',
|
|
57
|
+
'tr',
|
|
58
|
+
] as const;
|
|
59
|
+
|
|
60
|
+
const ENGINE_SET = new Set<string>(VOICEBOX_ENGINES);
|
|
61
|
+
const LANGUAGE_SET = new Set<string>(VOICEBOX_LANGUAGES);
|
|
62
|
+
|
|
63
|
+
interface VoiceSpeaker {
|
|
64
|
+
profile: string;
|
|
65
|
+
engine?: string;
|
|
66
|
+
language?: string;
|
|
67
|
+
instruct?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface VoiceSegment {
|
|
71
|
+
speaker?: string;
|
|
72
|
+
profile?: string;
|
|
73
|
+
text: string;
|
|
74
|
+
instruct?: string;
|
|
75
|
+
engine?: string;
|
|
76
|
+
language?: string;
|
|
77
|
+
gap_ms?: number;
|
|
78
|
+
max_chunk_chars?: number;
|
|
79
|
+
crossfade_ms?: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface VoiceScript {
|
|
83
|
+
default_engine?: string;
|
|
84
|
+
language?: string;
|
|
85
|
+
speakers?: Record<string, VoiceSpeaker>;
|
|
86
|
+
segments: VoiceSegment[];
|
|
87
|
+
max_chunk_chars?: number;
|
|
88
|
+
crossfade_ms?: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function assertEngine(value: string | undefined, label: string): void {
|
|
92
|
+
if (value !== undefined && !ENGINE_SET.has(value)) {
|
|
93
|
+
throw new Error(`${label} engine must be one of ${VOICEBOX_ENGINES.join('|')} (got "${value}")`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function assertLanguage(value: string | undefined, label: string): void {
|
|
98
|
+
if (value !== undefined && !LANGUAGE_SET.has(value)) {
|
|
99
|
+
throw new Error(`${label} language must be a Voicebox language code (got "${value}")`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function assertChunk(value: number | undefined): void {
|
|
104
|
+
if (value === undefined) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (!Number.isInteger(value) || value < VOICEBOX_CHUNK_CHARS_MIN || value > VOICEBOX_CHUNK_CHARS_MAX) {
|
|
108
|
+
throw new Error(`max_chunk_chars must be between ${VOICEBOX_CHUNK_CHARS_MIN} and ${VOICEBOX_CHUNK_CHARS_MAX}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function assertCrossfade(value: number | undefined): void {
|
|
113
|
+
if (value === undefined) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!Number.isInteger(value) || value < VOICEBOX_CROSSFADE_MS_MIN || value > VOICEBOX_CROSSFADE_MS_MAX) {
|
|
117
|
+
throw new Error(`crossfade_ms must be between ${VOICEBOX_CROSSFADE_MS_MIN} and ${VOICEBOX_CROSSFADE_MS_MAX}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function validateVoiceScript(script: VoiceScript): void {
|
|
122
|
+
if (!script || typeof script !== 'object') {
|
|
123
|
+
throw new Error('VoiceScript must be an object');
|
|
124
|
+
}
|
|
125
|
+
if (!Array.isArray(script.segments) || script.segments.length === 0) {
|
|
126
|
+
throw new Error('VoiceScript must have a non-empty segments array');
|
|
127
|
+
}
|
|
128
|
+
assertChunk(script.max_chunk_chars);
|
|
129
|
+
assertCrossfade(script.crossfade_ms);
|
|
130
|
+
assertEngine(script.default_engine, 'VoiceScript default_engine');
|
|
131
|
+
assertLanguage(script.language, 'VoiceScript');
|
|
132
|
+
|
|
133
|
+
if (script.speakers) {
|
|
134
|
+
for (const [name, speaker] of Object.entries(script.speakers)) {
|
|
135
|
+
if (!speaker || typeof speaker !== 'object') {
|
|
136
|
+
throw new Error(`Speaker "${name}" definition must be an object`);
|
|
137
|
+
}
|
|
138
|
+
if (!speaker.profile || typeof speaker.profile !== 'string') {
|
|
139
|
+
throw new Error(`Speaker "${name}" must have a profile specified`);
|
|
140
|
+
}
|
|
141
|
+
if (typeof speaker.instruct === 'string' && speaker.instruct.length > VOICEBOX_INSTRUCT_MAX) {
|
|
142
|
+
throw new Error(`Speaker "${name}" instruct exceeds 500 characters (${speaker.instruct.length} chars)`);
|
|
143
|
+
}
|
|
144
|
+
assertEngine(speaker.engine, `Speaker "${name}"`);
|
|
145
|
+
assertLanguage(speaker.language, `Speaker "${name}"`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
for (let idx = 0; idx < script.segments.length; idx++) {
|
|
150
|
+
const segment = script.segments[idx];
|
|
151
|
+
if (!segment || typeof segment !== 'object') {
|
|
152
|
+
throw new Error(`Segment at index ${idx} must be an object`);
|
|
153
|
+
}
|
|
154
|
+
if (typeof segment.text !== 'string' || segment.text.length === 0) {
|
|
155
|
+
throw new Error(`Segment at index ${idx} text must not be empty`);
|
|
156
|
+
}
|
|
157
|
+
if (segment.text.length > VOICEBOX_TEXT_MAX) {
|
|
158
|
+
throw new Error(
|
|
159
|
+
`Segment text exceeds the 50,000-character Voicebox /generate cap (${segment.text.length} chars)`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (typeof segment.instruct === 'string' && segment.instruct.length > VOICEBOX_INSTRUCT_MAX) {
|
|
163
|
+
throw new Error(`Segment instruct exceeds 500 characters (${segment.instruct.length} chars)`);
|
|
164
|
+
}
|
|
165
|
+
if (segment.speaker && (!script.speakers || !(segment.speaker in script.speakers))) {
|
|
166
|
+
throw new Error(`Unknown speaker: "${segment.speaker}"`);
|
|
167
|
+
}
|
|
168
|
+
assertChunk(segment.max_chunk_chars);
|
|
169
|
+
assertCrossfade(segment.crossfade_ms);
|
|
170
|
+
if (segment.gap_ms !== undefined && (typeof segment.gap_ms !== 'number' || segment.gap_ms < 0)) {
|
|
171
|
+
throw new Error('gap_ms must be non-negative');
|
|
172
|
+
}
|
|
173
|
+
assertEngine(segment.engine, `Segment at index ${idx}`);
|
|
174
|
+
assertLanguage(segment.language, `Segment at index ${idx}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function main(): void {
|
|
179
|
+
const { values } = parseArgs({
|
|
180
|
+
args: process.argv.slice(2),
|
|
181
|
+
options: { in: { type: 'string' } },
|
|
182
|
+
strict: false,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const inPath = values.in;
|
|
186
|
+
if (!inPath) {
|
|
187
|
+
console.error('missing required --in <path>');
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
let raw: string;
|
|
192
|
+
try {
|
|
193
|
+
raw = readFileSync(inPath, 'utf-8');
|
|
194
|
+
} catch (err) {
|
|
195
|
+
console.error(`unreadable input file: ${inPath} (${err instanceof Error ? err.message : String(err)})`);
|
|
196
|
+
process.exit(1);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const trimmed = raw.trim();
|
|
200
|
+
if (trimmed === '') {
|
|
201
|
+
console.error(`input file is empty: ${inPath}`);
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let parsed: unknown;
|
|
206
|
+
try {
|
|
207
|
+
parsed = trimmed.startsWith('{') ? JSON.parse(trimmed) : Bun.YAML.parse(trimmed);
|
|
208
|
+
} catch (err) {
|
|
209
|
+
console.error(`failed to parse VoiceScript: ${err instanceof Error ? err.message : String(err)}`);
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
214
|
+
console.error('VoiceScript root must be an object');
|
|
215
|
+
process.exit(1);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
validateVoiceScript(parsed as VoiceScript);
|
|
220
|
+
} catch (err) {
|
|
221
|
+
console.error(`VoiceScript validation failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
222
|
+
process.exit(1);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
main();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gobing-ai/emdash-pub",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"typecheck": "tsc --noEmit"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@gobing-ai/kk-core": "workspace:*",
|
|
10
|
+
"@gobing-ai/publish-harness": "workspace:*",
|
|
11
|
+
"@gobing-ai/ts-runtime": "catalog:",
|
|
12
|
+
"@gobing-ai/ts-utils": "catalog:"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/bun": "1.3.14"
|
|
16
|
+
}
|
|
17
|
+
}
|