@letterstory/cli 0.158.1 → 0.158.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/README.md CHANGED
@@ -879,7 +879,7 @@ letterstory mailers domain <owned-domain-id> # provisioning stag
879
879
  letterstory mailers messages <mailer-id> [--folder inbox|sent|all] [--limit 25] # envelopes
880
880
  letterstory mailers message <mailer-id> <uid> --folder inbox # one message, plain-text body
881
881
  letterstory mailers forward <mailer-id> --to me@acme.com # or --clear
882
- letterstory mailers warmup start|pause <mailer-id> # 10 days to ready
882
+ letterstory mailers warmup start|pause <mailer-id> # 14+ days; ready once the warmup score reaches 85
883
883
  letterstory mailers limit <mailer-id> 40 # 0..500; refused while warming
884
884
  letterstory mailers retire <mailer-id> # disable; history kept
885
885
  letterstory mailers retire <mailer-id> --release-mailbox --yes # also delete the hosted mailbox (irreversible)
package/lib/cli.mjs CHANGED
@@ -66,7 +66,7 @@ import {
66
66
 
67
67
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
68
68
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
69
- export const VERSION = "0.158.1";
69
+ export const VERSION = "0.158.3";
70
70
 
71
71
  // Flags that never take a value. Listing them explicitly means `deploy get --json <id>`
72
72
  // can't accidentally swallow the id as --json's value. Every `type: "bool"` flag (and its
@@ -1401,7 +1401,7 @@ Mailers (the sending mailboxes):
1401
1401
  mailers message <mailer-id> <uid> --folder inbox|sent
1402
1402
  One message in full (plain-text body)
1403
1403
  mailers forward <mailer-id> (--to <email> | --clear) Copy inbound mail to an address
1404
- mailers warmup start|pause <mailer-id> Start / pause warming (10 days to ready)
1404
+ mailers warmup start|pause <mailer-id> Start / pause warming (14+ days; ready at score 85)
1405
1405
  mailers limit <mailer-id> <per-day> Daily send limit, 0..500 (not while warming)
1406
1406
  mailers retire <mailer-id> [--release-mailbox --yes] Disable a mailer; --release-mailbox also deletes
1407
1407
  the hosted mailbox (stops billing, irreversible)
@@ -1516,7 +1516,7 @@ Repo changes (Claude Code edits your repo in a sandbox; the Letter GitHub App op
1516
1516
  One PR adding Letterprove's script and identify calls
1517
1517
  (pick the repo where users sign in)
1518
1518
  repo install-visitors [--site <id>] [--repo <owner/name>] [--branch <base>] [--action build|build_pr|build_merge|slack|linear] [--wait]
1519
- One PR adding the Visitors script tag to the repo that
1519
+ One PR adding the Visitors script tag and server snippet to the repo that
1520
1520
  builds the site (--repo: another repo)
1521
1521
  repo sites [--detect [--force]] Which website each repo builds, and the evidence
1522
1522
  repo set-site --repo <owner/name> --site <host> [--not] [--branch <name>|none]
@@ -1546,15 +1546,18 @@ Feedback (tell us what's broken, missing, unclear, or wanted):
1546
1546
  [--context '<json>']
1547
1547
 
1548
1548
  Visits (Visitors: AI agents reading your site, and AI answers sending people to it):
1549
- visits [--agent <a>] [--since 7d] [--path '/docs/*'] [--purpose live|index|training|automated_browser] [--site <id>]
1550
- Agent visits: per agent, why they came, most-read pages
1551
- visits citations [--since 30d] [--site <id>] People who clicked through from ChatGPT, Claude, Perplexity…
1549
+ visits [--agent <a>] [--since 7d] [--path '/docs/*'] [--purpose live|index|training|automated_browser] [--kind page|agent_file|site_file|asset] [--paths <n>] [--site <id>]
1550
+ Agent visits: per agent, why they came, most-read paths by kind
1551
+ visits citations [--since 30d] [--site <id>] Visits that clicked through from ChatGPT, Claude, Perplexity…
1552
1552
  visits compare <agent-a> <agent-b> [--since 7d] [--path '/docs/*'] [--purpose <p>]
1553
1553
  Pages one agent read that the other didn't
1554
1554
  visits export [--since 30d] [--format json|csv] [--table agent_visits|citations]
1555
1555
  visits sites Your Visitors sites and their install checks
1556
1556
  visits pages [--since 28d] [--path '/docs/*'] [--agent <id>] [--limit <n>] [--site <id>]
1557
1557
  People and AI agents per page
1558
+ visits health --site <id> Staff: how far to trust a site's numbers, each check and its fix
1559
+ visits connect vercel|cloudflare [--site <id>] Send the host's request logs (no code to deploy)
1560
+ visits connectors | disconnect <id> The site's host connectors
1558
1561
 
1559
1562
  Sim (Simulations: a free, simulated copy of your API for agents, and what they did with it):
1560
1563
  sim [list] Your simulations and their URLs
@@ -513,7 +513,7 @@ async function repoInstallLetterprove(ctx) {
513
513
  return followRun(ctx, result.run);
514
514
  }
515
515
 
516
- /** `repo install-visitors [--site id] [--repo owner/name] [--branch b] [--wait]`: the Visitors script tag → one PR. */
516
+ /** `repo install-visitors [--site id] [--repo owner/name] [--branch b] [--wait]`: the Visitors script tag and server snippet → one PR. */
517
517
  async function repoInstallVisitors(ctx) {
518
518
  const { client, flags, io } = ctx;
519
519
  refuseUnknownFlags(ctx, {}, ["site", "repo", "owner", "name", "branch", "action", "wait"]);
@@ -5,16 +5,21 @@
5
5
  // lib functions the app and lettervisit.com/mcp call.
6
6
  //
7
7
  // letterstory visits --agent claude --since 7d
8
+ // letterstory visits --kind agent_file --paths 100 --since 7d
8
9
  // letterstory visits compare chatgpt claude --path '/docs/*' --since 7d
9
10
  // letterstory visits citations --since 30d
10
11
  // letterstory visits export --since 30d --format csv
11
12
  // letterstory visits sites
12
13
  // letterstory visits pages --since 28d [--path '/docs/*'] [--agent openai-crawler]
14
+ // letterstory visits health --site <id> staff: how far to trust a site's numbers, and what to fix
15
+ // letterstory visits connect vercel|cloudflare send the host's request logs (no code to deploy)
16
+ // letterstory visits connectors | disconnect <id>
13
17
 
14
18
  import { CliError } from "../client.mjs";
15
19
  import { flagStr, printResult, argsFromFlags } from "./shared.mjs";
16
20
 
17
21
  const PURPOSES = ["live", "index", "training", "automated_browser", "unknown"];
22
+ const PATH_KINDS = ["page", "agent_file", "site_file", "asset"];
18
23
 
19
24
  const days = { value: (flags) => sinceDays(flags.since) };
20
25
 
@@ -26,8 +31,20 @@ export const ARGS = {
26
31
  agent: "agent",
27
32
  path: "path",
28
33
  purpose: { flag: "purpose", enum: PURPOSES },
34
+ path_kind: { flag: "kind", enum: PATH_KINDS },
35
+ paths_limit: { flag: "paths", type: "num" },
29
36
  },
30
37
  visitors_get_citations: { site_id: "site", days },
38
+ visitors_admin_coverage: { site_id: "site" },
39
+ visitors_add_connector: {
40
+ site_id: "site",
41
+ kind: { positional: 0, label: "host (vercel | cloudflare)", required: true, enum: ["vercel", "cloudflare"] },
42
+ },
43
+ visitors_list_connectors: { site_id: "site" },
44
+ visitors_remove_connector: {
45
+ site_id: "site",
46
+ connector_id: { positional: 0, label: "connector id", required: true },
47
+ },
31
48
  visitors_get_page_traffic: {
32
49
  site_id: "site",
33
50
  days,
@@ -80,11 +97,104 @@ export async function cmdVisits(ctx) {
80
97
  return visitsSites(rest);
81
98
  case "pages":
82
99
  return visitsPages(rest);
100
+ case "health":
101
+ return visitsHealth(rest);
102
+ case "connect":
103
+ return visitsConnect(rest);
104
+ case "connectors":
105
+ return visitsConnectors(rest);
106
+ case "disconnect":
107
+ return visitsDisconnect(rest);
83
108
  default:
84
- throw new CliError("Usage: visits [list|citations|compare|export|sites|pages]");
109
+ throw new CliError(
110
+ "Usage: visits [list|citations|compare|export|sites|pages|health|connect|connectors|disconnect]"
111
+ );
85
112
  }
86
113
  }
87
114
 
115
+ const STATE_WORDS = {
116
+ ok: "ok",
117
+ warn: "check",
118
+ degraded: "DEGRADED",
119
+ blind: "NOT COUNTED",
120
+ off: "off",
121
+ unknown: "too early",
122
+ };
123
+
124
+ /** What a report's numbers can't see: one line per measure, its first floor. */
125
+ function floorLines(floors) {
126
+ if (!floors?.length) return [];
127
+ return [
128
+ "",
129
+ "Floors (what these numbers can't see):",
130
+ ...floors.map((f) => ` ${f.measure.padEnd(11)} ${f.notes[0] ?? ""}`),
131
+ ];
132
+ }
133
+
134
+ async function visitsHealth(ctx) {
135
+ const { flags, io } = ctx;
136
+ if (!ctx.flags.site) throw new CliError("Usage: visits health --site <site id> (staff only)");
137
+ const result = await call(ctx, "visitors_admin_coverage");
138
+ printResult(io, flags, result, (r) => {
139
+ const lines = [
140
+ `${r.domain ?? r.site_id}: ${STATE_WORDS[r.state] ?? r.state} (checks read since ${r.since})`,
141
+ "",
142
+ ];
143
+ for (const c of r.checks ?? []) {
144
+ lines.push(
145
+ ` ${(STATE_WORDS[c.state] ?? c.state).padEnd(12)} ${c.title}${c.since ? ` (since ${c.since})` : ""}`
146
+ );
147
+ lines.push(` ${c.detail}`);
148
+ if (c.fix) lines.push(` Fix: ${c.fix}`);
149
+ }
150
+ lines.push("", "Floors:");
151
+ for (const m of r.measures ?? []) for (const f of m.floors) lines.push(` ${m.measure.padEnd(11)} ${f}`);
152
+ if (r.unknown_agents?.length) {
153
+ lines.push("", "Unrecognized User-Agents:");
154
+ for (const u of r.unknown_agents.slice(0, 10))
155
+ lines.push(` ${String(u.requests).padStart(6)} ${u.user_agent}`);
156
+ }
157
+ return lines.join("\n");
158
+ });
159
+ return 0;
160
+ }
161
+
162
+ function connectorLines(c) {
163
+ const status = c.last_received_at ? `delivering, last ${c.last_received_at}` : "waiting for the first delivery";
164
+ return [
165
+ `${c.kind} (${c.id}): ${status}${c.received_count ? `, ${c.received_count} requests` : ""}`,
166
+ ...(c.last_error ? [` last error: ${c.last_error}`] : []),
167
+ ...c.steps.map((step, i) => ` ${i + 1}. ${step}`),
168
+ ];
169
+ }
170
+
171
+ async function visitsConnect(ctx) {
172
+ const { flags, io } = ctx;
173
+ const result = await call(ctx, "visitors_add_connector");
174
+ printResult(io, flags, result, (c) => connectorLines(c).join("\n"));
175
+ return 0;
176
+ }
177
+
178
+ async function visitsConnectors(ctx) {
179
+ const { flags, io } = ctx;
180
+ const result = await call(ctx, "visitors_list_connectors");
181
+ printResult(io, flags, result, (r) =>
182
+ r.connectors?.length
183
+ ? r.connectors.flatMap((c) => [...connectorLines(c), ""]).join("\n")
184
+ : "No host connectors. Add one: visits connect vercel|cloudflare"
185
+ );
186
+ return 0;
187
+ }
188
+
189
+ async function visitsDisconnect(ctx) {
190
+ const { flags, io } = ctx;
191
+ const result = await call(ctx, "visitors_remove_connector");
192
+ printResult(io, flags, result, (r) =>
193
+ r.removed ? "Disconnected. Remove the drain or Logpush job in the host too." : "No such connector."
194
+ );
195
+ return 0;
196
+ }
197
+
88
198
  const PURPOSE_LABELS = {
89
199
  live: "answering a user",
90
200
  index: "search index",
@@ -118,7 +228,21 @@ async function visitsList(ctx) {
118
228
  lines.push("", "Most read:");
119
229
  for (const p of r.top_paths.slice(0, 10)) lines.push(` ${String(p.total).padStart(6)} ${p.path}`);
120
230
  }
231
+ const sv = r.served;
232
+ if (sv?.total) {
233
+ const known = sv.formats.markdown + sv.formats.html + sv.formats.other;
234
+ lines.push(
235
+ "",
236
+ `Served: ${sv.formats.markdown} markdown, ${sv.formats.html} HTML${sv.formats.other ? `, ${sv.formats.other} other` : ""}${sv.formats.unknown ? `, ${sv.formats.unknown} unknown` : ""}${sv.outcomes.blocked ? ` · ${sv.outcomes.blocked} blocked` : ""}`
237
+ );
238
+ if (known)
239
+ for (const a of sv.agents.slice(0, 8))
240
+ lines.push(
241
+ ` ${a.agent.padEnd(22)} ${String(a.markdown).padStart(6)} md ${String(a.html).padStart(6)} html`
242
+ );
243
+ }
121
244
  if (!r.total) lines.push("No agent visits in this window. Is the server snippet installed? (visits sites)");
245
+ lines.push(...floorLines(r.floors));
122
246
  return lines.join("\n");
123
247
  });
124
248
  return 0;
@@ -128,13 +252,16 @@ async function visitsCitations(ctx) {
128
252
  const { flags, io } = ctx;
129
253
  const result = await call(ctx, "visitors_get_citations");
130
254
  printResult(io, flags, result, (r) => {
131
- const lines = [`${r.total} people arrived from an AI answer since ${r.since}`];
255
+ const lines = [
256
+ `${r.total} visits from an AI answer since ${r.counting_since && r.counting_since > r.since ? r.counting_since : r.since}`,
257
+ ];
132
258
  for (const s of r.by_source ?? [])
133
259
  lines.push(` ${s.source.padEnd(12)} ${String(s.visits).padStart(6)} avg ${s.avg_seconds}s`);
134
260
  if (r.top_pages?.length) {
135
261
  lines.push("", "Landing pages:");
136
262
  for (const p of r.top_pages.slice(0, 10)) lines.push(` ${String(p.visits).padStart(6)} ${p.path}`);
137
263
  }
264
+ lines.push(...floorLines(r.floors));
138
265
  return lines.join("\n");
139
266
  });
140
267
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.158.1",
3
+ "version": "0.158.3",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",