@gobing-ai/knowledge-kit 0.0.31 → 0.0.33

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 (79) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +32320 -15021
  3. package/package.json +4 -4
  4. package/plugins/generations/content-gen/dist/index.js +10 -9
  5. package/plugins/generations/core-facts-gen/dist/index.js +13 -12
  6. package/plugins/generations/daily-article-gen/dist/index.js +14 -13
  7. package/plugins/generations/daily-article-gen/src/index.ts +1 -1
  8. package/plugins/generations/dailynews-gen/dist/index.js +10 -9
  9. package/plugins/generations/episode-plan-gen/dist/index.js +58 -15
  10. package/plugins/generations/episode-plan-gen/src/index.ts +76 -6
  11. package/plugins/generations/gemini-tts/README.md +11 -0
  12. package/plugins/generations/gemini-tts/dist/index.js +10 -9
  13. package/plugins/generations/image-gen/dist/index.js +154 -151
  14. package/plugins/generations/image-gen/src/compose/chromium.ts +60 -42
  15. package/plugins/generations/news-report-gen/dist/index.js +13 -12
  16. package/plugins/generations/voice-gen/dist/index.js +10 -9
  17. package/plugins/ingestions/aihot-ingest/dist/index.js +13 -12
  18. package/plugins/ingestions/horizon-ingest/dist/index.js +13 -12
  19. package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
  20. package/plugins/ingestions/last30days-ingest/dist/index.js +13 -12
  21. package/plugins/ingestions/web-search/dist/index.js +11 -10
  22. package/plugins/kk/README.md +38 -0
  23. package/plugins/kk/decisions/extract/ai-news.yaml +21 -0
  24. package/plugins/kk/decisions/kk-items.yaml +113 -0
  25. package/plugins/kk/plugin.json +1 -1
  26. package/plugins/kk/schedules/cron.tmpl +15 -0
  27. package/plugins/kk/schedules/launchd.plist.tmpl +77 -0
  28. package/plugins/kk/scripts/daily-stages.ts +1533 -0
  29. package/plugins/kk/scripts/kk-workflow-stages.ts +268 -1228
  30. package/plugins/kk/skills/content-judge/SKILL.md +12 -2
  31. package/plugins/kk/skills/content-judge/references/rubrics.md +8 -2
  32. package/plugins/kk/skills/content-safety/SKILL.md +60 -18
  33. package/plugins/kk/skills/web-automation/SKILL.md +100 -0
  34. package/plugins/kk/skills/web-automation/references/browser-launch.md +86 -0
  35. package/plugins/kk/workflows/kk-collect.yaml +258 -0
  36. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +74 -11
  37. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +655 -0
  38. package/plugins/kk/workflows/kk-daily-safety.yaml +170 -0
  39. package/plugins/publishings/emdash-pub/dist/index.js +10 -9
  40. package/plugins/publishings/infoq-pub/dist/index.js +8695 -211
  41. package/plugins/publishings/infoq-pub/package.json +3 -1
  42. package/plugins/publishings/infoq-pub/plugin.json +2 -1
  43. package/plugins/publishings/infoq-pub/src/index.ts +358 -29
  44. package/plugins/publishings/infoq-pub/src/profile-check.ts +21 -0
  45. package/plugins/publishings/juejin-pub/dist/index.js +8746 -211
  46. package/plugins/publishings/juejin-pub/package.json +3 -1
  47. package/plugins/publishings/juejin-pub/plugin.json +2 -1
  48. package/plugins/publishings/juejin-pub/src/index.ts +345 -29
  49. package/plugins/publishings/juejin-pub/src/profile-check.ts +19 -0
  50. package/plugins/publishings/medium-pub/dist/index.js +10 -9
  51. package/plugins/publishings/podcast-pub/dist/index.js +10 -9
  52. package/plugins/publishings/qiita-pub/dist/index.js +10 -9
  53. package/plugins/publishings/substack-pub/dist/index.js +8687 -211
  54. package/plugins/publishings/substack-pub/package.json +3 -1
  55. package/plugins/publishings/substack-pub/plugin.json +2 -1
  56. package/plugins/publishings/substack-pub/src/index.ts +302 -29
  57. package/plugins/publishings/substack-pub/src/profile-check.ts +76 -0
  58. package/plugins/publishings/surfdash-pub/dist/index.js +10 -9
  59. package/plugins/publishings/wechatmp-pub/dist/index.js +1315 -352
  60. package/plugins/publishings/wechatmp-pub/plugin.json +1 -0
  61. package/plugins/publishings/wechatmp-pub/src/enrich.ts +229 -0
  62. package/plugins/publishings/wechatmp-pub/src/flow.ts +896 -0
  63. package/plugins/publishings/wechatmp-pub/src/index.ts +223 -520
  64. package/plugins/publishings/wechatmp-pub/src/modes.ts +403 -0
  65. package/plugins/publishings/wechatmp-pub/src/page.ts +260 -0
  66. package/plugins/publishings/wechatmp-pub/src/profile-check.ts +84 -38
  67. package/plugins/publishings/x-pub/dist/index.js +8707 -223
  68. package/plugins/publishings/x-pub/package.json +3 -1
  69. package/plugins/publishings/x-pub/plugin.json +2 -1
  70. package/plugins/publishings/x-pub/src/index.ts +315 -23
  71. package/plugins/publishings/x-pub/src/profile-check.ts +19 -0
  72. package/plugins/publishings/xhs-pub/dist/index.js +897 -354
  73. package/plugins/publishings/xhs-pub/plugin.json +2 -1
  74. package/plugins/publishings/xhs-pub/src/flow.ts +572 -0
  75. package/plugins/publishings/xhs-pub/src/index.ts +108 -596
  76. package/plugins/publishings/xhs-pub/src/modes.ts +300 -0
  77. package/plugins/publishings/xhs-pub/src/page.ts +254 -0
  78. package/plugins/publishings/xhs-pub/src/profile-check.ts +29 -17
  79. package/plugins/publishings/zenn-pub/dist/index.js +10 -9
