@letterstory/cli 0.177.53 → 0.177.55

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
@@ -90,7 +90,7 @@ import {
90
90
  import { fetchParkedSections, withoutParked } from "./parked.mjs";
91
91
 
92
92
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
93
- export const VERSION = "0.177.53";
93
+ export const VERSION = "0.177.55";
94
94
 
95
95
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
96
96
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -2133,12 +2133,15 @@ Models (your own writing models, each trained on writing you give it so it write
2133
2133
  models material-review <id> <request-id> [<selection-id>…] [--cancel]
2134
2134
  Accept this request, or cancel it; never trains
2135
2135
  models material-history <id> [--offset <n>] Earlier material requests
2136
+ models preview <id> [--offset <n>] The training rows a run would build
2136
2137
  models add <id> <url>… [--train] Links to pieces of your writing; --train starts training
2137
2138
  models find <id> "<the writing to find>" [--max <n>] Letter finds the links and proposes them
2138
2139
  models confirm <id> [<link-id>…] [--keep-rest] [--no-train]
2139
2140
  Confirm what was found (all, or the ids) and train on it
2140
2141
  models remove <id> <link-id>… Take links out of the next version
2141
- models train <id> [--retry] Train the next version, or try a stopped one again
2142
+ models train <id> [--retry] [--recipe <id>] Train the next version, or try a stopped one again
2143
+ models test <id> [--version <n>] [--units <n>] Test a version on held-out writing against Claude with examples
2144
+ models activate <id> <version> Make a ready version live (a first version is live when it trains)
2142
2145
  models stop <id> Stop what is training; what it spent is charged
2143
2146
  models rewrite <id> "<source text>" Rewrite supplied prose in its trained voice
2144
2147
  models compare <id> "<source text>" Compare your model, Astra and Claude + Skill
@@ -10,10 +10,13 @@
10
10
  // letterstory models add <id> <url>… [--train]
11
11
  // letterstory models upload <id> <file-or-folder>…
12
12
  // letterstory models material <id> "<material or request>"
13
+ // letterstory models preview <id> [--offset <n>] the training set a run would build
13
14
  // letterstory models find <id> "<the writing to find>" [--max <n>]
14
15
  // letterstory models confirm <id> [<link-id>…] [--keep-rest] [--no-train] no link ids: all of them
15
16
  // letterstory models remove <id> <link-id>…
16
- // letterstory models train <id> [--retry]
17
+ // letterstory models train <id> [--retry] [--recipe rewrite_v1|content_brief_v2]
18
+ // letterstory models activate <id> <version> make a ready version live
19
+ // letterstory models test <id> [--version <n>] [--units <8-24>] test a version on held-out writing
17
20
  // letterstory models stop <id> stop what is training
18
21
  // letterstory models write <id> "<what to write>" [--words <n>]
19
22
  // letterstory models update <id> [--name <n>] [--budget <usd>] [--description <d>] [--base <base-id>]
@@ -73,6 +76,7 @@ export const ARGS = {
73
76
  selection_id: "selection",
74
77
  statuses: { flag: "status", type: "list" },
75
78
  },
79
+ preview_writing_model_training: { model_id: modelId, offset: { flag: "offset", type: "num" } },
76
80
  review_writing_model_material: {
77
81
  model_id: modelId,
78
82
  request_id: { positional: 1, required: true, label: "request-id" },
@@ -100,20 +104,32 @@ export const ARGS = {
100
104
  train: { flag: "no-train", type: "bool", invert: true },
101
105
  },
102
106
  remove_writing_model_links: { model_id: modelId, source_ids: { value: rest(1) } },
103
- train_writing_model: { model_id: modelId, retry: { flag: "retry", type: "bool" } },
107
+ train_writing_model: { model_id: modelId, retry: { flag: "retry", type: "bool" }, recipe: "recipe" },
108
+ activate_writing_model_version: {
109
+ model_id: modelId,
110
+ version: { value: (flags, positionals) => (positionals[1] ? Number(positionals[1]) : undefined) },
111
+ },
112
+ evaluate_writing_model_version: {
113
+ model_id: modelId,
114
+ version: { flag: "version", type: "num" },
115
+ units: { flag: "units", type: "num" },
116
+ },
104
117
  cancel_writing_model_run: { model_id: modelId },
105
118
  rewrite_with_writing_model: {
106
119
  model_id: modelId,
107
120
  text: { value: (flags, positionals) => positionals.slice(1).join(" ").trim() || undefined },
121
+ version: { flag: "version", type: "num" },
108
122
  },
109
123
  compare_writing_model: {
110
124
  model_id: modelId,
111
125
  text: { value: (flags, positionals) => positionals.slice(1).join(" ").trim() || undefined },
126
+ version: { flag: "version", type: "num" },
112
127
  },
113
128
  write_with_writing_model: {
114
129
  model_id: modelId,
115
130
  ask: { value: (flags, positionals) => positionals.slice(1).join(" ").trim() || undefined },
116
131
  max_words: { flag: "words", type: "num" },
132
+ version: { flag: "version", type: "num" },
117
133
  },
118
134
  };
119
135
 
@@ -212,6 +228,21 @@ export async function cmdModels(ctx) {
212
228
  case "material-show":
213
229
  printResult(next.io, next.flags, await call(next, "get_writing_model_material"), (r) => JSON.stringify(r));
214
230
  return 0;
231
+ case "preview": {
232
+ refuseUnknownFlags(next, ARGS.preview_writing_model_training, []);
233
+ printResult(next.io, next.flags, await call(next, "preview_writing_model_training"), (r) =>
234
+ [
235
+ `${r.sources} sources, ${r.pieces} pieces (${r.repeatedPieces} repeated, kept once), ${r.passages} rows, ${r.words} words`,
236
+ `${r.trainRows} to train on, ${r.heldOutRows} held out${r.blockedOn ? `; ${r.blockedOn}` : ""}`,
237
+ ...r.rows.map(
238
+ (row) =>
239
+ `\n--- ${row.title ?? row.sourceId}${row.parts > 1 ? ` (part ${row.part} of ${row.parts})` : ""}, ${row.words} words${row.heldOut ? ", held out" : ""}\n${row.text}${row.truncated ? "\n…" : ""}`
240
+ ),
241
+ ...(r.hasMore ? ["\nMore: --offset"] : []),
242
+ ].join("\n")
243
+ );
244
+ return 0;
245
+ }
215
246
  case "material": {
216
247
  refuseUnknownFlags(next, ARGS.ingest_writing_model_material, []);
217
248
  return modelShow(next, await call(next, "ingest_writing_model_material"));
@@ -266,6 +297,18 @@ export async function cmdModels(ctx) {
266
297
  printResult(next.io, next.flags, result, (r) => runLine(r.run));
267
298
  return 0;
268
299
  }
300
+ case "activate": {
301
+ refuseUnknownFlags(next, ARGS.activate_writing_model_version, []);
302
+ const args = argsFromFlags(ARGS.activate_writing_model_version, next.flags, next.positionals);
303
+ if (!Number.isInteger(args.version)) throw new CliError("Give the version: models activate <id> <version>");
304
+ return modelShow(next, await next.client.callTool("activate_writing_model_version", args));
305
+ }
306
+ case "test": {
307
+ refuseUnknownFlags(next, ARGS.evaluate_writing_model_version, []);
308
+ const result = await call(next, "evaluate_writing_model_version");
309
+ printResult(next.io, next.flags, result, (r) => evaluationLines(r.evaluation).join("\n"));
310
+ return 0;
311
+ }
269
312
  case "stop": {
270
313
  refuseUnknownFlags(next, ARGS.cancel_writing_model_run, []);
271
314
  const result = await call(next, "cancel_writing_model_run");
@@ -308,11 +351,24 @@ export async function cmdModels(ctx) {
308
351
  return modelShow(next, await call(next, "update_writing_model", { archived: sub === "archive" }));
309
352
  default:
310
353
  throw new CliError(
311
- "Usage: models [list|create|show|add|find|confirm|remove|train|stop|rewrite|compare|write|update|archive|restore]"
354
+ "Usage: models [list|create|show|add|find|confirm|remove|train|test|activate|stop|rewrite|compare|write|update|archive|restore]"
312
355
  );
313
356
  }
314
357
  }
315
358
 
359
+ const pct = (x) => (x === null || x === undefined ? "n/a" : `${Math.round(x * 100)}%`);
360
+
361
+ function evaluationLines(e) {
362
+ if (e.status === "too_few") return [`Version ${e.version}: only ${e.units} held-out passages, too few to read.`];
363
+ return [
364
+ `Version ${e.version} (${e.recipe}) on ${e.units} held-out passages${e.failed ? `, ${e.failed} left out` : ""}:`,
365
+ ` picked as the real writing: version ${pct(e.adapterVsOriginal)}, Claude with examples ${pct(e.baselineVsOriginal)} (50% is indistinguishable)`,
366
+ ` version against Claude with examples: ${pct(e.adapterVsBaseline)} chose the version`,
367
+ ` real against real (judge check): ${pct(e.nullTest)}`,
368
+ ` facts kept: version ${pct(e.factsKept.adapter)}, Claude ${pct(e.factsKept.baseline)}`,
369
+ ];
370
+ }
371
+
316
372
  function runLine(run) {
317
373
  if (!run) return "Not trained yet.";
318
374
  const where = run.blockedOn ? `stopped: ${run.blockedOn}` : (run.stageNote ?? run.stage);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.177.53",
3
+ "version": "0.177.55",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",