@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
@@ -23,7 +23,7 @@ and never report an outcome that was not observed.
23
23
  | Operation | When | Tier & Substrate | Output |
24
24
  | --- | --- | --- | --- |
25
25
  | **discover** | New/changed site; "figure out this UI", inspect selectors/shadow roots | **Tier 3** (`kk bot open` + CDP/Playwright) | Evidence dir (`frames/`, `signals.json`) + drift list (`docs/design/<channel>-ui-discovery.md`) |
26
- | **enhance** | Selectors drifted; a plugin or collection plan fails on a live console | **Tier 2 / 3** (`kk bot exec`, probe script) | Root-cause fix in plugin + updated discovery doc in same commit |
26
+ | **enhance** | Selectors drifted; a plugin or collection plan fails on a live console | **Tier 2 / 3** (`kk bot exec`, `kk bot record`/`replay`, probe script) | Root-cause fix in plugin + updated discovery doc in same commit; a rail change names its transcript |
27
27
  | **automate** | Repeatable web task (data collection, form fill, draft save, health audit) | **Tier 1 / 2** (`kk bot exec`, `runBotCollection`) | Bounded Result + captured artifacts (draft-safe by default, fail-closed) |
28
28
 
29
29
  This skill owns **method**. It does not own transport (that belongs to `kind: publish` / `ingestion` plugins) or orchestration
