@letterstory/cli 0.175.21 → 0.175.23

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
@@ -77,9 +77,10 @@ import {
77
77
  cmdVary,
78
78
  cmdBench,
79
79
  } from "./commands.mjs";
80
+ import { fetchParkedSections, withoutParked } from "./parked.mjs";
80
81
 
81
82
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
82
- export const VERSION = "0.175.21";
83
+ export const VERSION = "0.175.23";
83
84
 
84
85
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
85
86
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -245,6 +246,8 @@ export const BOOLEAN_FLAGS = new Set([
245
246
  // `phantom-onboard collection --enable-planner`, `strategy sitemap --posts-only`, and the
246
247
  // `strategy positioning set --clear-*` switches: value-less, and each sits next to a value.
247
248
  "enable-planner",
249
+ // `phantom-onboard collection --start-writing`: value-less, like --enable-planner.
250
+ "start-writing",
248
251
  // `phantom-onboard primitives --retry [<domain>]` re-reads a domain whose read failed.
249
252
  "retry",
250
253
  "posts-only",
@@ -886,7 +889,7 @@ What does this org still need? (the router — reads only, decides nothing):
886
889
  Collection onboarding (your OWN blog, on your org's domain — no provisioning):
887
890
  ${bin === "phantom" ? "onboard" : "phantom-onboard"} collection [--collection <uuid>] [--name "<collection name>"]
888
891
  [--about "the direction"] [--sitemap <url>] [--cms <provider>]
889
- [--enable-planner [--cadence <n/week>] [--approval manual|review_window|autopilot]] [--watch]
892
+ [--start-writing | --enable-planner [--cadence <n/week>] [--approval manual|review_window|autopilot]] [--watch]
890
893
  Import the existing blog from its sitemap
891
894
  (auto-discovered from the org's domain unless
892
895
  --sitemap pins one) OR from a connected CMS with
@@ -900,6 +903,9 @@ Collection onboarding (your OWN blog, on your org's domain — no provisioning):
900
903
  (same activation as the app's Guided review step;
901
904
  needs a user-scoped key). --approval defaults to
902
905
  manual: nothing publishes unreviewed.
906
+ --start-writing instead starts what the blog
907
+ writes once it is read in: the starter
908
+ automations, every draft for review.
903
909
  ${bin === "phantom" ? "onboard" : "phantom-onboard"} sync-sitemap --collection <uuid>
904
910
  Re-check an already-onboarded blog's sitemap
905
911
  right now instead of waiting for its cadence
@@ -962,9 +968,17 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
962
968
  nothing. Exits 1 if any row failed.
963
969
  admin recipes save [<id>] [--file <recipe.json>] [--name …] [--description …] [--recipe …]
964
970
  [--when-to-use …] [--when-not-to-use …] [--weight 1..10] [--approaches seo,geo]
971
+ [--reads llms_txt,github]
965
972
  Create one (no id) or change one; variations come from
966
- --file. Needs recipes:write.
973
+ --file. --reads names the facts its conditions rest on
974
+ (vocab lists them). Needs recipes:write.
967
975
  admin recipes delete <id> --yes Delete for good.
976
+ admin recipes refit [--org <id>,…] [--recipe <id|name>] [--limit 10]
977
+ Decide accounts' recipes again now, not on the hourly
978
+ sweep's turn: --org those accounts (every recipe);
979
+ --recipe every account whose verdict on it is missing
980
+ or stale; neither, every account stale for the library.
981
+ Each is a model call. Needs recipes:write.
968
982
  admin letterpress status [--customers] Letterpress as it runs now: per lens its mode, bar, recipes,
969
983
  runs, model and prompt hash, how often the shadow agreed,
970
984
  how runs grounded (a recipe / none). Needs recipes:read.
@@ -1281,6 +1295,8 @@ Seers (event-driven signals -> drafts):
1281
1295
  seers export [--file <path>] Dump the org's seers as a manifest
1282
1296
  seers apply --file <path> [--dry-run] Idempotent, name-keyed upsert from a manifest
1283
1297
  (never deletes; --dry-run prints the plan)
1298
+
1299
+ Org (the account as one file, its integrations and billing):
1284
1300
  org export [--sections <s>…] [--file <path>] The org's whole config as one JSON bundle
1285
1301
  org export --split <dir> …as one file per record (for keeping config in git)
1286
1302
  org join <dir> [--file <path>] Rebuild the bundle from a --split directory
@@ -1898,7 +1914,9 @@ export async function run(argv, io = defaultIo()) {
1898
1914
  if (!command || command === "help" || flags.help) {
1899
1915
  // `<command> … --help` shows that command's own lines, not the whole manual's first screen
1900
1916
  // (billing agent pass AGENT-5: `org billing request --help` printed Auth and Collections).
1901
- const help = buildHelp(bin);
1917
+ // Which sections are parked is the server's to say (a real run only; a test never reaches out).
1918
+ const parked = io.updateCheck ? await fetchParkedSections(resolveConfig({ url: str(flags.url) }).url) : null;
1919
+ const help = withoutParked(buildHelp(bin), parked ?? undefined);
1902
1920
  const own = command && command !== "help" ? helpFor(help, positionals) : null;
1903
1921
  io.log(own ? `${own}\n\nRun \`${bin} help\` for every command.` : help);
1904
1922
  return 0;
@@ -18,7 +18,7 @@
18
18
  // admin spend summary|reconcile|pnl|margin|pricing|entries|add|import|usage|remove|reference|stripe-sync|services|service … (spend:read / spend:write)
19
19
  // admin brand-detection <org-id> (fleet:read)
20
20
  // admin brand-detection <org-id> [--term t]... [--exact t]... [--exclude p]... [--note "…"] | --clear [--note "…"] (fleet:instrument)
21
- // admin recipes list|show|runs|vocab|export|import|save|delete … (recipes:read / recipes:write)
21
+ // admin recipes list|show|runs|vocab|export|import|save|delete|refit … (recipes:read / recipes:write)
22
22
  // admin letterpress companies | company <org-id> | facts <org-id> (the standing fit, per company)
23
23
  // admin letterpress beyond [--limit N] [--before ISO] (what members asked that went past the library)
24
24
  // admin letterpress settings|flip|set … (recipes:read / recipes:write)
@@ -5031,13 +5031,16 @@ const RECIPE_FILE_FIELDS = [
5031
5031
  "when_not_to_use",
5032
5032
  "weight",
5033
5033
  "approaches",
5034
+ "reads",
5034
5035
  "runs",
5036
+ "primitives_access",
5037
+ "immediate",
5035
5038
  "status",
5036
5039
  "needs",
5037
5040
  "variations",
5038
5041
  ];
5039
5042
  const RECIPES_USAGE =
5040
- "Usage: admin recipes list [--kind recipe|known_issue] [--status live|parked] [--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>] [--status live|parked] [--needs <what a parked recipe is missing>] | delete <id> --yes";
5043
+ "Usage: admin recipes list [--kind recipe|known_issue] [--status live|parked] [--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] | refit [--org <id>,…] [--recipe <id|name>] [--limit n] | 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,…] [--reads llms_txt,github,…] [--runs <catalog action id>] [--primitives-access true|false] [--immediate true|false] [--status live|parked] [--needs <what a parked recipe is missing>] | delete <id> --yes";
5041
5044
 
5042
5045
  const recipeForFile = (r) => Object.fromEntries(RECIPE_FILE_FIELDS.map((k) => [k, r[k]]));
5043
5046
 
@@ -5069,8 +5072,11 @@ function recipeDetail(r) {
5069
5072
  `${r.name} weight ${r.weight}/10 ${r.id}`,
5070
5073
  ` kind: ${r.kind === "known_issue" ? "known issue (Fix's list)" : "recipe (the Plan's)"}`,
5071
5074
  ` approaches: ${recipeApproaches(r)}`,
5075
+ ` reads: ${r.reads?.length ? r.reads.join(", ") : "— (not written: every probe runs)"}`,
5072
5076
  ` status: ${r.status === "parked" ? `parked${r.needs ? `, needs ${r.needs}` : ""}` : "live"}`,
5073
5077
  ` runs: ${r.runs || "one change to the site's code, from its own directions"}`,
5078
+ ...(r.primitives_access ? [" letter's tools: its build may use them (primitives_access)"] : []),
5079
+ ...(r.immediate ? [" immediate: a quick win: the Plan puts one in every top three"] : []),
5074
5080
  ...(variations.length > 1
5075
5081
  ? variations.flatMap((v, i) => [` variation ${i + 1}: ${v.name}`, ...fields(v, " ")])
5076
5082
  : fields(r, " ")),
@@ -5120,6 +5126,16 @@ function recipeFromFlags(flags) {
5120
5126
  ?.split(",")
5121
5127
  .map((a) => a.trim())
5122
5128
  .filter(Boolean),
5129
+ // --primitives-access true hands a start's build Letter's own tools; false takes them away.
5130
+ primitives_access:
5131
+ flags["primitives-access"] === undefined ? undefined : String(flags["primitives-access"]) === "true",
5132
+ // --immediate true marks a quick win (live within a day): the Plan puts one in every top three.
5133
+ immediate: flags.immediate === undefined ? undefined : String(flags.immediate) === "true",
5134
+ // --reads llms_txt,github declares the facts its conditions rest on; --reads "" clears them.
5135
+ reads: flagStr(flags.reads)
5136
+ ?.split(",")
5137
+ .map((k) => k.trim())
5138
+ .filter(Boolean),
5123
5139
  });
5124
5140
  }
5125
5141
 
@@ -5677,6 +5693,40 @@ async function cmdAdminRecipes(ctx) {
5677
5693
  printResult(io, flags, result, (r) => recipeDetail(r.recipe));
5678
5694
  return 0;
5679
5695
  }
5696
+ case "refit": {
5697
+ // refit_accounts: the standing fit decided again now, not on the hourly sweep's turn.
5698
+ const orgs = flagStr(flags.org);
5699
+ const key = flagStr(flags.recipe);
5700
+ const limit = flagNum(flags.limit);
5701
+ let recipeId;
5702
+ if (key) {
5703
+ const recipe = (await all()).find((r) => r.id === key || r.name === key);
5704
+ if (!recipe) throw new CliError(`No recipe with id or name "${key}".`);
5705
+ recipeId = recipe.id;
5706
+ }
5707
+ const result = await staffPost(ctx, `${RECIPES}/refit`, {
5708
+ ...(orgs
5709
+ ? {
5710
+ org_ids: orgs
5711
+ .split(",")
5712
+ .map((s) => s.trim())
5713
+ .filter(Boolean),
5714
+ }
5715
+ : {}),
5716
+ ...(recipeId ? { recipe_id: recipeId } : {}),
5717
+ ...(limit !== undefined ? { limit } : {}),
5718
+ });
5719
+ printResult(io, flags, result, (r) =>
5720
+ [
5721
+ ...r.outcomes.map(
5722
+ (o) =>
5723
+ `${o.status.padEnd(11)} ${(o.domain ?? "—").padEnd(28)} ${o.org_id}${o.reason ? ` ${o.reason}` : ""}`
5724
+ ),
5725
+ `${r.picked} account(s) taken (${r.mode})${r.left ? `, ${r.left} more past the limit` : ""}: ${r.outcomes.filter((o) => o.status === "refit").length} refit, ${r.outcomes.filter((o) => o.status === "standing").length} stood, ${r.outcomes.filter((o) => o.status === "failed").length} failed, ${r.outcomes.filter((o) => o.status === "not_reached").length} not reached.`,
5726
+ ].join("\n")
5727
+ );
5728
+ return result.outcomes?.some((o) => o.status === "failed") ? 1 : 0;
5729
+ }
5680
5730
  case "delete": {
5681
5731
  const id = requirePositional(positionals, 1, "id");
5682
5732
  if (!flagBool(flags.yes)) {
@@ -89,6 +89,9 @@ export const ARGS = {
89
89
  enable_planner: { flag: "enable-planner", type: "bool" },
90
90
  cadence_per_week: { flag: "cadence", type: "num" },
91
91
  approval_mode: { flag: "approval", enum: APPROVAL_MODES },
92
+ // Start what the blog writes once it is read in (the starter automations, every draft for
93
+ // review), the one accept apply_starter_automations makes. Not with --enable-planner.
94
+ start_writing: { flag: "start-writing", type: "bool" },
92
95
  },
93
96
  get_collection_onboard_status: {
94
97
  job_id: { internal: "the job id onboard_collection just returned" },
@@ -425,9 +428,11 @@ function formatCollectionStatus(s) {
425
428
  ` series: ${r.series ?? 0}`,
426
429
  ` open topics: ${r.spokes_open ?? 0} (${r.spokes_seo_bound ?? 0} SEO-bound)`,
427
430
  ` headlines suggested: ${r.headlines_suggested ?? 0}`,
428
- s.enable_planner
429
- ? ` Planner: ON — ${s.cadence_per_week ?? "?"}/week, ${s.approval_mode ?? "manual"} approval, queue filled.`
430
- : ` Review them in Headlines & Queue — the Planner is configured but OFF (pass --enable-planner to turn it on).`
431
+ r.writing
432
+ ? ` Writing: ${r.writing.note}`
433
+ : s.enable_planner
434
+ ? ` Planner: ON — ${s.cadence_per_week ?? "?"}/week, ${s.approval_mode ?? "manual"} approval, queue filled.`
435
+ : ` Review them in Headlines & Queue — the Planner is configured but OFF (pass --start-writing or --enable-planner to turn it on).`
431
436
  );
432
437
  }
433
438
  return lines.join("\n");
@@ -2,6 +2,7 @@
2
2
  // (src/lib/site). One subcommand per tool:
3
3
  // site list → list_sites site map <host> → map_site
4
4
  // site tree <host> [path] → get_site_tree site page <host> <path> → get_site_page
5
+ // site llms-txt <host> → get_llms_txt (the file Letter writes; --out <file> to save it)
5
6
  // site builds <host> → list_build_suggestions (--limit n)
6
7
  // site research-builds <host> → research_builds (Build's suggestion pass: propose, check, Jev, store)
7
8
  // site research-fixes <host> → research_fixes (Fix's suggestion pass: exact edits on pages that exist)
@@ -14,6 +15,8 @@
14
15
  // site competitors → list_competitor_sites site watch-competitors [d] → watch_competitor_sites
15
16
  // site highlight <domain> [--off] → set_competitor_highlight
16
17
 
18
+ import { writeFileSync } from "node:fs";
19
+
17
20
  import { CliError } from "../client.mjs";
18
21
  import {
19
22
  argsFromFlags,
@@ -66,6 +69,7 @@ const ARGS = {
66
69
  skip_suggest: { flag: "skip-suggest", type: "bool" },
67
70
  },
68
71
  unmap_site: { host: { positional: 0, required: true, label: "host" } },
72
+ get_llms_txt: { host: { positional: 0, required: true, label: "host" } },
69
73
  get_site_tree: {
70
74
  host: { positional: 0, required: true, label: "host" },
71
75
  path: { positional: 1, label: "path" },
@@ -215,6 +219,8 @@ export async function cmdSite(ctx) {
215
219
  return siteUnmap(rest);
216
220
  case "tree":
217
221
  return siteTree(rest);
222
+ case "llms-txt":
223
+ return siteLlmsTxt(rest);
218
224
  case "research-builds":
219
225
  return siteResearchBuilds(rest);
220
226
  case "research-fixes":
@@ -399,6 +405,20 @@ async function siteUnmap(ctx) {
399
405
  return 0;
400
406
  }
401
407
 
408
+ async function siteLlmsTxt(ctx) {
409
+ const { client, flags, io } = ctx;
410
+ refuseUnknownFlags(ctx, ARGS.get_llms_txt, ["out"]);
411
+ const result = await client.callTool("get_llms_txt", argsFromFlags(ARGS.get_llms_txt, flags, ctx.positionals));
412
+ const out = flagStr(flags.out);
413
+ if (out) {
414
+ writeFileSync(out, result.text);
415
+ ok(ctx, `Wrote ${out} (${result.pages} pages). ${result.where}`);
416
+ return 0;
417
+ }
418
+ printResult(io, flags, result, (r) => r.text);
419
+ return 0;
420
+ }
421
+
402
422
  async function siteTree(ctx) {
403
423
  const { client, flags, io } = ctx;
404
424
  refuseUnknownFlags(ctx, ARGS.get_site_tree);
package/lib/parked.mjs ADDED
@@ -0,0 +1,32 @@
1
+ // The help sections of primitives the app has parked (src/config/parked.ts): the commands still run,
2
+ // but `help` doesn't list them, so neither a person nor their agent is pointed at a product we have
3
+ // parked. Which are parked is decided on the server (Super Admin → Parked), so `help` asks it
4
+ // (GET /api/parked, `cli_sections`). This list is only what it falls back to when the server can't
5
+ // be reached: the state when this version shipped.
6
+ export const PARKED_HELP_SECTIONS = ["Seers", "Shredder", "Ledes"];
7
+
8
+ /** The parked help sections the server names now, or null when it can't say in time. */
9
+ export async function fetchParkedSections(url, { fetchImpl = globalThis.fetch, timeoutMs = 1500 } = {}) {
10
+ try {
11
+ const res = await fetchImpl(`${String(url).replace(/\/$/, "")}/api/parked`, {
12
+ signal: AbortSignal.timeout(timeoutMs),
13
+ });
14
+ if (!res.ok) return null;
15
+ const body = await res.json();
16
+ return Array.isArray(body?.cli_sections) ? body.cli_sections.filter((s) => typeof s === "string") : null;
17
+ } catch {
18
+ return null;
19
+ }
20
+ }
21
+
22
+ /** The manual less every parked section: a section is a line at column 0 and the lines under it. */
23
+ export function withoutParked(help, sections = PARKED_HELP_SECTIONS) {
24
+ const out = [];
25
+ let skipping = false;
26
+ for (const line of help.split("\n")) {
27
+ const heading = line !== "" && !/^\s/.test(line);
28
+ if (heading) skipping = sections.some((s) => line === `${s}:` || line.startsWith(`${s} (`));
29
+ if (!skipping) out.push(line);
30
+ }
31
+ return out.join("\n");
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.175.21",
3
+ "version": "0.175.23",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",