@gobing-ai/knowledge-kit 0.1.29 → 0.1.30

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 (114) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/board/api.js +8724 -3861
  3. package/dist/board/collect/index.js +69 -1
  4. package/dist/board/daily-voice/index.js +474 -265
  5. package/dist/board/itc/index.js +69 -1
  6. package/dist/board/wiki/index.css +1305 -0
  7. package/dist/board/wiki/index.js +1621 -0
  8. package/dist/index.js +34689 -28532
  9. package/package.json +1 -1
  10. package/plugins/generations/content-gen/dist/index.js +14 -1
  11. package/plugins/generations/core-facts-gen/dist/index.js +14 -1
  12. package/plugins/generations/daily-article-gen/dist/index.js +14 -1
  13. package/plugins/generations/dailynews-gen/dist/index.js +14 -1
  14. package/plugins/generations/episode-plan-gen/dist/index.js +32 -2
  15. package/plugins/generations/episode-plan-gen/src/index.ts +19 -1
  16. package/plugins/generations/gemini-tts/dist/index.js +14 -1
  17. package/plugins/generations/image-gen/dist/index.js +14 -1
  18. package/plugins/generations/music-gen/dist/index.js +15 -2
  19. package/plugins/generations/news-report-gen/dist/index.js +14 -1
  20. package/plugins/generations/vibe-voice-tts/dist/index.js +14 -1
  21. package/plugins/generations/video-gen/README.md +245 -8
  22. package/plugins/generations/video-gen/dist/index.js +22447 -4763
  23. package/plugins/generations/video-gen/package.json +1 -0
  24. package/plugins/generations/video-gen/presets/formats/avatar.yaml +5 -0
  25. package/plugins/generations/video-gen/presets/formats/editorial.yaml +6 -0
  26. package/plugins/generations/video-gen/presets/formats/hybrid-pip.yaml +5 -0
  27. package/plugins/generations/video-gen/presets/styles/daily-ai.yaml +5 -0
  28. package/plugins/generations/video-gen/presets/styles/neutral.yaml +3 -0
  29. package/plugins/generations/video-gen/python/colab_comfyui_h3.py +322 -0
  30. package/plugins/generations/video-gen/python/comfyui-h3-i2v-api.json +47 -0
  31. package/plugins/generations/video-gen/python/comfyui-h3-models.json +32 -0
  32. package/plugins/generations/video-gen/python/comfyui_model_cache.py +388 -0
  33. package/plugins/generations/video-gen/python/drive_client.py +187 -0
  34. package/plugins/generations/video-gen/src/brief-cli.ts +65 -0
  35. package/plugins/generations/video-gen/src/brief.ts +464 -0
  36. package/plugins/generations/video-gen/src/ccu-ledger.ts +206 -3
  37. package/plugins/generations/video-gen/src/colab-runner.ts +346 -35
  38. package/plugins/generations/video-gen/src/index.ts +141 -109
  39. package/plugins/generations/video-gen/src/inputs.ts +162 -4
  40. package/plugins/generations/video-gen/src/layout.ts +33 -0
  41. package/plugins/generations/video-gen/src/props.ts +27 -3
  42. package/plugins/generations/video-gen/src/remotion/AvatarReel.tsx +17 -1
  43. package/plugins/generations/video-gen/src/remotion/EditorialReel.tsx +17 -1
  44. package/plugins/generations/video-gen/src/remotion/Root.tsx +2 -0
  45. package/plugins/generations/video-gen/src/remotion/engine.ts +3 -7
  46. package/plugins/generations/video-gen/src/render.ts +25 -0
  47. package/plugins/generations/video-gen/src/request.ts +150 -20
  48. package/plugins/generations/video-gen/src/visual-provider.ts +116 -3
  49. package/plugins/generations/voice-gen/dist/index.js +14 -1
  50. package/plugins/generations/voxcpm-tts/dist/index.js +14 -1
  51. package/plugins/ingestions/aihot-ingest/dist/index.js +14 -1
  52. package/plugins/ingestions/horizon-ingest/dist/index.js +14 -1
  53. package/plugins/ingestions/last30days-ingest/dist/index.js +14 -1
  54. package/plugins/ingestions/web-search/dist/index.js +14 -1
  55. package/plugins/kk/config.example.yaml +1 -1
  56. package/plugins/kk/mcp-tools.yaml +47 -0
  57. package/plugins/kk/plugin.json +1 -1
  58. package/plugins/kk/publish-presets/itc-surfdash-locales.json +42 -0
  59. package/plugins/kk/scripts/daily-stages.ts +87 -6
  60. package/plugins/kk/scripts/kk-workflow-stages.ts +64 -9
  61. package/plugins/kk/scripts/video-stages.ts +332 -0
  62. package/plugins/kk/scripts/wiki-normalize-audio.ts +354 -0
  63. package/plugins/kk/scripts/wiki-normalize-document.ts +495 -0
  64. package/plugins/kk/scripts/wiki-normalize-stages.ts +96 -0
  65. package/plugins/kk/scripts/wiki-stage-runtime.ts +39 -0
  66. package/plugins/kk/skills/news-editorial/SKILL.md +2 -1
  67. package/plugins/kk/workflows/kk-collect.yaml +10 -0
  68. package/plugins/kk/workflows/kk-news-generate.yaml +70 -8
  69. package/plugins/kk/workflows/kk-smart-seo.yaml +8 -0
  70. package/plugins/kk/workflows/kk-storm-research.yaml +10 -0
  71. package/plugins/kk/workflows/kk-video-generate.yaml +169 -0
  72. package/plugins/kk/workflows/kk-wiki-digest.yaml +49 -0
  73. package/plugins/publishings/bilibili-pub/dist/index.js +281 -268
  74. package/plugins/publishings/bilibili-pub/dist/profile-check.js +202 -0
  75. package/plugins/publishings/cnblogs-pub/dist/index.js +281 -268
  76. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +202 -0
  77. package/plugins/publishings/csdn-pub/dist/index.js +281 -268
  78. package/plugins/publishings/csdn-pub/dist/profile-check.js +216 -1
  79. package/plugins/publishings/emdash-pub/dist/index.js +33 -3
  80. package/plugins/publishings/infoq-pub/dist/index.js +281 -268
  81. package/plugins/publishings/infoq-pub/dist/profile-check.js +216 -1
  82. package/plugins/publishings/jike-pub/dist/index.js +281 -268
  83. package/plugins/publishings/jike-pub/dist/profile-check.js +216 -1
  84. package/plugins/publishings/juejin-pub/dist/index.js +281 -268
  85. package/plugins/publishings/juejin-pub/dist/profile-check.js +216 -1
  86. package/plugins/publishings/linkedin-pub/dist/index.js +281 -268
  87. package/plugins/publishings/linkedin-pub/dist/profile-check.js +216 -1
  88. package/plugins/publishings/medium-pub/dist/index.js +281 -268
  89. package/plugins/publishings/medium-pub/dist/profile-check.js +216 -1
  90. package/plugins/publishings/podcast-pub/dist/index.js +39 -9
  91. package/plugins/publishings/qiita-pub/dist/index.js +33 -3
  92. package/plugins/publishings/shipinhao-pub/dist/index.js +281 -268
  93. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +175 -0
  94. package/plugins/publishings/sspai-pub/dist/index.js +281 -268
  95. package/plugins/publishings/sspai-pub/dist/profile-check.js +202 -0
  96. package/plugins/publishings/substack-pub/dist/index.js +281 -268
  97. package/plugins/publishings/substack-pub/dist/profile-check.js +216 -1
  98. package/plugins/publishings/surfdash-pub/dist/index.js +99 -39
  99. package/plugins/publishings/surfdash-pub/plugin.json +54 -0
  100. package/plugins/publishings/surfdash-pub/src/index.ts +36 -5
  101. package/plugins/publishings/threads-pub/dist/index.js +281 -268
  102. package/plugins/publishings/threads-pub/dist/profile-check.js +216 -1
  103. package/plugins/publishings/wechatmp-pub/dist/index.js +665 -451
  104. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +215 -3
  105. package/plugins/publishings/weibo-pub/dist/index.js +281 -268
  106. package/plugins/publishings/weibo-pub/dist/profile-check.js +189 -1
  107. package/plugins/publishings/x-pub/dist/index.js +281 -268
  108. package/plugins/publishings/x-pub/dist/profile-check.js +216 -1
  109. package/plugins/publishings/xhs-pub/dist/index.js +281 -268
  110. package/plugins/publishings/xhs-pub/dist/profile-check.js +119 -1
  111. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +281 -268
  112. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +202 -0
  113. package/plugins/publishings/youtube-pub/dist/index.js +14 -1
  114. package/plugins/publishings/zenn-pub/dist/index.js +37 -7
