@letterstory/cli 0.177.1 → 0.177.3

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
@@ -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.177.1";
90
+ export const VERSION = "0.177.3";
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;
@@ -96,6 +96,8 @@ export const EXIT_PAYMENT_REQUIRED = 3;
96
96
  // can't accidentally swallow the id as --json's value. Every `type: "bool"` flag (and its
97
97
  // `negate` spelling) in a command's ARGS map must be listed; boolean-flags.test.ts enforces it.
98
98
  export const BOOLEAN_FLAGS = new Set([
99
+ // collection onboard: connect without drafting or scheduling.
100
+ "connect-only",
99
101
  // admin demo ideas: every live recipe, not only the Ideas that fit.
100
102
  "library",
101
103
  // admin targets check: check every target again, checked or not.
@@ -5263,8 +5263,9 @@ const CODING_TELEMETRY = "/api/superadmin/coding-telemetry";
5263
5263
  const PULL_REQUESTS = "/api/superadmin/pull-requests";
5264
5264
  const PLATFORM_USAGE = "/api/superadmin/usage/platform";
5265
5265
  const BUILD_FAILURES = "/api/superadmin/build-failures";
5266
+ const SUGGESTION_REVIEW = "/api/superadmin/suggestion-review";
5266
5267
  const ENGINE_USAGE =
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] | ideas <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>";
5268
+ "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] | ideas <org-id> [--site host] | suggestions fix|idea [--day YYYY-MM-DD] [--type key [--org id]] [--all-orgs] | suggestions flag fix|idea <type-key> [--org id --item item-id] [--note …] | suggestions clear <flag-id> | 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>";
5268
5269
 
5269
5270
  /** One number of the settings from a dotted path and a value: the PUT body save_engine_settings reads. */
5270
5271
  function engineSettingsPatch(path, value) {
@@ -5751,6 +5752,71 @@ async function cmdAdminLetterpress(ctx) {
5751
5752
  );
5752
5753
  return 0;
5753
5754
  }
5755
+ case "suggestions": {
5756
+ // get_suggestion_types (last night's Fix or Ideas rows across the fleet, by type) or, with --type,
5757
+ // list_suggestion_sightings (the rows behind one type, with why each was surfaced); flag_suggestion and
5758
+ // clear_suggestion_flag.
5759
+ const sub = positionals[1];
5760
+ if (sub === "flag") {
5761
+ const tab = positionals[2];
5762
+ const typeKey = positionals[3];
5763
+ if (!["fix", "idea"].includes(tab) || !typeKey) throw new CliError(ENGINE_USAGE);
5764
+ const r = await staffPost(
5765
+ ctx,
5766
+ SUGGESTION_REVIEW,
5767
+ compact({
5768
+ tab,
5769
+ type_key: typeKey,
5770
+ org_id: flagStr(flags.org),
5771
+ item_id: flagStr(flags.item),
5772
+ note: flagStr(flags.note),
5773
+ })
5774
+ );
5775
+ printResult(
5776
+ io,
5777
+ flags,
5778
+ r,
5779
+ (x) =>
5780
+ `Flagged ${x.flag.type_key}${x.flag.org_id ? ` for ${x.flag.org_name ?? x.flag.org_id}` : ""}: ${x.flag.id}`
5781
+ );
5782
+ return 0;
5783
+ }
5784
+ if (sub === "clear") {
5785
+ const id = positionals[2];
5786
+ if (!id) throw new CliError(ENGINE_USAGE);
5787
+ const r = await staffRequest(ctx, "DELETE", `${SUGGESTION_REVIEW}?id=${encodeURIComponent(id)}`);
5788
+ printResult(io, flags, r, () => `Cleared ${id}`);
5789
+ return 0;
5790
+ }
5791
+ if (!["fix", "idea"].includes(sub)) throw new CliError(ENGINE_USAGE);
5792
+ const q = new URLSearchParams({ tab: sub });
5793
+ if (flags.day) q.set("day", String(flags.day));
5794
+ if (flags.type) q.set("type_key", String(flags.type));
5795
+ if (flags.org) q.set("org_id", String(flags.org));
5796
+ if (flagBool(flags["all-orgs"])) q.set("customers", "0");
5797
+ const r = await staffRequest(ctx, "GET", `${SUGGESTION_REVIEW}?${q}`);
5798
+ printResult(io, flags, r, (x) =>
5799
+ flags.type
5800
+ ? x.sightings.length
5801
+ ? x.sightings
5802
+ .map(
5803
+ (s) =>
5804
+ `${(s.org_name ?? s.org_id).padEnd(22)} ${s.status.padEnd(8)} ${s.new ? "new " : " "}${s.title}\n ${s.line}${s.why?.fit ? `\n fit: ${s.why.fit.verdict}, ${s.why.fit.why}` : ""}${s.flags.length ? `\n flagged: ${s.flags.map((f) => f.note || "no note").join("; ")}` : ""}\n item ${s.item_id}`
5805
+ )
5806
+ .join("\n")
5807
+ : "No rows."
5808
+ : x.day
5809
+ ? [
5810
+ `${sub === "fix" ? "Fix" : "Ideas"}, the night of ${x.day}${x.previous_day ? ` (against ${x.previous_day})` : ""}${x.customer_only ? ", customers only" : ""}: ${x.totals.types} types, ${x.totals.rows} rows (${x.totals.new_rows} new) across ${x.totals.companies} companies; ${x.totals.new_types} new types, ${x.totals.gone_types} gone; ${x.totals.flagged} flagged`,
5811
+ ...x.types.map(
5812
+ (t) =>
5813
+ `${String(t.companies).padStart(4)} cos ${String(t.rows).padStart(5)} rows ${String(t.new_rows).padStart(4)} new ${t.label} [${t.type_key}, ${t.source}]${t.new_type ? " NEW" : ""}${t.flags.length || t.flagged_rows ? " FLAGGED" : ""} ${t.examples[0] ?? ""}`
5814
+ ),
5815
+ ].join("\n")
5816
+ : "Nothing read yet: the fleet's suggestions are read every night."
5817
+ );
5818
+ return 0;
5819
+ }
5754
5820
  case "facts": {
5755
5821
  // list_account_facts: what the verdicts rest on.
5756
5822
  const org = positionals[1];
@@ -92,6 +92,7 @@ export const ARGS = {
92
92
  // Start what the blog writes once it is read in (the starter automations, every draft for
93
93
  // review), the one accept apply_starter_automations makes. Not with --enable-planner.
94
94
  start_writing: { flag: "start-writing", type: "bool" },
95
+ connect_only: { flag: "connect-only", type: "bool" },
95
96
  },
96
97
  get_collection_onboard_status: {
97
98
  job_id: { internal: "the job id onboard_collection just returned" },
@@ -414,6 +415,13 @@ function overridesFromFlags(flags) {
414
415
  // Final readback of a collection-onboarding job — the counts the engine PERSISTED.
415
416
  function formatCollectionStatus(s) {
416
417
  const r = s.result ?? {};
418
+ if (s.connect_only)
419
+ return [
420
+ `Connection ${s.status}`,
421
+ ` collection: ${s.collection_id}`,
422
+ ...(r.publishing ? [` publishing: ${r.publishing.destination}`] : []),
423
+ ...(s.error ? [` error: ${s.error}`] : []),
424
+ ].join("\n");
417
425
  const lines = [
418
426
  `Onboarding ${s.status} at stage "${s.stage}"`,
419
427
  ` collection: ${s.collection_id}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.177.1",
3
+ "version": "0.177.3",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",