@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
package/dist/harbor.js
CHANGED
|
@@ -4,7 +4,6 @@ import { resolve } from "node:path";
|
|
|
4
4
|
import { parse as parseToml } from "smol-toml";
|
|
5
5
|
import { HARBOR_FILE_PATHS, HARBOR_FILES, } from "./contract.js";
|
|
6
6
|
import { BundleError } from "./errors.js";
|
|
7
|
-
/** Total text the CLI will send to a quest. Well under Convex's argument limit. */
|
|
8
7
|
export const MAX_BUNDLE_BYTES = 4 * 1024 * 1024;
|
|
9
8
|
function isRecord(value) {
|
|
10
9
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
@@ -20,7 +19,6 @@ function num(table, key) {
|
|
|
20
19
|
function nonEmpty(value) {
|
|
21
20
|
return value && value.trim().length > 0 ? value : undefined;
|
|
22
21
|
}
|
|
23
|
-
/** Map `task.toml` tables onto `HarborMetadata`; overrides win. */
|
|
24
22
|
export function metadataFromToml(toml, overrides = {}) {
|
|
25
23
|
const metadata = isRecord(toml.metadata) ? toml.metadata : undefined;
|
|
26
24
|
const environment = isRecord(toml.environment) ? toml.environment : undefined;
|
|
@@ -35,14 +33,12 @@ export function metadataFromToml(toml, overrides = {}) {
|
|
|
35
33
|
dockerImage: str(environment, "docker_image"),
|
|
36
34
|
verifierTimeoutSec: num(verifier, "timeout_sec"),
|
|
37
35
|
};
|
|
38
|
-
// Drop undefined keys so the wire payload and the hash only carry set fields.
|
|
39
36
|
for (const key of Object.keys(out)) {
|
|
40
37
|
if (out[key] === undefined)
|
|
41
38
|
delete out[key];
|
|
42
39
|
}
|
|
43
40
|
return out;
|
|
44
41
|
}
|
|
45
|
-
/** JSON with object keys sorted at every level, so equal content hashes equal. */
|
|
46
42
|
export function canonicalJson(value) {
|
|
47
43
|
return JSON.stringify(sortKeys(value));
|
|
48
44
|
}
|
|
@@ -71,9 +67,6 @@ function formatMiB(bytes) {
|
|
|
71
67
|
}
|
|
72
68
|
async function fileSize(path) {
|
|
73
69
|
try {
|
|
74
|
-
// lstat, not stat: a bundle from an untrusted source could point a
|
|
75
|
-
// whitelisted name at any readable file via a symlink and have its
|
|
76
|
-
// contents sent to the quest.
|
|
77
70
|
const info = await lstat(path);
|
|
78
71
|
if (info.isSymbolicLink()) {
|
|
79
72
|
throw new BundleError(`${path} is a symlink; symlinked bundle files are not read.`);
|
|
@@ -88,10 +81,6 @@ async function fileSize(path) {
|
|
|
88
81
|
throw new BundleError(`Could not read ${path}: ${error.message}`);
|
|
89
82
|
}
|
|
90
83
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Read a Harbor task directory. Only the seven known paths are read; anything
|
|
93
|
-
* else in the directory is ignored. `task.toml` must exist and parse.
|
|
94
|
-
*/
|
|
95
84
|
export async function readHarborBundle(dir, overrides = {}) {
|
|
96
85
|
const root = resolve(dir);
|
|
97
86
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isAdminOnlyCommand(rawArgs: string[]): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const ADMIN_ONLY_CHECKS = new Set(["list", "run", "status", "cancel"]);
|
|
2
|
+
export function isAdminOnlyCommand(rawArgs) {
|
|
3
|
+
const words = rawArgs.filter((arg) => !arg.startsWith("-"));
|
|
4
|
+
return words[0] === "checks" && words.length > 1 && ADMIN_ONLY_CHECKS.has(words[1]);
|
|
5
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
|
-
import { defineCommand, runCommand
|
|
3
|
+
import { defineCommand, runCommand } from "citty";
|
|
4
|
+
import { requireAdminEdition } from "./auth.js";
|
|
4
5
|
import { login, logout, whoami } from "./commands/auth.js";
|
|
5
6
|
import checks from "./commands/checks.js";
|
|
7
|
+
import { problems } from "./commands/problems.js";
|
|
6
8
|
import { quests } from "./commands/quests.js";
|
|
9
|
+
import { runs } from "./commands/runs.js";
|
|
7
10
|
import { EXIT_USAGE, errorMessage, exitCodeForError } from "./errors.js";
|
|
11
|
+
import { text } from "./format.js";
|
|
12
|
+
import { isAdminOnlyCommand } from "./index-gate.js";
|
|
8
13
|
import { checkVersion, PACKAGE_NAME, VERSION } from "./quests.js";
|
|
14
|
+
import { createShowUsage } from "./usage.js";
|
|
9
15
|
const update = defineCommand({
|
|
10
16
|
meta: { name: "update", description: "Update the CLI to the latest published version" },
|
|
11
17
|
args: {
|
|
@@ -34,10 +40,11 @@ const main = defineCommand({
|
|
|
34
40
|
meta: {
|
|
35
41
|
name: "shipd",
|
|
36
42
|
version: VERSION,
|
|
37
|
-
description: "Shipd
|
|
43
|
+
description: "Shipd CLI: your quest challenges, their content, checks and agent runs (author edition); ad-hoc quest checks on Harbor tasks or existing tasks (admin edition)",
|
|
38
44
|
},
|
|
39
|
-
subCommands: { login, logout, whoami, quests, checks, update, version },
|
|
45
|
+
subCommands: { login, logout, whoami, quests, problems, checks, runs, update, version },
|
|
40
46
|
});
|
|
47
|
+
const showUsage = createShowUsage(main, { problems, checks, runs });
|
|
41
48
|
async function run() {
|
|
42
49
|
const rawArgs = process.argv.slice(2);
|
|
43
50
|
if (rawArgs.length === 0 || rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
@@ -48,21 +55,21 @@ async function run() {
|
|
|
48
55
|
console.log(VERSION);
|
|
49
56
|
return;
|
|
50
57
|
}
|
|
51
|
-
// Warn about an outdated CLI without blocking the command.
|
|
52
|
-
void checkVersion(questFromArgs(rawArgs)).catch(() => { });
|
|
53
58
|
try {
|
|
59
|
+
if (isAdminOnlyCommand(rawArgs))
|
|
60
|
+
requireAdminEdition();
|
|
61
|
+
void checkVersion(questFromArgs(rawArgs)).catch(() => { });
|
|
54
62
|
await runCommand(main, { rawArgs });
|
|
55
63
|
}
|
|
56
64
|
catch (error) {
|
|
57
65
|
const name = error instanceof Error ? error.name : "";
|
|
58
66
|
if (name === "CLIError") {
|
|
59
|
-
// citty's own usage errors (unknown command, missing argument).
|
|
60
67
|
await showUsageFor(rawArgs);
|
|
61
|
-
console.error(`\n Error: ${errorMessage(error)}\n`);
|
|
68
|
+
console.error(`\n Error: ${text(errorMessage(error))}\n`);
|
|
62
69
|
process.exitCode = EXIT_USAGE;
|
|
63
70
|
return;
|
|
64
71
|
}
|
|
65
|
-
console.error(`\n Error: ${errorMessage(error)}\n`);
|
|
72
|
+
console.error(`\n Error: ${text(errorMessage(error))}\n`);
|
|
66
73
|
process.exitCode = exitCodeForError(error);
|
|
67
74
|
}
|
|
68
75
|
}
|
|
@@ -77,8 +84,6 @@ function questFromArgs(rawArgs) {
|
|
|
77
84
|
return undefined;
|
|
78
85
|
}
|
|
79
86
|
async function showUsageFor(rawArgs) {
|
|
80
|
-
// Resolve the deepest sub-command named on the command line so `shipd checks run --help`
|
|
81
|
-
// prints the right usage.
|
|
82
87
|
let cmd = main;
|
|
83
88
|
let parent;
|
|
84
89
|
for (const arg of rawArgs) {
|
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export type ProblemSummary = {
|
|
2
|
+
_id: string;
|
|
3
|
+
_creationTime?: number;
|
|
4
|
+
title?: string;
|
|
5
|
+
status?: string;
|
|
6
|
+
language?: string;
|
|
7
|
+
category?: string;
|
|
8
|
+
difficulty?: string;
|
|
9
|
+
githubRepoUrl?: string;
|
|
10
|
+
githubCommitHash?: string;
|
|
11
|
+
estimatedLOC?: number;
|
|
12
|
+
};
|
|
13
|
+
export type VersionSummary = {
|
|
14
|
+
_id: string;
|
|
15
|
+
_creationTime?: number;
|
|
16
|
+
version: number;
|
|
17
|
+
isLocked?: boolean;
|
|
18
|
+
title?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
language?: string;
|
|
21
|
+
category?: string;
|
|
22
|
+
difficulty?: string;
|
|
23
|
+
githubRepoUrl?: string;
|
|
24
|
+
githubCommitHash?: string;
|
|
25
|
+
dockerfile?: string;
|
|
26
|
+
testPatch?: string;
|
|
27
|
+
solutionPatch?: string;
|
|
28
|
+
githubIssueUrl?: string;
|
|
29
|
+
solutionApproach?: string;
|
|
30
|
+
environmentDescription?: string;
|
|
31
|
+
hintText?: string;
|
|
32
|
+
hintJustification?: string;
|
|
33
|
+
testOutputMode?: string;
|
|
34
|
+
estimatedLOC?: number;
|
|
35
|
+
};
|
|
36
|
+
export type ProblemWithLatestVersion = ProblemSummary & {
|
|
37
|
+
latestVersion?: VersionSummary | null;
|
|
38
|
+
};
|
|
39
|
+
export type PrecheckCheck = {
|
|
40
|
+
id?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
status?: string;
|
|
43
|
+
message?: string;
|
|
44
|
+
};
|
|
45
|
+
export type PrecheckStage = {
|
|
46
|
+
id?: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
status?: string;
|
|
49
|
+
stale?: boolean;
|
|
50
|
+
missingFields?: string[];
|
|
51
|
+
checks?: PrecheckCheck[];
|
|
52
|
+
};
|
|
53
|
+
export declare function precheckStages(results: unknown): PrecheckStage[];
|
|
54
|
+
export type SubmissionReadiness = {
|
|
55
|
+
criteria: Array<{
|
|
56
|
+
id: string;
|
|
57
|
+
label: string;
|
|
58
|
+
status: string;
|
|
59
|
+
detail?: string;
|
|
60
|
+
stale?: boolean;
|
|
61
|
+
}>;
|
|
62
|
+
canSubmit: boolean;
|
|
63
|
+
};
|
|
64
|
+
export type AgentRunCriteria = {
|
|
65
|
+
criteria?: Array<{
|
|
66
|
+
id: string;
|
|
67
|
+
label: string;
|
|
68
|
+
status: string;
|
|
69
|
+
detail?: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
guidance?: string;
|
|
72
|
+
preview?: boolean;
|
|
73
|
+
}>;
|
|
74
|
+
};
|
|
75
|
+
export type ScopeGateStatus = {
|
|
76
|
+
latestVerdict: "pass" | "drop" | null;
|
|
77
|
+
fresh: boolean;
|
|
78
|
+
staleReason?: "content" | "series" | null;
|
|
79
|
+
inFlight: boolean;
|
|
80
|
+
canRunDynamicChecks?: boolean;
|
|
81
|
+
current?: {
|
|
82
|
+
jobId?: string;
|
|
83
|
+
status?: string;
|
|
84
|
+
error?: string;
|
|
85
|
+
} | null;
|
|
86
|
+
verdictRun?: {
|
|
87
|
+
jobId?: string;
|
|
88
|
+
status?: string;
|
|
89
|
+
output?: {
|
|
90
|
+
verdict?: string | null;
|
|
91
|
+
reasoning?: string;
|
|
92
|
+
findings?: Array<{
|
|
93
|
+
category?: string;
|
|
94
|
+
severity?: string;
|
|
95
|
+
summary?: string;
|
|
96
|
+
}>;
|
|
97
|
+
} | null;
|
|
98
|
+
error?: string;
|
|
99
|
+
} | null;
|
|
100
|
+
};
|
|
101
|
+
export type TrialQaStatus = {
|
|
102
|
+
state: string;
|
|
103
|
+
canRun: boolean;
|
|
104
|
+
hasEligibleRuns: boolean;
|
|
105
|
+
runsChangedSinceCheck?: boolean;
|
|
106
|
+
runRuleWaitsOn?: string | null;
|
|
107
|
+
tokenCost?: number;
|
|
108
|
+
currentStep?: string;
|
|
109
|
+
warnings?: string[];
|
|
110
|
+
};
|
|
111
|
+
export type DynamicCheckRecord = Record<string, {
|
|
112
|
+
jobId?: string;
|
|
113
|
+
status: string;
|
|
114
|
+
progress?: number;
|
|
115
|
+
currentStep?: string;
|
|
116
|
+
error?: string;
|
|
117
|
+
output?: Record<string, unknown>;
|
|
118
|
+
createdAt?: number;
|
|
119
|
+
completedAt?: number;
|
|
120
|
+
stale?: boolean;
|
|
121
|
+
}>;
|
|
122
|
+
export type DynamicCheckEntry = DynamicCheckRecord[string] & {
|
|
123
|
+
key: string;
|
|
124
|
+
overridden?: boolean;
|
|
125
|
+
};
|
|
126
|
+
export declare function normalizeDynamicChecks(dynamicChecks: unknown): DynamicCheckRecord;
|
|
127
|
+
export declare function getDynamicCheckEntries(dynamicChecks: unknown): DynamicCheckEntry[];
|
|
128
|
+
export declare function formatDynamicCheckLabel(key: string): string;
|
package/dist/model.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const DYNAMIC_CHECK_ORDER = [
|
|
2
|
+
"verifyBuild",
|
|
3
|
+
"verifyTests",
|
|
4
|
+
"verifySolution",
|
|
5
|
+
"verifyFlakiness",
|
|
6
|
+
"descriptionQuality",
|
|
7
|
+
"solutionQuality",
|
|
8
|
+
"rewardHacking",
|
|
9
|
+
"verifyFairness",
|
|
10
|
+
"crossRunAnalysis",
|
|
11
|
+
"rolloutCoach",
|
|
12
|
+
];
|
|
13
|
+
const DYNAMIC_CHECK_LABELS = {
|
|
14
|
+
verifyBuild: "Verify Build",
|
|
15
|
+
verifyTests: "Verify Tests",
|
|
16
|
+
verifySolution: "Verify Solution",
|
|
17
|
+
verifyFlakiness: "Verify Flakiness",
|
|
18
|
+
descriptionQuality: "Task Prompt Quality",
|
|
19
|
+
solutionQuality: "Solution Quality",
|
|
20
|
+
rewardHacking: "Reward Hacking",
|
|
21
|
+
verifyFairness: "Test Quality",
|
|
22
|
+
crossRunAnalysis: "Holistic Check",
|
|
23
|
+
rolloutCoach: "Rollout Coach",
|
|
24
|
+
};
|
|
25
|
+
export function precheckStages(results) {
|
|
26
|
+
if (Array.isArray(results))
|
|
27
|
+
return results;
|
|
28
|
+
if (!results || typeof results !== "object")
|
|
29
|
+
return [];
|
|
30
|
+
return Object.values(results);
|
|
31
|
+
}
|
|
32
|
+
function orderIndex(order, value) {
|
|
33
|
+
const index = order.indexOf(value);
|
|
34
|
+
return index === -1 ? Number.MAX_SAFE_INTEGER : index;
|
|
35
|
+
}
|
|
36
|
+
export function normalizeDynamicChecks(dynamicChecks) {
|
|
37
|
+
if (!dynamicChecks || typeof dynamicChecks !== "object" || Array.isArray(dynamicChecks)) {
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
return Object.fromEntries(Object.entries(dynamicChecks).filter(([key, value]) => {
|
|
41
|
+
return (!key.startsWith("_") &&
|
|
42
|
+
!!value &&
|
|
43
|
+
typeof value === "object" &&
|
|
44
|
+
!Array.isArray(value) &&
|
|
45
|
+
"status" in value);
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
export function getDynamicCheckEntries(dynamicChecks) {
|
|
49
|
+
const record = normalizeDynamicChecks(dynamicChecks);
|
|
50
|
+
const flags = dynamicChecks && typeof dynamicChecks === "object" && !Array.isArray(dynamicChecks)
|
|
51
|
+
? dynamicChecks
|
|
52
|
+
: {};
|
|
53
|
+
return Object.entries(record)
|
|
54
|
+
.map(([key, value]) => ({
|
|
55
|
+
key,
|
|
56
|
+
...value,
|
|
57
|
+
overridden: flags[`_${key}Overridden`] != null ? true : undefined,
|
|
58
|
+
}))
|
|
59
|
+
.sort((a, b) => {
|
|
60
|
+
const orderDelta = orderIndex(DYNAMIC_CHECK_ORDER, a.key) - orderIndex(DYNAMIC_CHECK_ORDER, b.key);
|
|
61
|
+
if (orderDelta !== 0)
|
|
62
|
+
return orderDelta;
|
|
63
|
+
return a.key.localeCompare(b.key);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export function formatDynamicCheckLabel(key) {
|
|
67
|
+
return DYNAMIC_CHECK_LABELS[key] ?? key;
|
|
68
|
+
}
|
package/dist/plan.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { QuestApi } from "./client.js";
|
|
|
2
2
|
import { type CheckDef, type Handle, type HarborBundle, type Options, type TaskRef, type Verdict } from "./contract.js";
|
|
3
3
|
import { type CheckResult, type StepRecord } from "./report.js";
|
|
4
4
|
export declare const DEFAULT_POLL_MS = 15000;
|
|
5
|
-
/** The longest worker timeout. */
|
|
6
5
|
export declare const DEFAULT_MAX_STEP_MS: number;
|
|
7
6
|
export type PlanEvent = {
|
|
8
7
|
type: "check:start";
|
|
@@ -26,9 +25,6 @@ export type PlanEvent = {
|
|
|
26
25
|
checkKey: string;
|
|
27
26
|
started: boolean;
|
|
28
27
|
detail?: string;
|
|
29
|
-
} | {
|
|
30
|
-
type: "live:nudge";
|
|
31
|
-
checkKey: string;
|
|
32
28
|
} | {
|
|
33
29
|
type: "check:end";
|
|
34
30
|
checkKey: string;
|
|
@@ -39,13 +35,6 @@ export type RunControls = {
|
|
|
39
35
|
maxStepMs: number;
|
|
40
36
|
signal?: AbortSignal;
|
|
41
37
|
onEvent?: (event: PlanEvent) => void;
|
|
42
|
-
/**
|
|
43
|
-
* What an abort does to in-flight Modal steps. `"cancel"` (default)
|
|
44
|
-
* cancels them; `"leave"` keeps them running and only stops polling, so
|
|
45
|
-
* their handles survive in the report for `checks status` / `checks
|
|
46
|
-
* cancel` later. The interrupt handler flips this to `"leave"` when the
|
|
47
|
-
* user declines the cancel prompt.
|
|
48
|
-
*/
|
|
49
38
|
onAbort?: () => "cancel" | "leave";
|
|
50
39
|
};
|
|
51
40
|
export type RunTarget = {
|
|
@@ -55,11 +44,7 @@ export type RunTarget = {
|
|
|
55
44
|
kind: "live";
|
|
56
45
|
task: TaskRef;
|
|
57
46
|
};
|
|
58
|
-
/** The step nothing depends on. With several, the last declared wins. */
|
|
59
47
|
export declare function sinkStepId(check: CheckDef): string;
|
|
60
|
-
/** Run one check against a Harbor bundle without writing anything to the quest. */
|
|
61
48
|
export declare function executeStatelessCheck(api: QuestApi, bundle: HarborBundle, check: CheckDef, options: Options, controls: RunControls): Promise<CheckResult>;
|
|
62
|
-
/** Run one check live on an existing task; the quest writes its normal rows. */
|
|
63
49
|
export declare function executeLiveCheck(api: QuestApi, task: TaskRef, check: CheckDef, options: Options, controls: RunControls): Promise<CheckResult>;
|
|
64
|
-
/** Run the selected checks concurrently and return one result per check. */
|
|
65
50
|
export declare function runChecks(api: QuestApi, target: RunTarget, checks: CheckDef[], options: Options, controls: RunControls): Promise<CheckResult[]>;
|
package/dist/plan.js
CHANGED
|
@@ -3,7 +3,6 @@ import { errorMessage } from "./errors.js";
|
|
|
3
3
|
import { formatDuration } from "./format.js";
|
|
4
4
|
import { precheckVerdict } from "./report.js";
|
|
5
5
|
export const DEFAULT_POLL_MS = 15_000;
|
|
6
|
-
/** The longest worker timeout. */
|
|
7
6
|
export const DEFAULT_MAX_STEP_MS = 3 * 60 * 60 * 1000;
|
|
8
7
|
function sleep(ms, signal) {
|
|
9
8
|
if (signal?.aborted)
|
|
@@ -28,7 +27,6 @@ const TERMINAL = new Set([
|
|
|
28
27
|
function isTerminal(record) {
|
|
29
28
|
return TERMINAL.has(record.status);
|
|
30
29
|
}
|
|
31
|
-
/** The step nothing depends on. With several, the last declared wins. */
|
|
32
30
|
export function sinkStepId(check) {
|
|
33
31
|
const depended = new Set(check.steps.flatMap((s) => s.after));
|
|
34
32
|
const sinks = check.steps.filter((s) => !depended.has(s.id));
|
|
@@ -105,7 +103,6 @@ async function runStatelessPrecheck(api, bundle, check, startedAt, controls) {
|
|
|
105
103
|
}, startedAt, controls);
|
|
106
104
|
}
|
|
107
105
|
}
|
|
108
|
-
/** Run one check against a Harbor bundle without writing anything to the quest. */
|
|
109
106
|
export async function executeStatelessCheck(api, bundle, check, options, controls) {
|
|
110
107
|
const startedAt = Date.now();
|
|
111
108
|
controls.onEvent?.({ type: "check:start", checkKey: check.key });
|
|
@@ -157,7 +154,6 @@ export async function executeStatelessCheck(api, bundle, check, options, control
|
|
|
157
154
|
return;
|
|
158
155
|
const elapsed = Date.now() - (record.startedAt ?? Date.now());
|
|
159
156
|
if (elapsed >= controls.maxStepMs) {
|
|
160
|
-
// Keep the handle so `shipd checks status` / `cancel` still work on it.
|
|
161
157
|
endStep(stepId, {
|
|
162
158
|
status: "error",
|
|
163
159
|
error: `timed out after ${formatDuration(controls.maxStepMs)}`,
|
|
@@ -192,7 +188,6 @@ export async function executeStatelessCheck(api, bundle, check, options, control
|
|
|
192
188
|
await api.cancelStep(record.handle);
|
|
193
189
|
}
|
|
194
190
|
catch {
|
|
195
|
-
// Best effort: the handle is still in the report for a manual cancel.
|
|
196
191
|
}
|
|
197
192
|
}
|
|
198
193
|
endStep(stepId, {
|
|
@@ -212,7 +207,6 @@ export async function executeStatelessCheck(api, bundle, check, options, control
|
|
|
212
207
|
await cancelInFlight();
|
|
213
208
|
break;
|
|
214
209
|
}
|
|
215
|
-
// Schedule: every pending step whose dependencies are all terminal.
|
|
216
210
|
const toStart = [];
|
|
217
211
|
let progressed = false;
|
|
218
212
|
for (const step of check.steps) {
|
|
@@ -241,8 +235,6 @@ export async function executeStatelessCheck(api, bundle, check, options, control
|
|
|
241
235
|
if (allTerminal)
|
|
242
236
|
break;
|
|
243
237
|
if (!progressed) {
|
|
244
|
-
// Nothing can start and nothing is running: the plan references steps
|
|
245
|
-
// that do not exist. Report rather than spin forever.
|
|
246
238
|
for (const [stepId, record] of Object.entries(steps)) {
|
|
247
239
|
if (record.status === "pending") {
|
|
248
240
|
endStep(stepId, { status: "error", error: "unresolvable step dependencies" });
|
|
@@ -279,7 +271,6 @@ export async function executeStatelessCheck(api, bundle, check, options, control
|
|
|
279
271
|
const prefix = check.steps.length > 1 && stepId ? `${stepId}: ` : "";
|
|
280
272
|
return finish(check, { status: "error", error: `${prefix}${record.error ?? "step did not complete"}`, steps }, startedAt, controls);
|
|
281
273
|
}
|
|
282
|
-
/** Run one check live on an existing task; the quest writes its normal rows. */
|
|
283
274
|
export async function executeLiveCheck(api, task, check, options, controls) {
|
|
284
275
|
const startedAt = Date.now();
|
|
285
276
|
controls.onEvent?.({ type: "check:start", checkKey: check.key });
|
|
@@ -305,7 +296,6 @@ export async function executeLiveCheck(api, task, check, options, controls) {
|
|
|
305
296
|
const reason = started.detail ?? "the quest did not start this check";
|
|
306
297
|
return finish(check, { status: "skipped", reason, steps: step({ status: "skipped", reason }) }, startedAt, controls);
|
|
307
298
|
}
|
|
308
|
-
let nudged = false;
|
|
309
299
|
while (true) {
|
|
310
300
|
if (signal?.aborted) {
|
|
311
301
|
const reason = "interrupted; the check keeps running in the product";
|
|
@@ -324,16 +314,6 @@ export async function executeLiveCheck(api, task, check, options, controls) {
|
|
|
324
314
|
return finish(check, { status: "error", error: message, steps: step({ status: "error", error: message }) }, startedAt, controls);
|
|
325
315
|
}
|
|
326
316
|
if (live.status === "running") {
|
|
327
|
-
if (live.nudgeSynthesis && !nudged) {
|
|
328
|
-
nudged = true;
|
|
329
|
-
controls.onEvent?.({ type: "live:nudge", checkKey: check.key });
|
|
330
|
-
try {
|
|
331
|
-
await api.nudgeSynthesis(task.versionId);
|
|
332
|
-
}
|
|
333
|
-
catch {
|
|
334
|
-
// The product's own scheduler will pick it up; keep polling.
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
317
|
await sleep(controls.pollMs, signal);
|
|
338
318
|
continue;
|
|
339
319
|
}
|
|
@@ -359,7 +339,6 @@ export async function executeLiveCheck(api, task, check, options, controls) {
|
|
|
359
339
|
}, startedAt, controls);
|
|
360
340
|
}
|
|
361
341
|
}
|
|
362
|
-
/** Run the selected checks concurrently and return one result per check. */
|
|
363
342
|
export function runChecks(api, target, checks, options, controls) {
|
|
364
343
|
return Promise.all(checks.map((check) => target.kind === "harbor"
|
|
365
344
|
? executeStatelessCheck(api, target.bundle, check, options, controls)
|
package/dist/prompt.d.ts
ADDED
package/dist/prompt.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createInterface } from "node:readline";
|
|
2
|
+
import { Writable } from "node:stream";
|
|
3
|
+
export function readSecret(question, input = process.stdin, output = process.stdout) {
|
|
4
|
+
output.write(question);
|
|
5
|
+
const sink = new Writable({
|
|
6
|
+
write(_chunk, _encoding, callback) {
|
|
7
|
+
callback();
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
const rl = createInterface({ input, output: sink, terminal: input.isTTY === true });
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
let answered = false;
|
|
13
|
+
rl.question("", (answer) => {
|
|
14
|
+
answered = true;
|
|
15
|
+
rl.close();
|
|
16
|
+
output.write("\n");
|
|
17
|
+
resolve(answer.trim());
|
|
18
|
+
});
|
|
19
|
+
rl.on("close", () => {
|
|
20
|
+
if (!answered) {
|
|
21
|
+
output.write("\n");
|
|
22
|
+
resolve("");
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
package/dist/quests.d.ts
CHANGED
|
@@ -2,25 +2,17 @@ declare const VERSION: string, PACKAGE_NAME: string;
|
|
|
2
2
|
export { VERSION, PACKAGE_NAME };
|
|
3
3
|
export declare const DEFAULT_QUEST = "olympus";
|
|
4
4
|
export declare function knownQuests(): string[];
|
|
5
|
-
|
|
5
|
+
export declare function questHasAuthorCommands(quest: string): boolean;
|
|
6
6
|
export declare function questBaseUrl(quest: string): string;
|
|
7
|
-
/** `SHIPD_AUTH_URL` override, or NODE_ENV=development → localhost. */
|
|
8
7
|
export declare function platformAuthUrl(): string;
|
|
9
|
-
/** A quest's own copy of the token page (the platform page is the default). */
|
|
10
8
|
export declare function questAuthUrl(quest: string): string;
|
|
11
9
|
export interface QuestConfig {
|
|
12
10
|
convexUrl: string;
|
|
13
11
|
minCliVersion: string;
|
|
14
12
|
fetchedAt: string;
|
|
13
|
+
baseUrl: string;
|
|
15
14
|
}
|
|
16
|
-
/** Load the quest's CLI config (cached 5 minutes) or fetch it from the quest. */
|
|
17
15
|
export declare function questConfig(quest: string): Promise<QuestConfig>;
|
|
18
|
-
/** The quest's Convex deployment URL, with `SHIPD_<QUEST>_CONVEX_URL` override. */
|
|
19
16
|
export declare function questConvexUrl(quest: string): Promise<string>;
|
|
20
|
-
/** Compare semver strings numerically (e.g. "0.10.0" > "0.9.0"). */
|
|
21
17
|
export declare function semverGt(a: string, b: string): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Warn (never block) when this CLI is below the quest's minimum or behind the
|
|
24
|
-
* latest npm release. Set SHIPD_NO_UPDATE_CHECK=1 to skip.
|
|
25
|
-
*/
|
|
26
18
|
export declare function checkVersion(quest?: string): Promise<void>;
|