@letterstory/cli 0.177.92 → 0.177.94

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.92";
93
+ export const VERSION = "0.177.94";
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;
@@ -191,6 +191,8 @@ export const BOOLEAN_FLAGS = new Set([
191
191
  "primitives-access",
192
192
  // build, repo revise: the sandbox also writes in Letter (posts into the blog collection, its publish target).
193
193
  "letter-writes",
194
+ // repo revise: fix what the review left open (Letter reads the open issues itself).
195
+ "review-issues",
194
196
  // build list: only Build's Archived tab (--open, already listed, is its Open tab).
195
197
  "archived",
196
198
  // plan pending --queued: only the rows a person queued for later.
@@ -492,6 +494,8 @@ export const BOOLEAN_FLAGS = new Set([
492
494
  "writes-posts",
493
495
  "no-writes-posts",
494
496
  "dry-run",
497
+ // usage database connect --existing: reuse the saved database connection.
498
+ "existing",
495
499
  // usage case-study generate --named: name the companies (counts only without it).
496
500
  "named",
497
501
  ]);
@@ -1181,6 +1185,12 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
1181
1185
  The Ideas invariants over production, read only: rows a
1182
1186
  start would refuse, builds whose reading disagrees with
1183
1187
  what they hold, grouped with ids. Exits 1 on any.
1188
+ admin lost-posts [--code lost_guard,lost_provider] [--days 7] [--org <id>] [--limit 200] [--apply]
1189
+ Letterbase posts lost on our side (a publish guard dropped
1190
+ the finished post, a provider outage failed the slot) and
1191
+ never published. Lists what it would requeue; --apply puts
1192
+ them back to work. --code held_guard takes a held post
1193
+ once its draft was edited. Staff.
1184
1194
  admin targets check [--org <id>,…] [--recheck] [--limit 10]
1185
1195
  Check ranking targets' phrases (buyer intent, self-named,
1186
1196
  search demand, fit) and store each verdict: --org those
@@ -1956,8 +1966,9 @@ The Site (one model of your whole marketing site, keyed by host and path):
1956
1966
  [--observation <id>]... Propose a registry tool call; input is validated now
1957
1967
  site decide <proposal-id> --decision accept|dismiss [--reason <why>]
1958
1968
  site fix <host> <observation-id>... [--action build|build_pr|build_merge|slack|linear|handoff] [--with-preview]
1959
- [--harness letterpress-1|claude-code|codex]
1960
- One change for N observations; handoff prints the prompt, slack/linear need no repo
1969
+ [--harness letterpress-1|claude-code|codex] [--again]
1970
+ One change for N observations; handoff prints the prompt, slack/linear need no repo;
1971
+ --again asks for findings Letter holds back, on purpose
1961
1972
  site competitors [--since <iso> | --days <n>] [--limit <n>] Tracked competitors' sites: new and removed pages, by folder
1962
1973
  site watch-competitors [domain] [--limit <n>] Map competitors' sitemaps (the next few unmapped, or one now)
1963
1974
  site highlight <domain> [--off] Highlight a competitor; its changes lead the top changes
@@ -2036,11 +2047,12 @@ Repo changes (Claude Code edits your repo in a sandbox; the Letter GitHub App op
2036
2047
  [--detail full] one row per run by default; full: every field
2037
2048
  repo publish <run-id> Make PR on a preview in review
2038
2049
  repo merge <run-id> Merge its open PR (a squash; the repo's branch rules decide)
2039
- repo revise <run-id> --instructions <text>|--instructions-file <path|-> [--copy-edits-file <path|->] [--letter-writes]
2050
+ repo revise <run-id> --instructions <text>|--instructions-file <path|->|--review-issues [--copy-edits-file <path|->] [--letter-writes]
2040
2051
  [--attach <path>]… [--attach-ref <path>]… [--attach-url name=url]… [--attach-url-ref name=url]…
2041
2052
  Ask for more on a preview (it takes over the preview's link) or an
2042
2053
  open PR (one more commit); copy edits: JSON [{ path, before, after }];
2043
2054
  files as repo start takes them (--attach-ref: read, never committed)
2055
+ --review-issues: fix what the review left open, read from the review
2044
2056
  repo address-reviews <run-id> Answer the review comments on its open PR, once: fix, reply, resolve
2045
2057
  repo cancel <run-id> [--force] Stop it and delete the sandbox; no PR (Discard a preview)
2046
2058
 
@@ -24,6 +24,7 @@
24
24
  // admin letterpress endings [--days N] [--write-cases] (how turns and repo changes ended when not done, by owner)
25
25
  // admin letterpress settings|flip|set … (recipes:read / recipes:write)
26
26
  // admin invariants [--org <id>,…] [--limit N] [--presses] (staff)
27
+ // admin lost-posts [--code lost_guard,lost_provider|held_guard] [--days N] [--org <id>] [--limit N] [--apply] (staff)
27
28
  // admin demo guide|list|show|set|reset|check|ideas … (demo:read / demo:write)
28
29
  // admin deployments [--health down|failing|blocked|setting_up|live|paused|archived] [--org <id>] [--q <text>] [--archived] [--test] [--no-host] (fleet:read)
29
30
  // admin models runs|run|star|unstar|scoreboard|requests|request|sampling … (models:read / models:write)
@@ -68,6 +69,14 @@ import {
68
69
 
69
70
  // `admin invariants`: the one tool it calls, its flags declared (scripts/parity-check.ts reads this map).
70
71
  export const ARGS = {
72
+ // `admin lost-posts`: a dry run unless --apply.
73
+ requeue_lost_posts: {
74
+ dry_run: { value: (flags) => !flagBool(flags.apply) },
75
+ codes: { value: (flags) => (flags.code ? flagCsv(flags.code) : undefined) },
76
+ days: { flag: "days", type: "num" },
77
+ org_id: { flag: "org" },
78
+ limit: { flag: "limit", type: "num" },
79
+ },
71
80
  check_ideas_invariants: {
72
81
  org_ids: { value: (flags) => (flags.org ? flagCsv(flags.org) : undefined) },
73
82
  limit: { flag: "limit", type: "num" },
@@ -99,6 +108,32 @@ async function cmdAdminInvariants(ctx) {
99
108
  );
100
109
  return result.total > 0 ? 1 : 0;
101
110
  }
111
+
112
+ // `admin lost-posts` — the replay for letterbase slots lost on Letter's side (lib/planner/lost-posts.ts): a finished
113
+ // post a publish guard dropped or holds, a slot a provider outage failed. Lists what it would requeue; --apply
114
+ // requeues them. requeue_lost_posts.
115
+ async function cmdAdminLostPosts(ctx) {
116
+ const { client, flags, io } = ctx;
117
+ const result = await client.callTool("requeue_lost_posts", argsFromFlags(ARGS.requeue_lost_posts, flags));
118
+ printResult(io, flags, result, (r) =>
119
+ [
120
+ r.dry_run
121
+ ? `${r.found} lost post(s) in the last ${r.days} day(s) would be requeued (dry run; --apply requeues them).`
122
+ : `${r.requeued} of ${r.found} lost post(s) requeued.`,
123
+ Object.entries(r.by_code)
124
+ .map(([code, n]) => `${code} ${n}`)
125
+ .join(" "),
126
+ ...r.posts.map(
127
+ (p) =>
128
+ ` ${p.code} ${p.lost_at.slice(0, 16)} ${p.org_id} ${p.run_id} -> ${p.resumes_at} ${p.headline ?? "(untitled)"}${p.error ? `\n not requeued: ${p.error}` : ""}`
129
+ ),
130
+ ...(r.more ? ["More than --limit: run again for the rest."] : []),
131
+ ]
132
+ .filter(Boolean)
133
+ .join("\n")
134
+ );
135
+ return 0;
136
+ }
102
137
  import { watchDomainJob } from "./onboard.mjs";
103
138
 
104
139
  const SEER_MODES = ["suggest", "skip"];
@@ -5326,7 +5361,7 @@ const BUILD_FAILURES = "/api/superadmin/build-failures";
5326
5361
  const SUGGESTION_REVIEW = "/api/superadmin/suggestion-review";
5327
5362
  const TURN_ENDINGS = "/api/superadmin/turn-endings";
5328
5363
  const ENGINE_USAGE =
5329
- "Usage: admin letterpress status | gaps | friction [--kind error|exception|rage|step|server|stall|background] [--surface s] [--org id] [--limit N] [--customers] | issues [--days N] [--state came_back|open|fixing|resolved] [--source ask|friction] [--surface s] [--whose ours|agent|setup] [--limit N] | issues fix|unfix <key> [--pr url] [--note …] | tools [--days N] [--org id] [--customers] | checks | frustration [--days N] | health | asks [--days N] [--surface cmd_l|build_chat|slack|terminal|app|signup|letter] [--people | --letter] [--door d] [--whose ours|agent|setup|member] [--pattern <code or key>] [--org id] [--limit N] [--customers] | telemetry [--days N] [--harness h] [--customers] | tokens [--days N] [--so-far] [--all-orgs] | prs [--days N | --from YYYY-MM-DD [--to YYYY-MM-DD] | --all-time] [--day YYYY-MM-DD] [--org id] [--state merged|open|closed] [--people | --letter] [--top N] [--tz zone] [--all-orgs] | failures [--days N | --from YYYY-MM-DD [--to YYYY-MM-DD] | --all-time] [--day YYYY-MM-DD] [--org id] [--failure ours|agent|setup|undelivered] [--cause c] [--stopped-at step] [--repo owner/name] [--slow] [--tz zone] [--customers] | blocked [--days N] [--org id] [--customers] | endings [--days N | --since ISO] [--org id,id] [--no-model] [--top N] [--write-cases [--dir evals/letterpress]] | unblock <org-id> <host> <subject> | decisions <org-id> [--site host] [--surface plan|fix|build|site] | undo <org-id> <host> <decision-id> | runs [--status s] [--error-code c] [--first-review-cause agent|context|setup|unknown] [--pr merged|closed|open|none] [--harness h] [--days N] [--customers] | beyond [--limit N] [--before ISO] | companies | company <org-id> [--site host] | ideas <org-id> [--site host] [--repo connected|none] | suggestions fix|idea [--day YYYY-MM-DD] [--type key [--org id]] [--customers] | suggestions flag fix|idea <type-key> [--org id --item item-id] [--note …] | suggestions clear <flag-id> | 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>";
5364
+ "Usage: admin letterpress status | gaps | friction [--kind error|exception|rage|step|rule|server|stall|background] [--surface s] [--org id] [--limit N] [--customers] | issues [--days N] [--state came_back|open|fixing|resolved] [--source ask|friction] [--surface s] [--whose ours|agent|setup] [--limit N] | issues fix|unfix <key> [--pr url] [--note …] | tools [--days N] [--org id] [--customers] | checks | frustration [--days N] | health | asks [--days N] [--surface cmd_l|build_chat|slack|terminal|app|signup|letter] [--people | --letter] [--door d] [--family premise|landing|preview|outcome|run|infra|writing|waiting|other] [--whose ours|agent|setup|member] [--pattern <code or key>] [--org id] [--limit N] [--customers] | telemetry [--days N] [--harness h] [--customers] | tokens [--days N] [--so-far] [--all-orgs] | prs [--days N | --from YYYY-MM-DD [--to YYYY-MM-DD] | --all-time] [--day YYYY-MM-DD] [--org id] [--state merged|open|closed] [--people | --letter] [--top N] [--tz zone] [--all-orgs] | failures [--days N | --from YYYY-MM-DD [--to YYYY-MM-DD] | --all-time] [--day YYYY-MM-DD] [--org id] [--failure ours|agent|setup|undelivered] [--cause c] [--stopped-at step] [--repo owner/name] [--slow] [--tz zone] [--customers] | blocked [--days N] [--org id] [--customers] | endings [--days N | --since ISO] [--org id,id] [--no-model] [--top N] [--write-cases [--dir evals/letterpress]] | unblock <org-id> <host> <subject> | decisions <org-id> [--site host] [--surface plan|fix|build|site] | undo <org-id> <host> <decision-id> | runs [--status s] [--error-code c] [--first-review-cause agent|context|setup|unknown] [--pr merged|closed|open|none] [--harness h] [--days N] [--customers] | beyond [--limit N] [--before ISO] | companies | company <org-id> [--site host] | ideas <org-id> [--site host] [--repo connected|none] | suggestions fix|idea [--day YYYY-MM-DD] [--type key [--org id]] [--customers] | suggestions flag fix|idea <type-key> [--org id --item item-id] [--note …] | suggestions clear <flag-id> | 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>";
5330
5365
 
5331
5366
  /** One number of the settings from a dotted path and a value: the PUT body save_engine_settings reads. */
5332
5367
  function engineSettingsPatch(path, value) {
@@ -5605,6 +5640,7 @@ async function cmdAdminLetterpress(ctx) {
5605
5640
  if (flags.door) q.set("door", String(flags.door));
5606
5641
  if (flags.surface) q.set("surface", String(flags.surface));
5607
5642
  if (flags.whose) q.set("whose", String(flags.whose));
5643
+ if (flags.family) q.set("family", String(flags.family));
5608
5644
  if (flags.pattern) q.set("pattern", String(flags.pattern));
5609
5645
  if (flags.org) q.set("org_id", String(flags.org));
5610
5646
  if (flagBool(flags.customers)) q.set("customers", "1");
@@ -5622,15 +5658,35 @@ async function cmdAdminLetterpress(ctx) {
5622
5658
  ? `Whose: ours ${a.summary.whose.ours} the agent's ${a.summary.whose.agent} their setup ${a.summary.whose.setup} their call ${a.summary.whose.member}`
5623
5659
  : "",
5624
5660
  "",
5661
+ // By family (read from the reason code): how wide, and how many are the same organization again.
5662
+ ...(a.summary.families ?? []).map(
5663
+ (x) =>
5664
+ `${String(x.count).padStart(5)} ${x.asked_by.padEnd(6)} ${x.family.padEnd(8)} in ${x.orgs ?? 0} orgs, ${x.repeats ?? 0} again`
5665
+ ),
5666
+ "",
5625
5667
  ...a.summary.doors.map(line),
5626
5668
  "",
5627
5669
  ...a.summary.reasons
5628
5670
  .slice(0, 12)
5629
5671
  .map((x) => `${String(x.count).padStart(5)} ${x.asked_by.padEnd(6)} ${x.reason}`),
5630
5672
  "",
5673
+ // The ways it failed over and over: a model-written reason is one pattern, with what its cases were about.
5674
+ ...(a.patterns ?? [])
5675
+ .slice(0, 12)
5676
+ .map(
5677
+ (p) =>
5678
+ `${String(p.count).padStart(5)} ${p.family.padEnd(8)} ${p.whose.padEnd(6)} ${p.reason} in ${p.orgs} orgs${p.recurring ? ", recurring" : ""}${p.subjects?.length ? ` (${p.subjects.slice(0, 3).join("; ")})` : ""}`
5679
+ ),
5680
+ "",
5681
+ // Each fix that named what it moves, with that count the 7 days before it shipped and after.
5682
+ ...(a.moves ?? []).map(
5683
+ (m) =>
5684
+ `${m.date} ${m.moves.join(", ")}: ${m.before ?? "—"} before, ${m.after ?? "—"} after${m.after_days < 7 ? ` (${m.after_days}d)` : ""} ${m.pr ?? ""} ${m.what}`
5685
+ ),
5686
+ "",
5631
5687
  ...a.failures.map(
5632
5688
  (f) =>
5633
- `${f.at.slice(0, 16)} ${(f.org ?? f.org_id).slice(0, 20).padEnd(20)} ${f.door.padEnd(22)} ${f.outcome.padEnd(13)} ${(f.whose ?? "").padEnd(6)} ${f.reason ?? ""}: ${f.why ?? ""}${f.pr_url ? ` ${f.pr_url}` : ""}`
5689
+ `${f.at.slice(0, 16)} ${(f.org ?? f.org_id).slice(0, 20).padEnd(20)} ${f.door.padEnd(22)} ${f.outcome.padEnd(13)} ${(f.family ?? "").padEnd(8)} ${(f.whose ?? "").padEnd(6)} ${f.reason ?? ""}: ${f.why ?? ""}${f.pr_url ? ` ${f.pr_url}` : ""}`
5634
5690
  ),
5635
5691
  ].join("\n")
5636
5692
  );
@@ -7667,10 +7723,11 @@ export async function cmdAdmin(ctx) {
7667
7723
  if (sub === "demo") return cmdAdminDemo({ ...ctx, positionals: ctx.positionals.slice(1) });
7668
7724
  if (sub === "targets") return cmdAdminTargets({ ...ctx, positionals: ctx.positionals.slice(1) });
7669
7725
  if (sub === "invariants") return cmdAdminInvariants({ ...ctx, positionals: ctx.positionals.slice(1) });
7726
+ if (sub === "lost-posts") return cmdAdminLostPosts({ ...ctx, positionals: ctx.positionals.slice(1) });
7670
7727
  if (sub === "deployments" || sub === "deploys")
7671
7728
  return cmdAdminDeployments({ ...ctx, positionals: ctx.positionals.slice(1) });
7672
7729
  throw new CliError(
7673
- 'Usage: admin recipes … | admin letterpress … | admin demo … | admin targets … | admin invariants … | admin deployments … | admin republish … | admin create-org --domain <bare-domain> [--onboard] … | admin ask "<question>" | admin patterns … | admin experiments … | admin fleet-experiments … | admin crm … | admin spend … | admin evals … | admin brand-detection … | admin tuning … | admin tuning-context | admin replays … (see --help)'
7730
+ 'Usage: admin recipes … | admin letterpress … | admin demo … | admin targets … | admin invariants … | admin lost-posts … | admin deployments … | admin republish … | admin create-org --domain <bare-domain> [--onboard] … | admin ask "<question>" | admin patterns … | admin experiments … | admin fleet-experiments … | admin crm … | admin spend … | admin evals … | admin brand-detection … | admin tuning … | admin tuning-context | admin replays … (see --help)'
7674
7731
  );
7675
7732
  }
7676
7733
 
@@ -86,6 +86,8 @@ const ARGS = {
86
86
  recipe: "recipe",
87
87
  // Preserve the account-specific task selected by the Plan.
88
88
  fit_run: "fit-run",
89
+ // --fit <id>: what the Ideas row showed (its action.args.fit): the start goes ahead while the idea is still that.
90
+ fit: "fit",
89
91
  // --instance <n>: which of a repeating recipe's rows (recipe:<id>~<n>), from 2; omitted: the recipe's own.
90
92
  instance: { flag: "instance", type: "num" },
91
93
  // --plan-action <id>: a Plan row's account action started as an Idea (blog:post, outbound:campaign, …).
@@ -150,6 +152,7 @@ const ARGS = {
150
152
  recipe: "recipe",
151
153
  // Preserve the account-specific task selected by the Plan.
152
154
  fit_run: "fit-run",
155
+ fit: "fit",
153
156
  files: { value: (_flags, _positionals, extra) => (extra.files?.length ? extra.files : undefined) },
154
157
  harness: { flag: "harness", enum: ["letterpress-1", "claude-code", "codex"] },
155
158
  // --repo owner/name: the repo you're working in, where a Proofs install goes.
@@ -283,6 +286,7 @@ async function buildStart(ctx) {
283
286
  "subject",
284
287
  "recipe",
285
288
  "fit-run",
289
+ "fit",
286
290
  "instance",
287
291
  "plan-action",
288
292
  "accepted-quote",
@@ -322,6 +326,7 @@ async function buildTalk(ctx) {
322
326
  "message",
323
327
  "recipe",
324
328
  "fit-run",
329
+ "fit",
325
330
  "conversation",
326
331
  "build",
327
332
  "site",
@@ -297,6 +297,8 @@ const ARGS = {
297
297
  copy_edits: { value: (flags) => copyEdits(flags) },
298
298
  // --letter-writes: the follow-up also writes in Letter (a review issue the last run had no access for).
299
299
  letter_writes: { flag: "letter-writes", type: "bool" },
300
+ // --review-issues: fix what the review left open; Letter reads the open issues itself.
301
+ review_issues: { flag: "review-issues", type: "bool" },
300
302
  files: { value: (_flags, _positionals, extra) => (extra.files?.length ? extra.files : undefined) },
301
303
  },
302
304
  address_pr_review: { run_id: { positional: 0, required: true, label: "run-id" } },
@@ -850,14 +852,16 @@ function copyEdits(flags) {
850
852
  }
851
853
 
852
854
  /**
853
- * `repo revise <run-id> --instructions <text> [--copy-edits-file <path|->] [--attach-ref <path>]…`: a follow-up,
855
+ * `repo revise <run-id> --instructions <text>|--review-issues [--copy-edits-file <path|->] [--attach-ref <path>]…`: a follow-up,
854
856
  * built on top of the change, with any files it needs (a screenshot to read, an image to place) as `repo start` takes them.
855
857
  */
856
858
  async function repoRevise(ctx) {
857
859
  const { client, flags, io } = ctx;
858
860
  const args = argsFromFlags(ARGS.revise_repo_change, flags, ctx.positionals, { files: await attachedFiles(ctx) });
859
- if (!args.instructions && !args.copy_edits) {
860
- throw new CliError("Missing --instructions (or --instructions-file <path|->), or --copy-edits-file <path|->");
861
+ if (!args.instructions && !args.copy_edits && !args.review_issues) {
862
+ throw new CliError(
863
+ "Missing --instructions (or --instructions-file <path|->), --copy-edits-file <path|->, or --review-issues"
864
+ );
861
865
  }
862
866
  const result = await client.callTool("revise_repo_change", args);
863
867
  ok(ctx, result.message);
@@ -228,6 +228,8 @@ const ARGS = {
228
228
  with_preview: { flag: "with-preview", type: "bool" },
229
229
  // --harness letterpress-1|claude-code|codex: the coding agent (codex is GPT); omitted, the organization's default.
230
230
  harness: { flag: "harness", enum: ["letterpress-1", "claude-code", "codex"] },
231
+ // --again: ask for held findings again on purpose (clears what the last change found on them, and starts).
232
+ again: { flag: "again", type: "bool" },
231
233
  },
232
234
  };
233
235
 
@@ -52,6 +52,7 @@ export const ARGS = {
52
52
  host: { flag: "host" },
53
53
  access_token: { flag: "key" },
54
54
  use_oauth: { flag: "oauth", type: "bool" },
55
+ use_existing: { flag: "existing", type: "bool" },
55
56
  streams: {
56
57
  value: (flags) => (flags.streams ? JSON.parse(readFileSync(String(flags.streams), "utf8")) : undefined),
57
58
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.177.92",
3
+ "version": "0.177.94",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",