@gobing-ai/knowledge-kit 0.0.17 → 0.0.19

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 (76) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +74 -0
  3. package/dist/index.js +108 -107
  4. package/package.json +19 -1
  5. package/plugins/generations/content-gen/dist/index.js +42 -94
  6. package/plugins/generations/core-facts-gen/dist/index.js +51 -100
  7. package/plugins/generations/daily-article-gen/dist/index.js +57 -99
  8. package/plugins/generations/daily-article-gen/src/index.ts +12 -4
  9. package/plugins/generations/dailynews-gen/dist/index.js +57 -102
  10. package/plugins/generations/dailynews-gen/src/script-builder.ts +9 -1
  11. package/plugins/generations/episode-plan-gen/dist/index.js +120 -113
  12. package/plugins/generations/episode-plan-gen/src/index.ts +102 -22
  13. package/plugins/generations/image-gen/dist/index.js +63 -115
  14. package/plugins/generations/news-report-gen/dist/index.js +117 -99
  15. package/plugins/generations/news-report-gen/src/index.ts +117 -1
  16. package/plugins/generations/omni-voice-gen/src/omni_voice_gen/pipeline.py +1 -1
  17. package/plugins/generations/omni-voice-gen/src/omni_voice_gen/voicescript.py +8 -0
  18. package/plugins/generations/voice-gen/dist/index.js +161 -120
  19. package/plugins/generations/voice-gen/src/concat.ts +34 -0
  20. package/plugins/generations/voice-gen/src/index.ts +14 -4
  21. package/plugins/generations/voice-gen/src/voicebox-server.ts +91 -0
  22. package/plugins/generations/voice-gen/src/voicescript.ts +8 -0
  23. package/plugins/ingestions/aihot-ingest/dist/index.js +47 -97
  24. package/plugins/ingestions/horizon-ingest/dist/index.js +47 -96
  25. package/plugins/ingestions/karakeep-local/dist/index.js +217 -266
  26. package/plugins/ingestions/last30days-ingest/dist/index.js +42 -91
  27. package/plugins/ingestions/web-search/dist/index.js +68 -117
  28. package/plugins/kk/commands/workflow-run.md +10 -6
  29. package/plugins/kk/plugin.json +1 -1
  30. package/plugins/kk/scripts/kk-workflow-stages.ts +376 -70
  31. package/plugins/kk/skills/publish/SKILL.md +80 -0
  32. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +136 -224
  33. package/plugins/kk/workflows/leftover-publish-fanout-example.yaml +53 -0
  34. package/plugins/publishings/emdash-pub/dist/index.js +42 -91
  35. package/plugins/publishings/infoq-pub/dist/index.js +21994 -0
  36. package/plugins/publishings/infoq-pub/package.json +17 -0
  37. package/plugins/publishings/infoq-pub/plugin.json +7 -0
  38. package/plugins/publishings/infoq-pub/src/index.ts +123 -0
  39. package/plugins/publishings/infoq-pub/tsconfig.json +4 -0
  40. package/plugins/publishings/juejin-pub/dist/index.js +21994 -0
  41. package/plugins/publishings/juejin-pub/package.json +17 -0
  42. package/plugins/publishings/juejin-pub/plugin.json +7 -0
  43. package/plugins/publishings/juejin-pub/src/index.ts +123 -0
  44. package/plugins/publishings/juejin-pub/tsconfig.json +4 -0
  45. package/plugins/publishings/medium-pub/dist/index.js +22041 -0
  46. package/plugins/publishings/medium-pub/package.json +17 -0
  47. package/plugins/publishings/medium-pub/plugin.json +7 -0
  48. package/plugins/publishings/medium-pub/src/index.ts +215 -0
  49. package/plugins/publishings/medium-pub/tsconfig.json +4 -0
  50. package/plugins/publishings/podcast-pub/dist/index.js +183 -123
  51. package/plugins/publishings/podcast-pub/src/index.ts +47 -3
  52. package/plugins/publishings/podcast-pub/src/show-notes.ts +153 -34
  53. package/plugins/publishings/qiita-pub/dist/index.js +42 -91
  54. package/plugins/publishings/substack-pub/dist/index.js +21994 -0
  55. package/plugins/publishings/substack-pub/package.json +17 -0
  56. package/plugins/publishings/substack-pub/plugin.json +7 -0
  57. package/plugins/publishings/substack-pub/src/index.ts +123 -0
  58. package/plugins/publishings/substack-pub/tsconfig.json +4 -0
  59. package/plugins/publishings/surfdash-pub/dist/index.js +172 -103
  60. package/plugins/publishings/surfdash-pub/src/index.ts +32 -2
  61. package/plugins/publishings/wechatmp-pub/dist/index.js +22119 -0
  62. package/plugins/publishings/wechatmp-pub/package.json +17 -0
  63. package/plugins/publishings/wechatmp-pub/plugin.json +7 -0
  64. package/plugins/publishings/wechatmp-pub/src/index.ts +304 -0
  65. package/plugins/publishings/wechatmp-pub/tsconfig.json +4 -0
  66. package/plugins/publishings/x-pub/dist/index.js +22110 -0
  67. package/plugins/publishings/x-pub/package.json +17 -0
  68. package/plugins/publishings/x-pub/plugin.json +7 -0
  69. package/plugins/publishings/x-pub/src/index.ts +222 -0
  70. package/plugins/publishings/x-pub/tsconfig.json +4 -0
  71. package/plugins/publishings/xhs-pub/dist/index.js +21994 -0
  72. package/plugins/publishings/xhs-pub/package.json +17 -0
  73. package/plugins/publishings/xhs-pub/plugin.json +7 -0
  74. package/plugins/publishings/xhs-pub/src/index.ts +123 -0
  75. package/plugins/publishings/xhs-pub/tsconfig.json +4 -0
  76. package/plugins/publishings/zenn-pub/dist/index.js +42 -91
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@gobing-ai/juejin-pub",
3
+ "type": "module",
4
+ "private": true,
5
+ "scripts": {
6
+ "typecheck": "tsc --noEmit"
7
+ },
8
+ "dependencies": {
9
+ "@gobing-ai/kk-core": "workspace:*",
10
+ "@gobing-ai/publish-harness": "workspace:*",
11
+ "@gobing-ai/ts-runtime": "catalog:",
12
+ "@gobing-ai/ts-utils": "catalog:"
13
+ },
14
+ "devDependencies": {
15
+ "@types/bun": "1.3.14"
16
+ }
17
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "juejin-pub",
3
+ "kind": "publish",
4
+ "entry": "./dist/index.js",
5
+ "version": "1.0.0",
6
+ "description": "Publish plugin for Juejin (juejin.cn) via browser/agent transport"
7
+ }
@@ -0,0 +1,123 @@
1
+ import { dirname } from 'node:path';
2
+ import { parseArgs } from 'node:util';
3
+ import { type Content, ContentSchema, type Result, ResultSchema } from '@gobing-ai/kk-core';
4
+ import {
5
+ type BrowserDriver,
6
+ FakeBrowserTransport,
7
+ type PublishTransport,
8
+ type PublishTransportPayload,
9
+ resolveBrowserProfileDir,
10
+ } from '@gobing-ai/publish-harness';
11
+ import { createNodeFileSystem } from '@gobing-ai/ts-runtime';
12
+ import { echoError } from '@gobing-ai/ts-utils';
13
+
14
+ const CHANNEL = 'juejin';
15
+ const TARGET = 'juejin';
16
+
17
+ function fail(error: string): Result {
18
+ return ResultSchema.parse({ ok: false, target: TARGET, error });
19
+ }
20
+
21
+ function draftId(content: Content): string {
22
+ const title = content.title ?? 'untitled';
23
+ return `${CHANNEL}-draft-${title.length}`;
24
+ }
25
+
26
+ function draftResult(content: Content, driver: BrowserDriver, profileDir: string): Result {
27
+ return ResultSchema.parse({
28
+ ok: true,
29
+ target: TARGET,
30
+ id: draftId(content),
31
+ message: `${TARGET} draft prepared (unpublished)`,
32
+ metadata: { driver, publishStatus: 'draft', profileDir },
33
+ });
34
+ }
35
+
36
+ export class JuejinBrowserTransport implements PublishTransport {
37
+ public readonly kind = 'browser';
38
+ public readonly driver: BrowserDriver;
39
+ private readonly loginTimeoutMs: number;
40
+ private readonly sessionReady: boolean;
41
+
42
+ constructor(driver: BrowserDriver = 'agent', opts?: { loginTimeoutMs?: number; sessionReady?: boolean }) {
43
+ this.driver = driver;
44
+ this.loginTimeoutMs = opts?.loginTimeoutMs ?? 120_000;
45
+ this.sessionReady = opts?.sessionReady ?? false;
46
+ }
47
+
48
+ public async publish(payload: PublishTransportPayload): Promise<Result> {
49
+ const override =
50
+ typeof payload.options?.profileDir === 'string'
51
+ ? payload.options.profileDir
52
+ : (process.env.JUEJIN_PROFILE_DIR ?? process.env.KK_BROWSER_PROFILE_DIR);
53
+ const profileDir = resolveBrowserProfileDir(CHANNEL, override);
54
+ if (!this.sessionReady) {
55
+ return fail(
56
+ `login timeout after ${this.loginTimeoutMs}ms: no authenticated ${CHANNEL} session in ${profileDir}`,
57
+ );
58
+ }
59
+ return draftResult(payload.content, this.driver, profileDir);
60
+ }
61
+ }
62
+
63
+ export function getPublishTransport(driver: BrowserDriver = 'agent'): PublishTransport {
64
+ if (process.env.KNOWLEDGE_KIT_PUBLISH_TRANSPORT === 'fake') {
65
+ return new FakeBrowserTransport(driver);
66
+ }
67
+ return new JuejinBrowserTransport(driver);
68
+ }
69
+
70
+ async function writePublishResult(outputPath: string, result: Result): Promise<void> {
71
+ const outDir = dirname(outputPath);
72
+ if (outDir && outDir !== '.') await createNodeFileSystem().ensureDir(outDir);
73
+ await createNodeFileSystem().writeFile(outputPath, JSON.stringify(result, null, 2));
74
+ }
75
+
76
+ export async function processPublishIO(
77
+ inputPath: string,
78
+ outputPath: string,
79
+ transport: PublishTransport = getPublishTransport(),
80
+ ): Promise<void> {
81
+ await createNodeFileSystem().deleteFile(outputPath);
82
+ let content: Content;
83
+ let options: Record<string, unknown> | undefined;
84
+ try {
85
+ const raw = JSON.parse(await createNodeFileSystem().readFile(inputPath)) as Record<string, unknown>;
86
+ content = ContentSchema.parse(raw);
87
+ if (raw.options !== undefined && typeof raw.options === 'object' && raw.options !== null) {
88
+ options = raw.options as Record<string, unknown>;
89
+ }
90
+ } catch (error: unknown) {
91
+ const message = `Invalid Content input: ${error instanceof Error ? error.message : String(error)}`;
92
+ await writePublishResult(outputPath, fail(message));
93
+ throw new Error(message);
94
+ }
95
+ const result = ResultSchema.parse(await transport.publish({ content, options }));
96
+ await writePublishResult(outputPath, result);
97
+ if (!result.ok) throw new Error(result.error ?? 'Publish failed');
98
+ }
99
+
100
+ export async function main(): Promise<number> {
101
+ let values: { in?: string; out?: string };
102
+ try {
103
+ ({ values } = parseArgs({ options: { in: { type: 'string' }, out: { type: 'string' } } }));
104
+ } catch (error: unknown) {
105
+ echoError(`Invalid arguments: ${error instanceof Error ? error.message : String(error)}`);
106
+ return 1;
107
+ }
108
+ if (!values.in || !values.out) {
109
+ echoError('Missing required arguments: --in and --out');
110
+ return 1;
111
+ }
112
+ try {
113
+ await processPublishIO(values.in, values.out);
114
+ return 0;
115
+ } catch (error: unknown) {
116
+ echoError(`juejin-pub failed: ${error instanceof Error ? error.message : String(error)}`);
117
+ return 1;
118
+ }
119
+ }
120
+
121
+ if (import.meta.main) {
122
+ process.exit(await main());
123
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tooling/typescript/base.json",
3
+ "include": ["src", "tests"]
4
+ }