@shipd-ai/cli 0.1.3 → 0.2.0
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/README.md +118 -43
- package/dist/auth.d.ts +9 -5
- package/dist/auth.js +43 -10
- package/dist/author.d.ts +11 -0
- package/dist/author.js +43 -0
- package/dist/backend.d.ts +4 -0
- package/dist/backend.js +51 -0
- package/dist/checks-view.d.ts +9 -0
- package/dist/checks-view.js +11 -0
- package/dist/client.d.ts +0 -8
- package/dist/client.js +0 -7
- package/dist/commands/auth.d.ts +9 -4
- package/dist/commands/auth.js +29 -41
- package/dist/commands/author-checks.d.ts +265 -0
- package/dist/commands/author-checks.js +365 -0
- package/dist/commands/checks.d.ts +0 -2
- package/dist/commands/checks.js +21 -17
- package/dist/commands/problems.d.ts +1 -0
- package/dist/commands/problems.js +189 -0
- package/dist/commands/quests.d.ts +0 -1
- package/dist/commands/quests.js +0 -1
- package/dist/contract.d.ts +0 -1
- package/dist/contract.js +0 -7
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +6 -5
- package/dist/format.d.ts +2 -4
- package/dist/format.js +29 -7
- package/dist/harbor.d.ts +0 -8
- package/dist/harbor.js +0 -11
- package/dist/index-gate.d.ts +1 -0
- package/dist/index-gate.js +5 -0
- package/dist/index.js +14 -10
- package/dist/model.d.ts +94 -0
- package/dist/model.js +68 -0
- package/dist/plan.d.ts +0 -15
- package/dist/plan.js +0 -21
- package/dist/prompt.d.ts +5 -0
- package/dist/prompt.js +26 -0
- package/dist/quests.d.ts +2 -10
- package/dist/quests.js +51 -34
- package/dist/report.d.ts +0 -9
- package/dist/report.js +1 -7
- package/dist/usage.d.ts +2 -0
- package/dist/usage.js +16 -0
- package/package.json +3 -2
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { api, backend, connectAuthor, requireProblemVersion } from "../author.js";
|
|
3
|
+
import { buildChecksViewPayload } from "../checks-view.js";
|
|
4
|
+
import { RefusedError, UsageError } from "../errors.js";
|
|
5
|
+
import { dim, paint, printJson, statusBadge, text, truncate } from "../format.js";
|
|
6
|
+
import { formatDynamicCheckLabel, getDynamicCheckEntries, precheckStages, } from "../model.js";
|
|
7
|
+
import { DEFAULT_QUEST } from "../quests.js";
|
|
8
|
+
export const questArg = {
|
|
9
|
+
quest: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: `Quest to talk to (default: ${DEFAULT_QUEST})`,
|
|
12
|
+
default: DEFAULT_QUEST,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
const color = () => Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
|
|
16
|
+
export const RUN_ALL_CHECK_KEYS = [
|
|
17
|
+
"verifyTests",
|
|
18
|
+
"verifySolution",
|
|
19
|
+
"verifyFlakiness",
|
|
20
|
+
"descriptionQuality",
|
|
21
|
+
"solutionQuality",
|
|
22
|
+
"rewardHacking",
|
|
23
|
+
"verifyFairness",
|
|
24
|
+
];
|
|
25
|
+
function printWaiting(result) {
|
|
26
|
+
if (typeof result !== "object" || result === null)
|
|
27
|
+
return;
|
|
28
|
+
const { waiting, running } = result;
|
|
29
|
+
if (Array.isArray(waiting) && waiting.length > 0) {
|
|
30
|
+
console.log(` Waiting for a prerequisite: ${text(waiting.join(", "))}`);
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(running) && running.length > 0) {
|
|
33
|
+
console.log(` Still running (not started again): ${text(running.join(", "))}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function formatCheckVerdict(check) {
|
|
37
|
+
const verdict = check.output?.verdict ??
|
|
38
|
+
check.output?.evaluation?.verdict;
|
|
39
|
+
return verdict ?? null;
|
|
40
|
+
}
|
|
41
|
+
function formatCheckMessage(check) {
|
|
42
|
+
const message = check.output?.message ??
|
|
43
|
+
check.output?.summary ??
|
|
44
|
+
check.output?.evaluation?.summary;
|
|
45
|
+
return message ?? null;
|
|
46
|
+
}
|
|
47
|
+
export function printPrechecks(results, c, emptyLine = true) {
|
|
48
|
+
const stageList = precheckStages(results);
|
|
49
|
+
if (stageList.length === 0) {
|
|
50
|
+
if (emptyLine)
|
|
51
|
+
console.log(` Prechecks:\n ${dim("No prechecks yet.", c)}`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
console.log(" Prechecks:");
|
|
55
|
+
for (const stage of stageList) {
|
|
56
|
+
const stale = stage.stale ? ` ${paint("yellow", "(stale)", c)}` : "";
|
|
57
|
+
console.log(` ${statusBadge(String(stage.status ?? "").toLowerCase(), c)} ${text(stage.name ?? stage.id)}${stale}`);
|
|
58
|
+
for (const check of stage.checks ?? []) {
|
|
59
|
+
const msg = check.message ? ` ${truncate(text(check.message), 70)}` : "";
|
|
60
|
+
console.log(` ${statusBadge(String(check.status ?? "").toLowerCase(), c)} ${text(check.description ?? check.id)}${msg}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function printQualityChecks(dynamicChecks, c, emptyLine = true) {
|
|
65
|
+
const checks = getDynamicCheckEntries(dynamicChecks);
|
|
66
|
+
if (checks.length === 0) {
|
|
67
|
+
if (emptyLine)
|
|
68
|
+
console.log(`\n Quality Checks:\n ${dim("No quality checks yet.", c)}`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
console.log("\n Quality Checks:");
|
|
72
|
+
for (const check of checks) {
|
|
73
|
+
const stale = check.stale ? ` ${paint("yellow", "(stale)", c)}` : "";
|
|
74
|
+
const overridden = check.overridden ? ` ${paint("yellow", "(overridden)", c)}` : "";
|
|
75
|
+
const verdict = formatCheckVerdict(check);
|
|
76
|
+
const message = formatCheckMessage(check);
|
|
77
|
+
const suffix = `${verdict ? ` [${text(verdict)}]` : ""}${message ? ` ${truncate(text(message), 70)}` : ""}`;
|
|
78
|
+
const key = text(check.key);
|
|
79
|
+
console.log(` ${statusBadge(check.status, c)} ${text(formatDynamicCheckLabel(check.key))} (${key})${suffix}${stale}${overridden}`);
|
|
80
|
+
if (check.error) {
|
|
81
|
+
console.log(` ${paint("red", `Error: ${truncate(text(check.error), 90)}`, c)}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function printTrialQa(trialQa, c) {
|
|
86
|
+
if (!trialQa)
|
|
87
|
+
return;
|
|
88
|
+
const parts = [`${statusBadge(trialQa.state, c)} Trial QA`];
|
|
89
|
+
if (trialQa.state === "running" && trialQa.currentStep) {
|
|
90
|
+
parts.push(` ${truncate(text(trialQa.currentStep), 60)}`);
|
|
91
|
+
}
|
|
92
|
+
if (trialQa.runRuleWaitsOn)
|
|
93
|
+
parts.push(` ${truncate(text(trialQa.runRuleWaitsOn), 70)}`);
|
|
94
|
+
if (trialQa.runsChangedSinceCheck) {
|
|
95
|
+
parts.push(` ${paint("yellow", "(runs changed since the check)", c)}`);
|
|
96
|
+
}
|
|
97
|
+
if (trialQa.warnings?.length) {
|
|
98
|
+
parts.push(` ${paint("yellow", `(${text(trialQa.warnings.join(", "))})`, c)}`);
|
|
99
|
+
}
|
|
100
|
+
console.log(`\n Trial QA:\n ${parts.join("")}`);
|
|
101
|
+
if (trialQa.canRun && trialQa.hasEligibleRuns && trialQa.state !== "running") {
|
|
102
|
+
console.log(` ${dim(`${trialQa.tokenCost ?? 0} tokens to run`, c)}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export function printReadiness(readiness, c) {
|
|
106
|
+
if (!readiness)
|
|
107
|
+
return;
|
|
108
|
+
console.log("\n Submission Readiness:");
|
|
109
|
+
for (const criterion of readiness.criteria) {
|
|
110
|
+
const detail = criterion.detail ? ` ${text(criterion.detail)}` : "";
|
|
111
|
+
const stale = criterion.stale ? ` ${paint("yellow", "(stale)", c)}` : "";
|
|
112
|
+
console.log(` ${statusBadge(criterion.status, c)} ${text(criterion.label)}${detail}${stale}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function printNextCommands(problemId, quest) {
|
|
116
|
+
const questFlag = quest === DEFAULT_QUEST ? "" : ` --quest ${quest}`;
|
|
117
|
+
console.log("\n Commands:");
|
|
118
|
+
console.log(` shipd problems view ${problemId}${questFlag} Full challenge detail`);
|
|
119
|
+
console.log(` shipd checks run-prechecks ${problemId}${questFlag} Run the prechecks`);
|
|
120
|
+
console.log(` shipd checks run-all ${problemId}${questFlag} Run the quality checks`);
|
|
121
|
+
console.log(` shipd checks run-trial-qa ${problemId}${questFlag} Run Trial QA`);
|
|
122
|
+
console.log(` shipd checks wait ${problemId}${questFlag} Watch active checks`);
|
|
123
|
+
}
|
|
124
|
+
async function readChecks(quest, problemId) {
|
|
125
|
+
const client = await connectAuthor(quest);
|
|
126
|
+
const { problem, version } = await requireProblemVersion(client, problemId);
|
|
127
|
+
const [stages, dynamicChecks, trialQa, readiness] = await backend(() => Promise.all([
|
|
128
|
+
client.query(api.stages.getValidationResults, {
|
|
129
|
+
itemId: problemId,
|
|
130
|
+
versionId: version._id,
|
|
131
|
+
}),
|
|
132
|
+
client.query(api.runDynamicChecks.getDynamicChecks, { versionId: version._id }),
|
|
133
|
+
client.query(api.fpReview.getFpCheckForVersion, { versionId: version._id }),
|
|
134
|
+
client.query(api.submissionReadiness.getSubmissionReadiness, { problemId }),
|
|
135
|
+
]));
|
|
136
|
+
return { client, problem, version, stages, dynamicChecks, trialQa, readiness };
|
|
137
|
+
}
|
|
138
|
+
const tokensArg = {
|
|
139
|
+
"use-general-tokens": {
|
|
140
|
+
type: "boolean",
|
|
141
|
+
description: "Charge general tokens instead of revision tokens",
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
export const view = defineCommand({
|
|
145
|
+
meta: {
|
|
146
|
+
name: "view",
|
|
147
|
+
description: "View a challenge's prechecks, quality checks, Trial QA and readiness",
|
|
148
|
+
},
|
|
149
|
+
args: {
|
|
150
|
+
id: { type: "positional", description: "Challenge ID", required: true },
|
|
151
|
+
...questArg,
|
|
152
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
153
|
+
},
|
|
154
|
+
run: async ({ args }) => {
|
|
155
|
+
const { version, stages, dynamicChecks, trialQa, readiness } = await readChecks(args.quest, args.id);
|
|
156
|
+
if (args.json) {
|
|
157
|
+
printJson(buildChecksViewPayload({
|
|
158
|
+
version: version.version,
|
|
159
|
+
prechecks: stages,
|
|
160
|
+
dynamicChecks,
|
|
161
|
+
trialQa,
|
|
162
|
+
readiness,
|
|
163
|
+
}));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const c = color();
|
|
167
|
+
console.log(`\n Checks for v${version.version}\n`);
|
|
168
|
+
printPrechecks(stages, c);
|
|
169
|
+
printQualityChecks(dynamicChecks, c);
|
|
170
|
+
printTrialQa(trialQa, c);
|
|
171
|
+
printReadiness(readiness, c);
|
|
172
|
+
printNextCommands(args.id, args.quest);
|
|
173
|
+
console.log(`\n ${dim("Use --json for the full check payload.", c)}\n`);
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
export const runCheck = defineCommand({
|
|
177
|
+
meta: { name: "run-check", description: "Run one of a challenge's quality checks" },
|
|
178
|
+
args: {
|
|
179
|
+
id: { type: "positional", description: "Challenge ID", required: true },
|
|
180
|
+
...questArg,
|
|
181
|
+
check: {
|
|
182
|
+
type: "string",
|
|
183
|
+
description: `Check key: ${RUN_ALL_CHECK_KEYS.join(", ")}`,
|
|
184
|
+
required: true,
|
|
185
|
+
},
|
|
186
|
+
...tokensArg,
|
|
187
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
188
|
+
},
|
|
189
|
+
run: async ({ args }) => {
|
|
190
|
+
if (!RUN_ALL_CHECK_KEYS.includes(args.check)) {
|
|
191
|
+
throw new UsageError(`Not a check the page runs: ${args.check}. One of: ${RUN_ALL_CHECK_KEYS.join(", ")}.`);
|
|
192
|
+
}
|
|
193
|
+
const client = await connectAuthor(args.quest);
|
|
194
|
+
const { version } = await requireProblemVersion(client, args.id);
|
|
195
|
+
const result = await backend(() => client.action(api.runDynamicChecks.triggerDynamicCheck, {
|
|
196
|
+
versionId: version._id,
|
|
197
|
+
checkKey: args.check,
|
|
198
|
+
useGeneralTokens: args["use-general-tokens"],
|
|
199
|
+
}));
|
|
200
|
+
if (args.json) {
|
|
201
|
+
printJson(result);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const c = color();
|
|
205
|
+
console.log(`\n Triggered ${args.check} on v${version.version}`);
|
|
206
|
+
printWaiting(result);
|
|
207
|
+
console.log(` ${dim("Use `shipd checks wait <id>` to watch active checks.", c)}\n`);
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
export const runAll = defineCommand({
|
|
211
|
+
meta: {
|
|
212
|
+
name: "run-all",
|
|
213
|
+
description: "Run the quality checks the page's Run Checks runs",
|
|
214
|
+
},
|
|
215
|
+
args: {
|
|
216
|
+
id: { type: "positional", description: "Challenge ID", required: true },
|
|
217
|
+
...questArg,
|
|
218
|
+
...tokensArg,
|
|
219
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
220
|
+
},
|
|
221
|
+
run: async ({ args }) => {
|
|
222
|
+
const client = await connectAuthor(args.quest);
|
|
223
|
+
const { version } = await requireProblemVersion(client, args.id);
|
|
224
|
+
const result = await backend(() => client.action(api.runDynamicChecks.triggerAllDynamicChecks, {
|
|
225
|
+
versionId: version._id,
|
|
226
|
+
checkKeys: [...RUN_ALL_CHECK_KEYS],
|
|
227
|
+
useGeneralTokens: args["use-general-tokens"],
|
|
228
|
+
}));
|
|
229
|
+
if (args.json) {
|
|
230
|
+
printJson({ result, checkKeys: RUN_ALL_CHECK_KEYS });
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const c = color();
|
|
234
|
+
console.log(`\n Triggered ${RUN_ALL_CHECK_KEYS.length} quality checks on v${version.version}`);
|
|
235
|
+
printWaiting(result);
|
|
236
|
+
console.log(` ${dim("Use `shipd checks wait <id>` to watch active checks.", c)}\n`);
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
export const runPrechecks = defineCommand({
|
|
240
|
+
meta: { name: "run-prechecks", description: "Run the prechecks on the saved version" },
|
|
241
|
+
args: {
|
|
242
|
+
id: { type: "positional", description: "Challenge ID", required: true },
|
|
243
|
+
...questArg,
|
|
244
|
+
...tokensArg,
|
|
245
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
246
|
+
},
|
|
247
|
+
run: async ({ args }) => {
|
|
248
|
+
const client = await connectAuthor(args.quest);
|
|
249
|
+
const { version } = await requireProblemVersion(client, args.id);
|
|
250
|
+
const result = await backend(() => client.action(api.contributorTokens.runAllChecksWithToken, {
|
|
251
|
+
problemId: args.id,
|
|
252
|
+
versionId: version._id,
|
|
253
|
+
useGeneralTokens: args["use-general-tokens"],
|
|
254
|
+
}));
|
|
255
|
+
if (args.json) {
|
|
256
|
+
printJson(result);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const c = color();
|
|
260
|
+
console.log(`\n Ran the prechecks on v${version.version}\n`);
|
|
261
|
+
printPrechecks(result, c);
|
|
262
|
+
console.log(`\n ${dim("Use `shipd checks view <id>` for the stored results.", c)}\n`);
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
export const runTrialQa = defineCommand({
|
|
266
|
+
meta: { name: "run-trial-qa", description: "Run Trial QA on the current rollouts" },
|
|
267
|
+
args: {
|
|
268
|
+
id: { type: "positional", description: "Challenge ID", required: true },
|
|
269
|
+
...questArg,
|
|
270
|
+
...tokensArg,
|
|
271
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
272
|
+
},
|
|
273
|
+
run: async ({ args }) => {
|
|
274
|
+
const client = await connectAuthor(args.quest);
|
|
275
|
+
const { version } = await requireProblemVersion(client, args.id);
|
|
276
|
+
const result = await backend(() => client.action(api.fpReview.requestFpCheck, {
|
|
277
|
+
versionId: version._id,
|
|
278
|
+
useGeneralTokens: args["use-general-tokens"],
|
|
279
|
+
}));
|
|
280
|
+
if (args.json) {
|
|
281
|
+
printJson(result);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const c = color();
|
|
285
|
+
console.log(`\n Started Trial QA on v${version.version}`);
|
|
286
|
+
console.log(` ${dim("Use `shipd checks wait <id>` to watch it.", c)}\n`);
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
export const wait = defineCommand({
|
|
290
|
+
meta: { name: "wait", description: "Wait for a challenge's active checks to finish" },
|
|
291
|
+
args: {
|
|
292
|
+
id: { type: "positional", description: "Challenge ID", required: true },
|
|
293
|
+
...questArg,
|
|
294
|
+
interval: { type: "string", description: "Poll interval in seconds (default 10)" },
|
|
295
|
+
timeout: { type: "string", description: "Timeout in minutes (default 30)" },
|
|
296
|
+
json: { type: "boolean", description: "Output final result as JSON" },
|
|
297
|
+
},
|
|
298
|
+
run: async ({ args }) => {
|
|
299
|
+
const client = await connectAuthor(args.quest);
|
|
300
|
+
const clamp = (value, fallback, min, max) => Math.min(max, Math.max(min, Number.parseInt(value ?? "", 10) || fallback));
|
|
301
|
+
const intervalMs = clamp(args.interval, 10, 1, 60 * 60) * 1000;
|
|
302
|
+
const timeoutMs = clamp(args.timeout, 30, 1, 24 * 60) * 60 * 1000;
|
|
303
|
+
const startedAt = Date.now();
|
|
304
|
+
const problemId = args.id;
|
|
305
|
+
const { version } = await requireProblemVersion(client, problemId);
|
|
306
|
+
console.error(` Waiting for active checks on v${version.version}...`);
|
|
307
|
+
while (Date.now() - startedAt < timeoutMs) {
|
|
308
|
+
const [dynamicChecks, order, trialQa, stages] = await backend(() => Promise.all([
|
|
309
|
+
client.query(api.runDynamicChecks.getDynamicChecks, { versionId: version._id }),
|
|
310
|
+
client.query(api.runDynamicChecks.getCheckOrder, { versionId: version._id }),
|
|
311
|
+
client.query(api.fpReview.getFpCheckForVersion, {
|
|
312
|
+
versionId: version._id,
|
|
313
|
+
}),
|
|
314
|
+
client.query(api.stages.getValidationResults, {
|
|
315
|
+
itemId: problemId,
|
|
316
|
+
versionId: version._id,
|
|
317
|
+
}),
|
|
318
|
+
]));
|
|
319
|
+
const checks = getDynamicCheckEntries(dynamicChecks);
|
|
320
|
+
const waitingCount = order?.waiting?.length ?? 0;
|
|
321
|
+
const running = checks.filter((check) => check.status === "pending" || check.status === "running");
|
|
322
|
+
const trialQaActive = trialQa?.state === "running" ? 1 : 0;
|
|
323
|
+
const pendingPrechecks = precheckStages(stages).filter((stage) => String(stage.status ?? "").toLowerCase() === "pending").length;
|
|
324
|
+
const activeCount = running.length + waitingCount + trialQaActive + pendingPrechecks;
|
|
325
|
+
const terminal = checks.filter((check) => check.status === "completed" || check.status === "failed");
|
|
326
|
+
const elapsed = Math.round((Date.now() - startedAt) / 1000);
|
|
327
|
+
process.stderr.write(`\r ${terminal.length} complete, ${activeCount} active, ${checks.length + trialQaActive + pendingPrechecks} total (${elapsed}s)`);
|
|
328
|
+
if (activeCount === 0) {
|
|
329
|
+
console.error("");
|
|
330
|
+
const readiness = await backend(() => client.query(api.submissionReadiness.getSubmissionReadiness, { problemId }));
|
|
331
|
+
if (args.json) {
|
|
332
|
+
printJson({
|
|
333
|
+
prechecks: stages,
|
|
334
|
+
dynamicChecks,
|
|
335
|
+
trialQa,
|
|
336
|
+
readiness,
|
|
337
|
+
version: version.version,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
const c = color();
|
|
342
|
+
console.log("");
|
|
343
|
+
printPrechecks(stages, c, false);
|
|
344
|
+
printQualityChecks(dynamicChecks, c);
|
|
345
|
+
printTrialQa(trialQa, c);
|
|
346
|
+
printReadiness(readiness, c);
|
|
347
|
+
printNextCommands(problemId, args.quest);
|
|
348
|
+
console.log("");
|
|
349
|
+
}
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
353
|
+
}
|
|
354
|
+
console.error("");
|
|
355
|
+
throw new RefusedError("Timed out waiting for checks.");
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
export const authorChecks = {
|
|
359
|
+
view,
|
|
360
|
+
"run-check": runCheck,
|
|
361
|
+
"run-all": runAll,
|
|
362
|
+
"run-prechecks": runPrechecks,
|
|
363
|
+
"run-trial-qa": runTrialQa,
|
|
364
|
+
wait,
|
|
365
|
+
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { type Catalog, type CheckDef, type TaskRef } from "../contract.js";
|
|
2
2
|
import { type Report } from "../report.js";
|
|
3
|
-
/** "a + b → c": steps grouped by dependency depth. */
|
|
4
3
|
export declare function formatSteps(check: CheckDef): string;
|
|
5
4
|
export declare function selectChecks(catalog: Catalog, explicit: string | undefined, all: boolean): {
|
|
6
5
|
checks: CheckDef[];
|
|
7
6
|
selection: Report["selection"];
|
|
8
7
|
};
|
|
9
|
-
/** Lines for `--dry-run --task`: what would be dispatched, without dispatching. */
|
|
10
8
|
export declare function dryRunTaskLines(task: TaskRef, checks: CheckDef[]): string[];
|
|
11
9
|
declare const _default: import("citty").CommandDef<import("citty").ArgsDef>;
|
|
12
10
|
export default _default;
|
package/dist/commands/checks.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { createInterface } from "node:readline";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
|
+
import { requireAdminEdition } from "../auth.js";
|
|
4
5
|
import { connectQuest } from "../client.js";
|
|
5
6
|
import { isPrecheckKey, precheckStageId, } from "../contract.js";
|
|
6
7
|
import { EXIT_CHECK_FAILED, UsageError } from "../errors.js";
|
|
@@ -9,6 +10,7 @@ import { readHarborBundle } from "../harbor.js";
|
|
|
9
10
|
import { DEFAULT_MAX_STEP_MS, DEFAULT_POLL_MS, runChecks, } from "../plan.js";
|
|
10
11
|
import { DEFAULT_QUEST } from "../quests.js";
|
|
11
12
|
import { exitCodeFor, modeLabel, renderTable, writeReport, } from "../report.js";
|
|
13
|
+
import { authorChecks } from "./author-checks.js";
|
|
12
14
|
const color = () => Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
|
|
13
15
|
const questArg = {
|
|
14
16
|
quest: {
|
|
@@ -26,7 +28,6 @@ function parsePositiveNumber(raw, fallback, flag) {
|
|
|
26
28
|
}
|
|
27
29
|
return parsed;
|
|
28
30
|
}
|
|
29
|
-
/** "a + b → c": steps grouped by dependency depth. */
|
|
30
31
|
export function formatSteps(check) {
|
|
31
32
|
const depth = new Map();
|
|
32
33
|
const resolve = (id, seen = []) => {
|
|
@@ -108,9 +109,6 @@ function progressPrinter() {
|
|
|
108
109
|
? ` ${dim("▸", c)} ${event.checkKey} triggered`
|
|
109
110
|
: ` ${statusBadge("skipped", c)} ${event.checkKey} not started${event.detail ? `: ${event.detail}` : ""}`);
|
|
110
111
|
break;
|
|
111
|
-
case "live:nudge":
|
|
112
|
-
console.error(` ${dim("▸", c)} ${event.checkKey} nudging synthesis`);
|
|
113
|
-
break;
|
|
114
112
|
case "check:end": {
|
|
115
113
|
const r = event.result;
|
|
116
114
|
const verdict = r.verdict ? ` (${r.verdict})` : "";
|
|
@@ -122,8 +120,6 @@ function progressPrinter() {
|
|
|
122
120
|
}
|
|
123
121
|
};
|
|
124
122
|
}
|
|
125
|
-
// Never exits the process directly: every path aborts the run and lets the
|
|
126
|
-
// command finish writing the report (handles included) before exit 3.
|
|
127
123
|
function installInterruptHandler(controller, state) {
|
|
128
124
|
let asked = false;
|
|
129
125
|
const leaveRunning = () => {
|
|
@@ -162,7 +158,6 @@ function installInterruptHandler(controller, state) {
|
|
|
162
158
|
process.off("SIGINT", onSigint);
|
|
163
159
|
};
|
|
164
160
|
}
|
|
165
|
-
/** Lines for `--dry-run --task`: what would be dispatched, without dispatching. */
|
|
166
161
|
export function dryRunTaskLines(task, checks) {
|
|
167
162
|
return [
|
|
168
163
|
`Task ${task.problemId} ("${task.title}", ${task.status}) — ${task.url}`,
|
|
@@ -268,7 +263,6 @@ async function startWithoutWaiting(api, target, checks, options) {
|
|
|
268
263
|
}
|
|
269
264
|
return failures > 0 ? EXIT_CHECK_FAILED : 0;
|
|
270
265
|
}
|
|
271
|
-
/** Parse `status`/`cancel` positionals: a handle JSON string or a report file path. */
|
|
272
266
|
async function readHandles(raw) {
|
|
273
267
|
if (raw.length === 0) {
|
|
274
268
|
throw new UsageError("Pass one or more handles (JSON from --no-wait) or a report file path.");
|
|
@@ -316,12 +310,16 @@ async function readHandles(raw) {
|
|
|
316
310
|
return handles;
|
|
317
311
|
}
|
|
318
312
|
const list = defineCommand({
|
|
319
|
-
meta: {
|
|
313
|
+
meta: {
|
|
314
|
+
name: "list",
|
|
315
|
+
description: "List the checks a quest offers for ad-hoc runs (admin edition)",
|
|
316
|
+
},
|
|
320
317
|
args: {
|
|
321
318
|
...questArg,
|
|
322
319
|
json: { type: "boolean", description: "Output as JSON" },
|
|
323
320
|
},
|
|
324
321
|
run: async ({ args }) => {
|
|
322
|
+
requireAdminEdition();
|
|
325
323
|
const api = await connectQuest(args.quest);
|
|
326
324
|
const catalog = await api.listChecks();
|
|
327
325
|
if (args.json) {
|
|
@@ -354,7 +352,7 @@ const list = defineCommand({
|
|
|
354
352
|
const run = defineCommand({
|
|
355
353
|
meta: {
|
|
356
354
|
name: "run",
|
|
357
|
-
description: "Run checks on a Harbor task directory (stateless or --create) or on a task (--task)",
|
|
355
|
+
description: "Run checks on a Harbor task directory (stateless or --create) or on a task (--task) (admin edition)",
|
|
358
356
|
},
|
|
359
357
|
args: {
|
|
360
358
|
dir: { type: "positional", description: "Harbor task directory", required: false },
|
|
@@ -397,6 +395,7 @@ const run = defineCommand({
|
|
|
397
395
|
timeout: { type: "string", description: "Per-step ceiling in minutes (default 180)" },
|
|
398
396
|
},
|
|
399
397
|
run: async ({ args }) => {
|
|
398
|
+
requireAdminEdition();
|
|
400
399
|
const dir = args.dir;
|
|
401
400
|
if (!dir && !args.task)
|
|
402
401
|
throw new UsageError("Pass a Harbor directory or --task <problemId>.");
|
|
@@ -415,7 +414,6 @@ const run = defineCommand({
|
|
|
415
414
|
options.agentModel = args.model;
|
|
416
415
|
if (args.effort)
|
|
417
416
|
options.reasoningEffort = args.effort;
|
|
418
|
-
// Bundle errors exit 2 before any network call.
|
|
419
417
|
const overrides = {
|
|
420
418
|
repo: args.repo,
|
|
421
419
|
commit: args.commit,
|
|
@@ -506,8 +504,6 @@ const run = defineCommand({
|
|
|
506
504
|
target = { kind: "harbor", bundle: bundle };
|
|
507
505
|
}
|
|
508
506
|
if (!args.wait) {
|
|
509
|
-
// Checks `adapt` marked ineligible never start; with an explicit
|
|
510
|
-
// --check list they still count as a failure, like in the waited run.
|
|
511
507
|
const skipped = Object.values(report.checks).filter((c) => c.status === "skipped");
|
|
512
508
|
for (const check of skipped) {
|
|
513
509
|
console.log(JSON.stringify({ checkKey: check.key, kind: "skipped", reason: check.reason }));
|
|
@@ -572,13 +568,17 @@ const run = defineCommand({
|
|
|
572
568
|
},
|
|
573
569
|
});
|
|
574
570
|
const status = defineCommand({
|
|
575
|
-
meta: {
|
|
571
|
+
meta: {
|
|
572
|
+
name: "status",
|
|
573
|
+
description: "Poll handles printed by `checks run --no-wait` (admin edition)",
|
|
574
|
+
},
|
|
576
575
|
args: {
|
|
577
576
|
handles: { type: "positional", description: "Handle JSON or a report file", required: false },
|
|
578
577
|
...questArg,
|
|
579
578
|
json: { type: "boolean", description: "Output as JSON lines" },
|
|
580
579
|
},
|
|
581
580
|
run: async ({ args }) => {
|
|
581
|
+
requireAdminEdition();
|
|
582
582
|
const handles = await readHandles(args._);
|
|
583
583
|
const api = await connectQuest(args.quest);
|
|
584
584
|
const rows = [];
|
|
@@ -624,13 +624,17 @@ const status = defineCommand({
|
|
|
624
624
|
},
|
|
625
625
|
});
|
|
626
626
|
const cancel = defineCommand({
|
|
627
|
-
meta: {
|
|
627
|
+
meta: {
|
|
628
|
+
name: "cancel",
|
|
629
|
+
description: "Cancel handles printed by `checks run --no-wait` (admin edition)",
|
|
630
|
+
},
|
|
628
631
|
args: {
|
|
629
632
|
handles: { type: "positional", description: "Handle JSON or a report file", required: false },
|
|
630
633
|
...questArg,
|
|
631
634
|
json: { type: "boolean", description: "Output as JSON lines" },
|
|
632
635
|
},
|
|
633
636
|
run: async ({ args }) => {
|
|
637
|
+
requireAdminEdition();
|
|
634
638
|
const handles = await readHandles(args._);
|
|
635
639
|
const api = await connectQuest(args.quest);
|
|
636
640
|
let failures = 0;
|
|
@@ -663,7 +667,7 @@ const cancel = defineCommand({
|
|
|
663
667
|
export default defineCommand({
|
|
664
668
|
meta: {
|
|
665
669
|
name: "checks",
|
|
666
|
-
description: "
|
|
670
|
+
description: "Your challenges' checks (view, run-check, run-all, run-prechecks, run-trial-qa, wait); ad-hoc quest checks for admins (list, run, status, cancel)",
|
|
667
671
|
},
|
|
668
|
-
subCommands: { list, run, status, cancel },
|
|
672
|
+
subCommands: { ...authorChecks, list, run, status, cancel },
|
|
669
673
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const problems: import("citty").CommandDef<import("citty").ArgsDef>;
|