@gobing-ai/knowledge-kit 0.1.25 → 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 (50) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +115 -21
  3. package/package.json +1 -1
  4. package/plugins/kk/plugin.json +1 -1
  5. package/plugins/kk/scripts/cn-lead-gate.ts +494 -0
  6. package/plugins/kk/scripts/daily-stages.ts +416 -134
  7. package/plugins/kk/scripts/kk-workflow-stages.ts +53 -3
  8. package/plugins/kk/skills/news-editorial/SKILL.md +20 -3
  9. package/plugins/kk/skills/news-editorial/references/selection.md +42 -0
  10. package/plugins/publishings/bilibili-pub/dist/index.js +33 -2
  11. package/plugins/publishings/bilibili-pub/dist/profile-check.js +33 -2
  12. package/plugins/publishings/cnblogs-pub/dist/index.js +33 -2
  13. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +33 -2
  14. package/plugins/publishings/csdn-pub/dist/index.js +33 -2
  15. package/plugins/publishings/csdn-pub/dist/profile-check.js +33 -2
  16. package/plugins/publishings/infoq-pub/dist/index.js +33 -2
  17. package/plugins/publishings/infoq-pub/dist/profile-check.js +33 -2
  18. package/plugins/publishings/jike-pub/dist/index.js +33 -2
  19. package/plugins/publishings/jike-pub/dist/profile-check.js +33 -2
  20. package/plugins/publishings/juejin-pub/dist/index.js +33 -2
  21. package/plugins/publishings/juejin-pub/dist/profile-check.js +33 -2
  22. package/plugins/publishings/linkedin-pub/dist/index.js +84 -13
  23. package/plugins/publishings/linkedin-pub/dist/profile-check.js +50 -5
  24. package/plugins/publishings/linkedin-pub/src/index.ts +126 -9
  25. package/plugins/publishings/medium-pub/dist/index.js +33 -2
  26. package/plugins/publishings/medium-pub/dist/profile-check.js +33 -2
  27. package/plugins/publishings/shipinhao-pub/dist/index.js +33 -2
  28. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +33 -2
  29. package/plugins/publishings/sspai-pub/dist/index.js +33 -2
  30. package/plugins/publishings/sspai-pub/dist/profile-check.js +33 -2
  31. package/plugins/publishings/substack-pub/dist/index.js +33 -2
  32. package/plugins/publishings/substack-pub/dist/profile-check.js +33 -2
  33. package/plugins/publishings/surfdash-pub/dist/index.js +53 -15
  34. package/plugins/publishings/surfdash-pub/src/index.ts +31 -4
  35. package/plugins/publishings/surfdash-pub/src/patch.ts +81 -12
  36. package/plugins/publishings/threads-pub/dist/index.js +33 -2
  37. package/plugins/publishings/threads-pub/dist/profile-check.js +33 -2
  38. package/plugins/publishings/wechatmp-pub/dist/index.js +65 -3
  39. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +67 -3
  40. package/plugins/publishings/wechatmp-pub/src/index.ts +64 -1
  41. package/plugins/publishings/weibo-pub/dist/index.js +56 -8
  42. package/plugins/publishings/weibo-pub/dist/profile-check.js +55 -8
  43. package/plugins/publishings/weibo-pub/plugin.json +1 -1
  44. package/plugins/publishings/weibo-pub/src/index.ts +76 -8
  45. package/plugins/publishings/x-pub/dist/index.js +33 -2
  46. package/plugins/publishings/x-pub/dist/profile-check.js +33 -2
  47. package/plugins/publishings/xhs-pub/dist/index.js +33 -2
  48. package/plugins/publishings/xhs-pub/dist/profile-check.js +33 -2
  49. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +33 -2
  50. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +33 -2
@@ -20558,7 +20558,12 @@ async function acquireProfileLease(profileDir, options = {}) {
20558
20558
  const leaseDir = join3(leaseRoot, id);
20559
20559
  await fileSystem.ensureDir(leaseRoot);
20560
20560
  if (!mkdirExclusive(leaseDir, 448)) {
20561
- throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20561
+ if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
20562
+ throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20563
+ }
20564
+ if (!mkdirExclusive(leaseDir, 448)) {
20565
+ throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20566
+ }
20562
20567
  }
20563
20568
  const token = randomBytes(16).toString("hex");
20564
20569
  const owner = {
@@ -20674,9 +20679,35 @@ async function busyGuidance(fileSystem, leaseDir) {
20674
20679
  }
20675
20680
  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`;
20676
20681
  }
20677
- const suffix = 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 \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
20682
+ const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
20683
+ 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}`;
20678
20684
  return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
20679
20685
  }
