@shipd-ai/cli 0.2.0 → 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 +62 -7
- package/dist/checks-view.d.ts +2 -1
- package/dist/checks-view.js +3 -2
- package/dist/commands/author-checks.d.ts +42 -1
- package/dist/commands/author-checks.js +71 -6
- package/dist/commands/author-content.d.ts +198 -0
- package/dist/commands/author-content.js +102 -0
- package/dist/commands/checks.js +1 -1
- package/dist/commands/problems.js +9 -2
- 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/index.js +4 -3
- package/dist/model.d.ts +34 -0
- package/dist/runs.d.ts +36 -0
- package/dist/runs.js +59 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ default when `--quest` is omitted).
|
|
|
17
17
|
## Install and sign in
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install -g @shipd-ai/cli@0.
|
|
20
|
+
npm install -g @shipd-ai/cli@0.3.0
|
|
21
21
|
shipd login # opens https://shipd.ai/quests/olympus/cli-auth; or: shipd login --token <jwt>
|
|
22
22
|
shipd whoami # who you are and which edition the token is
|
|
23
23
|
shipd quests # which quests this CLI can talk to
|
|
@@ -41,9 +41,16 @@ enrollment (or admin access) ends, from the next command on.
|
|
|
41
41
|
shipd problems list [--status <status>] [--limit <n>]
|
|
42
42
|
shipd problems view <challenge-id>
|
|
43
43
|
shipd problems versions <challenge-id>
|
|
44
|
+
shipd problems create [-d <dir>] [--title … --language … --repo … --test-patch-file … …]
|
|
45
|
+
shipd problems pull <challenge-id> -d <dir>
|
|
46
|
+
shipd problems push <challenge-id> [-d <dir>] [--title … --description-file … --clear <fields>]
|
|
47
|
+
|
|
48
|
+
shipd runs list <challenge-id>
|
|
49
|
+
shipd runs download <challenge-id> (--run <runId> | --all) [--artifact <keys> | --all-artifacts] -d <dir>
|
|
44
50
|
|
|
45
51
|
shipd checks view <challenge-id>
|
|
46
52
|
shipd checks run-prechecks <challenge-id>
|
|
53
|
+
shipd checks run-scope-gate <challenge-id>
|
|
47
54
|
shipd checks run-check <challenge-id> --check <checkKey>
|
|
48
55
|
shipd checks run-all <challenge-id>
|
|
49
56
|
shipd checks run-trial-qa <challenge-id>
|
|
@@ -54,15 +61,63 @@ shipd checks wait <challenge-id> [--interval <s>] [--timeout <min>]
|
|
|
54
61
|
quality checks, Trial QA and the rollout criteria. The CLI reaches only the
|
|
55
62
|
challenges you author or co-author; any other id is "not found".
|
|
56
63
|
|
|
64
|
+
### Content files
|
|
65
|
+
|
|
66
|
+
`problems pull` writes a challenge's saved content into a directory and
|
|
67
|
+
`problems push` saves the files found there (and any field flags) back onto
|
|
68
|
+
the draft; `problems create` makes a new draft from the same files/flags.
|
|
69
|
+
The layout is the editor's fields, named as the quest names them:
|
|
70
|
+
|
|
71
|
+
| File | Field |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `task.json` | `title`, `language`, `category`, `difficulty`, `githubRepoUrl`, `githubCommitHash`, `githubIssueUrl`, `testOutputMode` (`exit_code` \| `junit_xml`), `estimatedLOC` |
|
|
74
|
+
| `description.md` | `description` |
|
|
75
|
+
| `Dockerfile` | `dockerfile` |
|
|
76
|
+
| `test.patch` | `testPatch` |
|
|
77
|
+
| `solution.patch` | `solutionPatch` |
|
|
78
|
+
| `approach.md` | `solutionApproach` |
|
|
79
|
+
| `environment.md` | `environmentDescription` |
|
|
80
|
+
| `hint.md` | `hintText` |
|
|
81
|
+
| `hint-justification.md` | `hintJustification` |
|
|
82
|
+
|
|
83
|
+
`push` sends only what is present: a missing file or key leaves the saved
|
|
84
|
+
value alone, a flag beats the directory, `--clear hintText,githubIssueUrl`
|
|
85
|
+
empties a text field on purpose, and `--<field>-file -` reads one file from
|
|
86
|
+
stdin. Every save goes through the editor's own rules on the quest: your own
|
|
87
|
+
or co-authored draft only, no edits to a locked (submitted) version or an
|
|
88
|
+
archived draft, the patch size ceilings, the repository and field validators;
|
|
89
|
+
a refusal prints the page's message (exit 1). Build Image, the Scope Gate,
|
|
90
|
+
submitting and archiving stay page steps.
|
|
91
|
+
|
|
92
|
+
### Agent runs
|
|
93
|
+
|
|
94
|
+
`runs list` shows the latest version's agent runs as the checks tab lists
|
|
95
|
+
them (agent codename, status, verdict, flags, times). `runs download` saves a
|
|
96
|
+
run's files under `<dir>/<runId>/` with the names the page's own download
|
|
97
|
+
uses: `trajectory.json`, `workspace-diff.patch`, `solution-patch.patch`,
|
|
98
|
+
`test-log.txt`, `junit-baseline.xml`, `junit-new.xml`, `eval-result.json` —
|
|
99
|
+
fetched through the page's own download, the evaluator's result through the
|
|
100
|
+
same free-text filter the page applies. A file the quest does not hand an
|
|
101
|
+
author (admin-only diagnostics, a quality check's agent files) or that a run
|
|
102
|
+
never produced is reported as skipped. A later `pull` into the same directory
|
|
103
|
+
removes a content file the challenge no longer has, so a push after it cannot
|
|
104
|
+
restore a cleared field.
|
|
105
|
+
|
|
57
106
|
- `run-prechecks` runs the precheck stages on the saved version, as the page's
|
|
58
107
|
Run button does.
|
|
59
108
|
- `run-check` runs one quality check (`verifyTests`, `verifySolution`,
|
|
60
109
|
`verifyFlakiness`, `descriptionQuality`, `solutionQuality`, `rewardHacking`,
|
|
61
110
|
`verifyFairness`); `run-all` runs that set, the one the page's Run Checks
|
|
62
|
-
runs, in check order. The image build stays the page's Build Image button
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
111
|
+
runs, in check order. The image build stays the page's Build Image button,
|
|
112
|
+
the one step with no CLI command.
|
|
113
|
+
- `run-scope-gate` runs the Scope Gate as the page's card does, once the
|
|
114
|
+
prechecks pass: the card's own rules apply (your own draft, an unlocked
|
|
115
|
+
version, no run in flight, a verdict not already final for this exact
|
|
116
|
+
content, fresh passing prechecks, a description and both patches, a
|
|
117
|
+
connected GitHub account) and the same 4 tokens are charged; `checks view`
|
|
118
|
+
shows the standing verdict, its reasoning and findings, and `wait` counts a
|
|
119
|
+
gate in flight as active. `run-all` before the gate has passed prints the
|
|
120
|
+
page's refusal ("Run and pass the Scope Gate before running checks").
|
|
66
121
|
- `run-trial-qa` runs Trial QA on the current rollouts.
|
|
67
122
|
- `wait` polls until no check is active (nothing pending, running, waiting for
|
|
68
123
|
a prerequisite or in Trial QA), then prints the results; its progress goes
|
|
@@ -73,8 +128,8 @@ way (`--use-general-tokens` is the page's "use tokens instead" toggle), the
|
|
|
73
128
|
submission cooldown, the image build, the Scope Gate, the check order and the
|
|
74
129
|
locked-version rule all apply, and a refusal prints the message the page
|
|
75
130
|
shows (exit 1). Every command takes `--json`: `checks view --json` prints
|
|
76
|
-
`{ version, prechecks, dynamicChecks, trialQa, readiness }`, each
|
|
77
|
-
the quest returns it to the page.
|
|
131
|
+
`{ version, prechecks, scopeGate, dynamicChecks, trialQa, readiness }`, each
|
|
132
|
+
exactly as the quest returns it to the page.
|
|
78
133
|
|
|
79
134
|
## Admin ad-hoc checks
|
|
80
135
|
|
package/dist/checks-view.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare const CHECKS_VIEW_KEYS: readonly ["version", "prechecks", "dynamicChecks", "trialQa", "readiness"];
|
|
1
|
+
export declare const CHECKS_VIEW_KEYS: readonly ["version", "prechecks", "scopeGate", "dynamicChecks", "trialQa", "readiness"];
|
|
2
2
|
export type ChecksViewPayload = {
|
|
3
3
|
version: number;
|
|
4
4
|
prechecks: unknown;
|
|
5
|
+
scopeGate: unknown;
|
|
5
6
|
dynamicChecks: unknown;
|
|
6
7
|
trialQa: unknown;
|
|
7
8
|
readiness: unknown;
|
package/dist/checks-view.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export const CHECKS_VIEW_KEYS = [
|
|
2
2
|
"version",
|
|
3
3
|
"prechecks",
|
|
4
|
+
"scopeGate",
|
|
4
5
|
"dynamicChecks",
|
|
5
6
|
"trialQa",
|
|
6
7
|
"readiness",
|
|
7
8
|
];
|
|
8
9
|
export function buildChecksViewPayload(input) {
|
|
9
|
-
const { version, prechecks, dynamicChecks, trialQa, readiness } = input;
|
|
10
|
-
return { version, prechecks, dynamicChecks, trialQa, readiness };
|
|
10
|
+
const { version, prechecks, scopeGate, dynamicChecks, trialQa, readiness } = input;
|
|
11
|
+
return { version, prechecks, scopeGate, dynamicChecks, trialQa, readiness };
|
|
11
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type SubmissionReadiness, type TrialQaStatus } from "../model.js";
|
|
1
|
+
import { type ScopeGateStatus, type SubmissionReadiness, type TrialQaStatus } from "../model.js";
|
|
2
2
|
export declare const questArg: {
|
|
3
3
|
readonly quest: {
|
|
4
4
|
readonly type: "string";
|
|
@@ -10,6 +10,7 @@ export declare const RUN_ALL_CHECK_KEYS: readonly ["verifyTests", "verifySolutio
|
|
|
10
10
|
export declare function printPrechecks(results: unknown, c: boolean, emptyLine?: boolean): void;
|
|
11
11
|
export declare function printQualityChecks(dynamicChecks: unknown, c: boolean, emptyLine?: boolean): void;
|
|
12
12
|
export declare function printTrialQa(trialQa: TrialQaStatus | null, c: boolean): void;
|
|
13
|
+
export declare function printScopeGate(gate: ScopeGateStatus | null, c: boolean): void;
|
|
13
14
|
export declare function printReadiness(readiness: SubmissionReadiness | null, c: boolean): void;
|
|
14
15
|
export declare const view: import("citty").CommandDef<{
|
|
15
16
|
readonly json: {
|
|
@@ -112,6 +113,26 @@ export declare const runTrialQa: import("citty").CommandDef<{
|
|
|
112
113
|
readonly required: true;
|
|
113
114
|
};
|
|
114
115
|
}>;
|
|
116
|
+
export declare const runScopeGate: import("citty").CommandDef<{
|
|
117
|
+
readonly json: {
|
|
118
|
+
readonly type: "boolean";
|
|
119
|
+
readonly description: "Output as JSON";
|
|
120
|
+
};
|
|
121
|
+
readonly "use-general-tokens": {
|
|
122
|
+
readonly type: "boolean";
|
|
123
|
+
readonly description: "Charge general tokens instead of revision tokens";
|
|
124
|
+
};
|
|
125
|
+
readonly quest: {
|
|
126
|
+
readonly type: "string";
|
|
127
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
128
|
+
readonly default: "olympus";
|
|
129
|
+
};
|
|
130
|
+
readonly id: {
|
|
131
|
+
readonly type: "positional";
|
|
132
|
+
readonly description: "Challenge ID";
|
|
133
|
+
readonly required: true;
|
|
134
|
+
};
|
|
135
|
+
}>;
|
|
115
136
|
export declare const wait: import("citty").CommandDef<{
|
|
116
137
|
readonly interval: {
|
|
117
138
|
readonly type: "string";
|
|
@@ -218,6 +239,26 @@ export declare const authorChecks: {
|
|
|
218
239
|
readonly required: true;
|
|
219
240
|
};
|
|
220
241
|
}>;
|
|
242
|
+
"run-scope-gate": import("citty").CommandDef<{
|
|
243
|
+
readonly json: {
|
|
244
|
+
readonly type: "boolean";
|
|
245
|
+
readonly description: "Output as JSON";
|
|
246
|
+
};
|
|
247
|
+
readonly "use-general-tokens": {
|
|
248
|
+
readonly type: "boolean";
|
|
249
|
+
readonly description: "Charge general tokens instead of revision tokens";
|
|
250
|
+
};
|
|
251
|
+
readonly quest: {
|
|
252
|
+
readonly type: "string";
|
|
253
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
254
|
+
readonly default: "olympus";
|
|
255
|
+
};
|
|
256
|
+
readonly id: {
|
|
257
|
+
readonly type: "positional";
|
|
258
|
+
readonly description: "Challenge ID";
|
|
259
|
+
readonly required: true;
|
|
260
|
+
};
|
|
261
|
+
}>;
|
|
221
262
|
"run-trial-qa": import("citty").CommandDef<{
|
|
222
263
|
readonly json: {
|
|
223
264
|
readonly type: "boolean";
|
|
@@ -102,6 +102,29 @@ export function printTrialQa(trialQa, c) {
|
|
|
102
102
|
console.log(` ${dim(`${trialQa.tokenCost ?? 0} tokens to run`, c)}`);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
+
export function printScopeGate(gate, c) {
|
|
106
|
+
if (!gate)
|
|
107
|
+
return;
|
|
108
|
+
const verdict = gate.latestVerdict ?? (gate.inFlight ? "running" : "not_run");
|
|
109
|
+
const stale = gate.latestVerdict && !gate.fresh
|
|
110
|
+
? ` ${paint("yellow", gate.staleReason === "series" ? "(stale: a task on this repository changed)" : "(stale: edited since)", c)}`
|
|
111
|
+
: "";
|
|
112
|
+
const inFlight = gate.inFlight ? ` ${dim("(a run is in flight)", c)}` : "";
|
|
113
|
+
console.log(`\n Scope Gate:\n ${statusBadge(verdict, c)} Scope Gate${stale}${inFlight}`);
|
|
114
|
+
const output = gate.verdictRun?.output;
|
|
115
|
+
if (output?.reasoning) {
|
|
116
|
+
console.log(` ${truncate(text(output.reasoning), 160)}`);
|
|
117
|
+
}
|
|
118
|
+
for (const finding of output?.findings ?? []) {
|
|
119
|
+
const label = [finding.category, finding.severity].filter(Boolean).map(text).join(" / ");
|
|
120
|
+
const summary = finding.summary ? ` ${truncate(text(finding.summary), 120)}` : "";
|
|
121
|
+
if (label || summary)
|
|
122
|
+
console.log(` - ${label}${summary}`);
|
|
123
|
+
}
|
|
124
|
+
const error = gate.current?.error ?? gate.verdictRun?.error;
|
|
125
|
+
if (error)
|
|
126
|
+
console.log(` ${paint("red", `Error: ${truncate(text(error), 90)}`, c)}`);
|
|
127
|
+
}
|
|
105
128
|
export function printReadiness(readiness, c) {
|
|
106
129
|
if (!readiness)
|
|
107
130
|
return;
|
|
@@ -117,6 +140,7 @@ function printNextCommands(problemId, quest) {
|
|
|
117
140
|
console.log("\n Commands:");
|
|
118
141
|
console.log(` shipd problems view ${problemId}${questFlag} Full challenge detail`);
|
|
119
142
|
console.log(` shipd checks run-prechecks ${problemId}${questFlag} Run the prechecks`);
|
|
143
|
+
console.log(` shipd checks run-scope-gate ${problemId}${questFlag} Run the Scope Gate`);
|
|
120
144
|
console.log(` shipd checks run-all ${problemId}${questFlag} Run the quality checks`);
|
|
121
145
|
console.log(` shipd checks run-trial-qa ${problemId}${questFlag} Run Trial QA`);
|
|
122
146
|
console.log(` shipd checks wait ${problemId}${questFlag} Watch active checks`);
|
|
@@ -124,16 +148,19 @@ function printNextCommands(problemId, quest) {
|
|
|
124
148
|
async function readChecks(quest, problemId) {
|
|
125
149
|
const client = await connectAuthor(quest);
|
|
126
150
|
const { problem, version } = await requireProblemVersion(client, problemId);
|
|
127
|
-
const [stages, dynamicChecks, trialQa, readiness] = await backend(() => Promise.all([
|
|
151
|
+
const [stages, scopeGate, dynamicChecks, trialQa, readiness] = await backend(() => Promise.all([
|
|
128
152
|
client.query(api.stages.getValidationResults, {
|
|
129
153
|
itemId: problemId,
|
|
130
154
|
versionId: version._id,
|
|
131
155
|
}),
|
|
156
|
+
client.query(api.scopeGate.getScopeGate, {
|
|
157
|
+
versionId: version._id,
|
|
158
|
+
}),
|
|
132
159
|
client.query(api.runDynamicChecks.getDynamicChecks, { versionId: version._id }),
|
|
133
160
|
client.query(api.fpReview.getFpCheckForVersion, { versionId: version._id }),
|
|
134
161
|
client.query(api.submissionReadiness.getSubmissionReadiness, { problemId }),
|
|
135
162
|
]));
|
|
136
|
-
return { client, problem, version, stages, dynamicChecks, trialQa, readiness };
|
|
163
|
+
return { client, problem, version, stages, scopeGate, dynamicChecks, trialQa, readiness };
|
|
137
164
|
}
|
|
138
165
|
const tokensArg = {
|
|
139
166
|
"use-general-tokens": {
|
|
@@ -152,11 +179,12 @@ export const view = defineCommand({
|
|
|
152
179
|
json: { type: "boolean", description: "Output as JSON" },
|
|
153
180
|
},
|
|
154
181
|
run: async ({ args }) => {
|
|
155
|
-
const { version, stages, dynamicChecks, trialQa, readiness } = await readChecks(args.quest, args.id);
|
|
182
|
+
const { version, stages, scopeGate, dynamicChecks, trialQa, readiness } = await readChecks(args.quest, args.id);
|
|
156
183
|
if (args.json) {
|
|
157
184
|
printJson(buildChecksViewPayload({
|
|
158
185
|
version: version.version,
|
|
159
186
|
prechecks: stages,
|
|
187
|
+
scopeGate,
|
|
160
188
|
dynamicChecks,
|
|
161
189
|
trialQa,
|
|
162
190
|
readiness,
|
|
@@ -166,6 +194,7 @@ export const view = defineCommand({
|
|
|
166
194
|
const c = color();
|
|
167
195
|
console.log(`\n Checks for v${version.version}\n`);
|
|
168
196
|
printPrechecks(stages, c);
|
|
197
|
+
printScopeGate(scopeGate, c);
|
|
169
198
|
printQualityChecks(dynamicChecks, c);
|
|
170
199
|
printTrialQa(trialQa, c);
|
|
171
200
|
printReadiness(readiness, c);
|
|
@@ -286,6 +315,35 @@ export const runTrialQa = defineCommand({
|
|
|
286
315
|
console.log(` ${dim("Use `shipd checks wait <id>` to watch it.", c)}\n`);
|
|
287
316
|
},
|
|
288
317
|
});
|
|
318
|
+
export const runScopeGate = defineCommand({
|
|
319
|
+
meta: {
|
|
320
|
+
name: "run-scope-gate",
|
|
321
|
+
description: "Run the Scope Gate on the saved version (after the prechecks pass)",
|
|
322
|
+
},
|
|
323
|
+
args: {
|
|
324
|
+
id: { type: "positional", description: "Challenge ID", required: true },
|
|
325
|
+
...questArg,
|
|
326
|
+
...tokensArg,
|
|
327
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
328
|
+
},
|
|
329
|
+
run: async ({ args }) => {
|
|
330
|
+
const client = await connectAuthor(args.quest);
|
|
331
|
+
const { version } = await requireProblemVersion(client, args.id);
|
|
332
|
+
const result = (await backend(() => client.action(api.scopeGate.triggerScopeGate, {
|
|
333
|
+
versionId: version._id,
|
|
334
|
+
useGeneralTokens: args["use-general-tokens"] || undefined,
|
|
335
|
+
})));
|
|
336
|
+
if (args.json) {
|
|
337
|
+
printJson(result);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const c = color();
|
|
341
|
+
console.log(`\n Started the Scope Gate on v${version.version}`);
|
|
342
|
+
if (result?.jobId)
|
|
343
|
+
console.log(` ${dim(`Job ${text(result.jobId)}`, c)}`);
|
|
344
|
+
console.log(` ${dim(`Use \`shipd checks wait ${text(args.id)}\` to watch it; the quality checks unlock on a pass.`, c)}\n`);
|
|
345
|
+
},
|
|
346
|
+
});
|
|
289
347
|
export const wait = defineCommand({
|
|
290
348
|
meta: { name: "wait", description: "Wait for a challenge's active checks to finish" },
|
|
291
349
|
args: {
|
|
@@ -305,7 +363,7 @@ export const wait = defineCommand({
|
|
|
305
363
|
const { version } = await requireProblemVersion(client, problemId);
|
|
306
364
|
console.error(` Waiting for active checks on v${version.version}...`);
|
|
307
365
|
while (Date.now() - startedAt < timeoutMs) {
|
|
308
|
-
const [dynamicChecks, order, trialQa, stages] = await backend(() => Promise.all([
|
|
366
|
+
const [dynamicChecks, order, trialQa, stages, scopeGate] = await backend(() => Promise.all([
|
|
309
367
|
client.query(api.runDynamicChecks.getDynamicChecks, { versionId: version._id }),
|
|
310
368
|
client.query(api.runDynamicChecks.getCheckOrder, { versionId: version._id }),
|
|
311
369
|
client.query(api.fpReview.getFpCheckForVersion, {
|
|
@@ -315,22 +373,27 @@ export const wait = defineCommand({
|
|
|
315
373
|
itemId: problemId,
|
|
316
374
|
versionId: version._id,
|
|
317
375
|
}),
|
|
376
|
+
client.query(api.scopeGate.getScopeGate, {
|
|
377
|
+
versionId: version._id,
|
|
378
|
+
}),
|
|
318
379
|
]));
|
|
319
380
|
const checks = getDynamicCheckEntries(dynamicChecks);
|
|
320
381
|
const waitingCount = order?.waiting?.length ?? 0;
|
|
321
382
|
const running = checks.filter((check) => check.status === "pending" || check.status === "running");
|
|
322
383
|
const trialQaActive = trialQa?.state === "running" ? 1 : 0;
|
|
323
384
|
const pendingPrechecks = precheckStages(stages).filter((stage) => String(stage.status ?? "").toLowerCase() === "pending").length;
|
|
324
|
-
const
|
|
385
|
+
const gateActive = scopeGate?.inFlight ? 1 : 0;
|
|
386
|
+
const activeCount = running.length + waitingCount + trialQaActive + pendingPrechecks + gateActive;
|
|
325
387
|
const terminal = checks.filter((check) => check.status === "completed" || check.status === "failed");
|
|
326
388
|
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)`);
|
|
389
|
+
process.stderr.write(`\r ${terminal.length} complete, ${activeCount} active, ${checks.length + trialQaActive + pendingPrechecks + gateActive} total (${elapsed}s)`);
|
|
328
390
|
if (activeCount === 0) {
|
|
329
391
|
console.error("");
|
|
330
392
|
const readiness = await backend(() => client.query(api.submissionReadiness.getSubmissionReadiness, { problemId }));
|
|
331
393
|
if (args.json) {
|
|
332
394
|
printJson({
|
|
333
395
|
prechecks: stages,
|
|
396
|
+
scopeGate,
|
|
334
397
|
dynamicChecks,
|
|
335
398
|
trialQa,
|
|
336
399
|
readiness,
|
|
@@ -341,6 +404,7 @@ export const wait = defineCommand({
|
|
|
341
404
|
const c = color();
|
|
342
405
|
console.log("");
|
|
343
406
|
printPrechecks(stages, c, false);
|
|
407
|
+
printScopeGate(scopeGate, c);
|
|
344
408
|
printQualityChecks(dynamicChecks, c);
|
|
345
409
|
printTrialQa(trialQa, c);
|
|
346
410
|
printReadiness(readiness, c);
|
|
@@ -360,6 +424,7 @@ export const authorChecks = {
|
|
|
360
424
|
"run-check": runCheck,
|
|
361
425
|
"run-all": runAll,
|
|
362
426
|
"run-prechecks": runPrechecks,
|
|
427
|
+
"run-scope-gate": runScopeGate,
|
|
363
428
|
"run-trial-qa": runTrialQa,
|
|
364
429
|
wait,
|
|
365
430
|
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
export declare const create: import("citty").CommandDef<{
|
|
2
|
+
readonly json: {
|
|
3
|
+
readonly type: "boolean";
|
|
4
|
+
readonly description: "Output the new ids 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 title: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
readonly description: "Title";
|
|
14
|
+
};
|
|
15
|
+
readonly language: {
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
readonly description: "Language (as the page lists it)";
|
|
18
|
+
};
|
|
19
|
+
readonly category: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
readonly description: "Category (as the page lists it)";
|
|
22
|
+
};
|
|
23
|
+
readonly difficulty: {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
readonly description: "Difficulty (as the page lists it)";
|
|
26
|
+
};
|
|
27
|
+
readonly repo: {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly description: "GitHub repository URL";
|
|
30
|
+
};
|
|
31
|
+
readonly commit: {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
readonly description: "Commit hash";
|
|
34
|
+
};
|
|
35
|
+
readonly issue: {
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
readonly description: "GitHub issue URL";
|
|
38
|
+
};
|
|
39
|
+
readonly "test-output-mode": {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
readonly description: `Test output mode: ${string}`;
|
|
42
|
+
};
|
|
43
|
+
readonly "estimated-loc": {
|
|
44
|
+
readonly type: "string";
|
|
45
|
+
readonly description: "Estimated lines of code (whole number)";
|
|
46
|
+
};
|
|
47
|
+
readonly "description-file": {
|
|
48
|
+
readonly type: "string";
|
|
49
|
+
readonly description: "File holding the description (- = stdin)";
|
|
50
|
+
};
|
|
51
|
+
readonly "dockerfile-file": {
|
|
52
|
+
readonly type: "string";
|
|
53
|
+
readonly description: "File holding the Dockerfile (- = stdin)";
|
|
54
|
+
};
|
|
55
|
+
readonly "test-patch-file": {
|
|
56
|
+
readonly type: "string";
|
|
57
|
+
readonly description: "File holding the test patch (- = stdin)";
|
|
58
|
+
};
|
|
59
|
+
readonly "solution-patch-file": {
|
|
60
|
+
readonly type: "string";
|
|
61
|
+
readonly description: "File holding the solution patch (- = stdin)";
|
|
62
|
+
};
|
|
63
|
+
readonly "approach-file": {
|
|
64
|
+
readonly type: "string";
|
|
65
|
+
readonly description: "File holding the solution approach (- = stdin)";
|
|
66
|
+
};
|
|
67
|
+
readonly "env-file": {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
readonly description: "File holding the environment description (- = stdin)";
|
|
70
|
+
};
|
|
71
|
+
readonly "hint-file": {
|
|
72
|
+
readonly type: "string";
|
|
73
|
+
readonly description: "File holding the hint (- = stdin)";
|
|
74
|
+
};
|
|
75
|
+
readonly "hint-justification-file": {
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
readonly description: "File holding the hint justification (- = stdin)";
|
|
78
|
+
};
|
|
79
|
+
readonly dir: {
|
|
80
|
+
readonly type: "string";
|
|
81
|
+
readonly alias: "d";
|
|
82
|
+
readonly description: `Directory of content files (task.json, ${string})`;
|
|
83
|
+
};
|
|
84
|
+
}>;
|
|
85
|
+
export declare const pull: import("citty").CommandDef<{
|
|
86
|
+
readonly json: {
|
|
87
|
+
readonly type: "boolean";
|
|
88
|
+
readonly description: "Print the content as JSON instead of writing files";
|
|
89
|
+
};
|
|
90
|
+
readonly quest: {
|
|
91
|
+
readonly type: "string";
|
|
92
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
93
|
+
readonly default: "olympus";
|
|
94
|
+
};
|
|
95
|
+
readonly id: {
|
|
96
|
+
readonly type: "positional";
|
|
97
|
+
readonly description: "Challenge ID";
|
|
98
|
+
readonly required: true;
|
|
99
|
+
};
|
|
100
|
+
readonly dir: {
|
|
101
|
+
readonly type: "string";
|
|
102
|
+
readonly alias: "d";
|
|
103
|
+
readonly description: "Directory to write (default: the id)";
|
|
104
|
+
};
|
|
105
|
+
}>;
|
|
106
|
+
export declare const push: import("citty").CommandDef<{
|
|
107
|
+
readonly json: {
|
|
108
|
+
readonly type: "boolean";
|
|
109
|
+
readonly description: "Output the saved ids as JSON";
|
|
110
|
+
};
|
|
111
|
+
readonly quest: {
|
|
112
|
+
readonly type: "string";
|
|
113
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
114
|
+
readonly default: "olympus";
|
|
115
|
+
};
|
|
116
|
+
readonly clear: {
|
|
117
|
+
readonly type: "string";
|
|
118
|
+
readonly description: "Comma-separated text fields to empty (e.g. hintText,githubIssueUrl)";
|
|
119
|
+
};
|
|
120
|
+
readonly title: {
|
|
121
|
+
readonly type: "string";
|
|
122
|
+
readonly description: "Title";
|
|
123
|
+
};
|
|
124
|
+
readonly language: {
|
|
125
|
+
readonly type: "string";
|
|
126
|
+
readonly description: "Language (as the page lists it)";
|
|
127
|
+
};
|
|
128
|
+
readonly category: {
|
|
129
|
+
readonly type: "string";
|
|
130
|
+
readonly description: "Category (as the page lists it)";
|
|
131
|
+
};
|
|
132
|
+
readonly difficulty: {
|
|
133
|
+
readonly type: "string";
|
|
134
|
+
readonly description: "Difficulty (as the page lists it)";
|
|
135
|
+
};
|
|
136
|
+
readonly repo: {
|
|
137
|
+
readonly type: "string";
|
|
138
|
+
readonly description: "GitHub repository URL";
|
|
139
|
+
};
|
|
140
|
+
readonly commit: {
|
|
141
|
+
readonly type: "string";
|
|
142
|
+
readonly description: "Commit hash";
|
|
143
|
+
};
|
|
144
|
+
readonly issue: {
|
|
145
|
+
readonly type: "string";
|
|
146
|
+
readonly description: "GitHub issue URL";
|
|
147
|
+
};
|
|
148
|
+
readonly "test-output-mode": {
|
|
149
|
+
readonly type: "string";
|
|
150
|
+
readonly description: `Test output mode: ${string}`;
|
|
151
|
+
};
|
|
152
|
+
readonly "estimated-loc": {
|
|
153
|
+
readonly type: "string";
|
|
154
|
+
readonly description: "Estimated lines of code (whole number)";
|
|
155
|
+
};
|
|
156
|
+
readonly "description-file": {
|
|
157
|
+
readonly type: "string";
|
|
158
|
+
readonly description: "File holding the description (- = stdin)";
|
|
159
|
+
};
|
|
160
|
+
readonly "dockerfile-file": {
|
|
161
|
+
readonly type: "string";
|
|
162
|
+
readonly description: "File holding the Dockerfile (- = stdin)";
|
|
163
|
+
};
|
|
164
|
+
readonly "test-patch-file": {
|
|
165
|
+
readonly type: "string";
|
|
166
|
+
readonly description: "File holding the test patch (- = stdin)";
|
|
167
|
+
};
|
|
168
|
+
readonly "solution-patch-file": {
|
|
169
|
+
readonly type: "string";
|
|
170
|
+
readonly description: "File holding the solution patch (- = stdin)";
|
|
171
|
+
};
|
|
172
|
+
readonly "approach-file": {
|
|
173
|
+
readonly type: "string";
|
|
174
|
+
readonly description: "File holding the solution approach (- = stdin)";
|
|
175
|
+
};
|
|
176
|
+
readonly "env-file": {
|
|
177
|
+
readonly type: "string";
|
|
178
|
+
readonly description: "File holding the environment description (- = stdin)";
|
|
179
|
+
};
|
|
180
|
+
readonly "hint-file": {
|
|
181
|
+
readonly type: "string";
|
|
182
|
+
readonly description: "File holding the hint (- = stdin)";
|
|
183
|
+
};
|
|
184
|
+
readonly "hint-justification-file": {
|
|
185
|
+
readonly type: "string";
|
|
186
|
+
readonly description: "File holding the hint justification (- = stdin)";
|
|
187
|
+
};
|
|
188
|
+
readonly dir: {
|
|
189
|
+
readonly type: "string";
|
|
190
|
+
readonly alias: "d";
|
|
191
|
+
readonly description: `Directory of content files (task.json, ${string})`;
|
|
192
|
+
};
|
|
193
|
+
readonly id: {
|
|
194
|
+
readonly type: "positional";
|
|
195
|
+
readonly description: "Challenge ID";
|
|
196
|
+
readonly required: true;
|
|
197
|
+
};
|
|
198
|
+
}>;
|
|
@@ -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
|
+
});
|