@letterstory/cli 0.176.97 → 0.176.98
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 +4 -2
- package/lib/commands/admin.mjs +26 -1
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -87,7 +87,7 @@ import {
|
|
|
87
87
|
import { fetchParkedSections, withoutParked } from "./parked.mjs";
|
|
88
88
|
|
|
89
89
|
// Matches cli/package.json; publish-cli.yml rewrites both to the published version.
|
|
90
|
-
export const VERSION = "0.176.
|
|
90
|
+
export const VERSION = "0.176.98";
|
|
91
91
|
|
|
92
92
|
/** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
|
|
93
93
|
export const EXIT_PAYMENT_REQUIRED = 3;
|
|
@@ -131,7 +131,9 @@ export const BOOLEAN_FLAGS = new Set([
|
|
|
131
131
|
"start",
|
|
132
132
|
// site research-builds: run now even when the stored pass is under an hour old.
|
|
133
133
|
"fresh",
|
|
134
|
-
// admin letterpress
|
|
134
|
+
// admin letterpress tokens: today so far against yesterday and a week ago.
|
|
135
|
+
"so-far",
|
|
136
|
+
// admin letterpress telemetry | prs | tokens: every org, test and demo orgs included.
|
|
135
137
|
"all-orgs",
|
|
136
138
|
// admin letterpress prs | failures: since the first PR or build (all_time).
|
|
137
139
|
"all-time",
|
package/lib/commands/admin.mjs
CHANGED
|
@@ -5261,9 +5261,10 @@ const ENGINE = "/api/superadmin/engine-settings";
|
|
|
5261
5261
|
const LETTERPRESS = "/api/superadmin/letterpress";
|
|
5262
5262
|
const CODING_TELEMETRY = "/api/superadmin/coding-telemetry";
|
|
5263
5263
|
const PULL_REQUESTS = "/api/superadmin/pull-requests";
|
|
5264
|
+
const PLATFORM_USAGE = "/api/superadmin/usage/platform";
|
|
5264
5265
|
const BUILD_FAILURES = "/api/superadmin/build-failures";
|
|
5265
5266
|
const ENGINE_USAGE =
|
|
5266
|
-
"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] | failures [--days N | --from YYYY-MM-DD [--to YYYY-MM-DD] | --all-time] [--day YYYY-MM-DD] [--org id] [--failure ours|agent|setup|undelivered] [--cause c] [--stopped-at step] [--repo owner/name] [--slow] [--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>";
|
|
5267
|
+
"Usage: admin letterpress status | gaps | telemetry [--days N] [--harness h] [--all-orgs] | tokens [--days N] [--so-far] [--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] | failures [--days N | --from YYYY-MM-DD [--to YYYY-MM-DD] | --all-time] [--day YYYY-MM-DD] [--org id] [--failure ours|agent|setup|undelivered] [--cause c] [--stopped-at step] [--repo owner/name] [--slow] [--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>";
|
|
5267
5268
|
|
|
5268
5269
|
/** One number of the settings from a dotted path and a value: the PUT body save_engine_settings reads. */
|
|
5269
5270
|
function engineSettingsPatch(path, value) {
|
|
@@ -5506,6 +5507,30 @@ async function cmdAdminLetterpress(ctx) {
|
|
|
5506
5507
|
);
|
|
5507
5508
|
return 0;
|
|
5508
5509
|
}
|
|
5510
|
+
case "tokens": {
|
|
5511
|
+
// get_platform_usage: every customer's tokens day by day, Letterpress's on its own (Letterpress → Today).
|
|
5512
|
+
const q = new URLSearchParams({ days: String(flags.days ?? 30) });
|
|
5513
|
+
if (flagBool(flags["all-orgs"])) q.set("customers", "0");
|
|
5514
|
+
if (flagBool(flags["so-far"])) q.set("so_far", "1");
|
|
5515
|
+
const r = await staffRequest(ctx, "GET", `${PLATFORM_USAGE}?${q}`);
|
|
5516
|
+
const n = (v) => Math.round(v).toLocaleString("en-US");
|
|
5517
|
+
printResult(io, flags, r, (x) =>
|
|
5518
|
+
[
|
|
5519
|
+
`Tokens, ${x.since_day} to ${x.until_day} (${x.tz})${x.customer_only ? ", customers only" : ""}: ${n(x.totals.tokens)}, Letterpress ${n(x.totals.letterpress)}`,
|
|
5520
|
+
`by product: ${x.categories.map((c) => `${c.label} ${n(x.totals.by_category[c.key] ?? 0)}`).join(", ") || "—"}`,
|
|
5521
|
+
...x.series.map(
|
|
5522
|
+
(d) =>
|
|
5523
|
+
`${d.day} ${n(d.tokens).padStart(10)} tokens ${n(d.letterpress).padStart(8)} Letterpress`
|
|
5524
|
+
),
|
|
5525
|
+
...(x.so_far
|
|
5526
|
+
? [
|
|
5527
|
+
`today so far ${n(x.so_far.today)}; by this time yesterday ${n(x.so_far.yesterday)}, a week ago ${n(x.so_far.week_ago)}`,
|
|
5528
|
+
]
|
|
5529
|
+
: []),
|
|
5530
|
+
].join("\n")
|
|
5531
|
+
);
|
|
5532
|
+
return 0;
|
|
5533
|
+
}
|
|
5509
5534
|
case "prs": {
|
|
5510
5535
|
// get_pull_requests (the days) or, with --day / --org / --state, list_pull_requests (the PRs behind them).
|
|
5511
5536
|
const listing = flags.day || flags.org || flags.state;
|