@letterstory/cli 0.165.2 → 0.167.0

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
@@ -74,7 +74,7 @@ import {
74
74
  } from "./commands.mjs";
75
75
 
76
76
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
77
- export const VERSION = "0.165.2";
77
+ export const VERSION = "0.167.0";
78
78
 
79
79
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
80
80
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -919,14 +919,10 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
919
919
  The blind read: mark a shown item; the marks fill the case
920
920
  the run exports and the status's agreement. Needs recipes:write.
921
921
  admin letterpress settings What steers Letterpress beside the recipes: the one
922
- judgement's weights per ask and, per lens, its mode (off,
923
- shadow or live) and bar. Needs recipes:read.
924
- admin letterpress flip <build|fix|plan> <off|shadow|live>
925
- Flip a lens (Build, Fix: the one judgement; Plan: the pick
926
- with recipes as direction). Shadow: both run and are
927
- recorded on every run, today's shown; live: the new one
928
- decides. Recorded as yours. Needs recipes:write.
929
- admin letterpress set <weights.<ask>.<reading>|lenses.<lens>.mode|lenses.<lens>.bar.<reading>|lenses.<lens>.bar|asks.<lens>.ask|asks.<lens>.guidance> <value>
922
+ judgement's weights per ask, each lens's bar and read
923
+ budget, each surface's ask and guidance, the dismissal
924
+ window. Needs recipes:read.
925
+ admin letterpress 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> <value>
930
926
  Change one weight, one bar, or a lens's ask and guidance (the
931
927
  opinions Letterpress chooses by, as staff's words); the version
932
928
  bumps and the previous body is kept. Needs recipes:write.