@@ -1,46 +1,92 @@
1
- import { resolveBrowserProfileDir } from '@gobing-ai/publish-harness';
2
- import { openPersistentBrowser } from '@gobing-ai/ts-browser-automation';
3
- import { echo } from '@gobing-ai/ts-utils';
4
- import { checkWechatSession, storageStatePath } from './index';
1
+ /**
2
+ * WeChat MP profile-session capability (0216, ADR-032 probe contract).
3
+ *
4
+ * `login` opens the console headed and resolves once the QR scan lands on `/cgi-bin/home`, then
5
+ * captures the durable `storageState` file — mp.weixin.qq.com grant cookies do not survive a
6
+ * Chromium restart, so the saved state (not the profile cookie store) is the session artifact.
7
+ * `check` reopens the profile with that state re-injected and reports `verified` or `refused`
8
+ * as the LAST line on stdout, one JSON object — `kk plugin check` parses it. Exit codes:
9
+ * 0 verified, 1 refused, 2 usage error. No cookie, token or storageState value is ever printed;
10
+ * the profile directory is the only detail that leaves the process.
11
+ */
12
+ import { parseArgs } from 'node:util';
13
+ import { resolveChannelProfileDir } from '@gobing-ai/publish-harness/browser';
14
+ import { echo, echoError } from '@gobing-ai/ts-utils';
15
+ import { CHANNEL, checkWechatSession, openWechatLogin } from './index';
5
16
 
6
- const CONSOLE_URL = 'https://mp.weixin.qq.com/';
17
+ const USAGE = 'usage: wechatmp profile-check [login|check] [--profile <dir>] [--timeout <ms>] [--headed]';
7
18
  const LOGIN_TIMEOUT_MS = 180_000;
8
- const LOGGED_IN_FRAGMENT = '/cgi-bin/home';
9
19
 
10
- const profileDir = resolveBrowserProfileDir('wechatmp', process.env.WECHATMP_PROFILE_DIR);
11
- const verb = process.argv[2] ?? 'check';
20
+ interface WechatVerdict {
21
+ status: 'verified' | 'refused';
22
+ profileDir: string;
23
+ detail: string;
24
+ }
12
25
 
