@letterstory/cli 0.176.20 → 0.176.21

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
@@ -81,7 +81,7 @@ import {
81
81
  import { fetchParkedSections, withoutParked } from "./parked.mjs";
82
82
 
83
83
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
84
- export const VERSION = "0.176.20";
84
+ export const VERSION = "0.176.21";
85
85
 
86
86
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
87
87
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -112,8 +112,10 @@ export const BOOLEAN_FLAGS = new Set([
112
112
  "start",
113
113
  // site research-builds: run now even when the stored pass is under an hour old.
114
114
  "fresh",
115
- // admin letterpress telemetry: every org, test and demo orgs included.
115
+ // admin letterpress telemetry | prs: every org, test and demo orgs included.
116
116
  "all-orgs",
117
+ // admin letterpress prs: since the first PR (all_time).
118
+ "all-time",
117
119
  // admin letterpress status | gaps: the customers' reading (no test or demo orgs).
118
120
  "customers",
119
121
  // build: repeat an open build's ask; post its progress in the org's Slack channel.
@@ -5144,7 +5144,7 @@ const ENGINE = "/api/superadmin/engine-settings";
5144
5144
  const LETTERPRESS = "/api/superadmin/letterpress";
5145
5145
  const CODING_TELEMETRY = "/api/superadmin/coding-telemetry";
5146
5146
  const ENGINE_USAGE =
5147
- "Usage: admin letterpress status | gaps | telemetry [--days N] [--harness h] [--all-orgs] | blocked [--days N] [--org id] [--all-orgs] | unblock <org-id> <host> <subject> | decisions <org-id> [--site host] [--surface plan|fix|build|site] | undo <org-id> <host> <decision-id> | runs [--status s] [--error-code c] [--first-review-cause agent|context|setup|unknown] [--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|waiting] [--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|preflight.off|explore.ask|explore.research.turns|explore.research.ms|explore.every_days> <value>";
5147
+ "Usage: admin letterpress status | gaps | telemetry [--days N] [--harness h] [--all-orgs] | prs [--days N | --from YYYY-MM-DD [--to YYYY-MM-DD] | --all-time] [--day YYYY-MM-DD] [--org id] [--state merged|open|closed] [--top N] [--tz zone] [--all-orgs] | blocked [--days N] [--org id] [--all-orgs] | unblock <org-id> <host> <subject> | decisions <org-id> [--site host] [--surface plan|fix|build|site] | undo <org-id> <host> <decision-id> | runs [--status s] [--error-code c] [--first-review-cause agent|context|setup|unknown] [--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|waiting] [--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|preflight.off|explore.ask|explore.research.turns|explore.research.ms|explore.every_days> <value>";
5148
5148
 
5149
5149
  /** One number of the settings from a dotted path and a value: the PUT body save_engine_settings reads. */
5150
5150
  function engineSettingsPatch(path, value) {
@@ -5387,6 +5387,47 @@ async function cmdAdminLetterpress(ctx) {
5387
5387
  );
5388
5388
  return 0;
5389
5389
  }
5390
+ case "prs": {
5391
+ // get_pull_requests (the days) or, with --day / --org / --state, list_pull_requests (the PRs behind them).
5392
+ const listing = flags.day || flags.org || flags.state;
5393
+ const q = new URLSearchParams({ view: listing ? "pr_list" : "prs", days: String(flags.days ?? 30) });
5394
+ for (const [flag, key] of [
5395
+ ["day", "day"],
5396
+ ["org", "org_id"],
5397
+ ["state", "state"],
5398
+ ["from", "from"],
5399
+ ["to", "to"],
5400
+ ["tz", "tz"],
5401
+ ["limit", "limit"],
5402
+ ["top", "top"],
5403
+ ])
5404
+ if (flags[flag]) q.set(key, String(flags[flag]));
5405
+ if (flagBool(flags["all-orgs"])) q.set("customers", "0");
5406
+ if (flagBool(flags["all-time"])) q.set("all_time", "1");
5407
+ const r = await staffRequest(ctx, "GET", `${CODING_TELEMETRY}?${q}`);
5408
+ const pct = (v) => (v == null ? "—" : `${Math.round(100 * v)}%`);
5409
+ printResult(io, flags, r, (x) =>
5410
+ listing
5411
+ ? x.prs.length
5412
+ ? x.prs
5413
+ .map(
5414
+ (pr) =>
5415
+ `${pr.day} ${pr.state.padEnd(7)} ${pr.door_label.padEnd(9)} ${(pr.org_name ?? pr.org_id).padEnd(20)} ${pr.title} ${pr.url}`
5416
+ )
5417
+ .join("\n")
5418
+ : "No PRs match."
5419
+ : [
5420
+ `PRs opened, ${x.since_day} to ${x.until_day} (${x.days} days, ${x.tz})${x.customer_only ? ", customers only" : ""}: ${x.totals.opened} (${x.previous.opened} the period before); merged ${x.totals.merged}, still open ${x.totals.open}, closed ${x.totals.closed}; merge rate ${pct(x.totals.merge_rate)}; median time to merge ${x.totals.median_hours_to_merge == null ? "—" : `${x.totals.median_hours_to_merge}h`}`,
5421
+ ...x.series.map(
5422
+ (d) =>
5423
+ `${d.day} ${String(d.opened).padStart(3)} opened ${String(d.merged).padStart(3)} merged ${String(d.open).padStart(3)} open ${String(d.closed).padStart(3)} closed`
5424
+ ),
5425
+ `by door: ${x.by_door.map((d) => `${d.label} ${d.opened}`).join(", ") || "—"}`,
5426
+ `top customers: ${x.top_customers.map((c) => `${c.org_name ?? c.org_id} ${c.opened}`).join(", ") || "—"}`,
5427
+ ].join("\n")
5428
+ );
5429
+ return 0;
5430
+ }
5390
5431
  case "runs": {
5391
5432
  // list_coding_runs with fleet.
5392
5433
  const q = new URLSearchParams({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.176.20",
3
+ "version": "0.176.21",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",