@shipd-ai/cli 0.1.3 → 0.3.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 +172 -42
- 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 +10 -0
- package/dist/checks-view.js +12 -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 +306 -0
- package/dist/commands/author-checks.js +430 -0
- package/dist/commands/author-content.d.ts +198 -0
- package/dist/commands/author-content.js +102 -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 +196 -0
- package/dist/commands/quests.d.ts +0 -1
- package/dist/commands/quests.js +0 -1
- package/dist/commands/runs.d.ts +54 -0
- package/dist/commands/runs.js +143 -0
- package/dist/content.d.ts +105 -0
- package/dist/content.js +240 -0
- 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 +15 -10
- package/dist/model.d.ts +128 -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/runs.d.ts +36 -0
- package/dist/runs.js +59 -0
- package/dist/usage.d.ts +2 -0
- package/dist/usage.js +16 -0
- package/package.json +3 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { api, backend, connectAuthor } from "../author.js";
|
|
3
|
+
import { applyClears, CONTENT_FILES, contentFromChallenge, countFields, FIELD_FLAGS, readContentDir, TASK_JSON, updatesFromFlags, writeContentDir, } from "../content.js";
|
|
4
|
+
import { UsageError } from "../errors.js";
|
|
5
|
+
import { printJson, text } from "../format.js";
|
|
6
|
+
import { DEFAULT_QUEST } from "../quests.js";
|
|
7
|
+
import { questArg } from "./author-checks.js";
|
|
8
|
+
const dirArg = {
|
|
9
|
+
dir: {
|
|
10
|
+
type: "string",
|
|
11
|
+
alias: "d",
|
|
12
|
+
description: `Directory of content files (${TASK_JSON}, ${Object.values(CONTENT_FILES).join(", ")})`,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
function collectUpdates(args) {
|
|
16
|
+
const fromDir = args.dir ? readContentDir(args.dir) : {};
|
|
17
|
+
const updates = updatesFromFlags(args, fromDir);
|
|
18
|
+
return applyClears(updates, args.clear);
|
|
19
|
+
}
|
|
20
|
+
function printSaved(result, quest) {
|
|
21
|
+
const questFlag = quest === DEFAULT_QUEST ? "" : ` --quest ${quest}`;
|
|
22
|
+
console.log(`\n Saved ${text(result.problemId)}`);
|
|
23
|
+
if (result.versionId)
|
|
24
|
+
console.log(` Version ${text(result.versionId)}`);
|
|
25
|
+
console.log(`\n Next: shipd problems view ${text(result.problemId)}${questFlag}\n`);
|
|
26
|
+
}
|
|
27
|
+
export const create = defineCommand({
|
|
28
|
+
meta: { name: "create", description: "Create a draft challenge from files and/or flags" },
|
|
29
|
+
args: {
|
|
30
|
+
...dirArg,
|
|
31
|
+
...FIELD_FLAGS,
|
|
32
|
+
...questArg,
|
|
33
|
+
json: { type: "boolean", description: "Output the new ids as JSON" },
|
|
34
|
+
},
|
|
35
|
+
run: async ({ args }) => {
|
|
36
|
+
const updates = collectUpdates(args);
|
|
37
|
+
const client = await connectAuthor(args.quest);
|
|
38
|
+
const result = (await backend(() => client.mutation(api.problems.createDraft, updates)));
|
|
39
|
+
if (args.json) {
|
|
40
|
+
printJson(result);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
console.log(`\n Created a draft with ${countFields(updates)} field(s).`);
|
|
44
|
+
printSaved(result, args.quest);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
export const pull = defineCommand({
|
|
48
|
+
meta: { name: "pull", description: "Write a challenge's saved content into a directory" },
|
|
49
|
+
args: {
|
|
50
|
+
id: { type: "positional", description: "Challenge ID", required: true },
|
|
51
|
+
dir: { type: "string", alias: "d", description: "Directory to write (default: the id)" },
|
|
52
|
+
...questArg,
|
|
53
|
+
json: { type: "boolean", description: "Print the content as JSON instead of writing files" },
|
|
54
|
+
},
|
|
55
|
+
run: async ({ args }) => {
|
|
56
|
+
const client = await connectAuthor(args.quest);
|
|
57
|
+
const data = (await backend(() => client.query(api.problems.getWithLatestVersion, { problemId: args.id })));
|
|
58
|
+
if (!data)
|
|
59
|
+
throw new UsageError(`Challenge not found: ${text(args.id)}`);
|
|
60
|
+
const content = contentFromChallenge(data, data.latestVersion);
|
|
61
|
+
if (args.json) {
|
|
62
|
+
printJson(content);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const dir = args.dir ?? args.id;
|
|
66
|
+
const { written, removed } = writeContentDir(dir, content);
|
|
67
|
+
console.log(`\n Pulled ${text(args.id)} into ${dir}:`);
|
|
68
|
+
for (const path of written)
|
|
69
|
+
console.log(` ${path}`);
|
|
70
|
+
for (const path of removed)
|
|
71
|
+
console.log(` removed ${path} (the challenge no longer has it)`);
|
|
72
|
+
console.log("");
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
export const push = defineCommand({
|
|
76
|
+
meta: { name: "push", description: "Save content files and/or flags onto a challenge's draft" },
|
|
77
|
+
args: {
|
|
78
|
+
id: { type: "positional", description: "Challenge ID", required: true },
|
|
79
|
+
...dirArg,
|
|
80
|
+
...FIELD_FLAGS,
|
|
81
|
+
clear: {
|
|
82
|
+
type: "string",
|
|
83
|
+
description: "Comma-separated text fields to empty (e.g. hintText,githubIssueUrl)",
|
|
84
|
+
},
|
|
85
|
+
...questArg,
|
|
86
|
+
json: { type: "boolean", description: "Output the saved ids as JSON" },
|
|
87
|
+
},
|
|
88
|
+
run: async ({ args }) => {
|
|
89
|
+
const updates = collectUpdates(args);
|
|
90
|
+
if (countFields(updates) === 0) {
|
|
91
|
+
throw new UsageError("Nothing to push: name a directory with -d, or a field flag.");
|
|
92
|
+
}
|
|
93
|
+
const client = await connectAuthor(args.quest);
|
|
94
|
+
const result = (await backend(() => client.mutation(api.problems.updateDraft, { problemId: args.id, ...updates })));
|
|
95
|
+
if (args.json) {
|
|
96
|
+
printJson(result);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
console.log(`\n Pushed ${countFields(updates)} field(s).`);
|
|
100
|
+
printSaved(result, args.quest);
|
|
101
|
+
},
|
|
102
|
+
});
|
|
@@ -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-scope-gate, 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>;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { api, backend, connectAuthor } from "../author.js";
|
|
3
|
+
import { UsageError } from "../errors.js";
|
|
4
|
+
import { dim, paint, printJson, printKeyValue, printTable, statusBadge, text, truncate, } from "../format.js";
|
|
5
|
+
import { DEFAULT_QUEST } from "../quests.js";
|
|
6
|
+
import { printPrechecks, printQualityChecks, printReadiness, printTrialQa, questArg, } from "./author-checks.js";
|
|
7
|
+
import { create, pull, push } from "./author-content.js";
|
|
8
|
+
const DEFAULT_LIMIT = 30;
|
|
9
|
+
const color = () => Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
|
|
10
|
+
function field(value) {
|
|
11
|
+
if (value === undefined || value === null || value === "")
|
|
12
|
+
return undefined;
|
|
13
|
+
return text(value);
|
|
14
|
+
}
|
|
15
|
+
function printRunCriteria(criteria, c) {
|
|
16
|
+
const criteriaList = criteria?.criteria;
|
|
17
|
+
if (!criteriaList || criteriaList.length === 0)
|
|
18
|
+
return;
|
|
19
|
+
console.log("\n Rollout Criteria:");
|
|
20
|
+
for (const criterion of criteriaList) {
|
|
21
|
+
const detail = criterion.detail ? ` ${text(criterion.detail)}` : "";
|
|
22
|
+
const preview = criterion.preview ? ` ${dim("(preview)", c)}` : "";
|
|
23
|
+
console.log(` ${statusBadge(criterion.status, c)} ${text(criterion.label)}${detail}${preview}`);
|
|
24
|
+
if (criterion.description) {
|
|
25
|
+
console.log(` ${dim(`Target: ${text(criterion.description)}`, c)}`);
|
|
26
|
+
}
|
|
27
|
+
if (criterion.guidance) {
|
|
28
|
+
console.log(` ${paint("yellow", truncate(text(criterion.guidance), 100), c)}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const list = defineCommand({
|
|
33
|
+
meta: { name: "list", description: "List your challenges" },
|
|
34
|
+
args: {
|
|
35
|
+
...questArg,
|
|
36
|
+
status: { type: "string", description: "Filter by status" },
|
|
37
|
+
limit: { type: "string", description: `Max results (default ${DEFAULT_LIMIT})` },
|
|
38
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
39
|
+
},
|
|
40
|
+
run: async ({ args }) => {
|
|
41
|
+
const client = await connectAuthor(args.quest);
|
|
42
|
+
const limit = Number.parseInt(args.limit ?? "", 10) || DEFAULT_LIMIT;
|
|
43
|
+
const queryArgs = {};
|
|
44
|
+
if (args.status)
|
|
45
|
+
queryArgs.status = args.status;
|
|
46
|
+
const problems = (await backend(() => client.query(api.problems.listByUser, queryArgs)));
|
|
47
|
+
if (!problems || problems.length === 0) {
|
|
48
|
+
if (args.json)
|
|
49
|
+
printJson([]);
|
|
50
|
+
else
|
|
51
|
+
console.log(" No challenges found.");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
problems.sort((a, b) => (b._creationTime ?? 0) - (a._creationTime ?? 0));
|
|
55
|
+
const display = problems.slice(0, limit);
|
|
56
|
+
if (args.json) {
|
|
57
|
+
printJson(display);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const c = color();
|
|
61
|
+
printTable(display.map((problem) => ({
|
|
62
|
+
id: String(problem._id),
|
|
63
|
+
title: truncate(text(problem.title ?? ""), 50),
|
|
64
|
+
status: statusBadge(problem.status ?? "unknown", c),
|
|
65
|
+
lang: text(problem.language ?? ""),
|
|
66
|
+
diff: text(problem.difficulty ?? ""),
|
|
67
|
+
})), [
|
|
68
|
+
{ key: "id", label: "ID" },
|
|
69
|
+
{ key: "title", label: "Title", width: 52 },
|
|
70
|
+
{ key: "status", label: "Status", width: 24 },
|
|
71
|
+
{ key: "lang", label: "Lang", width: 12 },
|
|
72
|
+
{ key: "diff", label: "Diff", width: 8 },
|
|
73
|
+
]);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
const view = defineCommand({
|
|
77
|
+
meta: {
|
|
78
|
+
name: "view",
|
|
79
|
+
description: "View a challenge: its latest version, checks and readiness",
|
|
80
|
+
},
|
|
81
|
+
args: {
|
|
82
|
+
id: { type: "positional", description: "Challenge ID", required: true },
|
|
83
|
+
...questArg,
|
|
84
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
85
|
+
},
|
|
86
|
+
run: async ({ args }) => {
|
|
87
|
+
const client = await connectAuthor(args.quest);
|
|
88
|
+
const problemId = args.id;
|
|
89
|
+
const data = (await backend(() => client.query(api.problems.getWithLatestVersion, { problemId })));
|
|
90
|
+
if (!data) {
|
|
91
|
+
throw new UsageError(`Challenge not found: ${text(problemId)}`);
|
|
92
|
+
}
|
|
93
|
+
const latestVersion = data.latestVersion;
|
|
94
|
+
const [stages, dynamicChecks, trialQa, criteria, readiness] = latestVersion
|
|
95
|
+
? await backend(() => Promise.all([
|
|
96
|
+
client.query(api.stages.getValidationResults, {
|
|
97
|
+
itemId: problemId,
|
|
98
|
+
versionId: latestVersion._id,
|
|
99
|
+
}),
|
|
100
|
+
client.query(api.runDynamicChecks.getDynamicChecks, { versionId: latestVersion._id }),
|
|
101
|
+
client.query(api.fpReview.getFpCheckForVersion, { versionId: latestVersion._id }),
|
|
102
|
+
client.query(api.runAgentRuns.getAgentRunCriteria, { versionId: latestVersion._id }),
|
|
103
|
+
client.query(api.submissionReadiness.getSubmissionReadiness, { problemId }),
|
|
104
|
+
]))
|
|
105
|
+
: [[], null, null, null, null];
|
|
106
|
+
if (args.json) {
|
|
107
|
+
printJson({
|
|
108
|
+
...data,
|
|
109
|
+
checks: { stages, dynamicChecks, trialQa, readiness },
|
|
110
|
+
rolloutCriteria: criteria,
|
|
111
|
+
});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const c = color();
|
|
115
|
+
console.log("");
|
|
116
|
+
printKeyValue([
|
|
117
|
+
["ID", String(data._id)],
|
|
118
|
+
["Title", field(data.title)],
|
|
119
|
+
["Status", statusBadge(data.status ?? "unknown", c)],
|
|
120
|
+
[
|
|
121
|
+
"Version",
|
|
122
|
+
latestVersion
|
|
123
|
+
? `v${latestVersion.version}${latestVersion.isLocked ? " (locked)" : " (unlocked)"}`
|
|
124
|
+
: "none",
|
|
125
|
+
],
|
|
126
|
+
["Language", field(latestVersion?.language ?? data.language)],
|
|
127
|
+
["Difficulty", field(latestVersion?.difficulty ?? data.difficulty)],
|
|
128
|
+
["Category", field(latestVersion?.category ?? data.category)],
|
|
129
|
+
["Repo", field(latestVersion?.githubRepoUrl)],
|
|
130
|
+
["Commit", field(latestVersion?.githubCommitHash?.slice(0, 8))],
|
|
131
|
+
["Test Patch", latestVersion?.testPatch ? "yes" : "no"],
|
|
132
|
+
["Solution", latestVersion?.solutionPatch ? "yes" : "no"],
|
|
133
|
+
["Dockerfile", latestVersion?.dockerfile ? "yes" : "no"],
|
|
134
|
+
]);
|
|
135
|
+
if (latestVersion?.description) {
|
|
136
|
+
const description = text(latestVersion.description)
|
|
137
|
+
.split("\n")
|
|
138
|
+
.map((line) => ` ${line}`)
|
|
139
|
+
.join("\n");
|
|
140
|
+
console.log(`\n Description:\n${description}`);
|
|
141
|
+
}
|
|
142
|
+
printReadiness(readiness, c);
|
|
143
|
+
console.log("");
|
|
144
|
+
printPrechecks(stages, c, false);
|
|
145
|
+
printQualityChecks(dynamicChecks, c, false);
|
|
146
|
+
printTrialQa(trialQa, c);
|
|
147
|
+
printRunCriteria(criteria, c);
|
|
148
|
+
const questFlag = args.quest === DEFAULT_QUEST ? "" : ` --quest ${args.quest}`;
|
|
149
|
+
console.log("\n Commands:");
|
|
150
|
+
console.log(` shipd checks view ${problemId}${questFlag} Checks + readiness detail`);
|
|
151
|
+
console.log(` shipd checks run-prechecks ${problemId}${questFlag} Run the prechecks`);
|
|
152
|
+
console.log(` shipd checks run-all ${problemId}${questFlag} Run the quality checks`);
|
|
153
|
+
console.log(` shipd checks run-trial-qa ${problemId}${questFlag} Run Trial QA`);
|
|
154
|
+
console.log(` shipd problems versions ${problemId}${questFlag} List all versions`);
|
|
155
|
+
console.log(` shipd problems pull ${problemId} -d <dir>${questFlag} Write the content as files`);
|
|
156
|
+
console.log(` shipd problems push ${problemId} -d <dir>${questFlag} Save edited files`);
|
|
157
|
+
console.log(` shipd runs list ${problemId}${questFlag} Agent runs (download their files)`);
|
|
158
|
+
console.log("");
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
const versions = defineCommand({
|
|
162
|
+
meta: { name: "versions", description: "List all versions of a challenge" },
|
|
163
|
+
args: {
|
|
164
|
+
id: { type: "positional", description: "Challenge ID", required: true },
|
|
165
|
+
...questArg,
|
|
166
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
167
|
+
},
|
|
168
|
+
run: async ({ args }) => {
|
|
169
|
+
const client = await connectAuthor(args.quest);
|
|
170
|
+
const versions = (await backend(() => client.query(api.problems.listVersions, { problemId: args.id })));
|
|
171
|
+
if (args.json) {
|
|
172
|
+
printJson(versions ?? []);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const list = Array.isArray(versions) ? versions : [];
|
|
176
|
+
if (list.length === 0) {
|
|
177
|
+
console.log(" No versions found.");
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const c = color();
|
|
181
|
+
console.log("");
|
|
182
|
+
for (const item of list) {
|
|
183
|
+
const locked = item.isLocked ? ` ${paint("yellow", "(locked)", c)}` : "";
|
|
184
|
+
const date = new Date(item._creationTime ?? 0).toLocaleDateString();
|
|
185
|
+
console.log(` v${item.version}${locked} ${date}`);
|
|
186
|
+
}
|
|
187
|
+
console.log("");
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
export const problems = defineCommand({
|
|
191
|
+
meta: {
|
|
192
|
+
name: "problems",
|
|
193
|
+
description: "Your challenges: list, view, versions; create, pull and push their content",
|
|
194
|
+
},
|
|
195
|
+
subCommands: { list, view, versions, create, pull, push },
|
|
196
|
+
});
|
|
@@ -3,7 +3,6 @@ export type QuestRow = {
|
|
|
3
3
|
baseUrl: string;
|
|
4
4
|
default: boolean;
|
|
5
5
|
};
|
|
6
|
-
/** The quests this CLI knows how to talk to, with their resolved base URLs. */
|
|
7
6
|
export declare function listQuests(): QuestRow[];
|
|
8
7
|
export declare const quests: import("citty").CommandDef<{
|
|
9
8
|
readonly json: {
|
package/dist/commands/quests.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { defineCommand } from "citty";
|
|
2
2
|
import { printJson, printTable } from "../format.js";
|
|
3
3
|
import { DEFAULT_QUEST, knownQuests, questBaseUrl } from "../quests.js";
|
|
4
|
-
/** The quests this CLI knows how to talk to, with their resolved base URLs. */
|
|
5
4
|
export function listQuests() {
|
|
6
5
|
return knownQuests().map((quest) => ({
|
|
7
6
|
quest,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const list: import("citty").CommandDef<{
|
|
2
|
+
readonly json: {
|
|
3
|
+
readonly type: "boolean";
|
|
4
|
+
readonly description: "Output as JSON";
|
|
5
|
+
};
|
|
6
|
+
readonly quest: {
|
|
7
|
+
readonly type: "string";
|
|
8
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
9
|
+
readonly default: "olympus";
|
|
10
|
+
};
|
|
11
|
+
readonly id: {
|
|
12
|
+
readonly type: "positional";
|
|
13
|
+
readonly description: "Challenge ID";
|
|
14
|
+
readonly required: true;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
export declare const download: import("citty").CommandDef<{
|
|
18
|
+
readonly json: {
|
|
19
|
+
readonly type: "boolean";
|
|
20
|
+
readonly description: "Output the saved paths as JSON";
|
|
21
|
+
};
|
|
22
|
+
readonly quest: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
25
|
+
readonly default: "olympus";
|
|
26
|
+
};
|
|
27
|
+
readonly id: {
|
|
28
|
+
readonly type: "positional";
|
|
29
|
+
readonly description: "Challenge ID";
|
|
30
|
+
readonly required: true;
|
|
31
|
+
};
|
|
32
|
+
readonly run: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly description: "Run id (from `runs list`)";
|
|
35
|
+
};
|
|
36
|
+
readonly all: {
|
|
37
|
+
readonly type: "boolean";
|
|
38
|
+
readonly description: "Every run on the latest version";
|
|
39
|
+
};
|
|
40
|
+
readonly artifact: {
|
|
41
|
+
readonly type: "string";
|
|
42
|
+
readonly description: `Comma-separated files: ${string} (default: all)`;
|
|
43
|
+
};
|
|
44
|
+
readonly "all-artifacts": {
|
|
45
|
+
readonly type: "boolean";
|
|
46
|
+
readonly description: "Every file the run detail offers";
|
|
47
|
+
};
|
|
48
|
+
readonly dir: {
|
|
49
|
+
readonly type: "string";
|
|
50
|
+
readonly alias: "d";
|
|
51
|
+
readonly description: "Directory to write into (default: runs)";
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
export declare const runs: import("citty").CommandDef<import("citty").ArgsDef>;
|