@letterstory/cli 0.177.102 → 0.177.104

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
@@ -91,7 +91,7 @@ import {
91
91
  import { fetchParkedSections, withoutParked } from "./parked.mjs";
92
92
 
93
93
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
94
- export const VERSION = "0.177.102";
94
+ export const VERSION = "0.177.104";
95
95
 
96
96
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
97
97
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -1143,6 +1143,7 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
1143
1143
  the queries behind the answer. Needs the
1144
1144
  fleet:query capability on the staff key.
1145
1145
  admin deployments [--health down|failing|…] [--org <id>] [--q <text>] [--archived] [--test] [--no-host] [--json]
1146
+ admin deployments move <app-id> --to <org-id> (--dry-run | --yes) [--json]
1146
1147
  Every site Letter built and hosts, across every org,
1147
1148
  worst first: health, the problem, and what the host
1148
1149
  has that no app names. Needs fleet:read.
@@ -27,6 +27,7 @@
27
27
  // admin lost-posts [--code lost_guard,lost_provider|held_guard] [--days N] [--org <id>] [--limit N] [--apply] (staff)
28
28
  // admin demo guide|list|show|set|reset|check|ideas … (demo:read / demo:write)
29
29
  // admin deployments [--health down|failing|blocked|setting_up|live|paused|archived] [--org <id>] [--q <text>] [--archived] [--test] [--no-host] (fleet:read)
30
+ // admin deployments move <app-id> --to <org-id> (--dry-run | --yes) (fleet:onboard)
30
31
  // admin models runs|run|star|unstar|scoreboard|requests|request|sampling … (models:read / models:write)
31
32
  // admin replays [--org <id>] [--target <id>] [--status …] [--limit n] (fleet:read)
32
33
  // admin replay --org <id> [<response-id> | --target <id>] [--surface …] (fleet:replay)
@@ -7799,6 +7800,8 @@ const MANAGED_HEALTH = ["down", "failing", "blocked", "setting_up", "live", "pau
7799
7800
  // health and the problem in one sentence, then what the host has that no app of ours names. The
7800
7801
  // same read as Super Admin → Deployments and the staff-only `list_managed_deployments` tool.
7801
7802
  async function cmdAdminDeployments(ctx) {
7803
+ if (ctx.positionals[0] === "move")
7804
+ return cmdAdminDeploymentsMove({ ...ctx, positionals: ctx.positionals.slice(1) });
7802
7805
  const { flags, io } = ctx;
7803
7806
  const health = flagStr(flags.health);
7804
7807
  if (health !== undefined && !MANAGED_HEALTH.includes(health))
@@ -7838,6 +7841,59 @@ async function cmdAdminDeployments(ctx) {
7838
7841
  return 0;
7839
7842
  }
7840
7843
 
7844
+ // `admin deployments move <app-id> --to <org-id> (--dry-run | --yes)` — move a site Letter built and hosts to another
7845
+ // organization with its repo, domain, Visitors site, letterbase and map (docs/architecture/deployments.md, "Moving a
7846
+ // site to another organization"). --dry-run says what would move and what refuses; the move itself needs --yes. The
7847
+ // same function as Super Admin → Managed deployments' Move and the staff-only `move_deployment` tool (fleet:onboard).
7848
+ async function cmdAdminDeploymentsMove(ctx) {
7849
+ const { flags, positionals, io } = ctx;
7850
+ const id = requirePositional(positionals, 0, "app-id");
7851
+ const to = flagStr(flags.to);
7852
+ if (!to) throw new CliError("Usage: admin deployments move <app-id> --to <org-id> (--dry-run | --yes)");
7853
+ const dryRun = flagBool(flags["dry-run"]);
7854
+ if (!dryRun && !flagBool(flags.yes)) {
7855
+ io.error(
7856
+ `Moving hands the site, its repo, domain, Visitors data and letterbase to the other organization. See what moves first with --dry-run, then re-run with --yes: ${ctx.bin} admin deployments move ${id} --to ${to} --yes`
7857
+ );
7858
+ return 1;
7859
+ }
7860
+ let result;
7861
+ try {
7862
+ result = await staffPost(ctx, "/api/superadmin/deployments/move", {
7863
+ id,
7864
+ to_org_id: to,
7865
+ ...(dryRun ? { dry_run: true } : {}),
7866
+ });
7867
+ } catch (error) {
7868
+ // A refused move says every reason, as the dry run does.
7869
+ const refusals = error?.details?.refusals;
7870
+ if (!Array.isArray(refusals) || !refusals.length) throw error;
7871
+ io.error(["The site can't move now:", ...refusals.map((why) => ` ${why}`)].join("\n"));
7872
+ return 1;
7873
+ }
7874
+ printResult(io, flags, result, (r) => {
7875
+ const from = r.from_org.name ?? r.from_org.id;
7876
+ const dest = r.to_org.name ?? r.to_org.id;
7877
+ const site = r.app.domain ?? r.app.name;
7878
+ const lines = [
7879
+ r.moved
7880
+ ? `Moved ${site} from ${from} to ${dest}: ${r.rows} rows.`
7881
+ : r.refusals.length
7882
+ ? `${site} can't move from ${from} to ${dest} now:`
7883
+ : `${site} would move from ${from} to ${dest}: ${r.rows} rows. Re-run with --yes to move it.`,
7884
+ ];
7885
+ for (const why of r.refusals) lines.push(` ${why}`);
7886
+ for (const t of r.tables) lines.push(` ${String(t.rows).padStart(7)} ${t.table}`);
7887
+ if (r.left_pointing.length) {
7888
+ lines.push("Stays in the old organization, left pointing:");
7889
+ for (const k of r.left_pointing)
7890
+ lines.push(` ${String(k.rows).padStart(7)} ${k.table}.${k.column} -> ${k.of}`);
7891
+ }
7892
+ return lines.join("\n");
7893
+ });
7894
+ return result.refusals?.length && !result.moved ? 1 : 0;
7895
+ }
7896
+
7841
7897
  // `admin brand-detection <org-id>` — how the client's brand is detected in AI answers;
7842
7898
  // with --term / --exact / --exclude it SETS the exact set (replacing the inferred one),
7843
7899
  // --clear goes back to inferred (recorded as a decision, with --note as the why). Every
@@ -353,7 +353,7 @@ async function buildTalk(ctx) {
353
353
  // ——— Reading builds back: what Build's list and a build's page show ———
354
354
 
355
355
  /** Where a build stands, as the app reads it (`reading.state`: merged, pr_open, …); its steps' record only without one. */
356
- const standing = (b) => b.reading?.state ?? b.status;
356
+ const standing = (b) => b.standing ?? b.reading?.state ?? b.status;
357
357
 
358
358
  /** A build's change steps as lines: where each stands, then its preview and pull request. */
359
359
  export function buildLines(b) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.177.102",
3
+ "version": "0.177.104",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",