@@ -20950,6 +20950,9 @@ function rename(from, to) {
20950
20950
  function chmod(path, mode) {
20951
20951
  chmodSync(path, mode);
20952
20952
  }
20953
+ function createExclusiveFile(path) {
20954
+ closeSync(openSync(path, "wx", 384));
20955
+ }
20953
20956
 
20954
20957
  // ../../packages/publish-harness/src/bot-transaction.ts
20955
20958
  import { homedir } from "os";
@@ -21197,8 +21200,18 @@ function sha256Hex(value) {
21197
21200
  }
21198
21201
 
21199
21202
  // ../../packages/publish-harness/src/bot.ts
21203
+ var BOT_SCHEMA_VERSION = 1;
21204
+ var BOT_METADATA_FILE = "bot.json";
21200
21205
  var DEFAULT_BOT_PROFILE_ROOT = join3(homedir3(), ".config", "kk", "browser-profiles");
21206
+ var ISO_DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/;
21201
21207
  var MAX_IDENTITY_LENGTH = 128;
21208
+ var CONTROL_CHARACTERS = /\p{Cc}/u;
21209
+ function isSessionFactDate(value) {
21210
+ return typeof value === "string" && ISO_DATE_TIME.test(value) && Number.isFinite(Date.parse(value));
21211
+ }
21212
+ function isSessionFactIdentity(value) {
21213
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_IDENTITY_LENGTH && !CONTROL_CHARACTERS.test(value);
21214
+ }
21202
21215
  function normalizeSessionIdentity(value) {
21203
21216
  if (typeof value !== "string")
21204
21217
  return;
@@ -21215,6 +21228,124 @@ class BotError extends Error {
21215
21228
  this.details = details;
21216
21229
  }
21217
21230
  }
21231
+ function isStoredDefaultUrl(value, allowQuery) {
21232
+ let url;
21233
+ try {
21234
+ url = new URL(value);
21235
+ } catch {
21236
+ return false;
21237
+ }
21238
+ if (url.protocol !== "http:" && url.protocol !== "https:")
21239
+ return false;
21240
+ if (url.username !== "" || url.password !== "")
21241
+ return false;
21242
+ if (url.hash !== "")
21243
+ return false;
21244
+ if (!allowQuery && url.search !== "")
21245
+ return false;
21246
+ const stored = `${url.origin}${url.pathname}${allowQuery ? url.search : ""}`;
21247
+ return stored === value;
21248
+ }
21249
+ function parseBotMetadata(raw, source = "bot metadata") {
21250
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
21251
+ throw new BotError("persistence", `${source}: expected a JSON object`);
21252
+ }
21253
+ const record = raw;
21254
+ if (record.schemaVersion !== BOT_SCHEMA_VERSION) {
21255
+ throw new BotError("persistence", `${source}: unsupported schemaVersion ${JSON.stringify(record.schemaVersion)}`);
21256
+ }
21257
+ const evidence = record.authenticationEvidence;
21258
+ if (evidence !== "operator-confirmed" && evidence !== "site-verified") {
21259
+ throw new BotError("persistence", `${source}: authenticationEvidence must be operator-confirmed|site-verified`);
21260
+ }
21261
+ let pluginName;
21262
+ if (record.pluginName !== undefined) {
21263
+ if (typeof record.pluginName !== "string" || record.pluginName.length === 0) {
21264
+ throw new BotError("persistence", `${source}: pluginName must be a non-empty string`);
21265
+ }
21266
+ pluginName = record.pluginName;
21267
+ }
21268
+ const allowQuery = pluginName !== undefined;
21269
+ if (typeof record.defaultUrl !== "string" || !isStoredDefaultUrl(record.defaultUrl, allowQuery)) {
21270
+ throw new BotError("persistence", `${source}: defaultUrl must be an http(s) origin+pathname` + (allowQuery ? " with at most a plugin-fixed query" : ""));
21271
+ }
21272
+ const metadata = {
21273
+ schemaVersion: BOT_SCHEMA_VERSION,
21274
+ defaultUrl: record.defaultUrl,
21275
+ authenticationEvidence: evidence
21276
+ };
21277
+ if (pluginName !== undefined) {
21278
+ metadata.pluginName = pluginName;
21279
+ }
21280
+ if (record.lastLoginAt !== undefined) {
21281
+ if (!isSessionFactDate(record.lastLoginAt)) {
21282
+ throw new BotError("persistence", `${source}: lastLoginAt must be an ISO 8601 date-time`);
21283
+ }
21284
+ metadata.lastLoginAt = record.lastLoginAt;
21285
+ }
21286
+ if (record.lastRefreshedAt !== undefined) {
21287
+ if (!isSessionFactDate(record.lastRefreshedAt)) {
21288
+ throw new BotError("persistence", `${source}: lastRefreshedAt must be an ISO 8601 date-time`);
21289
+ }
21290
+ metadata.lastRefreshedAt = record.lastRefreshedAt;
21291
+ }
21292
+ if (record.expiresAt !== undefined) {
21293
+ if (!isSessionFactDate(record.expiresAt)) {
21294
+ throw new BotError("persistence", `${source}: expiresAt must be an ISO 8601 date-time`);
21295
+ }
21296
+ metadata.expiresAt = record.expiresAt;
21297
+ }
21298
+ if (record.identity !== undefined) {
21299
+ if (!isSessionFactIdentity(record.identity)) {
21300
+ throw new BotError("persistence", `${source}: identity must be a non-empty string of at most 128 characters without control characters`);
21301
+ }
21302
+ metadata.identity = record.identity;
21303
+ }
21304
+ return metadata;
21305
+ }
21306
+ async function readBotMetadata(fileSystem, metadataPath) {
21307
+ if (!await fileSystem.exists(metadataPath))
21308
+ return null;
21309
+ let text;
21310
+ try {
21311
+ text = await fileSystem.readFile(metadataPath);
21312
+ } catch (error) {
21313
+ const detail = error instanceof Error ? error.message : String(error);
21314
+ throw new BotError("persistence", `${metadataPath}: cannot read bot metadata: ${detail}`);
21315
+ }
21316
+ let raw;
21317
+ try {
21318
+ raw = JSON.parse(text);
21319
+ } catch {
21320
+ throw new BotError("persistence", `${metadataPath}: corrupt bot metadata (not valid JSON)`);
21321
+ }
21322
+ return parseBotMetadata(raw, metadataPath);
21323
+ }
21324
+
21325
+ // ../../packages/publish-harness/src/session-state.ts
21326
+ import { randomUUID } from "crypto";
21327
+ function channelStorageStatePath(profileDir) {
21328
+ return `${profileDir}/storage-state.json`;
21329
+ }
21330
+ async function persistChannelSessionState(context, profileDir) {
21331
+ const target = channelStorageStatePath(profileDir);
21332
+ const temporary = `${target}.${process.pid}.${randomUUID()}.tmp`;
21333
+ const fs = createNodeFileSystem();
21334
+ let reserved = false;
21335
+ try {
21336
+ createExclusiveFile(temporary);
21337
+ reserved = true;
21338
+ await context.storageState({ path: temporary });
21339
+ chmod(temporary, 384);
21340
+ await fs.rename(temporary, target);
21341
+ } finally {
21342
+ if (reserved) {
21343
+ await Promise.resolve().then(() => fs.deleteFile(temporary)).catch(() => {
21344
+ return;
21345
+ });
21346
+ }
21347
+ }
21348
+ }
21218
21349
  // ../../packages/publish-harness/src/index.ts
