@gobing-ai/knowledge-kit 0.1.19 → 0.1.22

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 (147) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/board/collect/index.js +1 -0
  3. package/dist/board/daily-voice/index.js +1315 -264
  4. package/dist/board/itc/index.js +1 -0
  5. package/dist/index.js +14674 -8775
  6. package/package.json +1 -1
  7. package/plugins/generations/dailynews-gen/dist/index.js +285 -16
  8. package/plugins/generations/dailynews-gen/src/editorial-claims.ts +215 -0
  9. package/plugins/generations/dailynews-gen/src/index.ts +23 -4
  10. package/plugins/generations/dailynews-gen/src/script-builder.ts +10 -3
  11. package/plugins/generations/dailynews-gen/src/script-plan.ts +74 -14
  12. package/plugins/generations/image-gen/README.md +31 -31
  13. package/plugins/generations/image-gen/assets/sample/provenance.json +314 -0
  14. package/plugins/generations/image-gen/config.example.yaml +3 -0
  15. package/plugins/generations/image-gen/dist/index.js +154 -14
  16. package/plugins/generations/image-gen/presets/SOURCE.md +65 -0
  17. package/plugins/generations/image-gen/scripts/eval-style-presets.ts +513 -0
  18. package/plugins/generations/image-gen/scripts/gen-samples.ts +57 -7
  19. package/plugins/generations/image-gen/src/presets.ts +6 -5
  20. package/plugins/generations/image-gen/src/providers/h3-local.ts +196 -0
  21. package/plugins/generations/image-gen/src/providers/types.ts +11 -1
  22. package/plugins/generations/music-gen/README.md +277 -0
  23. package/plugins/generations/music-gen/dist/index.js +23544 -0
  24. package/plugins/generations/music-gen/package.json +24 -0
  25. package/plugins/generations/music-gen/plugin.json +23 -0
  26. package/plugins/generations/music-gen/presets/SOURCE.md +39 -0
  27. package/plugins/generations/music-gen/presets/formats/clip.yaml +21 -0
  28. package/plugins/generations/music-gen/presets/formats/jingle.yaml +22 -0
  29. package/plugins/generations/music-gen/presets/formats/loop.yaml +21 -0
  30. package/plugins/generations/music-gen/presets/formats/song.yaml +31 -0
  31. package/plugins/generations/music-gen/presets/formats/underscore.yaml +22 -0
  32. package/plugins/generations/music-gen/presets/themes/ambient-tech.yaml +30 -0
  33. package/plugins/generations/music-gen/presets/themes/cinematic.yaml +30 -0
  34. package/plugins/generations/music-gen/presets/themes/lofi.yaml +30 -0
  35. package/plugins/generations/music-gen/presets/themes/synthwave.yaml +30 -0
  36. package/plugins/generations/music-gen/scripts/gen-preset-index.ts +181 -0
  37. package/plugins/generations/music-gen/scripts/resolve-preset.ts +64 -0
  38. package/plugins/generations/music-gen/src/adapter/index.ts +35 -0
  39. package/plugins/generations/music-gen/src/adapter/instance.ts +904 -0
  40. package/plugins/generations/music-gen/src/adapter/offline.ts +124 -0
  41. package/plugins/generations/music-gen/src/artifact.ts +223 -0
  42. package/plugins/generations/music-gen/src/audio/checks.ts +618 -0
  43. package/plugins/generations/music-gen/src/audio/master.ts +267 -0
  44. package/plugins/generations/music-gen/src/audio/measure.ts +507 -0
  45. package/plugins/generations/music-gen/src/audio/profile.ts +131 -0
  46. package/plugins/generations/music-gen/src/audio.ts +122 -0
  47. package/plugins/generations/music-gen/src/brief.ts +191 -0
  48. package/plugins/generations/music-gen/src/config.ts +451 -0
  49. package/plugins/generations/music-gen/src/content.ts +199 -0
  50. package/plugins/generations/music-gen/src/digest.ts +100 -0
  51. package/plugins/generations/music-gen/src/index.ts +147 -0
  52. package/plugins/generations/music-gen/src/job.ts +131 -0
  53. package/plugins/generations/music-gen/src/plugin.ts +371 -0
  54. package/plugins/generations/music-gen/src/presets.ts +918 -0
  55. package/plugins/generations/music-gen/src/render.ts +87 -0
  56. package/plugins/generations/music-gen/src/request.ts +102 -0
  57. package/plugins/generations/music-gen/src/spend.ts +495 -0
  58. package/plugins/generations/music-gen/tsconfig.json +8 -0
  59. package/plugins/kk/config.example.yaml +3 -0
  60. package/plugins/kk/decisions/extract/ai-news.yaml +5 -2
  61. package/plugins/kk/plugin.json +1 -1
  62. package/plugins/kk/publish-presets/daily-ai-voice.json +48 -7
  63. package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +2 -1
  64. package/plugins/kk/scripts/cover-compositor.ts +380 -32
  65. package/plugins/kk/scripts/daily-cover-mock.ts +40 -3
  66. package/plugins/kk/scripts/daily-stages.ts +897 -34
  67. package/plugins/kk/scripts/episode-identity.ts +180 -0
  68. package/plugins/kk/scripts/kk-workflow-stages.ts +37 -1
  69. package/plugins/kk/scripts/music-stages.ts +624 -0
  70. package/plugins/kk/scripts/news-editorial-ledger.ts +906 -0
  71. package/plugins/kk/scripts/source-citation.ts +187 -0
  72. package/plugins/kk/scripts/topic-selection-attempts.ts +446 -0
  73. package/plugins/kk/scripts/topic-selection-calibration.ts +161 -0
  74. package/plugins/kk/skills/content-judge/SKILL.md +11 -6
  75. package/plugins/kk/skills/content-judge/references/music-quality-rubric.md +147 -0
  76. package/plugins/kk/skills/content-judge/references/rubrics.md +15 -0
  77. package/plugins/kk/skills/content-safety/SKILL.md +12 -0
  78. package/plugins/kk/skills/image-authoring/SKILL.md +7 -3
  79. package/plugins/kk/skills/image-authoring/references/providers.md +27 -0
  80. package/plugins/kk/skills/image-authoring/references/style-extraction.md +1 -1
  81. package/plugins/kk/skills/music-authoring/SKILL.md +276 -0
  82. package/plugins/kk/skills/music-authoring/references/judge-input.md +117 -0
  83. package/plugins/kk/skills/news-editorial/SKILL.md +102 -15
  84. package/plugins/kk/skills/news-editorial/references/selection.md +4 -0
  85. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +58 -11
  86. package/plugins/kk/skills/publish/SKILL.md +11 -0
  87. package/plugins/kk/skills/web-automation/SKILL.md +31 -1
  88. package/plugins/kk/workflows/kk-collect.yaml +8 -4
  89. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +10 -9
  90. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +11 -9
  91. package/plugins/kk/workflows/kk-music.yaml +328 -0
  92. package/plugins/kk/workflows/kk-news-generate.yaml +58 -3
  93. package/plugins/publishings/bilibili-pub/dist/index.js +11 -1
  94. package/plugins/publishings/bilibili-pub/dist/profile-check.js +11 -1
  95. package/plugins/publishings/cnblogs-pub/dist/index.js +11 -1
  96. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +11 -1
  97. package/plugins/publishings/csdn-pub/dist/index.js +11 -1
  98. package/plugins/publishings/csdn-pub/dist/profile-check.js +11 -1
  99. package/plugins/publishings/infoq-pub/dist/index.js +11 -1
  100. package/plugins/publishings/infoq-pub/dist/profile-check.js +11 -1
  101. package/plugins/publishings/jike-pub/dist/index.js +11 -1
  102. package/plugins/publishings/jike-pub/dist/profile-check.js +11 -1
  103. package/plugins/publishings/juejin-pub/dist/index.js +11 -1
  104. package/plugins/publishings/juejin-pub/dist/profile-check.js +11 -1
  105. package/plugins/publishings/linkedin-pub/dist/index.js +54 -7
  106. package/plugins/publishings/linkedin-pub/dist/profile-check.js +43 -6
  107. package/plugins/publishings/linkedin-pub/src/index.ts +52 -6
  108. package/plugins/publishings/podcast-pub/dist/index.js +586 -20
  109. package/plugins/publishings/podcast-pub/src/corrections.ts +509 -0
  110. package/plugins/publishings/podcast-pub/src/index.ts +257 -5
  111. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +240 -0
  112. package/plugins/publishings/podcast-pub/src/show-notes.ts +69 -13
  113. package/plugins/publishings/shipinhao-pub/dist/index.js +437 -32
  114. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +14 -2
  115. package/plugins/publishings/shipinhao-pub/plugin.json +1 -1
  116. package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +492 -0
  117. package/plugins/publishings/shipinhao-pub/src/flow.ts +227 -12
  118. package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -0
  119. package/plugins/publishings/sspai-pub/dist/index.js +11 -1
  120. package/plugins/publishings/sspai-pub/dist/profile-check.js +11 -1
  121. package/plugins/publishings/substack-pub/dist/index.js +11 -1
  122. package/plugins/publishings/substack-pub/dist/profile-check.js +11 -1
  123. package/plugins/publishings/surfdash-pub/dist/index.js +122 -28
  124. package/plugins/publishings/surfdash-pub/src/digest-check.ts +7 -3
  125. package/plugins/publishings/surfdash-pub/src/index.ts +159 -25
  126. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +37 -4
  127. package/plugins/publishings/threads-pub/dist/index.js +9206 -296
  128. package/plugins/publishings/threads-pub/dist/profile-check.js +21149 -0
  129. package/plugins/publishings/threads-pub/package.json +3 -1
  130. package/plugins/publishings/threads-pub/plugin.json +6 -1
  131. package/plugins/publishings/threads-pub/src/index.ts +8 -1
  132. package/plugins/publishings/threads-pub/src/post-rail.ts +357 -0
  133. package/plugins/publishings/threads-pub/src/profile-check.ts +17 -0
  134. package/plugins/publishings/wechatmp-pub/dist/index.js +18 -1
  135. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +11 -1
  136. package/plugins/publishings/wechatmp-pub/src/flow.ts +13 -0
  137. package/plugins/publishings/weibo-pub/dist/index.js +57 -3
  138. package/plugins/publishings/weibo-pub/dist/profile-check.js +11 -1
  139. package/plugins/publishings/weibo-pub/src/index.ts +74 -2
  140. package/plugins/publishings/x-pub/dist/index.js +274 -44
  141. package/plugins/publishings/x-pub/dist/profile-check.js +14 -2
  142. package/plugins/publishings/x-pub/src/index.ts +15 -1
  143. package/plugins/publishings/x-pub/src/post-rail.ts +334 -0
  144. package/plugins/publishings/xhs-pub/dist/index.js +11 -1
  145. package/plugins/publishings/xhs-pub/dist/profile-check.js +11 -1
  146. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +11 -1
  147. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +11 -1
