@gobing-ai/knowledge-kit 0.0.29 → 0.0.31

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 (73) 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 +24 -7
  5. package/plugins/generations/daily-article-gen/src/index.ts +36 -12
  6. package/plugins/generations/dailynews-gen/dist/index.js +20 -3
  7. package/plugins/generations/dailynews-gen/src/index.ts +7 -0
  8. package/plugins/generations/dailynews-gen/src/script-builder.ts +4 -2
  9. package/plugins/generations/dailynews-gen/src/script-plan.ts +21 -3
  10. package/plugins/generations/episode-plan-gen/dist/index.js +66 -5
  11. package/plugins/generations/episode-plan-gen/src/index.ts +103 -4
  12. package/plugins/generations/image-gen/dist/index.js +122 -20
  13. package/plugins/generations/image-gen/src/bytes.ts +106 -18
  14. package/plugins/generations/image-gen/src/index.ts +46 -6
  15. package/plugins/generations/image-gen/src/job.ts +6 -0
  16. package/plugins/generations/image-gen/src/providers/minimax.ts +12 -4
  17. package/plugins/generations/image-gen/src/providers/types.ts +12 -1
  18. package/plugins/kk/plugin.json +1 -1
  19. package/plugins/kk/scripts/daily-voice-style.zh.md +5 -5
  20. package/plugins/kk/scripts/itc-stages.ts +21 -3
  21. package/plugins/kk/scripts/kk-workflow-stages.ts +199 -7
  22. package/plugins/kk/scripts/topic-boundary.json +3 -12
  23. package/plugins/kk/skills/content-judge/SKILL.md +32 -0
  24. package/plugins/kk/skills/content-judge/references/workflow-integration.md +10 -2
  25. package/plugins/kk/skills/publish/SKILL.md +1 -1
  26. package/plugins/kk/workflows/judge-gated-publish-example.yaml +18 -10
  27. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +39 -14
  28. package/plugins/kk/workflows/kk-itc.yaml +21 -8
  29. package/plugins/publishings/xhs-pub/dist/index.js +1 -1
  30. package/plugins/publishings/xhs-pub/src/automation-guard.ts +2 -2
  31. package/plugins/publishings/xhs-pub/src/index.ts +1 -1
  32. package/plugins/publishings/xhs-pub/src/profile-check.ts +2 -2
  33. package/plugins/sp/lib/env.ts +0 -46
  34. package/plugins/sp/lib/inline-run.generated.mjs +0 -1489
  35. package/plugins/sp/scripts/batch-preflight.mjs +0 -346
  36. package/plugins/sp/scripts/batch-preflight.ts +0 -459
  37. package/plugins/sp/scripts/daily-summary/daily-summary.mjs +0 -615
  38. package/plugins/sp/scripts/daily-summary/daily-summary.ts +0 -846
  39. package/plugins/sp/scripts/daily-summary/logger.ts +0 -28
  40. package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.mjs +0 -223
  41. package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts +0 -367
  42. package/plugins/sp/scripts/dogfood-testing/validate-report.mjs +0 -132
  43. package/plugins/sp/scripts/dogfood-testing/validate-report.ts +0 -169
  44. package/plugins/sp/scripts/feature-dev-precheck.mjs +0 -171
  45. package/plugins/sp/scripts/feature-dev-precheck.ts +0 -238
  46. package/plugins/sp/scripts/feature-sync-bounded.mjs +0 -285
  47. package/plugins/sp/scripts/feature-sync-bounded.ts +0 -478
  48. package/plugins/sp/scripts/feature-verification-steps.ts +0 -275
  49. package/plugins/sp/scripts/history-anatomy-cache.mjs +0 -902
  50. package/plugins/sp/scripts/history-anatomy-cache.ts +0 -1028
  51. package/plugins/sp/scripts/idea-handoff.mjs +0 -22
  52. package/plugins/sp/scripts/idea-handoff.ts +0 -44
  53. package/plugins/sp/scripts/inline-pipeline-parity-check.ts +0 -185
  54. package/plugins/sp/scripts/inline-run-setup.ts +0 -722
  55. package/plugins/sp/scripts/pr-reviewing.mjs +0 -769
  56. package/plugins/sp/scripts/pr-reviewing.ts +0 -925
  57. package/plugins/sp/scripts/quality-gate.mjs +0 -179
  58. package/plugins/sp/scripts/quality-gate.ts +0 -217
  59. package/plugins/sp/scripts/script-contract-check.ts +0 -319
  60. package/plugins/sp/scripts/stage-registry-adapter.ts +0 -1533
  61. package/plugins/sp/scripts/surface-drift-inventory.ts +0 -929
  62. package/plugins/sp/scripts/task-evidence-precheck.ts +0 -181
  63. package/plugins/sp/scripts/task-size-precheck.ts +0 -175
  64. package/plugins/sp/scripts/transition-shim-check.ts +0 -238
  65. package/plugins/sp/scripts/validate-commands.ts +0 -689
  66. package/plugins/sp/scripts/validate-flag-contracts.ts +0 -878
  67. package/plugins/sp/scripts/verify-answer-lint.ts +0 -530
  68. package/plugins/sp/scripts/workflow-step-profile.mjs +0 -316
  69. package/plugins/sp/scripts/workflow-step-profile.ts +0 -456
  70. package/plugins/sp/scripts/wrapup-drift-probe.mjs +0 -190
  71. package/plugins/sp/scripts/wrapup-drift-probe.ts +0 -258
  72. package/plugins/sp/scripts/wrapup-steps.mjs +0 -444
  73. 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
- };