@gobing-ai/knowledge-kit 0.0.11 → 0.0.13
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.
- package/dist/index.js +451 -152
- package/package.json +1 -1
- package/plugins/generations/content-gen/dist/index.js +22167 -0
- package/plugins/generations/content-gen/plugin.json +1 -1
- package/plugins/generations/content-gen/src/storm.ts +99 -50
- package/plugins/generations/core-facts-gen/dist/index.js +22048 -0
- package/plugins/generations/core-facts-gen/package.json +17 -0
- package/plugins/generations/core-facts-gen/plugin.json +7 -0
- package/plugins/generations/core-facts-gen/src/index.ts +116 -0
- package/plugins/generations/core-facts-gen/tsconfig.json +4 -0
- package/plugins/generations/daily-article-gen/dist/index.js +22022 -0
- package/plugins/generations/daily-article-gen/package.json +17 -0
- package/plugins/generations/daily-article-gen/plugin.json +7 -0
- package/plugins/generations/daily-article-gen/src/index.ts +91 -0
- package/plugins/generations/daily-article-gen/tsconfig.json +4 -0
- package/plugins/generations/dailynews-gen/dist/index.js +22324 -0
- package/plugins/generations/dailynews-gen/plugin.json +1 -1
- package/plugins/generations/dailynews-gen/src/index.ts +11 -0
- package/plugins/generations/dailynews-gen/src/script-builder.ts +1 -1
- package/plugins/generations/episode-plan-gen/dist/index.js +22479 -0
- package/plugins/generations/episode-plan-gen/package.json +17 -0
- package/plugins/generations/episode-plan-gen/plugin.json +7 -0
- package/plugins/generations/episode-plan-gen/src/index.ts +726 -0
- package/plugins/generations/episode-plan-gen/tsconfig.json +4 -0
- package/plugins/generations/image-gen/config.example.yaml +75 -0
- package/plugins/generations/image-gen/dist/index.js +22619 -0
- package/plugins/generations/image-gen/package.json +17 -0
- package/plugins/generations/image-gen/plugin.json +7 -0
- package/plugins/generations/image-gen/presets/formats/cover.yaml +57 -0
- package/plugins/generations/image-gen/presets/formats/free.yaml +46 -0
- package/plugins/generations/image-gen/presets/formats/illustration.yaml +48 -0
- package/plugins/generations/image-gen/presets/styles/clean-webapp-ui.yaml +28 -0
- package/plugins/generations/image-gen/presets/styles/cute.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/editorial.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/fresh.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/minimalist.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/photorealistic.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/sketch.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/technical-diagram.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/vibrant.yaml +3 -0
- package/plugins/generations/image-gen/presets/styles/warm.yaml +3 -0
- package/plugins/generations/image-gen/src/bytes.ts +19 -0
- package/plugins/generations/image-gen/src/index.ts +319 -0
- package/plugins/generations/image-gen/src/job.ts +143 -0
- package/plugins/generations/image-gen/src/paths.ts +31 -0
- package/plugins/generations/image-gen/src/presets.ts +344 -0
- package/plugins/generations/image-gen/src/providers/seedream.ts +128 -0
- package/plugins/generations/image-gen/src/providers/types.ts +285 -0
- package/plugins/generations/image-gen/tsconfig.json +8 -0
- package/plugins/generations/voice-gen/dist/index.js +23027 -0
- package/plugins/generations/voice-gen/plugin.json +1 -1
- package/plugins/generations/voice-gen/src/index.ts +102 -11
- package/plugins/generations/voice-gen/src/qc.ts +154 -9
- package/plugins/ingestions/aihot-ingest/dist/index.js +22358 -0
- package/plugins/ingestions/aihot-ingest/plugin.json +2 -2
- package/plugins/ingestions/aihot-ingest/src/index.ts +72 -13
- package/plugins/ingestions/aihot-ingest/src/mapper.ts +1 -0
- package/plugins/ingestions/aihot-ingest/src/rss.ts +151 -0
- package/plugins/ingestions/horizon-ingest/dist/index.js +22105 -0
- package/plugins/ingestions/horizon-ingest/package.json +17 -0
- package/plugins/ingestions/horizon-ingest/plugin.json +7 -0
- package/plugins/ingestions/horizon-ingest/src/index.ts +205 -0
- package/plugins/ingestions/horizon-ingest/tsconfig.json +4 -0
- package/plugins/ingestions/karakeep-local/dist/index.js +24204 -0
- package/plugins/ingestions/karakeep-local/plugin.json +1 -1
- package/plugins/ingestions/last30days-ingest/dist/index.js +22050 -0
- package/plugins/ingestions/last30days-ingest/package.json +17 -0
- package/plugins/ingestions/last30days-ingest/plugin.json +7 -0
- package/plugins/ingestions/last30days-ingest/src/index.ts +148 -0
- package/plugins/ingestions/last30days-ingest/tsconfig.json +4 -0
- package/plugins/ingestions/web-search/dist/index.js +24379 -0
- package/plugins/ingestions/web-search/plugin.json +1 -1
- package/plugins/kk/commands/image-generate.md +15 -0
- package/plugins/kk/config.example.yaml +80 -0
- package/plugins/kk/skills/image-authoring/SKILL.md +250 -0
- package/plugins/kk/skills/image-authoring/references/illustration-positions.md +87 -0
- package/plugins/kk/skills/image-authoring/references/migrating-from-wt.md +31 -0
- package/plugins/kk/skills/image-authoring/references/providers.md +52 -0
- package/plugins/kk/skills/image-authoring/references/style-extraction.md +134 -0
- package/plugins/kk/skills/taste-unslop/SKILL.md +12 -6
- package/plugins/kk/skills/taste-unslop/references/pattern-guide.md +128 -48
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +432 -19
- package/plugins/publishings/emdash-pub/dist/index.js +22243 -0
- package/plugins/publishings/emdash-pub/plugin.json +1 -1
- package/plugins/publishings/podcast-pub/dist/index.js +22596 -0
- package/plugins/publishings/podcast-pub/package.json +17 -0
- package/plugins/publishings/podcast-pub/plugin.json +13 -0
- package/plugins/publishings/podcast-pub/src/index.ts +538 -0
- package/plugins/publishings/podcast-pub/src/map.ts +165 -0
- package/plugins/publishings/podcast-pub/src/microfeed-client.ts +196 -0
- package/plugins/publishings/podcast-pub/src/show-notes.ts +132 -0
- package/plugins/publishings/podcast-pub/tsconfig.json +4 -0
- package/plugins/publishings/qiita-pub/dist/index.js +22081 -0
- package/plugins/publishings/qiita-pub/plugin.json +1 -1
- package/plugins/publishings/surfdash-pub/dist/index.js +22233 -0
- package/plugins/publishings/surfdash-pub/plugin.json +1 -1
- package/plugins/publishings/surfdash-pub/src/index.ts +328 -62
- package/plugins/publishings/zenn-pub/dist/index.js +22122 -0
- package/plugins/publishings/zenn-pub/plugin.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "content-gen",
|
|
3
3
|
"kind": "generator",
|
|
4
|
-
"entry": "./
|
|
4
|
+
"entry": "./dist/index.js",
|
|
5
5
|
"version": "1.0.0",
|
|
6
6
|
"description": "Generator plugin running the owned STORM pipeline (curation, outline, article, polish) to produce Doc[] → Content"
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Content, ContentSchema, type Doc } from '@gobing-ai/kk-core';
|
|
2
|
+
import { echoError } from '@gobing-ai/ts-utils';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import { parseAgentJson } from './agent-json';
|
|
4
5
|
|
|
@@ -21,60 +22,97 @@ export interface StormStageRunner {
|
|
|
21
22
|
runStage(prompt: string): Promise<AgentRunEnvelope>;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
25
|
+
interface SpawnOutcome {
|
|
26
|
+
kind: 'ok' | 'crash' | 'malformed';
|
|
27
|
+
envelope: AgentRunEnvelope;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** One `spur agent run` invocation + envelope unwrap. */
|
|
31
|
+
async function spawnAgentOnce(prompt: string): Promise<SpawnOutcome> {
|
|
32
|
+
const proc = Bun.spawn(
|
|
33
|
+
[
|
|
34
|
+
process.env.KNOWLEDGE_KIT_SPUR_BIN ?? 'spur',
|
|
35
|
+
'agent',
|
|
36
|
+
'run',
|
|
37
|
+
prompt,
|
|
38
|
+
'--agent',
|
|
39
|
+
'auto',
|
|
40
|
+
'--mode',
|
|
41
|
+
'text',
|
|
42
|
+
'--json',
|
|
43
|
+
'--cwd',
|
|
44
|
+
// Anchor the agent's cwd to the project root (set by the executor, whose own
|
|
45
|
+
// cwd is the invocation root). process.cwd() here is the plugin package dir —
|
|
46
|
+
// using it makes spur auto-init a stray `.spur/` and drops agent files there.
|
|
47
|
+
process.env.KNOWLEDGE_KIT_PROJECT_ROOT ?? process.cwd(),
|
|
48
|
+
],
|
|
49
|
+
{ stdout: 'pipe', stderr: 'pipe' },
|
|
50
|
+
);
|
|
51
|
+
const [exitCode, stdout, stderr] = await Promise.all([
|
|
52
|
+
proc.exited,
|
|
53
|
+
new Response(proc.stdout).text(),
|
|
54
|
+
new Response(proc.stderr).text(),
|
|
55
|
+
]);
|
|
56
|
+
if (exitCode !== 0) {
|
|
57
|
+
// CLI-level failure (spawn/argv): no envelope to unwrap; stages prefix the diagnostic.
|
|
58
|
+
return { kind: 'crash', envelope: { exitCode, stdout, stderr } };
|
|
59
|
+
}
|
|
60
|
+
// The CLI writes the agent envelope {exitCode, stdout, stderr, durationMs} to stdout.
|
|
61
|
+
// Unwrap it so stages consume the agent output.
|
|
62
|
+
try {
|
|
63
|
+
const parsed = JSON.parse(stdout) as Partial<AgentRunEnvelope>;
|
|
64
|
+
if (
|
|
65
|
+
typeof parsed.exitCode !== 'number' ||
|
|
66
|
+
typeof parsed.stdout !== 'string' ||
|
|
67
|
+
typeof parsed.stderr !== 'string'
|
|
68
|
+
) {
|
|
69
|
+
throw new Error('expected envelope {exitCode:number, stdout:string, stderr:string}');
|
|
51
70
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
typeof parsed.stdout !== 'string' ||
|
|
60
|
-
typeof parsed.stderr !== 'string'
|
|
61
|
-
) {
|
|
62
|
-
throw new Error('expected envelope {exitCode:number, stdout:string, stderr:string}');
|
|
63
|
-
}
|
|
64
|
-
envelope = parsed as AgentRunEnvelope;
|
|
65
|
-
} catch (error) {
|
|
66
|
-
// Exit-0 but non-envelope stdout: return a runner-level diagnostic so the calling
|
|
67
|
-
// stage prefixes it ({Stage} stage failed: …) instead of leaking a raw SyntaxError.
|
|
68
|
-
return {
|
|
71
|
+
const envelope = parsed as AgentRunEnvelope;
|
|
72
|
+
return { kind: envelope.exitCode === 0 ? 'ok' : 'crash', envelope };
|
|
73
|
+
} catch (error) {
|
|
74
|
+
// Exit-0 but non-envelope stdout: deterministic contract failure — never retried.
|
|
75
|
+
return {
|
|
76
|
+
kind: 'malformed',
|
|
77
|
+
envelope: {
|
|
69
78
|
exitCode: 1,
|
|
70
79
|
stdout: '',
|
|
71
80
|
stderr: `spur agent run returned malformed output: ${error instanceof Error ? error.message : String(error)}`,
|
|
72
|
-
}
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Concrete runner invoking the existing `spur agent run` boundary (same call shape as the D2 stand-in). */
|
|
87
|
+
export const spurStageRunner: StormStageRunner = {
|
|
88
|
+
async runStage(prompt: string): Promise<AgentRunEnvelope> {
|
|
89
|
+
// A crashed agent subprocess (e.g. polish stage exit 1, dogfood daily-ai-news-20260903)
|
|
90
|
+
// must not kill a 90-minute pipeline run — retry once. Malformed envelopes are a
|
|
91
|
+
// deterministic contract failure and are not retried.
|
|
92
|
+
let last: AgentRunEnvelope = { exitCode: 1, stdout: '', stderr: 'no attempt executed' };
|
|
93
|
+
for (let attempt = 1; attempt <= 2; attempt++) {
|
|
94
|
+
const outcome = await spawnAgentOnce(prompt);
|
|
95
|
+
if (outcome.kind !== 'crash') return outcome.envelope;
|
|
96
|
+
last = outcome.envelope;
|
|
97
|
+
if (attempt === 1) {
|
|
98
|
+
echoError(
|
|
99
|
+
`spurStageRunner: agent run exited ${last.exitCode}; retrying once (${last.stderr.trim().slice(0, 200)})`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
73
102
|
}
|
|
74
|
-
return
|
|
103
|
+
return last;
|
|
75
104
|
},
|
|
76
105
|
};
|
|
77
106
|
|
|
107
|
+
/** Language directive appended to outline/article/polish prompts when CONTENT_LANGUAGE is set. */
|
|
108
|
+
function languageDirective(): string {
|
|
109
|
+
const lang = process.env.CONTENT_LANGUAGE?.trim();
|
|
110
|
+
if (!lang) return '';
|
|
111
|
+
return lang === 'zh'
|
|
112
|
+
? 'Write everything in Simplified Chinese (简体中文), including the title and all section headings.'
|
|
113
|
+
: `Write everything in ${lang}, including the title and all section headings.`;
|
|
114
|
+
}
|
|
115
|
+
|
|
78
116
|
const PerspectiveSchema = z.object({
|
|
79
117
|
id: z.string().min(1),
|
|
80
118
|
name: z.string().min(1),
|
|
@@ -166,7 +204,9 @@ export async function curationStage(runner: StormStageRunner, docs: Doc[], input
|
|
|
166
204
|
[
|
|
167
205
|
'Develop multiple distinct perspectives (personas or angles) on the source material. For each perspective, list the questions it would ask and cite the supplied document IDs that ground it.',
|
|
168
206
|
'Return only a JSON object matching {"perspectives":[{"id":string,"name":string,"questions":[string],"evidence":[string]}]} where every evidence entry is one of the allowed document IDs.',
|
|
169
|
-
]
|
|
207
|
+
]
|
|
208
|
+
.filter(Boolean)
|
|
209
|
+
.join('\n'),
|
|
170
210
|
);
|
|
171
211
|
const envelope = await runner.runStage(prompt);
|
|
172
212
|
if (envelope.exitCode !== 0) {
|
|
@@ -204,8 +244,11 @@ export async function outlineStage(
|
|
|
204
244
|
[
|
|
205
245
|
`The validated curation result for the article is: ${JSON.stringify(curation)}`,
|
|
206
246
|
'Produce a structured markdown outline for the article derived from that curation result.',
|
|
247
|
+
languageDirective(),
|
|
207
248
|
'Return only a JSON object matching {"title":string,"outline":string,"references":[string]} where outline is markdown and every references entry is one of the allowed document IDs.',
|
|
208
|
-
]
|
|
249
|
+
]
|
|
250
|
+
.filter(Boolean)
|
|
251
|
+
.join('\n'),
|
|
209
252
|
);
|
|
210
253
|
const envelope = await runner.runStage(prompt);
|
|
211
254
|
if (envelope.exitCode !== 0) {
|
|
@@ -242,9 +285,12 @@ export async function articleStage(
|
|
|
242
285
|
`The validated curation result for the article is: ${JSON.stringify(curation)}`,
|
|
243
286
|
`The validated outline for the article is: ${JSON.stringify(outline)}`,
|
|
244
287
|
'Write the complete article as markdown, one section per outline heading. Every citation must reference one of the allowed document IDs.',
|
|
288
|
+
languageDirective(),
|
|
245
289
|
'Synthesize: the body must draw findings from across the supplied documents, compare them, and state conclusions. Never list sources one per line or produce an index of references — references are evidence, not the deliverable.',
|
|
246
290
|
'Return only a JSON object matching {"title":string,"body":string,"citations":[string]} where body is the full markdown draft and every citations entry is one of the allowed document IDs.',
|
|
247
|
-
]
|
|
291
|
+
]
|
|
292
|
+
.filter(Boolean)
|
|
293
|
+
.join('\n'),
|
|
248
294
|
);
|
|
249
295
|
const envelope = await runner.runStage(prompt);
|
|
250
296
|
if (envelope.exitCode !== 0) {
|
|
@@ -278,8 +324,11 @@ export async function polishStage(
|
|
|
278
324
|
[
|
|
279
325
|
`The drafted article is: ${JSON.stringify(article)}`,
|
|
280
326
|
'Polish the draft: preserve every heading and citation exactly, remove repetition, and tighten the prose. Do not cite any document outside the allowed IDs.',
|
|
327
|
+
languageDirective(),
|
|
281
328
|
'Return only a JSON object matching {"title":string,"body":string,"outline":string} where body is the polished markdown (headings and citations preserved) and outline is a markdown outline of the final article.',
|
|
282
|
-
]
|
|
329
|
+
]
|
|
330
|
+
.filter(Boolean)
|
|
331
|
+
.join('\n'),
|
|
283
332
|
);
|
|
284
333
|
const envelope = await runner.runStage(prompt);
|
|
285
334
|
if (envelope.exitCode !== 0) {
|