@gobing-ai/knowledge-kit 0.0.28 → 0.0.30

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 (97) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +114 -38
  3. package/package.json +1 -1
  4. package/plugins/generations/daily-article-gen/dist/index.js +45 -5
  5. package/plugins/generations/daily-article-gen/src/index.ts +59 -4
  6. package/plugins/generations/dailynews-gen/dist/index.js +46 -9
  7. package/plugins/generations/dailynews-gen/src/index.ts +36 -1
  8. package/plugins/generations/dailynews-gen/src/script-builder.ts +15 -12
  9. package/plugins/generations/dailynews-gen/src/script-plan.ts +21 -3
  10. package/plugins/generations/episode-plan-gen/dist/index.js +55 -4
  11. package/plugins/generations/episode-plan-gen/src/index.ts +80 -2
  12. package/plugins/generations/image-gen/assets/fonts/NotoSansSC-Bold.otf +0 -0
  13. package/plugins/generations/image-gen/assets/fonts/NotoSansSC-Regular.otf +0 -0
  14. package/plugins/generations/image-gen/assets/fonts/OFL.txt +92 -0
  15. package/plugins/generations/image-gen/assets/fonts/SOURCE.md +15 -0
  16. package/plugins/generations/image-gen/dist/index.js +700 -22
  17. package/plugins/generations/image-gen/package.json +1 -0
  18. package/plugins/generations/image-gen/presets/formats/daily-news-cover.yaml +2 -2
  19. package/plugins/generations/image-gen/presets/formats/xhs-card.yaml +19 -11
  20. package/plugins/generations/image-gen/presets/styles/xhs-knowledge.yaml +2 -1
  21. package/plugins/generations/image-gen/scripts/compose-e2e-artifact.ts +135 -0
  22. package/plugins/generations/image-gen/src/bytes.ts +116 -0
  23. package/plugins/generations/image-gen/src/compose/card.ts +294 -0
  24. package/plugins/generations/image-gen/src/compose/chromium.ts +147 -0
  25. package/plugins/generations/image-gen/src/compose/cmap.ts +177 -0
  26. package/plugins/generations/image-gen/src/index.ts +211 -13
  27. package/plugins/generations/image-gen/src/job.ts +12 -0
  28. package/plugins/generations/image-gen/src/presets.ts +53 -13
  29. package/plugins/generations/image-gen/src/providers/minimax.ts +12 -4
  30. package/plugins/generations/image-gen/src/providers/types.ts +12 -1
  31. package/plugins/kk/plugin.json +1 -1
  32. package/plugins/kk/scripts/daily-voice-style.zh.md +27 -14
  33. package/plugins/kk/scripts/itc-stages.ts +21 -3
  34. package/plugins/kk/scripts/kk-workflow-stages.ts +461 -10
  35. package/plugins/kk/scripts/topic-boundary.json +96 -0
  36. package/plugins/kk/scripts/validate-voicescript.ts +15 -0
  37. package/plugins/kk/skills/content-judge/SKILL.md +30 -0
  38. package/plugins/kk/skills/content-judge/references/workflow-integration.md +9 -2
  39. package/plugins/kk/skills/content-safety/SKILL.md +163 -0
  40. package/plugins/kk/skills/content-safety/references/platforms/apple-podcasts.md +36 -0
  41. package/plugins/kk/skills/content-safety/references/platforms/netease-music.md +31 -0
  42. package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +32 -0
  43. package/plugins/kk/skills/content-safety/references/platforms/xiaoyuzhou.md +35 -0
  44. package/plugins/kk/skills/publish/SKILL.md +1 -1
  45. package/plugins/kk/skills/xhs-images/SKILL.md +11 -7
  46. package/plugins/kk/skills/xhs-images/references/card-layouts.md +4 -4
  47. package/plugins/kk/workflows/judge-gated-publish-example.yaml +18 -10
  48. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +139 -24
  49. package/plugins/kk/workflows/kk-itc.yaml +21 -8
  50. package/plugins/publishings/podcast-pub/dist/index.js +4 -0
  51. package/plugins/publishings/podcast-pub/src/index.ts +2 -0
  52. package/plugins/publishings/podcast-pub/src/show-notes.ts +6 -0
  53. package/plugins/publishings/xhs-pub/dist/index.js +1 -1
  54. package/plugins/publishings/xhs-pub/src/automation-guard.ts +2 -2
  55. package/plugins/publishings/xhs-pub/src/index.ts +1 -1
  56. package/plugins/publishings/xhs-pub/src/profile-check.ts +2 -2
  57. package/plugins/sp/lib/env.ts +0 -46
  58. package/plugins/sp/lib/inline-run.generated.mjs +0 -1489
  59. package/plugins/sp/scripts/batch-preflight.mjs +0 -346
  60. package/plugins/sp/scripts/batch-preflight.ts +0 -459
  61. package/plugins/sp/scripts/daily-summary/daily-summary.mjs +0 -615
  62. package/plugins/sp/scripts/daily-summary/daily-summary.ts +0 -846
  63. package/plugins/sp/scripts/daily-summary/logger.ts +0 -28
  64. package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.mjs +0 -223
  65. package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts +0 -367
  66. package/plugins/sp/scripts/dogfood-testing/validate-report.mjs +0 -132
  67. package/plugins/sp/scripts/dogfood-testing/validate-report.ts +0 -169
  68. package/plugins/sp/scripts/feature-dev-precheck.mjs +0 -171
  69. package/plugins/sp/scripts/feature-dev-precheck.ts +0 -238
  70. package/plugins/sp/scripts/feature-sync-bounded.mjs +0 -285
  71. package/plugins/sp/scripts/feature-sync-bounded.ts +0 -478
  72. package/plugins/sp/scripts/feature-verification-steps.ts +0 -275
  73. package/plugins/sp/scripts/history-anatomy-cache.mjs +0 -902
  74. package/plugins/sp/scripts/history-anatomy-cache.ts +0 -1028
  75. package/plugins/sp/scripts/idea-handoff.mjs +0 -22
  76. package/plugins/sp/scripts/idea-handoff.ts +0 -44
  77. package/plugins/sp/scripts/inline-pipeline-parity-check.ts +0 -185
  78. package/plugins/sp/scripts/inline-run-setup.ts +0 -722
  79. package/plugins/sp/scripts/pr-reviewing.mjs +0 -769
  80. package/plugins/sp/scripts/pr-reviewing.ts +0 -925
  81. package/plugins/sp/scripts/quality-gate.mjs +0 -179
  82. package/plugins/sp/scripts/quality-gate.ts +0 -217
  83. package/plugins/sp/scripts/script-contract-check.ts +0 -319
  84. package/plugins/sp/scripts/stage-registry-adapter.ts +0 -1533
  85. package/plugins/sp/scripts/surface-drift-inventory.ts +0 -929
  86. package/plugins/sp/scripts/task-evidence-precheck.ts +0 -181
  87. package/plugins/sp/scripts/task-size-precheck.ts +0 -175
  88. package/plugins/sp/scripts/transition-shim-check.ts +0 -238
  89. package/plugins/sp/scripts/validate-commands.ts +0 -689
  90. package/plugins/sp/scripts/validate-flag-contracts.ts +0 -878
  91. package/plugins/sp/scripts/verify-answer-lint.ts +0 -530
  92. package/plugins/sp/scripts/workflow-step-profile.mjs +0 -316
  93. package/plugins/sp/scripts/workflow-step-profile.ts +0 -456
  94. package/plugins/sp/scripts/wrapup-drift-probe.mjs +0 -190
  95. package/plugins/sp/scripts/wrapup-drift-probe.ts +0 -258
  96. package/plugins/sp/scripts/wrapup-steps.mjs +0 -444
  97. package/plugins/sp/scripts/wrapup-steps.ts +0 -552
