@letterstory/cli 0.152.0 → 0.154.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/README.md CHANGED
@@ -473,6 +473,7 @@ letterstory admin crm record --source twitter --kind social_engagement \
473
473
  --title "Liked our launch tweet" --name "Pat" --linkedin https://linkedin.com/in/pat
474
474
  letterstory admin crm signal <signal-id> qualify # link/create the account
475
475
  letterstory admin crm signal <signal-id> dismiss # the easy delete (kept, marked)
476
+ letterstory admin crm add "Acme" --domain acme.com # quick-add; an existing account says "already exists as <name> (<domain>)"
476
477
  letterstory admin crm accounts --stage demo_scheduled # with likelihood
477
478
  letterstory admin crm score <account-id> # recompute; prints the factors
478
479
  letterstory admin crm slack-channels [--all] # Watchdog channels + the account each is linked to
package/lib/cli.mjs CHANGED
@@ -66,7 +66,7 @@ import {
66
66
 
67
67
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
68
68
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
69
- export const VERSION = "0.152.0";
69
+ export const VERSION = "0.154.1";
70
70
 
71
71
  // Flags that never take a value. Listing them explicitly means `deploy get --json <id>`
72
72
  // can't accidentally swallow the id as --json's value. Every `type: "bool"` flag (and its
@@ -113,6 +113,7 @@ export const BOOLEAN_FLAGS = new Set([
113
113
  "force-map",
114
114
  "force-audit",
115
115
  "skip-observe",
116
+ "skip-suggest",
116
117
  "ignore-budget",
117
118
  // lede library update / lede proposals accept: clear or drop the line's condition.
118
119
  "no-condition",
@@ -986,6 +987,7 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
986
987
  | record --title "…" [--source bookface] [--kind other] [--intent qualified]
987
988
  [--name …] [--email …] [--company …] [--domain …] [--linkedin …] [--detail …]
988
989
  | signal <id> qualify|dismiss|link [--account <id>]
990
+ | add "<name>" [--domain acme.com] [--stage lead] [--source …] [--owner <user-id>]
989
991
  | accounts [--stage lead] [--q acme] | account <id> | score <account-id>
990
992
  | slack-channels [--all] | link-slack <account-id> <channel-id|none>
991
993
  | white-glove [--suggested] | set-white-glove <account-id> on|off [--note "…"]
@@ -1421,7 +1423,7 @@ The Site (one model of your whole marketing site, keyed by host and path):
1421
1423
  site list Mapped hosts, and hosts you already have elsewhere
1422
1424
  site map <host> [--sitemap <url>] [--max-pages <n>] [--no-audit] [--relation owned|watched]
1423
1425
  Map a host from its sitemap; starts an audit if it has none
1424
- site refresh <host> [--force-map] [--force-audit] [--skip-observe]
1426
+ site refresh <host> [--force-map] [--force-audit] [--skip-observe] [--skip-suggest]
1425
1427
  Run the daily loop now: re-map, re-audit, signals, Jev
1426
1428
  site unmap <host> Remove a host and everything hanging off it
1427
1429
  site tree <host> [path] [--depth <n>] [--unfold] [--since <iso>]
@@ -1,6 +1,6 @@
1
1
  // `admin` — the PLATFORM-scoped commands, for staff. Everything else in this CLI is
2
2
  // org-scoped and rides the MCP endpoint with an org API key; these ride a STAFF API key
3
- // (`x-staff-api-key`, minted at Settings → Staff keys) against the superadmin REST
3
+ // (`x-staff-api-key`, minted at Super Admin → Staff keys) against the superadmin REST
4
4
  // routes, because they exist precisely to act BEFORE an org exists.
5
5
  //
6
6
  // admin ask "which kernels are hooked up to the most clients?" [--sql] [--json]
@@ -14,7 +14,7 @@
14
14
  // The old names — evals, eval-add, eval-set, proposals, propose-eval, capture-eval, reject-eval — still work.)
15
15
  // admin evals scoreboard|cases|runs|run|triage|guard|retire … (fleet:read / tuning:experiment)
16
16
  // admin fleet-experiments list|articles|clients|mark|unmark|new|assign|assign-eligible|assign-orgs|spin-up|apply|start|stop|decide … (fleet:read / fleet:experiment)
17
- // 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 … (crm:read / crm:write)
17
+ // admin crm import|capture|outreach|signals|record|signal|add|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 … (crm:read / crm:write)
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)
@@ -63,12 +63,22 @@ import { watchDomainJob } from "./onboard.mjs";
63
63
  const SEER_MODES = ["suggest", "skip"];
64
64
  const CMS_PROVIDERS = ["webflow", "framer", "sanity", "contentful", "github"];
65
65
 
66
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
67
+
66
68
  function staffKeyFrom(flags) {
67
69
  const key = flagStr(flags["staff-key"]) || process.env.LETTERSTORY_STAFF_API_KEY || null;
68
70
  if (!key) {
69
71
  throw new CliError(
70
72
  "admin commands need a STAFF API key: pass --staff-key <key> or set LETTERSTORY_STAFF_API_KEY " +
71
- "(mint one at Settings → Staff keys with the org:create capability)."
73
+ "(mint one at Super Admin → Staff keys, or POST /api/staff/keys, and save its plainKey)."
74
+ );
75
+ }
76
+ // The mint answers { key: <the row>, plainKey: <the secret> }; key.id is the easy thing to
77
+ // save by mistake. Say so before the server's 401 does (lib/staff-auth.ts says the same).
78
+ if (UUID_PATTERN.test(key.trim())) {
79
+ throw new CliError(
80
+ "the staff key (--staff-key / LETTERSTORY_STAFF_API_KEY) looks like a key id, not the key — " +
81
+ "use plainKey from the mint response, not key.id."
72
82
  );
73
83
  }
74
84
  return key;
@@ -2580,6 +2590,19 @@ function accountLine(a) {
2580
2590
  return `${a.id} [${a.stage}] ${score} ${a.name}${a.domain ? ` (${a.domain})` : ""}${a.isYc ? " · YC" : ""}`;
2581
2591
  }
2582
2592
 
2593
+ /**
2594
+ * `admin crm add`'s line: "created" for a new account; for an existing one, its OWN
2595
+ * name and domain ("already exists as Letterstory (letterstory.com)"), since a
2596
+ * subdomain is answered by its parent company's account.
2597
+ */
2598
+ export function crmAddLine(r, requestedName) {
2599
+ if (r.created) return `created: ${requestedName} ${r.id}`;
2600
+ const m = r.matched;
2601
+ if (!m) return `already exists ${r.id}`;
2602
+ const why = m.reason === "registrable_domain" ? ", matched on its company domain" : "";
2603
+ return `already exists as ${m.name}${m.domain ? ` (${m.domain})` : ""}${why} ${r.id}`;
2604
+ }
2605
+
2583
2606
  /* ------------------------------------------------------ CRM lead import (CSV) */
2584
2607
 
2585
2608
  /** RFC 4180-ish: quoted fields, doubled quotes, CRLF/LF, a BOM. Returns rows of cells. */
@@ -3246,6 +3269,25 @@ async function cmdAdminCrm(ctx) {
3246
3269
  );
3247
3270
  return out(r, (x) => signalLine(x.signal));
3248
3271
  }
3272
+ case "add": {
3273
+ // admin crm add "<name>" [--domain acme.com] [--stage lead] [--source referral] [--owner <user-id>]
3274
+ // The CRM's quick-add (POST /api/superadmin/crm/accounts). An existing account
3275
+ // answers with its own name and domain, never as if it were the one asked for.
3276
+ const name = ctx.positionals.slice(1).join(" ").trim();
3277
+ if (!name)
3278
+ throw new CliError(
3279
+ 'Usage: admin crm add "<company name>" [--domain acme.com] [--stage lead] [--source …] [--owner <user-id>]'
3280
+ );
3281
+ const body = compact({
3282
+ name,
3283
+ domain: flagStr(flags.domain),
3284
+ stage: flagStr(flags.stage),
3285
+ source: flagStr(flags.source),
3286
+ owner_id: flagStr(flags.owner),
3287
+ });
3288
+ const r = await staffPost(ctx, `${CRM}/accounts`, body);
3289
+ return out(r, (x) => crmAddLine(x, name));
3290
+ }
3249
3291
  case "accounts": {
3250
3292
  const params = new URLSearchParams(compact({ stage: flagStr(flags.stage), q: flagStr(flags.q) }));
3251
3293
  return out(await staffRequest(ctx, "GET", `${CRM}/accounts?${params}`), (r) =>
@@ -817,8 +817,8 @@ async function repoSuggestions(ctx) {
817
817
  .map((s) => {
818
818
  const where = s.repo ? `${s.repo} → ${s.siteHost}` : `${s.siteHost} (pick a repo)`;
819
819
  const start =
820
- s.start.tool === "fix_audit_issue"
821
- ? `letterstory repo fix-audit --audit ${s.start.args.audit_id} --issue ${s.start.args.issue_type}`
820
+ s.start.tool === "fix_site_observations"
821
+ ? `letterstory site fix ${s.start.args.host} ${s.start.args.observation_ids.join(" ")}`
822
822
  : s.start.args
823
823
  ? `letterstory repo install-letterprove --repo ${s.start.args.repo_owner}/${s.start.args.repo_name}`
824
824
  : "letterstory repo install-letterprove --repo <owner/name>";
@@ -63,6 +63,7 @@ const ARGS = {
63
63
  force_map: { flag: "force-map", type: "bool" },
64
64
  force_audit: { flag: "force-audit", type: "bool" },
65
65
  skip_observe: { flag: "skip-observe", type: "bool" },
66
+ skip_suggest: { flag: "skip-suggest", type: "bool" },
66
67
  },
67
68
  unmap_site: { host: { positional: 0, required: true, label: "host" } },
68
69
  get_site_tree: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.152.0",
3
+ "version": "0.154.1",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",