@letterstory/cli 0.175.0 → 0.175.2

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.0";
79
+ export const VERSION = "0.175.2";
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,8 @@
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)
23
+ // admin letterpress beyond [--limit N] [--before ISO] (what members asked that went past the library)
22
24
  // admin letterpress settings|flip|set … (recipes:read / recipes:write)
23
25
  // admin demo guide|list|show|set|reset|check … (demo:read / demo:write)
24
26
  // admin models runs|run|star|unstar|scoreboard|requests|request|sampling … (models:read / models:write)
@@ -5030,10 +5032,12 @@ const RECIPE_FILE_FIELDS = [
5030
5032
  "weight",
5031
5033
  "approaches",
5032
5034
  "runs",
5035
+ "status",
5036
+ "needs",
5033
5037
  "variations",
5034
5038
  ];
5035
5039
  const RECIPES_USAGE =
5036
- "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";
5037
5041
 
5038
5042
  const recipeForFile = (r) => Object.fromEntries(RECIPE_FILE_FIELDS.map((k) => [k, r[k]]));
5039
5043
 
@@ -5049,7 +5053,8 @@ const recipeVariations = (r) => [
5049
5053
  function recipeLine(r) {
5050
5054
  const more = r.variations?.length ? ` ${r.variations.length + 1} variations` : "";
5051
5055
  const kind = r.kind === "known_issue" ? " (known issue)" : "";
5052
- 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}`;
5053
5058
  }
5054
5059
 
5055
5060
  function recipeDetail(r) {
@@ -5064,6 +5069,7 @@ function recipeDetail(r) {
5064
5069
  `${r.name} weight ${r.weight}/10 ${r.id}`,
5065
5070
  ` kind: ${r.kind === "known_issue" ? "known issue (Fix's list)" : "recipe (the Plan's)"}`,
5066
5071
  ` approaches: ${recipeApproaches(r)}`,
5072
+ ` status: ${r.status === "parked" ? `parked${r.needs ? `, needs ${r.needs}` : ""}` : "live"}`,
5067
5073
  ` runs: ${r.runs || "one change to the site's code, from its own directions"}`,
5068
5074
  ...(variations.length > 1
5069
5075
  ? variations.flatMap((v, i) => [` variation ${i + 1}: ${v.name}`, ...fields(v, " ")])
@@ -5106,6 +5112,9 @@ function recipeFromFlags(flags) {
5106
5112
  weight: flagNum(flags.weight),
5107
5113
  // --runs visitors:site names the catalog action; --runs "" is one change to the site's code.
5108
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),
5109
5118
  // --approaches seo,geo sets the tags; --approaches "" clears them.
5110
5119
  approaches: flagStr(flags.approaches)
5111
5120
  ?.split(",")
@@ -5118,7 +5127,7 @@ const ENGINE = "/api/superadmin/engine-settings";
5118
5127
  const LETTERPRESS = "/api/superadmin/letterpress";
5119
5128
  const CODING_TELEMETRY = "/api/superadmin/coding-telemetry";
5120
5129
  const ENGINE_USAGE =
5121
- "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] | replay <run-id> | mark <run-id> <item-id> <right|weak|wrong|lead|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>";
5122
5131
 
5123
5132
  /** One number of the settings from a dotted path and a value: the PUT body save_engine_settings reads. */
5124
5133
  function engineSettingsPatch(path, value) {
@@ -5314,6 +5323,112 @@ async function cmdAdminLetterpress(ctx) {
5314
5323
  );
5315
5324
  return 0;
5316
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
+ }
5393
+ case "fits": {
5394
+ // list_recipe_fits: the standing fit's verdicts, one per account, site and recipe.
5395
+ const q = new URLSearchParams({ limit: String(flags.limit ?? 100) });
5396
+ if (flags.recipe) q.set("recipe_id", String(flags.recipe));
5397
+ if (flags.org) q.set("org_id", String(flags.org));
5398
+ if (flags.site) q.set("domain", String(flags.site));
5399
+ if (flags.fits) q.set("fits", String(flags.fits));
5400
+ const r = await staffRequest(ctx, "GET", `/api/superadmin/recipe-fits?${q}`);
5401
+ printResult(io, flags, r, (x) =>
5402
+ x.fits.length
5403
+ ? x.fits
5404
+ .map(
5405
+ (f) =>
5406
+ `${f.decided_at.slice(0, 16)} ${f.host} ${f.fits.padEnd(7)} ${f.recipe}: ${f.fits === "unknown" ? `needs ${f.needs}` : f.why}`
5407
+ )
5408
+ .join("\n")
5409
+ : "No verdicts match."
5410
+ );
5411
+ return 0;
5412
+ }
5413
+ case "beyond": {
5414
+ // list_letterpress_runs with beyond_library: the asks whose answer went past what the library holds.
5415
+ const q = new URLSearchParams({ beyond_library: "true", limit: String(flags.limit ?? 50) });
5416
+ if (flags.before) q.set("before", String(flags.before));
5417
+ const r = await staffRequest(ctx, "GET", `${LETTERPRESS}-runs?${q}`);
5418
+ printResult(io, flags, r, (x) =>
5419
+ x.runs.length
5420
+ ? x.runs
5421
+ .map((run) => {
5422
+ const turn = run.sequence?.turn ?? {};
5423
+ const web = (turn.web_reads ?? []).length ? ` web ${turn.web_reads.length}` : "";
5424
+ const mark = (run.marks ?? []).map((m) => m.verdict).join(",");
5425
+ return `${run.created_at.slice(0, 16)} ${run.domain || run.org_id} ${run.surface ?? ""} ${run.ask?.words ?? ""}${web}${mark ? ` [${mark}]` : ""} ${run.id}`;
5426
+ })
5427
+ .join("\n")
5428
+ : "Nothing asked has gone past the library."
5429
+ );
5430
+ return 0;
5431
+ }
5317
5432
  case "replay": {
5318
5433
  const id = positionals[1];
5319
5434
  if (!id) throw new CliError(ENGINE_USAGE);
@@ -5404,9 +5519,11 @@ async function cmdAdminRecipes(ctx) {
5404
5519
  case "list": {
5405
5520
  const approach = flagStr(flags.approach);
5406
5521
  const kind = flagStr(flags.kind);
5522
+ const status = flagStr(flags.status);
5407
5523
  const query = new URLSearchParams();
5408
5524
  if (approach) query.set("approach", approach);
5409
5525
  if (kind) query.set("kind", kind);
5526
+ if (status) query.set("status", status);
5410
5527
  const recipes = query.size
5411
5528
  ? ((await staffRequest(ctx, "GET", `${RECIPES}?${query}`)).recipes ?? [])
5412
5529
  : await all();
@@ -13,15 +13,15 @@ export const ARGS = {
13
13
  outcome: "outcome",
14
14
  lens: "lens",
15
15
  words: { value: (flags, positionals) => flagStr(flags.words) ?? (positionals.join(" ").trim() || undefined) },
16
- // --web: read the web for a recipe the facts can't decide (off by default: facts only).
17
- web: { flag: "web", type: "bool" },
16
+ // --refresh: decide every strategy again from the facts as they are now (the standing fit is read otherwise).
17
+ refresh: { flag: "refresh", type: "bool" },
18
18
  domain: "site",
19
19
  },
20
20
  };
21
21
 
22
22
  export async function cmdAsk(ctx) {
23
23
  const { client, flags, io } = ctx;
24
- refuseUnknownFlags(ctx, {}, ["outcome", "lens", "words", "site", "web"]);
24
+ refuseUnknownFlags(ctx, {}, ["outcome", "lens", "words", "site", "refresh"]);
25
25
  const args = argsFromFlags(ARGS.ask_letterpress, flags, ctx.positionals, {});
26
26
  if ([args.outcome, args.lens, args.words].filter(Boolean).length > 1)
27
27
  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.0",
3
+ "version": "0.175.2",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",