@gobing-ai/knowledge-kit 0.1.15 → 0.1.17

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 (116) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +1765 -40
  3. package/package.json +1 -1
  4. package/plugins/generations/content-gen/dist/index.js +58 -52
  5. package/plugins/generations/content-gen/src/storm.ts +94 -61
  6. package/plugins/generations/core-facts-gen/dist/index.js +1 -1
  7. package/plugins/generations/daily-article-gen/dist/index.js +1 -1
  8. package/plugins/generations/dailynews-gen/dist/index.js +1 -1
  9. package/plugins/generations/episode-plan-gen/dist/index.js +1 -1
  10. package/plugins/generations/gemini-tts/dist/index.js +1 -1
  11. package/plugins/generations/image-gen/README.md +31 -10
  12. package/plugins/generations/image-gen/assets/sample/cover__quasi-news-podcast.jpg +0 -0
  13. package/plugins/generations/image-gen/assets/sample/daily-news-cover__quasi-news-podcast.jpg +0 -0
  14. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__clean-webapp-ui.jpg +0 -0
  15. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__cute.jpg +0 -0
  16. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__daily-news.jpg +0 -0
  17. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__editorial.jpg +0 -0
  18. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__fresh.jpg +0 -0
  19. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__minimalist.jpg +0 -0
  20. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__photorealistic.jpg +0 -0
  21. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__quasi-news-podcast.jpg +0 -0
  22. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__sketch.jpg +0 -0
  23. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__technical-diagram.jpg +0 -0
  24. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__vibrant.jpg +0 -0
  25. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__warm.jpg +0 -0
  26. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__xhs-knowledge.jpg +0 -0
  27. package/plugins/generations/image-gen/assets/sample/free__quasi-news-podcast.jpg +0 -0
  28. package/plugins/generations/image-gen/assets/sample/illustration__quasi-news-podcast.jpg +0 -0
  29. package/plugins/generations/image-gen/assets/sample/xhs-card__quasi-news-podcast.jpg +0 -0
  30. package/plugins/generations/image-gen/dist/index.js +1 -1
  31. package/plugins/generations/image-gen/presets/formats/daily-news-podcast-cover.yaml +18 -0
  32. package/plugins/generations/image-gen/presets/styles/quasi-news-podcast.yaml +9 -0
  33. package/plugins/generations/news-report-gen/dist/index.js +1 -1
  34. package/plugins/generations/voice-gen/dist/index.js +1 -1
  35. package/plugins/generations/voxcpm-tts/dist/index.js +1 -1
  36. package/plugins/ingestions/aihot-ingest/dist/index.js +1 -1
  37. package/plugins/ingestions/horizon-ingest/dist/index.js +1 -1
  38. package/plugins/ingestions/last30days-ingest/dist/index.js +1 -1
  39. package/plugins/ingestions/web-search/dist/index.js +1 -1
  40. package/plugins/kk/plugin.json +1 -1
  41. package/plugins/kk/publish-presets/daily-ai-voice-migration.json +12 -3
  42. package/plugins/kk/publish-presets/daily-ai-voice.json +17 -9
  43. package/plugins/kk/publish-presets/itc-main.json +42 -0
  44. package/plugins/kk/scripts/cover-compositor.ts +198 -0
  45. package/plugins/kk/scripts/daily-cover-mock.ts +164 -0
  46. package/plugins/kk/scripts/daily-scheduled-run.ts +188 -3
  47. package/plugins/kk/scripts/daily-stages.ts +134 -26
  48. package/plugins/kk/scripts/daily-triage-core.ts +451 -0
  49. package/plugins/kk/scripts/daily-triage.ts +74 -0
  50. package/plugins/kk/scripts/itc-stages.ts +3 -2
  51. package/plugins/kk/scripts/kk-workflow-stages.ts +31 -2
  52. package/plugins/kk/scripts/voice3-publish-window.ts +5 -1
  53. package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +16 -10
  54. package/plugins/kk/skills/news-editorial/SKILL.md +3 -3
  55. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +2 -1
  56. package/plugins/kk/skills/publish/SKILL.md +1 -1
  57. package/plugins/kk/skills/wiki-authoring/SKILL.md +53 -0
  58. package/plugins/kk/skills/wiki-authoring/references/page-shapes.md +44 -0
  59. package/plugins/kk/workflows/kk-daily-ai-voice3.yaml +3 -3
  60. package/plugins/kk/workflows/kk-daily-publish3.yaml +10 -3
  61. package/plugins/kk/workflows/kk-daily-safety.yaml +32 -7
  62. package/plugins/publishings/bilibili-pub/dist/index.js +90 -17
  63. package/plugins/publishings/bilibili-pub/dist/profile-check.js +90 -16
  64. package/plugins/publishings/cnblogs-pub/dist/index.js +90 -17
  65. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +90 -16
  66. package/plugins/publishings/csdn-pub/dist/index.js +90 -17
  67. package/plugins/publishings/csdn-pub/dist/profile-check.js +91 -17
  68. package/plugins/publishings/emdash-pub/dist/index.js +1 -1
  69. package/plugins/publishings/infoq-pub/dist/index.js +120 -19
  70. package/plugins/publishings/infoq-pub/dist/profile-check.js +95 -18
  71. package/plugins/publishings/infoq-pub/src/index.ts +40 -1
  72. package/plugins/publishings/jike-pub/dist/index.js +90 -17
  73. package/plugins/publishings/jike-pub/dist/profile-check.js +91 -17
  74. package/plugins/publishings/juejin-pub/dist/index.js +117 -20
  75. package/plugins/publishings/juejin-pub/dist/profile-check.js +94 -18
  76. package/plugins/publishings/juejin-pub/src/index.ts +41 -2
  77. package/plugins/publishings/linkedin-pub/dist/index.js +90 -17
  78. package/plugins/publishings/linkedin-pub/dist/profile-check.js +91 -17
  79. package/plugins/publishings/medium-pub/dist/index.js +1 -1
  80. package/plugins/publishings/podcast-pub/dist/index.js +1 -1
  81. package/plugins/publishings/qiita-pub/dist/index.js +1 -1
  82. package/plugins/publishings/shipinhao-pub/dist/index.js +311 -66
  83. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +138 -17
  84. package/plugins/publishings/shipinhao-pub/plugin.json +2 -2
  85. package/plugins/publishings/shipinhao-pub/src/flow.ts +335 -79
  86. package/plugins/publishings/shipinhao-pub/src/index.ts +16 -8
  87. package/plugins/publishings/shipinhao-pub/src/profile-check.ts +1 -1
  88. package/plugins/publishings/shipinhao-pub/src/selectors.ts +103 -5
  89. package/plugins/publishings/sspai-pub/dist/index.js +90 -17
  90. package/plugins/publishings/sspai-pub/dist/profile-check.js +90 -16
  91. package/plugins/publishings/substack-pub/dist/index.js +90 -17
  92. package/plugins/publishings/substack-pub/dist/profile-check.js +91 -17
  93. package/plugins/publishings/surfdash-pub/dist/index.js +244 -13
  94. package/plugins/publishings/surfdash-pub/src/index.ts +144 -8
  95. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +189 -0
  96. package/plugins/publishings/threads-pub/dist/index.js +1 -1
  97. package/plugins/publishings/wechatmp-pub/dist/index.js +186 -39
  98. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +96 -19
  99. package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +14 -2
  100. package/plugins/publishings/wechatmp-pub/src/enrich.ts +10 -3
  101. package/plugins/publishings/wechatmp-pub/src/flow.ts +158 -25
  102. package/plugins/publishings/wechatmp-pub/src/page.ts +14 -0
  103. package/plugins/publishings/wechatmp-pub/src/profile-check.ts +8 -1
  104. package/plugins/publishings/weibo-pub/dist/index.js +90 -17
  105. package/plugins/publishings/weibo-pub/dist/profile-check.js +91 -17
  106. package/plugins/publishings/x-pub/dist/index.js +90 -17
  107. package/plugins/publishings/x-pub/dist/profile-check.js +91 -17
  108. package/plugins/publishings/xhs-pub/dist/index.js +646 -47
  109. package/plugins/publishings/xhs-pub/dist/profile-check.js +109 -17
  110. package/plugins/publishings/xhs-pub/src/errors.ts +45 -0
  111. package/plugins/publishings/xhs-pub/src/flow.ts +773 -45
  112. package/plugins/publishings/xhs-pub/src/page.ts +33 -0
  113. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +90 -17
  114. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +90 -16
  115. package/plugins/publishings/zenn-pub/dist/index.js +94 -2
  116. package/plugins/publishings/zenn-pub/src/index.ts +134 -1
