@gobing-ai/knowledge-kit 0.0.6 → 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 +21643 -11933
- 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 +299 -17
- package/plugins/kk/README.md +12 -1
- package/plugins/kk/commands/workflow-run.md +202 -0
- package/plugins/kk/config.example.yaml +34 -0
- package/plugins/kk/scripts/render-md.ts +150 -0
- package/plugins/kk/skills/{kk-judge → content-judge}/SKILL.md +13 -14
- package/plugins/kk/skills/{kk-judge → content-judge}/references/rubrics.md +2 -2
- package/plugins/kk/skills/{kk-judge → content-judge}/references/workflow-integration.md +17 -15
- 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 +173 -0
- package/plugins/kk/skills/{kk-topic → topic}/SKILL.md +4 -4
- 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/kk-storm-research.yaml +184 -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/kk-judge-compliance.md +0 -37
- package/plugins/kk/agents/kk-judge-tech.md +0 -35
- package/plugins/kk/agents/kk-judge-tone.md +0 -37
|
@@ -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,184 @@
|
|
|
1
|
+
---
|
|
2
|
+
# STORM topic-research daily workflow (C4):
|
|
3
|
+
# prepare -> ingest -> generate -> render -> done|failed.
|
|
4
|
+
#
|
|
5
|
+
# State-machine extension of the C3 dry-run prototype. Adds the 0056 XOR
|
|
6
|
+
# prepare + works layout, the generate local-doc merge, and the 0058 render
|
|
7
|
+
# sidecar state. No publish, no judge — by design (C4 scope).
|
|
8
|
+
#
|
|
9
|
+
# 0056 contract (docs/tasks/0056 ... Solution blocks 1-8): `work_dir` is the
|
|
10
|
+
# RESOLVED topic dir (`$works_root/<topic-id>`), computed by the invoker
|
|
11
|
+
# (0060/operator) and passed as `--vars`. prepare only `mkdir` + materializes
|
|
12
|
+
# files into `${vars.work_dir}`; it never hashes the topic-id in YAML. XOR:
|
|
13
|
+
# exactly one of `topic`/`input_file` must be non-empty.
|
|
14
|
+
#
|
|
15
|
+
# 0058 contract (docs/tasks/0058 ... Solution): render shells
|
|
16
|
+
# bun plugins/kk/scripts/render-md.ts --in <work_dir>/content.json \
|
|
17
|
+
# --out <work_dir>/content.md
|
|
18
|
+
#
|
|
19
|
+
# Success edges use `guard: { kind: always }` (repo convention — see the C3
|
|
20
|
+
# file and task-pipeline.yaml): a real-run action failure short-circuits at
|
|
21
|
+
# the state under the default onError=fail policy; `always` lets `--dry-run`
|
|
22
|
+
# walk to `done` (actions don't execute in dry-run, so `action-ok` would
|
|
23
|
+
# always deny and fall to `failed`).
|
|
24
|
+
"$schema": "@gobing-ai/spur/schemas/state-machine-workflow.schema.json"
|
|
25
|
+
name: kk-storm-research
|
|
26
|
+
kind: state-machine
|
|
27
|
+
description: >-
|
|
28
|
+
STORM daily topic research — XOR prepare into 0056 works layout, chain
|
|
29
|
+
ingest + generate, render content.md sidecar
|
|
30
|
+
initialState: prepare
|
|
31
|
+
terminalStates:
|
|
32
|
+
- done
|
|
33
|
+
- failed
|
|
34
|
+
vars:
|
|
35
|
+
topic: "" # sentence-mode query; ignored when input_file set (XOR)
|
|
36
|
+
input_file: "" # file-mode markdown path when non-empty (XOR)
|
|
37
|
+
maxResults: "8" # written into topic.json as int (0054 maxResults)
|
|
38
|
+
fixture: "false" # "true" selects the stub; CI/dry-run must pass "true"
|
|
39
|
+
work_dir: "./work" # RESOLVED topic dir ($works_root/<topic-id>)
|
|
40
|
+
plugins_path: "./plugins" # --plugins-path for kk executor run
|
|
41
|
+
ingestion_plugin: "web-search"
|
|
42
|
+
generator_plugin: "content-gen"
|
|
43
|
+
render_script: "plugins/kk/scripts/render-md.ts" # 0058 shipped runner
|
|
44
|
+
|
|
45
|
+
states:
|
|
46
|
+
- id: prepare
|
|
47
|
+
description: >-
|
|
48
|
+
mkdir work_dir; XOR guard; sentence mode writes topic.json; file mode
|
|
49
|
+
copies input.md, writes local-doc.json and topic.json with a derived
|
|
50
|
+
query
|
|
51
|
+
onEnter:
|
|
52
|
+
- kind: shell
|
|
53
|
+
options:
|
|
54
|
+
command: >-
|
|
55
|
+
set -e;
|
|
56
|
+
mkdir -p "${vars.work_dir}";
|
|
57
|
+
if [ -n "${vars.topic}" ] && [ -n "${vars.input_file}" ]; then
|
|
58
|
+
echo "XOR violation: both topic and input_file set" >&2; exit 1;
|
|
59
|
+
fi;
|
|
60
|
+
if [ -z "${vars.topic}" ] && [ -z "${vars.input_file}" ]; then
|
|
61
|
+
echo "XOR violation: neither topic nor input_file set" >&2;
|
|
62
|
+
exit 1;
|
|
63
|
+
fi;
|
|
64
|
+
if [ -n "${vars.topic}" ]; then
|
|
65
|
+
jq -n --arg topic "${vars.topic}" --arg maxResults
|
|
66
|
+
"${vars.maxResults}" --arg fixture "${vars.fixture}"
|
|
67
|
+
'{topic: $topic, maxResults: ($maxResults | tonumber),
|
|
68
|
+
fixture: ($fixture == "true")}' > "${vars.work_dir}/topic.json";
|
|
69
|
+
exit 0;
|
|
70
|
+
fi;
|
|
71
|
+
if [ -f "${vars.input_file}" ]; then
|
|
72
|
+
cp "${vars.input_file}" "${vars.work_dir}/input.md";
|
|
73
|
+
ABS=$(cd "$(dirname "${vars.input_file}")" && pwd)/$(basename
|
|
74
|
+
"${vars.input_file}");
|
|
75
|
+
QUERY=$(grep -m1 '^# ' "${vars.input_file}" | sed 's/^# *//'
|
|
76
|
+
|| true);
|
|
77
|
+
if [ -z "$QUERY" ]; then
|
|
78
|
+
QUERY=$(basename "${vars.input_file}" | sed 's/\.[^.]*$//');
|
|
79
|
+
fi;
|
|
80
|
+
if [ -z "$QUERY" ]; then
|
|
81
|
+
echo "no query derivable (no H1 and empty basename)" >&2;
|
|
82
|
+
exit 1;
|
|
83
|
+
fi;
|
|
84
|
+
ID=$(printf 'file://%s' "$ABS" | shasum -a 256 | cut -c1-16);
|
|
85
|
+
jq -n --arg id "$ID" --arg body "$(cat "${vars.input_file}")"
|
|
86
|
+
--arg title "$QUERY" --arg sourceUri "file://$ABS" --arg query
|
|
87
|
+
"$QUERY" '{id: $id, body: $body, title: $title, sourceUri:
|
|
88
|
+
$sourceUri, mediaType: "text/markdown",
|
|
89
|
+
metadata: {query: $query, rank: -1, position: 0}}'
|
|
90
|
+
> "${vars.work_dir}/local-doc.json";
|
|
91
|
+
jq -n --arg topic "$QUERY" --arg maxResults
|
|
92
|
+
"${vars.maxResults}" --arg fixture "${vars.fixture}"
|
|
93
|
+
'{topic: $topic, maxResults: ($maxResults | tonumber),
|
|
94
|
+
fixture: ($fixture == "true")}' > "${vars.work_dir}/topic.json";
|
|
95
|
+
else
|
|
96
|
+
echo "input_file not readable: ${vars.input_file}" >&2; exit 1;
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
- id: ingest
|
|
100
|
+
description: >-
|
|
101
|
+
Run web-search ingestion plugin to produce document list (docs.json)
|
|
102
|
+
onEnter:
|
|
103
|
+
- kind: shell
|
|
104
|
+
options:
|
|
105
|
+
command: >-
|
|
106
|
+
kk executor run "${vars.ingestion_plugin}" --in
|
|
107
|
+
"${vars.work_dir}/topic.json" --out "${vars.work_dir}/docs.json"
|
|
108
|
+
--plugins-path "${vars.plugins_path}"
|
|
109
|
+
|
|
110
|
+
- id: generate
|
|
111
|
+
description: >-
|
|
112
|
+
Prepend local-doc (when present) onto docs.json, then run content
|
|
113
|
+
generator to produce content.json
|
|
114
|
+
onEnter:
|
|
115
|
+
- kind: shell
|
|
116
|
+
options:
|
|
117
|
+
command: >-
|
|
118
|
+
if [ -f "${vars.work_dir}/local-doc.json" ]; then
|
|
119
|
+
jq -s '[.[0]] + .[1]' "${vars.work_dir}/local-doc.json"
|
|
120
|
+
"${vars.work_dir}/docs.json" > "${vars.work_dir}/docs.json.tmp"
|
|
121
|
+
&& mv "${vars.work_dir}/docs.json.tmp" "${vars.work_dir}/docs.json";
|
|
122
|
+
fi
|
|
123
|
+
- kind: shell
|
|
124
|
+
options:
|
|
125
|
+
command: >-
|
|
126
|
+
kk executor run "${vars.generator_plugin}" --in
|
|
127
|
+
"${vars.work_dir}/docs.json" --out "${vars.work_dir}/content.json"
|
|
128
|
+
--plugins-path "${vars.plugins_path}"
|
|
129
|
+
|
|
130
|
+
- id: render
|
|
131
|
+
description: >-
|
|
132
|
+
Render content.json to the markdown sidecar content.md via the 0058
|
|
133
|
+
shipped script
|
|
134
|
+
onEnter:
|
|
135
|
+
- kind: shell
|
|
136
|
+
options:
|
|
137
|
+
command: >-
|
|
138
|
+
bun "${vars.render_script}" --in "${vars.work_dir}/content.json"
|
|
139
|
+
--out "${vars.work_dir}/content.md"
|
|
140
|
+
|
|
141
|
+
- id: done
|
|
142
|
+
description: >-
|
|
143
|
+
Terminal — topic materialized, ingested, generated, and rendered to
|
|
144
|
+
content.md. No publish/judge by design (C4).
|
|
145
|
+
- id: failed
|
|
146
|
+
description: Terminal — one of the steps failed
|
|
147
|
+
|
|
148
|
+
transitions:
|
|
149
|
+
- from: prepare
|
|
150
|
+
to: ingest
|
|
151
|
+
description: Works materialized — proceed to web-search ingestion
|
|
152
|
+
guard:
|
|
153
|
+
kind: always
|
|
154
|
+
- from: prepare
|
|
155
|
+
to: failed
|
|
156
|
+
description: >-
|
|
157
|
+
prepare failed (XOR violation / unreadable input) — terminate workflow
|
|
158
|
+
|
|
159
|
+
- from: ingest
|
|
160
|
+
to: generate
|
|
161
|
+
description: Ingestion succeeded — proceed to content generation
|
|
162
|
+
guard:
|
|
163
|
+
kind: always
|
|
164
|
+
- from: ingest
|
|
165
|
+
to: failed
|
|
166
|
+
description: Ingestion failed — terminate workflow
|
|
167
|
+
|
|
168
|
+
- from: generate
|
|
169
|
+
to: render
|
|
170
|
+
description: Content generated — render the markdown sidecar
|
|
171
|
+
guard:
|
|
172
|
+
kind: always
|
|
173
|
+
- from: generate
|
|
174
|
+
to: failed
|
|
175
|
+
description: Generation failed — terminate workflow
|
|
176
|
+
|
|
177
|
+
- from: render
|
|
178
|
+
to: done
|
|
179
|
+
description: content.md rendered — workflow complete
|
|
180
|
+
guard:
|
|
181
|
+
kind: always
|
|
182
|
+
- from: render
|
|
183
|
+
to: failed
|
|
184
|
+
description: Render failed — terminate workflow
|