@@ -0,0 +1,328 @@
1
+ ---
2
+ # kk-music — one idea → a measured, judged, loudness-normalized take (feature D8, task 0403).
3
+ #
4
+ # prepare → brief → explore → select → analyze → check → judge → master → finalize → done
5
+ # ↘ failed
6
+ #
7
+ # **The spend shape (R2).** `explore` authors-or-adopts one brief per direction and takes exactly
8
+ # ONE take per brief in the FORMAT's own model (the preset names it: pro for song/jingle/underscore,
9
+ # clip for clip/loop). There is no Clip→Pro explore: a Clip render is a different model and cannot
10
+ # exhibit arrangement, structure timing or lyrics past 0:30. `select` is the only operator gate;
11
+ # `auto` skips it only when exactly one take exists (one take is not a choice). `analyze` runs on
12
+ # the selected take only. A brief whose take is already on disk is adopted by `music-stages.ts`, so
13
+ # re-running `explore` into the same run directory pays for nothing (0400's digest dedupe is the
14
+ # backstop), and anything else needs `force` + `force_reason`.
15
+ #
16
+ # **The gate order (R3).** `check` (`kk music check`, 0405 take checks) exits 0 before `judge`;
17
+ # `judge` is one `agent.run` on kk:content-judge with the `music-quality` rubric, routed through the
18
+ # same confidence-aware jq filter every kk judge gate uses (a `PASS` without a HIGH/MEDIUM/LOW
19
+ # confidence is `PASS!`, which no accept guard matches); `master` is reached only on `PASS`, or on
20
+ # `NEEDS_REVISION` with `accept_revision=true`; and `master` (0405's delivery check) exits 0 before
21
+ # `finalize`. A failing action aborts the run as failed at that state (the engine's default
22
+ # onError), which is what keeps an unmeasured take out of the judge and a failed file out of the
23
+ # report — the explicit `failed` edges below are the judgement route.
24
+ #
25
+ # **ADR-115.** Each shell action is one bounded call: a `kk music` verb, or one `kk stage run
26
+ # music-*` subcommand whose body lives in `plugins/kk/scripts/music-stages.ts` (fan-out and bundle
27
+ # assembly are verbs here, never YAML). Both `agent.run` prompts are skill invocations under the
28
+ # 1000-character cap and paste no brief, no rows and no rubric.
29
+ #
30
+ # **Resume (R5).** Every state is artifact-gated: briefs, prompt text, take sidecars, the analysis,
31
+ # `checks.json`, the judge bundle and the verdict all survive a failure, so a resumed run continues
32
+ # from the first artifact that is missing and never re-pays for a take that is on disk.
33
+ "$schema": "@gobing-ai/spur/schemas/state-machine-workflow.schema.json"
34
+ name: kk-music
35
+ kind: state-machine
36
+ description: >-
37
+ One musical idea into one delivered take: author differentiated briefs, explore them in the
38
+ format's own model, let the operator pick, analyze and measure that take, judge it against the
39
+ music-quality rubric, loudness-normalize it to a delivery profile and report the run.
40
+ initialState: prepare
41
+ terminalStates:
42
+ - done
43
+ - failed
44
+ failureStates:
45
+ - failed
46
+ iterationBound: 12
47
+ vars:
48
+ # --- the idea (R1): a one-line topic, or an existing idea/brief file ---
49
+ topic: ""
50
+ idea_file: ""
51
+ # --- the musical direction: shipped format + theme presets (`kk music presets`) ---
52
+ format: "song"
53
+ theme: ""
54
+ # --- the run directory: <works>/kk-music/<topic-slug>/ ---
55
+ works: ".works"
56
+ run_dir: ""
57
+ # --- spend shape: differentiated briefs to explore (default 2, never above music.takesCap) ---
58
+ directions: "2"
59
+ # --- who runs the authoring and judging agent.run steps ---
60
+ agent: ""
61
+ # --- delivery: the loudness profile `kk music master` normalizes to ---
62
+ delivery_profile: "streaming"
63
+ # --- gates ---
64
+ auto: "false"
65
+ accept_revision: "false"
66
+ force: "false"
67
+ force_reason: ""
68
+ # --- free rehearsal: KK_MUSIC_DRY_RUN=1 for every paid verb (offline adapter, no network) ---
69
+ dry_run: "false"
70
+ # --- projected from the run directory, never authored by hand ---
71
+ take_file: ""
72
+ instance_id: ""
73
+ brief_number: ""
74
+ verdict: ""
75
+ __runId: ""
76
+ __hitlAnswer: ""
77
+
78
+ states:
79
+ - id: prepare
80
+ description: >-
81
+ Resolve <works>/kk-music/<topic-slug>/, stage 1-brief/ and 3-takes/, write idea.md and publish
82
+ the run-bound path this workflow projects into vars.run_dir. No instance traffic.
83
+ onEnter:
84
+ - kind: shell
85
+ options:
86
+ command: >-
87
+ kk stage run music-prepare "${vars.works}" "${vars.topic}" "${vars.idea_file}"
88
+ "${vars.format}" "${vars.theme}" "${vars.directions}" "${vars.force}" "${vars.__runId}"
89
+ - kind: file.read.into-var
90
+ options:
91
+ path: ".spur/run/${vars.__runId}-music-run-dir.txt"
92
+ var: run_dir
93
+
94
+ - id: brief
95
+ description: >-
96
+ Author `directions` differentiated briefs and render each one's prompt text (agent.run on
97
+ kk:music-authoring). Free: render opens no socket. Existing briefs are reused verbatim.
98
+ onEnter:
99
+ - kind: agent.run
100
+ options:
101
+ role: scribe
102
+ agent: ${vars.agent}
103
+ input: |
104
+ Invoke the kk:music-authoring skill, operation `brief`.
105
+ Run directory: ${vars.run_dir} — idea at ${vars.run_dir}/idea.md.
106
+ Format ${vars.format}, theme ${vars.theme}, ${vars.directions} differentiated direction(s).
107
+ For each number 01..0${vars.directions}: write 1-brief/brief-<nn>.yaml in the 0397 authoring form
108
+ (takes: 1, no invented keys) and render it — kk music render --in 1-brief/brief-<nn>.yaml
109
+ --out 1-brief/brief-<nn>.prompt.txt, stdout into 1-brief/brief-<nn>.render.txt.
110
+ Reuse any brief-<nn>.yaml that already exists verbatim; never edit an authored brief.
111
+ Do not call kk music gen: exploring is the next state's job.
112
+ expectFile: ${vars.run_dir}/1-brief/brief-01.prompt.txt
113
+ - kind: shell
114
+ options:
115
+ command: >-
116
+ test -f "${vars.run_dir}/1-brief/brief-${vars.directions}.yaml" &&
117
+ test -f "${vars.run_dir}/1-brief/brief-${vars.directions}.prompt.txt"
118
+
119
+ - description: >-
120
+ One take per differentiated brief, in the format's own model. A brief whose sidecar and take
121
+ are on disk is adopted (no request); a digest already paid for refuses without force+reason.
122
+ id: explore
123
+ onEnter:
124
+ - kind: shell
125
+ options:
126
+ command: >-
127
+ kk stage run music-explore "${vars.run_dir}" "${vars.directions}" "${vars.force}"
128
+ "${vars.force_reason}" "${vars.dry_run}" "${vars.__runId}"
129
+
130
+ - id: select
131
+ description: "The only operator gate: pick which take becomes the deliverable (skipped by `auto` only when one take exists)"
132
+ pause: true
133
+ onEnter:
134
+ - kind: hitl.select
135
+ options:
136
+ prompt: >-
137
+ Pick the take to deliver from ${vars.run_dir}/3-takes/ — 01..0${vars.directions}. Each take's
138
+ prompt text is at 1-brief/brief-<nn>.prompt.txt and its spend is in 3-takes/explore.json.
139
+ options:
140
+ - "01"
141
+ - "02"
142
+ - "03"
143
+ - "04"
144
+ var: __hitlAnswer
145
+ # No auto path skips this state except the single-take route below, so the gate asks.
146
+ decision:
147
+ mode: never
148
+ - kind: shell
149
+ options:
150
+ command: >-
151
+ kk stage run music-select "${vars.run_dir}" "${vars.__hitlAnswer}" "${vars.auto}"
152
+ - kind: file.read.into-var
153
+ options:
154
+ path: ${vars.run_dir}/3-takes/.brief
155
+ var: brief_number
156
+
157
+ - id: analyze
158
+ description: >-
159
+ Bind the selected take (already bound by explore when there is exactly one) and pay for that
160
+ take's instance analysis once. A cached analysis-<instanceId>.json is adopted, never re-bought.
161
+ onEnter:
162
+ - kind: shell
163
+ options:
164
+ command: 'kk stage run music-select "${vars.run_dir}" "" "${vars.auto}"'
165
+ - kind: file.read.into-var
166
+ options:
167
+ path: ${vars.run_dir}/3-takes/.take-file
168
+ var: take_file
169
+ - kind: file.read.into-var
170
+ options:
171
+ path: ${vars.run_dir}/3-takes/.instance-id
172
+ var: instance_id
173
+ - kind: file.read.into-var
174
+ options:
175
+ path: ${vars.run_dir}/3-takes/.brief
176
+ var: brief_number
177
+ - kind: shell
178
+ options:
179
+ command: 'kk stage run music-analyze "${vars.run_dir}" "${vars.dry_run}"'
180
+
181
+ - id: check
182
+ description: >-
183
+ Measure the selected take (0405 take checks: duration band, leading/trailing silence, analysis
184
+ present, warn-only brief agreement) and write <take>.checks.json. A fail row exits 1, so no
185
+ unmeasured take reaches the judge.
186
+ onEnter:
187
+ - kind: shell
188
+ options:
189
+ command: >-
190
+ kk music check "${vars.run_dir}/3-takes/${vars.take_file}"
191
+ --brief "${vars.run_dir}/1-brief/brief-${vars.brief_number}.yaml"
192
+
193
+ - id: judge
194
+ description: >-
195
+ Assemble 4-judge-input.md from the five verbatim inputs once checks are clean, then judge the
196
+ take against the music-quality rubric (agent.run on kk:content-judge).
197
+ onEnter:
198
+ - kind: shell
199
+ options:
200
+ command: 'kk stage run music-judge-input "${vars.run_dir}"'
201
+ - kind: agent.run
202
+ options:
203
+ role: reviewer
204
+ agent: ${vars.agent}
205
+ input: |
206
+ Invoke the kk:content-judge skill with rubric `music-quality`.
207
+ content_path: ${vars.run_dir}/4-judge-input.md
208
+ content_ref: ${vars.run_dir}/3-takes/${vars.take_file}
209
+ verdict_path: ${vars.run_dir}/4-verdict-music.json
210
+ Grade only what the bundle shows; every measurement is quoted from checks.json with its
211
+ unit and source, never re-derived and never scored by ear. Emit the existing verdict
212
+ contract (verdict, confidence HIGH|MEDIUM|LOW, rubric, findings[], content_ref) and no
213
+ second verdict file.
214
+ expectFile: ${vars.run_dir}/4-verdict-music.json
215
+
216
+ - id: master
217
+ description: >-
218
+ Loudness-normalize the selected take to the delivery profile (0405). The post-master delivery
219
+ check is the last word: a delivery miss exits 1 and never reaches finalize.
220
+ onEnter:
221
+ - kind: shell
222
+ options:
223
+ command: >-
224
+ kk music master "${vars.run_dir}/3-takes/${vars.take_file}" --profile "${vars.delivery_profile}"
225
+
226
+ - id: finalize
227
+ description: >-
228
+ Write the run report: spend summed from the take sidecars, instance ids, verdict, the delivery
229
+ profile with its measured LUFS/true peak, and the final artifact path (R4).
230
+ onEnter:
231
+ - kind: shell
232
+ options:
233
+ command: >-
234
+ kk stage run music-finalize "${vars.run_dir}" "${vars.delivery_profile}" "${vars.format}"
235
+ "${vars.__runId}"
236
+
237
+ - id: done
238
+ description: "Terminal — the take is measured, judged PASS, normalized and reported."
239
+ - id: failed
240
+ description: >-
241
+ Terminal — the verdict refused the take (FAIL, an out-of-contract PASS, or NEEDS_REVISION
242
+ without accept_revision). A failing deterministic action fails the run at its own state.
243
+
244
+ transitions:
245
+ - from: prepare
246
+ to: brief
247
+ description: "Run directory staged and idea.md written -> author the briefs"
248
+ guard:
249
+ kind: always
250
+
251
+ - from: brief
252
+ to: explore
253
+ description: "Every direction has a brief and a rendered prompt -> take one take per brief"
254
+ guard:
255
+ kind: always
256
+
257
+ - from: explore
258
+ to: analyze
259
+ description: "auto with exactly one take -> the single take is not a choice, skip the operator gate"
260
+ guard:
261
+ kind: shell
262
+ options:
263
+ command: >-
264
+ test "${vars.auto}" = "true" &&
265
+ jq -e '.takes == 1' "${vars.run_dir}/3-takes/explore.json" >/dev/null
266
+
267
+ - from: explore
268
+ to: select
269
+ description: "Takes on disk -> pause for the operator's pick (always, when there is more than one take)"
270
+ guard:
271
+ kind: always
272
+
273
+ - from: select
274
+ to: analyze
275
+ description: "A take was selected -> bind and analyze that take only"
276
+ guard:
277
+ kind: always
278
+
279
+ - from: analyze
280
+ to: check
281
+ description: "The selected take's analysis is on disk -> measure it"
282
+ guard:
283
+ kind: always
284
+
285
+ - from: check
286
+ to: judge
287
+ description: "Every take check passed (checks.json has no fail row) -> assemble the bundle and judge"
288
+ guard:
289
+ kind: always
290
+
291
+ - from: judge
292
+ to: master
293
+ description: "PASS with a HIGH/MEDIUM/LOW confidence -> normalize"
294
+ guard:
295
+ kind: shell
296
+ options:
297
+ command: >-
298
+ v="$(jq -r 'if (.verdict // "") == "PASS" then (.verdict + (if ((.confidence // "") | test("^(HIGH|MEDIUM|LOW)$")) then "" else "!" end)) else (.verdict // "") end' ${vars.run_dir}/4-verdict-music.json 2>/dev/null)";
299
+ test "$v" = PASS
300
+
301
+ - from: judge
302
+ to: master
303
+ description: "NEEDS_REVISION with accept_revision=true -> normalize the take as it is"
304
+ guard:
305
+ kind: shell
306
+ options:
307
+ command: >-
308
+ v="$(jq -r 'if (.verdict // "") == "PASS" then (.verdict + (if ((.confidence // "") | test("^(HIGH|MEDIUM|LOW)$")) then "" else "!" end)) else (.verdict // "") end' ${vars.run_dir}/4-verdict-music.json 2>/dev/null)";
309
+ test "$v" = NEEDS_REVISION && test "${vars.accept_revision}" = "true"
310
+
311
+ - from: judge
312
+ to: failed
313
+ terminalReason: failed-guard
314
+ description: "FAIL, an out-of-contract PASS, or NEEDS_REVISION without accept_revision -> block master"
315
+ guard:
316
+ kind: always
317
+
318
+ - from: master
319
+ to: finalize
320
+ description: "Delivery check passed on the encoded output -> report the run"
321
+ guard:
322
+ kind: always
323
+
324
+ - from: finalize
325
+ to: done
326
+ description: "Run report written -> complete"
327
+ guard:
328
+ kind: always
@@ -91,7 +91,10 @@ nodes:
91
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
92
  --out-plan ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json