21219
21350
  import { homedir as homedir4 } from "os";
21220
21351
  import { join as join4, resolve as resolve4 } from "path";
@@ -21274,6 +21405,7 @@ var VERDICT_PRINT_MARGIN_MS = 2000;
21274
21405
  var MIN_PASS_BUDGET_MS = 5000;
21275
21406
  var PASS_LAUNCH_RESERVE_MS = 20000;
21276
21407
  var DEFAULT_POLL_MS = 500;
21408
+ var OPEN_SESSION_SAVE_DEBOUNCE_MS = 1500;
21277
21409
  function isInstantBrowserDeath(message) {
21278
21410
  return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
21279
21411
  }
@@ -21461,9 +21593,17 @@ async function openChannelSession(config, request, deps = {}, stdout = echo) {
21461
21593
  } catch (error) {
21462
21594
  stdout(`${config.channel} profile open navigation failed: ${errorMessage2(error)}`);
21463
21595
  }
21596
+ const capture = createOpenSessionCapture({
21597
+ context,
21598
+ profileDir: request.profileDir,
21599
+ fileSystem: createNodeFileSystem(),
21600
+ persistStorageState: true
21601
+ });
21602
+ capture.attach(page);
21464
21603
  await new Promise((resolveClose) => {
21465
21604
  context.once("close", () => resolveClose());
21466
21605
  });
