@letterstory/cli 0.168.1 → 0.168.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
@@ -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.1";
78
+ export const VERSION = "0.168.2";
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;
@@ -893,20 +893,27 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
893
893
  fleet:query capability on the staff key.
894
894
  admin recipes list | show <id|name> | vocab | stats Recipes: Letter's one library of direction for
895
895
  Letterpress on Plan, Build and Fix (/superadmin/recipes),
896
- five fields each: name, recipe, when to use, when not to
897
- use, weight. vocab says what each field means; stats how
896
+ each a name, a description, the recipe (what Letterpress
897
+ reads), when to use, when not to use, a weight, its tags
898
+ (approaches) and its variations (Letterpress follows one).
899
+ vocab says what each field means; stats how
898
900
  often runs followed each recipe (and the share of the
899
901
  runs that had it) and how its suggestions fare. Needs
900
902
  recipes:read.
901
903
  admin recipes list --approach <seo|geo|agent_conviction|inbound_conversion|outbound|other>
902
- One approach's recipes, read from their own words.
904
+ The recipes tagged with one approach (other: with none).
905
+ admin recipes runs <id|name> [--days 30] [--limit 100]
906
+ The runs that had the recipe to choose from, newest
907
+ first: company, what was asked, who asked, and ✓ on
908
+ the ones that used it.
903
909
  admin recipes export [--out recipes.json] The library as a file import reads back.
904
910
  admin recipes import <file> [--dry-run] Write a library in one call: each recipe matched by id,
905
911
  else name, then changed or created. --dry-run writes
906
912
  nothing. Exits 1 if any row failed.
907
- admin recipes save [<id>] [--file <recipe.json>] [--name …] [--recipe …] [--when-to-use …]
908
- [--when-not-to-use …] [--weight 1..10]
909
- Create one (no id) or change one. Needs recipes:write.
913
+ admin recipes save [<id>] [--file <recipe.json>] [--name …] [--description …] [--recipe …]
914
+ [--when-to-use …] [--when-not-to-use …] [--weight 1..10] [--approaches seo,geo]
915
+ Create one (no id) or change one; variations come from
916
+ --file. Needs recipes:write.
910
917
  admin recipes delete <id> --yes Delete for good.
911
918
  admin letterpress status [--customers] Letterpress as it runs now: per lens its mode, bar, recipes,
912
919
  runs, model and prompt hash, how often the shadow agreed,
@@ -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|vocab|export|import|save|delete … (recipes:read / recipes:write)
21
+ // admin recipes list|show|runs|vocab|export|import|save|delete … (recipes:read / recipes:write)
22
22
  // admin letterpress settings|flip|set … (recipes:read / recipes:write)
