@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
@@ -1,17 +1,19 @@
1
- # kk-daily-publish3-overseas — overseas window behind the podcast RSS gate (tasks 0323 R5, 0334 R1-R2).
1
+ # kk-daily-publish3-overseas — overseas window behind the podcast RSS gate (tasks 0323 R5,
2
+ # 0334 R1-R2; kk news verbs since 0369).
2
3
  #
3
4
  # 07:00 America/Los_Angeles, which needs no DST adjustment: the entry is defined in the zone the
4
5
  # machine already runs in. The gated date is the PREVIOUS day, because the observed episodes land
5
- # 13:43–15:22 PDT (after this tick) — the launcher derives yesterday's LA date for `run_date`.
6
+ # 13:43–15:22 PDT (after this tick) — `kk news publish` derives yesterday's LA date for
7
+ # `run_date` for this window.
6
8
  #
7
9
  # The gate decides whether anything publishes: a miss cancels the overseas targets and runs
8
- # `diagnose` + the tier-0-only repair. This line carries no live consent; the overseas channels
9
- # in the shipped preset are `draft`, so a live overseas post stays an operator launch.
10
+ # `diagnose` + the tier-0-only repair. This line carries no live consent; the overseas rows in the
11
+ # shipped preset are `dummy`/`off`, so a live overseas post stays an operator launch.
10
12
  #
11
- # plugins/kk/scripts/voice3-publish-window.ts (task 0334) owns the date math because a crontab
12
- # command ends at the first UNESCAPED percent sign — the old inline `date -v-1d +%Y%m%d` shell
13
- # truncated silently. The launcher resolves the GENERATION bundle (voice2 namespace, effective
14
- # works root) and refuses a missing/mismatched bundle before any spur process starts.
13
+ # `kk news publish` owns the date math because a crontab command ends at the first UNESCAPED
14
+ # percent sign — an inline `date -v-1d +%Y%m%d` would truncate silently. The verb resolves the
15
+ # generation bundle from the effective works root and refuses a missing or mismatched bundle
16
+ # before it touches a channel.
15
17
  #
16
18
  # Rendered by `kk schedule render kk-daily-publish3-overseas --platform cron --repo <checkout>`;
17
19
  # kk never edits the operator's crontab. MERGE, never replace:
@@ -19,4 +21,4 @@
19
21
  # crontab -l > /tmp/kk-overseas.cron 2>/dev/null || :
20
22
  # kk schedule render kk-daily-publish3-overseas --platform cron --repo "$PWD" >> /tmp/kk-overseas.cron
21
23
  # crontab /tmp/kk-overseas.cron