@@ -239,6 +239,36 @@ await withProfileLease(profileName, async () => {
239
239
  3. If selector changed, launch `kk bot open <channel>`, observe the updated DOM element.
240
240
  4. Update selector in shared helper, re-verify with probe script, commit alongside discovery doc.
241
241
 
242
+ ### Scenario E: Measured Rail Authoring — record → replay → codegen (`enhance`)
243
+ A rail whose selectors were guessed is a rail that will fail live. Measure the session instead.
244
+
245
+ 1. **Record** — `kk bot record <bot> -o <file>` opens the bot's saved page headed. Perform the flow
246
+ by hand *up to but not including* the final submit (the transcript is evidence, not a publish).
247
+ Close the window to finish. Typed text is a length marker unless `--include-text`; the transcript
248
+ is 0600 and its URL queries are dropped.
249
+ 2. **Read the recording, not the prose** — each step carries a ranked selector
250
+ (`data-testid` > `name` > exact `aria-label` > `role`+exact text > exact text > structural path) or
251
+ an explicit `ambiguous` marker. An `ambiguous` step is a real finding: the site has two visible
252
+ nodes with that attribute, so the flow needs a stronger landmark — re-record after the console is
253
+ in the right state.
254
+ 3. **Replay before generating** — `kk bot replay <bot> <transcript>` stops before the submit click
255
+ unless `--submit`, and writes one screenshot plus a `replay.json` row per step. A step that does
256
+ not resolve exactly one visible node fails the run: fix the recording, not the assertion. Cite
257
+ `.spur/run/bot-replay-<bot>/` as evidence in the repair task.
258
+ 4. **Generate** — `kk bot codegen <transcript> --plugin <name> --operation <op>` prints a rail
259
+ skeleton; `--apply` writes `<op>-rail.generated.ts` beside the plugin. The receipt is a
260
+ `page.waitForResponse` matcher over the recorded submit response with the id's dot path — never a
261
+ DOM-text comparison. No response in the transcript ⇒ an explicit `TODO receipt` warning, because a
262
+ rail with no receipt reports a publish it cannot prove.
263
+ 5. **Promote by hand** — read the generated file against the recording, then move what you accept into
264
+ the live rail. Never ship the generated file as the live rail.
265
+ 6. **Name the recording** — the live rail keeps a `// transcript: <repo path>` (or
266
+ `// transcript: none — <reason>`) header; the `rail-transcript-header` rule fails the tree without
267
+ it. Fixtures for offline tests live under
268
+ `packages/publish-harness/tests/fixtures/bot-record/`.
269
+
270
+ Contract detail: `docs/design/kk-bot-record-codegen.md`.
271
+
242
272
  ---
243
273
 
244
274
  ## Safety Rails (Non-Negotiable)
@@ -0,0 +1,485 @@
1
+ ---
2
+ "$schema": "@gobing-ai/spur/schemas/state-machine-workflow.schema.json"
3
+ name: kk-article-generate
4
+ kind: state-machine
5
+ version: "1"
6
+ description: >-
7
+ The article generation FSM (G61 / ADR-053 §1, §6; design
8
+ `docs/design/content-pipeline-consolidation.md` §5.2, task 0368): thirteen states, launched by
9
+ `kk article generate`. It replaces `kk-itc.yaml`'s author half — one node that shelled out to
10
+ supervise the child `kk-itc-author.yaml` — with the same authoring states inlined, because with
11
+ publishing moved to `kk-publish` the parent had nothing left but the author flow (design §3.3).
12
+ The run ends in a frozen `4-publish/bundle.json`; `kk article publish` then runs the shared
13
+ nine-node `kk-publish.yaml`, which has no article-specific node (R7).
14
+ Re-enter a failed run with
15
+ `spur workflow run plugins/kk/workflows/kk-article-generate.yaml --vars '{"work_dir":"<run dir>","slug":"<slug>","auto":"true"}'`
16
+ — the outline is committed before the draft and the bundle is frozen once, so a resume from
17
+ `freeze` never re-authors anything.
18
+
19
+ # ADR-053 §5: ONE executor variable drives every agent node. `agent` arrives from the launching verb
20
+ # (`kk article generate --agent`), defaults to `inline`, and every retry state resolves by
21
+ # `role: reviewer` instead of carrying a second executor pin (0360 R2). `skill_dir` is the writer
22
+ # skill's directory inside the running kk package (design §2.2: read in place, never copied into the
23
+ # run); `auto` turns the three human gates off; `preset` is the publish preset the freeze validates
24
+ # the bundle against.
25
+ initialState: executor-probe
26
+ terminalStates:
27
+ - done
28
+ - failed
29
+ failureStates:
30
+ - failed
31
+
32
+ vars:
33
+ work_dir: ""
34
+ slug: ""
35
+ run_id: ""
36
+ agent: inline
37
+ skill_dir: ""
38
+ auto: "false"
39
+ preset: ""
40
+ __hitlAnswer: ""
41
+
42
+ states:
43
+ # ── 1. executor-probe: one real prompt, before any spend (0360 R4) ──────────────────────────
44
+ - id: executor-probe
45
+ description: "One real prompt to the resolved executor; a dead executor fails the run here (ADR-053 §5)"
46
+ onEnter:
47
+ - kind: agent.run
48
+ options:
49
+ role: scribe
50
+ agent: ${vars.agent}
51
+ timeoutMs: 120000
52
+ # ADR-115 / 1233 R1: an agent step declares the artifact it produces, so even the probe
53
+ # leaves one — the same word it is asked to reply with, written where the run can read it.
54
+ input: "Reply with exactly: OK, then write that same word to ${vars.work_dir}/.executor-probe.ok"
55
+ expectFile: ${vars.work_dir}/.executor-probe.ok
56
+
57
+ # ── 2. outline-write: the options, and the deterministic pick when nobody is watching ──────
58
+ - id: outline-write
59
+ description: >-
60
+ Author outline options a (and b, optionally c) from the brief through the content type's writer
61
+ skill. `auto` runs the bounded pick in the same state: the engine cannot condition an action on
62
+ a var, so the guard expression — `test … != true || kk article generate-check --step outline` —
63
+ is the one-line spelling of design §5.2's "skipped when auto; generate-check picks instead".
64
+ That verb validates the recommendation, binds the catalog decision and commits
65
+ `2-outline/outline-approved.md`, which is the file every later state reads.
66
+ onEnter:
67
+ - kind: agent.run
68
+ options:
69
+ role: scribe
70
+ agent: ${vars.agent}
71
+ timeoutMs: 600000
72
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
73
+ input: |
74
+ Follow the writer skill ${vars.skill_dir}/SKILL.md (read its references first).
75
+ Write outline options a and b (optionally c) for the brief ${vars.work_dir}/brief.md into ${vars.work_dir}/2-outline/ as outline-option-a.md, outline-option-b.md (and outline-option-c.md).
76
+ Operator feedback from the last review, if any: ${vars.work_dir}/.itc/feedback.md
77
+ When auto mode is on (auto=${vars.auto}), also write ${vars.work_dir}/2-outline/outline-recommendation.json as {"pick":"a|b|c","rationale":"<why>"}.
78
+ Do not wait for a selection; write the option files.
79
+ expectFile: ${vars.work_dir}/2-outline/outline-option-a.md
80
+ - kind: shell
81
+ options:
82
+ # Auto only: the interactive modes pick at `outline-select` (design §5.2).
83
+ command: >-
84
+ test "${vars.auto}" != "true" ||
85
+ kk article generate-check --work-dir "${vars.work_dir}" --step outline
86
+
87
+ # ── 3. outline-select: the operator's pick (interactive only) ───────────────────────────────
88
+ - id: outline-select
89
+ description: >-
90
+ Operator selection of an outline option. Reached only when `auto` is off — the auto path took
91
+ its pick in `outline-write` — so this gate always asks (design §5.2: a human pause).
92
+ pause: true
93
+ onEnter:
94
+ - kind: hitl.select
95
+ options:
96
+ prompt: "Select an approved outline option from ${vars.work_dir}/2-outline/ (a, b or c):"
97
+ options:
98
+ - a
99
+ - b
100
+ - c
101
+ var: __hitlAnswer
102
+ decision:
103
+ mode: never
104
+
105
+ # ── 4. outline-review: commit the pick, then the operator's approval ───────────────────────
106
+ - id: outline-review
107
+ description: >-
108
+ Commit the operator's selection to `2-outline/outline-approved.md`, then ask for approval
109
+ (`hitl.confirm`). A paused state's enter actions are skipped on resume, so the commit is the
110
+ FIRST action here — the selection is already in `${vars.__hitlAnswer}` when the run wakes.
111
+ Declining loops back to `outline-write` while the round budget lasts (design §5.2 folds
112
+ `outline-revise` into this state; the human round cap stays the ITC three, while the JUDGE
113
+ loop is the one bound to `workflows.kk-article-generate.max_revisions` — R5).
114
+ pause: true
115
+ onEnter:
116
+ - kind: shell
117
+ options:
118
+ # Shell expansions use `$name`, never `${name}`: the engine reads `${…}` as a template
119
+ # reference to a declared var.
120
+ command: |
121
+ n=$(cat "${vars.work_dir}/.outline-review-count" 2>/dev/null || echo 0)
122
+ echo $((n + 1)) > "${vars.work_dir}/.outline-review-count"
123
+ sel="${vars.__hitlAnswer}"
124
+ src="${vars.work_dir}/2-outline/outline-option-$sel.md"
125
+ if [ ! -f "$src" ]; then echo "selected outline option not found: $src" >&2; exit 1; fi
126
+ cp "$src" "${vars.work_dir}/2-outline/outline-approved.md"
127
+ - kind: hitl.confirm
128
+ options:
129
+ prompt: "Review the approved outline at ${vars.work_dir}/2-outline/outline-approved.md. Approve?"
130
+ var: __hitlAnswer
131
+ decision:
132
+ mode: never
133
+
134
+ # ── 5–6. draft-write and the de-slop pass ──────────────────────────────────────────────────
135
+ - id: draft-write
136
+ description: >-
137
+ Author (or rewrite) `3-draft-draft-article.md` from the approved outline. Every entry bumps
138
+ `.draft-count`, which is the ONLY revision counter: `generate-check --step judge` reads
139
+ drafts-1 as the rewrites performed and bounds them by `max_revisions`, so the judge loop and
140
+ the operator loop cannot double-count (design §5.2: `draft-autorevise` is gone — this state is
141
+ the judge's fail edge target).
142
+ onEnter:
143
+ - kind: shell
144
+ options:
145
+ command: >-
146
+ n=$(cat "${vars.work_dir}/.draft-count" 2>/dev/null || echo 0);
147
+ echo $((n + 1)) > "${vars.work_dir}/.draft-count"
148
+ - kind: agent.run
149
+ options:
150
+ role: scribe
151
+ agent: ${vars.agent}
152
+ timeoutMs: 900000
153
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
154
+ input: |
155
+ Follow the writer skill ${vars.skill_dir}/SKILL.md (read its references first).
156
+ Author the full draft at ${vars.work_dir}/3-draft-draft-article.md from the approved outline ${vars.work_dir}/2-outline/outline-approved.md and the brief ${vars.work_dir}/brief.md.
157
+ When ${vars.work_dir}/.itc-verdict.json exists, apply every item of its feedback[]; when ${vars.work_dir}/.itc/feedback.md exists, apply that too.
158
+ Overwrite the draft with the complete article.
159
+ expectFile: ${vars.work_dir}/3-draft-draft-article.md
160
+
161
+ - id: unslop
162
+ description: "De-slop pass — kk:taste-unslop line-edits the draft in place (design §5.2, gated by workflows.kk-article-generate.unslop)"
163
+ onEnter:
164
+ - kind: agent.run
165
+ options:
166
+ role: scribe
167
+ agent: ${vars.agent}
168
+ timeoutMs: 600000
169
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
170
+ input: |
171
+ Invoke the kk:taste-unslop skill.
172
+ Read ${vars.work_dir}/3-draft-draft-article.md and write the line-edited version to ${vars.work_dir}/3-draft-draft-article.new.md, removing slop (AI-tell phrasing, filler, hedging) while preserving the technical claims, code blocks, links and the approved outline's structure. Do not modify the original file.
173
+ expectFile: ${vars.work_dir}/3-draft-draft-article.new.md
174
+ - kind: shell
175
+ options:
176
+ command: mv -f "${vars.work_dir}/3-draft-draft-article.new.md" "${vars.work_dir}/3-draft-draft-article.md"
177
+
178
+ # ── 7. draft-review: the operator's gate on the draft ──────────────────────────────────────
179
+ - id: draft-review
180
+ description: >-
181
+ Operator review of the draft (design §5.2: `draft-review`, `hitl.confirm`/`hitl.input`). One
182
+ gate carries both answers because a paused state resumes by skipping its enter actions: YES
183
+ approves and the run goes to the judge, anything else is a rewrite request and the operator
184
+ writes specifics to `.itc/feedback.md` for `draft-write` to apply. Skipped when `auto`.
185
+ pause: true
186
+ onEnter:
187
+ - kind: shell
188
+ options:
189
+ command: >-
190
+ n=$(cat "${vars.work_dir}/.draft-review-count" 2>/dev/null || echo 0);
191
+ echo $((n + 1)) > "${vars.work_dir}/.draft-review-count"
192
+ - kind: hitl.confirm
193
+ options:
194
+ prompt: >-
195
+ Review the draft at ${vars.work_dir}/3-draft-draft-article.md. Approve? (No asks for a
196
+ rewrite; write specifics to ${vars.work_dir}/.itc/feedback.md)
197
+ var: __hitlAnswer
198
+ decision:
199
+ mode: never
200
+
201
+ # ── 8. judge: the reviewer agent, then the deterministic disposition ───────────────────────
202
+ - id: judge
203
+ description: >-
204
+ kk:content-judge writes `.itc-verdict.json`; `generate-check --step judge` turns it into ONE
205
+ disposition word (`finish` | `autorevise` | `fail`) through `itc-author-verdict`, with the
206
+ revision budget bound to `workflows.kk-article-generate.max_revisions` (R5, AC3). The verdict
207
+ scale is HIGH/MEDIUM/LOW: a PASS without one never cleared the gate.
208
+ onEnter:
209
+ - kind: agent.run
210
+ options:
211
+ role: reviewer
212
+ agent: ${vars.agent}
213
+ timeoutMs: 600000
214
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
215
+ input: |
216
+ Invoke the kk:content-judge skill.
217
+ Evaluate the draft at ${vars.work_dir}/3-draft-draft-article.md against the tech-accuracy rubric.
218
+ Evidence: read ${vars.work_dir}/docs.json when it exists and weigh it.
219
+ Write the verdict JSON to ${vars.work_dir}/.itc-verdict.json per the skill's verdict contract (verdict PASS|NEEDS_REVISION|FAIL, confidence HIGH|MEDIUM|LOW, feedback[]).
220
+ expectFile: ${vars.work_dir}/.itc-verdict.json
221
+ - kind: shell
222
+ options:
223
+ command: >-
224
+ kk article generate-check --work-dir "${vars.work_dir}" --step judge
225
+
226
+ # ── 9. illustrate: optional cover/inline art, entered only when a spend var is on ──────────
227
+ - id: illustrate
228
+ description: "Optional cover/inline illustrations via kk:image-authoring — entered only when the frozen options turn a spend switch on (design §5.2, conditional)"
229
+ onEnter:
230
+ - kind: agent.run
231
+ options:
232
+ role: scribe
233
+ agent: ${vars.agent}
234
+ timeoutMs: 900000
235
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
236
+ input: |
237
+ Invoke the kk:image-authoring skill with KK_NONINTERACTIVE=1 and KK_IMAGE_AUTO_CONFIRM=1 (the operator approved spend via cover_enabled/inline_images).
238
+ Create ${vars.work_dir}/4-illustrations/ and generate the cover illustration into it as cover.png, sized for an article hero image.
239
+ Print each written path as the last line of stdout.
240
+ expectFile: ${vars.work_dir}/4-illustrations/cover.png
241
+
242
+ # ── 10. adapt: the plan, the adapted variants, and the deterministic check ─────────────────
243
+ - id: adapt
244
+ description: >-
245
+ `generate-bundle --stage variants` (design §6: `itc-materialize-plan`) materializes
246
+ `4-publish/content.json` and the ITC variant plan, kk:article-adapt writes every `adapt:true`
247
+ variant file, and `generate-check --step adapt` verifies them (`itc-adapt-verify`). The plan is
248
+ the adapt agent's input, so it is materialized here and removed by `freeze`; from then on
249
+ `kk-publish` plans from the bundle and the preset (design §4.1, §4.2).
250
+ onEnter:
251
+ - kind: shell
252
+ options:
253
+ command: >-
254
+ kk article generate-bundle --work-dir "${vars.work_dir}" --run-id "${vars.run_id}" --preset "${vars.preset}" --stage variants
255
+ - kind: agent.run
256
+ options:
257
+ role: scribe
258
+ agent: ${vars.agent}
259
+ timeoutMs: 900000
260
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
261
+ input: |
262
+ Invoke the kk:article-adapt skill.
263
+ Read ${vars.work_dir}/4-publish/publish-plan.json and, for each entry in variants with adapt=true, read ${vars.work_dir}/4-publish/content.json and write the variant Content file to ${vars.work_dir}/4-publish/<variant.file>.
264
+ Apply the plan's variant limits and translate title and body into the variant's locale. Never set metadata.published.
265
+ Record what you wrote in ${vars.work_dir}/4-publish/adapted.json as {"variants":[{"key":"<variant key>","file":"<variant.file>"}]}.
266
+ Print each written variant file path as the last line of stdout.
267
+ expectFile: ${vars.work_dir}/4-publish/adapted.json
268
+ - kind: shell
269
+ options:
270
+ command: >-
271
+ kk article generate-check --work-dir "${vars.work_dir}" --step adapt
272
+
273
+ # ── 11. freeze: the frozen bundle is the run's product ─────────────────────────────────────
274
+ - id: freeze
275
+ description: >-
276
+ `generate-bundle --stage variants` then `--stage freeze` (design §5.2): re-materializing first
277
+ makes this state self-sufficient on a resume, and the freeze — `itc-author-complete` plus the
278
+ design §4.1 article bundle (contentType, title, no episode, one {path, sha256} per adapted
279
+ file) — protects the whole authoring session behind it.
280
+ onEnter:
281
+ - kind: shell
282
+ options:
283
+ command: >-
284
+ kk article generate-bundle --work-dir "${vars.work_dir}" --run-id "${vars.run_id}" --preset "${vars.preset}" --stage variants
285
+ && kk article generate-bundle --work-dir "${vars.work_dir}" --run-id "${vars.run_id}" --preset "${vars.preset}" --stage freeze
286
+
287
+ # ── 12–13. terminal states ─────────────────────────────────────────────────────────────────
288
+ - id: done
289
+ description: "Terminal — the article is frozen and publishable"
290
+
291
+ - id: failed
292
+ description: "Terminal — the run was rejected, the judge failed, or a revision budget ran out"
293
+
294
+ transitions:
295
+ - from: executor-probe
296
+ to: outline-write
297
+ guard:
298
+ kind: always
299
+
300
+ - from: outline-write
301
+ to: draft-write
302
+ description: "Auto mode: the pick already committed outline-approved.md, so there is nothing to select or review"
303
+ guard:
304
+ kind: shell
305
+ options:
306
+ command: >-
307
+ test "${vars.auto}" = "true" && test -s "${vars.work_dir}/2-outline/outline-approved.md"
308
+
309
+ - from: outline-write
310
+ to: failed
311
+ terminalReason: failed-check
312
+ description: "Auto mode with no approved outline (a deferred decision has no operator to ask)"
313
+ guard:
314
+ kind: shell
315
+ options:
316
+ command: >-
317
+ test "${vars.auto}" = "true" && test ! -s "${vars.work_dir}/2-outline/outline-approved.md"
318
+
319
+ - from: outline-write
320
+ to: outline-select
321
+ description: "Interactive mode: the operator picks the outline"
322
+ guard:
323
+ kind: shell
324
+ options:
325
+ command: 'test "${vars.auto}" != "true"'
326
+
327
+ - from: outline-select
328
+ to: outline-review
329
+ guard:
330
+ kind: always
331
+
332
+ - from: outline-review
333
+ to: draft-write
334
+ description: "Operator approved the committed outline"
335
+ guard:
336
+ kind: shell
337
+ options:
338
+ command: 'test "${vars.__hitlAnswer}" = "true" -o "${vars.__hitlAnswer}" = "yes"'
339
+
340
+ - from: outline-review
341
+ to: outline-write
342
+ description: "Operator asked for another outline round and the round budget remains"
343
+ guard:
344
+ kind: shell
345
+ options:
346
+ command: >-
347
+ test "${vars.__hitlAnswer}" != "true" -a "${vars.__hitlAnswer}" != "yes" &&
348
+ test "$(cat "${vars.work_dir}/.outline-review-count" 2>/dev/null || echo 0)" -lt 3
349
+
350
+ - from: outline-review
351
+ to: failed
352
+ terminalReason: failed-guard
353
+ description: "Operator rejected the outline and the round budget is spent"
354
+ guard:
355
+ kind: shell
356
+ options:
357
+ command: >-
358
+ test "${vars.__hitlAnswer}" != "true" -a "${vars.__hitlAnswer}" != "yes" &&
359
+ test "$(cat "${vars.work_dir}/.outline-review-count" 2>/dev/null || echo 0)" -ge 3
360
+
361
+ - from: draft-write
362
+ to: unslop
363
+ description: "The de-slop pass is on (`workflows.kk-article-generate.unslop`, frozen into the run's options)"
364
+ guard:
365
+ kind: shell
366
+ options:
367
+ command: 'grep -qE "\"unslop\": *true" "${vars.work_dir}/itc-options.json" 2>/dev/null'
368
+
369
+ - from: draft-write
370
+ to: draft-review
371
+ description: "No de-slop pass and an operator is watching"
372
+ guard:
373
+ kind: shell
374
+ options:
375
+ command: >-
376
+ ! grep -qE "\"unslop\": *true" "${vars.work_dir}/itc-options.json" 2>/dev/null &&
377
+ test "${vars.auto}" != "true"
378
+
379
+ - from: draft-write
380
+ to: judge
381
+ description: "No de-slop pass, auto mode: straight to the reviewer"
382
+ guard:
383
+ kind: shell
384
+ options:
385
+ command: >-
386
+ ! grep -qE "\"unslop\": *true" "${vars.work_dir}/itc-options.json" 2>/dev/null &&
387
+ test "${vars.auto}" = "true"
388
+
389
+ - from: unslop
390
+ to: draft-review
391
+ description: "De-slopped draft, operator watching"
392
+ guard:
393
+ kind: shell
394
+ options:
395
+ command: 'test "${vars.auto}" != "true"'
396
+
397
+ - from: unslop
398
+ to: judge
399
+ description: "De-slopped draft, auto mode"
400
+ guard:
401
+ kind: shell
402
+ options:
403
+ command: 'test "${vars.auto}" = "true"'
404
+
405
+ - from: draft-review
406
+ to: judge
407
+ description: "Operator approved the draft"
408
+ guard:
409
+ kind: shell
410
+ options:
411
+ command: 'test "${vars.__hitlAnswer}" = "true" -o "${vars.__hitlAnswer}" = "yes"'
412
+
413
+ - from: draft-review
414
+ to: draft-write
415
+ description: "Operator asked for a rewrite and the human round budget remains (the judge's own bound is max_revisions)"
416
+ guard:
417
+ kind: shell
418
+ options:
419
+ command: >-
420
+ test "${vars.__hitlAnswer}" != "true" -a "${vars.__hitlAnswer}" != "yes" &&
421
+ test "$(cat "${vars.work_dir}/.draft-review-count" 2>/dev/null || echo 0)" -lt 3
422
+
423
+ - from: draft-review
424
+ to: failed
425
+ terminalReason: failed-guard
426
+ description: "Operator rejected the draft and the human round budget is spent"
427
+ guard:
428
+ kind: shell
429
+ options:
430
+ command: >-
431
+ test "${vars.__hitlAnswer}" != "true" -a "${vars.__hitlAnswer}" != "yes" &&
432
+ test "$(cat "${vars.work_dir}/.draft-review-count" 2>/dev/null || echo 0)" -ge 3
433
+
434
+ - from: judge
435
+ to: illustrate
436
+ description: "Judge PASS and a spend switch is on"
437
+ guard:
438
+ kind: shell
439
+ options:
440
+ command: >-
441
+ grep -qx finish "${vars.work_dir}/.itc/disposition.txt" &&
442
+ grep -qE "\"(coverEnabled|inlineImages)\": *true" "${vars.work_dir}/itc-options.json" 2>/dev/null
443
+
444
+ - from: judge
445
+ to: adapt
446
+ description: "Judge PASS with no illustration spend"
447
+ guard:
448
+ kind: shell
449
+ options:
450
+ command: >-
451
+ grep -qx finish "${vars.work_dir}/.itc/disposition.txt" &&
452
+ ! grep -qE "\"(coverEnabled|inlineImages)\": *true" "${vars.work_dir}/itc-options.json" 2>/dev/null
453
+
454
+ - from: judge
455
+ to: draft-write
456
+ description: "NEEDS_REVISION inside the budget: the verdict file IS the rewrite's input (design §5.2)"
457
+ guard:
458
+ kind: shell
459
+ options:
460
+ command: >-
461
+ grep -qxE "autorevise|revise" "${vars.work_dir}/.itc/disposition.txt"
462
+
463
+ - from: judge
464
+ to: failed
465
+ terminalReason: failed-check
466
+ description: "FAIL, an out-of-contract verdict, or max_revisions exhausted (R5)"
467
+ guard:
468
+ kind: shell
469
+ options:
470
+ command: 'grep -qx fail "${vars.work_dir}/.itc/disposition.txt"'
471
+
472
+ - from: illustrate
473
+ to: adapt
474
+ guard:
475
+ kind: always
476
+
477
+ - from: adapt
478
+ to: freeze
479
+ guard:
480
+ kind: always
481
+
482
+ - from: freeze
483
+ to: done
484
+ guard:
485
+ kind: always
@@ -71,12 +71,16 @@ states:
71
71
  - kind: shell
72
72
  options:
73
73
  # The claim is re-entrant for the same run and is stolen once its TTL has
74
- # passed, so a crashed holder costs at most one tick (the TTL below covers the
75
- # 6 h cadence and every plausible collect duration, so a slow run is never overtaken). stdout
76
- # IS the lock contract, and the guard below reads it back:
74
+ # passed. The TTL must stay BELOW the 6 h tick cadence (incident 2026-11-15): a run
75
+ # killed between `lock` and `release` — a `spur serve` restart aborts the tick in the
76
+ # queue, so `release-failed` never runs — leaves its claim behind, and a cadence-sized
77
+ # TTL made the very next tick skip instead of steal: the 16:05 tick was killed at
78
+ # 16:16 and the 22:05 tick reported `{"skipped":"locked"}`, costing 12 h of collection
79
+ # instead of one tick. 4 h is still ~20x the observed collect (12-15 min), so a live run
80
+ # is never overtaken. stdout IS the lock contract, and the guard below reads it back:
77
81
  # `{"acquired":true}` or `{"skipped":"locked","holder":<run>}` (R1).
78
82
  command: >-
79
- kk lock acquire --name collect --run "${vars.__runId}" --ttl 21600000 > "${vars.work_dir}/lock.json"
83
+ kk lock acquire --name collect --run "${vars.__runId}" --ttl 14400000 > "${vars.work_dir}/lock.json"
80
84
 
81
85
  - id: collect
82
86
  description: >-
@@ -70,7 +70,8 @@ vars:
70
70
  xhs_cards: "4"
71
71
  xhs_style: "xhs-knowledge"
72
72
  # Same credential surface as the cover pin: the provider/model must be one this machine can
73
- # actually reach, and each provider renders its own look.
73
+ # actually reach, and each provider renders its own look. This retired workflow stays frozen;
74
+ # the 0379 H3 XHS opt-in lives in kk-daily-ai-voice2 and the consolidated kk news config.
74
75
  xhs_provider: "minimax"
75
76
  xhs_model: "image-01"
76
77
  # ADR-022 rail: draft-box only. "true" posts live and stays a launch-time opt-in.
@@ -55,8 +55,10 @@ vars:
55
55
  xhs_enabled: "true"
56
56
  xhs_cards: "4"
57
57
  xhs_style: "xhs-knowledge"
58
- xhs_provider: "minimax"
59
- xhs_model: "image-01"
58
+ # 0379 K2: the local text-free/composition rehearsal passed; H3 remains an explicit XHS opt-in.
59
+ # Rollback: xhs_provider=minimax, xhs_model=image-01. The cover pin above is unchanged.
60
+ xhs_provider: "h3-local"
61
+ xhs_model: "h3"
60
62
  # ADR-022 rail: draft-box only. "true" posts live and stays a launch-time opt-in.
61
63
  xhs_live: "false"
62
64
  wechat_enabled: "true"
@@ -43,10 +43,6 @@ vars:
43
43
  safety_platforms: "xiaoyuzhou,apple-podcasts,wechatmp"
44
44
  # Agent selection for the two reviewer steps (inline | a dispatchable agent name).
45
45
  agent: "inline"
46
- # Executor for the judge retry (2026-10-24). Must sit ABOVE `agent`'s rung: the primary judge
47
- # failed on every attempt with a `scribe`-rung executor and the run closed `block` with no
48
- # verdict, so the recovery attempt is where a capable executor delivers the artifact.
49
- agent_retry: "claude"
50
46
  # Projected by the judge state from 24-script/<date>_09_safety-judge_status.txt; guards test this
51
47
  # var instead of cat-ing the file (state at decision time).
52
48
  safety_status: ""
@@ -88,7 +84,9 @@ states:
88
84
  onError: continue
89
85
  options:
90
86
  role: reviewer
91
- agent: ${vars.agent_retry}
87
+ # 0360 R2: the second attempt resolves by role (above the primary's rung), so a dead
88
+ # operator pin still has a live retry and there is no second executor var.
89
+ agent: inline
92
90
  timeoutMs: 1200000
93
91
  input: *safety-review-input
94
92
  expectFile: ${vars.work_dir}/${vars.safety_scope_dir}/${vars.run_date}_09_safety-review_report.json
@@ -119,7 +117,7 @@ states:
119
117
  onError: continue
120
118
  options:
121
119
  role: reviewer
122
- agent: ${vars.agent_retry}
120
+ agent: inline
123
121
  timeoutMs: 1200000
124
122
  input: *safety-judge-input
125
123
  expectFile: ${vars.work_dir}/${vars.safety_scope_dir}/${vars.run_date}_09_safety-judge_verdict.json
@@ -192,7 +190,7 @@ states:
192
190
  onError: continue
193
191
  options:
194
192
  role: reviewer
195
- agent: ${vars.agent_retry}
193
+ agent: inline
196
194
  timeoutMs: 600000
197
195
  input: *safety-revise-input
198
196
  expectFile: ${vars.work_dir}/${vars.safety_scope_dir}/${vars.run_date}_09_safety-revise_attempt.json