@gobing-ai/knowledge-kit 0.1.20 → 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 (115) 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 +1279 -261
  4. package/dist/board/itc/index.js +1 -0
  5. package/dist/index.js +13893 -8995
  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/music-gen/README.md +277 -0
  13. package/plugins/generations/music-gen/dist/index.js +23544 -0
  14. package/plugins/generations/music-gen/package.json +24 -0
  15. package/plugins/generations/music-gen/plugin.json +23 -0
  16. package/plugins/generations/music-gen/presets/SOURCE.md +39 -0
  17. package/plugins/generations/music-gen/presets/formats/clip.yaml +21 -0
  18. package/plugins/generations/music-gen/presets/formats/jingle.yaml +22 -0
  19. package/plugins/generations/music-gen/presets/formats/loop.yaml +21 -0
  20. package/plugins/generations/music-gen/presets/formats/song.yaml +31 -0
  21. package/plugins/generations/music-gen/presets/formats/underscore.yaml +22 -0
  22. package/plugins/generations/music-gen/presets/themes/ambient-tech.yaml +30 -0
  23. package/plugins/generations/music-gen/presets/themes/cinematic.yaml +30 -0
  24. package/plugins/generations/music-gen/presets/themes/lofi.yaml +30 -0
  25. package/plugins/generations/music-gen/presets/themes/synthwave.yaml +30 -0
  26. package/plugins/generations/music-gen/scripts/gen-preset-index.ts +181 -0
  27. package/plugins/generations/music-gen/scripts/resolve-preset.ts +64 -0
  28. package/plugins/generations/music-gen/src/adapter/index.ts +35 -0
  29. package/plugins/generations/music-gen/src/adapter/instance.ts +904 -0
  30. package/plugins/generations/music-gen/src/adapter/offline.ts +124 -0
  31. package/plugins/generations/music-gen/src/artifact.ts +223 -0
  32. package/plugins/generations/music-gen/src/audio/checks.ts +618 -0
  33. package/plugins/generations/music-gen/src/audio/master.ts +267 -0
  34. package/plugins/generations/music-gen/src/audio/measure.ts +507 -0
  35. package/plugins/generations/music-gen/src/audio/profile.ts +131 -0
  36. package/plugins/generations/music-gen/src/audio.ts +122 -0
  37. package/plugins/generations/music-gen/src/brief.ts +191 -0
  38. package/plugins/generations/music-gen/src/config.ts +451 -0
  39. package/plugins/generations/music-gen/src/content.ts +199 -0
  40. package/plugins/generations/music-gen/src/digest.ts +100 -0
  41. package/plugins/generations/music-gen/src/index.ts +147 -0
  42. package/plugins/generations/music-gen/src/job.ts +131 -0
  43. package/plugins/generations/music-gen/src/plugin.ts +371 -0
  44. package/plugins/generations/music-gen/src/presets.ts +918 -0
  45. package/plugins/generations/music-gen/src/render.ts +87 -0
  46. package/plugins/generations/music-gen/src/request.ts +102 -0
  47. package/plugins/generations/music-gen/src/spend.ts +495 -0
  48. package/plugins/generations/music-gen/tsconfig.json +8 -0
  49. package/plugins/kk/plugin.json +1 -1
  50. package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +2 -1
  51. package/plugins/kk/scripts/cover-compositor.ts +380 -32
  52. package/plugins/kk/scripts/daily-cover-mock.ts +40 -3
  53. package/plugins/kk/scripts/daily-stages.ts +659 -20
  54. package/plugins/kk/scripts/episode-identity.ts +180 -0
  55. package/plugins/kk/scripts/kk-workflow-stages.ts +37 -1
  56. package/plugins/kk/scripts/music-stages.ts +624 -0
  57. package/plugins/kk/scripts/news-editorial-ledger.ts +906 -0
  58. package/plugins/kk/scripts/source-citation.ts +187 -0
  59. package/plugins/kk/scripts/topic-selection-attempts.ts +446 -0
  60. package/plugins/kk/scripts/topic-selection-calibration.ts +161 -0
  61. package/plugins/kk/skills/content-judge/SKILL.md +11 -6
  62. package/plugins/kk/skills/content-judge/references/music-quality-rubric.md +147 -0
  63. package/plugins/kk/skills/content-judge/references/rubrics.md +15 -0
  64. package/plugins/kk/skills/content-safety/SKILL.md +12 -0
  65. package/plugins/kk/skills/music-authoring/SKILL.md +276 -0
  66. package/plugins/kk/skills/music-authoring/references/judge-input.md +117 -0
  67. package/plugins/kk/skills/news-editorial/SKILL.md +102 -15
  68. package/plugins/kk/skills/news-editorial/references/selection.md +4 -0
  69. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +58 -11
  70. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +8 -8
  71. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +7 -7
  72. package/plugins/kk/workflows/kk-music.yaml +328 -0
  73. package/plugins/kk/workflows/kk-news-generate.yaml +58 -3
  74. package/plugins/publishings/bilibili-pub/dist/index.js +11 -1
  75. package/plugins/publishings/bilibili-pub/dist/profile-check.js +11 -1
  76. package/plugins/publishings/cnblogs-pub/dist/index.js +11 -1
  77. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +11 -1
  78. package/plugins/publishings/csdn-pub/dist/index.js +11 -1
  79. package/plugins/publishings/csdn-pub/dist/profile-check.js +11 -1
  80. package/plugins/publishings/infoq-pub/dist/index.js +11 -1
  81. package/plugins/publishings/infoq-pub/dist/profile-check.js +11 -1
  82. package/plugins/publishings/jike-pub/dist/index.js +11 -1
  83. package/plugins/publishings/jike-pub/dist/profile-check.js +11 -1
  84. package/plugins/publishings/juejin-pub/dist/index.js +11 -1
  85. package/plugins/publishings/juejin-pub/dist/profile-check.js +11 -1
  86. package/plugins/publishings/linkedin-pub/dist/index.js +11 -1
  87. package/plugins/publishings/linkedin-pub/dist/profile-check.js +11 -1
  88. package/plugins/publishings/podcast-pub/dist/index.js +586 -20
  89. package/plugins/publishings/podcast-pub/src/corrections.ts +509 -0
  90. package/plugins/publishings/podcast-pub/src/index.ts +257 -5
  91. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +240 -0
  92. package/plugins/publishings/podcast-pub/src/show-notes.ts +69 -13
  93. package/plugins/publishings/shipinhao-pub/dist/index.js +59 -8
  94. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +11 -1
  95. package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +105 -6
  96. package/plugins/publishings/sspai-pub/dist/index.js +11 -1
  97. package/plugins/publishings/sspai-pub/dist/profile-check.js +11 -1
  98. package/plugins/publishings/substack-pub/dist/index.js +11 -1
  99. package/plugins/publishings/substack-pub/dist/profile-check.js +11 -1
  100. package/plugins/publishings/surfdash-pub/dist/index.js +72 -20
  101. package/plugins/publishings/surfdash-pub/src/digest-check.ts +7 -3
  102. package/plugins/publishings/surfdash-pub/src/index.ts +100 -17
  103. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +3 -1
  104. package/plugins/publishings/threads-pub/dist/index.js +11 -1
  105. package/plugins/publishings/threads-pub/dist/profile-check.js +11 -1
  106. package/plugins/publishings/wechatmp-pub/dist/index.js +11 -1
  107. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +11 -1
  108. package/plugins/publishings/weibo-pub/dist/index.js +11 -1
  109. package/plugins/publishings/weibo-pub/dist/profile-check.js +11 -1
  110. package/plugins/publishings/x-pub/dist/index.js +11 -1
  111. package/plugins/publishings/x-pub/dist/profile-check.js +11 -1
  112. package/plugins/publishings/xhs-pub/dist/index.js +11 -1
  113. package/plugins/publishings/xhs-pub/dist/profile-check.js +11 -1
  114. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +11 -1
  115. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +11 -1
