@letterstory/cli 0.176.19 → 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.19";
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,14 +112,18 @@ 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.
120
122
  "again",
121
123
  // build list: only Build's Archived tab (--open, already listed, is its Open tab).
122
124
  "archived",
125
+ // plan pending --queued: only the rows a person queued for later.
126
+ "queued",
123
127
  // ask --web: read the web in the Plan's fit for a recipe the facts can't decide (off by default).
124
128
  "web",
125
129
  "notify-slack",
@@ -1649,6 +1653,11 @@ Insights:
1649
1653
  them; each pick waits --veto-hours for a veto. Settings shown when none given.
1650
1654
  plan pending [--site host] What Auto-Plan picked and is waiting to build
1651
1655
  plan veto <proposal-id> Veto one: it is never built
1656
+ plan later <action-id> [--outcome geo|…] [--site host] Queue a Plan row for later: Auto-Plan starts it once it's ready
1657
+ plan later remove <queued-id> Take a queued row back off
1658
+ plan strategies [--site host] [--archived] The goals typed on the Plan, each a strategy
1659
+ plan strategy add "<words…>" [--site host] Keep a goal in your words as a strategy
1660
+ plan strategy archive <strategy-id> [--restore] Put one away (its card leaves the Plan), or bring it back
1652
1661
  insights summary [--period …] [--part <block>]... Measure Overview: AI named/cited rates, share of voice, search, targets
1653
1662
  insights reads [--period …] [--site all|own|phantoms|<key>]... [--path <path>] [--engine <operator>]
1654
1663
  Measure → Reads: AI engines and people reading your sites, counted one way
