@gobing-ai/knowledge-kit 0.1.17 → 0.1.20
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/.claude-plugin/marketplace.json +1 -1
- package/dist/board/daily-voice/index.js +40 -7
- package/dist/index.js +8428 -4448
- package/package.json +1 -1
- package/plugins/generations/image-gen/README.md +31 -31
- package/plugins/generations/image-gen/assets/sample/provenance.json +314 -0
- package/plugins/generations/image-gen/config.example.yaml +3 -0
- package/plugins/generations/image-gen/dist/index.js +154 -14
- package/plugins/generations/image-gen/presets/SOURCE.md +65 -0
- package/plugins/generations/image-gen/scripts/eval-style-presets.ts +513 -0
- package/plugins/generations/image-gen/scripts/gen-samples.ts +57 -7
- package/plugins/generations/image-gen/src/presets.ts +6 -5
- package/plugins/generations/image-gen/src/providers/h3-local.ts +196 -0
- package/plugins/generations/image-gen/src/providers/types.ts +11 -1
- package/plugins/kk/config.example.yaml +7 -2
- package/plugins/kk/decisions/extract/ai-news.yaml +5 -2
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/chinese-article.json +8 -2
- package/plugins/kk/publish-presets/daily-ai-voice-migration.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +57 -16
- package/plugins/kk/publish-presets/itc-main.json +36 -9
- package/plugins/kk/publish-presets/technical-article.json +8 -2
- package/plugins/kk/schedules/kk-daily-ai-voice3.cron.tmpl +8 -9
- package/plugins/kk/schedules/kk-daily-publish3-cn-peak.cron.tmpl +13 -19
- package/plugins/kk/schedules/kk-daily-publish3-overseas.cron.tmpl +11 -9
- package/plugins/kk/scripts/daily-stages.ts +238 -14
- package/plugins/kk/scripts/daily-triage-core.ts +43 -25
- package/plugins/kk/scripts/daily-triage.ts +1 -1
- package/plugins/kk/skills/image-authoring/SKILL.md +7 -3
- package/plugins/kk/skills/image-authoring/references/providers.md +27 -0
- package/plugins/kk/skills/image-authoring/references/style-extraction.md +1 -1
- package/plugins/kk/skills/publish/SKILL.md +15 -2
- package/plugins/kk/skills/web-automation/SKILL.md +31 -1
- package/plugins/kk/workflows/kk-article-generate.yaml +485 -0
- package/plugins/kk/workflows/kk-collect.yaml +8 -4
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +2 -1
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +4 -2
- package/plugins/kk/workflows/kk-daily-safety.yaml +5 -7
- package/plugins/kk/workflows/kk-news-generate.yaml +410 -0
- package/plugins/kk/workflows/kk-publish.yaml +236 -0
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +49 -10
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/csdn-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/infoq-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/jike-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/juejin-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/linkedin-pub/dist/index.js +43 -6
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +92 -15
- package/plugins/publishings/linkedin-pub/src/index.ts +52 -6
- package/plugins/publishings/shipinhao-pub/dist/index.js +391 -32
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +52 -11
- package/plugins/publishings/shipinhao-pub/plugin.json +1 -1
- package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +393 -0
- package/plugins/publishings/shipinhao-pub/src/flow.ts +243 -14
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -0
- package/plugins/publishings/sspai-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/substack-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/surfdash-pub/dist/index.js +50 -8
- package/plugins/publishings/surfdash-pub/src/index.ts +59 -8
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +34 -3
- package/plugins/publishings/threads-pub/dist/index.js +9196 -296
- package/plugins/publishings/threads-pub/dist/profile-check.js +21139 -0
- package/plugins/publishings/threads-pub/package.json +3 -1
- package/plugins/publishings/threads-pub/plugin.json +6 -1
- package/plugins/publishings/threads-pub/src/index.ts +8 -1
- package/plugins/publishings/threads-pub/src/post-rail.ts +357 -0
- package/plugins/publishings/threads-pub/src/profile-check.ts +17 -0
- package/plugins/publishings/wechatmp-pub/dist/index.js +454 -81
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +401 -102
- package/plugins/publishings/wechatmp-pub/src/flow.ts +42 -4
- package/plugins/publishings/wechatmp-pub/src/index.ts +142 -102
- package/plugins/publishings/wechatmp-pub/src/profile-check.ts +36 -58
- package/plugins/publishings/weibo-pub/dist/index.js +136 -22
- package/plugins/publishings/weibo-pub/dist/profile-check.js +61 -11
- package/plugins/publishings/weibo-pub/src/index.ts +208 -22
- package/plugins/publishings/x-pub/dist/index.js +263 -43
- package/plugins/publishings/x-pub/dist/profile-check.js +63 -11
- package/plugins/publishings/x-pub/src/index.ts +15 -1
- package/plugins/publishings/x-pub/src/post-rail.ts +334 -0
- package/plugins/publishings/xhs-pub/dist/index.js +193 -201
- package/plugins/publishings/xhs-pub/dist/profile-check.js +380 -85
- package/plugins/publishings/xhs-pub/src/automation-guard.ts +2 -3
- package/plugins/publishings/xhs-pub/src/flow.ts +177 -205
- package/plugins/publishings/xhs-pub/src/index.ts +65 -59
- package/plugins/publishings/xhs-pub/src/modes.ts +1 -1
- package/plugins/publishings/xhs-pub/src/page.ts +2 -2
- package/plugins/publishings/xhs-pub/src/profile-check.ts +86 -150
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +60 -10
- package/plugins/kk/scripts/daily-scheduled-run.ts +0 -581
- package/plugins/kk/scripts/voice3-publish-window.ts +0 -206
- package/plugins/kk/workflows/kk-daily-ai-voice3.yaml +0 -903
- package/plugins/kk/workflows/kk-daily-publish3.yaml +0 -353
- package/plugins/kk/workflows/kk-itc-author.yaml +0 -484
- package/plugins/kk/workflows/kk-itc-publish-tail.yaml +0 -112
- package/plugins/kk/workflows/kk-itc.yaml +0 -291
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
/**
|
|
3
|
-
* voice3-publish-window — cron-safe launcher for the voice3 shadow publish window (task 0334).
|
|
4
|
-
*
|
|
5
|
-
* WHY a launcher (audit F08/F09/F10, docs/design/kk-daily-ai-voice3.md):
|
|
6
|
-
* - cron ends a command at the first UNESCAPED % and feeds the rest to stdin, so any inline
|
|
7
|
-
* `$(date +%Y%m%d)` shell in a crontab entry silently truncates the command. Date math and
|
|
8
|
-
* flag assembly live here, in plain TypeScript, behind zero percent signs.
|
|
9
|
-
* - the publish window must read the GENERATION bundle (`<works>/kk-daily-ai-voice2/<date>/
|
|
10
|
-
* bundle.json` — voice3 prepares under the voice2 namespace until the operator's cutover
|
|
11
|
-
* changes it), never the publish3 output directory that earlier entries pointed at.
|
|
12
|
-
* - the CN consent token list is validated against the pinned preset's WINDOW rows before any
|
|
13
|
-
* spur process starts; the old baked `wechatmp-pub,xhs-pub,…` list (tokens that have no
|
|
14
|
-
* cn-peak row) is refused up front.
|
|
15
|
-
*
|
|
16
|
-
* Contract: everything before `spur workflow run plugins/kk/workflows/kk-daily-publish3.yaml`
|
|
17
|
-
* is preparation and refusal; the only side effects are refusal messages and, on success, the
|
|
18
|
-
* single spur exec. `KK_SPUR_BIN` pins the spur binary (same convention as board/capture.ts and
|
|
19
|
-
* decision-hub.ts); `--dry-run` prints the forwarded vars and stops (rehearsal aid).
|
|
20
|
-
*/
|
|
21
|
-
import { spawnSync } from 'node:child_process';
|
|
22
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
23
|
-
import { homedir } from 'node:os';
|
|
24
|
-
import { dirname, join, resolve } from 'node:path';
|
|
25
|
-
import { fileURLToPath } from 'node:url';
|
|
26
|
-
|
|
27
|
-
const USAGE =
|
|
28
|
-
'usage: voice3-publish-window.ts --window <after-generate|cn-peak|overseas-rss> [--run-date <YYYY-MM-DD|YYYYMMDD>] ' +
|
|
29
|
-
'[--preset <slug>] [--live-channels a,b] [--live-confirm true] [--work-dir <dir>] [--dummy] [--dry-run]';
|
|
30
|
-
|
|
31
|
-
const WINDOWS = new Set(['after-generate', 'cn-peak', 'overseas-rss']);
|
|
32
|
-
|
|
33
|
-
function failWith(code: number, message: string): never {
|
|
34
|
-
console.error(message);
|
|
35
|
-
process.exit(code);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function expandHome(raw: string): string {
|
|
39
|
-
return raw === '~' || raw.startsWith('~/') ? join(homedir(), raw.slice(1)) : raw;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** KK_WORKS_DIR env > config works_dir > <cwd>/.works — the kk-workflow-stages precedence. */
|
|
43
|
-
function resolveWorksDir(): string {
|
|
44
|
-
const fromEnv = process.env.KK_WORKS_DIR;
|
|
45
|
-
if (fromEnv) return expandHome(fromEnv);
|
|
46
|
-
const configPath = process.env.KK_CONFIG || join(homedir(), '.config/kk/config.yaml');
|
|
47
|
-
if (existsSync(configPath)) {
|
|
48
|
-
try {
|
|
49
|
-
const parsed = Bun.YAML.parse(readFileSync(configPath, 'utf-8')) as Record<string, unknown> | null;
|
|
50
|
-
const worksDir = parsed !== null && typeof parsed === 'object' ? parsed.works_dir : undefined;
|
|
51
|
-
if (typeof worksDir === 'string' && worksDir !== '') return expandHome(worksDir);
|
|
52
|
-
} catch {
|
|
53
|
-
// fall through to the compiled default
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return resolve(process.cwd(), '.works');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** A real calendar day as `YYYY-MM-DD`, or undefined (mirrors publish-matrix normalizeRunDate). */
|
|
60
|
-
function normalizeRunDate(raw: string): string | undefined {
|
|
61
|
-
const match = /^(\d{4})-?(\d{2})-?(\d{2})$/.exec(raw.trim());
|
|
62
|
-
if (match === null) return undefined;
|
|
63
|
-
const iso = `${match[1]}-${match[2]}-${match[3]}`;
|
|
64
|
-
const parsed = new Date(`${iso}T00:00:00Z`);
|
|
65
|
-
if (
|
|
66
|
-
Number.isNaN(parsed.getTime()) ||
|
|
67
|
-
parsed.getUTCFullYear() !== Number(match[1]) ||
|
|
68
|
-
parsed.getUTCMonth() + 1 !== Number(match[2]) ||
|
|
69
|
-
parsed.getUTCDate() !== Number(match[3])
|
|
70
|
-
) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
return iso;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** Today (offset 0) or yesterday (offset -1) in America/Los_Angeles — the episodes' own day. */
|
|
77
|
-
function losAngelesDate(offsetDays: number): string {
|
|
78
|
-
const instant = new Date(Date.now() + offsetDays * 24 * 60 * 60 * 1000);
|
|
79
|
-
// en-CA renders YYYY-MM-DD; Intl does the zone math cron cannot do inline.
|
|
80
|
-
return new Intl.DateTimeFormat('en-CA', { timeZone: 'America/Los_Angeles' }).format(instant);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** `--flag value`, or undefined. */
|
|
84
|
-
function flagValue(args: string[], flag: string): string | undefined {
|
|
85
|
-
const index = args.indexOf(flag);
|
|
86
|
-
return index >= 0 ? args[index + 1] : undefined;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function main(): void {
|
|
90
|
-
const args = process.argv.slice(2);
|
|
91
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
92
|
-
console.log(USAGE);
|
|
93
|
-
process.exit(0);
|
|
94
|
-
}
|
|
95
|
-
const window = flagValue(args, '--window');
|
|
96
|
-
if (window === undefined || !WINDOWS.has(window))
|
|
97
|
-
failWith(1, `${USAGE}\nvoice3-publish-window: --window must be one of ${[...WINDOWS].join('|')}`);
|
|
98
|
-
const dummy = args.includes('--dummy');
|
|
99
|
-
// ADR-022 amendment 2026-11-12: the preset's own rows carry live consent, so the send-confirm
|
|
100
|
-
// pause is opt-in. `--live-confirm true` restores it for a supervised one-off window.
|
|
101
|
-
const liveConfirm = (flagValue(args, '--live-confirm') ?? 'false').trim() === 'true';
|
|
102
|
-
const dryRun = args.includes('--dry-run');
|
|
103
|
-
const preset = flagValue(args, '--preset');
|
|
104
|
-
const liveChannelsRaw = flagValue(args, '--live-channels');
|
|
105
|
-
const workDirOverride = flagValue(args, '--work-dir');
|
|
106
|
-
|
|
107
|
-
// R1: run date = explicit flag, else window-derived LA day (overseas reads the episode that
|
|
108
|
-
// landed after the 07:00 tick, i.e. yesterday).
|
|
109
|
-
const runDateRaw = flagValue(args, '--run-date');
|
|
110
|
-
let runDate: string | undefined;
|
|
111
|
-
if (runDateRaw !== undefined && runDateRaw.trim() !== '') {
|
|
112
|
-
runDate = normalizeRunDate(runDateRaw);
|
|
113
|
-
if (runDate === undefined)
|
|
114
|
-
failWith(1, `voice3-publish-window: '${runDateRaw}' is not a valid calendar day (YYYY-MM-DD or YYYYMMDD)`);
|
|
115
|
-
} else {
|
|
116
|
-
runDate = losAngelesDate(window === 'overseas-rss' ? -1 : 0);
|
|
117
|
-
}
|
|
118
|
-
const digits = runDate.replaceAll('-', '');
|
|
119
|
-
|
|
120
|
-
if (dummy && liveChannelsRaw !== undefined) {
|
|
121
|
-
failWith(1, 'voice3-publish-window: --dummy and --live-channels are mutually exclusive');
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// R3/F10: live tokens validate against the pinned preset's WINDOW rows before any spawn.
|
|
125
|
-
const liveChannels =
|
|
126
|
-
liveChannelsRaw !== undefined && liveChannelsRaw.trim() !== ''
|
|
127
|
-
? liveChannelsRaw
|
|
128
|
-
.split(',')
|
|
129
|
-
.map((token) => token.trim())
|
|
130
|
-
.filter((token) => token !== '')
|
|
131
|
-
: [];
|
|
132
|
-
if (liveChannels.length > 0 && preset === undefined) {
|
|
133
|
-
failWith(1, 'voice3-publish-window: --live-channels requires an explicit --preset to validate the window');
|
|
134
|
-
}
|
|
135
|
-
if (liveChannels.length > 0) {
|
|
136
|
-
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
|
137
|
-
const presetPath = join(dirname(scriptDir), 'publish-presets', `${preset}.json`);
|
|
138
|
-
if (!existsSync(presetPath))
|
|
139
|
-
failWith(1, `voice3-publish-window: preset '${preset}' not found at ${presetPath}`);
|
|
140
|
-
const parsed = JSON.parse(readFileSync(presetPath, 'utf-8')) as {
|
|
141
|
-
targets?: Array<{ plugin: string; id?: string; mode?: string; window?: string }>;
|
|
142
|
-
};
|
|
143
|
-
const targets = parsed.targets ?? [];
|
|
144
|
-
const inWindow = targets.filter((target) => (target.window ?? 'after-generate') === window);
|
|
145
|
-
const refused = liveChannels.filter((token) => {
|
|
146
|
-
const row = inWindow.find((target) => target.plugin === token || target.id === token);
|
|
147
|
-
return row === undefined || (row.mode ?? 'draft') === 'off';
|
|
148
|
-
});
|
|
149
|
-
if (refused.length > 0) {
|
|
150
|
-
failWith(
|
|
151
|
-
1,
|
|
152
|
-
`voice3-publish-window: live token(s) ${refused.join(', ')} have no active row in window '${window}' of preset '${preset}'` +
|
|
153
|
-
` (send-confirm resumes are consent-scoped per window; see docs/design/kk-daily-ai-voice3.md)`,
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// R1/F08: the bundle is the GENERATION artifact under the voice2 namespace, never a publish3
|
|
159
|
-
// output dir. Mismatched/missing bundles refuse before spur starts.
|
|
160
|
-
const genDir =
|
|
161
|
-
workDirOverride !== undefined && workDirOverride.trim() !== ''
|
|
162
|
-
? resolve(workDirOverride)
|
|
163
|
-
: join(resolveWorksDir(), 'kk-daily-ai-voice2', digits);
|
|
164
|
-
const bundlePath = join(genDir, 'bundle.json');
|
|
165
|
-
if (!existsSync(bundlePath)) failWith(1, `voice3-publish-window: no generation bundle at ${bundlePath}`);
|
|
166
|
-
let bundleRunDate: string | undefined;
|
|
167
|
-
try {
|
|
168
|
-
const bundle = JSON.parse(readFileSync(bundlePath, 'utf-8')) as { runDate?: string };
|
|
169
|
-
bundleRunDate = typeof bundle.runDate === 'string' ? normalizeRunDate(bundle.runDate) : undefined;
|
|
170
|
-
} catch {
|
|
171
|
-
failWith(1, `voice3-publish-window: unreadable generation bundle at ${bundlePath}`);
|
|
172
|
-
}
|
|
173
|
-
if (bundleRunDate !== runDate) {
|
|
174
|
-
failWith(
|
|
175
|
-
1,
|
|
176
|
-
`voice3-publish-window: bundle at ${bundlePath} is dated ${bundleRunDate ?? 'unknown'}, not the requested ${runDate}`,
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const vars: Record<string, string> = {
|
|
181
|
-
work_dir: genDir,
|
|
182
|
-
run_date: digits,
|
|
183
|
-
window,
|
|
184
|
-
};
|
|
185
|
-
if (preset !== undefined && preset.trim() !== '') vars.preset = preset;
|
|
186
|
-
if (liveChannels.length > 0) vars.live_channels = liveChannels.join(',');
|
|
187
|
-
if (dummy) vars.dummy = 'true';
|
|
188
|
-
if (liveConfirm) vars.live_confirm = 'true';
|
|
189
|
-
|
|
190
|
-
if (dryRun) {
|
|
191
|
-
console.log(JSON.stringify(vars, null, 2));
|
|
192
|
-
process.exit(0);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const proc = spawnSync(
|
|
196
|
-
process.env.KK_SPUR_BIN || 'spur',
|
|
197
|
-
['workflow', 'run', 'plugins/kk/workflows/kk-daily-publish3.yaml', '--vars', JSON.stringify(vars)],
|
|
198
|
-
{
|
|
199
|
-
stdio: 'inherit',
|
|
200
|
-
},
|
|
201
|
-
);
|
|
202
|
-
// node spawnSync surfaces the child's code as `status` (exitCode is the async-API field).
|
|
203
|
-
process.exit(proc.status ?? 1);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
main();
|