@@ -12609,9 +12609,8 @@ function checkDigestFrontmatter(markdown, locale) {
12609
12609
  } else {
12610
12610
  const rest = match[2] ?? "";
12611
12611
  const heads = locale === "en" ? rest.split(", ") : rest.split("\u3001");
12612
- const seps = locale === "en" ? (rest.match(/, /g) ?? []).length : (rest.match(/\u3001/g) ?? []).length;
12613
- if (seps !== 1 || heads.some((head) => head.trim() === "")) {
12614
- problems.push(`title: expected exactly two non-empty headlines joined "${listSep}", got "${rest}"`);
12612
+ if (heads.length < 1 || heads.length > 2 || heads.some((head) => head.trim() === "")) {
12613
+ problems.push(`title: expected one or two non-empty headlines joined "${listSep}", got ${heads.length} in "${rest}"`);
12615
12614
  }
12616
12615
  }
12617
12616
  const seoTitle = `${title} | Surfing`;
@@ -12705,7 +12704,7 @@ function parseTitleHeadlines(title, locale) {
12705
12704
  if (!match?.[2])
12706
12705
  return;
12707
12706
  const heads = match[2].split(listSep).map((head) => head.trim());
12708
- if (heads.length < 2 || heads.some((head) => head === ""))
12707
+ if (heads.length < 1 || heads.length > 2 || heads.some((head) => head === ""))
12709
12708
  return;
12710
12709
  return heads;
12711
12710
  }
@@ -13615,6 +13614,49 @@ function resolvePreparedPost(options) {
13615
13614
  identity: identity.value
13616
13615
  };
13617
13616
  }
