@gobing-ai/knowledge-kit 0.0.12 → 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.
Files changed (66) hide show
  1. package/dist/index.js +100 -26
  2. package/package.json +1 -1
  3. package/plugins/generations/content-gen/dist/index.js +22167 -0
  4. package/plugins/generations/content-gen/plugin.json +1 -1
  5. package/plugins/generations/core-facts-gen/dist/index.js +22048 -0
  6. package/plugins/generations/core-facts-gen/plugin.json +1 -1
  7. package/plugins/generations/daily-article-gen/dist/index.js +22022 -0
  8. package/plugins/generations/daily-article-gen/plugin.json +1 -1
  9. package/plugins/generations/dailynews-gen/dist/index.js +22324 -0
  10. package/plugins/generations/dailynews-gen/plugin.json +1 -1
  11. package/plugins/generations/episode-plan-gen/dist/index.js +22479 -0
  12. package/plugins/generations/episode-plan-gen/plugin.json +1 -1
  13. package/plugins/generations/image-gen/config.example.yaml +75 -0
  14. package/plugins/generations/image-gen/dist/index.js +22619 -0
  15. package/plugins/generations/image-gen/package.json +17 -0
  16. package/plugins/generations/image-gen/plugin.json +7 -0
  17. package/plugins/generations/image-gen/presets/formats/cover.yaml +57 -0
  18. package/plugins/generations/image-gen/presets/formats/free.yaml +46 -0
  19. package/plugins/generations/image-gen/presets/formats/illustration.yaml +48 -0
  20. package/plugins/generations/image-gen/presets/styles/clean-webapp-ui.yaml +28 -0
  21. package/plugins/generations/image-gen/presets/styles/cute.yaml +3 -0
  22. package/plugins/generations/image-gen/presets/styles/editorial.yaml +3 -0
  23. package/plugins/generations/image-gen/presets/styles/fresh.yaml +3 -0
  24. package/plugins/generations/image-gen/presets/styles/minimalist.yaml +3 -0
  25. package/plugins/generations/image-gen/presets/styles/photorealistic.yaml +3 -0
  26. package/plugins/generations/image-gen/presets/styles/sketch.yaml +3 -0
  27. package/plugins/generations/image-gen/presets/styles/technical-diagram.yaml +3 -0
  28. package/plugins/generations/image-gen/presets/styles/vibrant.yaml +3 -0
  29. package/plugins/generations/image-gen/presets/styles/warm.yaml +3 -0
  30. package/plugins/generations/image-gen/src/bytes.ts +19 -0
  31. package/plugins/generations/image-gen/src/index.ts +319 -0
  32. package/plugins/generations/image-gen/src/job.ts +143 -0
  33. package/plugins/generations/image-gen/src/paths.ts +31 -0
  34. package/plugins/generations/image-gen/src/presets.ts +344 -0
  35. package/plugins/generations/image-gen/src/providers/seedream.ts +128 -0
  36. package/plugins/generations/image-gen/src/providers/types.ts +285 -0
  37. package/plugins/generations/image-gen/tsconfig.json +8 -0
  38. package/plugins/generations/voice-gen/dist/index.js +23027 -0
  39. package/plugins/generations/voice-gen/plugin.json +1 -1
  40. package/plugins/ingestions/aihot-ingest/dist/index.js +22358 -0
  41. package/plugins/ingestions/aihot-ingest/plugin.json +1 -1
  42. package/plugins/ingestions/horizon-ingest/dist/index.js +22105 -0
  43. package/plugins/ingestions/horizon-ingest/plugin.json +1 -1
  44. package/plugins/ingestions/karakeep-local/dist/index.js +24204 -0
  45. package/plugins/ingestions/karakeep-local/plugin.json +1 -1
  46. package/plugins/ingestions/last30days-ingest/dist/index.js +22050 -0
  47. package/plugins/ingestions/last30days-ingest/plugin.json +1 -1
  48. package/plugins/ingestions/web-search/dist/index.js +24379 -0
  49. package/plugins/ingestions/web-search/plugin.json +1 -1
  50. package/plugins/kk/commands/image-generate.md +15 -0
  51. package/plugins/kk/config.example.yaml +80 -0
  52. package/plugins/kk/skills/image-authoring/SKILL.md +250 -0
  53. package/plugins/kk/skills/image-authoring/references/illustration-positions.md +87 -0
  54. package/plugins/kk/skills/image-authoring/references/migrating-from-wt.md +31 -0
  55. package/plugins/kk/skills/image-authoring/references/providers.md +52 -0
  56. package/plugins/kk/skills/image-authoring/references/style-extraction.md +134 -0
  57. package/plugins/publishings/emdash-pub/dist/index.js +22243 -0
  58. package/plugins/publishings/emdash-pub/plugin.json +1 -1
  59. package/plugins/publishings/podcast-pub/dist/index.js +22596 -0
  60. package/plugins/publishings/podcast-pub/plugin.json +8 -2
  61. package/plugins/publishings/qiita-pub/dist/index.js +22081 -0
  62. package/plugins/publishings/qiita-pub/plugin.json +1 -1
  63. package/plugins/publishings/surfdash-pub/dist/index.js +22233 -0
  64. package/plugins/publishings/surfdash-pub/plugin.json +1 -1
  65. package/plugins/publishings/zenn-pub/dist/index.js +22122 -0
  66. package/plugins/publishings/zenn-pub/plugin.json +1 -1