@@ -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({
@@ -2,6 +2,7 @@
2
2
  // this account do next. The same answer as the console's Plan, Build and Fix tabs and Slack.
3
3
  // ask → each list's head: what's broken, what to build
4
4
  // ask --outcome geo|seo|… → the plan for that outcome (the Plan tab's box)
5
+ // ask --strategy <id> → a typed strategy's next actions (plan strategies)
5
6
  // ask --lens fix | --lens build → what's broken (most pressing first) | what to build
6
7
  // ask "<words…>" → in your own words; what nothing does comes back as unmet
7
8
  // ask "<words…>" --found "<…>" → with what you read outside the account for them (a case study)
@@ -12,6 +13,8 @@ import { argsFromFlags, flagStr, printResult, refuseUnknownFlags } from "./share
12
13
  export const ARGS = {
13
14
  ask_letterpress: {
14
15
  outcome: "outcome",
16
+ // --strategy <id>: a typed strategy's next actions (plan strategies), the same door as its words.
17
+ strategy_id: "strategy",
15
18
  lens: "lens",
16
19
  words: { value: (flags, positionals) => flagStr(flags.words) ?? (positionals.join(" ").trim() || undefined) },
17
20
  // --found: what was read outside the account for the words (a case study, a competitor), as findings.
@@ -24,10 +27,10 @@ export const ARGS = {
24
27
 
25
28
  export async function cmdAsk(ctx) {
26
29
  const { client, flags, io } = ctx;
27
- refuseUnknownFlags(ctx, {}, ["outcome", "lens", "words", "found", "site", "refresh"]);
30
+ refuseUnknownFlags(ctx, {}, ["outcome", "strategy", "lens", "words", "found", "site", "refresh"]);
28
31
  const args = argsFromFlags(ARGS.ask_letterpress, flags, ctx.positionals, {});
29
- if ([args.outcome, args.lens, args.words].filter(Boolean).length > 1)
30
- throw new CliError("One ask at a time: --outcome, --lens fix|build, or your words.");
32
+ if ([args.outcome, args.strategy_id, args.lens, args.words].filter(Boolean).length > 1)
33
+ throw new CliError("One ask at a time: --outcome, --strategy <id>, --lens fix|build, or your words.");
31
34
  const result = await client.callTool("ask_letterpress", args);
32
35
  printResult(io, flags, result, (r) => {
33
36
  const lines = [r.message];
@@ -5,6 +5,11 @@
5
5
  // [--aggression low|medium|high|xhigh] [--slack-channel <C…>|none] → set_auto_plan
6
6
  // plan pending → list_auto_plan_proposals (status pending)
7
7
  // plan veto <proposal-id> → veto_auto_plan_proposal
8
+ // plan later <action-id> [--outcome geo|…] → queue_plan_action (Auto-Plan starts it once it's ready)
9
+ // plan later remove <queued-id> → unqueue_plan_action
10
+ // plan strategies [--archived] → list_plan_strategies (the goals typed on the Plan)
11
+ // plan strategy add "<words…>" → create_plan_strategy
12
+ // plan strategy archive <strategy-id> → archive_plan_strategy (--restore brings it back)
8
13
 
9
14
  import { CliError } from "../client.mjs";
10
15
  import { argsFromFlags, flagStr, printResult, refuseUnknownFlags } from "./shared.mjs";
@@ -48,10 +53,26 @@ export const ARGS = {
48
53
  },
49
54
  list_auto_plan_proposals: {
50
55
  domain: "site",
51
- status: { flag: "status", enum: ["pending", "vetoed", "started", "failed"] },
56
+ status: { flag: "status", enum: ["pending", "vetoed", "started", "failed", "done"] },
57
+ queued: { flag: "queued", type: "bool" },
52
58
  limit: { flag: "limit", type: "num" },
53
59
  },
60
+ queue_plan_action: {
61
+ domain: "site",
62
+ action_id: { positional: 0, required: true, label: "action-id" },
63
+ outcome: "outcome",
64
+ },
65
+ unqueue_plan_action: { id: { positional: 0, required: true, label: "queued-id" } },
54
66
  veto_auto_plan_proposal: { id: { positional: 0, required: true, label: "proposal-id" } },
67
+ list_plan_strategies: { domain: "site", archived: { flag: "archived", type: "bool" } },
68
+ create_plan_strategy: {
69
+ domain: "site",
70
+ words: { value: (flags, positionals) => flagStr(flags.words) ?? (positionals.join(" ").trim() || undefined) },
71
+ },
72
+ archive_plan_strategy: {
73
+ id: { positional: 0, required: true, label: "strategy-id" },
74
+ archived: { value: (flags) => (flags.restore ? false : undefined) },
75
+ },
55
76
  };
56
77
 
57
78
  const SETTING_FLAGS = ["veto-hours", "auto-merge", "aggression", "slack-channel"];
@@ -70,8 +91,23 @@ export async function cmdPlan(ctx) {
70
91
  printResult(io, flags, result, (r) => r.message);
71
92
  return 0;
72
93
  }
94
+ if (sub === "later" && rest[0] === "remove") {
95
+ refuseUnknownFlags(ctx, {}, []);
96
+ const result = await client.callTool(
97
+ "unqueue_plan_action",
98
+ argsFromFlags(ARGS.unqueue_plan_action, flags, rest.slice(1))
99
+ );
100
+ printResult(io, flags, result, (r) => r.message);
101
+ return 0;
102
+ }
103
+ if (sub === "later") {
104
+ refuseUnknownFlags(ctx, {}, ["site", "outcome"]);
105
+ const result = await client.callTool("queue_plan_action", argsFromFlags(ARGS.queue_plan_action, flags, rest));
106
+ printResult(io, flags, result, (r) => r.message);
107
+ return 0;
108
+ }
73
109
  if (sub === "pending" || sub === "proposals") {
74
- refuseUnknownFlags(ctx, {}, ["site", "status", "limit"]);
110
+ refuseUnknownFlags(ctx, {}, ["site", "status", "queued", "limit"]);
75
111
  const args = argsFromFlags(ARGS.list_auto_plan_proposals, flags, rest);
76
112
  const result = await client.callTool("list_auto_plan_proposals", {
77
113
  ...(sub === "pending" ? { status: "pending" } : {}),
@@ -79,7 +115,16 @@ export async function cmdPlan(ctx) {
79
115
  });
80
116
  printResult(io, flags, result, (r) =>
81
117
  r.proposals.length
82
- ? r.proposals.map((p) => ` ${p.status.padEnd(8)} ${p.title} (builds ${p.due_at}) ${p.id}`).join("\n")
118
+ ? r.proposals
119
+ .map(
120
+ (p) =>
121
+ ` ${p.status.padEnd(8)} ${p.title} ${
122
+ p.queued_by
123
+ ? `(later${p.waits_on ? `, waits on ${p.waits_on}` : ""})`
124
+ : `(builds ${p.due_at})`
125
+ } ${p.id}`
126
+ )
127
+ .join("\n")
83
128
  : "Nothing pending."
84
129
  );
85
130
  return 0;
@@ -93,5 +138,41 @@ export async function cmdPlan(ctx) {
93
138
  printResult(io, flags, result, (r) => r.message);
94
139
  return 0;
95
140
  }
96
- throw new CliError("Usage: plan auto [settings…] | plan pending | plan veto <proposal-id>");
141
+ if (sub === "strategies") {
142
+ refuseUnknownFlags(ctx, {}, ["site", "archived"]);
143
+ const result = await client.callTool(
144
+ "list_plan_strategies",
145
+ argsFromFlags(ARGS.list_plan_strategies, flags, rest)
146
+ );
147
+ printResult(io, flags, result, (r) =>
148
+ r.strategies.length
149
+ ? r.strategies.map((s) => ` ${s.words} ${s.id}`).join("\n")
150
+ : 'No typed strategies. Add one: plan strategy add "<your goal>"'
151
+ );
152
+ return 0;
153
+ }
154
+ if (sub === "strategy") {
155
+ const action = rest[0];
156
+ if (action === "add") {
157
+ refuseUnknownFlags(ctx, {}, ["site", "words"]);
158
+ const args = argsFromFlags(ARGS.create_plan_strategy, flags, rest.slice(1));
159
+ if (!args.words) throw new CliError('Say the goal: plan strategy add "<your goal>"');
160
+ const result = await client.callTool("create_plan_strategy", args);
161
+ printResult(io, flags, result, (r) => r.message);
162
+ return 0;
163
+ }
164
+ if (action === "archive") {
165
+ refuseUnknownFlags(ctx, {}, ["restore"]);
166
+ const result = await client.callTool(
167
+ "archive_plan_strategy",
168
+ argsFromFlags(ARGS.archive_plan_strategy, flags, rest.slice(1))
169
+ );
170
+ printResult(io, flags, result, (r) => r.message);
171
+ return 0;
172
+ }
173
+ throw new CliError('Usage: plan strategy add "<words…>" | plan strategy archive <strategy-id> [--restore]');
174
+ }
175
+ throw new CliError(
176
+ "Usage: plan auto [settings…] | plan pending | plan veto <proposal-id> | plan later <action-id> | plan later remove <id> | plan strategies | plan strategy add|archive"
177
+ );
97
178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.176.19",
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",