13617
+ var LOCAL_DRAFTS = ["en", "ja"];
13618
+ function readLocaleDrafts(content) {
13619
+ const drafts = {};
13620
+ const surfdash = content.metadata?.surfdash;
13621
+ if (typeof surfdash !== "object" || surfdash === null)
13622
+ return drafts;
13623
+ const locales = surfdash.locales;
13624
+ if (typeof locales !== "object" || locales === null)
13625
+ return drafts;
13626
+ for (const locale of LOCAL_DRAFTS) {
13627
+ const entry = locales[locale];
13628
+ if (typeof entry !== "object" || entry === null)
13629
+ continue;
13630
+ const { title, body } = entry;
13631
+ if (typeof title !== "string" || title.trim() === "")
13632
+ continue;
13633
+ if (typeof body !== "string" || body.trim() === "")
13634
+ continue;
13635
+ drafts[locale] = { title, body };
13636
+ }
13637
+ return drafts;
13638
+ }
13639
+ async function mintLocalePost(options) {
13640
+ const filePath = join2(options.postDir, "index.md");
13641
+ if (readRefinedSnapshot(filePath) !== undefined) {
13642
+ echoError(`surfdash-pub: keeping existing refined post at ${filePath} (not re-minting)`);
13643
+ return;
13644
+ }
13645
+ await createNodeFileSystem().ensureDir(options.postDir);
13646
+ let imageFrontmatter;
13647
+ if (options.coverPath !== undefined) {
13648
+ const assetsDir = join2(options.postDir, "assets");
13649
+ await createNodeFileSystem().ensureDir(assetsDir);
13650
+ const coverName = `cover${extname(options.coverPath).toLowerCase()}`;
13651
+ await copyFile(options.coverPath, join2(assetsDir, coverName));
13652
+ imageFrontmatter = `./assets/${coverName}`;
13653
+ }
13654
+ const markdown = mapContentToSurfingMarkdown(options.content, {
13655
+ image: imageFrontmatter,
13656
+ publishDate: options.publishDate
13657
+ });
13658
+ await createNodeFileSystem().writeFile(filePath, markdown);
13659
+ }
13618
13660
  async function preparePost(payload) {
13619
13661
  const surfdashRoot = resolveSurfdashRoot();
13620
13662
  if (!surfdashRoot) {
@@ -13654,25 +13696,35 @@ async function preparePost(payload) {
13654
13696
  if (isDigestContent(payload.content) && typeof coverPath !== "string") {
13655
13697
  return { ok: false, result: failNotSent("digest post has no cover image (metadata.coverImage)") };
13656
13698
  }
13699
+ const drafts = readLocaleDrafts(payload.content);
13700
+ if (isDigestContent(payload.content)) {
13701
+ const missing = LOCAL_DRAFTS.filter((locale) => drafts[locale] === undefined);
13702
+ if (missing.length > 0) {
13703
+ return {
13704
+ ok: false,
13705
+ result: failNotSent(`digest post is missing metadata.surfdash.locales for ${missing.join(", ")} \u2014 the site refuses a digest with a missing locale file; re-run the localize step before publishing`)
13706
+ };
13707
+ }
13708
+ }
13657
13709
  const filePath = join2(postDir, "index.md");
13710
+ const publishDate = runDate ? `${runDate.slice(0, 4)}-${runDate.slice(4, 6)}-${runDate.slice(6, 8)}` : undefined;
13711
+ const cover = typeof coverPath === "string" ? coverPath : undefined;
13658
13712
  try {
13659
- if (readRefinedSnapshot(filePath) === undefined) {
13660
- await createNodeFileSystem().ensureDir(postDir);
13661
- let imageFrontmatter;
13662
- if (typeof coverPath === "string") {
13663
- const assetsDir = join2(postDir, "assets");
13664
- await createNodeFileSystem().ensureDir(assetsDir);
13665
- const coverName = `cover${extname(coverPath).toLowerCase()}`;
13666
- await copyFile(coverPath, join2(assetsDir, coverName));
13667
- imageFrontmatter = `./assets/${coverName}`;
13668
- }
13669
- const markdown = mapContentToSurfingMarkdown(payload.content, {
13670
- image: imageFrontmatter,
13671
- publishDate: runDate ? `${runDate.slice(0, 4)}-${runDate.slice(4, 6)}-${runDate.slice(6, 8)}` : undefined
13713
+ await mintLocalePost({ postDir, content: payload.content, coverPath: cover, publishDate });
13714
+ for (const locale of LOCAL_DRAFTS) {
13715
+ const draft = drafts[locale];
13716
+ if (draft === undefined)
13717
+ continue;
13718
+ const siblingDir = resolve(articlesRoot, locale, slug);
13719
+ if (dirname4(resolve(siblingDir)) !== resolve(articlesRoot, locale)) {
13720
+ return { ok: false, result: failNotSent(`post path escapes ${articlesRoot}`) };
13721
+ }
13722
+ await mintLocalePost({
13723
+ postDir: siblingDir,
13724
+ content: { ...payload.content, title: draft.title, body: draft.body },
13725
+ coverPath: cover,
13726
+ publishDate
13672
13727
  });
13673
- await createNodeFileSystem().writeFile(filePath, markdown);
13674
- } else {
13675
- echoError(`surfdash-pub: keeping existing refined post at ${filePath} (not re-minting)`);
13676
13728
  }
13677
13729
  } catch (err) {
13678
13730
  return {
@@ -222,9 +222,13 @@ export function checkDigestFrontmatter(markdown: string, locale: DigestLocale):
222
222
  } else {
223
223
  const rest = match[2] ?? '';
224
224
  const heads = locale === 'en' ? rest.split(', ') : rest.split('、');
225
- const seps = locale === 'en' ? (rest.match(/, /g) ?? []).length : (rest.match(/、/g) ?? []).length;
226
- if (seps !== 1 || heads.some((head) => head.trim() === '')) {
227
- problems.push(`title: expected exactly two non-empty headlines joined "${listSep}", got "${rest}"`);
225
+ // 1..2, not "exactly 2": the site's `seo retitle` legitimately collapses a title to one
226
+ // headline when two do not fit its SEO budget (surfdash `check-digest.ts`), and that
227
+ // budget verdict is the site's (ADR-008). kk mirrors only the structural range.
228
+ if (heads.length < 1 || heads.length > 2 || heads.some((head) => head.trim() === '')) {
229
+ problems.push(
230
+ `title: expected one or two non-empty headlines joined "${listSep}", got ${heads.length} in "${rest}"`,
231
+ );
228
232
  }
229
233
  }
230
234
  const seoTitle = `${title} | Surfing`;
@@ -1271,6 +1271,72 @@ function resolvePreparedPost(
1271
1271
 
1272
1272
  type PrepareOutcome = { ok: true; prepared: PreparedPost } | { ok: false; result: Result };
1273
1273
 
1274
+ /** The non-primary locales a digest post carries (`metadata.surfdash.locales`); zh is the primary. */
1275
+ const LOCAL_DRAFTS = ['en', 'ja'] as const;
1276
+
1277
+ /** One localized sibling's authored text, as the workflow's `localize` step delivers it. */
1278
+ interface LocaleDraft {
1279
+ title: string;
1280
+ body: string;
1281
+ }
1282
+
1283
+ /**
1284
+ * Reads `metadata.surfdash.locales.{en,ja}` off the article Content (0409 Q&A: the payload shape the
1285
+ * localize step and the article variant agree on). A blank title or body is not a locale: an
1286
+ * untranslated file must read as missing, so the digest refusal fires instead of publishing zh
1287
+ * text under `/en/` or `/ja/`.
1288
+ */
1289
+ function readLocaleDrafts(content: Content): Partial<Record<(typeof LOCAL_DRAFTS)[number], LocaleDraft>> {
1290
+ const drafts: Partial<Record<(typeof LOCAL_DRAFTS)[number], LocaleDraft>> = {};
1291
+ const surfdash = content.metadata?.surfdash;
1292
+ if (typeof surfdash !== 'object' || surfdash === null) return drafts;
1293
+ const locales = (surfdash as Record<string, unknown>).locales;
1294
+ if (typeof locales !== 'object' || locales === null) return drafts;
1295
+ for (const locale of LOCAL_DRAFTS) {
1296
+ const entry = (locales as Record<string, unknown>)[locale];
1297
+ if (typeof entry !== 'object' || entry === null) continue;
1298
+ const { title, body } = entry as Record<string, unknown>;
1299
+ if (typeof title !== 'string' || title.trim() === '') continue;
1300
+ if (typeof body !== 'string' || body.trim() === '') continue;
1301
+ drafts[locale] = { title, body };
1302
+ }
1303
+ return drafts;
1304
+ }
1305
+
1306
+ /**
1307
+ * Mints one locale's `index.md` (frontmatter + body) and copies the cover into its `assets/`.
1308
+ *
1309
+ * A file the site's own refine step already marked is not ours to clobber: re-minting replaces the
1310
+ * refined frontmatter (`refined`, `seo_title`, …) with generator defaults and flips a published day
1311
+ * back to a draft — so a refined file is kept and reused (2026-11-05 tier-0 rerun).
1312
+ */
1313
+ async function mintLocalePost(options: {
1314
+ postDir: string;
1315
+ content: Content;
1316
+ coverPath?: string;
1317
+ publishDate?: string;
1318
+ }): Promise<void> {
1319
+ const filePath = join(options.postDir, 'index.md');
1320
+ if (readRefinedSnapshot(filePath) !== undefined) {
1321
+ echoError(`surfdash-pub: keeping existing refined post at ${filePath} (not re-minting)`);
1322
+ return;
1323
+ }
1324
+ await createNodeFileSystem().ensureDir(options.postDir);
1325
+ let imageFrontmatter: string | undefined;
1326
+ if (options.coverPath !== undefined) {
1327
+ const assetsDir = join(options.postDir, 'assets');
1328
+ await createNodeFileSystem().ensureDir(assetsDir);
1329
+ const coverName = `cover${extname(options.coverPath).toLowerCase()}`;
1330
+ await copyFile(options.coverPath, join(assetsDir, coverName));
1331
+ imageFrontmatter = `./assets/${coverName}`;
1332
+ }
1333
+ const markdown = mapContentToSurfingMarkdown(options.content, {
1334
+ image: imageFrontmatter,
1335
+ publishDate: options.publishDate,
1336
+ });
1337
+ await createNodeFileSystem().writeFile(filePath, markdown);
1338
+ }
1339
+
1274
1340
  /**
1275
1341
  * Materializes the local post without invoking the external publishing FSM.
1276
1342
  *
@@ -1328,31 +1394,48 @@ async function preparePost(payload: PublishTransportPayload): Promise<PrepareOut
1328
1394
  return { ok: false, result: failNotSent('digest post has no cover image (metadata.coverImage)') };
1329
1395
  }
1330
1396
 
1397
+ // 0409 R2: the site requires the full locale set for a digest before it will sync
1398
+ // (`publish-orchestrator.ts` `discoverLocaleFiles` + the `sub-category:ai-daily` guard), so a
1399
+ // missing translation is refused here with effect none — never as the site's opaque
1400
+ // "missing locale file(s)" failure after the spawn.
1401
+ const drafts = readLocaleDrafts(payload.content);
1402
+ if (isDigestContent(payload.content)) {
1403
+ const missing = LOCAL_DRAFTS.filter((locale) => drafts[locale] === undefined);
1404
+ if (missing.length > 0) {
1405
+ return {
1406
+ ok: false,
1407
+ result: failNotSent(
1408
+ `digest post is missing metadata.surfdash.locales for ${missing.join(', ')} — the site refuses a digest with a missing locale file; re-run the localize step before publishing`,
1409
+ ),
1410
+ };
1411
+ }
1412
+ }
1413
+
1331
1414
  const filePath = join(postDir, 'index.md');
1415
+ const publishDate = runDate ? `${runDate.slice(0, 4)}-${runDate.slice(4, 6)}-${runDate.slice(6, 8)}` : undefined;
1416
+ const cover = typeof coverPath === 'string' ? coverPath : undefined;
1332
1417
  try {
1333
1418
  // A post the site's own refine step already marked is not ours to clobber: re-minting it
1334
1419
  // replaces the refined canonical frontmatter (refine owns `refined`, `seo_title`, …) with
1335
1420
  // generator defaults and flips an already-published day back to a draft. Keep the file and
1336
1421
  // reuse it; only genuinely fresh days (no marker) get minted (2026-11-05 tier-0 rerun).
1337
- if (readRefinedSnapshot(filePath) === undefined) {
1338
- await createNodeFileSystem().ensureDir(postDir);
1339
- let imageFrontmatter: string | undefined;
1340
- if (typeof coverPath === 'string') {
1341
- const assetsDir = join(postDir, 'assets');
1342
- await createNodeFileSystem().ensureDir(assetsDir);
1343
- const coverName = `cover${extname(coverPath).toLowerCase()}`;
1344
- await copyFile(coverPath, join(assetsDir, coverName));
1345
- imageFrontmatter = `./assets/${coverName}`;
1422
+ await mintLocalePost({ postDir, content: payload.content, coverPath: cover, publishDate });
1423
+ for (const locale of LOCAL_DRAFTS) {
1424
+ const draft = drafts[locale];
1425
+ if (draft === undefined) continue;
1426
+ const siblingDir = resolve(articlesRoot, locale, slug);
1427
+ if (dirname(resolve(siblingDir)) !== resolve(articlesRoot, locale)) {
1428
+ return { ok: false, result: failNotSent(`post path escapes ${articlesRoot}`) };
1346
1429
  }
1347
- const markdown = mapContentToSurfingMarkdown(payload.content, {
1348
- image: imageFrontmatter,
1349
- publishDate: runDate
1350
- ? `${runDate.slice(0, 4)}-${runDate.slice(4, 6)}-${runDate.slice(6, 8)}`
1351
- : undefined,
1430
+ // The zh Body and title are replaced by the translation; the frontmatter fields the
1431
+ // site owns (refined, seo_title, …) are rewritten by its own refine/retitle, exactly as
1432
+ // for zh — so a locale file is the same Content shape with a localized title/body.
1433
+ await mintLocalePost({
1434
+ postDir: siblingDir,
1435
+ content: { ...payload.content, title: draft.title, body: draft.body },
1436
+ coverPath: cover,
1437
+ publishDate,
1352
1438
  });
1353
- await createNodeFileSystem().writeFile(filePath, markdown);
1354
- } else {
1355
- echoError(`surfdash-pub: keeping existing refined post at ${filePath} (not re-minting)`);
1356
1439
  }
1357
1440
  } catch (err: unknown) {
1358
1441
  return {
@@ -68,7 +68,9 @@ function parseTitleHeadlines(title: string, locale: PatchLocale): string[] | und
68
68
  const match = title.match(new RegExp(`^${escapeRe(series)} · (\\d{4}-\\d{2}-\\d{2})${escapeRe(titleSep)}(.+)$`));
69
69
  if (!match?.[2]) return undefined;
70
70
  const heads = match[2].split(listSep).map((head) => head.trim());
71
- if (heads.length < 2 || heads.some((head) => head === '')) return undefined;
71
+ // 1..2 structural headlines: the site may collapse a title to one when two do not fit its
72
+ // SEO budget, so a single headline is a valid derivation source (task 0408).
73
+ if (heads.length < 1 || heads.length > 2 || heads.some((head) => head === '')) return undefined;
72
74
  return heads;
73
75
  }
74
76
 
@@ -20778,6 +20778,9 @@ async function ensureProfileDir2(profileDir, headless) {
20778
20778
  var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20779
20779
  // ../../packages/publish-harness/src/browser.ts
20780
20780
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20781
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20782
+ var MIN_PASS_BUDGET_MS = 5000;
20783
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20781
20784
  var DEFAULT_STEP_TIMEOUT_MS = 30000;
20782
20785
  var DEFAULT_POLL_MS = 500;
20783
20786
  var ATTACH_POLL_MS = 100;
@@ -20902,14 +20905,21 @@ async function checkChannelSession(config, opts) {
20902
20905
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20903
20906
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20904
20907
  let lastDetail = `${config.channel} readiness was never probed`;
20908
+ const deadline = Date.now() + timeoutMs;
20909
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20910
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20911
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20905
20912
  for (const headless of passes) {
20913
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20914
+ if (remainingMs < minPassMs)
20915
+ break;
20906
20916
  try {
20907
20917
  await withProfilePage({
20908
20918
  profileDir: opts.profileDir,
20909
20919
  headless,
20910
20920
  url: config.homeUrl,
20911
20921
  isAuthenticated: config.isAuthenticated,
20912
- timeoutMs,
20922
+ timeoutMs: remainingMs,
20913
20923
  launcher: opts.launcher ?? kkBrowserLauncher
20914
20924
  }, async () => true);
20915
20925
  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 {
@@ -20810,6 +20810,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20810
20810
  var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
20811
20811
  var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
20812
20812
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20813
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20814
+ var MIN_PASS_BUDGET_MS = 5000;
20815
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20813
20816
  var DEFAULT_STEP_TIMEOUT_MS = 30000;
20814
20817
  var DEFAULT_POLL_MS = 500;
20815
20818
  var ATTACH_POLL_MS = 100;
@@ -20934,14 +20937,21 @@ async function checkChannelSession(config, opts) {
20934
20937
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20935
20938
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20936
20939
  let lastDetail = `${config.channel} readiness was never probed`;
20940
+ const deadline = Date.now() + timeoutMs;
20941
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20942
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20943
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20937
20944
  for (const headless of passes) {
20945
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20946
+ if (remainingMs < minPassMs)
20947
+ break;
20938
20948
  try {
20939
20949
  await withProfilePage({
20940
20950
  profileDir: opts.profileDir,
20941
20951
  headless,
20942
20952
  url: config.homeUrl,
20943
20953
  isAuthenticated: config.isAuthenticated,
20944
- timeoutMs,
20954
+ timeoutMs: remainingMs,
20945
20955
  launcher: opts.launcher ?? kkBrowserLauncher
20946
20956
  }, async () => true);
20947
20957
  return {
@@ -20473,6 +20473,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20473
20473
  var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
20474
20474
  var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
20475
20475
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20476
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20477
+ var MIN_PASS_BUDGET_MS = 5000;
20478
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20476
20479
  var DEFAULT_POLL_MS = 500;
20477
20480
  function isInstantBrowserDeath(message) {
20478
20481
  return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
@@ -20595,14 +20598,21 @@ async function checkChannelSession(config, opts) {
20595
20598
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20596
20599
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20597
20600
  let lastDetail = `${config.channel} readiness was never probed`;
20601
+ const deadline = Date.now() + timeoutMs;
20602
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20603
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20604
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20598
20605
  for (const headless of passes) {
20606
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20607
+ if (remainingMs < minPassMs)
20608
+ break;
20599
20609
  try {
20600
20610
  await withProfilePage({
20601
20611
  profileDir: opts.profileDir,
20602
20612
  headless,
20603
20613
  url: config.homeUrl,
20604
20614
  isAuthenticated: config.isAuthenticated,
20605
- timeoutMs,
20615
+ timeoutMs: remainingMs,
20606
20616
  launcher: opts.launcher ?? kkBrowserLauncher
20607
20617
  }, async () => true);
20608
20618
  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 {
@@ -20801,6 +20801,9 @@ async function ensureProfileDir2(profileDir, headless) {
20801
20801
  var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20802
20802
  // ../../packages/publish-harness/src/browser.ts
20803
20803
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20804
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20805
+ var MIN_PASS_BUDGET_MS = 5000;
20806
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20804
20807
  var DEFAULT_STEP_TIMEOUT_MS = 30000;
20805
20808
  var DEFAULT_POLL_MS = 500;
20806
20809
  var ATTACH_POLL_MS = 100;
@@ -20925,14 +20928,21 @@ async function checkChannelSession(config, opts) {
20925
20928
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20926
20929
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20927
20930
  let lastDetail = `${config.channel} readiness was never probed`;
20931
+ const deadline = Date.now() + timeoutMs;
20932
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20933
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20934
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20928
20935
  for (const headless of passes) {
20936
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20937
+ if (remainingMs < minPassMs)
20938
+ break;
20929
20939
  try {
20930
20940
  await withProfilePage({
20931
20941
  profileDir: opts.profileDir,
20932
20942
  headless,
20933
20943
  url: config.homeUrl,
20934
20944
  isAuthenticated: config.isAuthenticated,
20935
- timeoutMs,
20945
+ timeoutMs: remainingMs,
20936
20946
  launcher: opts.launcher ?? kkBrowserLauncher
20937
20947
  }, async () => true);
20938
20948
  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 {
@@ -20583,6 +20583,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20583
20583
  var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
20584
20584
  var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
20585
20585
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20586
+ var VERDICT_PRINT_MARGIN_MS = 2000;
20587
+ var MIN_PASS_BUDGET_MS = 5000;
20588
+ var PASS_LAUNCH_RESERVE_MS = 20000;
20586
20589
  var DEFAULT_POLL_MS = 500;
20587
20590
  function isInstantBrowserDeath(message) {
20588
20591
  return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
@@ -20705,14 +20708,21 @@ async function checkChannelSession(config, opts) {
20705
20708
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20706
20709
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20707
20710
  let lastDetail = `${config.channel} readiness was never probed`;
20711
+ const deadline = Date.now() + timeoutMs;
20712
+ const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
20713
+ const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
20714
+ const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
20708
20715
  for (const headless of passes) {
20716
+ const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
20717
+ if (remainingMs < minPassMs)
20718
+ break;
20709
20719
  try {
20710
20720
  await withProfilePage({
20711
20721
  profileDir: opts.profileDir,
20712
20722
  headless,
20713
20723
  url: config.homeUrl,
20714
20724
  isAuthenticated: config.isAuthenticated,
20715
- timeoutMs,
20725
+ timeoutMs: remainingMs,
20716
20726
  launcher: opts.launcher ?? kkBrowserLauncher
20717
20727
  }, async () => true);
20718
20728
  return {