@gobing-ai/knowledge-kit 0.0.13 → 0.0.14
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/index.js +20 -0
- package/package.json +1 -1
- package/plugins/generations/content-gen/dist/index.js +20 -0
- package/plugins/generations/core-facts-gen/dist/index.js +20 -0
- package/plugins/generations/daily-article-gen/dist/index.js +29 -1
- package/plugins/generations/daily-article-gen/src/index.ts +13 -1
- package/plugins/generations/dailynews-gen/dist/index.js +20 -0
- package/plugins/generations/episode-plan-gen/dist/index.js +24 -0
- package/plugins/generations/episode-plan-gen/src/index.ts +11 -0
- package/plugins/generations/image-gen/dist/index.js +2296 -53
- package/plugins/generations/image-gen/src/providers/agnes.ts +110 -0
- package/plugins/generations/image-gen/src/providers/azure.ts +153 -0
- package/plugins/generations/image-gen/src/providers/codex-cli.ts +170 -0
- package/plugins/generations/image-gen/src/providers/dashscope.ts +485 -0
- package/plugins/generations/image-gen/src/providers/google.ts +268 -0
- package/plugins/generations/image-gen/src/providers/huggingface.ts +59 -0
- package/plugins/generations/image-gen/src/providers/jimeng.ts +259 -0
- package/plugins/generations/image-gen/src/providers/minimax.ts +171 -0
- package/plugins/generations/image-gen/src/providers/openai.ts +319 -0
- package/plugins/generations/image-gen/src/providers/openrouter.ts +257 -0
- package/plugins/generations/image-gen/src/providers/refs.ts +24 -0
- package/plugins/generations/image-gen/src/providers/replicate.ts +279 -0
- package/plugins/generations/image-gen/src/providers/seedream.ts +1 -1
- package/plugins/generations/image-gen/src/providers/types.ts +52 -51
- package/plugins/generations/image-gen/src/providers/zai.ts +237 -0
- package/plugins/generations/news-report-gen/dist/index.js +22193 -0
- package/plugins/generations/news-report-gen/package.json +17 -0
- package/plugins/generations/news-report-gen/plugin.json +7 -0
- package/plugins/generations/news-report-gen/src/index.ts +308 -0
- package/plugins/generations/news-report-gen/tsconfig.json +4 -0
- package/plugins/generations/omni-voice-gen/Makefile +14 -0
- package/plugins/generations/omni-voice-gen/README.md +112 -0
- package/plugins/generations/omni-voice-gen/bin/omni-voice-gen +2 -0
- package/plugins/generations/omni-voice-gen/dist/omni-voice-gen-prr8skpb. +2 -0
- package/plugins/generations/omni-voice-gen/dist/omni-voice-gen.js +6 -0
- package/plugins/generations/omni-voice-gen/plugin.json +6 -0
- package/plugins/generations/omni-voice-gen/profiles.json +12 -0
- package/plugins/generations/omni-voice-gen/pyproject.toml +25 -0
- package/plugins/generations/omni-voice-gen/scripts/coverage_gate.py +74 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/__init__.py +1 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/__main__.py +39 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/audio.py +190 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/backend.py +150 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/contract.py +76 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/mp3.py +60 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/pipeline.py +289 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/profiles.py +100 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/qc.py +234 -0
- package/plugins/generations/omni-voice-gen/src/omni_voice_gen/voicescript.py +352 -0
- package/plugins/generations/omni-voice-gen/uv.lock +3510 -0
- package/plugins/generations/voice-gen/dist/index.js +30 -2
- package/plugins/generations/voice-gen/src/index.ts +16 -1
- package/plugins/generations/voice-gen/src/voicebox-client.ts +3 -1
- package/plugins/ingestions/aihot-ingest/dist/index.js +20 -0
- package/plugins/ingestions/horizon-ingest/dist/index.js +20 -0
- package/plugins/ingestions/last30days-ingest/dist/index.js +20 -0
- package/plugins/ingestions/web-search/dist/index.js +20 -0
- package/plugins/kk/commands/image-extract.md +40 -0
- package/plugins/kk/commands/image-generate.md +18 -1
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/skills/image-authoring/SKILL.md +10 -3
- package/plugins/kk/skills/image-authoring/references/format-drafting.md +57 -0
- package/plugins/kk/skills/image-authoring/references/style-extraction.md +14 -9
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +130 -30
- package/plugins/publishings/emdash-pub/dist/index.js +20 -0
- package/plugins/publishings/podcast-pub/dist/index.js +57 -3
- package/plugins/publishings/podcast-pub/src/index.ts +18 -2
- package/plugins/publishings/podcast-pub/src/show-notes.ts +56 -9
- package/plugins/publishings/qiita-pub/dist/index.js +20 -0
- package/plugins/publishings/surfdash-pub/dist/index.js +96 -6
- package/plugins/publishings/surfdash-pub/src/index.ts +109 -9
- package/plugins/publishings/zenn-pub/dist/index.js +20 -0
- package/plugins/sp/scripts/batch-preflight.mjs +346 -0
- package/plugins/sp/scripts/batch-preflight.ts +459 -0
- package/plugins/sp/scripts/daily-summary/daily-summary.mjs +615 -0
- package/plugins/sp/scripts/daily-summary/daily-summary.ts +846 -0
- package/plugins/sp/scripts/daily-summary/logger.ts +28 -0
- package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.mjs +223 -0
- package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts +367 -0
- package/plugins/sp/scripts/dogfood-testing/validate-report.mjs +132 -0
- package/plugins/sp/scripts/dogfood-testing/validate-report.ts +169 -0
- package/plugins/sp/scripts/feature-dev-precheck.mjs +171 -0
- package/plugins/sp/scripts/feature-dev-precheck.ts +238 -0
- package/plugins/sp/scripts/feature-sync-bounded.mjs +285 -0
- package/plugins/sp/scripts/feature-sync-bounded.ts +478 -0
- package/plugins/sp/scripts/history-anatomy-cache.mjs +902 -0
- package/plugins/sp/scripts/history-anatomy-cache.ts +1028 -0
- package/plugins/sp/scripts/idea-handoff.mjs +22 -0
- package/plugins/sp/scripts/idea-handoff.ts +44 -0
- package/plugins/sp/scripts/inline-pipeline-parity-check.ts +185 -0
- package/plugins/sp/scripts/inline-run-setup.ts +198 -0
- package/plugins/sp/scripts/pr-reviewing.mjs +769 -0
- package/plugins/sp/scripts/pr-reviewing.ts +925 -0
- package/plugins/sp/scripts/quality-gate.mjs +179 -0
- package/plugins/sp/scripts/quality-gate.ts +217 -0
- package/plugins/sp/scripts/script-contract-check.ts +319 -0
- package/plugins/sp/scripts/stage-registry-adapter.ts +1533 -0
- package/plugins/sp/scripts/surface-drift-inventory.ts +929 -0
- package/plugins/sp/scripts/task-evidence-precheck.ts +181 -0
- package/plugins/sp/scripts/task-size-precheck.ts +175 -0
- package/plugins/sp/scripts/transition-shim-check.ts +238 -0
- package/plugins/sp/scripts/validate-commands.ts +689 -0
- package/plugins/sp/scripts/validate-flag-contracts.ts +878 -0
- package/plugins/sp/scripts/verify-answer-lint.ts +530 -0
- package/plugins/sp/scripts/workflow-step-profile.mjs +316 -0
- package/plugins/sp/scripts/workflow-step-profile.ts +456 -0
- package/plugins/sp/scripts/wrapup-steps.mjs +373 -0
- package/plugins/sp/scripts/wrapup-steps.ts +466 -0
|
@@ -0,0 +1,316 @@
|
|
|
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
|
+
};
|