@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.
Files changed (45) hide show
  1. package/README.md +118 -43
  2. package/dist/auth.d.ts +9 -5
  3. package/dist/auth.js +43 -10
  4. package/dist/author.d.ts +11 -0
  5. package/dist/author.js +43 -0
  6. package/dist/backend.d.ts +4 -0
  7. package/dist/backend.js +51 -0
  8. package/dist/checks-view.d.ts +9 -0
  9. package/dist/checks-view.js +11 -0
  10. package/dist/client.d.ts +0 -8
  11. package/dist/client.js +0 -7
  12. package/dist/commands/auth.d.ts +9 -4
  13. package/dist/commands/auth.js +29 -41
  14. package/dist/commands/author-checks.d.ts +265 -0
  15. package/dist/commands/author-checks.js +365 -0
  16. package/dist/commands/checks.d.ts +0 -2
  17. package/dist/commands/checks.js +21 -17
  18. package/dist/commands/problems.d.ts +1 -0
  19. package/dist/commands/problems.js +189 -0
  20. package/dist/commands/quests.d.ts +0 -1
  21. package/dist/commands/quests.js +0 -1
  22. package/dist/contract.d.ts +0 -1
  23. package/dist/contract.js +0 -7
  24. package/dist/errors.d.ts +3 -1
  25. package/dist/errors.js +6 -5
  26. package/dist/format.d.ts +2 -4
  27. package/dist/format.js +29 -7
  28. package/dist/harbor.d.ts +0 -8
  29. package/dist/harbor.js +0 -11
  30. package/dist/index-gate.d.ts +1 -0
  31. package/dist/index-gate.js +5 -0
  32. package/dist/index.js +14 -10
  33. package/dist/model.d.ts +94 -0
  34. package/dist/model.js +68 -0
  35. package/dist/plan.d.ts +0 -15
  36. package/dist/plan.js +0 -21
  37. package/dist/prompt.d.ts +5 -0
  38. package/dist/prompt.js +26 -0
  39. package/dist/quests.d.ts +2 -10
  40. package/dist/quests.js +51 -34
  41. package/dist/report.d.ts +0 -9
  42. package/dist/report.js +1 -7
  43. package/dist/usage.d.ts +2 -0
  44. package/dist/usage.js +16 -0
  45. package/package.json +3 -2
package/README.md CHANGED
@@ -1,33 +1,90 @@
1
1
  # Shipd CLI (`@shipd-ai/cli`)
2
2
 
3
- `shipd` is the admin command line for Shipd quests. Point it at a Harbor task
4
- directory (or an existing task) and it runs the quest's checks on the quest's
5
- own infrastructure, then returns the same structured output the product shows.
6
- The CLI is quest-agnostic: every command takes `--quest <quest>`, and any
7
- quest that implements the small `adhocChecks:*` contract works the same way.
8
- `shipd quests` lists the quests available (olympus today, which is also the
9
- default when `--quest` is omitted).
3
+ `shipd` is the command line for Shipd quests. It has two editions, decided by
4
+ the token you sign in with:
10
5
 
11
- Admins only: every quest entrypoint checks the caller's effective admin role.
6
+ - **Author edition** — read your own challenges and run their checks from a
7
+ terminal, exactly as the challenge page does (same visibility, same gates,
8
+ same results). `shipd problems …` and the author `shipd checks …` commands.
9
+ - **Admin edition** — everything above, plus the ad-hoc checks: point the CLI
10
+ at a Harbor task directory (or an existing task) and it runs the quest's
11
+ checks on the quest's own infrastructure. `shipd checks list|run|status|cancel`.
12
12
 
13
- ## Install and log in
13
+ The CLI is quest-agnostic: every command takes `--quest <quest>`, and
14
+ `shipd quests` lists the quests available (olympus today, which is also the
15
+ default when `--quest` is omitted).
14
16
 
15
- Admin docs, the supported checks, and a copy-paste setup prompt for coding agents live at https://shipd.ai/admin/cli (admins only; direct link to the prompt: https://shipd.ai/admin/cli#agent-setup-prompt).
17
+ ## Install and sign in
16
18
 
