@letterstory/cli 0.168.0 → 0.168.1

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
@@ -75,7 +75,7 @@ import {
75
75
  } from "./commands.mjs";
76
76
 
77
77
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
78
- export const VERSION = "0.168.0";
78
+ export const VERSION = "0.168.1";
79
79
 
80
80
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
81
81
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -84,6 +84,8 @@ export const EXIT_PAYMENT_REQUIRED = 3;
84
84
  // can't accidentally swallow the id as --json's value. Every `type: "bool"` flag (and its
85
85
  // `negate` spelling) in a command's ARGS map must be listed; boolean-flags.test.ts enforces it.
86
86
  export const BOOLEAN_FLAGS = new Set([
87
+ // admin crm prospect-org: start (or retry) the org prepared for the booked call.
88
+ "start",
87
89
  // site research-builds: run now even when the stored pass is under an hour old.
88
90
  "fresh",
89
91
  // admin letterpress status | gaps: the customers' reading (no test or demo orgs).
@@ -158,6 +160,8 @@ export const BOOLEAN_FLAGS = new Set([
158
160
  "moves",
159
161
  "enroll",
160
162
  "unenroll",
163
+ // admin demo set --release
164
+ "release",
161
165
  "clean-slate",
162
166
  // admin crm record-outcome --draft
163
167
  "draft",
@@ -891,7 +895,11 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
891
895
  Letterpress on Plan, Build and Fix (/superadmin/recipes),
892
896
  five fields each: name, recipe, when to use, when not to
893
897
  use, weight. vocab says what each field means; stats how
894
- each recipe's suggestions fare. Needs recipes:read.
898
+ often runs followed each recipe (and the share of the
899
+ runs that had it) and how its suggestions fare. Needs
900
+ recipes:read.
901
+ admin recipes list --approach <seo|geo|agent_conviction|inbound_conversion|outbound|other>
902
+ One approach's recipes, read from their own words.
895
903
  admin recipes export [--out recipes.json] The library as a file import reads back.
896
904
  admin recipes import <file> [--dry-run] Write a library in one call: each recipe matched by id,
897
905
  else name, then changed or created. --dry-run writes
@@ -927,11 +935,18 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
927
935
  admin demo set <org-id> [--enroll] [--phantom parked] [--search-console hidden] [--inject <key>]... [--save-as n]
928
936
  Set what a demo org shows (merged); 'shown' puts a thing
929
937
  back. --file takes a scenario as JSON. Needs demo:write.
930
- admin demo reset <org-id> <scenario> [--clean-slate] [--close-prs since_applied|all_open|none]
938
+ admin demo reset <org-id> <scenario> [--clean-slate] [--close-prs since_applied|all_open|none] [--hold <min>]
931
939
  Undo the last take (its PRs closed, builds archived), then
932
940
  show a scenario: real, fresh_geo, fresh_seo, after_approve
933
941
  or a saved one. --clean-slate closes every open PR and
934
- archives every build.
942
+ archives every build. --hold <min> starts a demo: no automatic
943
+ reset for that long. Ends with the readiness check.
944
+ admin demo set <org-id> --auto-reset <scenario>|off [--every <min>] [--release]
945
+ Reset on its own every <min> (default 30) once idle 15
946
+ min and not held; --release ends a hold.
947
+ admin demo check <org-id> Is it ready to show? Competitors, targets, answers, the
948
+ Plan's rows, the issues open, no PR open, GitHub, the
949
+ phantom's site. Exits 1 when not ready.
935
950
  admin brand-detection <org-id> [--term <t>]... [--exact <t>]... [--exclude <phrase>]... [--note "…"] | --clear [--note "…"]
936
951
  How a client's brand is detected in AI answers, with
937
952
  every earlier setting; with flags, set the exact set
@@ -1071,6 +1086,8 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
1071
1086
  [--slack a@acme.com,b@acme.com] [--invite a@acme.com[:admin]]… [--no-checklist]
1072
1087
  | onboarding <account-id> | retry-onboarding <onboarding-id>
1073
1088
  | onboard-plan <account-id> [--refresh]
1089
+ | prospect-org <account-id> [--start] [--domain acme.com] the org prepared for their booked call
1090
+ | prospect-orgs [--status preparing|ready|failed|skipped|parked|converted] [--limit 50]
1074
1091
  | payment-link <account-id> [--amount-cents N] [--description "…"] [--plan starter] [--ratio N] [--why "…"] [--first-invoice-credit-cents N]
1075
1092
  The staff CRM's pipeline: bulk-importing a
1076
1093
  CSV of leads, the inbound signal
@@ -20,7 +20,7 @@
20
20
  // admin brand-detection <org-id> [--term t]... [--exact t]... [--exclude p]... [--note "…"] | --clear [--note "…"] (fleet:instrument)
21
21
  // admin recipes list|show|vocab|export|import|save|delete … (recipes:read / recipes:write)
22
22
  // admin letterpress settings|flip|set … (recipes:read / recipes:write)
23
- // admin demo guide|list|show|set|reset … (demo:read / demo:write)
23
+ // admin demo guide|list|show|set|reset|check … (demo:read / demo:write)
24
24
  // admin models runs|run|star|unstar|scoreboard|requests|request|sampling … (models:read / models:write)
25
25
  // admin replays [--org <id>] [--target <id>] [--status …] [--limit n] (fleet:read)
26
26
  // admin replay --org <id> [<response-id> | --target <id>] [--surface …] (fleet:replay)
@@ -2740,6 +2740,35 @@ function onboardingLines(o) {
2740
2740
  ].join("\n");
2741
2741
  }
2742
2742
 
2743
+ function prospectOrgHeadline(p) {
2744
+ const call = p.callAt ? ` call ${p.callAt.slice(0, 16).replace("T", " ")}` : "";
2745
+ return `${p.status.padEnd(9)} ${p.accountName ?? p.accountId} ${p.domain || "(no domain)"}${call}${p.note ? ` — ${p.note}` : ""}`;
2746
+ }
2747
+
2748
+ function prospectOrgLines(p) {
2749
+ if (!p) return "(no prospect org for this account)";
2750
+ const mark = { done: "✓", skipped: "–", failed: "✗", running: "…", pending: "·" };
2751
+ return [
2752
+ `${p.id} ${prospectOrgHeadline(p)}`,
2753
+ ...(p.orgName ? [` org: ${p.orgName} (${p.orgId})`] : []),
2754
+ ...p.steps.map(
2755
+ (s) =>
2756
+ ` ${mark[s.status] ?? "?"} ${s.key.padEnd(16)} ${s.status}${s.detail ? ` ${s.detail}` : ""}${s.error ? `\n error: ${s.error}` : ""}`
2757
+ ),
2758
+ ...(p.competitors.length
2759
+ ? [
2760
+ ` competitors: ${p.competitors
2761
+ .map(
2762
+ (c) =>
2763
+ `${c.host}${c.employees != null ? ` (${c.employees} people)` : ""}${c.pages != null ? ` ${c.pages} pages` : ""}`
2764
+ )
2765
+ .join(", ")}`,
2766
+ ]
2767
+ : []),
2768
+ ...(p.openUrl ? [` open: ${p.openUrl}`] : []),
2769
+ ].join("\n");
2770
+ }
2771
+
2743
2772
  function dollars(cents) {
2744
2773
  return `$${(cents / 100).toLocaleString("en-US", { maximumFractionDigits: 2 })}`;
2745
2774
  }
@@ -3752,6 +3781,31 @@ async function cmdAdminCrm(ctx) {
3752
3781
  onboardingLines(x.onboarding)
3753
3782
  );
3754
3783
  }
3784
+ case "prospect-org": {
3785
+ // admin crm prospect-org <account-id> [--start] [--domain acme.com] — the org prepared
3786
+ // for the account's booked call (docs/architecture/prospect-orgs.md). --start (or a
3787
+ // --domain) starts it by hand, or retries its failed steps; the key then needs
3788
+ // crm:write + org:create.
3789
+ if (!id) throw new CliError("Usage: admin crm prospect-org <account-id> [--start] [--domain acme.com]");
3790
+ if (flagBool(flags.start) || flags.domain) {
3791
+ const r = await staffPost(ctx, `${CRM}/accounts/${id}/prospect-org`, compact({ domain: flags.domain }));
3792
+ return out(r, (x) => prospectOrgLines(x.prospectOrg));
3793
+ }
3794
+ return out(await staffRequest(ctx, "GET", `${CRM}/accounts/${id}/prospect-org`), (x) =>
3795
+ prospectOrgLines(x.prospectOrg)
3796
+ );
3797
+ }
3798
+ case "prospect-orgs": {
3799
+ // admin crm prospect-orgs [--status ready] [--limit 50] — the orgs prepared for booked
3800
+ // calls, newest first.
3801
+ const q = new URLSearchParams(compact({ status: flags.status, limit: flags.limit }));
3802
+ const qs = q.toString() ? `?${q}` : "";
3803
+ return out(await staffRequest(ctx, "GET", `${CRM}/prospect-orgs${qs}`), (x) =>
3804
+ x.prospectOrgs.length
3805
+ ? x.prospectOrgs.map((p) => prospectOrgHeadline(p)).join("\n")
3806
+ : "(no prospect orgs yet)"
3807
+ );
3808
+ }
3755
3809
  case "onboard-plan": {
3756
3810
  // admin crm onboard-plan <account-id> [--refresh] — what the calls say onboarding
3757
3811
  // should set up (sites, Slack/app people, notes) + paid or not. --refresh re-reads.
@@ -3797,7 +3851,7 @@ async function cmdAdminCrm(ctx) {
3797
3851
  }
3798
3852
  default:
3799
3853
  throw new CliError(
3800
- "Usage: admin crm import|capture|outreach|signals|record|signal|accounts|account|score|slack-channels|link-slack|white-glove|set-white-glove|churn|revenue|reach-outs|replies|record-churn|draft-churn-reason|undo-churn|outcomes|record-outcome|renewals|track-record|weekly-note|at-risk|expansion-signals|collections|delivery-flags|pulse|case|onboard|onboarding|retry-onboarding|onboard-plan|payment-link … (see --help)"
3854
+ "Usage: admin crm import|capture|outreach|signals|record|signal|accounts|account|score|slack-channels|link-slack|white-glove|set-white-glove|churn|revenue|reach-outs|replies|record-churn|draft-churn-reason|undo-churn|outcomes|record-outcome|renewals|track-record|weekly-note|at-risk|expansion-signals|collections|delivery-flags|pulse|case|onboard|onboarding|retry-onboarding|onboard-plan|prospect-org|prospect-orgs|payment-link … (see --help)"
3801
3855
  );
3802
3856
  }
3803
3857
  }
@@ -4934,17 +4988,21 @@ const RECIPES = "/api/superadmin/recipes";
4934
4988
  /** The fields a recipe file carries: what import_recipes reads back. */
4935
4989
  const RECIPE_FILE_FIELDS = ["id", "name", "recipe", "when_to_use", "when_not_to_use", "weight"];
4936
4990
  const RECIPES_USAGE =
4937
- "Usage: admin recipes list | show <id|name> | vocab | stats | export [--out <file>] | import <file> [--dry-run] | save [<id>] [--file <recipe.json>] [--name …] [--recipe …] [--when-to-use …] [--when-not-to-use …] [--weight 1..10] | delete <id> --yes";
4991
+ "Usage: admin recipes list [--approach seo|geo|agent_conviction|inbound_conversion|outbound|other] | show <id|name> | vocab | stats | export [--out <file>] | import <file> [--dry-run] | save [<id>] [--file <recipe.json>] [--name …] [--recipe …] [--when-to-use …] [--when-not-to-use …] [--weight 1..10] | delete <id> --yes";
4938
4992
 
4939
4993
  const recipeForFile = (r) => Object.fromEntries(RECIPE_FILE_FIELDS.map((k) => [k, r[k]]));
4940
4994
 
4995
+ /** A recipe's approaches (read from its words by the server), or "other". */
4996
+ const recipeApproaches = (r) => (r.approaches?.length ? r.approaches.join(", ") : "other");
4997
+
4941
4998
  function recipeLine(r) {
4942
- return `${String(r.weight).padStart(2)}/10 ${r.name} ${r.id}`;
4999
+ return `${String(r.weight).padStart(2)}/10 ${r.name} [${recipeApproaches(r)}] ${r.id}`;
4943
5000
  }
4944
5001
 
4945
5002
  function recipeDetail(r) {
4946
5003
  return [
4947
5004
  `${r.name} weight ${r.weight}/10 ${r.id}`,
5005
+ ...(r.approaches ? [` approaches: ${recipeApproaches(r)}`] : []),
4948
5006
  ` recipe: ${r.recipe || "—"}`,
4949
5007
  ` when to use: ${r.when_to_use || "—"}`,
4950
5008
  ` when not to use: ${r.when_not_to_use || "—"}`,
@@ -5186,20 +5244,34 @@ async function cmdAdminRecipes(ctx) {
5186
5244
  switch (sub) {
5187
5245
  case "stats": {
5188
5246
  const result = await staffRequest(ctx, "GET", `${RECIPES}/stats`);
5247
+ const pct = (share) => (share === null ? " —" : `${String(Math.round(share * 100)).padStart(3)}%`);
5189
5248
  printResult(io, flags, result, (r) =>
5190
- r.stats.length
5191
- ? r.stats
5192
- .map(
5249
+ [
5250
+ `Runs over the last ${r.usage_days ?? 30} days (followed / had it to choose from):`,
5251
+ ...(r.usage?.length
5252
+ ? r.usage.map(
5253
+ (u) =>
5254
+ `${String(u.runs).padStart(5)} runs ${pct(u.selected_share)} of ${String(u.offered).padEnd(4)} plan ${u.by_lens.plan} build ${u.by_lens.build} fix ${u.by_lens.fix} ${u.name}`
5255
+ )
5256
+ : [" No recipes yet."]),
5257
+ "",
5258
+ "What the passes show and people dismissed:",
5259
+ ...(r.stats.length
5260
+ ? r.stats.map(
5193
5261
  (s) =>
5194
5262
  `${String(s.shown).padStart(5)} shown ${String(s.dismissed).padStart(4)} dismissed ${String(s.resolved ?? 0).padStart(4)} resolved ${String(s.built ?? 0).padStart(3)} built ${s.lens.padEnd(5)} ${s.recipe}${s.reasons.length ? `\n why: ${s.reasons.slice(0, 3).join(" · ")}` : ""}`
5195
5263
  )
5196
- .join("\n")
5197
- : "No suggestions from the passes yet."
5264
+ : [" No suggestions from the passes yet."]),
5265
+ ].join("\n")
5198
5266
  );
5199
5267
  return 0;
5200
5268
  }
5201
5269
  case "list": {
5202
- const recipes = await all();
5270
+ const approach = flagStr(flags.approach);
5271
+ const recipes = approach
5272
+ ? ((await staffRequest(ctx, "GET", `${RECIPES}?approach=${encodeURIComponent(approach)}`)).recipes ??
5273
+ [])
5274
+ : await all();
5203
5275
  printResult(io, flags, { recipes }, (r) =>
5204
5276
  r.recipes.length ? r.recipes.map(recipeLine).join("\n") : "No recipes yet."
5205
5277
  );
@@ -5705,7 +5777,7 @@ async function cmdAdminBilling(ctx) {
5705
5777
 
5706
5778
  // `admin demo` — demo control (docs/architecture/demo-control.md): what each demo org shows,
5707
5779
  // set, rehearsed and reset. The staff routes behind /superadmin/demo, the same functions and
5708
- // schema as list_demo_orgs / get_demo_state / set_demo_state / reset_demo_state.
5780
+ // schema as list_demo_orgs / get_demo_state / set_demo_state / reset_demo_state / run_demo_readiness_check.
5709
5781
  const DEMO = "/api/superadmin/demo";
5710
5782
  const DEMO_ITEM_FLAGS = [
5711
5783
  "phantom",
@@ -5720,7 +5792,15 @@ const DEMO_ITEM_FLAGS = [
5720
5792
  "setup",
5721
5793
  ];
5722
5794
  const DEMO_USAGE =
5723
- "Usage: admin demo guide | list [--enrollable] | show <org-id> [--moves] | set <org-id> [--enroll] [--unenroll] [--file <state.json>] [--phantom parked|shown] [--main-blog …] [--visitors …] [--probes not_run|shown] [--cms hidden|shown] [--publish-target …] [--search-console …] [--github …] [--domain …] [--setup fresh|finished] [--domain-cap n] [--inject <key>]... [--hide <key>]... [--save-as <name>] | reset <org-id> <scenario> [--clean-slate] [--close-prs since_applied|all_open|none]";
5795
+ "Usage: admin demo guide | list [--enrollable] | show <org-id> [--moves] | set <org-id> [--enroll] [--unenroll] [--file <state.json>] [--phantom parked|shown] [--main-blog …] [--visitors …] [--probes not_run|shown] [--cms hidden|shown] [--publish-target …] [--search-console …] [--github …] [--domain …] [--setup fresh|finished] [--domain-cap n] [--inject <key>]... [--hide <key>]... [--save-as <name>] [--auto-reset <scenario>|off] [--every <minutes>] [--release] | reset <org-id> <scenario> [--clean-slate] [--close-prs since_applied|all_open|none] [--hold <minutes>] | check <org-id>";
5796
+
5797
+ const readinessLines = (r) =>
5798
+ r
5799
+ ? [
5800
+ `${r.ok ? "READY" : "NOT READY"} (checked ${r.at})`,
5801
+ ...r.checks.map((c) => ` ${c.ok ? "ok " : "FAIL"} ${c.label}: ${c.detail}`),
5802
+ ].join("\n")
5803
+ : "Not checked yet.";
5724
5804
 
5725
5805
  async function cmdAdminDemo(ctx) {
5726
5806
  const { flags, positionals, io } = ctx;
@@ -5758,7 +5838,11 @@ async function cmdAdminDemo(ctx) {
5758
5838
  (o) =>
5759
5839
  `${o.enrolled ? "demo" : "test"} ${o.name} ${o.domain ?? "—"} ${o.scenario ?? ""}${
5760
5840
  o.differs?.length ? ` [${o.differs.join(", ")}]` : ""
5761
- } ${o.org_id}`
5841
+ }${o.ready === true ? " ready" : o.ready === false ? " NOT READY" : ""}${
5842
+ o.auto_reset
5843
+ ? ` auto ${o.auto_reset.scenario}/${o.auto_reset.every_minutes}m`
5844
+ : ""
5845
+ }${o.held ? ` held until ${o.held.until}` : ""} ${o.org_id}`
5762
5846
  )
5763
5847
  .join("\n")
5764
5848
  : "No demo orgs yet."
@@ -5778,6 +5862,8 @@ async function cmdAdminDemo(ctx) {
5778
5862
  ...r.knobs.map((k) => ` ${k.item.padEnd(16)} real: ${k.real} · shown: ${k.shown} (${k.how})`),
5779
5863
  ` observations open: ${r.observations.open.map((o) => `${o.key}${o.injected ? " (demo)" : ""}`).join(", ") || "none"}`,
5780
5864
  ` answers: ${r.answers.map((q) => `${q.named}/${q.answers} ${q.text}`).join("; ") || "never probed"}`,
5865
+ ` auto-reset: ${r.state.auto_reset ? `${r.state.auto_reset.scenario} every ${r.state.auto_reset.every_minutes} min, next due ${r.state.auto_reset.next_due_at}` : "off"}${r.state.held ? ` · held until ${r.state.held.until}` : ""}`,
5866
+ readinessLines(r.state.readiness),
5781
5867
  ].join("\n")
5782
5868
  );
5783
5869
  return 0;
@@ -5805,6 +5891,13 @@ async function cmdAdminDemo(ctx) {
5805
5891
  enroll: flagBool(flags.enroll) || undefined,
5806
5892
  unenroll: flagBool(flags.unenroll) || undefined,
5807
5893
  save_as: flagStr(flags["save-as"]),
5894
+ auto_reset: flagStr(flags["auto-reset"])
5895
+ ? {
5896
+ scenario: flagStr(flags["auto-reset"]) === "off" ? null : flagStr(flags["auto-reset"]),
5897
+ ...(flagNum(flags.every) ? { every_minutes: flagNum(flags.every) } : {}),
5898
+ }
5899
+ : undefined,
5900
+ release_hold: flagBool(flags.release) || undefined,
5808
5901
  });
5809
5902
  if (!Object.keys(body).length) throw new CliError(DEMO_USAGE);
5810
5903
  const result = await staffRequest(ctx, "PATCH", `${DEMO}/${encodeURIComponent(orgId)}`, body);
@@ -5821,11 +5914,18 @@ async function cmdAdminDemo(ctx) {
5821
5914
  scenario,
5822
5915
  close_prs: flagStr(flags["close-prs"]),
5823
5916
  clean_slate: flagBool(flags["clean-slate"]) || undefined,
5917
+ hold_minutes: flagNum(flags.hold) ?? undefined,
5824
5918
  })
5825
5919
  );
5826
- printResult(io, flags, result, (r) => r.notes.join("\n"));
5920
+ printResult(io, flags, result, (r) => [r.notes.join("\n"), readinessLines(r.readiness)].join("\n"));
5827
5921
  return 0;
5828
5922
  }
5923
+ case "check": {
5924
+ const orgId = requirePositional(positionals, 1, "org-id");
5925
+ const result = await staffPost(ctx, `${DEMO}/${encodeURIComponent(orgId)}/check`, {});
5926
+ printResult(io, flags, result, (r) => readinessLines(r.readiness));
5927
+ return result.readiness?.ok ? 0 : 1;
5928
+ }
5829
5929
  default:
5830
5930
  throw new CliError(DEMO_USAGE);
5831
5931
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.168.0",
3
+ "version": "0.168.1",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",