@letterstory/cli 0.177.51 → 0.177.53
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 +11 -3
- package/lib/commands/models.mjs +4 -2
- package/lib/commands/usage.mjs +89 -1
- package/package.json +1 -1
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.
|
|
93
|
+
export const VERSION = "0.177.53";
|
|
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;
|
|
@@ -472,6 +472,8 @@ export const BOOLEAN_FLAGS = new Set([
|
|
|
472
472
|
"train",
|
|
473
473
|
"keep-rest",
|
|
474
474
|
"no-train",
|
|
475
|
+
// usage case-study generate --named: name the companies (counts only without it).
|
|
476
|
+
"named",
|
|
475
477
|
]);
|
|
476
478
|
|
|
477
479
|
// Tiny argv parser: `--flag value`, `--flag=value`, boolean `--flag`, and positionals.
|
|
@@ -2111,11 +2113,17 @@ Refs (Visual Refs: other companies' brands to design something new after, apart
|
|
|
2111
2113
|
Usage data (what signed-in people do in your own app):
|
|
2112
2114
|
usage [--days 7|30|90] [--site <id>] [--limit <n>] People, companies and the features they use
|
|
2113
2115
|
usage --host <app host> What to add to the app before anyone signed in
|
|
2116
|
+
usage case-study [--days 7|30|90] The patterns in your usage and the latest case study
|
|
2117
|
+
usage case-study generate [--patterns <id,id>] [--named [--companies <a.com,b.com>]]
|
|
2118
|
+
Write a case study (no company named unless --named)
|
|
2119
|
+
usage case-study publish|unpublish <id> Make it public at a link, or take it down
|
|
2120
|
+
usage case-study pr <id> --repo <owner/name> A pull request that puts it on your website
|
|
2114
2121
|
|
|
2115
2122
|
Models (your own writing models, each trained on writing you give it so it writes in your voice):
|
|
2116
2123
|
models [list] [--archived] Your models: where each stands, its links, its version
|
|
2117
|
-
models create "<name>" [--budget <usd>] [--description <d>]
|
|
2124
|
+
models create "<name>" [--budget <usd>] [--description <d>] [--base <base-id>]
|
|
2118
2125
|
Budget: the most one training run may cost (default $100)
|
|
2126
|
+
Base: qwen2.5-14b-instruct (default), qwen3.5-27b or gemma-3-27b-it
|
|
2119
2127
|
models show <id> Its links, its training and what it cost
|
|
2120
2128
|
models upload <id> <file-or-folder>… Import files, folders or ZIPs without training
|
|
2121
2129
|
models material <id> "<material or request>" [--stage-only] [--request <id>] [--from-request <id>]
|
|
@@ -2135,7 +2143,7 @@ Models (your own writing models, each trained on writing you give it so it write
|
|
|
2135
2143
|
models rewrite <id> "<source text>" Rewrite supplied prose in its trained voice
|
|
2136
2144
|
models compare <id> "<source text>" Compare your model, Astra and Claude + Skill
|
|
2137
2145
|
models write <id> "<what to write>" [--words <n>] Legacy ask-based generation
|
|
2138
|
-
models update <id> [--name <n>] [--budget <usd>] [--description <d>]
|
|
2146
|
+
models update <id> [--name <n>] [--budget <usd>] [--description <d>] [--base <base-id>]
|
|
2139
2147
|
models archive <id> | models restore <id>
|
|
2140
2148
|
|
|
2141
2149
|
Bench (Benches: open-source benchmarks on their own domains, kept running; @letterstory.com only):
|
package/lib/commands/models.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// write_with_writing_model), the same lib functions the app calls.
|
|
6
6
|
//
|
|
7
7
|
// letterstory models [list] [--archived]
|
|
8
|
-
// letterstory models create "<name>" [--budget <usd>] [--description <d>]
|
|
8
|
+
// letterstory models create "<name>" [--budget <usd>] [--description <d>] [--base qwen2.5-14b-instruct|qwen3.5-27b|gemma-3-27b-it]
|
|
9
9
|
// letterstory models show <id>
|
|
10
10
|
// letterstory models add <id> <url>… [--train]
|
|
11
11
|
// letterstory models upload <id> <file-or-folder>…
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// letterstory models train <id> [--retry]
|
|
17
17
|
// letterstory models stop <id> stop what is training
|
|
18
18
|
// letterstory models write <id> "<what to write>" [--words <n>]
|
|
19
|
-
// letterstory models update <id> [--name <n>] [--budget <usd>] [--description <d>]
|
|
19
|
+
// letterstory models update <id> [--name <n>] [--budget <usd>] [--description <d>] [--base <base-id>]
|
|
20
20
|
// letterstory models archive <id> | models restore <id>
|
|
21
21
|
|
|
22
22
|
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
@@ -35,6 +35,7 @@ export const ARGS = {
|
|
|
35
35
|
name: { value: (flags, positionals) => flagStr(flags.name) ?? (positionals.join(" ").trim() || undefined) },
|
|
36
36
|
description: "description",
|
|
37
37
|
budget_usd: { flag: "budget", type: "num" },
|
|
38
|
+
base_model: "base",
|
|
38
39
|
},
|
|
39
40
|
list_writing_models: { archived: { flag: "archived", type: "bool" } },
|
|
40
41
|
get_writing_model: { model_id: modelId },
|
|
@@ -43,6 +44,7 @@ export const ARGS = {
|
|
|
43
44
|
name: "name",
|
|
44
45
|
description: "description",
|
|
45
46
|
budget_usd: { flag: "budget", type: "num" },
|
|
47
|
+
base_model: "base",
|
|
46
48
|
archived: { internal: "models archive / models restore" },
|
|
47
49
|
},
|
|
48
50
|
add_writing_model_links: {
|
package/lib/commands/usage.mjs
CHANGED
|
@@ -5,10 +5,29 @@
|
|
|
5
5
|
// letterstory usage --host app.acme.com what to add to the app before anyone signed in
|
|
6
6
|
// letterstory usage import-posthog --project <id> --key <phx_…> [--days 90] [--host app.acme.com]
|
|
7
7
|
// [--feature-urls map.json] [--dry-run] history from your PostHog (import_posthog_usage)
|
|
8
|
+
// letterstory usage case-study [--days 7|30|90] the patterns and the latest case study
|
|
9
|
+
// letterstory usage case-study generate [--days] [--patterns a,b] [--named [--companies x.com,y.com]]
|
|
10
|
+
// letterstory usage case-study publish|unpublish <id>
|
|
11
|
+
// letterstory usage case-study pr <id> --repo <owner/name> [--base <branch>]
|
|
8
12
|
|
|
9
13
|
import { CliError } from "../client.mjs";
|
|
10
14
|
import { readFileSync } from "node:fs";
|
|
11
|
-
import { argsFromFlags, printResult } from "./shared.mjs";
|
|
15
|
+
import { argsFromFlags, flagCsv, printResult } from "./shared.mjs";
|
|
16
|
+
|
|
17
|
+
const csv = (flag) => ({
|
|
18
|
+
value: (flags) => {
|
|
19
|
+
const list = flagCsv(flags[flag]);
|
|
20
|
+
return list.length ? list : undefined;
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const repoPart = (i) => ({
|
|
24
|
+
value: (flags) => {
|
|
25
|
+
const repo = typeof flags.repo === "string" ? flags.repo : "";
|
|
26
|
+
const [owner, name] = repo.split("/");
|
|
27
|
+
if (!owner || !name) throw new CliError("--repo must be <owner/name>.");
|
|
28
|
+
return [owner, name][i];
|
|
29
|
+
},
|
|
30
|
+
});
|
|
12
31
|
|
|
13
32
|
export const ARGS = {
|
|
14
33
|
get_usage_data: {
|
|
@@ -44,8 +63,76 @@ export const ARGS = {
|
|
|
44
63
|
},
|
|
45
64
|
dry_run: { flag: "dry-run", type: "bool" },
|
|
46
65
|
},
|
|
66
|
+
get_case_study: {
|
|
67
|
+
id: { flag: "id" },
|
|
68
|
+
days: { flag: "days", type: "num" },
|
|
69
|
+
site_id: { flag: "site" },
|
|
70
|
+
},
|
|
71
|
+
generate_case_study: {
|
|
72
|
+
days: { flag: "days", type: "num" },
|
|
73
|
+
site_id: { flag: "site" },
|
|
74
|
+
patterns: csv("patterns"),
|
|
75
|
+
anonymization: { value: (flags) => (flags.named === true ? "companies_named" : "counts_only") },
|
|
76
|
+
named_companies: csv("companies"),
|
|
77
|
+
},
|
|
78
|
+
publish_case_study: { id: { positional: 0, required: true, label: "id" } },
|
|
79
|
+
unpublish_case_study: { id: { positional: 0, required: true, label: "id" } },
|
|
80
|
+
open_case_study_pr: {
|
|
81
|
+
id: { positional: 0, required: true, label: "id" },
|
|
82
|
+
repo_owner: repoPart(0),
|
|
83
|
+
repo_name: repoPart(1),
|
|
84
|
+
base_branch: { flag: "base" },
|
|
85
|
+
provider: { flag: "provider", enum: ["github", "gitlab"] },
|
|
86
|
+
},
|
|
47
87
|
};
|
|
48
88
|
|
|
89
|
+
function printCaseStudy(c) {
|
|
90
|
+
if (!c) return "No case study yet. Write one: letterstory usage case-study generate";
|
|
91
|
+
const lines = [
|
|
92
|
+
`${c.headline} (${c.status}${c.url ? `, ${c.url}` : ""})`,
|
|
93
|
+
"",
|
|
94
|
+
...c.paragraphs.flatMap((p) => [p, ""]),
|
|
95
|
+
`${c.anonymization === "counts_only" ? "No company named" : `Named: ${c.named_companies.join(", ") || "none"}`}; last ${c.days} days; id ${c.id}`,
|
|
96
|
+
];
|
|
97
|
+
return lines.join("\n");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function cmdCaseStudy(ctx) {
|
|
101
|
+
const { client, flags, io } = ctx;
|
|
102
|
+
const [, sub, ...rest] = ctx.positionals;
|
|
103
|
+
if (!sub) {
|
|
104
|
+
const result = await client.callTool("get_case_study", argsFromFlags(ARGS.get_case_study, flags, []));
|
|
105
|
+
printResult(io, flags, result, (r) =>
|
|
106
|
+
[
|
|
107
|
+
`Patterns, last ${r.days} days`,
|
|
108
|
+
...(r.patterns.length
|
|
109
|
+
? r.patterns.map((p) => ` ${p.id.padEnd(36)} ${p.fact}`)
|
|
110
|
+
: [" Not enough usage yet."]),
|
|
111
|
+
"",
|
|
112
|
+
printCaseStudy(r.case_study),
|
|
113
|
+
].join("\n")
|
|
114
|
+
);
|
|
115
|
+
return 0;
|
|
116
|
+
}
|
|
117
|
+
if (sub === "generate") {
|
|
118
|
+
const result = await client.callTool("generate_case_study", argsFromFlags(ARGS.generate_case_study, flags, []));
|
|
119
|
+
printResult(io, flags, result, printCaseStudy);
|
|
120
|
+
return 0;
|
|
121
|
+
}
|
|
122
|
+
if (sub === "publish" || sub === "unpublish") {
|
|
123
|
+
const tool = sub === "publish" ? "publish_case_study" : "unpublish_case_study";
|
|
124
|
+
const result = await client.callTool(tool, argsFromFlags(ARGS[tool], flags, rest));
|
|
125
|
+
printResult(io, flags, result, printCaseStudy);
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
if (sub === "pr") {
|
|
129
|
+
const result = await client.callTool("open_case_study_pr", argsFromFlags(ARGS.open_case_study_pr, flags, rest));
|
|
130
|
+
printResult(io, flags, result, (r) => r.message);
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
throw new CliError(`Unknown: usage case-study ${sub}. Try generate, publish, unpublish or pr.`);
|
|
134
|
+
}
|
|
135
|
+
|
|
49
136
|
const STEP = {
|
|
50
137
|
identify: "Letter's script is on the app. Add the identify line to signed-in pages:",
|
|
51
138
|
add_app: "Put this tag and the identify line on the app:",
|
|
@@ -55,6 +142,7 @@ const STEP = {
|
|
|
55
142
|
|
|
56
143
|
export async function cmdUsage(ctx) {
|
|
57
144
|
const { client, flags, io } = ctx;
|
|
145
|
+
if (ctx.positionals[0] === "case-study") return cmdCaseStudy(ctx);
|
|
58
146
|
if (ctx.positionals[0] === "import-posthog") {
|
|
59
147
|
if (!flags.project || !flags.key) throw new CliError("import-posthog needs --project and --key.");
|
|
60
148
|
const result = await client.callTool(
|