20686
+ async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
20687
+ const owner = await readOwner(fileSystem, leaseDir);
20688
+ if (owner === null || isProcessAlive(owner.pid))
20689
+ return false;
20690
+ if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
20691
+ return false;
20692
+ const target = staleLeaseDir(leaseDir);
20693
+ try {
20694
+ rename(leaseDir, target);
20695
+ } catch {
20696
+ return false;
20697
+ }
20698
+ const moved = await readOwner(fileSystem, target);
20699
+ if (moved !== null && moved.token !== owner.token) {
20700
+ try {
20701
+ rename(target, leaseDir);
20702
+ } catch {}
20703
+ return false;
20704
+ }
20705
+ return true;
20706
+ }
20707
+ function staleLeaseDir(leaseDir) {
20708
+ const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
20709
+ return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
20710
+ }
20680
20711
  async function holderResidue(fileSystem, leaseDir) {
20681
20712
  try {
20682
20713
  const entries = await fileSystem.readDir(leaseDir);
@@ -20223,7 +20223,12 @@ async function acquireProfileLease(profileDir, options = {}) {
20223
20223
  const leaseDir = join2(leaseRoot, id);
20224
20224
  await fileSystem.ensureDir(leaseRoot);
20225
20225
  if (!mkdirExclusive(leaseDir, 448)) {
20226
- throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20226
+ if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
20227
+ throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20228
+ }
20229
+ if (!mkdirExclusive(leaseDir, 448)) {
20230
+ throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20231
+ }
20227
20232
  }
20228
20233
  const token = randomBytes(16).toString("hex");
20229
20234
  const owner = {
@@ -20339,9 +20344,35 @@ async function busyGuidance(fileSystem, leaseDir) {
20339
20344
  }
20340
20345
  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`;
20341
20346
  }
20342
- const suffix = 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 \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
20347
+ const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
20348
+ 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}`;
20343
20349
  return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
20344
20350
  }
20351
+ async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
20352
+ const owner = await readOwner(fileSystem, leaseDir);
20353
+ if (owner === null || isProcessAlive(owner.pid))
20354
+ return false;
20355
+ if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
20356
+ return false;
20357
+ const target = staleLeaseDir(leaseDir);
20358
+ try {
20359
+ rename(leaseDir, target);
20360
+ } catch {
20361
+ return false;
20362
+ }
20363
+ const moved = await readOwner(fileSystem, target);
20364
+ if (moved !== null && moved.token !== owner.token) {
20365
+ try {
20366
+ rename(target, leaseDir);
20367
+ } catch {}
20368
+ return false;
20369
+ }
20370
+ return true;
20371
+ }
20372
+ function staleLeaseDir(leaseDir) {
20373
+ const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
20374
+ return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
20375
+ }
20345
20376
  async function holderResidue(fileSystem, leaseDir) {
20346
20377
  try {
20347
20378
  const entries = await fileSystem.readDir(leaseDir);
@@ -20564,7 +20564,12 @@ async function acquireProfileLease(profileDir, options = {}) {
20564
20564
  const leaseDir = join3(leaseRoot, id);
20565
20565
  await fileSystem.ensureDir(leaseRoot);
20566
20566
  if (!mkdirExclusive(leaseDir, 448)) {
20567
- throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20567
+ if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
20568
+ throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20569
+ }
20570
+ if (!mkdirExclusive(leaseDir, 448)) {
20571
+ throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
20572
+ }
20568
20573
  }
20569
20574
  const token = randomBytes(16).toString("hex");
20570
20575
  const owner = {
@@ -20680,9 +20685,35 @@ async function busyGuidance(fileSystem, leaseDir) {
20680
20685
  }
20681
20686
  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`;
20682
20687
  }
20683
- const suffix = 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 \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
20688
+ const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
20689
+ 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}`;
20684
20690
  return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
20685
20691
  }
20692
+ async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
20693
+ const owner = await readOwner(fileSystem, leaseDir);
20694
+ if (owner === null || isProcessAlive(owner.pid))
20695
+ return false;
20696
+ if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
20697
+ return false;
20698
+ const target = staleLeaseDir(leaseDir);
20699
+ try {
20700
+ rename(leaseDir, target);
20701
+ } catch {
20702
+ return false;
20703
+ }
20704
+ const moved = await readOwner(fileSystem, target);
20705
+ if (moved !== null && moved.token !== owner.token) {
20706
+ try {
20707
+ rename(target, leaseDir);
20708
+ } catch {}
20709
+ return false;
20710
+ }
20711
+ return true;
20712
+ }
20713
+ function staleLeaseDir(leaseDir) {
20714
+ const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
20715
+ return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
20716
+ }
20686
20717
  async function holderResidue(fileSystem, leaseDir) {
20687
20718
  try {
20688
20719
  const entries = await fileSystem.readDir(leaseDir);
@@ -19947,7 +19947,12 @@ async function acquireProfileLease(profileDir, options = {}) {
19947
19947
  const leaseDir = join2(leaseRoot, id);
19948
19948
  await fileSystem.ensureDir(leaseRoot);
19949
19949
  if (!mkdirExclusive(leaseDir, 448)) {
19950
- throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
19950
+ if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
19951
+ throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
19952
+ }
19953
+ if (!mkdirExclusive(leaseDir, 448)) {
19954
+ throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
19955
+ }
19951
19956
  }
19952
19957
  const token = randomBytes(16).toString("hex");
19953
19958
  const owner = {
@@ -20063,9 +20068,35 @@ async function busyGuidance(fileSystem, leaseDir) {
20063
20068
  }
20064
20069
  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`;
20065
20070
  }
20066
- const suffix = 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 \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
20071
+ const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
20072
+ 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}`;
20067
20073
  return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
20068
20074
  }
20075
+ async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
20076
+ const owner = await readOwner(fileSystem, leaseDir);
20077
+ if (owner === null || isProcessAlive(owner.pid))
20078
+ return false;
20079
+ if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
20080
+ return false;
20081
+ const target = staleLeaseDir(leaseDir);
20082
+ try {
20083
+ rename(leaseDir, target);
20084
+ } catch {
20085
+ return false;
20086
+ }
20087
+ const moved = await readOwner(fileSystem, target);
20088
+ if (moved !== null && moved.token !== owner.token) {
20089
+ try {
20090
+ rename(target, leaseDir);
20091
+ } catch {}
20092
+ return false;
20093
+ }
20094
+ return true;
20095
+ }
20096
+ function staleLeaseDir(leaseDir) {
20097
+ const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
20098
+ return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
20099
+ }
20069
20100
  async function holderResidue(fileSystem, leaseDir) {
20070
20101
  try {
20071
20102
  const entries = await fileSystem.readDir(leaseDir);