@letterstory/cli 0.177.72 → 0.177.74

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
@@ -90,7 +90,7 @@ import {
90
90
  import { fetchParkedSections, withoutParked } from "./parked.mjs";
91
91
 
92
92
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
93
- export const VERSION = "0.177.72";
93
+ export const VERSION = "0.177.74";
94
94
 
95
95
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
96
96
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -2124,6 +2124,11 @@ Refs (Visual Refs: other companies' brands to design something new after, apart
2124
2124
  refs brief-show <brief-id> The brief, once ready
2125
2125
 
2126
2126
  Usage data (what signed-in people do in your own app):
2127
+ usage proofs [--id <id>] Read saved proof analysis
2128
+ usage find-proofs --since <ISO> --until <ISO> [--focus <text>] Analyze actions
2129
+ usage review-proof --analysis-id <id> --card-id <id> --decision approved|dismissed
2130
+ usage discover-actions --since <ISO> --until <ISO> Event inventory from connected PostHog
2131
+ usage evaluate-action --since <ISO> --until <ISO> --definition <file.json>
2127
2132
  usage [--days 7|30|90] [--site <id>] [--limit <n>] People, companies and the features they use
2128
2133
  usage --host <app host> What to add to the app before anyone signed in
2129
2134
  usage posthog connect --project <id> --key <phx_…> [--posthog-host <h>] [--host <app host>]
package/lib/client.mjs CHANGED
@@ -48,6 +48,7 @@ function timeoutFor(kind, toolName) {
48
48
  const env = Number(process.env.LETTERSTORY_TIMEOUT_MS);
49
49
  if (Number.isFinite(env) && env > 0) return env;
50
50
  if (kind !== "tool") return REQUEST_TIMEOUT_MS;
51
+ if (["generate_proof_actions", "refresh_proof_actions"].includes(toolName)) return 660_000; // Bounded analysis plus its final source read
51
52
  if (WAKE_TOOLS.has(toolName)) return WAKE_TOOL_TIMEOUT_MS;
52
53
  return LONG_TOOLS.has(toolName) ? LONG_TOOL_TIMEOUT_MS : TOOL_TIMEOUT_MS;
53
54
  }
@@ -33,6 +33,22 @@ const repoPart = (i) => ({
33
33
  });
34
34
 
35
35
  export const ARGS = {
36
+ generate_proof_actions: {
37
+ window: { value: (flags) => ({ since: flags.since, until: flags.until }) },
38
+ focus: { flag: "focus" },
39
+ },
40
+ refresh_proof_actions: {},
41
+ get_proof_actions: { id: { flag: "id" } },
42
+ decide_proof_action: {
43
+ analysis_id: { flag: "analysis-id" },
44
+ card_id: { flag: "card-id" },
45
+ decision: { flag: "decision" },
46
+ },
47
+ discover_action_events: { window: { value: (flags) => ({ since: flags.since, until: flags.until }) } },
48
+ evaluate_action: {
49
+ window: { value: (flags) => ({ since: flags.since, until: flags.until }) },
50
+ definition: { value: (flags) => JSON.parse(readFileSync(String(flags.definition), "utf8")) },
51
+ },
36
52
  get_usage_data: {
37
53
  days: {
38
54
  value: (flags) => {
@@ -209,6 +225,25 @@ const STEP = {
209
225
 
210
226
  export async function cmdUsage(ctx) {
211
227
  const { client, flags, io } = ctx;
228
+ if (["proofs", "find-proofs", "review-proof", "refresh-proofs"].includes(ctx.positionals[0])) {
229
+ const tool = {
230
+ proofs: "get_proof_actions",
231
+ "refresh-proofs": "refresh_proof_actions",
232
+ "find-proofs": "generate_proof_actions",
233
+ "review-proof": "decide_proof_action",
234
+ }[ctx.positionals[0]];
235
+ if (tool === "generate_proof_actions" && (!flags.since || !flags.until))
236
+ throw new CliError("Use --since and --until with ISO timestamps.");
237
+ printResult(io, flags, await client.callTool(tool, argsFromFlags(ARGS[tool], flags, [])));
238
+ return 0;
239
+ }
240
+ if (["discover-actions", "evaluate-action"].includes(ctx.positionals[0])) {
241
+ const tool = ctx.positionals[0] === "discover-actions" ? "discover_action_events" : "evaluate_action";
242
+ if (!flags.since || !flags.until) throw new CliError("Use --since and --until with ISO timestamps.");
243
+ if (tool === "evaluate_action" && !flags.definition) throw new CliError("Use --definition with a JSON file.");
244
+ printResult(io, flags, await client.callTool(tool, argsFromFlags(ARGS[tool], flags, [])));
245
+ return 0;
246
+ }
212
247
  if (ctx.positionals[0] === "case-study") return cmdCaseStudy(ctx);
213
248
  if (ctx.positionals[0] === "posthog") return cmdPostHog(ctx);
214
249
  if (ctx.positionals[0] === "import-posthog") {
@@ -18,6 +18,7 @@
18
18
  // letterstory visits health --site <id> staff: how far to trust a site's numbers, and what to fix
19
19
  // letterstory visits connect vercel|cloudflare send the host's request logs (no code to deploy)
20
20
  // letterstory visits connectors | disconnect <id>
21
+ // letterstory visits shortcut [mod+e | default] your own key for Letter Edit's card (⌘L by default)
21
22
 
22
23
  import { CliError } from "../client.mjs";
23
24
  import { flagStr, printResult, argsFromFlags } from "./shared.mjs";
@@ -29,6 +30,13 @@ const days = { value: (flags) => sinceDays(flags.since) };
29
30
 
30
31
  export const ARGS = {
31
32
  visitors_list_sites: {},
33
+ get_editor_shortcut: {},
34
+ set_editor_shortcut: {
35
+ // "default" (or "reset") puts ⌘L back: the tool's null.
36
+ shortcut: {
37
+ value: (_flags, positionals) => (/^(default|reset)$/i.test(positionals[0] ?? "") ? null : positionals[0]),
38
+ },
39
+ },
32
40
  visitors_update_site: {
33
41
  site_id: "site",
34
42
  domain: { positional: 0, label: "new domain (e.g. acme.com)", required: true },
@@ -137,9 +145,11 @@ export async function cmdVisits(ctx) {
137
145
  return visitsConnectors(rest);
138
146
  case "disconnect":
139
147
  return visitsDisconnect(rest);
148
+ case "shortcut":
149
+ return visitsShortcut(rest);
140
150
  default:
141
151
  throw new CliError(
142
- "Usage: visits [list|citations|people|who|compare|export|sites|domain|pages|health|connect|connectors|disconnect]"
152
+ "Usage: visits [list|citations|people|who|compare|export|sites|domain|pages|health|connect|connectors|disconnect|shortcut]"
143
153
  );
144
154
  }
145
155
  }
@@ -448,3 +458,13 @@ async function visitsSites(ctx) {
448
458
  });
449
459
  return 0;
450
460
  }
461
+
462
+ /** Your own key for Letter Edit's card: read with no argument, set with one (mod+e, mod+shift+k), default for ⌘L. */
463
+ async function visitsShortcut(ctx) {
464
+ const { flags, io } = ctx;
465
+ const result = ctx.positionals.length
466
+ ? await call(ctx, "set_editor_shortcut")
467
+ : await call(ctx, "get_editor_shortcut");
468
+ printResult(io, flags, result, (r) => `${r.shortcut}${r.is_default ? " (default)" : ""}`);
469
+ return 0;
470
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.177.72",
3
+ "version": "0.177.74",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",