@letterstory/cli 0.174.4 → 0.175.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/lib/cli.mjs CHANGED
@@ -76,7 +76,7 @@ import {
76
76
  } from "./commands.mjs";
77
77
 
78
78
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
79
- export const VERSION = "0.174.4";
79
+ export const VERSION = "0.175.0";
80
80
 
81
81
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
82
82
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -4549,7 +4549,7 @@ async function cmdAdminSpend(ctx) {
4549
4549
  const result = await staffRequest(ctx, "GET", `${SPEND}/usage-margin${params.size ? `?${params}` : ""}`);
4550
4550
  printResult(io, flags, result, (m) =>
4551
4551
  [
4552
- `${m.range.from} → ${m.range.to}: ${m.totals.billableEvents} billable of ${m.totals.events} events · ${m.totals.tokens ?? "?"} tokens (${m.rateCard?.version ?? "no card"}) · cost ${usd(m.totals.cost?.totalUsd)} · margin ${m.totals.marginUsd === null ? "?" : usd(m.totals.marginUsd)}`,
4552
+ `${m.range.from} → ${m.range.to}: ${m.totals.billableEvents} billable of ${m.totals.events} events · ${m.totals.tokens ?? "?"} tokens (${m.rateCards?.length > 1 ? `${m.rateCards.map((c) => c.version).join(" + ")}, each day on its own card` : (m.rateCard?.version ?? "no card")}) · cost ${usd(m.totals.cost?.totalUsd)} · margin ${m.totals.marginUsd === null ? "?" : usd(m.totals.marginUsd)}`,
4553
4553
  "",
4554
4554
  ...m.rows.map(
4555
4555
  (r) =>
@@ -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
  }
@@ -37,6 +37,8 @@ const ARGS = {
37
37
  build_id: "build",
38
38
  domain: "site",
39
39
  subjects: { flag: "subject", type: "list" },
40
+ // --recipe <id>: the recipe the words carry out (a Plan row's), recorded on the build it starts.
41
+ recipe: "recipe",
40
42
  files: { value: (_flags, _positionals, extra) => (extra.files?.length ? extra.files : undefined) },
41
43
  harness: { flag: "harness", enum: ["claude-code", "letterpress-1"] },
42
44
  // --repo owner/name: the repo you're working in, where a Proofs install goes.
@@ -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)` : ""}` : ""}.`,
@@ -268,7 +274,7 @@ function tokenRewardsText(r) {
268
274
  return [
269
275
  `Free tokens for actions: ${r.claimedTokens} earned, ${r.availableTokens} still to earn.`,
270
276
  ...lines,
271
- "GitHub, GitLab, Slack and the CLI are granted on their own once done.",
277
+ "Slack, the CLI, GitHub, GitLab and Search Console are granted on their own once done.",
272
278
  "Claim the rest: letterstory org billing rewards claim <action>",
273
279
  ].join("\n");
274
280
  }
@@ -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). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.174.4",
3
+ "version": "0.175.0",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",