@letterstory/cli 0.174.3 → 0.174.5

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
@@ -29,6 +29,7 @@ import {
29
29
  cmdPublished,
30
30
  cmdReviewers,
31
31
  cmdAutomations,
32
+ cmdAutomate,
32
33
  cmdCollections,
33
34
  cmdAuthors,
34
35
  cmdFlows,
@@ -75,7 +76,7 @@ import {
75
76
  } from "./commands.mjs";
76
77
 
77
78
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
78
- export const VERSION = "0.174.3";
79
+ export const VERSION = "0.174.5";
79
80
 
80
81
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
81
82
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -84,6 +85,10 @@ export const EXIT_PAYMENT_REQUIRED = 3;
84
85
  // can't accidentally swallow the id as --json's value. Every `type: "bool"` flag (and its
85
86
  // `negate` spelling) in a command's ARGS map must be listed; boolean-flags.test.ts enforces it.
86
87
  export const BOOLEAN_FLAGS = new Set([
88
+ // automate add/set: on or off; only identified visitors marked hot leads.
89
+ "on",
90
+ "off",
91
+ "hot-leads-only",
87
92
  // admin crm prospect-org: start (or retry) the org prepared for the booked call.
88
93
  "start",
89
94
  // site research-builds: run now even when the stored pass is under an hour old.
@@ -469,6 +474,7 @@ Collections (the content engine as a primitive — one door, 'collection run'):
469
474
  collection run-status <run-id> Status, steps, constraints, verification
470
475
  collection runs [--collection <id>] [--status <s>] [--limit <n>]
471
476
  collection approve <run-id> [--now] Answer the gate (--now publishes immediately)
477
+ collection move <run-id> --date YYYY-MM-DD Move a slot not yet written, or an approved written post, to another day
472
478
  collection cancel <run-id>
473
479
  collection inventory <id> Where every piece is; each finished draft's publish-on-its-own time
474
480
  collection links <id> [--refresh] Internal-link refresh: on/off, posts due (--refresh runs the next batch now)
@@ -547,6 +553,27 @@ Reviewers:
547
553
  automations set <automation-id> --collection <id> [--pace <n>] [--pause | --resume] [--goal <id>]
548
554
  [--brief <text>] [--remap]
549
555
  automations remove <automation-id> --collection <id>
556
+ automate options What an automation can be made of here: triggers,
557
+ actions and what each can be fixed to
558
+ automate list Your automations: an event, what Letter reads it
559
+ for, the action it becomes
560
+ automate show <automation-id>
561
+ automate add --name <n> --trigger competitor_page|visitor_identified|custom
562
+ --action write_post|enroll_in_sequence|build_page [--instruction <text>]
563
+ [--collection <id>|--sequence <id>|--host <site>] [--event <name>] [--kind post|landing]
564
+ [--competitor <host>] [--site <host>] [--hot-leads-only] [--review act|ask] [--off]
565
+ Make one: it starts from now
566
+ automate set <automation-id> [--name <n>] [--instruction <text>] [--review act|ask] [--on|--off] ...
567
+ automate try [<automation-id>] [--trigger <t> --action <a> --instruction <text> ...] [--limit <n>]
568
+ What it would do with the latest events (acts on none)
569
+ automate runs [--automation <id>] [--status proposed|acted|skipped|failed|rejected] [--limit <n>]
570
+ Every event read, what came of it and why
571
+ automate approve <run-id> Make the call a run that asked first proposes
572
+ automate reject <run-id> --reason <why>
573
+ automate send <event-name> --title <what happened> [--key <id>] [--url <u>] [--fact k=v ...]
574
+ [--email <e>] [--person <name>] [--company <c>]
575
+ Send an event from your own systems
576
+ automate remove <automation-id>
550
577
  reviewers invite <article-id> --email <e> [--name <n>]
551
578
  Invite a guest to review one post
552
579
  (emails them a link and a PIN)
@@ -1636,8 +1663,9 @@ Repo changes (Claude Code edits your repo in a sandbox; the Letter GitHub App op
1636
1663
  [--detail full] one row per run by default; full: every field
1637
1664
  repo publish <run-id> Make PR on a preview in review
1638
1665
  repo merge <run-id> Merge its open PR (a squash; the repo's branch rules decide)
1639
- repo revise <run-id> --instructions <text>|--instructions-file <path|->
1640
- Ask for more on a preview; it takes over the preview's link
1666
+ repo revise <run-id> --instructions <text>|--instructions-file <path|-> [--copy-edits-file <path|->]
1667
+ Ask for more on a preview (it takes over the preview's link) or an
1668
+ open PR (one more commit); copy edits: JSON [{ path, before, after }]
1641
1669
  repo cancel <run-id> [--force] Stop it and delete the sandbox; no PR (Discard a preview)
1642
1670
 
1643
1671
  Feedback (tell us what's broken, missing, unclear, or wanted):
@@ -1727,6 +1755,7 @@ const CLIENT_COMMANDS = {
1727
1755
  published: cmdPublished,
1728
1756
  reviewers: cmdReviewers,
1729
1757
  automations: cmdAutomations,
1758
+ automate: cmdAutomate,
1730
1759
  collections: cmdCollections,
1731
1760
  authors: cmdAuthors,
1732
1761
  flows: cmdFlows,
@@ -5029,10 +5029,11 @@ const RECIPE_FILE_FIELDS = [
5029
5029
  "when_not_to_use",
5030
5030
  "weight",
5031
5031
  "approaches",
5032
+ "runs",
5032
5033
  "variations",
5033
5034
  ];
5034
5035
  const RECIPES_USAGE =
5035
- "Usage: admin recipes list [--kind recipe|known_issue] [--approach seo|geo|agent_conviction|inbound_conversion|outbound|other] | show <id|name> | runs <id|name> [--days 1..90] [--limit n] | vocab | stats | export [--out <file>] | import <file> [--dry-run] | save [<id>] [--file <recipe.json>] [--kind recipe|known_issue] [--name …] [--description …] [--recipe …] [--when-to-use …] [--when-not-to-use …] [--weight 1..10] [--approaches seo,geo,…] | delete <id> --yes";
5036
+ "Usage: admin recipes list [--kind recipe|known_issue] [--approach seo|geo|agent_conviction|inbound_conversion|outbound|other] | show <id|name> | runs <id|name> [--days 1..90] [--limit n] | vocab | stats | export [--out <file>] | import <file> [--dry-run] | save [<id>] [--file <recipe.json>] [--kind recipe|known_issue] [--name …] [--description …] [--recipe …] [--when-to-use …] [--when-not-to-use …] [--weight 1..10] [--approaches seo,geo,…] [--runs <catalog action id>] | delete <id> --yes";
5036
5037
 
5037
5038
  const recipeForFile = (r) => Object.fromEntries(RECIPE_FILE_FIELDS.map((k) => [k, r[k]]));
5038
5039
 
@@ -5063,6 +5064,7 @@ function recipeDetail(r) {
5063
5064
  `${r.name} weight ${r.weight}/10 ${r.id}`,
5064
5065
  ` kind: ${r.kind === "known_issue" ? "known issue (Fix's list)" : "recipe (the Plan's)"}`,
5065
5066
  ` approaches: ${recipeApproaches(r)}`,
5067
+ ` runs: ${r.runs || "one change to the site's code, from its own directions"}`,
5066
5068
  ...(variations.length > 1
5067
5069
  ? variations.flatMap((v, i) => [` variation ${i + 1}: ${v.name}`, ...fields(v, " ")])
5068
5070
  : fields(r, " ")),
@@ -5102,6 +5104,8 @@ function recipeFromFlags(flags) {
5102
5104
  when_to_use: flagStr(flags["when-to-use"]),
5103
5105
  when_not_to_use: flagStr(flags["when-not-to-use"]),
5104
5106
  weight: flagNum(flags.weight),
5107
+ // --runs visitors:site names the catalog action; --runs "" is one change to the site's code.
5108
+ runs: flagStr(flags.runs),
5105
5109
  // --approaches seo,geo sets the tags; --approaches "" clears them.
5106
5110
  approaches: flagStr(flags.approaches)
5107
5111
  ?.split(",")
@@ -5477,9 +5481,12 @@ async function cmdAdminRecipes(ctx) {
5477
5481
  };
5478
5482
  printResult(io, flags, result, (r) =>
5479
5483
  [
5480
- ...r.results.map(
5481
- (row) =>
5482
- `${verb[row.action] ?? row.action} ${row.name}${row.changed.length && row.action !== "create" ? ` (${row.changed.join(", ")})` : ""}${row.error ? ` → ${row.error}` : ""}`
5484
+ ...r.results.map((row) =>
5485
+ [
5486
+ `${verb[row.action] ?? row.action} ${row.name}${row.changed.length && row.action !== "create" ? ` (${row.changed.join(", ")})` : ""}${row.error ? ` → ${row.error}` : ""}`,
5487
+ // What staff should know about it as it stands (lint): said under the row, never a block.
5488
+ ...(row.warnings ?? []).map((w) => ` warn: ${w}`),
5489
+ ].join("\n")
5483
5490
  ),
5484
5491
  `${r.dry_run ? "Would create" : "Created"} ${r.counts.created}, ${r.dry_run ? "update" : "updated"} ${r.counts.updated}; ${r.counts.unchanged} unchanged, ${r.counts.failed} failed.${r.dry_run ? " Nothing was written (--dry-run)." : ""}`,
5485
5492
  ].join("\n")
@@ -5494,6 +5501,7 @@ async function cmdAdminRecipes(ctx) {
5494
5501
  ? await staffRequest(ctx, "PATCH", `${RECIPES}/${encodeURIComponent(id)}`, fields)
5495
5502
  : await staffPost(ctx, RECIPES, fields);
5496
5503
  ok(ctx, `${result.created ? "Created" : "Saved"} "${result.recipe.name}" (${result.recipe.id}).`);
5504
+ for (const w of result.warnings ?? []) io.error(`warn: ${w}`);
5497
5505
  printResult(io, flags, result, (r) => recipeDetail(r.recipe));
5498
5506
  return 0;
5499
5507
  }
@@ -0,0 +1,162 @@
1
+ // `automate` — Letterpress → Automations (docs/architecture/event-automations.md): an event, read
2
+ // against your instruction, made into an action. options / list / show / add / set / try / runs /
3
+ // approve / reject / send / remove, through the same tools the app uses. (A letterbase's writing
4
+ // automations are `automations`.)
5
+ // Same flag/positional/io conventions as posts.mjs — no commander, no color.
6
+
7
+ import { CliError } from "../client.mjs";
8
+ import { printResult, ok, argsFromFlags, flagList, refuseUnknownFlags } from "./shared.mjs";
9
+
10
+ const TRIGGERS = ["competitor_page", "visitor_identified", "custom"];
11
+ const ACTIONS = ["write_post", "enroll_in_sequence", "build_page"];
12
+ const REVIEW = ["act", "ask"];
13
+ const STATUSES = ["pending", "proposed", "acted", "skipped", "failed", "rejected"];
14
+
15
+ const triggerParams = {
16
+ object: {
17
+ kinds: { flag: "kind", type: "list" },
18
+ competitors: { flag: "competitor", type: "list" },
19
+ hosts: { flag: "site", type: "list" },
20
+ hot_leads_only: { flag: "hot-leads-only", type: "bool" },
21
+ event: { flag: "event" },
22
+ },
23
+ };
24
+ const actionParams = {
25
+ object: {
26
+ collection_id: { flag: "collection" },
27
+ sequence_id: { flag: "sequence" },
28
+ host: { flag: "host" },
29
+ },
30
+ };
31
+ const enabled = { value: (flags) => (flags.off === true ? false : flags.on === true ? true : undefined) };
32
+
33
+ /** --fact plan=team --fact seats=40 → { plan: "team", seats: 40 } (numbers and true/false read as such). */
34
+ function factsOf(flags) {
35
+ const pairs = flagList(flags.fact);
36
+ if (!pairs.length) return undefined;
37
+ const facts = {};
38
+ for (const pair of pairs) {
39
+ const i = pair.indexOf("=");
40
+ if (i <= 0) throw new CliError(`--fact takes key=value, got: ${pair}`);
41
+ const raw = pair.slice(i + 1);
42
+ facts[pair.slice(0, i)] =
43
+ raw === "true"
44
+ ? true
45
+ : raw === "false"
46
+ ? false
47
+ : raw !== "" && !Number.isNaN(Number(raw))
48
+ ? Number(raw)
49
+ : raw;
50
+ }
51
+ return facts;
52
+ }
53
+
54
+ /** See `argsFromFlags` in shared.mjs; `scripts/parity-check.ts` diffs these keys against the tool. */
55
+ export const ARGS = {
56
+ describe_automation_options: {},
57
+ list_event_automations: {},
58
+ get_event_automation: {
59
+ automation_id: { positional: 0, label: "automation-id", required: true },
60
+ },
61
+ create_event_automation: {
62
+ name: { flag: "name", required: true },
63
+ trigger: { flag: "trigger", required: true, enum: TRIGGERS },
64
+ trigger_params: triggerParams,
65
+ instruction: { flag: "instruction" },
66
+ action: { flag: "action", required: true, enum: ACTIONS },
67
+ action_params: actionParams,
68
+ review: { flag: "review", enum: REVIEW },
69
+ enabled,
70
+ },
71
+ update_event_automation: {
72
+ automation_id: { positional: 0, label: "automation-id", required: true },
73
+ name: { flag: "name" },
74
+ trigger_params: triggerParams,
75
+ instruction: { flag: "instruction" },
76
+ action_params: actionParams,
77
+ review: { flag: "review", enum: REVIEW },
78
+ enabled,
79
+ },
80
+ delete_event_automation: {
81
+ automation_id: { positional: 0, label: "automation-id", required: true },
82
+ },
83
+ try_event_automation: {
84
+ automation_id: { positional: 0, label: "automation-id" },
85
+ trigger: { flag: "trigger", enum: TRIGGERS },
86
+ trigger_params: triggerParams,
87
+ instruction: { flag: "instruction" },
88
+ action: { flag: "action", enum: ACTIONS },
89
+ action_params: actionParams,
90
+ limit: { flag: "limit", type: "num" },
91
+ },
92
+ list_automation_runs: {
93
+ automation_id: { flag: "automation" },
94
+ status: { flag: "status", enum: STATUSES },
95
+ limit: { flag: "limit", type: "num" },
96
+ before: { flag: "before" },
97
+ },
98
+ decide_automation_run: {
99
+ run_id: { positional: 0, label: "run-id", required: true },
100
+ decision: { internal: "approve or reject, from the subcommand" },
101
+ reason: { flag: "reason" },
102
+ },
103
+ send_automation_event: {
104
+ event: { positional: 0, label: "event-name", required: true },
105
+ key: { flag: "key" },
106
+ title: { flag: "title", required: true },
107
+ url: { flag: "url" },
108
+ at: { flag: "at" },
109
+ facts: { value: factsOf },
110
+ person: {
111
+ object: {
112
+ email: { flag: "email" },
113
+ name: { flag: "person" },
114
+ company: { flag: "company" },
115
+ },
116
+ },
117
+ },
118
+ };
119
+
120
+ export async function cmdAutomate(ctx) {
121
+ const sub = ctx.positionals[0];
122
+ const rest = { ...ctx, positionals: ctx.positionals.slice(1) };
123
+ switch (sub) {
124
+ case "options":
125
+ return run(rest, "describe_automation_options");
126
+ case "list":
127
+ case "ls":
128
+ return run(rest, "list_event_automations");
129
+ case "show":
130
+ return run(rest, "get_event_automation");
131
+ case "add":
132
+ return run(rest, "create_event_automation", "Added.");
133
+ case "set":
134
+ refuseUnknownFlags(rest, ARGS.update_event_automation);
135
+ return run(rest, "update_event_automation", "Changed.");
136
+ case "try":
137
+ return run(rest, "try_event_automation");
138
+ case "runs":
139
+ return run(rest, "list_automation_runs");
140
+ case "approve":
141
+ return run(rest, "decide_automation_run", "Approved.", { decision: "approve" });
142
+ case "reject":
143
+ return run(rest, "decide_automation_run", "Rejected.", { decision: "reject" });
144
+ case "send":
145
+ return run(rest, "send_automation_event");
146
+ case "remove":
147
+ case "rm":
148
+ return run(rest, "delete_event_automation", "Removed.");
149
+ default:
150
+ throw new CliError(
151
+ `Unknown automate subcommand: ${sub ?? "(none)"}. Try: options, list, show, add, set, try, runs, approve, reject, send, remove`
152
+ );
153
+ }
154
+ }
155
+
156
+ async function run(ctx, tool, said, extra = {}) {
157
+ const { client, flags, io } = ctx;
158
+ const result = await client.callTool(tool, { ...argsFromFlags(ARGS[tool], flags, ctx.positionals), ...extra });
159
+ if (said) ok(ctx, said);
160
+ printResult(io, flags, result);
161
+ return 0;
162
+ }
@@ -133,6 +133,10 @@ export const ARGS = {
133
133
  cancel_collection_run: {
134
134
  run_id: { positional: 0, label: "run-id", required: true },
135
135
  },
136
+ reschedule_collection_run: {
137
+ run_id: { positional: 0, label: "run-id", required: true },
138
+ date: { flag: "date", required: true },
139
+ },
136
140
  get_collection_inventory: {
137
141
  collection_id: { positional: 0, label: "collection-id", required: true },
138
142
  },
@@ -176,6 +180,9 @@ export async function cmdCollection(ctx) {
176
180
  return collectionApprove(rest);
177
181
  case "cancel":
178
182
  return collectionCancel(rest);
183
+ case "move":
184
+ case "reschedule":
185
+ return collectionMove(rest);
179
186
  case "inventory":
180
187
  return collectionInventory(rest);
181
188
  case "overview":
@@ -184,7 +191,7 @@ export async function cmdCollection(ctx) {
184
191
  return collectionLinks(rest);
185
192
  default:
186
193
  throw new CliError(
187
- `Unknown collection subcommand: ${sub ?? "(none)"}. Try: list, overview, new, config, delete, run, add, queue, headline, run-status, runs, approve, cancel, inventory, links`
194
+ `Unknown collection subcommand: ${sub ?? "(none)"}. Try: list, overview, new, config, delete, run, add, queue, headline, run-status, runs, approve, move, cancel, inventory, links`
188
195
  );
189
196
  }
190
197
  }
@@ -382,6 +389,18 @@ async function collectionCancel(ctx) {
382
389
  return 0;
383
390
  }
384
391
 
392
+ // `collection move <run-id> --date YYYY-MM-DD` — a slot not yet written, or a written post
393
+ // already approved, onto another day (reschedule_collection_run).
394
+ async function collectionMove(ctx) {
395
+ const result = await ctx.client.callTool(
396
+ "reschedule_collection_run",
397
+ argsFromFlags(ARGS.reschedule_collection_run, ctx.flags, ctx.positionals)
398
+ );
399
+ ok(ctx, `Moved: goes live ${toolField(result, "scheduled_for") ?? "?"}.`);
400
+ printResult(ctx.io, ctx.flags, result);
401
+ return 0;
402
+ }
403
+
385
404
  // `collection inventory <id>` — where every piece is, and each finished draft's
386
405
  // publish-on-its-own time (the collection room's Work tab + "needs you" strip).
387
406
  function formatInventory(r) {
@@ -146,6 +146,9 @@ export const ARGS = {
146
146
  generator_id: { positional: 0, label: "enclosure-id", required: true },
147
147
  version: { flag: "version", type: "num", required: true },
148
148
  },
149
+ delete_generator: {
150
+ generator_id: { positional: 0, label: "enclosure-id", required: true },
151
+ },
149
152
  print_generator: {
150
153
  generator_id: { positional: 0, label: "enclosure-id", required: true },
151
154
  prospect_ids: { flag: "prospect", type: "list" },
@@ -191,6 +194,7 @@ const USAGE = `Usage: enclosures <list|show|create|update|prints>
191
194
  enclosures add-version <enclosure-id> (--script <code>|--script-file <path>) --step <text>… [--host <h>…] [--summary <s>]
192
195
  enclosures approve <enclosure-id> --version <n>
193
196
  enclosures print <enclosure-id> (--prospect <id>…|--list <list-id>) [--version <n>] [--redo] [--dry-run]
197
+ enclosures delete <enclosure-id> --yes Prints already made stay; refused while a sequence uses it
194
198
  enclosures apps list
195
199
  enclosures apps show <app-id>
196
200
  enclosures apps connect <sign-in-url> [--name <n>] [--no-remember] Prints a sign-in link a person opens
@@ -228,6 +232,8 @@ export async function cmdEnclosures(ctx) {
228
232
  return enclosuresApprove(rest);
229
233
  case "print":
230
234
  return enclosuresPrint(rest);
235
+ case "delete":
236
+ return enclosuresDelete(rest);
231
237
  default:
232
238
  throw new CliError(USAGE);
233
239
  }
@@ -454,3 +460,17 @@ async function enclosuresPrint(ctx) {
454
460
  });
455
461
  return 0;
456
462
  }
463
+
464
+ async function enclosuresDelete(ctx) {
465
+ const { client, flags, positionals, io } = ctx;
466
+ refuseUnknownFlags(ctx, ARGS.delete_generator, ["yes"]);
467
+ const id = requirePositional(positionals, 0, "enclosure-id");
468
+ if (!flags.yes) {
469
+ io.error(`Re-run with --yes to confirm: ${ctx.bin} enclosures delete ${id} --yes`);
470
+ return 1;
471
+ }
472
+ const result = await client.callTool("delete_generator", argsFromFlags(ARGS.delete_generator, flags, positionals));
473
+ ok(ctx, `Deleted ${result.deleted?.name}. Its prints and their pictures stay; its columns stay in Prospects.`);
474
+ printResult(io, flags, result, (r) => `deleted ${r.deleted.id}`);
475
+ return 0;
476
+ }
@@ -232,6 +232,12 @@ export function billingAccountText(r) {
232
232
  : "When they run out, new work needs a card (an admin adds one in Settings → Billing).",
233
233
  ]
234
234
  : []),
235
+ // No plan and not on free tokens (unassigned, or the plan ended): adding a card starts one (addCard).
236
+ ...(r.addCard && !f
237
+ ? [
238
+ `Adding a card starts ${r.addCard.planName}, at ${usd(r.addCard.monthlyUsd)} a month: an admin adds one in Settings → Billing.`,
239
+ ]
240
+ : []),
235
241
  ...(u
236
242
  ? [
237
243
  `This period (${u.periodFrom.slice(0, 10)} to ${u.periodTo.slice(0, 10)}): ${u.usedTokens} of ${u.allowanceTokens} tokens included${u.overageUsd > 0 ? `, ${usd(u.overageUsd)} of overage so far${u.overageChargedUsd ? ` (${usd(u.overageChargedUsd)} of it already charged to the card)` : ""}` : ""}${u.runningTokens ? `; ${u.runningTokens} more held by running work${u.runningOverageUsd > 0 ? ` (${usd(u.runningOverageUsd)} against the cap)` : ""}` : ""}.`,
@@ -302,7 +308,21 @@ function billingInvoicesText(r) {
302
308
 
303
309
  const tokensOrQty = (p) => `${p.billableQuantity}${p.tokens === null ? "" : ` ${p.tokens} tokens`}`;
304
310
 
305
- /** `org billing usage` as text: the period, the totals, then each product and each collection. */
311
+ /** Every plan at list prices (get_billing's `plans`), this account's marked, as Settings → Billing lists them. */
312
+ function plansText(r) {
313
+ if (!r.plans?.length) return [];
314
+ return [
315
+ "",
316
+ "Plans (pay only for what you use):",
317
+ ...r.plans.map((p) =>
318
+ p.contact
319
+ ? ` ${p.name} priced on a call: Book a call in Settings → Billing`
320
+ : ` ${p.name} ${usd(p.monthlyUsd)} a month, ${p.includedTokens} tokens included, then $${Number(p.overageUsdPerToken.toFixed(5))} a token${r.plan?.code === p.code ? " (your plan)" : ""}`
321
+ ),
322
+ ];
323
+ }
324
+
325
+ /** `org billing usage` as text: the period, the totals, each product and each collection, then the plans. */
306
326
  function billingUsageText(r) {
307
327
  const lines = [
308
328
  `${r.plan ? `Plan: ${r.plan.name}${r.plan.ratio !== 1 ? ` (${r.plan.ratio}x)` : ""}. ` : ""}This period: ${r.period.from.slice(0, 10)} to ${r.period.to.slice(0, 10)}${r.period.basis === "ours" ? " (Lago unreadable: our own rating)" : r.period.basis === "ours_split" ? " (split by product and collection by our own rating: Lago has the total, no breakdown yet)" : ""}.`,
@@ -316,14 +336,14 @@ function billingUsageText(r) {
316
336
  lines.push(
317
337
  `Plan fee ${usd(r.usd.planFee)}; overage so far ${usd(r.usd.overage)}. What was charged and the next invoice: letterstory org billing invoices.`
318
338
  );
319
- if (r.byProduct.length === 0) return [...lines, "No usage this period."].join("\n");
339
+ if (r.byProduct.length === 0) return [...lines, "No usage this period.", ...plansText(r)].join("\n");
320
340
  lines.push("", "By product:", ...r.byProduct.map((p) => ` ${p.label} ${tokensOrQty(p)}`));
321
341
  lines.push("", "By collection:");
322
342
  for (const c of r.byCollection) {
323
343
  lines.push(` ${c.name}${c.tokens === null ? "" : ` ${c.tokens} tokens`}`);
324
344
  for (const p of c.products) lines.push(` ${p.label} ${tokensOrQty(p)}`);
325
345
  }
326
- return lines.join("\n");
346
+ return [...lines, ...plansText(r)].join("\n");
327
347
  }
328
348
 
329
349
  /** `org fields [section]`: what each setting in the bundle means (describe_org_config_fields). */
@@ -5,7 +5,7 @@
5
5
  // repo list → list_repo_changes repo cancel → cancel_repo_change
6
6
  // repo publish → publish_repo_change (Make PR on a preview)
7
7
  // repo merge → merge_repo_change (merge its open PR, as a squash)
8
- // repo revise → revise_repo_change (ask for more on a preview, before the PR)
8
+ // repo revise → revise_repo_change (ask for more on a preview or an open PR; --copy-edits-file for exact copy)
9
9
  // repo say → send_repo_change_message (steer a build while its agent works)
10
10
  // repo repos → list_github_app_repos repo branches → list_repo_branches
11
11
  // repo connect → connect_github (the link a person opens to connect GitHub)
@@ -256,6 +256,7 @@ const ARGS = {
256
256
  revise_repo_change: {
257
257
  run_id: { positional: 0, required: true, label: "run-id" },
258
258
  instructions: { value: (flags) => readTextInput(flags, "instructions", "instructions-file") },
259
+ copy_edits: { value: (flags) => copyEdits(flags) },
259
260
  },
260
261
  list_repo_changes: {
261
262
  status: { flag: "status", enum: ["running", "succeeded", "no_changes", "failed", "cancelled", "sent"] },
@@ -737,11 +738,31 @@ async function repoSay(ctx) {
737
738
  return 0;
738
739
  }
739
740
 
740
- /** `repo revise <run-id> --instructions <text>`: a follow-up on a preview, built on top of it. */
741
+ /**
742
+ * `--copy-edits-file <path|->`: exact copy changes, a JSON array of { path, before, after, context? }
743
+ * (or { copy_edits: [...] }), what the preview panel sends when a reviewer types over the page.
744
+ */
745
+ function copyEdits(flags) {
746
+ const text = readTextInput(flags, "copy-edits", "copy-edits-file");
747
+ if (text === undefined) return undefined;
748
+ let parsed;
749
+ try {
750
+ parsed = JSON.parse(text);
751
+ } catch {
752
+ throw new CliError("--copy-edits-file is not valid JSON.");
753
+ }
754
+ const list = Array.isArray(parsed) ? parsed : parsed?.copy_edits;
755
+ if (!Array.isArray(list)) throw new CliError("--copy-edits-file is a JSON array of { path, before, after }.");
756
+ return list;
757
+ }
758
+
759
+ /** `repo revise <run-id> --instructions <text> [--copy-edits-file <path|->]`: a follow-up, built on top of the change. */
741
760
  async function repoRevise(ctx) {
742
761
  const { client, flags, io } = ctx;
743
762
  const args = argsFromFlags(ARGS.revise_repo_change, flags, ctx.positionals);
744
- if (!args.instructions) throw new CliError("Missing --instructions (or --instructions-file <path|->)");
763
+ if (!args.instructions && !args.copy_edits) {
764
+ throw new CliError("Missing --instructions (or --instructions-file <path|->), or --copy-edits-file <path|->");
765
+ }
745
766
  const result = await client.callTool("revise_repo_change", args);
746
767
  ok(ctx, result.message);
747
768
  printResult(io, flags, result.run, describe);
package/lib/commands.mjs CHANGED
@@ -12,6 +12,7 @@ export * from "./commands/mcp.mjs";
12
12
  export * from "./commands/posts.mjs";
13
13
  export * from "./commands/reviewers.mjs";
14
14
  export * from "./commands/automations.mjs";
15
+ export * from "./commands/automate.mjs";
15
16
  export * from "./commands/collections.mjs";
16
17
  export * from "./commands/authors.mjs";
17
18
  export * from "./commands/flows.mjs";
package/lib/documents.mjs CHANGED
@@ -89,6 +89,8 @@ export const JSON_ARG_FLAG_PAIRS = [
89
89
  ["token", "token-file"],
90
90
  // An enclosure version's script (enclosures.mjs add-version): code, read verbatim.
91
91
  ["script", "script-file"],
92
+ // Exact copy changes for a follow-up, parsed as JSON (repo.mjs `repo revise`).
93
+ ["copy-edits", "copy-edits-file"],
92
94
  ];
93
95
 
94
96
  /** Lower-case extension without the dot. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.174.3",
3
+ "version": "0.174.5",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",