93
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).
94
+ Then follow mode `align` (SKILL.md) and deliver ${vars.work_dir}/21-plan/${vars.run_date}_judgment-proposal.json:
95
+ evidence-backed judgments over the SAME selected ids, superseding (never rewriting) an aired one;
96
+ no new evidence = {"version":1,"judgments":[]}. Ledger for reference: ${vars.work_dir}/../conclusion.md
97
+ Deliver all three JSON files with your file-write tool (a headless sandbox may block shell writes).
95
98
  expectFile: ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json
96
99
  allowAppend: false
97
100
 
@@ -135,7 +138,7 @@ nodes:
135
138
  allowAppend: false
136
139
 
137
140
  - id: curate-final
138
- description: "`generate-check --step curate --final`: the documented fallback — untranslated candidates with `[]` exclusions — when the fix pass still fails"
141
+ description: "`generate-check --step curate --final`: the documented fallback — untranslated candidates with `[]` exclusions — when the fix pass still fails; also commits the editorial judgment ledger (0384), the deterministic alignment entry before `script-write`"
139
142
  dependsOn: [curate-check, curate-fix]
140
143
  condition:
141
144
  kind: shell
@@ -167,6 +170,9 @@ nodes:
167
170
  --in ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json (don't edit it)
168
171
  --excluded ${vars.work_dir}/21-plan/${vars.run_date}_03_curate_excluded.json
169
172
  --out ${vars.work_dir}/24-script/${vars.run_date}_08_script-write_plan.json
173
+ Draft from the frozen judgments at ${vars.work_dir}/21-plan/${vars.run_date}_judgment-snapshot.json (never the live
174
+ ledger): acknowledge any correction it carries openly (error, apology, corrected fact), and never restate
175
+ a superseded claim.
170
176
  Output only the JSON file.
171
177
  expectFile: ${vars.work_dir}/24-script/${vars.run_date}_08_script-write_plan.json
172
178
  allowAppend: false
@@ -291,6 +297,55 @@ nodes:
291
297
  test "${vars.skip_review}" != "true"
292
298
  && grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null
293
299
 
300
+ # ── 13a. localize: en/ja translations of the reviewed zh article, before the freeze ────────
301
+ - id: localize
302
+ description: >-
303
+ Translate the reviewed zh article into en/ja (0409 R1) and write
304
+ `22-article/locales/{en,ja}.md` (first line `# <title>`, rest the body). The site's publish
305
+ orchestrator refuses a `sub-category:ai-daily` post whose locale set is incomplete, and the
306
+ translations must exist BEFORE the freeze so the variant — hence the variants safety review
307
+ and the freeze digest — covers exactly the bytes that publish (ADR-053). Translating here,
308
+ not in the plugin, keeps the model call in the workflow and the plugin deterministic.
309
+ dependsOn: [render, review]
310
+ condition:
311
+ kind: shell
312
+ options:
313
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
314
+ action:
315
+ kind: agent.run
316
+ options:
317
+ role: scribe
318
+ agent: ${vars.agent}
319
+ timeoutMs: 900000
320
+ # ADR-115 error tier: keep this prompt <= 1000 chars.
321
+ input: |
322
+ Translate the daily AI digest article into English and Japanese (task 0409).
323
+ Source: ${vars.work_dir}/22-article/${vars.run_date}_06_article_content.json (title, body).
324
+ Write TWO plain markdown files with your file-write tool (a headless sandbox may block shell writes):
325
+ ${vars.work_dir}/22-article/locales/en.md and ${vars.work_dir}/22-article/locales/ja.md
326
+ Each file: first line `# <translated title>`, then a blank line, then the translated body.
327
+ Keep every code block, URL, model name, company name and reference intact; translate prose only.
328
+ English: natural tech-journalism English. Japanese: natural です・ます tech-journalism Japanese.
329
+ Neither file may contain Chinese text — a zh draft under /en/ or /ja/ fails the gate.
330
+ expectFile: ${vars.work_dir}/22-article/locales/ja.md
331
+ allowAppend: false
332
+
333
+ - id: localize-check
334
+ description: >-
335
+ `news-localize-validate` (0409 R1): a deterministic gate on the two translations — missing,
336
+ empty, untitled, or untranslated (a zh document under en/ja) fails the run HERE, before the
337
+ variants are built and long before `surfdash-pub` would hit the site's opaque
338
+ "missing locale file(s)". No `onError: continue`: a half-localized day must not freeze.
339
+ dependsOn: [localize]
340
+ condition:
341
+ kind: shell
342
+ options:
343
+ command: 'grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null'
344
+ action:
345
+ kind: shell
346
+ options:
347
+ command: 'kk stage news-localize-validate "${vars.work_dir}"'
348
+
294
349
  # ── 14–16. voice: one engine per attempt, the fallback chain visible in the graph ───────────
295
350
  - id: voice
296
351
  description: >-
@@ -359,7 +414,7 @@ nodes:
359
414
  `daily-safety-manifest` in one process: `31-publish/` prep, `30-variants/*` payloads and the
360
415
  manifest the nested variants review registers. Two stages, because the review of those
361
416
  variants has to run between them and a nested workflow call cannot live inside a verb.
362
- dependsOn: [voice, voice-fallback, voice-fallback2, cards]
417
+ dependsOn: [voice, voice-fallback, voice-fallback2, cards, localize-check]
363
418
  condition:
364
419
  kind: shell
365
420
  options:
@@ -20758,6 +20758,9 @@ async function ensureProfileDir2(profileDir, headless) {
20758
20758
  var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20759
20759
  // ../../packages/publish-harness/src/browser.ts
20760
20760
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20761
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20762
+ var MIN_PASS_BUDGET_MS = 5000;
20763
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20761
20764
  var DEFAULT_POLL_MS = 500;
20762
20765
  function isInstantBrowserDeath(message) {
20763
20766
  return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
@@ -20880,14 +20883,21 @@ async function checkChannelSession(config, opts) {
20880
20883
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20881
20884
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20882
20885
  let lastDetail = `${config.channel} readiness was never probed`;
20886
+ const deadline = Date.now() + timeoutMs;
20887
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20888
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20889
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20883
20890
  for (const headless of passes) {
20891
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20892
+ if (remainingMs < minPassMs)
20893
+ break;
20884
20894
  try {
20885
20895
  await withProfilePage({
20886
20896
  profileDir: opts.profileDir,
20887
20897
  headless,
20888
20898
  url: config.homeUrl,
20889
20899
  isAuthenticated: config.isAuthenticated,
20890
- timeoutMs,
20900
+ timeoutMs: remainingMs,
20891
20901
  launcher: opts.launcher ?? kkBrowserLauncher
20892
20902
  }, async () => true);
20893
20903
  return {
@@ -20189,6 +20189,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20189
20189
  var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
20190
20190
  var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
20191
20191
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20192
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20193
+ var MIN_PASS_BUDGET_MS = 5000;
20194
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20192
20195
  var DEFAULT_POLL_MS = 500;
20193
20196
  function isInstantBrowserDeath(message) {
20194
20197
  return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
@@ -20311,14 +20314,21 @@ async function checkChannelSession(config, opts) {
20311
20314
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20312
20315
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20313
20316
  let lastDetail = `${config.channel} readiness was never probed`;
20317
+ const deadline = Date.now() + timeoutMs;
20318
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20319
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20320
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20314
20321
  for (const headless of passes) {
20322
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20323
+ if (remainingMs < minPassMs)
20324
+ break;
20315
20325
  try {
20316
20326
  await withProfilePage({
20317
20327
  profileDir: opts.profileDir,
20318
20328
  headless,
20319
20329
  url: config.homeUrl,
20320
20330
  isAuthenticated: config.isAuthenticated,
20321
- timeoutMs,
20331
+ timeoutMs: remainingMs,
20322
20332
  launcher: opts.launcher ?? kkBrowserLauncher
20323
20333
  }, async () => true);
20324
20334
  return {
@@ -20779,6 +20779,9 @@ async function ensureProfileDir2(profileDir, headless) {
20779
20779
  var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20780
20780
  // ../../packages/publish-harness/src/browser.ts
20781
20781
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20782
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20783
+ var MIN_PASS_BUDGET_MS = 5000;
20784
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20782
20785
  var DEFAULT_STEP_TIMEOUT_MS = 30000;
20783
20786
  var DEFAULT_POLL_MS = 500;
20784
20787
  var ATTACH_POLL_MS = 100;
@@ -20903,14 +20906,21 @@ async function checkChannelSession(config, opts) {
20903
20906
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20904
20907
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20905
20908
  let lastDetail = `${config.channel} readiness was never probed`;
20909
+ const deadline = Date.now() + timeoutMs;
20910
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20911
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20912
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20906
20913
  for (const headless of passes) {
20914
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20915
+ if (remainingMs < minPassMs)
20916
+ break;
20907
20917
  try {
20908
20918
  await withProfilePage({
20909
20919
  profileDir: opts.profileDir,
20910
20920
  headless,
20911
20921
  url: config.homeUrl,
20912
20922
  isAuthenticated: config.isAuthenticated,
20913
- timeoutMs,
20923
+ timeoutMs: remainingMs,
20914
20924
  launcher: opts.launcher ?? kkBrowserLauncher
20915
20925
  }, async () => true);
20916
20926
  return {
@@ -20210,6 +20210,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20210
20210
  var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
20211
20211
  var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
20212
20212
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20213
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20214
+ var MIN_PASS_BUDGET_MS = 5000;
20215
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20213
20216
  var DEFAULT_POLL_MS = 500;
20214
20217
  function isInstantBrowserDeath(message) {
20215
20218
  return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
@@ -20332,14 +20335,21 @@ async function checkChannelSession(config, opts) {
20332
20335
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20333
20336
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20334
20337
  let lastDetail = `${config.channel} readiness was never probed`;
20338
+ const deadline = Date.now() + timeoutMs;
20339
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20340
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20341
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20335
20342
  for (const headless of passes) {
20343
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20344
+ if (remainingMs < minPassMs)
20345
+ break;
20336
20346
  try {
20337
20347
  await withProfilePage({
20338
20348
  profileDir: opts.profileDir,
20339
20349
  headless,
20340
20350
  url: config.homeUrl,
20341
20351
  isAuthenticated: config.isAuthenticated,
20342
- timeoutMs,
20352
+ timeoutMs: remainingMs,
20343
20353
  launcher: opts.launcher ?? kkBrowserLauncher
20344
20354
  }, async () => true);
20345
20355
  return {
@@ -20776,6 +20776,9 @@ async function ensureProfileDir2(profileDir, headless) {
20776
20776
  var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20777
20777
  // ../../packages/publish-harness/src/browser.ts
20778
20778
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20779
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20780
+ var MIN_PASS_BUDGET_MS = 5000;
20781
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20779
20782
  var DEFAULT_STEP_TIMEOUT_MS = 30000;
20780
20783
  var DEFAULT_POLL_MS = 500;
20781
20784
  var ATTACH_POLL_MS = 100;
@@ -20900,14 +20903,21 @@ async function checkChannelSession(config, opts) {
20900
20903
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20901
20904
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20902
20905
  let lastDetail = `${config.channel} readiness was never probed`;
20906
+ const deadline = Date.now() + timeoutMs;
20907
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20908
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20909
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20903
20910
  for (const headless of passes) {
20911
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20912
+ if (remainingMs < minPassMs)
20913
+ break;
20904
20914
  try {
20905
20915
  await withProfilePage({
20906
20916
  profileDir: opts.profileDir,
20907
20917
  headless,
20908
20918
  url: config.homeUrl,
20909
20919
  isAuthenticated: config.isAuthenticated,
20910
- timeoutMs,
20920
+ timeoutMs: remainingMs,
20911
20921
  launcher: opts.launcher ?? kkBrowserLauncher
20912
20922
  }, async () => true);
20913
20923
  return {
@@ -20482,6 +20482,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20482
20482
  var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
20483
20483
  var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
20484
20484
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20485
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20486
+ var MIN_PASS_BUDGET_MS = 5000;
20487
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20485
20488
  var DEFAULT_POLL_MS = 500;
20486
20489
  function isInstantBrowserDeath(message) {
20487
20490
  return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
@@ -20604,14 +20607,21 @@ async function checkChannelSession(config, opts) {
20604
20607
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20605
20608
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20606
20609
  let lastDetail = `${config.channel} readiness was never probed`;
20610
+ const deadline = Date.now() + timeoutMs;
20611
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20612
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20613
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20607
20614
  for (const headless of passes) {
20615
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20616
+ if (remainingMs < minPassMs)
20617
+ break;
20608
20618
  try {
20609
20619
  await withProfilePage({
20610
20620
  profileDir: opts.profileDir,
20611
20621
  headless,
20612
20622
  url: config.homeUrl,
20613
20623
  isAuthenticated: config.isAuthenticated,
20614
- timeoutMs,
20624
+ timeoutMs: remainingMs,
20615
20625
  launcher: opts.launcher ?? kkBrowserLauncher
20616
20626
  }, async () => true);
20617
20627
  return {
@@ -20776,6 +20776,9 @@ async function ensureProfileDir2(profileDir, headless) {
20776
20776
  var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20777
20777
  // ../../packages/publish-harness/src/browser.ts
20778
20778
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20779
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20780
+ var MIN_PASS_BUDGET_MS = 5000;
20781
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20779
20782
  var DEFAULT_STEP_TIMEOUT_MS = 30000;
20780
20783
  var DEFAULT_POLL_MS = 500;
20781
20784
  var ATTACH_POLL_MS = 100;
@@ -20900,14 +20903,21 @@ async function checkChannelSession(config, opts) {
20900
20903
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20901
20904
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20902
20905
  let lastDetail = `${config.channel} readiness was never probed`;
20906
+ const deadline = Date.now() + timeoutMs;
20907
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20908
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20909
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20903
20910
  for (const headless of passes) {
20911
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20912
+ if (remainingMs < minPassMs)
20913
+ break;
20904
20914
  try {
20905
20915
  await withProfilePage({
20906
20916
  profileDir: opts.profileDir,
20907
20917
  headless,
20908
20918
  url: config.homeUrl,
20909
20919
  isAuthenticated: config.isAuthenticated,
20910
- timeoutMs,
20920
+ timeoutMs: remainingMs,
20911
20921
  launcher: opts.launcher ?? kkBrowserLauncher
20912
20922
  }, async () => true);
20913
20923
  return {