@@ -5048,7 +5048,7 @@ function recipeFromFlags(flags) {
5048
5048
  const ENGINE = "/api/superadmin/engine-settings";
5049
5049
  const LETTERPRESS = "/api/superadmin/letterpress";
5050
5050
  const ENGINE_USAGE =
5051
- "Usage: admin letterpress status | gaps | replay <run-id> | mark <run-id> <item-id> <right|weak|wrong|lead|clear> [--note …] | settings | flip <build|fix|plan> <off|shadow|live> | set <weights.<ask>.<reading>|lenses.<lens>.mode|lenses.<lens>.bar.<reading>|lenses.<lens>.bar|lenses.<lens>.research.turns|lenses.<lens>.research.ms|asks.<lens>.ask|asks.<lens>.guidance> <value>";
5051
+ "Usage: admin letterpress status | gaps | 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> <value>";
5052
5052
 
5053
5053
  /** One number of the settings from a dotted path and a value: the PUT body save_engine_settings reads. */
5054
5054
  function engineSettingsPatch(path, value) {
@@ -5060,8 +5060,11 @@ function engineSettingsPatch(path, value) {
5060
5060
  }
5061
5061
  if (parts[0] === "asks" && (parts[2] === "ask" || parts[2] === "guidance") && parts.length === 3)
5062
5062
  return { asks: { [parts[1]]: { [parts[2]]: String(value) } } };
5063
- if (parts[0] === "lenses" && parts[2] === "mode" && parts.length === 3)
5064
- return { lenses: { [parts[1]]: { mode: String(value) } } };
5063
+ if (parts[0] === "dismissals" && parts[1] === "block_days" && parts.length === 2) {
5064
+ const n = Number(value);
5065
+ if (!Number.isInteger(n)) throw new CliError(`${path}: a whole number of days`);
5066
+ return { dismissals: { block_days: n } };
5067
+ }
5065
5068
  if (parts[0] === "lenses" && parts[2] === "bar" && parts.length === 3 && value === "none")
5066
5069
  return { lenses: { [parts[1]]: { bar: null } } };
5067
5070
  if (parts[0] === "lenses" && parts[2] === "bar" && parts.length === 4) {
@@ -5072,12 +5075,12 @@ function engineSettingsPatch(path, value) {
5072
5075
  throw new CliError(ENGINE_USAGE);
5073
5076
  }
5074
5077
 
5075
- /** The settings as a few lines: each lens's judgement and bar, then the weights per ask. */
5078
+ /** The settings as a few lines: each lens's bar and budget, the dismissal window, then the weights per ask. */
5076
5079
  function engineSettingsText(r) {
5077
5080
  const s = r.settings;
5078
5081
  const lenses = Object.entries(s.lenses).map(
5079
5082
  ([lens, l]) =>
5080
- `${lens.padEnd(6)} mode ${l.mode.padEnd(6)} bar ${
5083
+ `${lens.padEnd(6)} reads ${l.research ? `${l.research.turns} turns, ${Math.round(l.research.ms / 1000)}s` : "default"} bar ${
5081
5084
  l.bar
5082
5085
  ? Object.entries(l.bar)
5083
5086
  .map(([k, v]) => `${k}≥${v}`)
@@ -5100,7 +5103,10 @@ function engineSettingsText(r) {
5100
5103
  .map((l) => ` · ${l}`),
5101
5104
  ]);
5102
5105
  const head = `Engine settings v${r.version}${r.defaults_only ? " (the defaults; no row yet)" : ""}${r.updated_by ? ` · by ${r.updated_by}` : ""}${r.changed ? ` · changed: ${r.changed.join(", ") || "nothing"}` : ""}`;
5103
- return [head, ...lenses, "", ...weights, "", ...asks].join("\n");
5106
+ const dismissals = s.dismissals
5107
+ ? `a dismissal blocks for ${s.dismissals.block_days} days, then is dated history`
5108
+ : null;
5109
+ return [head, ...lenses, ...(dismissals ? [dismissals] : []), "", ...weights, "", ...asks].join("\n");
5104
5110
  }
5105
5111
 
5106
5112
  /**
@@ -5191,13 +5197,6 @@ async function cmdAdminLetterpress(ctx) {
5191
5197
  printResult(io, flags, result, engineSettingsText);
5192
5198
  return 0;
5193
5199
  }
5194
- case "flip": {
5195
- const [, lens, mode] = positionals;
5196
- if (!lens || !mode) throw new CliError(ENGINE_USAGE);
5197
- const result = await staffRequest(ctx, "PUT", ENGINE, { lenses: { [lens]: { mode } } });
5198
- printResult(io, flags, result, engineSettingsText);
5199
- return 0;
5200
- }
5201
5200
  case "set": {
5202
5201
  const [, path, value] = positionals;
5203
5202
  if (!path || value === undefined) throw new CliError(ENGINE_USAGE);
@@ -5410,7 +5409,8 @@ async function cmdAdminBillingLegacyUnmark(ctx) {
5410
5409
  }
5411
5410
 
5412
5411
  const FREE_USAGE = `Usage: admin billing free exposure [--json] who the free paywall covers, and who is unassigned
5413
- admin billing free backfill --why "…" [--apply] signup grant for self-serve orgs with none; a dry run unless --apply`;
5412
+ admin billing free backfill --why "…" [--apply] signup grant for self-serve orgs with none; a dry run unless --apply
5413
+ admin billing free repair-subjects --why "…" [--apply] staff-address signup subjects fixed, refused orgs granted (R1); a dry run unless --apply`;
5414
5414
 
5415
5415
  const EXPOSURE_WORDS = {
5416
5416
  needs_legacy: "pay today: need a legacy mark (admin billing legacy mark --all)",
@@ -5461,6 +5461,26 @@ async function cmdAdminBillingFree(ctx) {
5461
5461
  });
5462
5462
  return 0;
5463
5463
  }
5464
+ if (positionals[1] === "repair-subjects") {
5465
+ const why = flagStr(flags.why);
5466
+ if (!why) throw new CliError(`Say why (--why "…").\n${FREE_USAGE}`);
5467
+ const r = await staffPost(ctx, "/api/superadmin/billing/free-tokens/repair-subjects", {
5468
+ dry: !flagBool(flags.apply),
5469
+ why,
5470
+ });
5471
+ printResult(io, flags, r, (x) => {
5472
+ const granted = x.regranted.filter((g) => g.outcome === "granted" || g.outcome === "would_grant");
5473
+ const lines = [
5474
+ `${x.dry ? "Would fix" : "Fixed"} ${x.fixed.length} staff-address subject(s):`,
5475
+ ...x.fixed.map((f) => ` ${f.orgId.slice(0, 8)} ${f.from} -> ${f.to ?? "(none)"}`),
5476
+ `${x.dry ? "Would grant" : "Granted"} ${granted.length} self-serve org(s) with no signup grant:`,
5477
+ ...x.regranted.map((g) => ` ${g.orgId.slice(0, 8)} ${g.outcome}`),
5478
+ ];
5479
+ if (x.dry) lines.push("Nothing written. Run again with --apply.");
5480
+ return lines.join("\n");
5481
+ });
5482
+ return 0;
5483
+ }
5464
5484
  throw new CliError(FREE_USAGE);
5465
5485
  }
5466
5486
 
@@ -263,12 +263,13 @@ function tokenRewardsText(r) {
263
263
  return "Free tokens for actions are for workspaces on free tokens; this one is on a plan.";
264
264
  const lines = r.rewards.map(
265
265
  (x) =>
266
- ` ${x.claimed ? "✓" : x.ready === false ? "·" : "○"} ${x.action.padEnd(18)} ${String(x.tokens).padStart(6)} tokens ${x.title}${x.claimed ? " (claimed)" : x.ready === false ? " (not done yet)" : ""}`
266
+ ` ${x.claimed ? "✓" : x.ready === false ? "·" : "○"} ${x.action.padEnd(18)} ${String(x.tokens).padStart(6)} tokens ${x.title}${x.claimed ? " (earned)" : x.auto ? " (granted when done)" : x.ready === false ? " (not done yet)" : ""}`
267
267
  );
268
268
  return [
269
- `Free tokens for actions: ${r.claimedTokens} claimed, ${r.availableTokens} still to earn.`,
269
+ `Free tokens for actions: ${r.claimedTokens} earned, ${r.availableTokens} still to earn.`,
270
270
  ...lines,
271
- "Claim one: letterstory org billing rewards claim <action>",
271
+ "GitHub, GitLab, Slack and the CLI are granted on their own once done.",
272
+ "Claim the rest: letterstory org billing rewards claim <action>",
272
273
  ].join("\n");
273
274
  }
274
275
 
@@ -224,6 +224,14 @@ async function visitsList(ctx) {
224
224
  ` ${a.agent.padEnd(22)} ${String(a.total).padStart(6)}${a.verified !== null && a.verified !== undefined ? ` (${a.verified} verified)` : ""}`
225
225
  );
226
226
  }
227
+ if (r.earlier) {
228
+ lines.push(
229
+ "",
230
+ `Before ${r.baseline} (v1 count, kept apart from the above): ${r.earlier.total} visits, ${r.earlier.verified} verified`
231
+ );
232
+ for (const a of r.earlier.agents.slice(0, 8))
233
+ lines.push(` ${a.agent.padEnd(22)} ${String(a.total).padStart(6)} (${a.verified} verified)`);
234
+ }
227
235
  if (r.top_paths?.length) {
228
236
  lines.push("", "Most read:");
229
237
  for (const p of r.top_paths.slice(0, 10)) lines.push(` ${String(p.total).padStart(6)} ${p.path}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.165.2",
3
+ "version": "0.167.0",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",