@letterstory/cli 0.158.1 → 0.158.2
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 +5 -4
- package/lib/commands/visits.mjs +61 -2
- package/package.json +1 -1
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.
|
|
69
|
+
export const VERSION = "0.158.2";
|
|
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
|
|
@@ -1546,15 +1546,16 @@ 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
|
|
1551
|
-
visits citations [--since 30d] [--site <id>]
|
|
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
|
|
1558
1559
|
|
|
1559
1560
|
Sim (Simulations: a free, simulated copy of your API for agents, and what they did with it):
|
|
1560
1561
|
sim [list] Your simulations and their URLs
|
package/lib/commands/visits.mjs
CHANGED
|
@@ -5,16 +5,19 @@
|
|
|
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
|
|
13
15
|
|
|
14
16
|
import { CliError } from "../client.mjs";
|
|
15
17
|
import { flagStr, printResult, argsFromFlags } from "./shared.mjs";
|
|
16
18
|
|
|
17
19
|
const PURPOSES = ["live", "index", "training", "automated_browser", "unknown"];
|
|
20
|
+
const PATH_KINDS = ["page", "agent_file", "site_file", "asset"];
|
|
18
21
|
|
|
19
22
|
const days = { value: (flags) => sinceDays(flags.since) };
|
|
20
23
|
|
|
@@ -26,8 +29,11 @@ export const ARGS = {
|
|
|
26
29
|
agent: "agent",
|
|
27
30
|
path: "path",
|
|
28
31
|
purpose: { flag: "purpose", enum: PURPOSES },
|
|
32
|
+
path_kind: { flag: "kind", enum: PATH_KINDS },
|
|
33
|
+
paths_limit: { flag: "paths", type: "num" },
|
|
29
34
|
},
|
|
30
35
|
visitors_get_citations: { site_id: "site", days },
|
|
36
|
+
visitors_admin_coverage: { site_id: "site" },
|
|
31
37
|
visitors_get_page_traffic: {
|
|
32
38
|
site_id: "site",
|
|
33
39
|
days,
|
|
@@ -80,11 +86,60 @@ export async function cmdVisits(ctx) {
|
|
|
80
86
|
return visitsSites(rest);
|
|
81
87
|
case "pages":
|
|
82
88
|
return visitsPages(rest);
|
|
89
|
+
case "health":
|
|
90
|
+
return visitsHealth(rest);
|
|
83
91
|
default:
|
|
84
|
-
throw new CliError("Usage: visits [list|citations|compare|export|sites|pages]");
|
|
92
|
+
throw new CliError("Usage: visits [list|citations|compare|export|sites|pages|health]");
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
95
|
|
|
96
|
+
const STATE_WORDS = {
|
|
97
|
+
ok: "ok",
|
|
98
|
+
warn: "check",
|
|
99
|
+
degraded: "DEGRADED",
|
|
100
|
+
blind: "NOT COUNTED",
|
|
101
|
+
off: "off",
|
|
102
|
+
unknown: "too early",
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** What a report's numbers can't see: one line per measure, its first floor. */
|
|
106
|
+
function floorLines(floors) {
|
|
107
|
+
if (!floors?.length) return [];
|
|
108
|
+
return [
|
|
109
|
+
"",
|
|
110
|
+
"Floors (what these numbers can't see):",
|
|
111
|
+
...floors.map((f) => ` ${f.measure.padEnd(11)} ${f.notes[0] ?? ""}`),
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function visitsHealth(ctx) {
|
|
116
|
+
const { flags, io } = ctx;
|
|
117
|
+
if (!ctx.flags.site) throw new CliError("Usage: visits health --site <site id> (staff only)");
|
|
118
|
+
const result = await call(ctx, "visitors_admin_coverage");
|
|
119
|
+
printResult(io, flags, result, (r) => {
|
|
120
|
+
const lines = [
|
|
121
|
+
`${r.domain ?? r.site_id}: ${STATE_WORDS[r.state] ?? r.state} (checks read since ${r.since})`,
|
|
122
|
+
"",
|
|
123
|
+
];
|
|
124
|
+
for (const c of r.checks ?? []) {
|
|
125
|
+
lines.push(
|
|
126
|
+
` ${(STATE_WORDS[c.state] ?? c.state).padEnd(12)} ${c.title}${c.since ? ` (since ${c.since})` : ""}`
|
|
127
|
+
);
|
|
128
|
+
lines.push(` ${c.detail}`);
|
|
129
|
+
if (c.fix) lines.push(` Fix: ${c.fix}`);
|
|
130
|
+
}
|
|
131
|
+
lines.push("", "Floors:");
|
|
132
|
+
for (const m of r.measures ?? []) for (const f of m.floors) lines.push(` ${m.measure.padEnd(11)} ${f}`);
|
|
133
|
+
if (r.unknown_agents?.length) {
|
|
134
|
+
lines.push("", "Unrecognized User-Agents:");
|
|
135
|
+
for (const u of r.unknown_agents.slice(0, 10))
|
|
136
|
+
lines.push(` ${String(u.requests).padStart(6)} ${u.user_agent}`);
|
|
137
|
+
}
|
|
138
|
+
return lines.join("\n");
|
|
139
|
+
});
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
142
|
+
|
|
88
143
|
const PURPOSE_LABELS = {
|
|
89
144
|
live: "answering a user",
|
|
90
145
|
index: "search index",
|
|
@@ -119,6 +174,7 @@ async function visitsList(ctx) {
|
|
|
119
174
|
for (const p of r.top_paths.slice(0, 10)) lines.push(` ${String(p.total).padStart(6)} ${p.path}`);
|
|
120
175
|
}
|
|
121
176
|
if (!r.total) lines.push("No agent visits in this window. Is the server snippet installed? (visits sites)");
|
|
177
|
+
lines.push(...floorLines(r.floors));
|
|
122
178
|
return lines.join("\n");
|
|
123
179
|
});
|
|
124
180
|
return 0;
|
|
@@ -128,13 +184,16 @@ async function visitsCitations(ctx) {
|
|
|
128
184
|
const { flags, io } = ctx;
|
|
129
185
|
const result = await call(ctx, "visitors_get_citations");
|
|
130
186
|
printResult(io, flags, result, (r) => {
|
|
131
|
-
const lines = [
|
|
187
|
+
const lines = [
|
|
188
|
+
`${r.total} visits from an AI answer since ${r.counting_since && r.counting_since > r.since ? r.counting_since : r.since}`,
|
|
189
|
+
];
|
|
132
190
|
for (const s of r.by_source ?? [])
|
|
133
191
|
lines.push(` ${s.source.padEnd(12)} ${String(s.visits).padStart(6)} avg ${s.avg_seconds}s`);
|
|
134
192
|
if (r.top_pages?.length) {
|
|
135
193
|
lines.push("", "Landing pages:");
|
|
136
194
|
for (const p of r.top_pages.slice(0, 10)) lines.push(` ${String(p.visits).padStart(6)} ${p.path}`);
|
|
137
195
|
}
|
|
196
|
+
lines.push(...floorLines(r.floors));
|
|
138
197
|
return lines.join("\n");
|
|
139
198
|
});
|
|
140
199
|
return 0;
|