21606
+ await capture.flush();
21467
21607
  stdout(`${config.channel} profile open closed: ${request.profileDir}`);
21468
21608
  return 0;
21469
21609
  }
@@ -21624,6 +21764,68 @@ async function readIdentityOrUndefined(readIdentity, page) {
21624
21764
  return;
21625
21765
  }
21626
21766
  }
21767
+ function createOpenSessionCapture(options) {
21768
+ const metadataPath = join5(options.profileDir, BOT_METADATA_FILE);
21769
+ let closing = false;
21770
+ let timer;
21771
+ let chain = Promise.resolve();
21772
+ options.context.once("close", () => {
21773
+ closing = true;
21774
+ });
21775
+ const snapshot = async () => {
21776
+ if (closing)
21777
+ return;
21778
+ try {
21779
+ if (options.persistStorageState) {
21780
+ await persistChannelSessionState(options.context, options.profileDir);
21781
+ }
21782
+ if (lstat(metadataPath) === null)
21783
+ return;
21784
+ const metadata = await readBotMetadata(options.fileSystem, metadataPath);
21785
+ if (metadata === null)
21786
+ return;
21787
+ const facts = await captureSessionFacts(options.context, metadata.defaultUrl);
21788
+ await writeBotMetadata(options.fileSystem, metadataPath, {
21789
+ ...metadata,
21790
+ lastRefreshedAt: new Date().toISOString(),
21791
+ ...facts.expiresAt === undefined ? {} : { expiresAt: facts.expiresAt }
21792
+ });
21793
+ } catch {}
21794
+ };
21795
+ const schedule = () => {
21796
+ if (closing)
21797
+ return;
21798
+ if (timer !== undefined)
21799
+ clearTimeout(timer);
21800
+ timer = setTimeout(() => {
21801
+ timer = undefined;
21802
+ chain = chain.then(snapshot);
21803
+ }, OPEN_SESSION_SAVE_DEBOUNCE_MS);
21804
+ timer.unref?.();
21805
+ };
21806
+ const attachPage = (target) => {
21807
+ target.on?.("load", schedule);
21808
+ };
21809
+ return {
21810
+ attach: (page) => {
21811
+ attachPage(page);
21812
+ options.context.on?.("page", attachPage);
21813
+ },
21814
+ flush: async () => {
21815
+ if (timer !== undefined) {
21816
+ clearTimeout(timer);
21817
+ timer = undefined;
21818
+ }
21819
+ closing = true;
21820
+ await chain;
21821
+ }
21822
+ };
21823
+ }
21824
+ async function writeBotMetadata(fileSystem, path, metadata) {
21825
+ await fileSystem.writeFile(path, `${JSON.stringify(metadata, null, 2)}
21826
+ `);
21827
+ chmod(path, 384);
21828
+ }
21627
21829
  function errorMessage2(error) {
21628
21830
  return error instanceof Error ? error.message : String(error);
21629
21831
  }
@@ -26329,7 +26531,19 @@ var omniVoiceGenContentSchema = ContentSchema.extend({
26329
26531
  })
26330
26532
  });
26331
26533
  var VideoVisualModeSchema = _enum2(["editorial", "avatar", "hybrid-pip"]);
