@letterstory/cli 0.175.11 → 0.175.13

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 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.11";
81
+ export const VERSION = "0.175.13";
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;
@@ -968,7 +969,7 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
968
969
  judgement's weights per ask, each lens's bar and read
969
970
  budget, each surface's ask and guidance, the dismissal
970
971
  window. Needs recipes:read.
971
- admin letterpress set <weights.<ask>.<reading>|lenses.<lens>.bar.<reading>|lenses.<lens>.bar|lenses.<lens>.research.turns|lenses.<lens>.research.ms|asks.<lens>.ask|asks.<lens>.guidance|dismissals.block_days|explore.ask|explore.research.turns|explore.every_days> <value>
972
+ admin letterpress set <weights.<ask>.<reading>|lenses.<lens>.bar.<reading>|lenses.<lens>.bar|lenses.<lens>.research.turns|lenses.<lens>.research.ms|asks.<lens>.ask|asks.<lens>.guidance|dismissals.block_days|preflight.off|explore.ask|explore.research.turns|explore.every_days> <value>
972
973
  Change one weight, one bar, or a lens's ask and guidance (the
973
974
  opinions Letterpress chooses by, as staff's words); the version
974
975
  bumps and the previous body is kept. Needs recipes:write.
@@ -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
  };
@@ -5127,7 +5127,7 @@ const ENGINE = "/api/superadmin/engine-settings";
5127
5127
  const LETTERPRESS = "/api/superadmin/letterpress";
5128
5128
  const CODING_TELEMETRY = "/api/superadmin/coding-telemetry";
5129
5129
  const ENGINE_USAGE =
5130
- "Usage: admin letterpress status | gaps | telemetry [--days N] [--harness h] [--all-orgs] | runs [--status s] [--error-code c] [--first-review-cause agent|context|setup|unknown] [--pr merged|closed|open|none] [--harness h] [--days N] | beyond [--limit N] [--before ISO] | companies | company <org-id> [--site host] | facts <org-id> [--site host] | fits [--recipe id] [--org id] [--site host] [--fits yes|no|unknown|waiting] [--limit N] | replay <run-id> | mark <run-id> <item-id> <right|weak|wrong|lead|gap|recipe|clear> [--note …] | settings | set <weights.<ask>.<reading>|lenses.<lens>.bar.<reading>|lenses.<lens>.bar|lenses.<lens>.research.turns|lenses.<lens>.research.ms|asks.<lens>.ask|asks.<lens>.guidance|dismissals.block_days|explore.ask|explore.research.turns|explore.research.ms|explore.every_days> <value>";
5130
+ "Usage: admin letterpress status | gaps | telemetry [--days N] [--harness h] [--all-orgs] | blocked [--days N] [--org id] [--all-orgs] | unblock <org-id> <host> <subject> | runs [--status s] [--error-code c] [--first-review-cause agent|context|setup|unknown] [--pr merged|closed|open|none] [--harness h] [--days N] | beyond [--limit N] [--before ISO] | companies | company <org-id> [--site host] | facts <org-id> [--site host] | fits [--recipe id] [--org id] [--site host] [--fits yes|no|unknown|waiting] [--limit N] | replay <run-id> | mark <run-id> <item-id> <right|weak|wrong|lead|gap|recipe|clear> [--note …] | settings | set <weights.<ask>.<reading>|lenses.<lens>.bar.<reading>|lenses.<lens>.bar|lenses.<lens>.research.turns|lenses.<lens>.research.ms|asks.<lens>.ask|asks.<lens>.guidance|dismissals.block_days|preflight.off|explore.ask|explore.research.turns|explore.research.ms|explore.every_days> <value>";
5131
5131
 
5132
5132
  /** One number of the settings from a dotted path and a value: the PUT body save_engine_settings reads. */
