@letterstory/cli 0.175.11 → 0.175.12
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/lib/cli.mjs +17 -1
- package/lib/commands/bench.mjs +192 -0
- package/lib/commands.mjs +1 -0
- package/lib/documents.mjs +2 -0
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -74,10 +74,11 @@ import {
|
|
|
74
74
|
cmdVisits,
|
|
75
75
|
cmdSim,
|
|
76
76
|
cmdVary,
|
|
77
|
+
cmdBench,
|
|
77
78
|
} from "./commands.mjs";
|
|
78
79
|
|
|
79
80
|
// Matches cli/package.json; publish-cli.yml rewrites both to the published version.
|
|
80
|
-
export const VERSION = "0.175.
|
|
81
|
+
export const VERSION = "0.175.12";
|
|
81
82
|
|
|
82
83
|
/** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
|
|
83
84
|
export const EXIT_PAYMENT_REQUIRED = 3;
|
|
@@ -1718,6 +1719,20 @@ Vary (Variationals: A/B tests of a page's words and images on your own site):
|
|
|
1718
1719
|
vary start <id> | vary pause <id> | vary end <id> [--winner b]
|
|
1719
1720
|
vary remove-variant <id> <key> | vary delete <id>
|
|
1720
1721
|
|
|
1722
|
+
Bench (Benches: open-source benchmarks on their own domains, kept running; @letterstory.com only):
|
|
1723
|
+
bench [list] Your benches: stage, what each waits on, domain
|
|
1724
|
+
bench create (--prompt "<what it is and how it works>"|--prompt-file <path>) [--name <n>] [--domain <d>]
|
|
1725
|
+
[--letterbase <collection-id>] [--every <days>] [--repo-owner <o>] [--repo-name <r>] [--spec-file <path>]
|
|
1726
|
+
The repo lives on your organization's GitHub
|
|
1727
|
+
bench show <id> Spec, domain, repo, site, results, recent events
|
|
1728
|
+
bench update <id> [--name <n>] [--slug <s>] [--repo-owner <o>] [--repo-name <r>] [--spec-file <path>] [--domain <d>] [--every <days>]
|
|
1729
|
+
bench pause <id> | bench resume <id> | bench archive <id>
|
|
1730
|
+
bench advance <id> [--retry] Move it on now; --retry once blocked_on is done
|
|
1731
|
+
bench run <id> [--note "<what else to do>"] Letterpress-1 runs the benchmark again
|
|
1732
|
+
bench connect <id> <collection-id|none> A letterbase whose posts cite and link it
|
|
1733
|
+
bench cite <id> The reference line a post cites
|
|
1734
|
+
bench replicate <id> REPLICATE.md: how an agent reproduces the results
|
|
1735
|
+
|
|
1721
1736
|
Evals (how the pipeline is doing on your posts, and the regression cases captured from them):
|
|
1722
1737
|
evals scoreboard [--collection <id>] [--days N] Every measure by stage: posts, failing, rate
|
|
1723
1738
|
evals cases [--status open|guarding|proposed|retired|rejected] [--stage research|brief|links|mentions|accuracy|pipeline|shred]
|
|
@@ -1821,6 +1836,7 @@ const CLIENT_COMMANDS = {
|
|
|
1821
1836
|
visits: cmdVisits,
|
|
1822
1837
|
sim: cmdSim,
|
|
1823
1838
|
vary: cmdVary,
|
|
1839
|
+
bench: cmdBench,
|
|
1824
1840
|
// Platform-scoped (staff key) — the only commands that act BEFORE an org exists.
|
|
1825
1841
|
admin: cmdAdmin,
|
|
1826
1842
|
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// `bench` — Benches from a terminal (docs/architecture/benches.md): public, open-source benchmarks
|
|
2
|
+
// on their own domains, kept running by Letter. Staff only: the tools answer only a key an
|
|
3
|
+
// @letterstory.com person made. Thin wrappers over the bench tools (create_bench, list_benches,
|
|
4
|
+
// get_bench, update_bench, advance_bench, start_bench_run, connect_bench_letterbase,
|
|
5
|
+
// get_bench_citation), the same lib functions the app calls.
|
|
6
|
+
//
|
|
7
|
+
// letterstory bench create --prompt "Benchmark Acme's vector search against Pinecone and Qdrant: …"
|
|
8
|
+
// letterstory bench create --prompt-file brief.md --name VectorBench --domain vectorbench.dev --letterbase <collection-id>
|
|
9
|
+
// [--repo-owner <their GitHub account>] [--repo-name <name>]
|
|
10
|
+
// letterstory bench list
|
|
11
|
+
// letterstory bench show <id>
|
|
12
|
+
// letterstory bench update <id> [--name <n>] [--slug <s>] [--repo-owner <o>] [--repo-name <r>] [--spec-file spec.json] [--domain <d>] [--every <days>]
|
|
13
|
+
// letterstory bench pause <id> | resume <id> | archive <id>
|
|
14
|
+
// letterstory bench advance <id> [--retry]
|
|
15
|
+
// letterstory bench run <id> [--note "add Qdrant as a contender"]
|
|
16
|
+
// letterstory bench connect <id> <collection-id|none>
|
|
17
|
+
// letterstory bench cite <id>
|
|
18
|
+
// letterstory bench replicate <id>
|
|
19
|
+
|
|
20
|
+
import { readFileSync } from "node:fs";
|
|
21
|
+
import { CliError } from "../client.mjs";
|
|
22
|
+
import { argsFromFlags, flagStr, printResult, readTextInput, refuseUnknownFlags } from "./shared.mjs";
|
|
23
|
+
|
|
24
|
+
const benchId = { positional: 0, label: "bench-id", required: true };
|
|
25
|
+
|
|
26
|
+
function specFromFile(flags) {
|
|
27
|
+
const path = flagStr(flags["spec-file"]);
|
|
28
|
+
if (!path) return undefined;
|
|
29
|
+
try {
|
|
30
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
31
|
+
} catch {
|
|
32
|
+
throw new CliError(`--spec-file must be the spec as JSON (could not parse ${path})`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const ARGS = {
|
|
37
|
+
create_bench: {
|
|
38
|
+
prompt: {
|
|
39
|
+
value: (flags) => {
|
|
40
|
+
const prompt = readTextInput(flags, "prompt", "prompt-file");
|
|
41
|
+
if (prompt === undefined) throw new CliError("Missing required --prompt (or --prompt-file <path>)");
|
|
42
|
+
return prompt;
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
name: "name",
|
|
46
|
+
domain: "domain",
|
|
47
|
+
repo_owner: "repo-owner",
|
|
48
|
+
repo_name: "repo-name",
|
|
49
|
+
collection_id: "letterbase",
|
|
50
|
+
rerun_every_days: { flag: "every", type: "num" },
|
|
51
|
+
spec: { value: specFromFile },
|
|
52
|
+
},
|
|
53
|
+
list_benches: {},
|
|
54
|
+
get_bench: { bench_id: benchId },
|
|
55
|
+
update_bench: {
|
|
56
|
+
bench_id: benchId,
|
|
57
|
+
name: "name",
|
|
58
|
+
slug: "slug",
|
|
59
|
+
repo_owner: "repo-owner",
|
|
60
|
+
repo_name: "repo-name",
|
|
61
|
+
spec: { value: specFromFile },
|
|
62
|
+
domain: "domain",
|
|
63
|
+
rerun_every_days: { flag: "every", type: "num" },
|
|
64
|
+
status: { flag: "status", enum: ["live", "paused", "archived"] },
|
|
65
|
+
},
|
|
66
|
+
advance_bench: { bench_id: benchId, retry: { flag: "retry", type: "bool" } },
|
|
67
|
+
start_bench_run: { bench_id: benchId, note: "note" },
|
|
68
|
+
connect_bench_letterbase: {
|
|
69
|
+
bench_id: benchId,
|
|
70
|
+
collection_id: {
|
|
71
|
+
value: (_flags, positionals) => {
|
|
72
|
+
const v = positionals[1];
|
|
73
|
+
if (v === undefined) throw new CliError("Missing required <collection-id|none>");
|
|
74
|
+
return v === "none" ? null : v;
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
get_bench_citation: { bench_id: benchId },
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
function call(ctx, tool) {
|
|
82
|
+
return ctx.client.callTool(tool, argsFromFlags(ARGS[tool], ctx.flags, ctx.positionals));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function cmdBench(ctx) {
|
|
86
|
+
const sub = ctx.positionals[0];
|
|
87
|
+
const rest = { ...ctx, positionals: ctx.positionals.slice(1) };
|
|
88
|
+
switch (sub) {
|
|
89
|
+
case undefined:
|
|
90
|
+
case "list":
|
|
91
|
+
case "ls":
|
|
92
|
+
return benchList(rest);
|
|
93
|
+
case "create":
|
|
94
|
+
refuseUnknownFlags(rest, ARGS.create_bench, ["prompt", "prompt-file", "spec-file"]);
|
|
95
|
+
return benchShow(rest, await call(rest, "create_bench"));
|
|
96
|
+
case "show":
|
|
97
|
+
return benchShow(rest, await call(rest, "get_bench"));
|
|
98
|
+
case "update":
|
|
99
|
+
refuseUnknownFlags(rest, ARGS.update_bench, ["spec-file"]);
|
|
100
|
+
return benchShow(rest, await call(rest, "update_bench"));
|
|
101
|
+
case "pause":
|
|
102
|
+
case "resume":
|
|
103
|
+
case "archive":
|
|
104
|
+
rest.flags = { ...rest.flags, status: { pause: "paused", resume: "live", archive: "archived" }[sub] };
|
|
105
|
+
return benchShow(rest, await call(rest, "update_bench"));
|
|
106
|
+
case "advance":
|
|
107
|
+
refuseUnknownFlags(rest, ARGS.advance_bench, []);
|
|
108
|
+
return benchShow(rest, await call(rest, "advance_bench"));
|
|
109
|
+
case "run":
|
|
110
|
+
refuseUnknownFlags(rest, ARGS.start_bench_run, []);
|
|
111
|
+
return benchShow(rest, await call(rest, "start_bench_run"));
|
|
112
|
+
case "connect":
|
|
113
|
+
return benchShow(rest, await call(rest, "connect_bench_letterbase"));
|
|
114
|
+
case "cite":
|
|
115
|
+
return benchCite(rest);
|
|
116
|
+
case "replicate":
|
|
117
|
+
return benchReplicate(rest);
|
|
118
|
+
default:
|
|
119
|
+
throw new CliError(
|
|
120
|
+
"Usage: bench [list|create|show|update|pause|resume|archive|advance|run|connect|cite|replicate]"
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const title = (b) => b.name || "(drafting the spec)";
|
|
126
|
+
|
|
127
|
+
async function benchList(ctx) {
|
|
128
|
+
const result = await call(ctx, "list_benches");
|
|
129
|
+
printResult(ctx.io, ctx.flags, result, (r) => {
|
|
130
|
+
if (!r.benches?.length)
|
|
131
|
+
return 'No benches yet. Start one: bench create --prompt "<what it is and how it works>"';
|
|
132
|
+
return r.benches
|
|
133
|
+
.map(
|
|
134
|
+
(b) =>
|
|
135
|
+
`${b.id} ${title(b).padEnd(24)} ${(b.blocked_on ? "blocked" : b.status).padEnd(10)} ${b.stage.padEnd(7)} ${b.domain ?? ""}`
|
|
136
|
+
)
|
|
137
|
+
.join("\n");
|
|
138
|
+
});
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function benchShow(ctx, result) {
|
|
143
|
+
printResult(ctx.io, ctx.flags, result, (r) => {
|
|
144
|
+
const b = r.bench;
|
|
145
|
+
const lines = [
|
|
146
|
+
`${title(b)} — ${b.status}, stage ${b.stage}`,
|
|
147
|
+
...(b.spec ? [` ${b.spec.tagline}`] : []),
|
|
148
|
+
...(b.blocked_on ? [` Blocked: ${b.blocked_on}`, ` Then: bench advance ${b.id} --retry`] : []),
|
|
149
|
+
...(b.stage_note && !b.blocked_on ? [` ${b.stage_note}`] : []),
|
|
150
|
+
...(b.domain
|
|
151
|
+
? [` Domain ${b.domain}${b.domain_decision?.source === "ai" ? " (chosen and bought)" : ""}`]
|
|
152
|
+
: []),
|
|
153
|
+
...(b.repo_url ? [` Repo ${b.repo_url}`] : []),
|
|
154
|
+
...(b.site_url
|
|
155
|
+
? [` Site ${b.site_url}${b.site_ok === false ? " (not serving at the last check)" : ""}`]
|
|
156
|
+
: []),
|
|
157
|
+
...(b.run_id ? [` Run ${b.run_id} (repo show ${b.run_id})`] : []),
|
|
158
|
+
...(b.next_run_at && b.status === "live" ? [` Next run ${b.next_run_at}`] : []),
|
|
159
|
+
];
|
|
160
|
+
if (b.results) {
|
|
161
|
+
lines.push("", `Results (${b.results.ran_at}): ${b.results.summary}`);
|
|
162
|
+
}
|
|
163
|
+
const board = r.citation?.leaderboard ?? [];
|
|
164
|
+
for (const row of board) {
|
|
165
|
+
lines.push(
|
|
166
|
+
` ${String(row.rank ?? "–").padStart(2)} ${row.name.padEnd(24)} ${row.value ?? "—"} ${row.status === "ok" ? "" : row.status}`
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
if (r.run) lines.push("", `Started run ${r.run.id}: repo show ${r.run.id}`);
|
|
170
|
+
if (typeof r.linked === "boolean") {
|
|
171
|
+
lines.push("", r.linked ? "The letterbase cites and links it now." : "Linked once the bench is live.");
|
|
172
|
+
}
|
|
173
|
+
if (r.events?.length) {
|
|
174
|
+
lines.push("", "Recent:");
|
|
175
|
+
for (const e of r.events.slice(0, 8)) lines.push(` ${e.created_at} ${e.message}`);
|
|
176
|
+
}
|
|
177
|
+
return lines.join("\n");
|
|
178
|
+
});
|
|
179
|
+
return 0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function benchCite(ctx) {
|
|
183
|
+
const result = await call(ctx, "get_bench_citation");
|
|
184
|
+
printResult(ctx.io, ctx.flags, result, (r) => r.citation.cite_as);
|
|
185
|
+
return 0;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function benchReplicate(ctx) {
|
|
189
|
+
const result = await call(ctx, "get_bench");
|
|
190
|
+
printResult(ctx.io, ctx.flags, result, (r) => r.replication ?? "No instructions yet: the spec isn't drafted.");
|
|
191
|
+
return 0;
|
|
192
|
+
}
|
package/lib/commands.mjs
CHANGED
package/lib/documents.mjs
CHANGED
|
@@ -63,6 +63,8 @@ export const DOCUMENT_FLAG_PAIRS = [
|
|
|
63
63
|
["manifesto", "manifesto-file"],
|
|
64
64
|
// A repo change's brief (repo.mjs `repo start`) — prose, so a .docx or PDF spec is fine.
|
|
65
65
|
["instructions", "instructions-file"],
|
|
66
|
+
// A bench's prompt (bench.mjs `bench create`): what the benchmark is and how it works, prose.
|
|
67
|
+
["prompt", "prompt-file"],
|
|
66
68
|
];
|
|
67
69
|
|
|
68
70
|
/**
|