@@ -1,316 +0,0 @@
1
- #!/usr/bin/env node
2
- // @bun
3
-
4
- // plugins/sp/scripts/workflow-step-profile.ts
5
- import { spawnSync } from 'node:child_process';
6
- import { existsSync } from 'node:fs';
7
- import { fileURLToPath } from 'node:url';
8
-
9
- var DEFAULT_LAST = 20;
10
- var DEFAULT_WINDOW_SEC = 300;
11
- function nearestRankP50(values) {
12
- if (values.length === 0) return null;
13
- const sorted = [...values].sort((a, b) => a - b);
14
- return sorted[Math.ceil(sorted.length / 2) - 1] ?? null;
15
- }
16
- function numeric(value) {
17
- return typeof value === 'number' && Number.isFinite(value) ? value : null;
18
- }
19
- function msBetween(from, to) {
20
- if (typeof from !== 'string' || typeof to !== 'string') return null;
21
- const start = Date.parse(from);
22
- const end = Date.parse(to);
23
- if (!Number.isFinite(start) || !Number.isFinite(end)) return null;
24
- return end - start;
25
- }
26
- function sessionOf(event) {
27
- const value = event.invocation?.continue;
28
- if (value === true) return 'resumed';
29
- if (value === false) return 'fresh';
30
- return null;
31
- }
32
- function cacheHitOf(event) {
33
- return numeric(event.cost?.exact?.cacheHit);
34
- }
35
- function startKey(event) {
36
- const parsed = typeof event.startedAt === 'string' ? Date.parse(event.startedAt) : Number.NaN;
37
- return Number.isFinite(parsed) ? parsed : Number.POSITIVE_INFINITY;
38
- }
39
- function extractExecutions(runId, events) {
40
- const actions = events
41
- .filter((e) => e.kind === 'action')
42
- .sort((a, b) => {
43
- const left = startKey(a);
44
- const right = startKey(b);
45
- return left === right ? 0 : left - right;
46
- });
47
- const executions = [];
48
- for (const [index, event] of actions.entries()) {
49
- const previous = index === 0 ? undefined : actions[index - 1];
50
- executions.push({
51
- runId,
52
- node: event.node ?? '',
53
- actionKind: event.actionKind ?? '',
54
- durationMs: numeric(event.durationMs),
55
- idleGapMs: msBetween(previous?.completedAt, event.startedAt),
56
- session: sessionOf(event),
57
- cacheHit: cacheHitOf(event),
58
- });
59
- }
60
- return executions;
61
- }
62
- function foldSession(executions) {
63
- const known = new Set(executions.map((e) => e.session).filter((s) => s !== null));
64
- if (known.size === 0) return null;
65
- if (known.size === 1) return [...known][0] ?? null;
66
- return 'mixed';
67
- }
68
- function rowFlags(row, windowSec) {
69
- const wMs = windowSec * 1000;
70
- const flags = [];
71
- const agentRun = row.actionKind === 'agent.run';
72
- const resumed = row.session === 'resumed' || row.session === 'mixed';
73
- const p50 = row.durationMs.p50;
74
- if (!agentRun && p50 !== null && p50 > wMs) flags.push('step-over-window');
75
- const idle = row.idleGapMs.p50;
76
- if (agentRun && resumed && idle !== null && idle > wMs) flags.push('resume-after-idle');
77
- const hit = row.cacheHit.p50;
78
- if (agentRun && resumed && row.cacheHit.known > 0 && hit !== null && hit < 0.5) flags.push('resume-cold-cache');
79
- if (agentRun && p50 !== null && p50 > 2 * wMs) flags.push('agent-run-over-2w');
80
- return flags;
81
- }
82
- function buildRows(executions, windowSec) {
83
- const grouped = new Map();
84
- for (const execution of executions) {
85
- const key = `${execution.node}\x00${execution.actionKind}`;
86
- const bucket = grouped.get(key);
87
- if (bucket === undefined) grouped.set(key, [execution]);
88
- else bucket.push(execution);
89
- }
90
- const rows = [];
91
- for (const bucket of grouped.values()) {
92
- const first = bucket[0];
93
- if (first === undefined) continue;
94
- const durations = bucket.map((e) => e.durationMs).filter((d) => d !== null);
95
- const gaps = bucket.map((e) => e.idleGapMs).filter((g) => g !== null);
96
- const hits = bucket.map((e) => e.cacheHit).filter((h) => h !== null);
97
- const row = {
98
- node: first.node,
99
- actionKind: first.actionKind,
100
- runs: new Set(bucket.map((e) => e.runId)).size,
101
- executions: bucket.length,
102
- durationMs: {
103
- p50: nearestRankP50(durations),
104
- max: durations.length === 0 ? null : Math.max(...durations),
105
- },
106
- idleGapMs: { p50: nearestRankP50(gaps) },
107
- session: first.actionKind === 'agent.run' ? foldSession(bucket) : null,
108
- cacheHit: {
109
- p50: nearestRankP50(hits),
110
- known: hits.length,
111
- of: bucket.length,
112
- },
113
- flags: [],
114
- };
115
- row.flags = rowFlags(row, windowSec);
116
- rows.push(row);
117
- }
118
- return rows.sort((a, b) =>
119
- a.node === b.node ? a.actionKind.localeCompare(b.actionKind) : a.node.localeCompare(b.node),
120
- );
121
- }
122
- function buildStepProfile(input) {
123
- const executions = input.runs.flatMap((run) => extractExecutions(run.runId, run.events));
124
- return {
125
- workflow: input.workflow,
126
- windowSec: input.windowSec,
127
- sampledRuns: input.runs.length,
128
- rows: buildRows(executions, input.windowSec),
129
- };
130
- }
131
- function nonDryRuns(entries) {
132
- return entries.filter((e) => e.isDryRun !== true && typeof e.runId === 'string' && e.runId.length > 0);
133
- }
134
- function seconds(value) {
135
- return value === null ? '?' : `${(value / 1000).toFixed(1)}s`;
136
- }
137
- function ratio(value) {
138
- return value === null ? '?' : value.toFixed(2);
139
- }
140
- function formatStepProfileHuman(profile) {
141
- const lines = [
142
- `step profile \u2014 ${profile.workflow} (window ${profile.windowSec}s, ${profile.sampledRuns} sampled runs)`,
143
- ];
144
- for (const row of profile.rows) {
145
- lines.push(
146
- [
147
- row.node.padEnd(20),
148
- row.actionKind.padEnd(14),
149
- `${row.runs}/${row.executions}`.padEnd(8),
150
- `p50=${seconds(row.durationMs.p50)}`.padEnd(12),
151
- `max=${seconds(row.durationMs.max)}`.padEnd(12),
152
- `idle=${seconds(row.idleGapMs.p50)}`.padEnd(12),
153
- `session=${row.session ?? '?'}`.padEnd(15),
154
- `cacheHit=${ratio(row.cacheHit.p50)} (${row.cacheHit.known}/${row.cacheHit.of})`.padEnd(20),
155
- `flags=${row.flags.length === 0 ? '-' : row.flags.join(',')}`,
156
- ].join(' '),
157
- );
158
- }
159
- return `${lines.join(`
160
- `)}
161
- `;
162
- }
163
- function defaultSpurBin() {
164
- if (process.env.SPUR_BIN) return process.env.SPUR_BIN;
165
- const local = fileURLToPath(new URL('../../../apps/cli/src/index.ts', import.meta.url));
166
- if (existsSync(local)) return `bun ${local}`;
167
- return 'spur';
168
- }
169
- function positiveInt(raw, fallback) {
170
- const parsed = Number.parseInt(raw ?? '', 10);
171
- return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
172
- }
173
- function parseStepProfileCliArgs(argv) {
174
- let workflow = '';
175
- let spurBin = defaultSpurBin();
176
- let last = DEFAULT_LAST;
177
- let windowSec = DEFAULT_WINDOW_SEC;
178
- let json = false;
179
- let help = false;
180
- for (let i = 0; i < argv.length; i++) {
181
- const a = argv[i];
182
- if (a === '--help' || a === '-h') help = true;
183
- else if (a === '--json') json = true;
184
- else if (a === '--last') last = positiveInt(argv[++i], last);
185
- else if (a === '--window') windowSec = positiveInt(argv[++i], windowSec);
186
- else if (a === '--spur-bin') spurBin = argv[++i] ?? spurBin;
187
- else if (!a.startsWith('--') && workflow === '') workflow = a;
188
- }
189
- return { workflow, last, windowSec, spurBin, json, help };
190
- }
191
- function runSpurJson(spurBin, args) {
192
- const binParts = spurBin.split(/\s+/).filter(Boolean);
193
- const cmd = binParts[0] ?? 'spur';
194
- const cmdArgs = [...binParts.slice(1), ...args];
195
- const r = spawnSync(cmd, cmdArgs, { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8' });
196
- const decode = (b) => (typeof b === 'string' ? b : Buffer.from(b ?? []).toString('utf8'));
197
- return {
198
- stdout: typeof r.stdout === 'string' ? r.stdout : decode(r.stdout),
199
- stderr: typeof r.stderr === 'string' ? r.stderr : decode(r.stderr),
200
- exitCode: r.status ?? (r.error ? 1 : 0),
201
- ok: (r.status ?? (r.error ? 1 : 0)) === 0,
202
- };
203
- }
204
- var STEP_PROFILE_USAGE = `usage: workflow-step-profile <workflow> [--last <N>] [--window <sec>] [--json] [--spur-bin <cmd>]
205
-
206
- Read-only step profile from \`spur workflow trace\`: per node and action kind it reports runs,
207
- executions, p50/max durationMs, p50 idle gap, session mode and cacheHit p50 with coverage, then
208
- flags the satellite \xA710 cache-window budgets. --last defaults to ${DEFAULT_LAST} runs and --window
209
- (W) to ${DEFAULT_WINDOW_SEC} seconds. Unknown evidence is reported as \`?\` / null, never 0.
210
-
211
- Exit: 0 = profile produced (flags included); 1 = a spur call failed, its JSON did not parse, or the
212
- workflow argument is missing.`;
213
- function failure(message) {
214
- return {
215
- exitCode: 1,
216
- stdout: '',
217
- stderr: `workflow-step-profile: ${message}
218
- `,
219
- };
220
- }
221
- function runFailure(spurBin, result, what) {
222
- const detail =
223
- result.stderr
224
- .trim()
225
- .split(`
226
- `)
227
- .slice(-1)[0] ?? '';
228
- return failure(`${what} failed (exit ${result.exitCode}${detail === '' ? '' : `: ${detail}`}) [${spurBin}]`);
229
- }
230
- function runStepProfileCli(argv) {
231
- const args = parseStepProfileCliArgs(argv);
232
- if (args.help)
233
- return {
234
- exitCode: 0,
235
- stdout: `${STEP_PROFILE_USAGE}
236
- `,
237
- stderr: '',
238
- };
239
- if (args.workflow === '')
240
- return failure(`a workflow name is required
241
- ${STEP_PROFILE_USAGE}`);
242
- const listArgs = [
243
- 'workflow',
244
- 'trace',
245
- '--workflow',
246
- args.workflow,
247
- '--status',
248
- 'done',
249
- '--last',
250
- String(args.last),
251
- '--json',
252
- ];
253
- const list = runSpurJson(args.spurBin, listArgs);
254
- if (!list.ok) return runFailure(args.spurBin, list, `spur ${listArgs.join(' ')}`);
255
- let entries;
256
- try {
257
- const parsed = JSON.parse(list.stdout);
258
- if (!Array.isArray(parsed.entries)) throw new Error('no "entries" array');
259
- entries = parsed.entries;
260
- } catch (err) {
261
- return failure(`spur workflow trace output did not parse as JSON: ${String(err)}`);
262
- }
263
- const runs = [];
264
- for (const entry of nonDryRuns(entries)) {
265
- const runArgs = ['workflow', 'trace', entry.runId, '--json'];
266
- const timeline = runSpurJson(args.spurBin, runArgs);
267
- if (!timeline.ok) return runFailure(args.spurBin, timeline, `spur ${runArgs.join(' ')}`);
268
- try {
269
- const parsed = JSON.parse(timeline.stdout);
270
- if (!Array.isArray(parsed.events)) throw new Error('no "events" array');
271
- runs.push({ runId: entry.runId, events: parsed.events });
272
- } catch (err) {
273
- return failure(`spur workflow trace ${entry.runId} output did not parse as JSON: ${String(err)}`);
274
- }
275
- }
276
- const profile = buildStepProfile({ workflow: args.workflow, windowSec: args.windowSec, runs });
277
- return {
278
- exitCode: 0,
279
- stdout: args.json
280
- ? `${JSON.stringify(profile, null, 2)}
281
- `
282
- : formatStepProfileHuman(profile),
283
- stderr: '',
284
- };
285
- }
286
- function main(argv) {
287
- const { exitCode, stdout, stderr } = runStepProfileCli(argv);
288
- if (stdout) process.stdout.write(stdout);
289
- if (stderr)
290
- process.stderr.write(
291
- stderr.endsWith(`
292
- `)
293
- ? stderr
294
- : `${stderr}
295
- `,
296
- );
297
- return exitCode;
298
- }
299
- process.exit(main(process.argv.slice(2)));
300
-
301
- export {
302
- buildRows,
303
- buildStepProfile,
304
- DEFAULT_LAST,
305
- DEFAULT_WINDOW_SEC,
306
- defaultSpurBin,
307
- extractExecutions,
308
- formatStepProfileHuman,
309
- main,
310
- nearestRankP50,
311
- nonDryRuns,
312
- parseStepProfileCliArgs,
313
- rowFlags,
314
- runStepProfileCli,
315
- STEP_PROFILE_USAGE,
316
- };