5133
5133
  function engineSettingsPatch(path, value) {
@@ -5150,6 +5150,11 @@ function engineSettingsPatch(path, value) {
5150
5150
  if (!Number.isInteger(n)) throw new CliError(`${path}: a whole number of days`);
5151
5151
  return { explore: { every_days: n } };
5152
5152
  }
5153
+ // preflight.off wrong_repo,not_in_repo: those codes are not enforced (blank or "none": every code back on).
5154
+ if (parts[0] === "preflight" && parts[1] === "off" && parts.length === 2) {
5155
+ const text = String(value ?? "").trim();
5156
+ return { preflight: { off: text === "" || text === "none" ? [] : text.split(",").map((c) => c.trim()) } };
5157
+ }
5153
5158
  if (parts[0] === "dismissals" && parts[1] === "block_days" && parts.length === 2) {
5154
5159
  const n = Number(value);
5155
5160
  if (!Number.isInteger(n)) throw new CliError(`${path}: a whole number of days`);
@@ -5238,6 +5243,9 @@ async function cmdAdminLetterpress(ctx) {
5238
5243
  ? `asks from: ${s.surfaces.map((x) => `${x.surface} ${x.runs}`).join(", ")}`
5239
5244
  : "no runs yet",
5240
5245
  `turns ${s.turns.runs}${s.turns.by_action.length ? ` (${s.turns.by_action.map((a) => `${a.action} ${a.runs}`).join(", ")})` : ""}; builds ${s.turns.merge.builds}, merged ${s.turns.merge.merged}, closed ${s.turns.merge.closed}${s.customer_only ? " [customers only]" : ""}`,
5246
+ s.withheld && s.withheld.active > 0
5247
+ ? `withheld: ${s.withheld.active} suggestion${s.withheld.active === 1 ? "" : "s"} in ${s.withheld.orgs} org${s.withheld.orgs === 1 ? "" : "s"} (Letter cannot do them there)${s.withheld.recipe_bugs ? `; ${s.withheld.recipe_bugs} recipe bug${s.withheld.recipe_bugs === 1 ? "" : "s"}` : ""} → admin letterpress blocked`
5248
+ : "withheld: none",
5241
5249
  ...(s.harness_evals ?? []).map(
5242
5250
  (p) =>
5243
5251
  `harness eval ${p.at.slice(0, 10)} (${p.version}, ${p.pairs} pairs): ${p.harnesses
@@ -5284,6 +5292,46 @@ async function cmdAdminLetterpress(ctx) {
5284
5292
  );
5285
5293
  return 0;
5286
5294
  }
5295
+ case "blocked": {
5296
+ // list_blockers: what Letter withheld because it cannot do it here (docs/architecture/preflight.md).
5297
+ const q = new URLSearchParams({ view: "blocked", days: String(flags.days ?? 7) });
5298
+ if (flags.org) q.set("org_id", String(flags.org));
5299
+ if (flagBool(flags["all-orgs"])) q.set("customers", "0");
5300
+ const r = await staffRequest(ctx, "GET", `${CODING_TELEMETRY}?${q}`);
5301
+ printResult(io, flags, r, (b) =>
5302
+ [
5303
+ `Withheld now: ${b.active} in ${b.orgs} organizations. In the last ${b.days} days: ${b.cleared.facts} came back (facts moved), ${b.cleared.time} timed out, ${b.cleared.staff} cleared by staff.${b.off.length ? ` OFF: ${b.off.join(", ")}` : ""}`,
5304
+ ...b.by_code.map(
5305
+ (c) =>
5306
+ `${c.code.padEnd(14)} ${String(c.active).padStart(3)} in ${c.orgs} orgs (${c.owner}) ${c.what_to_do}`
5307
+ ),
5308
+ ...(b.by_subject.length ? ["", "Most blocked:"] : []),
5309
+ ...b.by_subject.map(
5310
+ (s) =>
5311
+ ` ${s.recipe_bug ? "RECIPE BUG " : ""}${s.label} [${s.code}] ${s.active} in ${s.orgs} orgs`
5312
+ ),
5313
+ ...(b.recent.length ? ["", "Holding now:"] : []),
5314
+ ...b.recent
5315
+ .slice(0, 20)
5316
+ .map(
5317
+ (x) =>
5318
+ ` ${(x.org_name ?? x.org_id).slice(0, 24).padEnd(24)} ${x.host} ${x.subject} [${x.code}] ${x.say}`
5319
+ ),
5320
+ ].join("\n")
5321
+ );
5322
+ return 0;
5323
+ }
5324
+ case "unblock": {
5325
+ // clear_blocker: "Show anyway" on one withheld item.
5326
+ const [orgId, host, subject] = positionals.slice(1);
5327
+ if (!orgId || !host || !subject)
5328
+ throw new CliError("Usage: admin letterpress unblock <org-id> <host> <subject>");
5329
+ const r = await staffRequest(ctx, "POST", CODING_TELEMETRY, { org_id: orgId, host, subject });
5330
+ printResult(io, flags, r, (x) =>
5331
+ x.cleared ? "Cleared: it is offered and allowed to start again." : "Nothing was holding."
5332
+ );
5333
+ return 0;
5334
+ }
5287
5335
  case "runs": {
5288
5336
  // list_coding_runs with fleet.
5289
5337
  const q = new URLSearchParams({
@@ -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
@@ -52,3 +52,4 @@ export * from "./commands/evals.mjs";
52
52
  export * from "./commands/visits.mjs";
53
53
  export * from "./commands/sim.mjs";
54
54
  export * from "./commands/vary.mjs";
55
+ export * from "./commands/bench.mjs";
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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.175.11",
3
+ "version": "0.175.13",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",