@letterstory/cli 0.175.1 → 0.175.3

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.175.1";
79
+ export const VERSION = "0.175.3";
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;
@@ -19,6 +19,7 @@
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
21
  // admin recipes list|show|runs|vocab|export|import|save|delete … (recipes:read / recipes:write)
22
+ // admin letterpress companies | company <org-id> | facts <org-id> (the standing fit, per company)
22
23
  // admin letterpress beyond [--limit N] [--before ISO] (what members asked that went past the library)
23
24
  // admin letterpress settings|flip|set … (recipes:read / recipes:write)
24
25
  // admin demo guide|list|show|set|reset|check … (demo:read / demo:write)
@@ -5031,10 +5032,12 @@ const RECIPE_FILE_FIELDS = [
5031
5032
  "weight",
5032
5033
  "approaches",
5033
5034
  "runs",
5035
+ "status",
5036
+ "needs",
5034
5037
  "variations",
5035
5038
  ];
5036
5039
  const RECIPES_USAGE =
5037
- "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";
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";
5038
5041
 
5039
5042
  const recipeForFile = (r) => Object.fromEntries(RECIPE_FILE_FIELDS.map((k) => [k, r[k]]));
5040
5043
 
@@ -5050,7 +5053,8 @@ const recipeVariations = (r) => [
5050
5053
  function recipeLine(r) {
5051
5054
  const more = r.variations?.length ? ` ${r.variations.length + 1} variations` : "";
5052
5055
  const kind = r.kind === "known_issue" ? " (known issue)" : "";
5053
- return `${String(r.weight).padStart(2)}/10 ${r.name}${kind} [${recipeApproaches(r)}]${more} ${r.id}`;
5056
+ const parked = r.status === "parked" ? ` [parked${r.needs ? `: ${r.needs}` : ""}]` : "";
5057
+ return `${String(r.weight).padStart(2)}/10 ${r.name}${kind}${parked} [${recipeApproaches(r)}]${more} ${r.id}`;
5054
5058
  }
5055
5059
 
5056
5060
  function recipeDetail(r) {
@@ -5065,6 +5069,7 @@ function recipeDetail(r) {
5065
5069
  `${r.name} weight ${r.weight}/10 ${r.id}`,
5066
5070
  ` kind: ${r.kind === "known_issue" ? "known issue (Fix's list)" : "recipe (the Plan's)"}`,
5067
5071
  ` approaches: ${recipeApproaches(r)}`,
5072
+ ` status: ${r.status === "parked" ? `parked${r.needs ? `, needs ${r.needs}` : ""}` : "live"}`,
5068
5073
  ` runs: ${r.runs || "one change to the site's code, from its own directions"}`,
5069
5074
  ...(variations.length > 1
5070
5075
  ? variations.flatMap((v, i) => [` variation ${i + 1}: ${v.name}`, ...fields(v, " ")])
@@ -5107,6 +5112,9 @@ function recipeFromFlags(flags) {
5107
5112
  weight: flagNum(flags.weight),
5108
5113
  // --runs visitors:site names the catalog action; --runs "" is one change to the site's code.
5109
5114
  runs: flagStr(flags.runs),
5115
+ // --status parked takes it out of the fit (say what it is missing with --needs); --status live brings it back.
5116
+ status: flagStr(flags.status),
5117
+ needs: flagStr(flags.needs),
5110
5118
  // --approaches seo,geo sets the tags; --approaches "" clears them.
5111
5119
  approaches: flagStr(flags.approaches)
5112
5120
  ?.split(",")
@@ -5119,7 +5127,7 @@ const ENGINE = "/api/superadmin/engine-settings";
5119
5127
  const LETTERPRESS = "/api/superadmin/letterpress";
5120
5128
  const CODING_TELEMETRY = "/api/superadmin/coding-telemetry";
5121
5129
  const ENGINE_USAGE =
5122
- "Usage: admin letterpress status | gaps | telemetry [--days N] [--harness h] [--all-orgs] | runs [--status s] [--error-code c] [--pr merged|closed|open|none] [--harness h] [--days N] | beyond [--limit N] [--before ISO] | fits [--recipe id] [--org id] [--site host] [--fits yes|no|unknown] [--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|explore.ask|explore.research.turns|explore.research.ms|explore.every_days> <value>";
5130
+ "Usage: admin letterpress status | gaps | telemetry [--days N] [--harness h] [--all-orgs] | runs [--status s] [--error-code c] [--pr merged|closed|open|none] [--harness h] [--days N] | beyond [--limit N] [--before ISO] | companies | company <org-id> [--site host] | facts <org-id> [--site host] | fits [--recipe id] [--org id] [--site host] [--fits yes|no|unknown] [--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|explore.ask|explore.research.turns|explore.research.ms|explore.every_days> <value>";
5123
5131
 
5124
5132
  /** One number of the settings from a dotted path and a value: the PUT body save_engine_settings reads. */
5125
5133
  function engineSettingsPatch(path, value) {
@@ -5315,6 +5323,73 @@ async function cmdAdminLetterpress(ctx) {
5315
5323
  );
5316
5324
  return 0;
5317
5325
  }
5326
+ case "companies": {
5327
+ // list_letterpress_companies: who Letterpress holds a fit for.
5328
+ const r = await staffRequest(ctx, "GET", `${LETTERPRESS}-companies?limit=${flags.limit ?? 200}`);
5329
+ printResult(io, flags, r, (x) =>
5330
+ x.companies.length
5331
+ ? x.companies
5332
+ .map(
5333
+ (c) =>
5334
+ `${(c.last_decided_at ?? "waiting").slice(0, 16).padEnd(16)} ${(c.name ?? c.host).padEnd(28)} ${c.host.padEnd(26)} fit ${String(c.yes).padStart(2)} no ${String(c.no).padStart(2)} unknown ${String(c.unknown).padStart(2)} ${c.org_id}`
5335
+ )
5336
+ .join("\n")
5337
+ : "No company has a fit yet."
5338
+ );
5339
+ return 0;
5340
+ }
5341
+ case "company": {
5342
+ // get_letterpress_company: verdicts, the facts they rest on, dismissed and left, the history.
5343
+ const org = positionals[1];
5344
+ if (!org) throw new CliError(ENGINE_USAGE);
5345
+ const q = new URLSearchParams({ org_id: org });
5346
+ if (flags.site) q.set("domain", String(flags.site));
5347
+ const r = await staffRequest(ctx, "GET", `${LETTERPRESS}-companies?${q}`);
5348
+ printResult(io, flags, r, (c) =>
5349
+ [
5350
+ `${c.org.name ?? c.org.id} · ${c.host} · ${c.beyond_library} ask${c.beyond_library === 1 ? "" : "s"} went past the library`,
5351
+ ...c.verdicts.map(
5352
+ (v) =>
5353
+ ` ${v.fits.padEnd(7)} ${v.recipe}: ${v.fits === "unknown" ? `needs ${v.needs}` : v.why} [reads ${v.reads.join(", ") || "—"}]`
5354
+ ),
5355
+ ...c.facts.stored.map(
5356
+ (f) =>
5357
+ ` fact ${f.key.padEnd(18)} ${f.read_at ? `${f.read_at.slice(0, 10)}${f.live ? "" : " (stale)"}` : "not read"} ${JSON.stringify(f.value)}`
5358
+ ),
5359
+ ...c.dismissed.map((d) => ` said ${d.kind}: ${d.recipe} (${d.at.slice(0, 10)})`),
5360
+ ...c.left.map((l) => ` shown and left ${l.times}×: ${l.recipe}`),
5361
+ ...c.runs
5362
+ .slice(0, 15)
5363
+ .map(
5364
+ (run) =>
5365
+ ` ${run.created_at.slice(0, 16)} ${(run.surface ?? "").padEnd(12)} ${run.ask}${run.beyond_library ? " [beyond the library]" : ""}`
5366
+ ),
5367
+ ].join("\n")
5368
+ );
5369
+ return 0;
5370
+ }
5371
+ case "facts": {
5372
+ // list_account_facts: what the verdicts rest on.
5373
+ const org = positionals[1];
5374
+ if (!org) throw new CliError(ENGINE_USAGE);
5375
+ const q = new URLSearchParams({ org_id: org });
5376
+ if (flags.site) q.set("domain", String(flags.site));
5377
+ const r = await staffRequest(ctx, "GET", `${LETTERPRESS}-companies?${q}`);
5378
+ printResult(io, flags, r, (c) =>
5379
+ [
5380
+ `${c.host}: facts as read${c.facts.lines_at ? `, the fit decided on those of ${c.facts.lines_at.slice(0, 16)}` : " (no fit yet)"}`,
5381
+ ...c.facts.stored.map(
5382
+ (f) =>
5383
+ ` ${f.key.padEnd(18)} ${f.read_at ? `${f.read_at.slice(0, 10)}${f.live ? "" : " (stale)"}` : "not read"} ${JSON.stringify(f.value)}`
5384
+ ),
5385
+ ...(c.facts.lines ?? []).flatMap((l) => [
5386
+ ` - ${l.line}`,
5387
+ ...(l.detail ?? []).map((d) => ` ${d}`),
5388
+ ]),
5389
+ ].join("\n")
5390
+ );
5391
+ return 0;
5392
+ }
5318
5393
  case "fits": {
5319
5394
  // list_recipe_fits: the standing fit's verdicts, one per account, site and recipe.
5320
5395
  const q = new URLSearchParams({ limit: String(flags.limit ?? 100) });
@@ -5444,9 +5519,11 @@ async function cmdAdminRecipes(ctx) {
5444
5519
  case "list": {
5445
5520
  const approach = flagStr(flags.approach);
5446
5521
  const kind = flagStr(flags.kind);
5522
+ const status = flagStr(flags.status);
5447
5523
  const query = new URLSearchParams();
5448
5524
  if (approach) query.set("approach", approach);
5449
5525
  if (kind) query.set("kind", kind);
5526
+ if (status) query.set("status", status);
5450
5527
  const recipes = query.size
5451
5528
  ? ((await staffRequest(ctx, "GET", `${RECIPES}?${query}`)).recipes ?? [])
5452
5529
  : await all();
@@ -4,6 +4,7 @@
4
4
  // ask --outcome geo|seo|… → the plan for that outcome (the Plan tab's box)
5
5
  // ask --lens fix | --lens build → what's broken (most pressing first) | what to build
6
6
  // ask "<words…>" → in your own words; what nothing does comes back as unmet
7
+ // ask "<words…>" --found "<…>" → with what you read outside the account for them (a case study)
7
8
 
8
9
  import { CliError } from "../client.mjs";
9
10
  import { argsFromFlags, flagStr, printResult, refuseUnknownFlags } from "./shared.mjs";
@@ -13,6 +14,8 @@ export const ARGS = {
13
14
  outcome: "outcome",
14
15
  lens: "lens",
15
16
  words: { value: (flags, positionals) => flagStr(flags.words) ?? (positionals.join(" ").trim() || undefined) },
17
+ // --found: what was read outside the account for the words (a case study, a competitor), as findings.
18
+ found: "found",
16
19
  // --refresh: decide every strategy again from the facts as they are now (the standing fit is read otherwise).
17
20
  refresh: { flag: "refresh", type: "bool" },
18
21
  domain: "site",
@@ -21,7 +24,7 @@ export const ARGS = {
21
24
 
22
25
  export async function cmdAsk(ctx) {
23
26
  const { client, flags, io } = ctx;
24
- refuseUnknownFlags(ctx, {}, ["outcome", "lens", "words", "site", "refresh"]);
27
+ refuseUnknownFlags(ctx, {}, ["outcome", "lens", "words", "found", "site", "refresh"]);
25
28
  const args = argsFromFlags(ARGS.ask_letterpress, flags, ctx.positionals, {});
26
29
  if ([args.outcome, args.lens, args.words].filter(Boolean).length > 1)
27
30
  throw new CliError("One ask at a time: --outcome, --lens fix|build, or your words.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.175.1",
3
+ "version": "0.175.3",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",