@gobing-ai/knowledge-kit 0.1.24 → 0.1.27

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 (77) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +416 -79
  3. package/package.json +1 -1
  4. package/plugins/generations/episode-plan-gen/dist/index.js +47 -6
  5. package/plugins/generations/episode-plan-gen/src/index.ts +71 -7
  6. package/plugins/generations/music-gen/dist/index.js +17 -13
  7. package/plugins/generations/music-gen/src/audio/measure.ts +25 -20
  8. package/plugins/kk/decisions/extract/ai-news.yaml +8 -1
  9. package/plugins/kk/plugin.json +1 -1
  10. package/plugins/kk/publish-presets/daily-ai-voice.json +4 -4
  11. package/plugins/kk/publish-presets/itc-main.json +39 -23
  12. package/plugins/kk/scripts/cn-lead-gate.ts +494 -0
  13. package/plugins/kk/scripts/daily-stages.ts +880 -131
  14. package/plugins/kk/scripts/kk-workflow-stages.ts +58 -3
  15. package/plugins/kk/skills/content-safety/references/platforms/apple-podcasts.md +12 -5
  16. package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +8 -0
  17. package/plugins/kk/skills/content-safety/references/platforms/xiaoyuzhou.md +5 -0
  18. package/plugins/kk/skills/daily-news-cover/SKILL.md +96 -0
  19. package/plugins/kk/skills/daily-news-illustrations/SKILL.md +123 -0
  20. package/plugins/kk/skills/news-editorial/SKILL.md +25 -6
  21. package/plugins/kk/skills/news-editorial/references/daily-visual-composition.md +150 -0
  22. package/plugins/kk/skills/news-editorial/references/selection.md +42 -0
  23. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +1 -1
  24. package/plugins/kk/workflows/kk-article-generate.yaml +13 -1
  25. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +6 -3
  26. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -4
  27. package/plugins/kk/workflows/kk-news-generate.yaml +71 -1
  28. package/plugins/publishings/bilibili-pub/dist/index.js +35 -3
  29. package/plugins/publishings/bilibili-pub/dist/profile-check.js +35 -3
  30. package/plugins/publishings/cnblogs-pub/dist/index.js +35 -3
  31. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +35 -3
  32. package/plugins/publishings/csdn-pub/dist/index.js +35 -3
  33. package/plugins/publishings/csdn-pub/dist/profile-check.js +35 -3
  34. package/plugins/publishings/infoq-pub/dist/index.js +35 -3
  35. package/plugins/publishings/infoq-pub/dist/profile-check.js +35 -3
  36. package/plugins/publishings/jike-pub/dist/index.js +35 -3
  37. package/plugins/publishings/jike-pub/dist/profile-check.js +35 -3
  38. package/plugins/publishings/juejin-pub/dist/index.js +35 -3
  39. package/plugins/publishings/juejin-pub/dist/profile-check.js +35 -3
  40. package/plugins/publishings/linkedin-pub/dist/index.js +86 -14
  41. package/plugins/publishings/linkedin-pub/dist/profile-check.js +52 -6
  42. package/plugins/publishings/linkedin-pub/src/index.ts +126 -9
  43. package/plugins/publishings/medium-pub/dist/index.js +9229 -279
  44. package/plugins/publishings/medium-pub/dist/profile-check.js +21205 -0
  45. package/plugins/publishings/medium-pub/package.json +3 -1
  46. package/plugins/publishings/medium-pub/plugin.json +6 -1
  47. package/plugins/publishings/medium-pub/src/browser-rail.ts +280 -0
  48. package/plugins/publishings/medium-pub/src/index.ts +17 -1
  49. package/plugins/publishings/medium-pub/src/profile-check.ts +27 -0
  50. package/plugins/publishings/shipinhao-pub/dist/index.js +38 -4
  51. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +37 -4
  52. package/plugins/publishings/shipinhao-pub/src/flow.ts +5 -0
  53. package/plugins/publishings/shipinhao-pub/src/selectors.ts +11 -4
  54. package/plugins/publishings/sspai-pub/dist/index.js +35 -3
  55. package/plugins/publishings/sspai-pub/dist/profile-check.js +35 -3
  56. package/plugins/publishings/substack-pub/dist/index.js +35 -3
  57. package/plugins/publishings/substack-pub/dist/profile-check.js +35 -3
  58. package/plugins/publishings/surfdash-pub/dist/index.js +53 -15
  59. package/plugins/publishings/surfdash-pub/src/index.ts +31 -4
  60. package/plugins/publishings/surfdash-pub/src/patch.ts +81 -12
  61. package/plugins/publishings/threads-pub/dist/index.js +35 -3
  62. package/plugins/publishings/threads-pub/dist/profile-check.js +35 -3
  63. package/plugins/publishings/wechatmp-pub/dist/index.js +326 -44
  64. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +69 -4
  65. package/plugins/publishings/wechatmp-pub/src/flow.ts +447 -53
  66. package/plugins/publishings/wechatmp-pub/src/index.ts +68 -2
  67. package/plugins/publishings/wechatmp-pub/src/page.ts +8 -0
  68. package/plugins/publishings/weibo-pub/dist/index.js +58 -9
  69. package/plugins/publishings/weibo-pub/dist/profile-check.js +57 -9
  70. package/plugins/publishings/weibo-pub/plugin.json +1 -1
  71. package/plugins/publishings/weibo-pub/src/index.ts +76 -8
  72. package/plugins/publishings/x-pub/dist/index.js +35 -3
  73. package/plugins/publishings/x-pub/dist/profile-check.js +35 -3
  74. package/plugins/publishings/xhs-pub/dist/index.js +35 -3
  75. package/plugins/publishings/xhs-pub/dist/profile-check.js +35 -3
  76. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +35 -3
  77. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +35 -3