13
- try {
14
- if (verb === 'login') {
15
- echo(
16
- `wechatmp login: opening the console in a headed browser — scan the QR once (timeout ${LOGIN_TIMEOUT_MS / 1000}s)`,
17
- );
18
- const context = await openPersistentBrowser({ profileDir, headless: false });
19
- try {
20
- const page = context.pages()[0] ?? (await context.newPage());
21
- await page.goto(CONSOLE_URL);
22
- const deadline = Date.now() + LOGIN_TIMEOUT_MS;
23
- while (!page.url().includes(LOGGED_IN_FRAGMENT)) {
24
- if (Date.now() > deadline) throw new Error(`QR scan not completed within ${LOGIN_TIMEOUT_MS / 1000}s`);
25
- await new Promise((resolve) => setTimeout(resolve, 1000));
26
+ export async function main(argv: string[] = process.argv.slice(2)): Promise<number> {
27
+ let command: string;
28
+ let profileDir: string;
29
+ let timeoutMs: number | undefined;
30
+ let headed = false;
31
+ try {
32
+ const { positionals, values } = parseArgs({
33
+ args: argv,
34
+ allowPositionals: true,
35
+ options: {
36
+ profile: { type: 'string' },
37
+ timeout: { type: 'string' },
38
+ headed: { type: 'boolean' },
39
+ },
40
+ });
41
+ command = positionals[0] ?? 'check';
42
+ if (command !== 'login' && command !== 'check') {
43
+ throw new Error(`unknown command '${command}'`);
44
+ }
45
+ headed = values.headed === true;
46
+ if (values.timeout !== undefined) {
47
+ timeoutMs = Number(values.timeout);
48
+ if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
49
+ throw new Error(`--timeout must be a non-negative number of ms, got '${values.timeout}'`);
26
50
  }
27
- await page.waitForTimeout(10_000); // settle: let the console finish its post-auth Set-Cookies
28
- // The Chromium profile store drops the grant cookies on restart even though they carry
29
- // multi-day expiries — the durable session artifact is the captured storageState file,
30
- // which the publish flow re-injects into every launch.
31
- await context.storageState({ path: storageStatePath(profileDir) });
32
- echo(`wechatmp login: session saved in ${storageStatePath(profileDir)}`);
33
- } finally {
34
- await context.close();
35
51
  }
36
- } else if (verb === 'check') {
37
- await checkWechatSession(profileDir);
38
- echo(`wechatmp session: OK (${profileDir})`);
39
- } else {
40
- echo('usage: bun src/profile-check.ts login|check');
41
- process.exit(1);
52
+ profileDir = resolveChannelProfileDir(CHANNEL, values.profile);
53
+ } catch (error) {
54
+ const message = error instanceof Error ? error.message : String(error);
55
+ echoError(`wechatmp profile-check: ${message} — ${USAGE}`);
56
+ echo(JSON.stringify({ status: 'error', detail: message }));
57
+ return 2;
42
58
  }
43
- } catch (error: unknown) {
44
- echo(`wechatmp ${verb}: failed — ${error instanceof Error ? error.message : String(error)}`);
45
- process.exit(1);
59
+
60
+ if (command === 'login') {
61
+ try {
62
+ await openWechatLogin({ profileDir, timeoutMs: timeoutMs ?? LOGIN_TIMEOUT_MS });
63
+ echo(`wechatmp profile login verified: ${profileDir}`);
64
+ return 0;
65
+ } catch (error) {
66
+ echoError(`wechatmp profile login failed: ${error instanceof Error ? error.message : String(error)}`);
67
+ return 1;
68
+ }
69
+ }
70
+
71
+ let verdict: WechatVerdict;
72
+ try {
73
+ await checkWechatSession(profileDir, { headless: !headed, timeoutMs });
74
+ verdict = {
75
+ status: 'verified',
76
+ profileDir,
77
+ detail: `authenticated wechatmp console session observed ${headed ? 'via a headed pass' : 'headlessly'} via profile ${profileDir} (read-only)`,
78
+ };
79
+ } catch (error) {
80
+ verdict = {
81
+ status: 'refused',
82
+ profileDir,
83
+ detail: `wechatmp readiness refused: ${error instanceof Error ? error.message : String(error)}`,
84
+ };
85
+ }
86
+ echo(JSON.stringify(verdict));
87
+ return verdict.status === 'verified' ? 0 : 1;
88
+ }
89
+
90
+ if (import.meta.main) {
91
+ process.exit(await main());
46
92
  }