@@ -20133,8 +20133,11 @@ import {
20133
20133
  mkdirSync as mkdirSync2,
20134
20134
  openSync,
20135
20135
  readdirSync as readdirSync2,
20136
+ readlinkSync,
20136
20137
  realpathSync as realpathSync2,
20137
- rmdirSync
20138
+ renameSync as renameSync2,
20139
+ rmdirSync,
20140
+ unlinkSync
20138
20141
  } from "fs";
20139
20142
  function lstat(path) {
20140
20143
  try {
@@ -20169,6 +20172,33 @@ function rmdir(path) {
20169
20172
  throw error;
20170
20173
  }
20171
20174
  }
20175
+ function readlink(path) {
20176
+ try {
20177
+ return readlinkSync(path);
20178
+ } catch {
20179
+ return null;
20180
+ }
20181
+ }
20182
+ function unlink(path) {
20183
+ try {
20184
+ unlinkSync(path);
20185
+ return true;
20186
+ } catch (error) {
20187
+ if (error.code === "ENOENT")
20188
+ return false;
20189
+ throw error;
20190
+ }
20191
+ }
20192
+ function rename(from, to) {
20193
+ try {
20194
+ renameSync2(from, to);
20195
+ return true;
20196
+ } catch (error) {
20197
+ if (error.code === "ENOENT")
20198
+ return false;
20199
+ throw error;
20200
+ }
20201
+ }
20172
20202
  function chmod(path, mode) {
20173
20203
  chmodSync(path, mode);
20174
20204
  }
@@ -20180,14 +20210,14 @@ var DEFAULT_BOT_TRANSACTION_ROOT = join(homedir(), ".config", "kk", "browser-tra
20180
20210
 
20181
20211
  // ../../packages/publish-harness/src/profile-lease.ts
20182
20212
  import { createHash, randomBytes } from "crypto";
20183
- import { homedir as homedir2 } from "os";
20213
+ import { homedir as homedir2, hostname } from "os";
20184
20214
  import { basename, dirname as dirname3, join as join2, resolve as resolve2 } from "path";
20185
20215
  var DEFAULT_BOT_LEASE_ROOT = join2(homedir2(), ".config", "kk", "browser-leases");
20186
20216
  var KK_BOT_LEASE_PATH = "KK_BOT_LEASE_PATH";
20187
20217
  var KK_BOT_LEASE_TOKEN = "KK_BOT_LEASE_TOKEN";
20188
20218
  var OWNER_FILE = "owner.json";
20189
20219
  var HOLDER_PREFIX = "holder-";
20190
- var NATIVE_LOCK_FILES = ["SingletonLock", "SingletonSocket"];
20220
+ var NATIVE_LOCK_FILES = ["SingletonLock", "SingletonSocket", "SingletonCookie"];
20191
20221
  async function acquireProfileLease(profileDir, options = {}) {
20192
20222
  const fileSystem = options.fileSystem ?? createNodeFileSystem();
20193
20223
  const leaseRoot = options.leaseRoot ?? DEFAULT_BOT_LEASE_ROOT;
@@ -20355,6 +20385,8 @@ function isProcessAlive(pid) {
20355
20385
  }
20356
20386
  }
20357
20387
  function refuseNativeLock(profileDir) {
20388
+ if (reclaimStaleNativeLock(profileDir))
20389
+ return;
20358
20390
  for (const name of NATIVE_LOCK_FILES) {
20359
20391
  const path = join2(profileDir, name);
20360
20392
  if (lstat(path) !== null) {
@@ -20362,6 +20394,24 @@ function refuseNativeLock(profileDir) {
20362
20394
  }
20363
20395
  }
20364
20396
  }
20397
+ function reclaimStaleNativeLock(profileDir) {
20398
+ const lockPath = join2(profileDir, "SingletonLock");
20399
+ const target = readlink(lockPath);
20400
+ if (target === null)
20401
+ return false;
20402
+ const match = /^(.*)-(\d+)$/.exec(target);
20403
+ if (match === null)
20404
+ return false;
20405
+ const [, host, pidText] = match;
20406
+ if (host !== hostname())
20407
+ return false;
20408
+ const pid = Number(pidText);
20409
+ if (!Number.isInteger(pid) || pid <= 0 || isProcessAlive(pid))
20410
+ return false;
20411
+ for (const name of NATIVE_LOCK_FILES)
20412
+ unlink(join2(profileDir, name));
20413
+ return true;
20414
+ }
20365
20415
  function sha256Hex(value) {
20366
20416
  return createHash("sha256").update(value).digest("hex");
20367
20417
  }
@@ -20430,6 +20480,27 @@ async function ensureProfileDir2(profileDir, headless) {
20430
20480
  var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20431
20481
  // ../../packages/publish-harness/src/browser.ts
20432
20482
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20483
+ function isInstantBrowserDeath(message) {
20484
+ return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
20485
+ }
20486
+ function classifyLaunchError(error, profileDir, channel) {
20487
+ const message = errorMessage2(error);
20488
+ if (/singleton|already in use|in use by another/i.test(message))
20489
+ return new BrowserProfileBusyError(profileDir, error);
20490
+ if (/playwright install|executable doesn't exist/i.test(message)) {
20491
+ return new PlaywrightUnavailableError(`Browser channel '${channel}' is not installed. Run \`bunx playwright install chromium\` (or install Google Chrome for KK_BROWSER_CHANNEL=chrome).`, { cause: error });
20492
+ }
20493
+ if (isInstantBrowserDeath(message)) {
20494
+ return new PlaywrightUnavailableError(`browser profile ${profileDir} makes Chromium exit during startup (no diagnostic reported). Move it aside (\`mv ${profileDir} ${profileDir}.broken-<date>\`) and log in again; \`storage-state.json\` is the only state worth keeping.`, { cause: error });
20495
+ }
20496
+ return error instanceof Error ? error : new Error(message);
20497
+ }
20498
+ function quarantineProfileSyncData(profileDir) {
20499
+ const syncData = join5(profileDir, "Default", "Sync Data");
20500
+ if (lstat(syncData) === null)
20501
+ return false;
20502
+ return rename(syncData, `${syncData}.broken-${new Date().toISOString().replace(/[:.]/g, "").slice(0, 15)}`);
20503
+ }
20433
20504
  function createKkBrowserLauncher(loadPlaywright = () => import("playwright"), ownership, leaseOptions = {}) {
20434
20505
  return {
20435
20506
  async launch(request) {
@@ -20458,23 +20529,25 @@ async function launchKkContext(loadPlaywright, profileDir, headless) {
20458
20529
  throw new PlaywrightUnavailableError('The "playwright" dependency is not installed. Run `bunx playwright install chromium`.', { cause: error });
20459
20530
  }
20460
20531
  const channel = process.env.KK_BROWSER_CHANNEL?.trim() || "chromium";
20532
+ const launch = () => playwright.chromium.launchPersistentContext(profileDir, {
20533
+ headless,
20534
+ channel,
20535
+ args: ["--disable-blink-features=AutomationControlled"],
20536
+ ignoreDefaultArgs: ["--enable-automation"]
20537
+ });
20461
20538
  let context;
20462
20539
  try {
20463
- context = await playwright.chromium.launchPersistentContext(profileDir, {
20464
- headless,
20465
- channel,
20466
- args: ["--disable-blink-features=AutomationControlled"],
20467
- ignoreDefaultArgs: ["--enable-automation"]
20468
- });
20540
+ context = await launch();
20469
20541
  } catch (error) {
20470
- const message = errorMessage2(error);
20471
- if (/singleton|already in use|in use by another/i.test(message)) {
20472
- throw new BrowserProfileBusyError(profileDir, error);
20473
- }
20474
- if (/playwright install|executable doesn't exist/i.test(message)) {
20475
- throw new PlaywrightUnavailableError(`Browser channel '${channel}' is not installed. Run \`bunx playwright install chromium\` (or install Google Chrome for KK_BROWSER_CHANNEL=chrome).`, { cause: error });
20542
+ if (!isInstantBrowserDeath(errorMessage2(error)))
20543
+ throw classifyLaunchError(error, profileDir, channel);
20544
+ if (!quarantineProfileSyncData(profileDir))
20545
+ throw classifyLaunchError(error, profileDir, channel);
20546
+ try {
20547
+ context = await launch();
20548
+ } catch (retryError) {
20549
+ throw classifyLaunchError(retryError, profileDir, channel);
20476
20550
  }
20477
- throw error;
20478
20551
  }
20479
20552
  try {
20480
20553
  await context.addInitScript(() => {
@@ -20753,7 +20826,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
20753
20826
  shortVideo: Object.freeze({
20754
20827
  douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
20755
20828
  kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
20756
- shipinhao: Object.freeze({ max: 1000, unit: "unicode_code_points" })
20829
+ shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
20757
20830
  })
20758
20831
  })
20759
20832
  });
@@ -21024,6 +21097,25 @@ function wrapPlaywrightPage(raw, shadow) {
21024
21097
  }
21025
21098
  return pw.waitForEvent(event, options);
21026
21099
  },
21100
+ on: (event, handler) => {
21101
+ const raw2 = raw;
21102
+ raw2.on?.(event, handler);
21103
+ },
21104
+ off: (event, handler) => {
21105
+ const raw2 = raw;
21106
+ raw2.off?.(event, handler);
21107
+ },
21108
+ onContextResponse: (handler) => {
21109
+ const raw2 = raw;
21110
+ const ctx = raw2.context?.();
21111
+ ctx?.on?.("response", handler);
21112
+ },
21113
+ offContextResponse: (handler) => {
21114
+ const raw2 = raw;
21115
+ const ctx = raw2.context?.();
21116
+ ctx?.off?.("response", handler);
21117
+ },
21118
+ boundingBoxesOnScreen: (selector) => onScreen(selector).then((found) => found.map((entry) => entry.box)),
21027
21119
  mouse: {
21028
21120
  click: (x, y) => pw.mouse.click(x, y)
21029
21121
  }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Typed publish failures (task 0350), mirroring the vendor-proven
3
+ * `vendors/xiaohongshu-skills/scripts/xhs/errors.py` mapping. The flows THROW these; the
4
+ * transport's catch turns `error.message` into the failed Result, so every message names its
5
+ * class — the Result error string is what callers and tiers match on.
6
+ *
7
+ * Name assignment lives in constructor bodies, not field initializers: bun's coverage counts
8
+ * each initializer as an unattributable function, which would pin this file below the 90%
9
+ * per-file function threshold.
10
+ */
11
+ export class PublishError extends Error {
12
+ override name: string;
13
+ constructor(message: string, name = 'PublishError') {
14
+ super(message);
15
+ this.name = name;
16
+ }
17
+ }
18
+
19
+ /** The server refused the note for account-level risk control (−913x / 禁止发笔记) — not retryable. */
20
+ export class AccountRiskControlError extends PublishError {
21
+ constructor(message: string) {
22
+ super(message, 'AccountRiskControlError');
23
+ }
24
+ }
25
+
26
+ /** The platform's own counter says the title exceeds its limit. */
27
+ export class TitleTooLongError extends PublishError {
28
+ constructor(message: string) {
29
+ super(message, 'TitleTooLongError');
30
+ }
31
+ }
32
+
33
+ /** The platform's own counter says the body exceeds its limit. */
34
+ export class ContentTooLongError extends PublishError {
35
+ constructor(message: string) {
36
+ super(message, 'ContentTooLongError');
37
+ }
38
+ }
39
+
40
+ /** A just-saved draft failed its post-save reopen verification (slots/srcs/fields). */
41
+ export class DraftVerifyError extends PublishError {
42
+ constructor(message: string) {
43
+ super(message, 'DraftVerifyError');
44
+ }
45
+ }