@gobing-ai/knowledge-kit 0.1.17 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/board/daily-voice/index.js +40 -7
  3. package/dist/index.js +8428 -4448
  4. package/package.json +1 -1
  5. package/plugins/generations/image-gen/README.md +31 -31
  6. package/plugins/generations/image-gen/assets/sample/provenance.json +314 -0
  7. package/plugins/generations/image-gen/config.example.yaml +3 -0
  8. package/plugins/generations/image-gen/dist/index.js +154 -14
  9. package/plugins/generations/image-gen/presets/SOURCE.md +65 -0
  10. package/plugins/generations/image-gen/scripts/eval-style-presets.ts +513 -0
  11. package/plugins/generations/image-gen/scripts/gen-samples.ts +57 -7
  12. package/plugins/generations/image-gen/src/presets.ts +6 -5
  13. package/plugins/generations/image-gen/src/providers/h3-local.ts +196 -0
  14. package/plugins/generations/image-gen/src/providers/types.ts +11 -1
  15. package/plugins/kk/config.example.yaml +7 -2
  16. package/plugins/kk/decisions/extract/ai-news.yaml +5 -2
  17. package/plugins/kk/plugin.json +1 -1
  18. package/plugins/kk/publish-presets/chinese-article.json +8 -2
  19. package/plugins/kk/publish-presets/daily-ai-voice-migration.json +1 -1
  20. package/plugins/kk/publish-presets/daily-ai-voice.json +57 -16
  21. package/plugins/kk/publish-presets/itc-main.json +36 -9
  22. package/plugins/kk/publish-presets/technical-article.json +8 -2
  23. package/plugins/kk/schedules/kk-daily-ai-voice3.cron.tmpl +8 -9
  24. package/plugins/kk/schedules/kk-daily-publish3-cn-peak.cron.tmpl +13 -19
  25. package/plugins/kk/schedules/kk-daily-publish3-overseas.cron.tmpl +11 -9
  26. package/plugins/kk/scripts/daily-stages.ts +238 -14
  27. package/plugins/kk/scripts/daily-triage-core.ts +43 -25
  28. package/plugins/kk/scripts/daily-triage.ts +1 -1
  29. package/plugins/kk/skills/image-authoring/SKILL.md +7 -3
  30. package/plugins/kk/skills/image-authoring/references/providers.md +27 -0
  31. package/plugins/kk/skills/image-authoring/references/style-extraction.md +1 -1
  32. package/plugins/kk/skills/publish/SKILL.md +15 -2
  33. package/plugins/kk/skills/web-automation/SKILL.md +31 -1
  34. package/plugins/kk/workflows/kk-article-generate.yaml +485 -0
  35. package/plugins/kk/workflows/kk-collect.yaml +8 -4
  36. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +2 -1
  37. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +4 -2
  38. package/plugins/kk/workflows/kk-daily-safety.yaml +5 -7
  39. package/plugins/kk/workflows/kk-news-generate.yaml +410 -0
  40. package/plugins/kk/workflows/kk-publish.yaml +236 -0
  41. package/plugins/publishings/bilibili-pub/dist/profile-check.js +49 -10
  42. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +60 -10
  43. package/plugins/publishings/csdn-pub/dist/profile-check.js +60 -10
  44. package/plugins/publishings/infoq-pub/dist/profile-check.js +60 -10
  45. package/plugins/publishings/jike-pub/dist/profile-check.js +60 -10
  46. package/plugins/publishings/juejin-pub/dist/profile-check.js +60 -10
  47. package/plugins/publishings/linkedin-pub/dist/index.js +43 -6
  48. package/plugins/publishings/linkedin-pub/dist/profile-check.js +92 -15
  49. package/plugins/publishings/linkedin-pub/src/index.ts +52 -6
  50. package/plugins/publishings/shipinhao-pub/dist/index.js +391 -32
  51. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +52 -11
  52. package/plugins/publishings/shipinhao-pub/plugin.json +1 -1
  53. package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +393 -0
  54. package/plugins/publishings/shipinhao-pub/src/flow.ts +243 -14
  55. package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -0
  56. package/plugins/publishings/sspai-pub/dist/profile-check.js +60 -10
  57. package/plugins/publishings/substack-pub/dist/profile-check.js +60 -10
  58. package/plugins/publishings/surfdash-pub/dist/index.js +50 -8
  59. package/plugins/publishings/surfdash-pub/src/index.ts +59 -8
  60. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +34 -3
  61. package/plugins/publishings/threads-pub/dist/index.js +9196 -296
  62. package/plugins/publishings/threads-pub/dist/profile-check.js +21139 -0
  63. package/plugins/publishings/threads-pub/package.json +3 -1
  64. package/plugins/publishings/threads-pub/plugin.json +6 -1
  65. package/plugins/publishings/threads-pub/src/index.ts +8 -1
  66. package/plugins/publishings/threads-pub/src/post-rail.ts +357 -0
  67. package/plugins/publishings/threads-pub/src/profile-check.ts +17 -0
  68. package/plugins/publishings/wechatmp-pub/dist/index.js +454 -81
  69. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +401 -102
  70. package/plugins/publishings/wechatmp-pub/src/flow.ts +42 -4
  71. package/plugins/publishings/wechatmp-pub/src/index.ts +142 -102
  72. package/plugins/publishings/wechatmp-pub/src/profile-check.ts +36 -58
  73. package/plugins/publishings/weibo-pub/dist/index.js +136 -22
  74. package/plugins/publishings/weibo-pub/dist/profile-check.js +61 -11
  75. package/plugins/publishings/weibo-pub/src/index.ts +208 -22
  76. package/plugins/publishings/x-pub/dist/index.js +263 -43
  77. package/plugins/publishings/x-pub/dist/profile-check.js +63 -11
  78. package/plugins/publishings/x-pub/src/index.ts +15 -1
  79. package/plugins/publishings/x-pub/src/post-rail.ts +334 -0
  80. package/plugins/publishings/xhs-pub/dist/index.js +193 -201
  81. package/plugins/publishings/xhs-pub/dist/profile-check.js +380 -85
  82. package/plugins/publishings/xhs-pub/src/automation-guard.ts +2 -3
  83. package/plugins/publishings/xhs-pub/src/flow.ts +177 -205
  84. package/plugins/publishings/xhs-pub/src/index.ts +65 -59
  85. package/plugins/publishings/xhs-pub/src/modes.ts +1 -1
  86. package/plugins/publishings/xhs-pub/src/page.ts +2 -2
  87. package/plugins/publishings/xhs-pub/src/profile-check.ts +86 -150
  88. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +60 -10
  89. package/plugins/kk/scripts/daily-scheduled-run.ts +0 -581
  90. package/plugins/kk/scripts/voice3-publish-window.ts +0 -206
  91. package/plugins/kk/workflows/kk-daily-ai-voice3.yaml +0 -903
  92. package/plugins/kk/workflows/kk-daily-publish3.yaml +0 -353
  93. package/plugins/kk/workflows/kk-itc-author.yaml +0 -484
  94. package/plugins/kk/workflows/kk-itc-publish-tail.yaml +0 -112
  95. package/plugins/kk/workflows/kk-itc.yaml +0 -291
