@letterstory/cli 0.176.20 → 0.176.22
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 +42 -1
- package/lib/commands/repo.mjs +25 -0
- package/package.json +1 -1
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.
|
|
84
|
+
export const VERSION = "0.176.22";
|
|
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.
|
package/lib/commands/admin.mjs
CHANGED
|
@@ -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/lib/commands/repo.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// pull request by the Letter GitHub App (src/lib/repo-changes). One subcommand per tool:
|
|
3
3
|
// repo start → start_repo_change repo status → get_repo_change
|
|
4
4
|
// repo activity → get_repo_change_activity (what the sandbox is doing; --follow polls)
|
|
5
|
+
// repo diff → get_repo_change_diff (what it changed, line by line)
|
|
5
6
|
// repo list → list_repo_changes repo cancel → cancel_repo_change
|
|
6
7
|
// repo publish → publish_repo_change (Make PR on a preview)
|
|
7
8
|
// repo merge → merge_repo_change (merge its open PR, as a squash)
|
|
@@ -236,6 +237,7 @@ const ARGS = {
|
|
|
236
237
|
run_id: { positional: 0, required: true, label: "run-id" },
|
|
237
238
|
since: "since",
|
|
238
239
|
},
|
|
240
|
+
get_repo_change_diff: { run_id: { positional: 0, required: true, label: "run-id" } },
|
|
239
241
|
send_repo_change_message: {
|
|
240
242
|
run_id: { positional: 0, required: true, label: "run-id" },
|
|
241
243
|
message: {
|
|
@@ -338,6 +340,8 @@ export async function cmdRepo(ctx) {
|
|
|
338
340
|
return repoStatus(rest);
|
|
339
341
|
case "activity":
|
|
340
342
|
return repoActivity(rest);
|
|
343
|
+
case "diff":
|
|
344
|
+
return repoDiff(rest);
|
|
341
345
|
case "fix-audit":
|
|
342
346
|
return repoFixAudit(rest);
|
|
343
347
|
case "install-letterprove":
|
|
@@ -679,6 +683,27 @@ async function repoActivity(ctx) {
|
|
|
679
683
|
return 0;
|
|
680
684
|
}
|
|
681
685
|
|
|
686
|
+
/** `repo diff <run-id>`: what a change changed, line by line (--json for the tool's answer). */
|
|
687
|
+
async function repoDiff(ctx) {
|
|
688
|
+
const { client, flags, io } = ctx;
|
|
689
|
+
refuseUnknownFlags(ctx, {}, []);
|
|
690
|
+
const { diff } = await client.callTool(
|
|
691
|
+
"get_repo_change_diff",
|
|
692
|
+
argsFromFlags(ARGS.get_repo_change_diff, flags, ctx.positionals)
|
|
693
|
+
);
|
|
694
|
+
printResult(io, flags, diff, (d) =>
|
|
695
|
+
[
|
|
696
|
+
...d.files.map((f) => {
|
|
697
|
+
const counts = f.additions === null ? "" : ` +${f.additions} -${f.deletions}`;
|
|
698
|
+
return `${f.path} (${f.status})${counts}${f.patch ? `\n${f.patch}` : ""}`;
|
|
699
|
+
}),
|
|
700
|
+
...(d.message ? [d.message] : []),
|
|
701
|
+
...(d.url ? [d.url] : []),
|
|
702
|
+
].join("\n")
|
|
703
|
+
);
|
|
704
|
+
return 0;
|
|
705
|
+
}
|
|
706
|
+
|
|
682
707
|
async function repoList(ctx) {
|
|
683
708
|
const { client, flags, io } = ctx;
|
|
684
709
|
const result = await client.callTool(
|