@letterstory/cli 0.161.0 → 0.163.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
@@ -67,7 +67,7 @@ import {
67
67
 
68
68
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
69
69
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
70
- export const VERSION = "0.161.0";
70
+ export const VERSION = "0.163.0";
71
71
 
72
72
  // Flags that never take a value. Listing them explicitly means `deploy get --json <id>`
73
73
  // can't accidentally swallow the id as --json's value. Every `type: "bool"` flag (and its
@@ -131,6 +131,8 @@ export const BOOLEAN_FLAGS = new Set([
131
131
  "refresh",
132
132
  "preview",
133
133
  "with-preview",
134
+ // repo …: the repo is a GitLab project (--repo group/subgroup/project).
135
+ "gitlab",
134
136
  "accept",
135
137
  "help",
136
138
  "version",
@@ -901,6 +903,9 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
901
903
  admin letterpress replay <run-id> A Build or Fix run through today's checks and settings, no
902
904
  model: what it would keep, drop and rank against what it
903
905
  showed; --json carries the run as an evals case.
906
+ admin letterpress mark <run-id> <item-id> <right|weak|wrong|lead|clear> [--note …]
907
+ The blind read: mark a shown item; the marks fill the case
908
+ the run exports and the status's agreement. Needs recipes:write.
904
909
  admin letterpress settings What steers Letterpress beside the recipes: the one
905
910
  judgement's weights per ask and, per lens, its mode (off,
906
911
  shadow or live) and bar. Needs recipes:read.
@@ -1510,8 +1515,9 @@ The Site (one model of your whole marketing site, keyed by host and path):
1510
1515
  site highlight <domain> [--off] Highlight a competitor; its changes lead the top changes
1511
1516
 
1512
1517
  Repo changes (Claude Code edits your repo in a sandbox; the Letter GitHub App opens a PR):
1513
- repo repos Repos the Letter GitHub App can reach
1514
- repo connect Is GitHub connected; the link a person opens to connect it
1518
+ repo repos [--gitlab [--search <text>] [--page n]] Repos the Letter GitHub App can reach (--gitlab: the GitLab
1519
+ projects the organization's connection can push to)
1520
+ repo connect [--gitlab] Is GitHub (or GitLab) connected; the link a person opens to connect it
1515
1521
  repo branches --repo owner/name Branches a change can start from (default first)
1516
1522
  repo prs [--repo owner/name] Every open PR (whoever opened it), longest-idle first
1517
1523
  repo suggestions Fixes found and not acted on yet, and how to start each
@@ -1529,7 +1535,7 @@ Repo changes (Claude Code edits your repo in a sandbox; the Letter GitHub App op
1529
1535
  actions, and competitors' new pages, each with a channel
1530
1536
  repo slack-targets Slack channels and people Send to Slack can use, with ids
1531
1537
  repo slack-test Post a test into the Send to Slack channel
1532
- repo start --repo <owner/name> --instructions <text>|--instructions-file <path|->
1538
+ repo start --repo <owner/name> [--gitlab] --instructions <text>|--instructions-file <path|->
1533
1539
  [--branch <base>] [--attach <path>]... [--attach-url <name>=<https url>]...
1534
1540
  [--attach-ref <path>]... [--attach-url-ref <name>=<https url>]...
1535
1541
  [--action build|build_pr|build_merge|slack|linear] [--with-preview]
@@ -1540,25 +1546,28 @@ Repo changes (Claude Code edits your repo in a sandbox; the Letter GitHub App op
1540
1546
  --harness picks the coding agent (default: the deployment's);
1541
1547
  --verifier reviews the change and has the agent fix
1542
1548
  what's blocking before it goes out;
1543
- --wait follows it to the PR
1549
+ --wait follows it to the PR;
1550
+ --gitlab: a GitLab project (--repo group/subgroup/project),
1551
+ through Settings → Integrations → GitLab
1544
1552
  repo fix-audit --issue <issue-type>... [--audit <id>] [--branch <base>] [--action build|build_pr|build_merge|slack|linear] [--wait]
1545
1553
  One PR fixing site-audit issues (repeat --issue to bundle) on every affected page,
1546
1554
  in the repo verified to build the site
1547
- repo install-letterprove --repo <owner/name> [--branch <base>] [--action build|build_pr|build_merge|slack|linear] [--wait]
1555
+ repo install-letterprove --repo <owner/name> [--gitlab] [--branch <base>] [--action build|build_pr|build_merge|slack|linear] [--wait]
1548
1556
  One PR adding Letterprove's script and identify calls
1549
1557
  (pick the repo where users sign in)
1550
- repo install-visitors [--site <id>] [--repo <owner/name>] [--branch <base>] [--action build|build_pr|build_merge|slack|linear] [--wait]
1558
+ repo install-visitors [--site <id>] [--repo <owner/name> [--gitlab]] [--branch <base>] [--action build|build_pr|build_merge|slack|linear] [--wait]
1551
1559
  One PR adding the Visitors script tag and server snippet to the repo that
1552
1560
  builds the site (--repo: another repo)
1553
1561
  repo sites [--detect [--force]] Which website each repo builds, and the evidence
1554
- repo set-site --repo <owner/name> --site <host> [--not] [--branch <name>|none]
1562
+ repo set-site --repo <owner/name> [--gitlab] --site <host> [--not] [--branch <name>|none]
1555
1563
  Say which site a repo builds (--not: correct a wrong label)
1556
- repo reset-site --repo <owner/name> --site <host> Back to automatic detection
1557
- repo secrets --repo <owner/name> Preview secrets: names and when set (never values)
1558
- repo set-secret --repo <owner/name> --secret <KEY> --value <v> | --value-file <path|->
1564
+ repo reset-site --repo <owner/name> [--gitlab] --site <host>
1565
+ Back to automatic detection
1566
+ repo secrets --repo <owner/name> [--gitlab] Preview secrets: names and when set (never values)
1567
+ repo set-secret --repo <owner/name> [--gitlab] --secret <KEY> --value <v> | --value-file <path|->
1559
1568
  Set an env var the preview site gets (use test credentials:
1560
1569
  the preview URL is public to anyone with the link)
1561
- repo delete-secret --repo <owner/name> --secret <KEY>
1570
+ repo delete-secret --repo <owner/name> [--gitlab] --secret <KEY>
1562
1571
  Delete one
1563
1572
  repo status <run-id> Phase, spend, PR link and Claude's summary
1564
1573
  repo activity <run-id> [--follow] [--since <iso>] What the sandbox is doing, line by line (--follow: until it stops)
@@ -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> | settings | flip <build|fix|plan> <off|shadow|live> | set <weights.<ask>.<reading>|lenses.<lens>.mode|lenses.<lens>.bar.<reading>|lenses.<lens>.bar|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 | flip <build|fix|plan> <off|shadow|live> | set <weights.<ask>.<reading>|lenses.<lens>.mode|lenses.<lens>.bar.<reading>|lenses.<lens>.bar|asks.<lens>.ask|asks.<lens>.guidance> <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) {
@@ -5168,6 +5168,24 @@ async function cmdAdminLetterpress(ctx) {
5168
5168
  );
5169
5169
  return 0;
5170
5170
  }
5171
+ case "mark": {
5172
+ const [, id, item, verdict] = positionals;
5173
+ if (!id || !item || !verdict) throw new CliError(ENGINE_USAGE);
5174
+ const r = await staffRequest(ctx, "POST", `${LETTERPRESS}-runs/mark`, {
5175
+ id,
5176
+ marks: [
5177
+ { item_id: item, verdict: verdict === "clear" ? null : verdict, note: flagStr(flags.note) ?? null },
5178
+ ],
5179
+ });
5180
+ printResult(
5181
+ io,
5182
+ flags,
5183
+ r,
5184
+ (x) =>
5185
+ `Run ${x.run.id}: ${x.run.marks.length} marked (${x.run.marks.map((m) => `${m.item_id} ${m.verdict}`).join(", ") || "none"})`
5186
+ );
5187
+ return 0;
5188
+ }
5171
5189
  case "settings": {
5172
5190
  const result = await staffRequest(ctx, "GET", ENGINE);
5173
5191
  printResult(io, flags, result, engineSettingsText);
@@ -5375,13 +5393,14 @@ async function cmdAdminBillingLegacy(ctx) {
5375
5393
  return 0;
5376
5394
  }
5377
5395
 
5378
- const FREE_USAGE = `Usage: admin billing free exposure [--json] who the free paywall would stop today
5396
+ const FREE_USAGE = `Usage: admin billing free exposure [--json] who the free paywall covers, and who is unassigned
5379
5397
  admin billing free backfill --why "…" [--apply] signup grant for self-serve orgs with none; a dry run unless --apply`;
5380
5398
 
5381
5399
  const EXPOSURE_WORDS = {
5382
5400
  needs_legacy: "pay today: need a legacy mark (admin billing legacy mark --all)",
5383
- self_serve_no_grant: "self-serve, no grant: blocked at once (admin billing free backfill)",
5384
- other_no_grant: "free, not paying, not self-serve, no grant: blocked at once (a person decides)",
5401
+ self_serve_no_grant:
5402
+ "self-serve, no grant: unassigned, not gated, should be on free tokens (admin billing free backfill)",
5403
+ other_no_grant: "unassigned (no grant, not self-serve): not gated, a person decides",
5385
5404
  granted: "free with a grant (as designed)",
5386
5405
  };
5387
5406
 
@@ -5598,7 +5617,7 @@ async function cmdAdminBilling(ctx) {
5598
5617
  const p = result.plan;
5599
5618
  ok(
5600
5619
  ctx,
5601
- `${result.dryRun ? "Would move" : "Moving"} ${p.orgId} from Stripe ${p.from.stripeSubscriptionId} (${p.from.product ?? "subscription"}) to Lago ${p.to.plan} at its renewal ${p.from.renewsAt}: Stripe stops then, Lago charges $${(p.to.amountCents / 100).toFixed(2)} then (${p.to.includedTokens} tokens included, overage $${p.to.overageUsdPerToken} a token).`
5620
+ `${result.dryRun ? "Would move" : "Moving"} ${p.orgId} from Stripe ${p.from.stripeSubscriptionId} (${p.from.product ?? "subscription"}) to Lago ${p.to.plan} at its renewal ${p.from.renewsAt}: Stripe stops then, Lago charges $${(p.to.amountCents / 100).toFixed(2)} then (${p.to.includedTokens} tokens included, overage $${p.to.overageUsdPerToken} a token). Bonus when it takes effect: ${(p.to.bonusTokens ?? 0).toLocaleString("en-US")} tokens (signup × ${p.to.ratio}x), once.`
5602
5621
  );
5603
5622
  printResult(io, flags, result);
5604
5623
  return 0;
@@ -9,6 +9,7 @@
9
9
  // repo say → send_repo_change_message (steer a build while its agent works)
10
10
  // repo repos → list_github_app_repos repo branches → list_repo_branches
11
11
  // repo connect → connect_github (the link a person opens to connect GitHub)
12
+ // repo repos --gitlab → list_gitlab_repos repo connect --gitlab → connect_gitlab
12
13
  // repo prs → list_open_pull_requests (every open PR, whoever opened it)
13
14
  // repo install-letterprove → letterprove_open_install_pr
14
15
  // repo install-visitors → visitors_open_install_pr
@@ -40,15 +41,29 @@ function secretValue(flags) {
40
41
  return inline === undefined ? value.replace(/\r?\n$/, "") : value;
41
42
  }
42
43
 
43
- /** `--repo owner/name` → the two schema keys; --owner/--name also work. */
44
+ /**
45
+ * `--repo owner/name` → the two schema keys; --owner/--name also work. With --gitlab the path may
46
+ * nest (`group/subgroup/project`): the owner is everything before the last slash.
47
+ */
44
48
  function splitRepo(flags) {
45
49
  const full = flagStr(flags.repo);
46
50
  if (full === undefined) return { owner: flagStr(flags.owner), name: flagStr(flags.name) };
51
+ if (flags.gitlab) {
52
+ const at = full.lastIndexOf("/");
53
+ const owner = full.slice(0, at);
54
+ const name = full.slice(at + 1);
55
+ if (at < 1 || !name) throw new CliError("--repo must be group/project (or group/subgroup/project)");
56
+ return { owner, name };
57
+ }
47
58
  const [owner, name, ...extra] = full.split("/");
48
- if (!owner || !name || extra.length) throw new CliError("--repo must be owner/name");
59
+ if (!owner || !name || extra.length)
60
+ throw new CliError("--repo must be owner/name (add --gitlab for a GitLab group/subgroup/project)");
49
61
  return { owner, name };
50
62
  }
51
63
 
64
+ /** `--gitlab`: the repo is a GitLab project; GitHub when left out. */
65
+ const provider = { value: (flags) => (flags.gitlab ? "gitlab" : undefined) };
66
+
52
67
  function issueList(flags) {
53
68
  return flagList(flags.issue)
54
69
  .flatMap((v) => v.split(","))
@@ -58,6 +73,7 @@ function issueList(flags) {
58
73
 
59
74
  const ARGS = {
60
75
  start_repo_change: {
76
+ provider,
61
77
  repo_owner: { value: (flags) => splitRepo(flags).owner },
62
78
  repo_name: { value: (flags) => splitRepo(flags).name },
63
79
  base_branch: "branch",
@@ -81,6 +97,7 @@ const ARGS = {
81
97
  list_repo_sites: {},
82
98
  detect_repo_sites: { force: { flag: "force", type: "bool" } },
83
99
  set_repo_site: {
100
+ provider,
84
101
  repo_owner: { value: (flags) => splitRepo(flags).owner },
85
102
  repo_name: { value: (flags) => splitRepo(flags).name },
86
103
  site_host: { flag: "site", required: true },
@@ -89,21 +106,25 @@ const ARGS = {
89
106
  branch: { value: (flags) => (flags.branch === "none" ? null : flagStr(flags.branch)) },
90
107
  },
91
108
  reset_repo_site: {
109
+ provider,
92
110
  repo_owner: { value: (flags) => splitRepo(flags).owner },
93
111
  repo_name: { value: (flags) => splitRepo(flags).name },
94
112
  site_host: { flag: "site", required: true },
95
113
  },
96
114
  list_repo_preview_secrets: {
115
+ provider,
97
116
  repo_owner: { value: (flags) => splitRepo(flags).owner },
98
117
  repo_name: { value: (flags) => splitRepo(flags).name },
99
118
  },
100
119
  set_repo_preview_secret: {
120
+ provider,
101
121
  repo_owner: { value: (flags) => splitRepo(flags).owner },
102
122
  repo_name: { value: (flags) => splitRepo(flags).name },
103
123
  key: { flag: "secret", required: true },
104
124
  value: { value: (flags) => secretValue(flags) },
105
125
  },
106
126
  delete_repo_preview_secret: {
127
+ provider,
107
128
  repo_owner: { value: (flags) => splitRepo(flags).owner },
108
129
  repo_name: { value: (flags) => splitRepo(flags).name },
109
130
  key: { flag: "secret", required: true },
@@ -118,12 +139,14 @@ const ARGS = {
118
139
  preview: { flag: "preview", type: "bool" },
119
140
  },
120
141
  letterprove_open_install_pr: {
142
+ provider,
121
143
  repo_owner: { value: (flags) => splitRepo(flags).owner },
122
144
  repo_name: { value: (flags) => splitRepo(flags).name },
123
145
  base_branch: "branch",
124
146
  action: { flag: "action", enum: ["build", "build_pr", "build_merge", "slack", "linear"] },
125
147
  },
126
148
  visitors_open_install_pr: {
149
+ provider,
127
150
  site_id: "site",
128
151
  repo_owner: { value: (flags) => splitRepo(flags).owner },
129
152
  repo_name: { value: (flags) => splitRepo(flags).name },
@@ -252,6 +275,8 @@ const ARGS = {
252
275
  },
253
276
  list_github_app_repos: {},
254
277
  connect_github: {},
278
+ list_gitlab_repos: { search: "search", page: { flag: "page", type: "num" } },
279
+ connect_gitlab: {},
255
280
  list_repo_branches: {
256
281
  repo_owner: { value: (flags) => splitRepo(flags).owner },
257
282
  repo_name: { value: (flags) => splitRepo(flags).name },
@@ -409,6 +434,7 @@ async function repoStart(ctx) {
409
434
  const { client, flags, io } = ctx;
410
435
  refuseUnknownFlags(ctx, {}, [
411
436
  "repo",
437
+ "gitlab",
412
438
  "owner",
413
439
  "name",
414
440
  "branch",
@@ -500,7 +526,7 @@ async function repoFixAudit(ctx) {
500
526
  /** `repo install-letterprove --repo owner/name [--branch b] [--wait]`: Letterprove's script + identify calls → one PR. */
501
527
  async function repoInstallLetterprove(ctx) {
502
528
  const { client, flags, io } = ctx;
503
- refuseUnknownFlags(ctx, {}, ["repo", "owner", "name", "branch", "action", "wait"]);
529
+ refuseUnknownFlags(ctx, {}, ["repo", "owner", "name", "gitlab", "branch", "action", "wait"]);
504
530
  const result = await client.callTool(
505
531
  "letterprove_open_install_pr",
506
532
  argsFromFlags(ARGS.letterprove_open_install_pr, flags, ctx.positionals)
@@ -516,7 +542,7 @@ async function repoInstallLetterprove(ctx) {
516
542
  /** `repo install-visitors [--site id] [--repo owner/name] [--branch b] [--wait]`: the Visitors script tag and server snippet → one PR. */
517
543
  async function repoInstallVisitors(ctx) {
518
544
  const { client, flags, io } = ctx;
519
- refuseUnknownFlags(ctx, {}, ["site", "repo", "owner", "name", "branch", "action", "wait"]);
545
+ refuseUnknownFlags(ctx, {}, ["site", "repo", "owner", "name", "gitlab", "branch", "action", "wait"]);
520
546
  const result = await client.callTool(
521
547
  "visitors_open_install_pr",
522
548
  argsFromFlags(ARGS.visitors_open_install_pr, flags, ctx.positionals)
@@ -551,7 +577,7 @@ async function repoSites(ctx) {
551
577
  /** `repo set-site --repo owner/name --site acme.com [--not]`: say which site a repo builds (or doesn't). */
552
578
  async function repoSetSite(ctx) {
553
579
  const { client, flags, io } = ctx;
554
- refuseUnknownFlags(ctx, {}, ["repo", "owner", "name", "site", "not", "branch"]);
580
+ refuseUnknownFlags(ctx, {}, ["repo", "owner", "name", "gitlab", "site", "not", "branch"]);
555
581
  const result = await client.callTool("set_repo_site", argsFromFlags(ARGS.set_repo_site, flags));
556
582
  ok(ctx, result.message);
557
583
  printResult(io, flags, result.site);
@@ -561,7 +587,7 @@ async function repoSetSite(ctx) {
561
587
  /** `repo reset-site --repo owner/name --site acme.com`: back to automatic detection. */
562
588
  async function repoResetSite(ctx) {
563
589
  const { client, flags, io } = ctx;
564
- refuseUnknownFlags(ctx, {}, ["repo", "owner", "name", "site"]);
590
+ refuseUnknownFlags(ctx, {}, ["repo", "owner", "name", "gitlab", "site"]);
565
591
  const result = await client.callTool("reset_repo_site", argsFromFlags(ARGS.reset_repo_site, flags));
566
592
  ok(ctx, result.message);
567
593
  printResult(io, flags, result);
@@ -571,7 +597,7 @@ async function repoResetSite(ctx) {
571
597
  /** `repo secrets --repo owner/name`: the repo's preview secrets, names and when each was set (never values). */
572
598
  async function repoSecrets(ctx) {
573
599
  const { client, flags, io } = ctx;
574
- refuseUnknownFlags(ctx, {}, ["repo", "owner", "name"]);
600
+ refuseUnknownFlags(ctx, {}, ["repo", "owner", "name", "gitlab"]);
575
601
  const result = await client.callTool(
576
602
  "list_repo_preview_secrets",
577
603
  argsFromFlags(ARGS.list_repo_preview_secrets, flags)
@@ -587,7 +613,7 @@ async function repoSecrets(ctx) {
587
613
  /** `repo set-secret --repo owner/name --secret KEY --value v | --value-file path|-`: set or overwrite one. */
588
614
  async function repoSetSecret(ctx) {
589
615
  const { client, flags, io } = ctx;
590
- refuseUnknownFlags(ctx, {}, ["repo", "owner", "name", "secret", "value", "value-file"]);
616
+ refuseUnknownFlags(ctx, {}, ["repo", "owner", "name", "gitlab", "secret", "value", "value-file"]);
591
617
  const result = await client.callTool("set_repo_preview_secret", argsFromFlags(ARGS.set_repo_preview_secret, flags));
592
618
  ok(ctx, result.message);
593
619
  printResult(io, flags, result.secret);
@@ -597,7 +623,7 @@ async function repoSetSecret(ctx) {
597
623
  /** `repo delete-secret --repo owner/name --secret KEY`: delete one. */
598
624
  async function repoDeleteSecret(ctx) {
599
625
  const { client, flags, io } = ctx;
600
- refuseUnknownFlags(ctx, {}, ["repo", "owner", "name", "secret"]);
626
+ refuseUnknownFlags(ctx, {}, ["repo", "owner", "name", "gitlab", "secret"]);
601
627
  const result = await client.callTool(
602
628
  "delete_repo_preview_secret",
603
629
  argsFromFlags(ARGS.delete_repo_preview_secret, flags)
@@ -723,6 +749,15 @@ async function repoRevise(ctx) {
723
749
 
724
750
  async function repoRepos(ctx) {
725
751
  const { client, flags, io } = ctx;
752
+ if (flags.gitlab) {
753
+ const found = await client.callTool("list_gitlab_repos", argsFromFlags(ARGS.list_gitlab_repos, flags));
754
+ printResult(io, flags, found, (r) =>
755
+ r.projects.length
756
+ ? r.projects.map((p) => `${p.path} (default ${p.defaultBranch ?? "none"})`).join("\n")
757
+ : r.message
758
+ );
759
+ return 0;
760
+ }
726
761
  const result = await client.callTool("list_github_app_repos", argsFromFlags(ARGS.list_github_app_repos, flags));
727
762
  printResult(io, flags, result, (r) =>
728
763
  r.repos.length
@@ -732,10 +767,12 @@ async function repoRepos(ctx) {
732
767
  return 0;
733
768
  }
734
769
 
735
- /** `repo connect`: whether GitHub is connected, and the link a person opens to connect it. */
770
+ /** `repo connect [--gitlab]`: whether GitHub (or GitLab) is connected, and the link a person opens to connect it. */
736
771
  async function repoConnect(ctx) {
737
772
  const { client, flags, io } = ctx;
738
- const result = await client.callTool("connect_github", argsFromFlags(ARGS.connect_github, flags));
773
+ const result = flags.gitlab
774
+ ? await client.callTool("connect_gitlab", argsFromFlags(ARGS.connect_gitlab, flags))
775
+ : await client.callTool("connect_github", argsFromFlags(ARGS.connect_github, flags));
739
776
  printResult(io, flags, result, (r) => r.message);
740
777
  return 0;
741
778
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.161.0",
3
+ "version": "0.163.0",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",