17
19
  ```bash
18
- npm install -g @shipd-ai/cli
19
- shipd login # opens https://shipd.ai/cli-auth (one token for every quest); or: shipd login --token <jwt>
20
- shipd whoami
20
+ npm install -g @shipd-ai/cli@0.2.0
21
+ shipd login # opens https://shipd.ai/quests/olympus/cli-auth; or: shipd login --token <jwt>
22
+ shipd whoami # who you are and which edition the token is
21
23
  shipd quests # which quests this CLI can talk to
22
24
  ```
23
25
 
24
- `login` opens the token page in your browser; paste the token back into the
25
- terminal. `--no-browser` prints the page URL instead of opening it. The token is
26
- stored at `~/.shipd/credentials.json` (mode 0600). It is personal: never commit
27
- or share it. Typing `--token` by hand leaves it in your shell history, so prefer
28
- the prompt there. `shipd logout` deletes it.
26
+ `login` opens the quest's token page in your browser, which mints the author
27
+ edition for an enrolled author and the admin edition for a real admin; paste
28
+ the token back into the terminal — it is not echoed. `--no-browser` prints the
29
+ page URL instead of opening it; `--platform` opens the platform-level admin
30
+ page instead. The token is stored owner-readable only at
31
+ `~/.shipd/credentials.json` (mode 0600; a file the CLI cannot make owner-only
32
+ refuses the save). It is personal: never commit or share it. Typing `--token`
33
+ by hand leaves it in your shell history, so prefer the prompt there.
34
+ `shipd logout` deletes it. The author token lasts 7 days, the admin token 30;
35
+ a token cannot be revoked before it expires, but it stops working when your
36
+ enrollment (or admin access) ends, from the next command on.
37
+
38
+ ## Author commands
29
39
 