@@ -0,0 +1,410 @@
1
+ ---
2
+ name: kk-news-generate
3
+ kind: dag
4
+ version: "1"
5
+ description: >-
6
+ The news generation workflow (G61 / ADR-053 §5, design
7
+ `docs/design/content-pipeline-consolidation.md` §5.1, task 0367): twenty nodes, launched by
8
+ `kk news generate`. It replaces the forty-three nodes of the retired voice3 DAG — the ten
9
+ deterministic nodes that composed and gated the run are one `kk news prepare`, the fifteen
10
+ generation nodes are four step verbs, and the publish tail is gone (`generate --publish` launches
11
+ `kk news publish` after this workflow exits 0). It publishes nothing: the channel matrix lives in
12
+ the publish preset and `kk-publish`.
13
+ Re-enter a failed run with
14
+ `spur workflow run plugins/kk/workflows/kk-news-generate.yaml --vars '{"work_dir":"<run dir>","run_date":"<YYYYMMDD>"}'`
15
+ — every boundary node is a verb whose stages are cached or idempotent, and the pool gate says
16
+ whether there is anything to generate at all.
17
+
18
+ # ADR-053 §5: ONE executor variable drives every agent node. `agent` arrives from the launching verb
19
+ # (`kk news generate --agent`), defaults to `inline`, and every retry node resolves by `role:
20
+ # reviewer` instead of carrying a second executor pin (0360 R2).
21
+ #
22
+ # The run identity arrives from `kk news generate` (`work_dir`, `run_date`, `run_id`, `skill_dir`),
23
+ # so no node reads a work directory out of a token file and no shell action sets a var (shell actions
24
+ # cannot: the engine's only var writers are the launching verb and `file.read.into-var`, which AC1
25
+ # forbids here). `preset` names the publish preset the freeze validates against; `skip_review` turns
26
+ # the operator's review pause off.
27
+ vars:
28
+ work_dir: ""
29
+ run_date: ""
30
+ run_id: ""
31
+ agent: inline
32
+ # The writer skill, read in place (design §2.2): `<package>/plugins/kk/skills/news-editorial`. No
33
+ # `20-editorial/` copy and no style-contract copy exist in a new run — the prompts cite this path.
34
+ skill_dir: ""
35
+ skip_review: "false"
36
+ preset: ""
37
+
38
+ # Node policy (unchanged from voice3 where it earns its place):
39
+ # * a node whose dependencies were ALL skipped is skipped; a done+skipped mix still runs;
40
+ # * any failed node fails the run unless its action says `onError: continue`, which is how the
41
+ # bounded voice chain and the advisory nodes keep a day alive;
42
+ # * nodes are declared in topological order — the engine settles skips in one pass over this list;
43
+ # * every node after `prepare` conditions on `pool-gate.json`, so an empty pool (a no-content day)
44
+ # skips the whole content subtree and the run still closes `done`.
45
+ nodes:
46
+ # ── 1. executor-probe: one real prompt, before any spend (0360 R4) ───────────────────────────
47
+ - id: executor-probe
48
+ description: "One real prompt to the resolved executor; a dead executor fails the run here (ADR-053 §5)"
49
+ action:
50
+ kind: agent.run
51
+ options:
52
+ role: scribe
53
+ agent: ${vars.agent}
54
+ timeoutMs: 120000
55
+ input: "Reply with exactly: OK"
56
+
57
+ # ── 2. prepare: workspace, pool, QC, selection, the pool gate ────────────────────────────────
58
+ - id: prepare
59
+ description: >-
60
+ `kk news prepare` — one verb for voice3's ten composition nodes: `daily-preflight` (the stage
61
+ roster check: this checkout's YAML against the installed stage runner), the warn-only session
62
+ probe, `daily-extract`, `daily-plan`, `daily-qc-content`, `kk store select` (the cross-day
63
+ selection ledger) and the pool gate, written as `pool-gate.json` `{status: PASS|EMPTY}` inside
64
+ the run directory instead of a token under `.spur/run/`. It exits 0 on an empty pool: a thin
65
+ day is a verdict, not a failure, and every later node reads the gate.
66
+ dependsOn: [executor-probe]
67
+ action:
68
+ kind: shell
69
+ options:
70
+ command: >-
71
+ kk news prepare --work-dir "${vars.work_dir}" --run-date "${vars.run_date}" --ledger-sync
72
+
73
+ # ── 3–6. curate: the agent call, its two guards and the documented fallback ──────────────────
74
+ - id: curate
75
+ description: "Curate the QC candidates into a translated plan + exclusion list via the writer skill's `curate` mode (10 min behind, so it is guarded below)"
76
+ dependsOn: [prepare]
77
+ condition:
78
+ kind: shell
79
+ options:
80
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
81
+ action:
82
+ kind: agent.run
83
+ onError: continue
84
+ options:
85
+ role: scribe
86
+ agent: ${vars.agent}
87
+ timeoutMs: 600000
88
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
89
+ input: |
90
+ Follow mode `curate` in ${vars.skill_dir}/SKILL.md (read references/selection.md and references/style-contract.zh.md first).
91
+ --in ${vars.work_dir}/21-plan/${vars.run_date}_04_quality-control-content_candidates.json (metadata.docs is the candidate Doc[]; don't edit it)
92
+ --out-plan ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json
93
+ --out-excluded ${vars.work_dir}/21-plan/${vars.run_date}_03_curate_excluded.json
94
+ Deliver both JSON files with your file-write tool (a headless sandbox may block shell writes).
95
+ expectFile: ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json
96
+ allowAppend: false
97
+
98
+ - id: curate-check
99
+ description: "`generate-check --step curate`: validate the split, unwrap a Content envelope, dedup near-duplicate titles; a fix verdict writes _03_curate_errors.json"
100
+ dependsOn: [curate]
101
+ condition:
102
+ kind: shell
103
+ options:
104
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
105
+ action:
106
+ kind: shell
107
+ options:
108
+ command: 'kk news generate-check --work-dir "${vars.work_dir}" --step curate'
109
+
110
+ - id: curate-fix
111
+ description: "One targeted `curate --fix` pass on the check's errors — the reviewer rung, so a dead operator pin still has a second attempt"
112
+ dependsOn: [curate-check]
113
+ condition:
114
+ kind: shell
115
+ options:
116
+ command: >-
117
+ test -s "${vars.work_dir}/21-plan/${vars.run_date}_03_curate_errors.json"
118
+ && grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null
119
+ action:
120
+ kind: agent.run
121
+ onError: continue
122
+ options:
123
+ role: reviewer
124
+ agent: ${vars.agent}
125
+ timeoutMs: 600000
126
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
127
+ input: |
128
+ Follow mode `curate --fix` in ${vars.skill_dir}/SKILL.md (read references/selection.md and references/style-contract.zh.md first).
129
+ --in ${vars.work_dir}/21-plan/${vars.run_date}_04_quality-control-content_candidates.json (metadata.docs is the candidate Doc[]; don't edit it)
130
+ --fix ${vars.work_dir}/21-plan/${vars.run_date}_03_curate_errors.json
131
+ --out-plan ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json
132
+ --out-excluded ${vars.work_dir}/21-plan/${vars.run_date}_03_curate_excluded.json
133
+ Deliver both corrected JSON files with your file-write tool.
134
+ expectFile: ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json
135
+ allowAppend: false
136
+
137
+ - id: curate-final
138
+ description: "`generate-check --step curate --final`: the documented fallback — untranslated candidates with `[]` exclusions — when the fix pass still fails"
139
+ dependsOn: [curate-check, curate-fix]
140
+ condition:
141
+ kind: shell
142
+ options:
143
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
144
+ action:
145
+ kind: shell
146
+ options:
147
+ command: 'kk news generate-check --work-dir "${vars.work_dir}" --step curate --final'
148
+
149
+ # ── 7–10. script-write: the master script plan, its guards, the advisory judge ───────────────
150
+ - id: script-write
151
+ description: "Author the master script plan (intro/outro, lead/insight/card per doc id, cover, cards, social, excluded); a rejected plan falls back to templates inside `generate-render` (F613)"
152
+ dependsOn: [curate-final]
153
+ condition:
154
+ kind: shell
155
+ options:
156
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
157
+ action:
158
+ kind: agent.run
159
+ onError: continue
160
+ options:
161
+ role: scribe
162
+ agent: ${vars.agent}
163
+ timeoutMs: 600000
164
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
165
+ input: |
166
+ Follow mode `write` in ${vars.skill_dir}/SKILL.md (read its references first: the skill owns selection, balance, style contract and the master output shape).
167
+ --in ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json (don't edit it)
168
+ --excluded ${vars.work_dir}/21-plan/${vars.run_date}_03_curate_excluded.json
169
+ --out ${vars.work_dir}/24-script/${vars.run_date}_08_script-write_plan.json
170
+ Output only the JSON file.
171
+ expectFile: ${vars.work_dir}/24-script/${vars.run_date}_08_script-write_plan.json
172
+ allowAppend: false
173
+
174
+ - id: script-check
175
+ description: "`generate-check --step script`: dry-run the script validator; a fix verdict writes _08_script-write_errors.json beside the plan"
176
+ dependsOn: [script-write]
177
+ condition:
178
+ kind: shell
179
+ options:
180
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
181
+ action:
182
+ kind: shell
183
+ options:
184
+ command: 'kk news generate-check --work-dir "${vars.work_dir}" --step script'
185
+
186
+ - id: script-fix
187
+ description: "One targeted `write --fix` pass on the validator's errors (reviewer rung); still-rejected plans fall back to templates"
188
+ dependsOn: [script-check, curate-final]
189
+ condition:
190
+ kind: shell
191
+ options:
192
+ command: >-
193
+ test -s "${vars.work_dir}/24-script/${vars.run_date}_08_script-write_errors.json"
194
+ && grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null
195
+ action:
196
+ kind: agent.run
197
+ onError: continue
198
+ options:
199
+ role: reviewer
200
+ agent: ${vars.agent}
201
+ timeoutMs: 600000
202
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
203
+ input: |
204
+ Follow mode `write --fix` in ${vars.skill_dir}/SKILL.md (read its references first).
205
+ --in ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json (don't edit it)
206
+ --excluded ${vars.work_dir}/21-plan/${vars.run_date}_03_curate_excluded.json
207
+ Previous plan (may be absent): ${vars.work_dir}/24-script/${vars.run_date}_08_script-write_plan.json
208
+ --fix ${vars.work_dir}/24-script/${vars.run_date}_08_script-write_errors.json
209
+ --out ${vars.work_dir}/24-script/${vars.run_date}_08_script-write_plan.json (overwrite it with the full corrected plan)
210
+ Output only the JSON file.
211
+ expectFile: ${vars.work_dir}/24-script/${vars.run_date}_08_script-write_plan.json
212
+ allowAppend: false
213
+
214
+ - id: editorial-judge
215
+ description: "Advisory kk:content-judge evaluation of the script plan under the news-balance rubric; nothing depends on it for control flow (0345 R11)"
216
+ dependsOn: [script-check, script-fix]
217
+ condition:
218
+ kind: shell
219
+ options:
220
+ command: >-
221
+ test -s "${vars.work_dir}/24-script/${vars.run_date}_08_script-write_plan.json"
222
+ && grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null
223
+ action:
224
+ kind: agent.run
225
+ onError: continue
226
+ options:
227
+ role: reviewer
228
+ agent: ${vars.agent}
229
+ timeoutMs: 600000
230
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
231
+ input: |
232
+ You are an LLM-as-judge evaluating a daily news script plan for the knowledge-kit pipeline.
233
+ Content to evaluate: ${vars.work_dir}/24-script/${vars.run_date}_08_script-write_plan.json
234
+ Plan docs reference: ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json
235
+ Rubric: news-balance
236
+ Load the rubric definition from plugins/kk/skills/content-judge/references/rubrics.md (section: news-balance) and the contract from plugins/kk/skills/content-judge/SKILL.md.
237
+ Evaluate the script plan against every criterion in news-balance (news-first, commentary-share, no-restatement, tech-depth, ordering).
238
+ Write the verdict JSON (with confidence HIGH | MEDIUM | LOW) to ${vars.work_dir}/24-script/${vars.run_date}_08_editorial-judge_verdict.json.
239
+ expectFile: ${vars.work_dir}/24-script/${vars.run_date}_08_editorial-judge_verdict.json
240
+ allowAppend: false
241
+
242
+ # ── 11. render: everything deterministic between the agents and TTS ─────────────────────────
243
+ - id: render
244
+ description: >-
245
+ `kk news generate-render` — voice3's `script`, `editorial-render`, `article`, `cover`,
246
+ `cover-normalize` and `wrap-docs` in one process. Roughly half a minute itself; it separates
247
+ the agent output behind it from the 141-minute voice step, and it is the node that renders the
248
+ article and the TTS input `generate-voice` reads.
249
+ dependsOn: [curate-final, script-check, script-fix]
250
+ condition:
251
+ kind: shell
252
+ options:
253
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
254
+ action:
255
+ kind: shell
256
+ options:
257
+ command: 'kk news generate-render --work-dir "${vars.work_dir}"'
258
+
259
+ # ── 12–13. content safety (nested state machine) and the operator review pause ──────────────
260
+ - id: safety
261
+ description: >-
262
+ Content safety as a nested state machine (`kk-daily-safety.yaml`, unchanged by G61): review →
263
+ judge → bounded revise → clean|block. It blocks here and only here, so a non-zero exit means
264
+ the drafts must not publish. The launcher vars the parent run exports are stripped at the
265
+ nested-spur boundary, exactly as voice3 does.
266
+ dependsOn: [render]
267
+ condition:
268
+ kind: shell
269
+ options:
270
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
271
+ action:
272
+ kind: shell
273
+ options:
274
+ command: >-
275
+ env -u SPUR_WORKFLOW_RUN_ACTIVE -u SPUR_EXPECTED_DEFINITION_DIGEST
276
+ spur workflow run plugins/kk/workflows/kk-daily-safety.yaml
277
+ --vars "{\"work_dir\":\"${vars.work_dir}\",\"run_date\":\"${vars.run_date}\",\"agent\":\"${vars.agent}\"}"
278
+ --quiet --no-plan
279
+
280
+ - id: review
281
+ description: >-
282
+ Operator review of the safety-gated drafts: `pause: true` stops the run and RESUME is the
283
+ approval (the engine marks a paused node done on resume); cancelling is the rejection. Skipped
284
+ when `skip_review=true`, so a scheduled day runs unattended without losing the audit pause.
285
+ dependsOn: [safety]
286
+ pause: true
287
+ condition:
288
+ kind: shell
289
+ options:
290
+ command: >-
291
+ test "${vars.skip_review}" != "true"
292
+ && grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null
293
+
294
+ # ── 14–16. voice: one engine per attempt, the fallback chain visible in the graph ───────────
295
+ - id: voice
296
+ description: >-
297
+ `generate-voice --engine voxcpm` — the primary driver, and the longest step in the run
298
+ (141 min measured). `generate-voice` never falls back internally: the workflow owns the chain,
299
+ so a resume restarts at the engine that failed, not at engine one. onError: continue — the
300
+ siblings below are the loud second and third attempts.
301
+ dependsOn: [render, review]
302
+ condition:
303
+ kind: shell
304
+ options:
305
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
306
+ action:
307
+ kind: shell
308
+ onError: continue
309
+ options:
310
+ command: 'kk news generate-voice --work-dir "${vars.work_dir}" --engine voxcpm'
311
+
312
+ - id: voice-fallback
313
+ description: "Fallback 1: gemini — runs when no engine has left a passing audio verdict (the content JSON is the evidence; `grep` keeps `jq` out of the graph)"
314
+ dependsOn: [voice]
315
+ condition:
316
+ kind: shell
317
+ options:
318
+ command: >-
319
+ ! grep -q '"passed": true' "${vars.work_dir}/30-audio/${vars.run_date}_11_generate_content.json" 2>/dev/null
320
+ && grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null
321
+ action:
322
+ kind: shell
323
+ onError: continue
324
+ options:
325
+ command: 'kk news generate-voice --work-dir "${vars.work_dir}" --engine gemini'
326
+
327
+ - id: voice-fallback2
328
+ description: "Fallback 2 (last, loud): omnivoice — the run fails here if three engines could not render the script"
329
+ dependsOn: [voice-fallback]
330
+ condition:
331
+ kind: shell
332
+ options:
333
+ command: >-
334
+ ! grep -q '"passed": true' "${vars.work_dir}/30-audio/${vars.run_date}_11_generate_content.json" 2>/dev/null
335
+ && grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null
336
+ action:
337
+ kind: shell
338
+ options:
339
+ command: 'kk news generate-voice --work-dir "${vars.work_dir}" --engine omnivoice'
340
+
341
+ # ── 17. cards: 46 minutes measured, and a missing series must not fail the episode ──────────
342
+ - id: cards
343
+ description: "`kk news generate-cards` — the card series through the pinned xhs presets; continue on failure, the publish plan names a missing series and stays soft"
344
+ dependsOn: [render, review]
345
+ condition:
346
+ kind: shell
347
+ options:
348
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
349
+ action:
350
+ kind: shell
351
+ onError: continue
352
+ options:
353
+ command: 'kk news generate-cards --work-dir "${vars.work_dir}"'
354
+
355
+ # ── 18–20. the frozen bundle: variants, the nested variants review, then the freeze ─────────
356
+ - id: variants
357
+ description: >-
358
+ `kk news generate-bundle --stage variants` — voice3's `publish-prep`, `bundle-variants` and
359
+ `daily-safety-manifest` in one process: `31-publish/` prep, `30-variants/*` payloads and the
360
+ manifest the nested variants review registers. Two stages, because the review of those
361
+ variants has to run between them and a nested workflow call cannot live inside a verb.
362
+ dependsOn: [voice, voice-fallback, voice-fallback2, cards]
363
+ condition:
364
+ kind: shell
365
+ options:
366
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
367
+ action:
368
+ kind: shell
369
+ options:
370
+ command: 'kk news generate-bundle --work-dir "${vars.work_dir}" --run-id "${vars.run_id}" --run-date "${vars.run_date}" --stage variants'
371
+
372
+ - id: safety-variants
373
+ description: >-
374
+ The final-variant safety review (0331) through the same nested machine, re-rooted by
375
+ `safety_scope_dir=4-safety-variants`. It leaves `4-safety-variants/safety.json` — status,
376
+ exclusion record and the sha256 of every reviewed variant — which the freeze carries into the
377
+ bundle, so live launches and social edits are gated on exactly the reviewed bytes. Fails
378
+ closed: a block fails this node and the run never freezes.
379
+ dependsOn: [variants]
380
+ condition:
381
+ kind: shell
382
+ options:
383
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
384
+ action:
385
+ kind: shell
386
+ options:
387
+ command: >-
388
+ env -u SPUR_WORKFLOW_RUN_ACTIVE -u SPUR_EXPECTED_DEFINITION_DIGEST
389
+ spur workflow run plugins/kk/workflows/kk-daily-safety.yaml
390
+ --vars "{\"work_dir\":\"${vars.work_dir}\",\"run_date\":\"${vars.run_date}\",\"agent\":\"${vars.agent}\",\"safety_scope_dir\":\"4-safety-variants\"}"
391
+ --quiet --no-plan
392
+
393
+ - id: freeze
394
+ description: >-
395
+ `generate-bundle --stage freeze` then `kk news report` — the bundle is frozen over exactly the
396
+ reviewed bytes, and the generation report plus the ledger sync are the run's own last write.
397
+ Two commands, because a report failure must not cost three hours of generation a re-run: the
398
+ freeze has already landed when the report starts. A second freeze of a frozen bundle exits 1
399
+ without rewriting it.
400
+ dependsOn: [safety-variants]
401
+ condition:
402
+ kind: shell
403
+ options:
404
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
405
+ action:
406
+ kind: shell
407
+ options:
408
+ command: >-
409
+ kk news generate-bundle --work-dir "${vars.work_dir}" --run-id "${vars.run_id}" --run-date "${vars.run_date}" --preset "${vars.preset}" --stage freeze
410
+ && kk news report --work-dir "${vars.work_dir}"
@@ -0,0 +1,236 @@
1
+ ---
2
+ name: kk-publish
3
+ kind: dag
4
+ version: "1"
5
+ description: >-
6
+ The one publish workflow for every content noun (G61 / ADR-053 §1, design
7
+ `docs/design/content-pipeline-consolidation.md` §5.3, task 0366): nine nodes over one frozen
8
+ `4-publish/bundle.json`, launched by `kk news publish` / `kk article publish`. Each node is an
9
+ agent call, the live-send pause, or a boundary that runs exactly one `kk <noun> publish-<step>`
10
+ verb — the eighteen nodes of the retired publish3 DAG and the seven-node retired ITC publish tail
11
+ fold into these nine. The channel matrix lives in the publish preset, never here.
12
+ Re-enter a failed window with
13
+ `spur workflow run plugins/kk/workflows/kk-publish.yaml --vars '{"work_dir":"<run dir>","window":"after-generate"}'`
14
+ — receipts make the rerun a no-op for anything already delivered, and `--retry` resends only
15
+ `effect: none` failures.
16
+
17
+ # ADR-022: live is launch-only. A workflow file never yields a live send; the operator's launch var
18
+ # (or the installed schedule entry that carries it) is the consent.
19
+ #
20
+ # Two var shapes, both forced by the engine (probe-verified against spur 0.4.33, not by preference):
21
+ # * a var the node command needs as a *word* always has a non-empty default (`window`, `preset`,
22
+ # `noun`, `agent`);
23
+ # * an optional flag is spelled by its own var: `--preset=${vars.preset}` style for flags that take
24
+ # a value (an empty value is tolerated by the verb), and a whole-word var for the two switches
25
+ # that take none — `dummy` holds `--dummy` or nothing, so the unquoted expansion adds the word
26
+ # only in a rehearsal. The engine rejects `${vars.x:+…}` conditionals as an undeclared reference,
27
+ # and R2 forbids a multi-command shell here, so assembling the flag list any other way would cost
28
+ # the single-call node. `live_confirm`/`retry` stay `true`/`false` because only conditions read
29
+ # them.
30
+ vars:
31
+ work_dir: ""
32
+ run_date: ""
33
+ window: after-generate
34
+ # The compiled default preset (`apps/cli/src/publish-matrix.ts` DEFAULT_PUBLISH_PRESET). The
35
+ # launching verb always overrides it with `content_types.<type>.publish_preset`.
36
+ preset: daily-ai-voice
37
+ channels: ""
38
+ live_channels: ""
39
+ live_confirm: "false"
40
+ dummy: ""
41
+ retry: "false"
42
+ # `publish-plan --feed`: the RSS gate's feed URL. Empty means the shipped podcast feed; a test or
43
+ # operator pins a fixture through it (`data:` URLs are a legal fetch target).
44
+ feed: ""
45
+ noun: news
46
+ agent: inline
47
+
48
+ nodes:
49
+ # ── 1. plan: the one node that waits, gates and freezes the window ───────────────────────────
50
+ - id: plan
51
+ description: >-
52
+ `publish-plan` — sleeps to the window's wall clock when the window is `cn-peak`, runs the RSS
53
+ gate when it is `overseas-rss`, binds the bundle's calendar day, then freezes this window's
54
+ rows and payloads into `4-publish/plan.<window>.json`. `onError: continue` is what keeps a
55
+ gated miss inside the graph: `publish-plan` exits 1 when the feed lacks the episode (after
56
+ writing `rss-gate.json` + the deterministic incident floor), and a *failing* node would skip
57
+ every successor by the all-deps-skipped rule — taking the `diagnose`/`repair` path with it.
58
+ A plan failure that is NOT a gated miss still fails the run at `check`, which needs the plan.
59
+ action:
60
+ kind: shell
61
+ onError: continue
62
+ options:
63
+ command: >-
64
+ kk ${vars.noun} publish-plan --work-dir "${vars.work_dir}" --window "${vars.window}"
65
+ --preset=${vars.preset} --run-date=${vars.run_date} --channels=${vars.channels}
66
+ --live-channels=${vars.live_channels} --feed=${vars.feed} ${vars.dummy}
67
+
68
+ # ── 2. check: readiness probes, before the human approval that reads them ────────────────────
69
+ - id: check
70
+ description: >-
71
+ `publish-check` — warn-only probes for the planned non-dummy channels, recorded in
72
+ `4-publish/check.<window>.json`. Skipped on a gated miss (there is no plan to probe), which is
73
+ also why it is the node that fails a plan failure the graph must not swallow: with a plan it
74
+ cannot read, `publish-check` exits 1 and the run stops before any dispatch.
75
+ dependsOn: [plan]
76
+ condition:
77
+ kind: shell
78
+ options:
79
+ # Run unless this is an overseas window whose feed gate missed. A missing rss-gate.json is
80
+ # not a miss (the gate never ran), so check still runs and fails loud on the absent plan.
81
+ command: >-
82
+ test "${vars.window}" != "overseas-rss"
83
+ || ! grep -q '"hit": false' "${vars.work_dir}/4-publish/rss-gate.json" 2>/dev/null
84
+
85
+ action:
86
+ kind: shell
87
+ options:
88
+ command: 'kk ${vars.noun} publish-check --work-dir "${vars.work_dir}" --window "${vars.window}"'
89
+
90
+ # ── 3. send-confirm: the only human pause in the publish half ────────────────────────────────
91
+ - id: send-confirm
92
+ description: >-
93
+ Operator approval of a LIVE send: `pause: true` stops the run and RESUME is the approval;
94
+ cancelling is the rejection. Requires `live_confirm=true` AND a live row in the frozen plan,
95
+ so a scheduled posture (the preset owns live/draft, ADR-022 amendment) and a draft-only or
96
+ dummy window proceed without a human — and a pause can never appear for a send that will not
97
+ happen.
98
+ dependsOn: [check]
99
+ pause: true
100
+ condition:
101
+ kind: shell
102
+ options:
103
+ command: >-
104
+ test "${vars.live_confirm}" = "true"
105
+ && grep -q '"mode": "live"' "${vars.work_dir}/4-publish/plan.${vars.window}.json" 2>/dev/null
106
+
107
+ # ── 4. send: tier order, receipts keyed per target ──────────────────────────────────────────
108
+ - id: send
109
+ description: >-
110
+ `publish-send` — tier 0 serial and blocking, later tiers once the tier-0 links resolve.
111
+ Receipts key every target, so a rerun never resends what was delivered, and a dummy row never
112
+ spawns a plugin. `check` sits beside `send-confirm` on purpose: the engine skips a node only
113
+ when ALL its dependencies were skipped, so a draft window (no live row → `send-confirm`
114
+ skipped) still sends, while a gated plan (both ancestors skipped) still stops here. A failing
115
+ target does NOT end the run here — `onError: continue` lets the bounded retry and the
116
+ settlement decide, so the evidence always survives to the operator.
117
+ dependsOn: [check, send-confirm]
118
+ action:
119
+ kind: shell
120
+ onError: continue
121
+ options:
122
+ command: 'kk ${vars.noun} publish-send --work-dir "${vars.work_dir}" --window "${vars.window}"'
123
+
124
+ # ── 5. send-retry: the ONE bounded retry ────────────────────────────────────────────────────
125
+ - id: send-retry
126
+ description: >-
127
+ `publish-send --retry` — resends only rows whose receipt is a failure with `effect: none`
128
+ (a succeeded row is skipped, a live row with an unknown effect is never resent, a dummy row
129
+ never spawns a plugin). No back-edge: one retry node, then the settlement rules. Runs when
130
+ `send` left a failed receipt, and unconditionally when the operator asked for `--retry` (an
131
+ explicit re-send is the operator's call, even when every visible receipt reads succeeded).
132
+ dependsOn: [send]
133
+ condition:
134
+ kind: shell
135
+ options:
136
+ command: >-
137
+ test "${vars.retry}" = "true"
138
+ || grep -q '"status": "failed"' "${vars.work_dir}/4-publish/receipts/"*.json 2>/dev/null
139
+
140
+ action:
141
+ kind: shell
142
+ options:
143
+ command: >-
144
+ kk ${vars.noun} publish-send --work-dir "${vars.work_dir}" --window "${vars.window}" --retry
145
+
146
+ # ── 6. diagnose: a gated miss is explained, never silently dropped ──────────────────────────
147
+ - id: diagnose
148
+ description: >-
149
+ overseas-rss only, on a feed-gate miss: classify why the episode is not in the feed
150
+ (`no-run | generation-failed@<node> | no-content | t0-failed | rss-lag`) and write
151
+ `4-publish/incident.json` / `incident.md`. The gate already wrote its deterministic incident
152
+ floor, so this agent refines it and never invents one. `dependsOn: [plan]` (not the row above)
153
+ is what makes the miss path reachable at all: `plan` runs even when it exits 1, and the plan
154
+ chain between them is skipped. `onError: continue` — a diagnosis must never mask the miss it
155
+ is describing.
156
+ dependsOn: [plan]
157
+ condition:
158
+ kind: shell
159
+ options:
160
+ command: >-
161
+ test "${vars.window}" = "overseas-rss"
162
+ && grep -q '"hit": false' "${vars.work_dir}/4-publish/rss-gate.json" 2>/dev/null
163
+
164
+ action:
165
+ kind: agent.run
166
+ onError: continue
167
+ options:
168
+ role: scribe
169
+ agent: ${vars.agent}
170
+ timeoutMs: 600000
171
+ input: |
172
+ Diagnose a missed overseas publish window. Read only these paths:
173
+ - ${vars.work_dir}/4-publish/rss-gate.json (the miss reason)
174
+ - ${vars.work_dir}/bundle.json (absent = no generation ran)
175
+ - ${vars.work_dir}/4-publish/outcome.after-generate.json and receipts/ (tier-0 evidence)
176
+ Run `spur workflow trace --json` for the generation run named in bundle.json if it exists.
177
+ Write ${vars.work_dir}/4-publish/incident.json with exactly
178
+ {"schemaVersion":1,"date":"<run_date>","class":"<one of no-run|generation-failed|<node>|no-content|t0-failed|rss-lag>","reason":"<one line>","evidence":["<paths>"]}
179
+ and ${vars.work_dir}/4-publish/incident.md with 3 sentences of operator prose: what is missing,
180
+ which class, and the one action that would fix it. Never regenerate content.
181
+ expectFile: ${vars.work_dir}/4-publish/incident.json
182
+
183
+ # ── 7. repair: the one safe automatic fix for a gated miss ─────────────────────────────────
184
+ - id: repair
185
+ description: >-
186
+ overseas-rss only, on a gate miss (its only edge is `diagnose`): resend the tier-0 rows whose
187
+ receipt is `effect: none` in the `after-generate` window. It never regenerates content and
188
+ never resends an uncertain live send (the shared `--retry` rules), so a lost generation stays
189
+ an operator decision.
190
+ dependsOn: [diagnose]
191
+ action:
192
+ kind: shell
193
+ options:
194
+ command: >-
195
+ kk ${vars.noun} publish-send --work-dir "${vars.work_dir}" --window after-generate --retry --tier 0
196
+
197
+ # ── 8. settle: classify, settle the store, the run's honest exit ───────────────────────────
198
+ - id: settle
199
+ description: >-
200
+ `publish-settle` — one verb for the five publish3 nodes `classify`, `patch-surfdash`,
201
+ `partial-marker`, `settle` and `bundle-runs`: it writes `4-publish/outcome.<window>.json`,
202
+ the status and settlement files, the partial marker when the window is not full, and appends
203
+ this run to `bundle.json` `runs[]`. `onError: continue`, so a window with a failed required
204
+ row still reaches `report`: publish3's `outcome-assert` sat AFTER report and ledger, and
205
+ `report` now owns that honest exit (design §5.3 R3 — the page and the ledger row survive a
206
+ partial window). Skipped on a gated miss: nothing was planned, so there is no window to
207
+ classify and the incident path already owns the day.
208
+ dependsOn: [send, repair]
209
+ condition:
210
+ kind: shell
211
+ options:
212
+ command: >-
213
+ test "${vars.window}" != "overseas-rss"
214
+ || ! grep -q '"hit": false' "${vars.work_dir}/4-publish/rss-gate.json" 2>/dev/null
215
+
216
+ action:
217
+ kind: shell
218
+ onError: continue
219
+ options:
220
+ command: 'kk ${vars.noun} publish-settle --work-dir "${vars.work_dir}" --window "${vars.window}"'
221
+
222
+ # ── 9. report: the operator's page, on every path that reached a window ─────────────────────
223
+ - id: report
224
+ description: >-
225
+ `publish-report` — per-window status and every receipt on one page (`5-report/publish-<w>.md`,
226
+ plus the SEO export for types that ask for one), then the ledger sync, and then the run's
227
+ honest exit: the verb re-reads `outcome.<window>.json` and exits 1 when a required non-dummy
228
+ row did not succeed (design §5.3 R3 — the page and the ledger row are already written, so a
229
+ partial window keeps its report and still fails). Depends on `settle` so a report can never
230
+ race an unfinished settlement, and on `diagnose` so a gated-miss day (settle skipped, diagnose
231
+ ran) still writes its page and stays done (no outcome file).
232
+ dependsOn: [settle, diagnose]
233
+ action:
234
+ kind: shell
235
+ options:
236
+ command: 'kk ${vars.noun} publish-report --work-dir "${vars.work_dir}" --window "${vars.window}"'