@@ -0,0 +1,285 @@
1
+ /**
2
+ * Task 0103 — the frozen `ImageProvider` contract: 0104 codes against it and the 12
3
+ * baoyu-derived adapters implement it. Wire-speaking adapters are later tickets; this
4
+ * file carries only the request/result types, the registry, and the selection order.
5
+ *
6
+ * Prior art: vendors/baoyu-skills/skills/baoyu-image-gen/scripts/ (MIT © 2026 Jim Liu).
7
+ * The deliberate differences from baoyu's `ProviderModule` (scripts/main.ts:15-20) —
8
+ * `ImageRequest` replaces `CliArgs`, `isAvailable()` and `supportsReferenceImages(model)`
9
+ * are new, `ImageResult` wraps the bytes — are recorded in the task Design.
10
+ */
11
+
12
+ import { createSeedream } from './seedream';
13
+
14
+ /** The two quality levels baoyu exposes (SKILL.md); every provider maps or ignores them. */
15
+ export type ImageQuality = 'normal' | '2k';
16
+
17
+ /** One generation request; a non-empty `referenceImages` means image-to-image (0105). */
18
+ export interface ImageRequest {
19
+ prompt: string;
20
+ model: string;
21
+ /** e.g. '21:9' — from FormatPreset.aspectRatio (0102). */
22
+ aspectRatio?: string;
23
+ /** Optional exact pixels; providers that only take an aspect ratio ignore them. */
24
+ width?: number;
25
+ height?: number;
26
+ quality?: ImageQuality;
27
+ /** From StylePreset.negative (0102); providers without negative prompts ignore it. */
28
+ negative?: string;
29
+ /** Absolute paths; empty or undefined = text-to-image. */
30
+ referenceImages?: string[];
31
+ /** Default 1. v1 rule: a caller wanting N images issues N calls; adapters return the first. */
32
+ n?: number;
33
+ }
34
+
35
+ /** Adapters return bytes, never paths — 0104 owns file naming and writing. */
36
+ export interface ImageResult {
37
+ bytes: Uint8Array;
38
+ /** 'png' | 'jpg' | 'webp' — the provider decides. */
39
+ extension: string;
40
+ provider: string;
41
+ model: string;
42
+ }
43
+
44
+ export interface ImageProvider {
45
+ readonly name: string;
46
+ defaultModel(): string;
47
+ /**
48
+ * Env-presence readiness — MUST NOT perform network or subprocess calls. A stale
49
+ * key still passes; it surfaces as the adapter's own auth error at generate()
50
+ * time, matching baoyu's throw-at-call-time behaviour (task Q&A, closed).
51
+ */
52
+ isAvailable(): boolean;
53
+ /** Queryable ref-image capability; 0105 routes `--ref` work on this fact. */
54
+ supportsReferenceImages(model: string): boolean;
55
+ /** Throw on an impossible combination (e.g. Imagen + referenceImages) before spending money. */
56
+ validate?(req: ImageRequest): void;
57
+ generate(req: ImageRequest): Promise<ImageResult>;
58
+ }
59
+
60
+ /** Injection seam for tests — mirrors `VoiceboxClientOptions.fetch` (voice-gen). */
61
+ export interface ProviderOptions {
62
+ fetch?: typeof fetch;
63
+ /** Environment consulted instead of process.env (tests). */
64
+ env?: Record<string, string | undefined>;
65
+ }
66
+
67
+ export type ProviderFactory = (options?: ProviderOptions) => ImageProvider;
68
+
69
+ /** Env var consulted for the provider name when no explicit request is passed (selection step 2). */
70
+ const IMAGE_GEN_PROVIDER_ENV = 'IMAGE_GEN_PROVIDER';
71
+
72
+ /** Providers that may never be auto-selected, even if listed in AUTO_ORDER later (task 0103 R3). */
73
+ const NEVER_AUTO: ReadonlySet<string> = new Set(['codex-cli']);
74
+
75
+ /** Registry row: the availability facts an adapter must honour, verbatim from its baoyu source. */
76
+ interface ProviderSpec {
77
+ readonly name: string;
78
+ /** Env vars where any one present = usable (google's `A || B` fallback chains). */
79
+ readonly env: readonly string[];
80
+ /** Env vars where every one must be present (jimeng's access/secret key pair). */
81
+ readonly envAll?: readonly string[];
82
+ readonly defaultModel: string;
83
+ /** Model fragments that accept reference images; omit = every model does; empty = none. */
84
+ readonly refModels?: readonly string[];
85
+ /** Replaces the missing-credential text when readiness is not an env var (codex-cli). */
86
+ readonly note?: string;
87
+ }
88
+
89
+ type ProviderRegistration = ProviderSpec & { readonly create: ProviderFactory };
90
+
91
+ /**
92
+ * Env-only shell: makes the frozen registry executable (`isAvailable` /
93
+ * `supportsReferenceImages` answer from the inventory facts) before the adapter tickets
94
+ * land; `generate` throws until then. An adapter ticket replaces `create` with the real
95
+ * wire-speaking factory. A spec with no env criteria (codex-cli) reports not-ready — its
96
+ * readiness (codex on PATH) is not env-expressible.
97
+ */
98
+ function envOnlyProvider(spec: ProviderSpec): ProviderFactory {
99
+ return (options) => ({
100
+ name: spec.name,
101
+ defaultModel: () => spec.defaultModel,
102
+ isAvailable: () => {
103
+ const env = options?.env ?? process.env;
104
+ const present = (key: string): boolean => (env[key] ?? '') !== '';
105
+ const anyOf = spec.env.length > 0 ? spec.env.some(present) : spec.envAll !== undefined;
106
+ return anyOf && (spec.envAll ?? []).every(present);
107
+ },
108
+ supportsReferenceImages: (model) =>
109
+ spec.refModels === undefined ? true : spec.refModels.some((fragment) => model.includes(fragment)),
110
+ generate: () => {
111
+ throw new Error(`Provider '${spec.name}' has no adapter yet (feature K phase plan, task 0103 Design).`);
112
+ },
113
+ });
114
+ }
115
+
116
+ function defineProvider(spec: ProviderSpec): ProviderRegistration {
117
+ return { ...spec, create: envOnlyProvider(spec) };
118
+ }
119
+
120
+ /** The 12 baoyu adapters, one row each (task 0103 R1 inventory). Keys sorted alphabetically. */
121
+ export const PROVIDERS: Readonly<Record<string, ProviderRegistration>> = {
122
+ agnes: defineProvider({
123
+ name: 'agnes',
124
+ env: ['AGNES_API_KEY'],
125
+ defaultModel: 'agnes-image-2.1-flash',
126
+ }),
127
+ azure: defineProvider({
128
+ name: 'azure',
129
+ env: ['AZURE_OPENAI_API_KEY'],
130
+ defaultModel: 'gpt-image-2',
131
+ }),
132
+ 'codex-cli': defineProvider({
133
+ name: 'codex-cli',
134
+ env: [],
135
+ defaultModel: 'codex-image-gen',
136
+ note: "requires the 'codex' CLI on PATH with an active login (never auto-selected)",
137
+ }),
138
+ dashscope: defineProvider({
139
+ name: 'dashscope',
140
+ env: ['DASHSCOPE_API_KEY'],
141
+ defaultModel: 'qwen-image-2.0-pro',
142
+ refModels: ['wan2.7'],
143
+ }),
144
+ google: defineProvider({
145
+ name: 'google',
146
+ env: ['GOOGLE_API_KEY', 'GEMINI_API_KEY'],
147
+ defaultModel: 'gemini-3-pro-image',
148
+ refModels: [
149
+ 'gemini-3-pro-image',
150
+ 'gemini-3.1-flash-image',
151
+ 'gemini-3-pro-image-preview',
152
+ 'gemini-3-flash-preview',
153
+ 'gemini-3.1-flash-image-preview',
154
+ ],
155
+ }),
156
+ jimeng: defineProvider({
157
+ name: 'jimeng',
158
+ env: [],
159
+ envAll: ['JIMENG_ACCESS_KEY_ID', 'JIMENG_SECRET_ACCESS_KEY'],
160
+ defaultModel: 'jimeng_t2i_v40',
161
+ }),
162
+ minimax: defineProvider({
163
+ name: 'minimax',
164
+ env: ['MINIMAX_API_KEY'],
165
+ defaultModel: 'image-01',
166
+ }),
167
+ openai: defineProvider({
168
+ name: 'openai',
169
+ env: ['OPENAI_API_KEY'],
170
+ defaultModel: 'gpt-image-2',
171
+ refModels: ['gpt-image'],
172
+ }),
173
+ openrouter: defineProvider({
174
+ name: 'openrouter',
175
+ env: ['OPENROUTER_API_KEY'],
176
+ defaultModel: 'google/gemini-3.1-flash-image',
177
+ }),
178
+ replicate: defineProvider({
179
+ name: 'replicate',
180
+ env: ['REPLICATE_API_TOKEN'],
181
+ defaultModel: 'google/nano-banana-2',
182
+ }),
183
+ seedream: {
184
+ name: 'seedream',
185
+ env: ['ARK_API_KEY'],
186
+ defaultModel: 'doubao-seedream-5-0-260128',
187
+ refModels: ['doubao-seedream-5-0', 'doubao-seedream-4-5-', 'doubao-seedream-4-0-'],
188
+ // 0107: the first wire-speaking adapter — replaces the envOnly shell.
189
+ create: createSeedream,
190
+ },
191
+ zai: defineProvider({
192
+ name: 'zai',
193
+ env: ['ZAI_API_KEY', 'BIGMODEL_API_KEY'],
194
+ defaultModel: 'glm-image',
195
+ refModels: [],
196
+ }),
197
+ };
198
+
199
+ /** Frozen auto-selection priority (task 0103 Design). `codex-cli` is absent on purpose. */
200
+ export const AUTO_ORDER = [
201
+ 'google',
202
+ 'openai',
203
+ 'replicate',
204
+ 'openrouter',
205
+ 'dashscope',
206
+ 'seedream',
207
+ 'zai',
208
+ 'minimax',
209
+ 'jimeng',
210
+ 'azure',
211
+ 'agnes',
212
+ ] as const;
213
+
214
+ /** Human-readable readiness requirement for one registry row. */
215
+ function envSummary(reg: ProviderRegistration): string {
216
+ if (reg.note !== undefined) {
217
+ return reg.note;
218
+ }
219
+ // env entries are any-of alternatives (' or '); envAll entries are all-required (' and ');
220
+ // the two groups are both required when present (' and ' across groups).
221
+ const groups: string[] = [];
222
+ if (reg.env.length > 0) groups.push(reg.env.join(' or '));
223
+ if (reg.envAll !== undefined && reg.envAll.length > 0) groups.push(reg.envAll.join(' and '));
224
+ return groups.join(' and ');
225
+ }
226
+
227
+ function notConfiguredMessage(reg: ProviderRegistration): string {
228
+ if (reg.note !== undefined) {
229
+ return `Provider '${reg.name}' is not available: ${reg.note}`;
230
+ }
231
+ return `Provider '${reg.name}' is not configured: missing ${envSummary(reg)} (set it in plugins.generations.image-gen.env or process.env)`;
232
+ }
233
+
234
+ /**
235
+ * Resolve which provider name a generation job uses. First match wins:
236
+ * 1. `requested` — an explicit name from the job input; unknown throws listing all 12
237
+ * valid names, known-but-unconfigured throws naming the missing env var (no silent
238
+ * downgrade: that would change what the operator paid for).
239
+ * 2. `IMAGE_GEN_PROVIDER` in the environment, same two failure rules.
240
+ * 3. The first name in AUTO_ORDER whose provider `isAvailable()`.
241
+ * 4. Nothing available → throw listing every provider with what each one needs.
242
+ */
243
+ export function selectProvider(
244
+ requested?: string,
245
+ options?: {
246
+ /** Environment consulted instead of process.env (tests). */
247
+ env?: Record<string, string | undefined>;
248
+ /** Availability override; default asks the registered provider's isAvailable(). */
249
+ isAvailable?: (name: string) => boolean;
250
+ },
251
+ ): string {
252
+ const env = options?.env ?? process.env;
253
+ const available =
254
+ options?.isAvailable ??
255
+ ((name: string): boolean => {
256
+ const reg = PROVIDERS[name];
257
+ return reg?.create({ env }).isAvailable() ?? false;
258
+ });
259
+ const names = Object.keys(PROVIDERS).sort();
260
+
261
+ const explicit = requested ?? env[IMAGE_GEN_PROVIDER_ENV];
262
+ if (explicit !== undefined && explicit !== '') {
263
+ const reg = PROVIDERS[explicit];
264
+ if (reg === undefined) {
265
+ throw new Error(`Unknown image provider '${explicit}'. Valid providers: ${names.join(', ')}`);
266
+ }
267
+ if (!available(reg.name)) {
268
+ throw new Error(notConfiguredMessage(reg));
269
+ }
270
+ return reg.name;
271
+ }
272
+
273
+ for (const name of AUTO_ORDER) {
274
+ if (!NEVER_AUTO.has(name) && available(name)) {
275
+ return name;
276
+ }
277
+ }
278
+ const wanted = names
279
+ .map((name) => {
280
+ const reg = PROVIDERS[name];
281
+ return reg === undefined ? name : `${name}: ${envSummary(reg)}`;
282
+ })
283
+ .join('; ');
284
+ throw new Error(`No image provider is configured. Credentials wanted — ${wanted}`);
285
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../../tooling/typescript/base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist"
6
+ },
7
+ "include": ["src/**/*"]
8
+ }