@shipd-ai/cli 0.1.2 → 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 -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 +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 +13 -6
- package/dist/commands/auth.js +42 -35
- 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
package/dist/commands/auth.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { exec, execFile } from "node:child_process";
|
|
2
|
-
import { createInterface } from "node:readline";
|
|
3
2
|
import { defineCommand } from "citty";
|
|
4
|
-
import { clearCredentials, loadCredentials, saveCredentials } from "../auth.js";
|
|
3
|
+
import { clearCredentials, loadCredentials, saveCredentials, tokenEdition, } from "../auth.js";
|
|
5
4
|
import { UsageError } from "../errors.js";
|
|
6
|
-
import { printJson } from "../format.js";
|
|
7
|
-
import {
|
|
5
|
+
import { printJson, text } from "../format.js";
|
|
6
|
+
import { readSecret } from "../prompt.js";
|
|
7
|
+
import { DEFAULT_QUEST, platformAuthUrl, questAuthUrl } from "../quests.js";
|
|
8
8
|
function openBrowser(url) {
|
|
9
9
|
if (process.platform === "win32") {
|
|
10
|
-
// `start` is a cmd.exe built-in, not a standalone executable.
|
|
11
10
|
exec(`start "" "${url.replace(/"/g, '\\"')}"`, () => { });
|
|
12
11
|
}
|
|
13
12
|
else {
|
|
@@ -15,48 +14,53 @@ function openBrowser(url) {
|
|
|
15
14
|
execFile(cmd, [url], () => { });
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
rl.close();
|
|
23
|
-
resolve(answer.trim());
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const questArg = {
|
|
28
|
-
quest: {
|
|
29
|
-
type: "string",
|
|
30
|
-
description: "Open this quest's own login page instead of the platform page (the token works for every quest either way)",
|
|
31
|
-
},
|
|
17
|
+
const EDITION_LABELS = {
|
|
18
|
+
admin: "admin (every command, 30 days)",
|
|
19
|
+
author: "author (your challenges and their checks, 7 days)",
|
|
20
|
+
unknown: "unknown (a retired template; sign in again)",
|
|
32
21
|
};
|
|
33
22
|
export const login = defineCommand({
|
|
34
23
|
meta: { name: "login", description: "Sign in via the browser and store the CLI token" },
|
|
35
24
|
args: {
|
|
36
|
-
|
|
25
|
+
quest: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: `Open this quest's login page (default: ${DEFAULT_QUEST}); it mints the author or the admin edition for whoever is enrolled there`,
|
|
28
|
+
},
|
|
29
|
+
platform: {
|
|
30
|
+
type: "boolean",
|
|
31
|
+
description: "Open the platform login page (admins only) instead of a quest's",
|
|
32
|
+
default: false,
|
|
33
|
+
},
|
|
37
34
|
token: { type: "string", description: "Paste the token directly instead of prompting" },
|
|
38
|
-
|
|
35
|
+
browser: {
|
|
36
|
+
type: "boolean",
|
|
37
|
+
default: true,
|
|
38
|
+
description: "Open the login page in a browser",
|
|
39
|
+
negativeDescription: "Print the login URL instead of opening a browser",
|
|
40
|
+
},
|
|
39
41
|
},
|
|
40
42
|
run: async ({ args }) => {
|
|
41
|
-
const authUrl = args.
|
|
43
|
+
const authUrl = args.platform ? platformAuthUrl() : questAuthUrl(args.quest ?? DEFAULT_QUEST);
|
|
42
44
|
let token = args.token?.trim();
|
|
43
45
|
if (!token) {
|
|
44
|
-
if (args
|
|
45
|
-
console.log(`\n Open this page and copy the token:\n ${authUrl}\n`);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
46
|
+
if (args.browser) {
|
|
48
47
|
console.log(`\n Opening browser...\n ${authUrl}\n`);
|
|
49
48
|
openBrowser(authUrl);
|
|
50
49
|
}
|
|
51
|
-
|
|
50
|
+
else {
|
|
51
|
+
console.log(`\n Open this page and copy the token:\n ${authUrl}\n`);
|
|
52
|
+
}
|
|
53
|
+
token = await readSecret(" Paste your token (not shown): ");
|
|
54
|
+
}
|
|
55
|
+
if (!token) {
|
|
56
|
+
throw new UsageError("No token provided. Pass it with --token, or paste it at the prompt in an interactive terminal.");
|
|
52
57
|
}
|
|
53
|
-
if (!token)
|
|
54
|
-
throw new UsageError("No token provided.");
|
|
55
58
|
const identity = saveCredentials(token);
|
|
56
59
|
const expiresAt = new Date(identity.exp * 1000).toLocaleDateString();
|
|
57
|
-
console.log(`\n Logged in as ${identity.name || identity.email || identity.sub}`);
|
|
60
|
+
console.log(`\n Logged in as ${text(identity.name || identity.email || identity.sub)}`);
|
|
58
61
|
if (identity.username)
|
|
59
|
-
console.log(` Username: @${identity.username}`);
|
|
62
|
+
console.log(` Username: @${text(identity.username)}`);
|
|
63
|
+
console.log(` Edition: ${EDITION_LABELS[tokenEdition(identity)]}`);
|
|
60
64
|
console.log(` Expires: ${expiresAt}\n`);
|
|
61
65
|
},
|
|
62
66
|
});
|
|
@@ -68,7 +72,7 @@ export const logout = defineCommand({
|
|
|
68
72
|
},
|
|
69
73
|
});
|
|
70
74
|
export const whoami = defineCommand({
|
|
71
|
-
meta: { name: "whoami", description: "Show who the stored token belongs to" },
|
|
75
|
+
meta: { name: "whoami", description: "Show who the stored token belongs to and its edition" },
|
|
72
76
|
args: {
|
|
73
77
|
json: { type: "boolean", description: "Output as JSON" },
|
|
74
78
|
},
|
|
@@ -85,6 +89,7 @@ export const whoami = defineCommand({
|
|
|
85
89
|
return;
|
|
86
90
|
}
|
|
87
91
|
const { identity } = creds;
|
|
92
|
+
const edition = tokenEdition(identity);
|
|
88
93
|
const expiresAt = new Date(identity.exp * 1000);
|
|
89
94
|
const daysLeft = Math.ceil((expiresAt.getTime() - Date.now()) / (1000 * 60 * 60 * 24));
|
|
90
95
|
if (args.json) {
|
|
@@ -94,15 +99,17 @@ export const whoami = defineCommand({
|
|
|
94
99
|
email: identity.email,
|
|
95
100
|
username: identity.username,
|
|
96
101
|
name: identity.name,
|
|
102
|
+
edition,
|
|
97
103
|
expiresAt: expiresAt.toISOString(),
|
|
98
104
|
daysLeft,
|
|
99
105
|
});
|
|
100
106
|
return;
|
|
101
107
|
}
|
|
102
|
-
console.log(` Logged in as ${identity.name || identity.email || identity.sub}`);
|
|
108
|
+
console.log(` Logged in as ${text(identity.name || identity.email || identity.sub)}`);
|
|
103
109
|
if (identity.username)
|
|
104
|
-
console.log(` Username: @${identity.username}`);
|
|
105
|
-
console.log(` User ID: ${identity.sub}`);
|
|
110
|
+
console.log(` Username: @${text(identity.username)}`);
|
|
111
|
+
console.log(` User ID: ${text(identity.sub)}`);
|
|
112
|
+
console.log(` Edition: ${EDITION_LABELS[edition]}`);
|
|
106
113
|
console.log(` Expires: ${expiresAt.toLocaleDateString()} (${daysLeft}d)`);
|
|
107
114
|
},
|
|
108
115
|
});
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { type SubmissionReadiness, type TrialQaStatus } from "../model.js";
|
|
2
|
+
export declare const questArg: {
|
|
3
|
+
readonly quest: {
|
|
4
|
+
readonly type: "string";
|
|
5
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
6
|
+
readonly default: "olympus";
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare const RUN_ALL_CHECK_KEYS: readonly ["verifyTests", "verifySolution", "verifyFlakiness", "descriptionQuality", "solutionQuality", "rewardHacking", "verifyFairness"];
|
|
10
|
+
export declare function printPrechecks(results: unknown, c: boolean, emptyLine?: boolean): void;
|
|
11
|
+
export declare function printQualityChecks(dynamicChecks: unknown, c: boolean, emptyLine?: boolean): void;
|
|
12
|
+
export declare function printTrialQa(trialQa: TrialQaStatus | null, c: boolean): void;
|
|
13
|
+
export declare function printReadiness(readiness: SubmissionReadiness | null, c: boolean): void;
|
|
14
|
+
export declare const view: import("citty").CommandDef<{
|
|
15
|
+
readonly json: {
|
|
16
|
+
readonly type: "boolean";
|
|
17
|
+
readonly description: "Output as JSON";
|
|
18
|
+
};
|
|
19
|
+
readonly quest: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
22
|
+
readonly default: "olympus";
|
|
23
|
+
};
|
|
24
|
+
readonly id: {
|
|
25
|
+
readonly type: "positional";
|
|
26
|
+
readonly description: "Challenge ID";
|
|
27
|
+
readonly required: true;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
export declare const runCheck: import("citty").CommandDef<{
|
|
31
|
+
readonly json: {
|
|
32
|
+
readonly type: "boolean";
|
|
33
|
+
readonly description: "Output as JSON";
|
|
34
|
+
};
|
|
35
|
+
readonly "use-general-tokens": {
|
|
36
|
+
readonly type: "boolean";
|
|
37
|
+
readonly description: "Charge general tokens instead of revision tokens";
|
|
38
|
+
};
|
|
39
|
+
readonly check: {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
readonly description: `Check key: ${string}`;
|
|
42
|
+
readonly required: true;
|
|
43
|
+
};
|
|
44
|
+
readonly quest: {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
47
|
+
readonly default: "olympus";
|
|
48
|
+
};
|
|
49
|
+
readonly id: {
|
|
50
|
+
readonly type: "positional";
|
|
51
|
+
readonly description: "Challenge ID";
|
|
52
|
+
readonly required: true;
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
55
|
+
export declare const runAll: import("citty").CommandDef<{
|
|
56
|
+
readonly json: {
|
|
57
|
+
readonly type: "boolean";
|
|
58
|
+
readonly description: "Output as JSON";
|
|
59
|
+
};
|
|
60
|
+
readonly "use-general-tokens": {
|
|
61
|
+
readonly type: "boolean";
|
|
62
|
+
readonly description: "Charge general tokens instead of revision tokens";
|
|
63
|
+
};
|
|
64
|
+
readonly quest: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
67
|
+
readonly default: "olympus";
|
|
68
|
+
};
|
|
69
|
+
readonly id: {
|
|
70
|
+
readonly type: "positional";
|
|
71
|
+
readonly description: "Challenge ID";
|
|
72
|
+
readonly required: true;
|
|
73
|
+
};
|
|
74
|
+
}>;
|
|
75
|
+
export declare const runPrechecks: import("citty").CommandDef<{
|
|
76
|
+
readonly json: {
|
|
77
|
+
readonly type: "boolean";
|
|
78
|
+
readonly description: "Output as JSON";
|
|
79
|
+
};
|
|
80
|
+
readonly "use-general-tokens": {
|
|
81
|
+
readonly type: "boolean";
|
|
82
|
+
readonly description: "Charge general tokens instead of revision tokens";
|
|
83
|
+
};
|
|
84
|
+
readonly quest: {
|
|
85
|
+
readonly type: "string";
|
|
86
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
87
|
+
readonly default: "olympus";
|
|
88
|
+
};
|
|
89
|
+
readonly id: {
|
|
90
|
+
readonly type: "positional";
|
|
91
|
+
readonly description: "Challenge ID";
|
|
92
|
+
readonly required: true;
|
|
93
|
+
};
|
|
94
|
+
}>;
|
|
95
|
+
export declare const runTrialQa: import("citty").CommandDef<{
|
|
96
|
+
readonly json: {
|
|
97
|
+
readonly type: "boolean";
|
|
98
|
+
readonly description: "Output as JSON";
|
|
99
|
+
};
|
|
100
|
+
readonly "use-general-tokens": {
|
|
101
|
+
readonly type: "boolean";
|
|
102
|
+
readonly description: "Charge general tokens instead of revision tokens";
|
|
103
|
+
};
|
|
104
|
+
readonly quest: {
|
|
105
|
+
readonly type: "string";
|
|
106
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
107
|
+
readonly default: "olympus";
|
|
108
|
+
};
|
|
109
|
+
readonly id: {
|
|
110
|
+
readonly type: "positional";
|
|
111
|
+
readonly description: "Challenge ID";
|
|
112
|
+
readonly required: true;
|
|
113
|
+
};
|
|
114
|
+
}>;
|
|
115
|
+
export declare const wait: import("citty").CommandDef<{
|
|
116
|
+
readonly interval: {
|
|
117
|
+
readonly type: "string";
|
|
118
|
+
readonly description: "Poll interval in seconds (default 10)";
|
|
119
|
+
};
|
|
120
|
+
readonly timeout: {
|
|
121
|
+
readonly type: "string";
|
|
122
|
+
readonly description: "Timeout in minutes (default 30)";
|
|
123
|
+
};
|
|
124
|
+
readonly json: {
|
|
125
|
+
readonly type: "boolean";
|
|
126
|
+
readonly description: "Output final result as JSON";
|
|
127
|
+
};
|
|
128
|
+
readonly quest: {
|
|
129
|
+
readonly type: "string";
|
|
130
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
131
|
+
readonly default: "olympus";
|
|
132
|
+
};
|
|
133
|
+
readonly id: {
|
|
134
|
+
readonly type: "positional";
|
|
135
|
+
readonly description: "Challenge ID";
|
|
136
|
+
readonly required: true;
|
|
137
|
+
};
|
|
138
|
+
}>;
|
|
139
|
+
export declare const authorChecks: {
|
|
140
|
+
view: import("citty").CommandDef<{
|
|
141
|
+
readonly json: {
|
|
142
|
+
readonly type: "boolean";
|
|
143
|
+
readonly description: "Output as JSON";
|
|
144
|
+
};
|
|
145
|
+
readonly quest: {
|
|
146
|
+
readonly type: "string";
|
|
147
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
148
|
+
readonly default: "olympus";
|
|
149
|
+
};
|
|
150
|
+
readonly id: {
|
|
151
|
+
readonly type: "positional";
|
|
152
|
+
readonly description: "Challenge ID";
|
|
153
|
+
readonly required: true;
|
|
154
|
+
};
|
|
155
|
+
}>;
|
|
156
|
+
"run-check": import("citty").CommandDef<{
|
|
157
|
+
readonly json: {
|
|
158
|
+
readonly type: "boolean";
|
|
159
|
+
readonly description: "Output as JSON";
|
|
160
|
+
};
|
|
161
|
+
readonly "use-general-tokens": {
|
|
162
|
+
readonly type: "boolean";
|
|
163
|
+
readonly description: "Charge general tokens instead of revision tokens";
|
|
164
|
+
};
|
|
165
|
+
readonly check: {
|
|
166
|
+
readonly type: "string";
|
|
167
|
+
readonly description: `Check key: ${string}`;
|
|
168
|
+
readonly required: true;
|
|
169
|
+
};
|
|
170
|
+
readonly quest: {
|
|
171
|
+
readonly type: "string";
|
|
172
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
173
|
+
readonly default: "olympus";
|
|
174
|
+
};
|
|
175
|
+
readonly id: {
|
|
176
|
+
readonly type: "positional";
|
|
177
|
+
readonly description: "Challenge ID";
|
|
178
|
+
readonly required: true;
|
|
179
|
+
};
|
|
180
|
+
}>;
|
|
181
|
+
"run-all": import("citty").CommandDef<{
|
|
182
|
+
readonly json: {
|
|
183
|
+
readonly type: "boolean";
|
|
184
|
+
readonly description: "Output as JSON";
|
|
185
|
+
};
|
|
186
|
+
readonly "use-general-tokens": {
|
|
187
|
+
readonly type: "boolean";
|
|
188
|
+
readonly description: "Charge general tokens instead of revision tokens";
|
|
189
|
+
};
|
|
190
|
+
readonly quest: {
|
|
191
|
+
readonly type: "string";
|
|
192
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
193
|
+
readonly default: "olympus";
|
|
194
|
+
};
|
|
195
|
+
readonly id: {
|
|
196
|
+
readonly type: "positional";
|
|
197
|
+
readonly description: "Challenge ID";
|
|
198
|
+
readonly required: true;
|
|
199
|
+
};
|
|
200
|
+
}>;
|
|
201
|
+
"run-prechecks": import("citty").CommandDef<{
|
|
202
|
+
readonly json: {
|
|
203
|
+
readonly type: "boolean";
|
|
204
|
+
readonly description: "Output as JSON";
|
|
205
|
+
};
|
|
206
|
+
readonly "use-general-tokens": {
|
|
207
|
+
readonly type: "boolean";
|
|
208
|
+
readonly description: "Charge general tokens instead of revision tokens";
|
|
209
|
+
};
|
|
210
|
+
readonly quest: {
|
|
211
|
+
readonly type: "string";
|
|
212
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
213
|
+
readonly default: "olympus";
|
|
214
|
+
};
|
|
215
|
+
readonly id: {
|
|
216
|
+
readonly type: "positional";
|
|
217
|
+
readonly description: "Challenge ID";
|
|
218
|
+
readonly required: true;
|
|
219
|
+
};
|
|
220
|
+
}>;
|
|
221
|
+
"run-trial-qa": import("citty").CommandDef<{
|
|
222
|
+
readonly json: {
|
|
223
|
+
readonly type: "boolean";
|
|
224
|
+
readonly description: "Output as JSON";
|
|
225
|
+
};
|
|
226
|
+
readonly "use-general-tokens": {
|
|
227
|
+
readonly type: "boolean";
|
|
228
|
+
readonly description: "Charge general tokens instead of revision tokens";
|
|
229
|
+
};
|
|
230
|
+
readonly quest: {
|
|
231
|
+
readonly type: "string";
|
|
232
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
233
|
+
readonly default: "olympus";
|
|
234
|
+
};
|
|
235
|
+
readonly id: {
|
|
236
|
+
readonly type: "positional";
|
|
237
|
+
readonly description: "Challenge ID";
|
|
238
|
+
readonly required: true;
|
|
239
|
+
};
|
|
240
|
+
}>;
|
|
241
|
+
wait: import("citty").CommandDef<{
|
|
242
|
+
readonly interval: {
|
|
243
|
+
readonly type: "string";
|
|
244
|
+
readonly description: "Poll interval in seconds (default 10)";
|
|
245
|
+
};
|
|
246
|
+
readonly timeout: {
|
|
247
|
+
readonly type: "string";
|
|
248
|
+
readonly description: "Timeout in minutes (default 30)";
|
|
249
|
+
};
|
|
250
|
+
readonly json: {
|
|
251
|
+
readonly type: "boolean";
|
|
252
|
+
readonly description: "Output final result as JSON";
|
|
253
|
+
};
|
|
254
|
+
readonly quest: {
|
|
255
|
+
readonly type: "string";
|
|
256
|
+
readonly description: "Quest to talk to (default: olympus)";
|
|
257
|
+
readonly default: "olympus";
|
|
258
|
+
};
|
|
259
|
+
readonly id: {
|
|
260
|
+
readonly type: "positional";
|
|
261
|
+
readonly description: "Challenge ID";
|
|
262
|
+
readonly required: true;
|
|
263
|
+
};
|
|
264
|
+
}>;
|
|
265
|
+
};
|