23
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)
@@ -4986,26 +4986,50 @@ async function cmdAdminRepublish(ctx) {
4986
4986
 
4987
4987
  const RECIPES = "/api/superadmin/recipes";
4988
4988
  /** The fields a recipe file carries: what import_recipes reads back. */
4989
- const RECIPE_FILE_FIELDS = ["id", "name", "recipe", "when_to_use", "when_not_to_use", "weight"];
4989
+ const RECIPE_FILE_FIELDS = [
4990
+ "id",
4991
+ "name",
4992
+ "description",
4993
+ "recipe",
4994
+ "when_to_use",
4995
+ "when_not_to_use",
4996
+ "weight",
4997
+ "approaches",
4998
+ "variations",
4999
+ ];
4990
5000
  const RECIPES_USAGE =
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";
5001
+ "Usage: admin recipes list [--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>] [--name …] [--description …] [--recipe …] [--when-to-use …] [--when-not-to-use …] [--weight 1..10] [--approaches seo,geo,…] | delete <id> --yes";
4992
5002
 
4993
5003
  const recipeForFile = (r) => Object.fromEntries(RECIPE_FILE_FIELDS.map((k) => [k, r[k]]));
4994
5004
 
4995
- /** A recipe's approaches (read from its words by the server), or "other". */
5005
+ /** A recipe's approaches (its tags), or "other". */
4996
5006
  const recipeApproaches = (r) => (r.approaches?.length ? r.approaches.join(", ") : "other");
4997
5007
 
5008
+ /** Every variation of a recipe, its own first; an untitled one takes the recipe's name. */
5009
+ const recipeVariations = (r) => [
5010
+ r,
5011
+ ...(r.variations ?? []).map((v) => ({ ...v, name: v.name || r.name, description: v.description ?? "" })),
5012
+ ];
5013
+
4998
5014
  function recipeLine(r) {
4999
- return `${String(r.weight).padStart(2)}/10 ${r.name} [${recipeApproaches(r)}] ${r.id}`;
5015
+ const more = r.variations?.length ? ` ${r.variations.length + 1} variations` : "";
5016
+ return `${String(r.weight).padStart(2)}/10 ${r.name} [${recipeApproaches(r)}]${more} ${r.id}`;
5000
5017
  }
5001
5018
 
5002
5019
  function recipeDetail(r) {
5020
+ const variations = recipeVariations(r);
5021
+ const fields = (v, pad) => [
5022
+ `${pad}description: ${v.description || "—"}`,
5023
+ `${pad}recipe: ${v.recipe || "—"}`,
5024
+ `${pad}when to use: ${v.when_to_use || "—"}`,
5025
+ `${pad}when not to use: ${v.when_not_to_use || "—"}`,
5026
+ ];
5003
5027
  return [
5004
5028
  `${r.name} weight ${r.weight}/10 ${r.id}`,
5005
- ...(r.approaches ? [` approaches: ${recipeApproaches(r)}`] : []),
5006
- ` recipe: ${r.recipe || "—"}`,
5007
- ` when to use: ${r.when_to_use || "—"}`,
5008
- ` when not to use: ${r.when_not_to_use || "—"}`,
5029
+ ` approaches: ${recipeApproaches(r)}`,
5030
+ ...(variations.length > 1
5031
+ ? variations.flatMap((v, i) => [` variation ${i + 1}: ${v.name}`, ...fields(v, " ")])
5032
+ : fields(r, " ")),
5009
5033
  ].join("\n");
5010
5034
  }
5011
5035
 
@@ -5036,10 +5060,16 @@ function recipeFromFlags(flags) {
5036
5060
  return compact({
5037
5061
  ...compact(recipeForFile(base)),
5038
5062
  name: flagStr(flags.name),
5063
+ description: flagStr(flags.description),
5039
5064
  recipe: flagStr(flags.recipe),
5040
5065
  when_to_use: flagStr(flags["when-to-use"]),
5041
5066
  when_not_to_use: flagStr(flags["when-not-to-use"]),
5042
5067
  weight: flagNum(flags.weight),
5068
+ // --approaches seo,geo sets the tags; --approaches "" clears them.
5069
+ approaches: flagStr(flags.approaches)
5070
+ ?.split(",")
5071
+ .map((a) => a.trim())
5072
+ .filter(Boolean),
5043
5073
  });
5044
5074
  }
5045
5075
 
@@ -5284,6 +5314,27 @@ async function cmdAdminRecipes(ctx) {
5284
5314
  printResult(io, flags, { recipe }, (r) => recipeDetail(r.recipe));
5285
5315
  return 0;
5286
5316
  }
5317
+ case "runs": {
5318
+ const key = requirePositional(positionals, 1, "id|name");
5319
+ const recipe = (await all()).find((r) => r.id === key || r.name === key);
5320
+ if (!recipe) throw new CliError(`No recipe with id or name "${key}".`);
5321
+ const q = new URLSearchParams();
5322
+ const days = flagNum(flags.days);
5323
+ const limit = flagNum(flags.limit);
5324
+ if (days !== undefined) q.set("days", String(days));
5325
+ if (limit !== undefined) q.set("limit", String(limit));
5326
+ const result = await staffRequest(ctx, "GET", `${RECIPES}/${recipe.id}/runs${q.size ? `?${q}` : ""}`);
5327
+ printResult(io, flags, result, (r) =>
5328
+ [
5329
+ `${r.recipe.name}: ${r.offered} run(s) had it over the last ${r.days} days, ${r.used} used it.`,
5330
+ ...r.runs.map(
5331
+ (run) =>
5332
+ `${run.used ? "✓ used" : " - "} ${run.created_at.slice(0, 16).replace("T", " ")} ${run.company.name ?? run.company.domain} (${run.company.domain}) ${run.ask}${run.started_by?.name ? ` by ${run.started_by.name}` : ""}${run.variations.length ? ` variation ${run.variations.join(", ")}` : ""} ${run.id}`
5333
+ ),
5334
+ ].join("\n")
5335
+ );
5336
+ return 0;
5337
+ }
5287
5338
  case "vocab": {
5288
5339
  const v = await staffRequest(ctx, "GET", `${RECIPES}/vocabulary`);
5289
5340
  printResult(io, flags, v, (r) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.168.1",
3
+ "version": "0.168.2",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",