26332
- var VideoRenderProviderSchema = _enum2(["local-ken-burns", "wan21-i2v", "musetalk", "echomimic-v2"]);
26534
+ var VideoRenderProviderSchema = _enum2([
26535
+ "local-ken-burns",
26536
+ "wan21-i2v",
26537
+ "comfyui-minimax-h3",
26538
+ "musetalk",
26539
+ "echomimic-v2"
26540
+ ]);
26541
+ var RenderProvenanceSchema = object3({
26542
+ cache: _enum2(["drive", "local"]),
26543
+ comfyuiCommit: string4().min(1).optional(),
26544
+ comfyuiRuntimeCommit: string4().min(1).nullable().optional(),
26545
+ modelCache: object3({ verified: boolean4(), restored: number4().int().nonnegative() }).optional()
26546
+ });
26333
26547
  var videoGenContentSchema = ContentSchema.extend({
26334
26548
  format: literal("video"),
26335
26549
  metadata: looseObject({
@@ -26342,6 +26556,7 @@ var videoGenContentSchema = ContentSchema.extend({
26342
26556
  durationSec: number4().positive(),
26343
26557
  visualMode: VideoVisualModeSchema,
26344
26558
  renderProvider: VideoRenderProviderSchema,
26559
+ renderProvenance: RenderProvenanceSchema.optional(),
26345
26560
  fallbackUsed: boolean4().optional(),
26346
26561
  warnings: array2(string4()).optional(),
26347
26562
  ccuEstimated: number4().nonnegative().optional(),
@@ -12805,8 +12805,40 @@ var init_dist3 = __esm(() => {
12805
12805
  // ../../packages/publish-harness/src/bot-fs.ts
12806
12806
  var init_bot_fs = () => {};
12807
12807
 
12808
+ // ../../packages/publish-harness/src/bot-transaction.ts
12809
+ import { homedir } from "os";
12810
+ import { dirname as dirname4, join, resolve } from "path";
12811
+ var DEFAULT_BOT_TRANSACTION_ROOT;
12812
+ var init_bot_transaction = __esm(() => {
12813
+ init_bot();
12814
+ init_bot_fs();
12815
+ DEFAULT_BOT_TRANSACTION_ROOT = join(homedir(), ".config", "kk", "browser-transactions");
12816
+ });
12817
+
12818
+ // ../../packages/publish-harness/src/profile-lease.ts
12819
+ import { homedir as homedir2, hostname } from "os";
12820
+ import { basename as basename3, dirname as dirname5, join as join2, resolve as resolve2 } from "path";
12821
+ var DEFAULT_BOT_LEASE_ROOT;
12822
+ var init_profile_lease = __esm(() => {
12823
+ init_bot();
12824
+ init_bot_fs();
12825
+ DEFAULT_BOT_LEASE_ROOT = join2(homedir2(), ".config", "kk", "browser-leases");
12826
+ });
12827
+
12828
+ // ../../packages/publish-harness/src/bot.ts
12829
+ import { homedir as homedir3 } from "os";
12830
+ import { isAbsolute, join as join3, relative, resolve as resolve3, sep as sep2 } from "path";
12831
+ var DEFAULT_BOT_PROFILE_ROOT;
12832
+ var init_bot = __esm(() => {
12833
+ init_bot_fs();
12834
+ init_bot_transaction();
12835
+ init_profile_lease();
12836
+ DEFAULT_BOT_PROFILE_ROOT = join3(homedir3(), ".config", "kk", "browser-profiles");
12837
+ });
12838
+
12808
12839
  // ../../packages/publish-harness/src/session-state.ts
12809
12840
  var init_session_state = __esm(() => {
12841
+ init_bot();
12810
12842
  init_bot_fs();
12811
12843
  });
12812
12844
 
@@ -12868,7 +12900,7 @@ var init_src = __esm(() => {
12868
12900
  import { createHash } from "crypto";
12869
12901
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
12870
12902
  import { writeFile } from "fs/promises";
12871
- import { basename as basename3, dirname as dirname4, extname as extname2, isAbsolute, join, relative, resolve, sep as sep2 } from "path";
12903
+ import { basename as basename4, dirname as dirname6, extname as extname2, isAbsolute as isAbsolute2, join as join4, relative as relative2, resolve as resolve4, sep as sep3 } from "path";
12872
12904
  import { parseArgs } from "util";
12873
12905
 
12874
12906
  // ../../packages/kk-core/src/content-limits.ts
@@ -17569,7 +17601,19 @@ var omniVoiceGenContentSchema = ContentSchema.extend({
17569
17601
  })
17570
17602
  });
17571
17603
  var VideoVisualModeSchema = _enum(["editorial", "avatar", "hybrid-pip"]);
17572
- var VideoRenderProviderSchema = _enum(["local-ken-burns", "wan21-i2v", "musetalk", "echomimic-v2"]);
17604
+ var VideoRenderProviderSchema = _enum([
17605
+ "local-ken-burns",
17606
+ "wan21-i2v",
17607
+ "comfyui-minimax-h3",
17608
+ "musetalk",
17609
+ "echomimic-v2"
17610
+ ]);
17611
+ var RenderProvenanceSchema = object({
17612
+ cache: _enum(["drive", "local"]),
17613
+ comfyuiCommit: string2().min(1).optional(),
17614
+ comfyuiRuntimeCommit: string2().min(1).nullable().optional(),
17615
+ modelCache: object({ verified: boolean2(), restored: number2().int().nonnegative() }).optional()
17616
+ });
17573
17617
  var videoGenContentSchema = ContentSchema.extend({
17574
17618
  format: literal("video"),
17575
17619
  metadata: looseObject({
@@ -17582,6 +17626,7 @@ var videoGenContentSchema = ContentSchema.extend({
17582
17626
  durationSec: number2().positive(),
17583
17627
  visualMode: VideoVisualModeSchema,
17584
17628
  renderProvider: VideoRenderProviderSchema,
17629
+ renderProvenance: RenderProvenanceSchema.optional(),
17585
17630
  fallbackUsed: boolean2().optional(),
17586
17631
  warnings: array(string2()).optional(),
17587
17632
  ccuEstimated: number2().nonnegative().optional(),
@@ -18407,7 +18452,7 @@ function failUncertain(error) {
18407
18452
  return failWithDeliveryState(error, "uncertain");
18408
18453
  }
18409
18454
  async function writePublishResult(outputPath, result) {
18410
- const outDir = dirname4(outputPath);
18455
+ const outDir = dirname6(outputPath);
18411
18456
  if (outDir && outDir !== ".") {
18412
18457
  await createNodeFileSystem().ensureDir(outDir);
18413
18458
  }
@@ -18426,14 +18471,14 @@ function resolvePostPath(options) {
18426
18471
  return { error: `options.postPath is required for the "${String(options.operation)}" operation` };
18427
18472
  }
18428
18473
  const postPath = raw.trim();
18429
- if (!isAbsolute(postPath)) {
18474
+ if (!isAbsolute2(postPath)) {
18430
18475
  return { error: `options.postPath must be an absolute path inside the surfdash checkout: ${postPath}` };
18431
18476
  }
18432
18477
  return { postPath };
18433
18478
  }
18434
18479
  function postPathOutsideRoot(postPath, surfdashRoot) {
18435
- const root = resolve(surfdashRoot);
18436
- if (!resolve(postPath).startsWith(root + sep2)) {
18480
+ const root = resolve4(surfdashRoot);
18481
+ if (!resolve4(postPath).startsWith(root + sep3)) {
18437
18482
  return `options.postPath must resolve inside the surfdash checkout (${root}): ${postPath}`;
18438
18483
  }
18439
18484
  return;
@@ -18448,16 +18493,16 @@ function resolveScaffoldTarget(options) {
18448
18493
  return { locale: raw };
18449
18494
  }
18450
18495
  function deriveLocaleDraftPath(postPath, locale) {
18451
- const marker = `${sep2}zh${sep2}`;
18496
+ const marker = `${sep3}zh${sep3}`;
18452
18497
  const idx = postPath.lastIndexOf(marker);
18453
18498
  if (idx < 0) {
18454
18499
  return;
18455
18500
  }
18456
- return `${postPath.slice(0, idx)}${sep2}${locale}${sep2}${postPath.slice(idx + marker.length)}`;
18501
+ return `${postPath.slice(0, idx)}${sep3}${locale}${sep3}${postPath.slice(idx + marker.length)}`;
18457
18502
  }
18458
18503
  function resolveSurfdashRoot() {
18459
18504
  const postsurfingBin = process.env.POSTSURFING_BIN ?? "postsurfing";
18460
- return process.env.SURFDASH_ROOT ?? (postsurfingBin.includes("/") ? resolve(dirname4(dirname4(postsurfingBin))) : undefined);
18505
+ return process.env.SURFDASH_ROOT ?? (postsurfingBin.includes("/") ? resolve4(dirname6(dirname6(postsurfingBin))) : undefined);
18461
18506
  }
18462
18507
  async function spawnCli(cmd, cwd) {
18463
18508
  const env = { ...process.env };
@@ -18526,7 +18571,7 @@ function digestCheckGate(filePath, locale) {
18526
18571
  return `digest frontmatter check failed: ${problems.join("; ")}`;
18527
18572
  }
18528
18573
  function localeSiblings(postPath) {
18529
- const segments = postPath.split(sep2);
18574
+ const segments = postPath.split(sep3);
18530
18575
  let index = -1;
18531
18576
  for (let i = segments.length - 1;i >= 0; i--) {
18532
18577
  if (segments[i] === "zh" || segments[i] === "en" || segments[i] === "ja") {
@@ -18537,7 +18582,7 @@ function localeSiblings(postPath) {
18537
18582
  if (index < 0)
18538
18583
  return [];
18539
18584
  return PATCH_LOCALES.map((locale) => ({
18540
- filePath: [...segments.slice(0, index), locale, ...segments.slice(index + 1)].join(sep2),
18585
+ filePath: [...segments.slice(0, index), locale, ...segments.slice(index + 1)].join(sep3),
18541
18586
  locale
18542
18587
  }));
18543
18588
  }
@@ -18610,7 +18655,7 @@ async function runDailyTopicsSync(surfdashRoot, zhPostPath) {
18610
18655
  if (!built.ok) {
18611
18656
  return { ok: false, error: `daily-topics sync failed: ${built.error}` };
18612
18657
  }
18613
- const mapPath = join(surfdashRoot, "scripts", "seo", "daily-topics.json");
18658
+ const mapPath = join4(surfdashRoot, "scripts", "seo", "daily-topics.json");
18614
18659
  const before = await spawnCli(["git", "status", "--porcelain", "--", ...DAILY_TOPICS_GIT_PATHS], surfdashRoot);
18615
18660
  const beforePaths = new Set(parsePorcelainPaths(before.stdout));
18616
18661
  try {
@@ -18630,7 +18675,7 @@ async function runDailyTopicsSync(surfdashRoot, zhPostPath) {
18630
18675
  }
18631
18676
  const after = await spawnCli(["git", "status", "--porcelain", "--", ...DAILY_TOPICS_GIT_PATHS], surfdashRoot);
18632
18677
  const changed = parsePorcelainPaths(after.stdout).filter((p) => !beforePaths.has(p));
18633
- return { ok: true, paths: [...new Set([relative(surfdashRoot, mapPath), ...changed])] };
18678
+ return { ok: true, paths: [...new Set([relative2(surfdashRoot, mapPath), ...changed])] };
18634
18679
  }
18635
18680
  var SITE_GATE_COMMANDS = [
18636
18681
  ["bun", "run", "sd", "check", "digest"],
@@ -18824,7 +18869,7 @@ async function scaffoldLocale(options) {
18824
18869
  }
18825
18870
  const draftPath = deriveLocaleDraftPath(postPath.postPath, target.locale);
18826
18871
  if (!draftPath) {
18827
- return fail(`options.postPath must be a zh post path containing a "${sep2}zh${sep2}" segment: ${postPath.postPath}`);
18872
+ return fail(`options.postPath must be a zh post path containing a "${sep3}zh${sep3}" segment: ${postPath.postPath}`);
18828
18873
  }
18829
18874
  try {
18830
18875
  const force = options.force === true;
@@ -18948,12 +18993,12 @@ async function patchPost(options) {
18948
18993
  echoError(`patch: cover patch skipped for ${outcome.slug} \u2014 ${outcome.coverPatch.reason} (page ${outcome.coverPatch.pageUrl === "" ? "unknown" : outcome.coverPatch.pageUrl})`);
18949
18994
  }
18950
18995
  const synced = await syncPost({ postPath: postPath.postPath });
18951
- const commitPaths = new Set(outcome.written.map((path) => relative(surfdashRoot, path)));
18996
+ const commitPaths = new Set(outcome.written.map((path) => relative2(surfdashRoot, path)));
18952
18997
  if (process.env.SURFDASH_AUTO_PUSH !== "0") {
18953
18998
  const backfilled = await runListenLinkBackfill(surfdashRoot);
18954
18999
  for (const p of backfilled)
18955
19000
  commitPaths.add(p);
18956
- const gate = await runSiteGate(surfdashRoot, [...commitPaths, relative(surfdashRoot, postPath.postPath)]);
19001
+ const gate = await runSiteGate(surfdashRoot, [...commitPaths, relative2(surfdashRoot, postPath.postPath)]);
18957
19002
  if (!gate.ok)
18958
19003
  return fail(gate.error);
18959
19004
  }
@@ -19034,9 +19079,9 @@ function resolvePreparedLocaleSet(options) {
19034
19079
  if (typeof runDate !== "string" || !/^\d{8}$/.test(runDate)) {
19035
19080
  return { ok: false, result: failNotSent(`options.runDate must be YYYYMMDD, got '${String(runDate)}'`) };
19036
19081
  }
19037
- const articlesRoot = resolve(surfdashRoot, "content", "posts", "articles");
19038
- const relativePost = relative(articlesRoot, postPath.postPath);
19039
- const parts = relativePost.split(sep2);
19082
+ const articlesRoot = resolve4(surfdashRoot, "content", "posts", "articles");
19083
+ const relativePost = relative2(articlesRoot, postPath.postPath);
19084
+ const parts = relativePost.split(sep3);
19040
19085
  const slug = parts[1];
19041
19086
  if (parts.length !== 3 || parts[0] !== "zh" || parts[2] !== "index.md" || slug === undefined || slug === "") {
19042
19087
  return {
@@ -19100,14 +19145,15 @@ function resolvePreparedPost(options) {
19100
19145
  dateStamp: runDate,
19101
19146
  slug,
19102
19147
  filePath: preparedPath,
19103
- relPostDir: join("content", "posts", "articles", "zh", slug),
19104
- relPostDirs: ["zh", "en", "ja"].map((locale) => join("content", "posts", "articles", locale, slug)),
19148
+ relPostDir: join4("content", "posts", "articles", "zh", slug),
19149
+ relPostDirs: ["zh", "en", "ja"].map((locale) => join4("content", "posts", "articles", locale, slug)),
19105
19150
  articleUrl: `${baseUrl}/zh/posts/${slug}`
19106
19151
  },
19107
19152
  identity: identity.value
19108
19153
  };
19109
19154
  }
19110
19155
  var LOCAL_DRAFTS = ["en", "ja"];
19156
+ var SUPPORTED_LOCALES = ["zh", "en", "ja"];
19111
19157
  function readLocaleDrafts(content) {
19112
19158
  const drafts = {};
19113
19159
  const surfdash = content.metadata?.surfdash;
@@ -19130,7 +19176,7 @@ function readLocaleDrafts(content) {
19130
19176
  return drafts;
19131
19177
  }
19132
19178
  async function mintLocalePost(options) {
19133
- const filePath = join(options.postDir, "index.md");
19179
+ const filePath = join4(options.postDir, "index.md");
19134
19180
  if (readRefinedSnapshot(filePath) !== undefined) {
19135
19181
  echoError(`surfdash-pub: keeping existing refined post at ${filePath} (not re-minting)`);
19136
19182
  return;
@@ -19151,11 +19197,24 @@ async function preparePost(payload) {
19151
19197
  result: failNotSent("SURFDASH_ROOT is required when POSTSURFING_BIN is not a path inside the surfdash checkout")
19152
19198
  };
19153
19199
  }
19154
- const rawLocale = process.env.SURFDASH_LOCALE ?? "zh";
19155
- if (!["zh", "en", "ja"].includes(rawLocale)) {
19156
- return { ok: false, result: failNotSent(`SURFDASH_LOCALE must be one of zh/en/ja, got '${rawLocale}'`) };
19200
+ const suppliedLocale = payload.content.metadata?.locale;
19201
+ if (suppliedLocale !== undefined && (typeof suppliedLocale !== "string" || !SUPPORTED_LOCALES.includes(suppliedLocale))) {
19202
+ return {
19203
+ ok: false,
19204
+ result: failNotSent(`metadata.locale must be one of ${SUPPORTED_LOCALES.join("/")}, got ${JSON.stringify(suppliedLocale)}`)
19205
+ };
19206
+ }
19207
+ const explicitLocale = suppliedLocale !== undefined && !isDigestContent(payload.content);
19208
+ let locale;
19209
+ if (explicitLocale) {
19210
+ locale = suppliedLocale;
19211
+ } else {
19212
+ const rawLocale = process.env.SURFDASH_LOCALE ?? "zh";
19213
+ if (!SUPPORTED_LOCALES.includes(rawLocale)) {
19214
+ return { ok: false, result: failNotSent(`SURFDASH_LOCALE must be one of zh/en/ja, got '${rawLocale}'`) };
19215
+ }
19216
+ locale = rawLocale;
19157
19217
  }
19158
- const locale = rawLocale;
19159
19218
  const runDate = typeof payload.content.metadata?.runDate === "string" && payload.content.metadata.runDate !== "" ? payload.content.metadata.runDate : typeof payload.content.metadata?.date === "string" ? payload.content.metadata.date.replaceAll("-", "") : "";
19160
19219
  const dateStamp = runDate || new Date().toISOString().slice(0, 10).replaceAll("-", "");
19161
19220
  const titleSlug = slugify3(payload.content.title ?? "");
@@ -19163,10 +19222,10 @@ async function preparePost(payload) {
19163
19222
  if (runDate !== "" && !/^\d{8}$/.test(runDate)) {
19164
19223
  return { ok: false, result: failNotSent(`metadata.runDate must be YYYYMMDD, got '${runDate}'`) };
19165
19224
  }
19166
- const articlesRoot = resolve(surfdashRoot, "content", "posts", "articles");
19167
- const localeRoot = resolve(articlesRoot, locale);
19168
- const postDir = resolve(localeRoot, slug);
19169
- if (dirname4(localeRoot) !== articlesRoot || dirname4(postDir) !== localeRoot) {
19225
+ const articlesRoot = resolve4(surfdashRoot, "content", "posts", "articles");
19226
+ const localeRoot = resolve4(articlesRoot, locale);
19227
+ const postDir = resolve4(localeRoot, slug);
19228
+ if (dirname6(localeRoot) !== articlesRoot || dirname6(postDir) !== localeRoot) {
19170
19229
  return { ok: false, result: failNotSent(`post path escapes ${articlesRoot}`) };
19171
19230
  }
19172
19231
  const rawCover = payload.content.metadata?.coverImage;
@@ -19188,7 +19247,7 @@ async function preparePost(payload) {
19188
19247
  const optsObj = payload.options !== undefined && typeof payload.options === "object" && payload.options !== null ? payload.options : {};
19189
19248
  const isDryRun = optsObj.dryRun === true || process.env.KNOWLEDGE_KIT_PUBLISH_TRANSPORT === "fake";
19190
19249
  if (isDryRun) {
19191
- const safeName = basename3(trimmedCover).replace(/[^a-zA-Z0-9._-]/g, "_") || "cover.png";
19250
+ const safeName = basename4(trimmedCover).replace(/[^a-zA-Z0-9._-]/g, "_") || "cover.png";
19192
19251
  coverUrl = `https://podcast-media.salty.vip/production/images/dry-run-${safeName}`;
19193
19252
  } else {
19194
19253
  try {
@@ -19214,17 +19273,18 @@ async function preparePost(payload) {
19214
19273
  };
19215
19274
  }
19216
19275
  }
19217
- const filePath = join(postDir, "index.md");
19276
+ const filePath = join4(postDir, "index.md");
19218
19277
  const publishDate = runDate ? `${runDate.slice(0, 4)}-${runDate.slice(4, 6)}-${runDate.slice(6, 8)}` : undefined;
19219
- const mintedDirs = [join("content", "posts", "articles", locale, slug)];
19278
+ const mintedDirs = [join4("content", "posts", "articles", locale, slug)];
19220
19279
  try {
19221
19280
  await mintLocalePost({ postDir, content: payload.content, coverUrl, locale, publishDate });
19222
- for (const draftLocale of LOCAL_DRAFTS) {
19281
+ const siblingLocales = explicitLocale ? [] : LOCAL_DRAFTS;
19282
+ for (const draftLocale of siblingLocales) {
19223
19283
  const draft = drafts[draftLocale];
19224
19284
  if (draft === undefined)
19225
19285
  continue;
19226
- const siblingDir = resolve(articlesRoot, draftLocale, slug);
19227
- if (dirname4(resolve(siblingDir)) !== resolve(articlesRoot, draftLocale)) {
19286
+ const siblingDir = resolve4(articlesRoot, draftLocale, slug);
19287
+ if (dirname6(resolve4(siblingDir)) !== resolve4(articlesRoot, draftLocale)) {
19228
19288
  return { ok: false, result: failNotSent(`post path escapes ${articlesRoot}`) };
19229
19289
  }
19230
19290
  await mintLocalePost({
@@ -19234,7 +19294,7 @@ async function preparePost(payload) {
19234
19294
  locale: draftLocale,
19235
19295
  publishDate
19236
19296
  });
19237
- mintedDirs.push(join("content", "posts", "articles", draftLocale, slug));
19297
+ mintedDirs.push(join4("content", "posts", "articles", draftLocale, slug));
19238
19298
  }
19239
19299
  } catch (err) {
19240
19300
  return {
@@ -19252,7 +19312,7 @@ async function preparePost(payload) {
19252
19312
  dateStamp,
19253
19313
  slug,
19254
19314
  filePath,
19255
- relPostDir: join("content", "posts", "articles", locale, slug),
19315
+ relPostDir: join4("content", "posts", "articles", locale, slug),
19256
19316
  relPostDirs: mintedDirs,
19257
19317
  articleUrl,
19258
19318
  ...coverUrl !== undefined ? { coverUrl } : {}
@@ -19358,7 +19418,7 @@ async function refinePreparedPost(options) {
19358
19418
  const resolved = resolvePreparedLocaleSet(options);
19359
19419
  if (!resolved.ok)
19360
19420
  return resolved.result;
19361
- const orchestrator = join(resolved.value.surfdashRoot, "scripts", "publish-orchestrator.ts");
19421
+ const orchestrator = join4(resolved.value.surfdashRoot, "scripts", "publish-orchestrator.ts");
19362
19422
  if (!existsSync2(orchestrator))
19363
19423
  return failNotSent(`Surfdash refine orchestrator is missing: ${orchestrator}`);
19364
19424
  try {
@@ -22,6 +22,60 @@
22
22
  }
23
23
  }
24
24
  }
25
+ },
26
+ "article-zh": {
27
+ "format": "article",
28
+ "locale": "zh",
29
+ "modes": {
30
+ "draft": {
31
+ "metadata": {
32
+ "published": false,
33
+ "locale": "zh"
34
+ }
35
+ },
36
+ "live": {
37
+ "metadata": {
38
+ "published": true,
39
+ "locale": "zh"
40
+ }
41
+ }
42
+ }
43
+ },
44
+ "article-ja": {
45
+ "format": "article",
46
+ "locale": "ja",
47
+ "modes": {
48
+ "draft": {
49
+ "metadata": {
50
+ "published": false,
51
+ "locale": "ja"
52
+ }
53
+ },
54
+ "live": {
55
+ "metadata": {
56
+ "published": true,
57
+ "locale": "ja"
58
+ }
59
+ }
60
+ }
61
+ },
62
+ "article-en": {
63
+ "format": "article",
64
+ "locale": "en",
65
+ "modes": {
66
+ "draft": {
67
+ "metadata": {
68
+ "published": false,
69
+ "locale": "en"
70
+ }
71
+ },
72
+ "live": {
73
+ "metadata": {
74
+ "published": true,
75
+ "locale": "en"
76
+ }
77
+ }
78
+ }
25
79
  }
26
80
  }
27
81
  }