22
- 0 7 * * * cd {{repo}} && mkdir -p .works/kk-daily-publish3 && PATH="{{home}}/.bun/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" TZ=America/Los_Angeles bun {{repo}}/plugins/kk/scripts/voice3-publish-window.ts --window overseas-rss >> {{repo}}/.works/kk-daily-publish3/overseas.log 2>&1
24
+ 0 7 * * * cd {{repo}} && mkdir -p .works/kk-news-publish && PATH="{{home}}/.bun/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" TZ=America/Los_Angeles kk news publish --window overseas-rss --unattended >> {{repo}}/.works/kk-news-publish/overseas.log 2>&1
@@ -304,18 +304,196 @@ function authoredPlanDescendants(workDir: string, runDate: string): string[] {
304
304
  */
305
305
  const SPEAK_CHAR_EXPANSION = 1.4;
306
306
 
307
+ /**
308
+ * The cold-start ratio the PRE-SPEND widen decision uses, and it is deliberately not 1.4.
309
+ *
310
+ * The consumers need opposite safe directions (the same argument `scriptFloorCharRate` makes about
311
+ * the char rate): the reported arithmetic wants the typical ratio, while the pre-spend gates want
312
+ * the *worst measured* ratio, because a cheap error is a rung too many and the expensive one is an
313
+ * authoring pass the TTS gate then refuses.
314
+ *
315
+ * Measured spoken/kept-candidate ratios: 2026-10-11 1,270/1,800 = 0.71 and 5,925/4,300 = 1.38;
316
+ * 2026-11-15 run `kk-news-generate-20261115-1794773860762` 2,053/7,244 = 0.28. Treating 1.4 as the
317
+ * floor ratio let that day pass the gate at 32.6 min, spend a full authoring pass, then refuse at
318
+ * 6.2 min — and the ladder that exists to fill a thin day from the backlog never climbed a rung
319
+ * (0377).
320
+ *
321
+ * This constant is only the fallback: both gates prefer the ratio a previous run recorded, and the
322
+ * two records carry DIFFERENT denominators (see `readKeptRatio` — using one ratio for both was the
323
+ * 2026-11-16 refusal of a 23-min episode).
324
+ */
325
+ const SPEAK_CHAR_EXPANSION_FLOOR = 0.28;
326
+
327
+ /**
328
+ * Where a run records the ratios it actually delivered (0377 R2/R3). Two denominators, because the
329
+ * two pre-spend consumers measure different sets: `ratio` is spoken/pool (the ladder, which judges
330
+ * the raw extracted pool) and `keptRatio` is spoken/kept-candidate chars (the floor gate, which
331
+ * judges what QC actually admitted). The gates read the newest record from the sibling run
332
+ * directories, so they judge today's material by what the writer really produced last time instead
333
+ * of a constant that was calibrated once.
334
+ */
335
+ const SPOKEN_RATIO_SUFFIX = '_09_spoken-ratio.json';
336
+
337
+ /** The measured ratio one run delivered, and where it came from. */
338
+ interface SpokenRatio {
339
+ ratio: number;
340
+ source: string;
341
+ }
342
+
343
+ /** Clamp a recorded ratio into a plausible band: a corrupt file must not freeze or flood the ladder. */
344
+ function clampRatio(value: number): number {
345
+ return Math.min(2, Math.max(0.05, value));
346
+ }
347
+
348
+ /**
349
+ * The newest recorded spoken/raw ratio across this workflow's run directories, or the calibrated
350
+ * floor constant when no run has recorded one yet. `workDir` is one run directory, so its parent is
351
+ * the workflow directory the sibling runs live in.
352
+ */
353
+ function readSpokenRatio(workDir: string): SpokenRatio {
354
+ const base = resolve(workDir, '..');
355
+ let newest: { at: number; ratio: number; from: string } | null = null;
356
+ let entries: string[] = [];
357
+ try {
358
+ entries = readdirSync(base);
359
+ } catch {
360
+ return { ratio: SPEAK_CHAR_EXPANSION_FLOOR, source: 'default 0.28 (no sibling runs)' };
361
+ }
362
+ for (const entry of entries) {
363
+ const dir = join(base, entry, '21-plan');
364
+ let files: string[] = [];
365
+ try {
366
+ files = readdirSync(dir).filter((file) => file.endsWith(SPOKEN_RATIO_SUFFIX));
367
+ } catch {
368
+ continue;
369
+ }
370
+ for (const file of files) {
371
+ const path = join(dir, file);
372
+ try {
373
+ const parsed = readJson(path) as Record<string, unknown> | null;
374
+ const ratio = Number(parsed?.ratio);
375
+ if (!Number.isFinite(ratio) || ratio <= 0) continue;
376
+ const at = statSync(path).mtimeMs;
377
+ if (newest === null || at > newest.at) newest = { at, ratio, from: path };
378
+ } catch {
379
+ // A malformed record is not evidence; the next run overwrites it.
380
+ }
381
+ }
382
+ }
383
+ if (newest === null) return { ratio: SPEAK_CHAR_EXPANSION_FLOOR, source: 'default 0.28 (no recorded run)' };
384
+ return { ratio: clampRatio(newest.ratio), source: `${newest.from} (${newest.ratio.toFixed(2)}x)` };
385
+ }
386
+
387
+ /**
388
+ * The newest recorded spoken/KEPT ratio across sibling runs, or the cold-start constant.
389
+ *
390
+ * WHY this is separate from `readSpokenRatio` (2026-11-16): one constant was applied to two
391
+ * different denominators. The ladder multiplies the raw pool (38,241 chars that day) while this gate
392
+ * multiplies the kept candidates (13,963 chars — planning admitted 37% of the pool), so the same
393
+ * 0.28 read as a 34.5 min "clears" in the ladder and a 12.7 min "refusing" at the gate, and the run
394
+ * paid for the planning pass to discover it. The writer then delivered 7,194 spoken chars ≈ 23 min:
395
+ * the refusal discounted the planning shrink twice. `keptRatio` for that run is 0.515.
396
+ */
397
+ function readKeptRatio(workDir: string): SpokenRatio {
398
+ const base = resolve(workDir, '..');
399
+ let newest: { at: number; ratio: number; from: string } | null = null;
400
+ let entries: string[] = [];
401
+ try {
402
+ entries = readdirSync(base);
403
+ } catch {
404
+ return { ratio: SPEAK_CHAR_EXPANSION_FLOOR, source: 'default 0.28 (no sibling runs)' };
405
+ }
406
+ for (const entry of entries) {
407
+ const dir = join(base, entry, '21-plan');
408
+ let files: string[] = [];
409
+ try {
410
+ files = readdirSync(dir).filter((file) => file.endsWith(SPOKEN_RATIO_SUFFIX));
411
+ } catch {
412
+ continue;
413
+ }
414
+ for (const file of files) {
415
+ const path = join(dir, file);
416
+ try {
417
+ const parsed = readJson(path) as Record<string, unknown> | null;
418
+ // A pre-2026-11-16 record carries no kept ratio at all: skip it rather than divide by
419
+ // its pool figure, which is what produced the double discount.
420
+ const ratio = Number(parsed?.keptRatio);
421
+ if (!Number.isFinite(ratio) || ratio <= 0) continue;
422
+ const at = statSync(path).mtimeMs;
423
+ if (newest === null || at > newest.at) newest = { at, ratio, from: path };
424
+ } catch {
425
+ // A malformed record is not evidence; the next run overwrites it.
426
+ }
427
+ }
428
+ }
429
+ if (newest === null) return { ratio: SPEAK_CHAR_EXPANSION_FLOOR, source: 'default 0.28 (no recorded kept ratio)' };
430
+ return { ratio: clampRatio(newest.ratio), source: `${newest.from} (${newest.ratio.toFixed(2)}x)` };
431
+ }
432
+
433
+ /**
434
+ * Record what this run delivered — spoken script chars over raw pool chars, and over the kept
435
+ * candidates — and warn when it drifted from the ratio the widen decision used. A refused script
436
+ * records too: a thin day teaches the ladder even though it produced no episode.
437
+ */
438
+ function recordSpokenRatio(workDir: string, runDate: string, spokenChars: number): void {
439
+ const poolPath = join(workDir, '10-collect', 'pool.json');
440
+ if (!isFile(poolPath)) return;
441
+ const pool = readJson(poolPath);
442
+ const poolChars = rawChars(Array.isArray(pool) ? pool : []);
443
+ if (poolChars <= 0) return;
444
+ // The admitted set the floor gate measures, so the next pre-spend estimate discounts the planning
445
+ // shrink once instead of twice (2026-11-16).
446
+ const keptPath = join(workDir, '21-plan', `${runDate}_04_quality-control-content_candidates.json`);
447
+ const keptChars = isFile(keptPath) ? rawChars(metadataOf(readJson(keptPath)).docs ?? []) : 0;
448
+ const round3 = (value: number): number => Math.round(value * 1000) / 1000;
449
+ const ratio = round3(spokenChars / poolChars);
450
+ const out = join(workDir, '21-plan', `${runDate}${SPOKEN_RATIO_SUFFIX}`);
451
+ mkdirSync(join(workDir, '21-plan'), { recursive: true });
452
+ writeJsonText(out, {
453
+ runDate,
454
+ poolChars,
455
+ ...(keptChars > 0 ? { keptChars, keptRatio: round3(spokenChars / keptChars) } : {}),
456
+ spokenChars,
457
+ ratio,
458
+ });
459
+ // Drift warning: the ladder judged this pool with some ratio; the writer just delivered a
460
+ // different one. A wide gap means the next run's ladder is working from a stale measure.
461
+ let used: number | null = null;
462
+ try {
463
+ const ladder = readJson(join(workDir, '10-collect', 'ladder.json')) as Record<string, unknown> | null;
464
+ const candidate = Number(ladder?.ratioUsed);
465
+ if (Number.isFinite(candidate) && candidate > 0) used = candidate;
466
+ } catch {
467
+ used = null;
468
+ }
469
+ if (used !== null && Math.abs(ratio / used - 1) > 0.25) {
470
+ console.error(
471
+ `spoken ratio drifted: this run delivered ${ratio.toFixed(2)}x of the pool, the ladder widened on ${used.toFixed(2)}x (see ${out})`,
472
+ );
473
+ }
474
+ }
475
+
476
+ /** Title+body characters of a Doc[] — the raw measure every spoken ratio here divides into. */
477
+ function rawChars(docs: unknown[]): number {
478
+ return docs.reduce((sum, doc) => {
479
+ const entry = (doc ?? {}) as Record<string, unknown>;
480
+ return sum + `${String(entry.title ?? '')}`.length + String(entry.body ?? '').length;
481
+ }, 0);
482
+ }
483
+
307
484
  /**
308
485
  * The calibrated pre-spend estimate over a kept pool (title+body characters × the 1.4 expansion,
309
486
  * over the driver's measured char rate, plus the 8 s intro sting) — shared by the pre-spend floor
310
487
  * gate (applyFloorGate) and the post-spend duration refusal (dailyEpisodeDuration, 0266), so both
311
488
  * artifacts report the same arithmetic. `seconds` is unrounded: the floor gate compares seconds.
312
489
  */
313
- function estimateSpokenMinutes(docs: unknown[], vdriver: string): { minutes: number; seconds: number; chars: number } {
314
- const chars = docs.reduce((sum, doc) => {
315
- const entry = (doc ?? {}) as Record<string, unknown>;
316
- return sum + `${String(entry.title ?? '')}`.length + String(entry.body ?? '').length;
317
- }, 0);
318
- const seconds = 8 + (chars * SPEAK_CHAR_EXPANSION) / spokenCharRate(vdriver);
490
+ function estimateSpokenMinutes(
491
+ docs: unknown[],
492
+ vdriver: string,
493
+ expansion: number = SPEAK_CHAR_EXPANSION,
494
+ ): { minutes: number; seconds: number; chars: number } {
495
+ const chars = rawChars(docs);
496
+ const seconds = 8 + (chars * expansion) / spokenCharRate(vdriver);
319
497
  return { minutes: Math.round((seconds / 60) * 10) / 10, seconds, chars };
320
498
  }
321
499
 
@@ -329,6 +507,10 @@ function estimateSpokenMinutes(docs: unknown[], vdriver: string): { minutes: num
329
507
  * `pool-count --min 1` guard then skips the content, audio, publish and XHS subtrees, and the run
330
508
  * closes through run-report and the ledger exactly like an empty pool. The estimate and its inputs
331
509
  * land in a refusal artifact next to the candidates.
510
+ *
511
+ * The ratio comes from `readKeptRatio`, NOT the pool-denominated one the ladder uses: this gate
512
+ * measures the admitted set, and applying the pool ratio to it discounted the planning shrink twice
513
+ * (2026-11-16: estimated 12.7 min, the writer delivered 23).
332
514
  */
333
515
  function applyFloorGate(
334
516
  candidates: string,
@@ -350,7 +532,12 @@ function applyFloorGate(
350
532
  if (clearStaleRefusal && isFile(refusal)) unlinkSync(refusal);
351
533
  return;
352
534
  }
353
- const { minutes: estimatedMinutes, seconds: estimatedSeconds, chars } = estimateSpokenMinutes(docs, vdriver);
535
+ const keptRatio = readKeptRatio(workDir);
536
+ const {
537
+ minutes: estimatedMinutes,
538
+ seconds: estimatedSeconds,
539
+ chars,
540
+ } = estimateSpokenMinutes(docs, vdriver, keptRatio.ratio);
354
541
  if (estimatedSeconds >= floor * 60) {
355
542
  if (clearStaleRefusal && isFile(refusal)) unlinkSync(refusal);
356
543
  console.log(`floor gate: estimated ${estimatedMinutes} min from ${chars} chars — above the ${floor} min floor`);
@@ -362,7 +549,10 @@ function applyFloorGate(
362
549
  estimatedMinutes,
363
550
  minMinutes: floor,
364
551
  candidateChars: chars,
365
- expansion: SPEAK_CHAR_EXPANSION,
552
+ // The ratio this refusal actually used, and where it came from (0377; 2026-11-16): the
553
+ // gate measures the KEPT set, so a pool-denominated ratio under-predicts it badly.
554
+ expansion: keptRatio.ratio,
555
+ expansionSource: keptRatio.source,
366
556
  charRate: spokenCharRate(vdriver),
367
557
  ids,
368
558
  reason: `a ${docs.length}-item pool estimates ${estimatedMinutes} min of speech, below the ${floor} min floor — refusing before any TTS spend`,
@@ -445,23 +635,40 @@ export function dailyExtract(args: string[]): void {
445
635
  console.error(`extract: plan already authored — keeping the frozen pool (${poolPath})`);
446
636
  return;
447
637
  }
638
+ // 0377 R2: judge the pool by what the writer actually delivered last time. The calibrated
639
+ // 0.28 constant is only the fallback for a workflow that has never recorded a ratio.
640
+ const ratio = readSpokenRatio(workDir);
448
641
  let chosen: { window: string; docs: unknown[] } | null = null;
642
+ const rungs: Array<{ window: string; items: number; chars: number; minutes: number; clears: boolean }> = [];
449
643
  for (const ms of windows) {
450
644
  const label = formatWindowMs(ms);
451
645
  const attempt = join(workDir, '10-collect', `.pool-${label}.json`);
452
646
  kk(['store', 'extract', '--topic', topic, '--window', label, '--out', attempt]);
453
647
  const parsed = readJson(attempt);
454
648
  const docs = Array.isArray(parsed) ? (parsed as unknown[]) : [];
455
- const estimate = estimateSpokenMinutes(docs, vdriver);
649
+ const estimate = estimateSpokenMinutes(docs, vdriver, ratio.ratio);
650
+ const clears = estimate.seconds >= floor * 60;
651
+ rungs.push({ window: label, items: docs.length, chars: estimate.chars, minutes: estimate.minutes, clears });
456
652
  chosen = { window: label, docs };
457
653
  const verdict = gated
458
- ? `estimated ${estimate.minutes} min — ${estimate.seconds >= floor * 60 ? 'clears' : 'below'} the ${floor} min floor`
654
+ ? `estimated ${estimate.minutes} min at ${ratio.ratio.toFixed(2)}x — ${clears ? 'clears' : 'below'} the ${floor} min floor`
459
655
  : 'floor gate off';
460
656
  console.error(`extract: ${label} pool ${docs.length} item(s), ${verdict}`);
461
- if (!gated || estimate.seconds >= floor * 60) break;
657
+ if (!gated || clears) break;
462
658
  rmSync(attempt, { force: true });
463
659
  }
464
660
  const picked = chosen ?? { window: formatWindowMs(base), docs: [] as unknown[] };
661
+ // 0377 R3: the decision is an artifact, not just a stderr line — the run report and
662
+ // `kk news status` read which measure drove it, the rung chosen and the estimate at each rung.
663
+ sted('write', join(workDir, '10-collect', 'ladder.json'), () =>
664
+ writeJsonText(join(workDir, '10-collect', 'ladder.json'), {
665
+ floorMinutes: gated ? floor : null,
666
+ ratioUsed: ratio.ratio,
667
+ ratioSource: ratio.source,
668
+ chosen: picked.window,
669
+ rungs,
670
+ }),
671
+ );
465
672
  sted('write', poolPath, () => writeJsonText(poolPath, picked.docs));
466
673
  for (const ms of windows)
467
674
  rmSync(join(workDir, '10-collect', `.pool-${formatWindowMs(ms)}.json`), { force: true });
@@ -1072,6 +1279,9 @@ export function dailyGenerate(args: string[]): void {
1072
1279
  );
1073
1280
  const charRate = scriptFloorCharRate(vdriver);
1074
1281
  const seconds = 8 + chars / charRate;
1282
+ // Record what the writer delivered before judging it: a refused day still teaches the
1283
+ // next run's ladder what this pool really yielded (0377 R2/R3).
1284
+ recordSpokenRatio(workDir, runDate, chars);
1075
1285
  if (seconds < minMinutes * 60) {
1076
1286
  refuseScriptBelowFloor(workDir, runDate, { chars, charRate, seconds, minMinutes });
1077
1287
  return;
@@ -1954,6 +2164,8 @@ const SOCIAL_LIMITS: Record<string, SocialLimit> = {
1954
2164
  x: { max: 280, weighted: true },
1955
2165
  weibo: { max: 2000 },
1956
2166
  threads: { max: 500 },
2167
+ // 即刻's 动态 composer accepts long text; the shared short notice fits far below this.
2168
+ jike: { max: 2000 },
1957
2169
  linkedin: { max: 3000 },
1958
2170
  };
1959
2171
 
@@ -2007,11 +2219,22 @@ export function dailyBundleVariants(args: string[]): void {
2007
2219
 
2008
2220
  // Generic variants first: a channel-specific variant wins over the shared one, so the
2009
2221
  // shared copy must exist for the channels the preset does not specialise.
2222
+ const firstArticleLine =
2223
+ article !== null && typeof (article as Record<string, unknown>).title === 'string'
2224
+ ? String((article as Record<string, unknown>).title)
2225
+ : '';
2010
2226
  if (article === null) skipped.push('article (no 22-article content)');
2011
2227
  else {
2012
2228
  write('article', buildSurfdashContent(article, links, { coverPath: cover }));
2013
2229
  write('article@surfdash-pub', buildSurfdashContent(article, links, { coverPath: cover }));
2014
2230
  write('article@xhs-pub', buildXhsArticleContent(article, { publishStatus: 'draft' }));
2231
+ // The article carries the episode audio at the top (operator request 2026-11-15): the
2232
+ // 公众号 播客 row is off, so without this the MP draft had no player at all. Same source
2233
+ // as the episode variant — `publish-prep`'s rendered mp3 — so one episode has one audio.
2234
+ const articleAudio =
2235
+ prep !== null && typeof metadataOf(prep).audioFile === 'string'
2236
+ ? String(metadataOf(prep).audioFile)
2237
+ : undefined;
2015
2238
  write(
2016
2239
  'article@wechatmp-pub',
2017
2240
  buildWechatArticleContent(article, {
@@ -2019,6 +2242,7 @@ export function dailyBundleVariants(args: string[]): void {
2019
2242
  publishStatus: 'draft',
2020
2243
  collection: '每日AI资讯',
2021
2244
  ...(cover === undefined ? {} : { coverPath: cover }),
2245
+ ...(articleAudio === undefined ? {} : { audioPath: articleAudio, audioTitle: firstArticleLine }),
2022
2246
  }),
2023
2247
  );
2024
2248
  }
@@ -4381,7 +4605,7 @@ const EDITORIAL_ARTICLE_OPENING = '这里是由Robin为你带来的咸话咸说
4381
4605
  * 1. `22-article/<date>_06_article-write_body.md`
4382
4606
  * 2. `23-cover/<date>_07_cover-brief.json`
4383
4607
  * 3. `25-xhs/<date>_18_xhs_plan.json` (only when `cards_enabled === 'true'`)
4384
- * 4. `26-social/{x,threads}.md` (`social.short`)
4608
+ * 4. `26-social/{x,threads,jike}.md` (`social.short`)
4385
4609
  * 5. `26-social/{weibo,linkedin}.md` (`social.long`)
4386
4610
  * Missing master field -> skip that one artifact with a logged reason, write the others.
4387
4611
  */
@@ -4589,11 +4813,11 @@ export function dailyEditorialRender(args: string[]): void {
4589
4813
  const socialDir = join(workDir, '26-social');
4590
4814
  if (socialShort !== '') {
4591
4815
  sted('mkdir', socialDir, () => mkdirSync(socialDir, { recursive: true }));
4592
- for (const name of ['x.md', 'threads.md', 'weibo.md']) {
4816
+ for (const name of ['x.md', 'threads.md', 'weibo.md', 'jike.md']) {
4593
4817
  const out = join(socialDir, name);
4594
4818
  sted('write', out, () => writeRaw(out, `${socialShort}\n`));
4595
4819
  }
4596
- console.log('editorial-render: wrote 26-social/{x,threads,weibo}.md');
4820
+ console.log('editorial-render: wrote 26-social/{x,threads,weibo,jike}.md');
4597
4821
  } else if (socialLong !== '') {
4598
4822
  sted('mkdir', socialDir, () => mkdirSync(socialDir, { recursive: true }));
4599
4823
  const out = join(socialDir, 'weibo.md');
@@ -17,6 +17,7 @@
17
17
  import { spawnSync } from 'node:child_process';
18
18
  import { createHash } from 'node:crypto';
19
19
  import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
20
+ import { homedir } from 'node:os';
20
21
  import { basename, join } from 'node:path';
21
22
 
22
23
  export interface TriageReceipt {
@@ -25,7 +26,6 @@ export interface TriageReceipt {
25
26
  completedAt?: string;
26
27
  workDir?: string;
27
28
  agent?: string;
28
- retryAgent?: string;
29
29
  exitCode?: number;
30
30
  error?: string | null;
31
31
  }
@@ -70,7 +70,41 @@ const RECEIPTS_DIR = join('.spur', 'run');
70
70
  /** When the failed-node text names no nested workflow, assume the daily safety machine. */
71
71
  const WORKFLOW_NESTED_FALLBACK = 'kk-daily-safety';
72
72
  const RUNS_DIR = join('.spur', 'memory', 'runs');
73
- const WORKS_FLOW_DIR = join('.works', 'kk-daily-ai-voice2');
73
+ /** Run directories before the 0369 cut-over; kept so historical runs still triage. */
74
+ const LEGACY_NEWS_WORKFLOW = 'kk-daily-ai-voice2';
75
+
76
+ /**
77
+ * The works sub-directories that hold daily news runs, newest naming first: the workflow named by
78
+ * `content_types.news.workflow` (default `kk-news-generate`), then the pre-cut-over directory.
79
+ */
80
+ export function newsFlowDirs(): string[] {
81
+ let workflow = 'kk-news-generate';
82
+ try {
83
+ const configPath = process.env.KK_CONFIG || join(homedir(), '.config/kk/config.yaml');
84
+ const parsed = Bun.YAML.parse(readFileSync(configPath, 'utf-8')) as {
85
+ content_types?: { news?: { workflow?: unknown } };
86
+ } | null;
87
+ const configured = parsed?.content_types?.news?.workflow;
88
+ if (typeof configured === 'string' && configured !== '') workflow = configured;
89
+ } catch {
90
+ // no readable config: the built-in workflow name stands
91
+ }
92
+ return [...new Set([workflow, LEGACY_NEWS_WORKFLOW])].map((name) => join('.works', name));
93
+ }
94
+
95
+ /** Every `<stamp>/schedule-receipt.json` under the news run roots, newest stamp first per root. */
96
+ function receiptPaths(repo: string): { stamp: string; receiptPath: string }[] {
97
+ return newsFlowDirs().flatMap((dir) => {
98
+ try {
99
+ return readdirSync(join(repo, dir))
100
+ .filter((name) => /^\d{8}$/.test(name))
101
+ .reverse()
102
+ .map((stamp) => ({ stamp, receiptPath: join(repo, dir, stamp, 'schedule-receipt.json') }));
103
+ } catch {
104
+ return [];
105
+ }
106
+ });
107
+ }
74
108
  const FAILED_RECEIPT_STATUSES = new Set(['failed', 'timed-out', 'interrupted', 'incomplete', 'preflight-refused']);
75
109
  /** Receipt statuses that mean the supervisor is mid-flight, not failed. */
76
110
  const ACTIVE_RECEIPT_STATUSES = new Set(['running', 'inspecting']);
@@ -299,7 +333,6 @@ export function collectTriage(
299
333
  ...(typeof raw.completedAt === 'string' ? { completedAt: raw.completedAt } : {}),
300
334
  ...(typeof raw.workDir === 'string' ? { workDir: raw.workDir } : {}),
301
335
  ...(typeof raw.agent === 'string' ? { agent: raw.agent } : {}),
302
- ...(typeof raw.retryAgent === 'string' ? { retryAgent: raw.retryAgent } : {}),
303
336
  ...(typeof raw.exitCode === 'number' ? { exitCode: raw.exitCode } : {}),
304
337
  ...(typeof raw.error === 'string' || raw.error === null
305
338
  ? { error: raw.error as string | null }
@@ -401,40 +434,25 @@ export function summarizeTriage(report: TriageReport): string[] {
401
434
  return [line1, line2, line3, line4, `suggestion: ${report.suggestions[0] ?? '?'}`];
402
435
  }
403
436
 
404
- /** Locate the schedule receipt for a run id across the voice2 works root (stamps newest first). */
437
+ /** Locate the schedule receipt for a run id across the news run roots (stamps newest first). */
405
438
  export function findReceiptByRunId(repo: string, runId: string): string | null {
406
- const root = join(repo, WORKS_FLOW_DIR);
407
- let stamps: string[] = [];
408
- try {
409
- stamps = readdirSync(root).filter((name) => /^\d{8}$/.test(name));
410
- } catch {
411
- return null;
412
- }
413
- for (const stamp of stamps.reverse()) {
414
- const receiptPath = join(root, stamp, 'schedule-receipt.json');
439
+ for (const { receiptPath } of receiptPaths(repo)) {
415
440
  const receipt = readTriageJson(receiptPath);
416
441
  if (receipt !== null && receipt.runId === runId) return receiptPath;
417
442
  }
418
443
  return null;
419
444
  }
420
445
 
421
- /** Newest failed daily-run receipt across the voice2 works root, for `daily-triage --latest`. */
446
+ /** Newest failed daily-run receipt across the news run roots, for `daily-triage --latest`. */
422
447
  export function latestFailedRun(repo: string): { runId: string; receiptPath: string } | null {
423
- const root = join(repo, WORKS_FLOW_DIR);
424
- let stamps: string[] = [];
425
- try {
426
- stamps = readdirSync(root).filter((name) => /^\d{8}$/.test(name));
427
- } catch {
428
- return null;
429
- }
430
448
  const candidates: { runId: string; receiptPath: string; completedAt: number }[] = [];
431
- for (const stamp of stamps.reverse()) {
432
- const receiptPath = join(root, stamp, 'schedule-receipt.json');
449
+ for (const { stamp, receiptPath } of receiptPaths(repo)) {
433
450
  const receipt = readTriageJson(receiptPath);
434
451
  if (receipt === null || typeof receipt.status !== 'string') continue;
435
452
  if (!FAILED_RECEIPT_STATUSES.has(receipt.status)) continue;
436
- const completedAt =
437
- typeof receipt.completedAt === 'string' ? Date.parse(receipt.completedAt) : statSync(receiptPath).mtimeMs;
453
+ // `finishedAt` is the launchWorkflow receipt's spelling (0365); `completedAt` the legacy launcher's.
454
+ const stampedAt = receipt.completedAt ?? receipt.finishedAt;
455
+ const completedAt = typeof stampedAt === 'string' ? Date.parse(stampedAt) : statSync(receiptPath).mtimeMs;
438
456
  candidates.push({
439
457
  runId: typeof receipt.runId === 'string' ? receipt.runId : `${stamp}-unknown`,
440
458
  receiptPath,
@@ -46,7 +46,7 @@ export function main(args: string[]): void {
46
46
  if (values.latest) {
47
47
  const found = latestFailedRun(repo);
48
48
  if (found === null) {
49
- console.log('daily-triage: no failed daily run found in .works/kk-daily-ai-voice2 — nothing to triage');
49
+ console.log('daily-triage: no failed daily run found under .works — nothing to triage');
50
50
  process.exit(0);
51
51
  }
52
52
  runId = found.runId;
@@ -69,9 +69,13 @@ Sequence: **resolve preferences** (Preference chain) → **resolve the format**
69
69
  - `illustration` — detect insertion positions and author captions per
70
70
  [references/illustration-positions.md](references/illustration-positions.md);
71
71
  the chosen anchors cross as `metadata.positions`, one image per anchor.
72
- 3. Resolve the style: `--style`, else the preference `image.style`, else the format's
73
- `defaultStyle`. Without an explicit choice the skill may propose an auto-detected
74
- style — taste, this skill's — shown in the preview for approval.
72
+ 3. Resolve the visual direction before locking the style: `--style`, else the preference `image.style`, else the format's
73
+ `defaultStyle`. Use each preset's `description` and `bestFor` as routing evidence. If the direction is unclear,
74
+ offer **two or three visibly different styles** with one-sentence tradeoffs — do not force a weak third — and wait
75
+ for the user's choice before writing a long prompt. Commit to **one primary style**; never blend style presets or
76
+ mixed reference bundles automatically. Explicit user constraints (subject, aspect ratio, text, people, brand,
77
+ forbidden content) override preset defaults. When the direction is clear or the user delegates the choice, the
78
+ skill may auto-detect one style — taste, this skill's — shown in the preview for approval.
75
79
  4. Resolve the provider and model per Preference chain; the credential and
76
80
  reference-image facts per provider live in
77
81
  [references/providers.md](references/providers.md).
@@ -18,6 +18,32 @@ are read by `invoke.ts` at spawn, never by this skill.
18
18
  `--provider` outranks it.
19
19
  - **`codex-cli` is never auto-selected.** Its readiness (the `codex` CLI on
20
20
  PATH with an active login) is not env-expressible; pin it explicitly.
21
+ - **`h3-local` is never auto-selected either.** It drives Robin's local Apple
22
+ Silicon MLX runtime through `h3gen.sh`, and one render costs minutes of wall
23
+ time (3 min floor, ~7 min for 1024², up to ~28 min for a two-reference edit).
24
+ Pin it with `--provider h3-local`; the cloud defaults stay until the K2
25
+ rollout gates pass. H3 has no native negative-prompt parameter, so a style's
26
+ `negative` travels as the composed `avoid: …` segment like every other
27
+ provider; seeds cannot be set (the wrapper's default 42 applies); and only
28
+ multiples of 32 in 256–4096 are accepted per edge — every other preset falls
29
+ back to an aspect-only canvas (0379).
30
+ - **Running or verifying it locally.** `H3_IMAGE_MLX_BIN` can live in
31
+ `plugins.generations.image-gen.env` in `~/.config/kk/config.yaml`, so no shell
32
+ export is needed. `KK_IMAGE_DRY_RUN=1` proves prompt composition and provider
33
+ selection in about a second; one real `free` render is ~6 min because model
34
+ load dominates (a smaller canvas saves nothing). `scripts/gen-samples.ts` and
35
+ `scripts/eval-style-presets.ts` both accept `--provider h3-local` (the model
36
+ defaults to `h3`) and need `--concurrency 1` — three concurrent model loads
37
+ thrash a 16 GB machine. A reference edit costs ~28 min: never use one as a
38
+ smoke test.
39
+ - **H3 paints prompt tags as text unless the style declares a `negative`.** Same
40
+ subject, canvas and format at 1024²: with `editorial` (no `negative`) the model
41
+ rendered "8K, high-quality, masterpiece…" as gibberish lettering in the frame;
42
+ with `daily-news` (whose `avoid: text, letters, words, …` segment K3 now
43
+ appends) the identical request came back clean. When rendering locally, use a
44
+ style that declares `negative` (`daily-news`, `quasi-news-podcast`,
45
+ `xhs-knowledge`, `clean-webapp-ui`) or add one — never compare a local sample
46
+ against a cloud one from a style that leaves text unconstrained.
21
47
  - **Reference images** ride `--ref` only when `supportsReferenceImages(model)`
22
48
  is true for the resolved model — a substring test over the registry's
23
49
  `refModels` fragments (no `refModels` = every model; empty list = none).
@@ -33,6 +59,7 @@ are read by `invoke.ts` at spawn, never by this skill.
33
59
  | codex-cli | not env-expressible — `codex` CLI + login | `codex-image-gen` | never auto-selected |
34
60
  | dashscope | `DASHSCOPE_API_KEY` | `qwen-image-2.0-pro` | only `wan2.7` models |
35
61
  | google | `GOOGLE_API_KEY` or `GEMINI_API_KEY` | `gemini-3-pro-image` | the gemini image models (`gemini-3-pro-image`, `*-flash-image`, previews) |
62
+ | h3-local | `H3_IMAGE_MLX_BIN` (path to the local `h3gen.sh`) | `h3` | yes (up to 16, `<Picture N>` in prompt order) — never auto-selected |
36
63
  | jimeng | `JIMENG_ACCESS_KEY_ID` **and** `JIMENG_SECRET_ACCESS_KEY` (both halves) | `jimeng_t2i_v40` | yes |
37
64
  | minimax | `MINIMAX_API_KEY` | `image-01` | yes (jpg/png <10MB, subject reference) |
38
65
  | openai | `OPENAI_API_KEY` | `gpt-image-2` | `gpt-image` models |
@@ -52,7 +52,7 @@ enhancement.** Field-by-field:
52
52
  | `typography` | no | Only when the image evidences it. Omit rather than guess. |
53
53
  | `visualElements` | no | Array of strings naming recurring visual devices (borders, banding, grain, iconography). Only what the image shows. |
54
54
  | `bestFor` | no | The content types this look suits. Inferred from the image's own subject matter. |
55
- | `negative` | no | What this look must avoid — inferred from what is conspicuously absent. |
55
+ | `negative` | no | What this look must avoid — inferred from what is conspicuously absent. Rendered as one `avoid: …` segment after `modifiers` in the composed provider prompt (K3). |
56
56
  | `source` | yes for extraction | `kind: extracted`, `refImages` = the absolute input paths **in the order given**, `extractedAt` = ISO-8601 timestamp, `confidence` = the judgement below. |
57
57
 
58
58
  ### The `confidence` decision rule (human-judged, not computed)
@@ -44,10 +44,12 @@ headed login, then verify reuse read-only:
44
44
 
45
45
  ```bash
46
46
  kk bot login xhs # headed; sign in once in the window (adapter-verified)
47
- bun plugins/publishings/xhs-pub/src/profile-check.ts check # headless; exit 0 = session verified (underlying probe)
47
+ bun plugins/publishings/xhs-pub/src/profile-check.ts check # offline: reads the recorded expiry, opens no browser; exit 0 = no known refusal
48
48
  ```
49
49
 
50
- `check` never signs in — with no saved profile it refuses (exit 1) instead of reporting success.
50
+ `check` never signs in and never opens a browser (ADR-025 amendment 2026-11-13) — an absent or
51
+ expired profile refuses (exit 1). The recorded expiry is an estimate; `check --headed` runs the
52
+ real readiness probe and draws on the 2 h check budget.
51
53
  Overrides: `--profile <dir>`, `--timeout <ms>`; env fallback `XHS_PROFILE_DIR` / `KK_BROWSER_PROFILE_DIR`.
52
54
 
53
55
  **ADR-025 (2026-09-28, after an XHS warning about automated activity).** Publish now runs this same
@@ -106,3 +108,14 @@ the confirmed live status; otherwise fail naming the switch.
106
108
  | weibo-pub | none — its session lives in the browser profile (`WEIBO_PROFILE_DIR` overrides the dir; tier: `--profile` > `WEIBO_PROFILE_DIR` > `KK_BROWSER_PROFILE_DIR` > `~/.config/kk/browser-profiles/weibo`) |
107
109
 
108
110
  Missing env → plugin exit 1, `Result.ok false`, error names the variable.
111
+
112
+ ## Authoring or repairing a browser rail
113
+
114
+ Do not guess a selector. A browser rail (`plugins/publishings/<plugin>/src/*rail*.ts`,
115
+ `*flow*.ts`) is measured: `kk bot record <bot>` → `kk bot replay <bot> <transcript>` →
116
+ `kk bot codegen <transcript> --plugin <plugin> --operation <op>`, then promote by hand. The receipt
117
+ must come from the recorded submit response, and the rail carries a `// transcript:` header (the
118
+ `rail-transcript-header` rule enforces it). The playbook is
119
+ `plugins/kk/skills/web-automation/SKILL.md` § Scenario E; the contract is
120
+ `docs/design/kk-bot-record-codegen.md`. This skill stays transport-free — it shells these verbs, it
121
+ does not own them.