@@ -20231,7 +20231,12 @@ async function acquireProfileLease(profileDir, options = {}) {
20231
20231
  const leaseDir = join2(leaseRoot, id);
20232
20232
  await fileSystem.ensureDir(leaseRoot);
20233
20233
  if (!mkdirExclusive(leaseDir, 448)) {
20234
- throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20234
+ if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
20235
+ throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20236
+ }
20237
+ if (!mkdirExclusive(leaseDir, 448)) {
20238
+ throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20239
+ }
20235
20240
  }
20236
20241
  const token = randomBytes(16).toString("hex");
20237
20242
  const owner = {
@@ -20347,7 +20352,34 @@ async function busyGuidance(fileSystem, leaseDir) {
20347
20352
  }
20348
20353
  return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
20349
20354
  }
20350
- return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed`;
20355
+ const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
20356
+ const suffix = live.length > 0 ? `pid ${owner.pid} is gone but child holders ${live.join(", ")} are still running \u2014 stop those processes before retrying` : isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running and the lease could not be reclassified \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
20357
+ return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
20358
+ }
20359
+ async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
20360
+ const owner = await readOwner(fileSystem, leaseDir);
20361
+ if (owner === null || isProcessAlive(owner.pid))
20362
+ return false;
20363
+ if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
20364
+ return false;
20365
+ const target = staleLeaseDir(leaseDir);
20366
+ try {
20367
+ rename(leaseDir, target);
20368
+ } catch {
20369
+ return false;
20370
+ }
20371
+ const moved = await readOwner(fileSystem, target);
20372
+ if (moved !== null && moved.token !== owner.token) {
20373
+ try {
20374
+ rename(target, leaseDir);
20375
+ } catch {}
20376
+ return false;
20377
+ }
20378
+ return true;
20379
+ }
20380
+ function staleLeaseDir(leaseDir) {
20381
+ const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
20382
+ return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
20351
20383
  }
20352
20384
  async function holderResidue(fileSystem, leaseDir) {
20353
20385
  try {
@@ -20595,7 +20627,7 @@ function resolveChannelProfileDir(channel, override) {
20595
20627
  return resolveBrowserProfileDir(channel, chosen);
20596
20628
  }
20597
20629
  async function checkChannelSession(config, opts) {
20598
- const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20630
+ const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20599
20631
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20600
20632
  let lastDetail = `${config.channel} readiness was never probed`;
20601
20633
  const deadline = Date.now() + timeoutMs;
@@ -21113,6 +21145,9 @@ if (false) {}
21113
21145
  var CJK_TERMINATORS = new Set(["\u3002", "\uFF01", "\uFF1F"]);
21114
21146
  var LATIN_TERMINATORS = new Set([".", "!", "?"]);
21115
21147
  var ATTACHED_CLOSERS = new Set(["\u201D", "\u2019", "\u300D", "\u300F", "\uFF09", ")", '"', "'"]);
21148
+ // ../../plugins/publishings/wechatmp-pub/src/index.ts
21149
+ init_dist();
21150
+
21116
21151
  // ../../plugins/publishings/wechatmp-pub/src/cgi.ts
21117
21152
  var MP_ORIGIN = "https://mp.weixin.qq.com";
21118
21153
  var FILETRANSFER_URL = `${MP_ORIGIN}/cgi-bin/filetransfer`;
@@ -21244,6 +21279,30 @@ async function openWithState(profileDir, headless, url = CONSOLE_URL) {
21244
21279
  throw error;
21245
21280
  }
21246
21281
  }
21282
+ function cookieIdentity(cookie) {
21283
+ return `${cookie.domain ?? ""}\x00${cookie.path ?? "/"}\x00${cookie.name}`;
21284
+ }
21285
+ function isLiveCookie(cookie, nowMs) {
21286
+ return cookie.expires === undefined || cookie.expires <= 0 || cookie.expires * 1000 > nowMs;
21287
+ }
21288
+ function selectRestoreCookies(saved, profile, nowMs = Date.now()) {
21289
+ const live = new Set(profile.filter((cookie) => isLiveCookie(cookie, nowMs)).map(cookieIdentity));
21290
+ const inject = [];
21291
+ let shadowed = 0;
21292
+ let expired = 0;
21293
+ for (const cookie of saved) {
21294
+ if (!isLiveCookie(cookie, nowMs)) {
21295
+ expired += 1;
21296
+ continue;
21297
+ }
21298
+ if (live.has(cookieIdentity(cookie))) {
21299
+ shadowed += 1;
21300
+ continue;
21301
+ }
21302
+ inject.push(cookie);
21303
+ }
21304
+ return { inject, shadowed, expired };
21305
+ }
21247
21306
  async function restoreWechatSessionState(context, page, profileDir) {
21248
21307
  const stateFile = storageStatePath(profileDir);
21249
21308
  let state;
@@ -21256,7 +21315,13 @@ async function restoreWechatSessionState(context, page, profileDir) {
21256
21315
  if (!cookies || cookies.length === 0) {
21257
21316
  throw new BrowserProfileMissingError(`no saved console session state (${stateFile}) \u2014 run \`bun src/profile-check.ts login\` once`);
21258
21317
  }
21259
- await context.addCookies(cookies);
21318
+ const profileCookies = await context.cookies().catch(() => []);
21319
+ const selection = selectRestoreCookies(cookies, profileCookies);
21320
+ if (selection.shadowed > 0 || selection.expired > 0) {
21321
+ echoError(`wechatmp-pub: kept ${selection.shadowed} session cookie(s) from the profile itself and skipped ` + `${selection.expired} expired saved cookie(s) \u2014 the saved state is older than this profile`);
21322
+ }
21323
+ if (selection.inject.length > 0)
21324
+ await context.addCookies(selection.inject);
21260
21325
  for (const entry of state?.origins ?? []) {
21261
21326
  const items = entry.localStorage ?? [];
21262
21327
  if (entry.origin === undefined || entry.origin.length === 0 || items.length === 0)