@letterstory/cli 0.176.0 → 0.176.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/org.mjs +14 -3
- package/lib/commands/visits.mjs +26 -2
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
import { fetchParkedSections, withoutParked } from "./parked.mjs";
|
|
81
81
|
|
|
82
82
|
// Matches cli/package.json; publish-cli.yml rewrites both to the published version.
|
|
83
|
-
export const VERSION = "0.176.
|
|
83
|
+
export const VERSION = "0.176.2";
|
|
84
84
|
|
|
85
85
|
/** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
|
|
86
86
|
export const EXIT_PAYMENT_REQUIRED = 3;
|
|
@@ -1307,11 +1307,12 @@ Org (the account as one file, its integrations and billing):
|
|
|
1307
1307
|
org export --split <dir> …as one file per record (for keeping config in git)
|
|
1308
1308
|
org join <dir> [--file <path>] Rebuild the bundle from a --split directory
|
|
1309
1309
|
org integrations Every integration and whether it's connected
|
|
1310
|
-
org billing [cap <dollars|off> [--why "…"] | card | request [--note "…"] | cancel [--why "…"] --yes]
|
|
1310
|
+
org billing [cap <dollars|off> [--why "…"] | card | request [--note "…"] | cancel [--why "…"] --yes | keep]
|
|
1311
1311
|
Usage billing: plan, this period against the
|
|
1312
1312
|
allowance and spend cap, failed payments; set
|
|
1313
|
-
the cap or change the card (admins), or
|
|
1314
|
-
|
|
1313
|
+
the cap or change the card (admins), cancel or
|
|
1314
|
+
keep a plan set to end (admins), or ask the
|
|
1315
|
+
admins for more
|
|
1315
1316
|
org billing usage This period by product and collection: quantities,
|
|
1316
1317
|
and tokens and dollars when billed by usage
|
|
1317
1318
|
org billing rewards [claim <action>] Free tokens for connecting Slack, signing in with the
|
package/lib/commands/org.mjs
CHANGED
|
@@ -38,6 +38,7 @@ export const ARGS = {
|
|
|
38
38
|
},
|
|
39
39
|
request_billing_tokens: { note: { flag: "note" } },
|
|
40
40
|
cancel_billing_plan: { reason: { flag: "why" } },
|
|
41
|
+
undo_billing_plan_cancel: {},
|
|
41
42
|
update_billing_card: {},
|
|
42
43
|
list_integrations: {},
|
|
43
44
|
get_linear_connection: {},
|
|
@@ -116,7 +117,8 @@ const usd = (n) => `$${Number(n).toFixed(2)}`;
|
|
|
116
117
|
* `org billing`: the org's plan on Lago, this period against its allowance and spend cap, whether
|
|
117
118
|
* it is past due, and its failed payments (get_billing_payments). `org billing cap <dollars|off>`
|
|
118
119
|
* sets the cap (set_billing_spend_cap, admins); `org billing card` links to Stripe's page for a new
|
|
119
|
-
* card (update_billing_card, admins); `org billing
|
|
120
|
+
* card (update_billing_card, admins); `org billing keep` takes back a cancel set for the period's end
|
|
121
|
+
* (undo_billing_plan_cancel, admins); `org billing request` asks the admins for more
|
|
120
122
|
* (request_billing_tokens); `org billing usage` is this period by product and collection (get_billing);
|
|
121
123
|
* `org billing invoices` is what was charged and the next invoice (get_billing_invoices).
|
|
122
124
|
*/
|
|
@@ -141,12 +143,21 @@ async function orgBilling(ctx) {
|
|
|
141
143
|
refuseUnknownFlags(ctx, ARGS.cancel_billing_plan, ["yes"]);
|
|
142
144
|
if (!flagBool(flags.yes))
|
|
143
145
|
throw new CliError(
|
|
144
|
-
"In the plan's first month this ends it now and refunds the plan fee, once per workspace (usage so far is billed; overage already charged isn't refunded). If the workspace had that refund before, the plan ends at the end of this billing period instead, with no refund. Run again with --yes to do it."
|
|
146
|
+
"In the plan's first month (its first billing period) this ends it now and refunds the plan fee, once per workspace; an unpaid first invoice is cancelled instead and doesn't use the refund (usage so far is billed; overage already charged isn't refunded). If the workspace had that refund before, the plan ends at the end of this billing period instead, with no refund. Run again with --yes to do it."
|
|
145
147
|
);
|
|
146
148
|
const result = await client.callTool("cancel_billing_plan", argsFromFlags(ARGS.cancel_billing_plan, flags, []));
|
|
147
149
|
printResult(io, flags, result, (r) => r.message);
|
|
148
150
|
return 0;
|
|
149
151
|
}
|
|
152
|
+
if (positionals[0] === "keep") {
|
|
153
|
+
refuseUnknownFlags(ctx, ARGS.undo_billing_plan_cancel, []);
|
|
154
|
+
const result = await client.callTool(
|
|
155
|
+
"undo_billing_plan_cancel",
|
|
156
|
+
argsFromFlags(ARGS.undo_billing_plan_cancel, flags, [])
|
|
157
|
+
);
|
|
158
|
+
printResult(io, flags, result, (r) => r.message);
|
|
159
|
+
return 0;
|
|
160
|
+
}
|
|
150
161
|
if (positionals[0] === "card") {
|
|
151
162
|
refuseUnknownFlags(ctx, ARGS.update_billing_card, []);
|
|
152
163
|
const result = await client.callTool("update_billing_card", argsFromFlags(ARGS.update_billing_card, flags, []));
|
|
@@ -294,7 +305,7 @@ function billingInvoicesText(r) {
|
|
|
294
305
|
const lines = [];
|
|
295
306
|
if (r.upcoming)
|
|
296
307
|
lines.push(
|
|
297
|
-
|
|
308
|
+
`${r.upcoming.final ? "Last invoice (the plan ends)" : "Next invoice"} ${r.upcoming.issuesOn}: ${usd(r.upcoming.totalUsd)} (plan ${usd(r.upcoming.planFeeUsd)}${r.upcoming.final ? "" : " in advance"} + overage ${usd(r.upcoming.overageUsd)}${r.upcoming.overagePrepaidUsd ? `, ${usd(r.upcoming.overagePrepaidUsd)} of it already charged` : ""}).`,
|
|
298
309
|
""
|
|
299
310
|
);
|
|
300
311
|
if (r.invoices.length === 0) return [...lines, "No invoices yet."].join("\n");
|
package/lib/commands/visits.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// `visits` — Visitors from a terminal: which AI agents read your site, why they
|
|
2
2
|
// came, which AI answers sent people to you, and two agents side by side. Thin
|
|
3
3
|
// wrappers over the visitors_* tools (visitors_get_agent_visits,
|
|
4
|
-
// visitors_get_citations, visitors_compare_agents, visitors_export, …), the same
|
|
4
|
+
// visitors_get_citations, visitors_get_human_visits, visitors_compare_agents, visitors_export, …), the same
|
|
5
5
|
// lib functions the app and lettervisit.com/mcp call.
|
|
6
6
|
//
|
|
7
7
|
// letterstory visits --agent claude --since 7d
|
|
8
8
|
// letterstory visits --kind agent_file --paths 100 --since 7d
|
|
9
9
|
// letterstory visits compare chatgpt claude --path '/docs/*' --since 7d
|
|
10
10
|
// letterstory visits citations --since 30d
|
|
11
|
+
// letterstory visits people --since 30d people who read the site, and how many were identified
|
|
11
12
|
// letterstory visits export --since 30d --format csv
|
|
12
13
|
// letterstory visits sites
|
|
13
14
|
// letterstory visits pages --since 28d [--path '/docs/*'] [--agent openai-crawler]
|
|
@@ -35,6 +36,7 @@ export const ARGS = {
|
|
|
35
36
|
paths_limit: { flag: "paths", type: "num" },
|
|
36
37
|
},
|
|
37
38
|
visitors_get_citations: { site_id: "site", days },
|
|
39
|
+
visitors_get_human_visits: { site_id: "site", days },
|
|
38
40
|
visitors_admin_coverage: { site_id: "site" },
|
|
39
41
|
visitors_add_connector: {
|
|
40
42
|
site_id: "site",
|
|
@@ -89,6 +91,8 @@ export async function cmdVisits(ctx) {
|
|
|
89
91
|
return visitsList(sub === undefined ? ctx : rest);
|
|
90
92
|
case "citations":
|
|
91
93
|
return visitsCitations(rest);
|
|
94
|
+
case "people":
|
|
95
|
+
return visitsPeople(rest);
|
|
92
96
|
case "compare":
|
|
93
97
|
return visitsCompare(rest);
|
|
94
98
|
case "export":
|
|
@@ -107,7 +111,7 @@ export async function cmdVisits(ctx) {
|
|
|
107
111
|
return visitsDisconnect(rest);
|
|
108
112
|
default:
|
|
109
113
|
throw new CliError(
|
|
110
|
-
"Usage: visits [list|citations|compare|export|sites|pages|health|connect|connectors|disconnect]"
|
|
114
|
+
"Usage: visits [list|citations|people|compare|export|sites|pages|health|connect|connectors|disconnect]"
|
|
111
115
|
);
|
|
112
116
|
}
|
|
113
117
|
}
|
|
@@ -279,6 +283,26 @@ async function visitsCitations(ctx) {
|
|
|
279
283
|
return 0;
|
|
280
284
|
}
|
|
281
285
|
|
|
286
|
+
async function visitsPeople(ctx) {
|
|
287
|
+
const { flags, io } = ctx;
|
|
288
|
+
const result = await call(ctx, "visitors_get_human_visits");
|
|
289
|
+
printResult(io, flags, result, (r) => {
|
|
290
|
+
if (!r.people_counted) return r.message ?? "People aren't counted for this site.";
|
|
291
|
+
const lines = [`${r.humans} page views by people, ${r.since} to ${r.until}`];
|
|
292
|
+
if (r.unique_visitors !== null)
|
|
293
|
+
lines.push(` ${r.unique_visitors} unique visitors${r.uniques_exact ? "" : " (a floor)"}`);
|
|
294
|
+
if (r.identified_people !== null) {
|
|
295
|
+
const share =
|
|
296
|
+
r.identified_share === null ? "" : ` (${(r.identified_share * 100).toFixed(1)}% of unique visitors)`;
|
|
297
|
+
lines.push(` ${r.identified_people} identified${share}`);
|
|
298
|
+
}
|
|
299
|
+
lines.push("", "Per day:");
|
|
300
|
+
for (const d of r.daily) lines.push(` ${d.day} ${String(d.humans).padStart(6)}`);
|
|
301
|
+
return lines.join("\n");
|
|
302
|
+
});
|
|
303
|
+
return 0;
|
|
304
|
+
}
|
|
305
|
+
|
|
282
306
|
async function visitsCompare(ctx) {
|
|
283
307
|
const { flags, io } = ctx;
|
|
284
308
|
const result = await call(ctx, "visitors_compare_agents");
|