30
- ## Three input modes
40
+ ```bash
41
+ shipd problems list [--status <status>] [--limit <n>]
42
+ shipd problems view <challenge-id>
43
+ shipd problems versions <challenge-id>
44
+
45
+ shipd checks view <challenge-id>
46
+ shipd checks run-prechecks <challenge-id>
47
+ shipd checks run-check <challenge-id> --check <checkKey>
48
+ shipd checks run-all <challenge-id>
49
+ shipd checks run-trial-qa <challenge-id>
50
+ shipd checks wait <challenge-id> [--interval <s>] [--timeout <min>]
51
+ ```
52
+
53
+ `problems view` shows the latest version, submission readiness, prechecks,
54
+ quality checks, Trial QA and the rollout criteria. The CLI reaches only the
55
+ challenges you author or co-author; any other id is "not found".
56
+
57
+ - `run-prechecks` runs the precheck stages on the saved version, as the page's
58
+ Run button does.
59
+ - `run-check` runs one quality check (`verifyTests`, `verifySolution`,
60
+ `verifyFlakiness`, `descriptionQuality`, `solutionQuality`, `rewardHacking`,
61
+ `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
+ - The Scope Gate has no CLI command: run and pass it on the challenge page
64
+ after the prechecks; `run-all` before it has passed prints the page's
65
+ refusal ("Run and pass the Scope Gate before running checks").
66
+ - `run-trial-qa` runs Trial QA on the current rollouts.
67
+ - `wait` polls until no check is active (nothing pending, running, waiting for
68
+ a prerequisite or in Trial QA), then prints the results; its progress goes
69
+ to stderr.
70
+
71
+ Every run goes through the same gates as the page: tokens are charged the same
72
+ way (`--use-general-tokens` is the page's "use tokens instead" toggle), the
73
+ submission cooldown, the image build, the Scope Gate, the check order and the
74
+ locked-version rule all apply, and a refusal prints the message the page
75
+ shows (exit 1). Every command takes `--json`: `checks view --json` prints
76
+ `{ version, prechecks, dynamicChecks, trialQa, readiness }`, each exactly as
77
+ the quest returns it to the page.
78
+
79
+ ## Admin ad-hoc checks
80
+
81
+ Admins only: every quest entrypoint checks the caller's effective admin role,
82
+ and the CLI refuses an author token for these commands before any network
83
+ call. Admin docs, the supported checks, and a copy-paste setup prompt for
84
+ coding agents live at https://shipd.ai/admin/cli (admins only; direct link to
85
+ the prompt: https://shipd.ai/admin/cli#agent-setup-prompt).
86
+
87
+ ### Three input modes
31
88
 
32
89
  | Mode | Command | What happens | Writes to production |
33
90
  | --- | --- | --- | --- |
@@ -40,7 +97,7 @@ dispatched; `--create` prints the new task URL as soon as the draft exists.
40
97
  Checks cost real compute: use `--dry-run` first and confirm `--all` with a
41
98
  human when an agent is driving.
42
99
 
43
- ## Harbor layout
100
+ ### Harbor layout
44
101
 
45
102
  Only these paths are read; everything else in the directory is ignored.
46
103
 
@@ -59,14 +116,14 @@ files may total at most 4 MiB. `--repo`, `--commit`, `--title`, `--category`,
59
116
  `--language` and `--difficulty` override the `task.toml` metadata, which is how
60
117
  a non-Olympus bundle fills in what it lacks.
61
118
 
62
- ## Commands
119
+ ### Commands
63
120
 
64
121
  ```bash
65
122
  shipd checks list --quest olympus
66
123
  shipd checks run ./task --all --dry-run # eligibility + adapted inputs, spends nothing
67
124
  shipd checks run ./task --check verifyBuild,descriptionQuality
68
125
  shipd checks run ./task --all --json --out report.json
69
- shipd checks run ./task --create --check autoReview # creates a draft, runs live
126
+ shipd checks run ./task --create --check solutionQuality # creates a draft, runs live
70
127
  shipd checks run --task <problemId> --check scopeGate # runs live on an existing task
71
128
  shipd checks run ./task --check verifyBuild --no-wait # prints handles as JSON lines
72
129
  shipd checks status '<handle json>' # or: shipd checks status report.json
@@ -81,42 +138,56 @@ per step (default 180, the longest worker timeout).
81
138
 
82
139
  Checks whose required bundle parts are missing are reported as `skipped` with
83
140
  the missing list. With `--all` that is informational; with `--check` it fails
84
- the run. Multi-step checks (for example `autoReview`) run as a step plan the
85
- quest describes: independent steps in parallel, each later step fed the
86
- earlier outputs, a failed step marking its dependents `skipped: upstream
87
- failed`. Prechecks (`precheck:<stage>`) run synchronously.
141
+ the run. Multi-step checks (for example `solutionQuality`: `verifySolution`,
142
+ then `evaluate`) run as a step plan the quest describes: independent steps in
143
+ parallel, each later step fed the earlier outputs, a failed step marking its
144
+ dependents `skipped: upstream failed`. Prechecks (`precheck:<stage>`) run
145
+ synchronously.
88
146
 
89
147
  Ctrl-C asks whether to cancel the in-flight steps; a second Ctrl-C leaves them
90
148
  running. Handles stay in the JSON report, so `checks status` and
91
149
  `checks cancel` keep working on them afterwards.
92
150
 
151
+ ### Report
152
+
153
+ `--json` and `--out` produce the same document: `quest`, `mode`, `source`
154
+ (bundle directory and `inputHash`, or the task ids, title and URL), a top-level
155
+ `taskUrl` in live modes, one entry per
156
+ check with `status`, `verdict`, `output`, `error`, `durationMs`, and `steps`
157
+ (each step's handle and output), plus `prechecks` keyed by stage id.
158
+
93
159
  ## Exit codes
94
160
 
95
161
  | Code | Meaning |
96
162
  | --- | --- |
97
- | 0 | every run check passed or warned |
98
- | 1 | a check failed or errored (or an explicitly requested check was skipped) |
163
+ | 0 | every run check passed or warned; the author command succeeded |
164
+ | 1 | a check failed or errored (or an explicitly requested check was skipped); the quest refused an author command |
99
165
  | 2 | usage, auth, or bundle error (nothing was dispatched) |
100
166
  | 3 | cancelled |
101
167
 
102
- ## Report
168
+ ## Where the token goes
103
169
 
104
- `--json` and `--out` produce the same document: `quest`, `mode`, `source`
105
- (bundle directory and `inputHash`, or the task ids, title and URL), a top-level
106
- `taskUrl` in live modes, one entry per
107
- check with `status`, `verdict`, `output`, `error`, `durationMs`, and `steps`
108
- (each step's handle and output), plus `prechecks` keyed by stage id.
170
+ The quest's base URL serves its token page and the `/api/cli/config` endpoint
171
+ that names its Convex deployment; the token is sent only to that deployment.
172
+ Outside development the base URL must be a `shipd.ai` host over https and the
173
+ Convex URL `https://*.convex.cloud` or `https://*.convex.site`, whether it
174
+ came from the endpoint or the cache; `*.convex.cloud` is shared by every
175
+ Convex tenant, so a bare `SHIPD_<QUEST>_CONVEX_URL` is honoured only with
176
+ `NODE_ENV=development`. Any override is named once on stderr (`Using
177
+ SHIPD_OLYMPUS_URL: <host>`) so a stray environment variable cannot quietly
178
+ redirect the CLI. Every string the quest sends back is printed through a
179
+ control-byte filter; `--json` is the quest's payload verbatim.
109
180
 
110
181
  ## Environment
111
182
 
112
183
  | Variable | Effect |
113
184
  | --- | --- |
114
- | `SHIPD_AUTH_URL` | Override the platform login page `shipd login` opens (default `https://shipd.ai/cli-auth`). |
115
- | `SHIPD_<QUEST>_URL` | Override the quest's base URL (for example `SHIPD_OLYMPUS_URL`). |
116
- | `SHIPD_<QUEST>_CONVEX_URL` | Skip `/api/cli/config` and talk to this Convex deployment. |
185
+ | `SHIPD_AUTH_URL` | Override the platform login page `shipd login --platform` opens (default `https://shipd.ai/cli-auth`). |
186
+ | `SHIPD_<QUEST>_URL` | Override the quest's base URL (for example `SHIPD_OLYMPUS_URL`); a `shipd.ai` host over https outside development. |
187
+ | `SHIPD_<QUEST>_CONVEX_URL` | Skip `/api/cli/config` and talk to this Convex deployment — development only. |
117
188
  | `SHIPD_HOME` | Credentials and caches directory (default `~/.shipd`). |
118
- | `SHIPD_NO_UPDATE_CHECK=1` | Skip the version check. |
119
- | `NODE_ENV=development` | Use the localhost quest URLs. |
189
+ | `SHIPD_NO_UPDATE_CHECK=1` | Skip the version check. The quest's `minCliVersion` is advisory (client-enforced): the quest admits a token by its claims and your enrollment, not by the client's version. |
190
+ | `NODE_ENV=development` | Use the localhost quest URLs, and allow any https host, localhost over http, and the overrides. |
120
191
 
121
192
  ## Developer notes
122
193
 
@@ -125,12 +196,16 @@ pnpm --dir packages/shipd-cli typecheck
125
196
  pnpm --dir packages/shipd-cli test
126
197
  pnpm --dir packages/shipd-cli build
127
198
  pnpm --dir packages/shipd-cli cli checks list --quest olympus # runs src/ with tsx
128
- NODE_ENV=development pnpm --dir packages/shipd-cli cli checks list # against a local quest
199
+ NODE_ENV=development pnpm --dir packages/shipd-cli cli problems list # against a local quest
129
200
  ```
130
201
 
131
- The CLI contains no quest logic. It calls `adhocChecks:*` by name through
132
- Convex's `anyApi`; the shared argument and return shapes live in
133
- `src/contract.ts`, and each quest mirrors them with validators. The plan
202
+ The CLI contains no quest logic. The admin commands call `adhocChecks:*` by
203
+ name through Convex's `anyApi`; the shared argument and return shapes live in
204
+ `src/contract.ts`, and each quest mirrors them with validators. The author
205
+ commands call the challenge page's own queries and actions by name
206
+ (`src/author.ts`); on the quest those are the functions that opted in for the
207
+ author-edition token, redacted and gated server-side exactly as for the page
208
+ (Olympus: `convex/helpers/cliToken.boundary.test.ts` pins the list). The plan
134
209
  executor (`src/plan.ts`) and bundle reader (`src/harbor.ts`) are unit-tested
135
210
  against a fake quest and a fixture bundle in `test/`.
136
211
 
package/dist/auth.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare function shipdDir(): string;
2
+ export declare function credentialsPath(): string;
2
3
  export interface DecodedIdentity {
3
4
  sub: string;
4
5
  email: string;
@@ -6,12 +7,10 @@ export interface DecodedIdentity {
6
7
  name: string;
7
8
  picture: string;
8
9
  exp: number;
10
+ cli?: unknown;
9
11
  }
10
- /**
11
- * Decode the JWT payload without verifying the signature. The quest's Convex
12
- * deployment verifies it on every request; the CLI only reads the payload for
13
- * display (name, email) and the local expiry check.
14
- */
12
+ export type TokenEdition = "admin" | "author" | "unknown";
13
+ export declare function tokenEdition(identity: Pick<DecodedIdentity, "cli">): TokenEdition;
15
14
  export declare function decodeJwtPayload(token: string): DecodedIdentity;
16
15
  export declare function ensureShipdDir(): string;
17
16
  export declare function saveCredentials(token: string): DecodedIdentity;
@@ -24,3 +23,8 @@ export declare function requireAuth(): {
24
23
  token: string;
25
24
  identity: DecodedIdentity;
26
25
  };
26
+ export declare const ADMIN_EDITION_REQUIRED = "This command needs the admin edition of the token.";
27
+ export declare function requireAdminEdition(): {
28
+ token: string;
29
+ identity: DecodedIdentity;
30
+ };
package/dist/auth.js CHANGED
@@ -1,18 +1,20 @@
1
- import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
1
+ import { chmodSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { resolve } from "node:path";
4
- import { AuthError } from "./errors.js";
4
+ import { AuthError, UsageError } from "./errors.js";
5
5
  export function shipdDir() {
6
6
  return resolve(process.env.SHIPD_HOME ?? resolve(homedir(), ".shipd"));
7
7
  }
8
- function credentialsPath() {
8
+ export function credentialsPath() {
9
9
  return resolve(shipdDir(), "credentials.json");
10
10
  }
11
- /**
12
- * Decode the JWT payload without verifying the signature. The quest's Convex
13
- * deployment verifies it on every request; the CLI only reads the payload for
14
- * display (name, email) and the local expiry check.
15
- */
11
+ export function tokenEdition(identity) {
12
+ if (identity.cli === true)
13
+ return "admin";
14
+ if (identity.cli === "author")
15
+ return "author";
16
+ return "unknown";
17
+ }
16
18
  export function decodeJwtPayload(token) {
17
19
  const parts = token.split(".");
18
20
  if (parts.length !== 3) {
@@ -32,12 +34,35 @@ export function ensureShipdDir() {
32
34
  }
33
35
  return dir;
34
36
  }
37
+ function ownerOnly(path, mode) {
38
+ try {
39
+ chmodSync(path, mode);
40
+ }
41
+ catch (error) {
42
+ if (process.platform === "win32")
43
+ return;
44
+ const code = error.code ?? "unknown error";
45
+ throw new AuthError(`Refusing to save credentials: could not make ${path} owner-only (${code}). ` +
46
+ "Fix its owner and permissions, or remove it, then sign in again.");
47
+ }
48
+ }
35
49
  export function saveCredentials(token) {
36
50
  const identity = decodeJwtPayload(token);
37
51
  const expiresAt = new Date(identity.exp * 1000).toISOString();
38
- ensureShipdDir();
52
+ const dir = ensureShipdDir();
53
+ const path = credentialsPath();
54
+ ownerOnly(dir, 0o700);
55
+ if (existsSync(path))
56
+ ownerOnly(path, 0o600);
39
57
  const data = { token, expiresAt };
40
- writeFileSync(credentialsPath(), `${JSON.stringify(data, null, 2)}\n`, { mode: 0o600 });
58
+ writeFileSync(path, `${JSON.stringify(data, null, 2)}\n`, { mode: 0o600 });
59
+ try {
60
+ ownerOnly(path, 0o600);
61
+ }
62
+ catch (error) {
63
+ unlinkSync(path);
64
+ throw error;
65
+ }
41
66
  return identity;
42
67
  }
43
68
  export function loadCredentials() {
@@ -73,3 +98,11 @@ export function requireAuth() {
73
98
  }
74
99
  return creds;
75
100
  }
101
+ export const ADMIN_EDITION_REQUIRED = "This command needs the admin edition of the token.";
102
+ export function requireAdminEdition() {
103
+ const creds = requireAuth();
104
+ if (tokenEdition(creds.identity) === "author") {
105
+ throw new UsageError(ADMIN_EDITION_REQUIRED);
106
+ }
107
+ return creds;
108
+ }
@@ -0,0 +1,11 @@
1
+ import { ConvexHttpClient } from "convex/browser";
2
+ import type { ProblemWithLatestVersion, VersionSummary } from "./model.js";
3
+ export declare const api: import("convex/server").AnyApi;
4
+ export type AuthorClient = ConvexHttpClient;
5
+ export declare function connectAuthor(quest: string): Promise<AuthorClient>;
6
+ export declare function refusalMessage(error: unknown): string;
7
+ export declare function backend<T>(call: () => Promise<T>): Promise<T>;
8
+ export declare function requireProblemVersion(client: AuthorClient, problemId: string): Promise<{
9
+ problem: ProblemWithLatestVersion;
10
+ version: VersionSummary;
11
+ }>;
package/dist/author.js ADDED
@@ -0,0 +1,43 @@
1
+ import { ConvexHttpClient } from "convex/browser";
2
+ import { anyApi } from "convex/server";
3
+ import { ConvexError } from "convex/values";
4
+ import { requireAuth } from "./auth.js";
5
+ import { RefusedError, UsageError } from "./errors.js";
6
+ import { text } from "./format.js";
7
+ import { questConvexUrl, questHasAuthorCommands } from "./quests.js";
8
+ export const api = anyApi;
9
+ export async function connectAuthor(quest) {
10
+ if (!questHasAuthorCommands(quest)) {
11
+ throw new UsageError(`The author commands are not available for "${quest}".`);
12
+ }
13
+ const { token } = requireAuth();
14
+ const convexUrl = await questConvexUrl(quest);
15
+ const client = new ConvexHttpClient(convexUrl);
16
+ client.setAuth(token);
17
+ return client;
18
+ }
19
+ export function refusalMessage(error) {
20
+ if (error instanceof ConvexError && typeof error.data === "string")
21
+ return text(error.data);
22
+ const raw = error instanceof Error ? error.message : String(error);
23
+ return text(raw.split("\n")[0].replace(/^Uncaught (?:ConvexError|Error): /, ""));
24
+ }
25
+ export async function backend(call) {
26
+ try {
27
+ return await call();
28
+ }
29
+ catch (error) {
30
+ throw new RefusedError(refusalMessage(error));
31
+ }
32
+ }
33
+ export async function requireProblemVersion(client, problemId) {
34
+ const data = (await backend(() => client.query(api.problems.getWithLatestVersion, { problemId })));
35
+ if (!data) {
36
+ throw new UsageError(`Challenge not found: ${text(problemId)}`);
37
+ }
38
+ const version = data.latestVersion;
39
+ if (!version) {
40
+ throw new UsageError("No version found.");
41
+ }
42
+ return { problem: data, version };
43
+ }
@@ -0,0 +1,4 @@
1
+ export declare function isDevelopment(): boolean;
2
+ export declare function assertTrustedBaseUrl(url: string, development: boolean): string;
3
+ export declare function assertTrustedConvexUrl(url: string, development: boolean): string;
4
+ export declare function overrideHost(url: string): string;
@@ -0,0 +1,51 @@
1
+ const CONVEX_HOST_SUFFIXES = [".convex.cloud", ".convex.site"];
2
+ const SHIPD_HOST = "shipd.ai";
3
+ export function isDevelopment() {
4
+ return process.env.NODE_ENV === "development";
5
+ }
6
+ function parse(url, what) {
7
+ try {
8
+ return new URL(url);
9
+ }
10
+ catch {
11
+ throw new Error(`Refusing ${what} "${url}": not a valid URL.`);
12
+ }
13
+ }
14
+ function isLocalhost(parsed) {
15
+ return parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
16
+ }
17
+ function isShipdHost(parsed) {
18
+ return parsed.hostname === SHIPD_HOST || parsed.hostname.endsWith(`.${SHIPD_HOST}`);
19
+ }
20
+ function isConvexHost(parsed) {
21
+ return CONVEX_HOST_SUFFIXES.some((suffix) => parsed.hostname.endsWith(suffix));
22
+ }
23
+ export function assertTrustedBaseUrl(url, development) {
24
+ const parsed = parse(url, "the quest URL");
25
+ if (development) {
26
+ if (parsed.protocol === "https:")
27
+ return url;
28
+ if (parsed.protocol === "http:" && isLocalhost(parsed))
29
+ return url;
30
+ throw new Error(`Refusing the quest URL ${parsed.host}: it must be https, or localhost over http.`);
31
+ }
32
+ if (parsed.protocol === "https:" && isShipdHost(parsed))
33
+ return url;
34
+ throw new Error(`Refusing the quest URL ${parsed.host}: outside development the CLI only talks to https://${SHIPD_HOST} (set NODE_ENV=development for another host).`);
35
+ }
36
+ export function assertTrustedConvexUrl(url, development) {
37
+ const parsed = parse(url, "the backend URL");
38
+ if (development && parsed.protocol === "http:" && isLocalhost(parsed))
39
+ return url;
40
+ if (parsed.protocol === "https:" && isConvexHost(parsed))
41
+ return url;
42
+ throw new Error(`Refusing the backend URL ${parsed.host}: the token is only sent to https://*.convex.cloud or https://*.convex.site (localhost over http only with NODE_ENV=development).`);
43
+ }
44
+ export function overrideHost(url) {
45
+ try {
46
+ return new URL(url).host;
47
+ }
48
+ catch {
49
+ return url;
50
+ }
51
+ }
@@ -0,0 +1,9 @@
1
+ export declare const CHECKS_VIEW_KEYS: readonly ["version", "prechecks", "dynamicChecks", "trialQa", "readiness"];
2
+ export type ChecksViewPayload = {
3
+ version: number;
4
+ prechecks: unknown;
5
+ dynamicChecks: unknown;
6
+ trialQa: unknown;
7
+ readiness: unknown;
8
+ };
9
+ export declare function buildChecksViewPayload(input: ChecksViewPayload): ChecksViewPayload;
@@ -0,0 +1,11 @@
1
+ export const CHECKS_VIEW_KEYS = [
2
+ "version",
3
+ "prechecks",
4
+ "dynamicChecks",
5
+ "trialQa",
6
+ "readiness",
7
+ ];
8
+ export function buildChecksViewPayload(input) {
9
+ const { version, prechecks, dynamicChecks, trialQa, readiness } = input;
10
+ return { version, prechecks, dynamicChecks, trialQa, readiness };
11
+ }
package/dist/client.d.ts CHANGED
@@ -1,8 +1,4 @@
1
1
  import type { AdaptResult, Catalog, Handle, HarborBundle, LiveStatus, Options, PrecheckResult, StartStepResult, StepStatus, TaskRef } from "./contract.js";
2
- /**
3
- * Everything the plan executor needs from a quest. `QuestClient` implements it
4
- * over Convex; tests implement it with a fake.
5
- */
6
2
  export interface QuestApi {
7
3
  readonly quest: string;
8
4
  listChecks(): Promise<Catalog>;
@@ -21,9 +17,7 @@ export interface QuestApi {
21
17
  detail?: string;
22
18
  }>;
23
19
  getLiveCheck(versionId: string, checkKey: string): Promise<LiveStatus>;
24
- nudgeSynthesis(versionId: string): Promise<null>;
25
20
  }
26
- /** The bundle as sent over the wire: `dir`, `metadata`, `files` and nothing else. */
27
21
  export declare function toWireBundle(bundle: HarborBundle): HarborBundle;
28
22
  export declare class QuestClient implements QuestApi {
29
23
  readonly quest: string;
@@ -45,7 +39,5 @@ export declare class QuestClient implements QuestApi {
45
39
  detail?: string;
46
40
  }>;
47
41
  getLiveCheck(versionId: string, checkKey: string): Promise<LiveStatus>;
48
- nudgeSynthesis(versionId: string): Promise<null>;
49
42
  }
50
- /** Build an authenticated client for a quest, or throw an AuthError/UsageError. */
51
43
  export declare function connectQuest(quest: string): Promise<QuestClient>;
package/dist/client.js CHANGED
@@ -2,15 +2,12 @@ import { ConvexHttpClient } from "convex/browser";
2
2
  import { anyApi } from "convex/server";
3
3
  import { requireAuth } from "./auth.js";
4
4
  import { questConvexUrl } from "./quests.js";
5
- /** The bundle as sent over the wire: `dir`, `metadata`, `files` and nothing else. */
6
5
  export function toWireBundle(bundle) {
7
6
  return { dir: bundle.dir, metadata: bundle.metadata, files: bundle.files };
8
7
  }
9
8
  function withOptions(args, options) {
10
9
  return options && Object.keys(options).length > 0 ? { ...args, options } : args;
11
10
  }
12
- // Functions are addressed by name through `anyApi` so the CLI has no
13
- // dependency on any quest's generated API at typecheck time.
14
11
  const fns = anyApi.adhocChecks;
15
12
  export class QuestClient {
16
13
  quest;
@@ -58,11 +55,7 @@ export class QuestClient {
58
55
  getLiveCheck(versionId, checkKey) {
59
56
  return this.convex.query(fns.getLiveCheck, { versionId, checkKey });
60
57
  }
61
- nudgeSynthesis(versionId) {
62
- return this.convex.action(fns.nudgeSynthesis, { versionId });
63
- }
64
58
  }
65
- /** Build an authenticated client for a quest, or throw an AuthError/UsageError. */
66
59
  export async function connectQuest(quest) {
67
60
  const { token } = requireAuth();
68
61
  const convexUrl = await questConvexUrl(quest);
@@ -1,4 +1,13 @@
1
1
  export declare const login: import("citty").CommandDef<{
2
+ readonly quest: {
3
+ readonly type: "string";
4
+ readonly description: "Open this quest's login page (default: olympus); it mints the author or the admin edition for whoever is enrolled there";
5
+ };
6
+ readonly platform: {
7
+ readonly type: "boolean";
8
+ readonly description: "Open the platform login page (admins only) instead of a quest's";
9
+ readonly default: false;
10
+ };
2
11
  readonly token: {
3
12
  readonly type: "string";
4
13
  readonly description: "Paste the token directly instead of prompting";
@@ -9,10 +18,6 @@ export declare const login: import("citty").CommandDef<{
9
18
  readonly description: "Open the login page in a browser";
10
19
  readonly negativeDescription: "Print the login URL instead of opening a browser";
11
20
  };
12
- readonly quest: {
13
- readonly type: "string";
14
- readonly description: "Open this quest's own login page instead of the platform page (the token works for every quest either way)";
15
- };
16
21
  }>;
17
22
  export declare const logout: import("citty").CommandDef<import("citty").ArgsDef>;
18
23
  export declare const whoami: import("citty").CommandDef<{