@letterstory/cli 0.6.0 → 0.7.0
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 -1
- package/lib/commands/shredder.mjs +99 -0
- package/lib/commands.mjs +1 -0
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -33,10 +33,11 @@ import {
|
|
|
33
33
|
cmdPhantomJob,
|
|
34
34
|
cmdSeers,
|
|
35
35
|
cmdTemplates,
|
|
36
|
+
cmdShredder,
|
|
36
37
|
} from "./commands.mjs";
|
|
37
38
|
|
|
38
39
|
// Keep in sync with cli/package.json.
|
|
39
|
-
export const VERSION = "0.
|
|
40
|
+
export const VERSION = "0.7.0";
|
|
40
41
|
|
|
41
42
|
// Flags that never take a value. Listing them explicitly means `deploy get --json <id>`
|
|
42
43
|
// can't accidentally swallow the id as --json's value.
|
|
@@ -267,6 +268,14 @@ Content templates (compose structures seers bind via config.template_key):
|
|
|
267
268
|
templates update <template-id> [--name] [--angle] [--sections '<json>'|--sections-file <path>]
|
|
268
269
|
templates delete <template-id> --yes
|
|
269
270
|
|
|
271
|
+
Shredder (diversify content produced outside Letterstory; structure preserved):
|
|
272
|
+
shredder list Your shredder endpoints + run counts
|
|
273
|
+
shredder create --name <n> New endpoint (returns a callable public id)
|
|
274
|
+
shredder delete <endpoint-id> --yes
|
|
275
|
+
shredder run <endpoint-id> (--body <text>|--file <path>|--file -) [--coverage <0..1>] [--attempts <n>]
|
|
276
|
+
Shred prose through an endpoint (logs telemetry)
|
|
277
|
+
shredder runs [--endpoint <id>] [--limit <n>] Recent shred calls (telemetry), newest first
|
|
278
|
+
|
|
270
279
|
Insights:
|
|
271
280
|
insights site [--period 14d|30d|90d] [--collection <uuid>]
|
|
272
281
|
insights post <article-id> [--period 14d|30d|90d]
|
|
@@ -330,6 +339,7 @@ const CLIENT_COMMANDS = {
|
|
|
330
339
|
"phantom-job": cmdPhantomJob,
|
|
331
340
|
seers: cmdSeers,
|
|
332
341
|
templates: cmdTemplates,
|
|
342
|
+
shredder: cmdShredder,
|
|
333
343
|
};
|
|
334
344
|
|
|
335
345
|
// LETTERSTORY_POLL_INTERVAL_MS / LETTERSTORY_MAX_POLLS let an operator (or an
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// `shredder` — create shredder endpoints and run content produced OUTSIDE Letterstory
|
|
2
|
+
// through the cross-provider shredder. A shred rewrites each sentence across multiple
|
|
3
|
+
// LLM providers to diversify, leaving structure (headings, lists, tables) untouched, and
|
|
4
|
+
// logs every call to telemetry.
|
|
5
|
+
|
|
6
|
+
import { CliError } from "../client.mjs";
|
|
7
|
+
import {
|
|
8
|
+
flagStr,
|
|
9
|
+
flagNum,
|
|
10
|
+
requireFlag,
|
|
11
|
+
requirePositional,
|
|
12
|
+
readBodyInput,
|
|
13
|
+
printResult,
|
|
14
|
+
compact,
|
|
15
|
+
ok,
|
|
16
|
+
} from "./shared.mjs";
|
|
17
|
+
|
|
18
|
+
export async function cmdShredder(ctx) {
|
|
19
|
+
const sub = ctx.positionals[0];
|
|
20
|
+
const rest = { ...ctx, positionals: ctx.positionals.slice(1) };
|
|
21
|
+
switch (sub) {
|
|
22
|
+
case "list":
|
|
23
|
+
case "ls":
|
|
24
|
+
return shredderList(rest);
|
|
25
|
+
case "new":
|
|
26
|
+
case "create":
|
|
27
|
+
return shredderCreate(rest);
|
|
28
|
+
case "delete":
|
|
29
|
+
case "rm":
|
|
30
|
+
return shredderDelete(rest);
|
|
31
|
+
case "run":
|
|
32
|
+
case "shred":
|
|
33
|
+
return shredderRun(rest);
|
|
34
|
+
case "runs":
|
|
35
|
+
case "telemetry":
|
|
36
|
+
return shredderRuns(rest);
|
|
37
|
+
default:
|
|
38
|
+
throw new CliError(`Unknown shredder subcommand: ${sub ?? "(none)"}. Try: list, create, delete, run, runs`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function shredderList(ctx) {
|
|
43
|
+
const { client, flags, io } = ctx;
|
|
44
|
+
const result = await client.callTool("list_shredder_endpoints", {});
|
|
45
|
+
printResult(io, flags, result);
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function shredderCreate(ctx) {
|
|
50
|
+
const { client, flags, io } = ctx;
|
|
51
|
+
const name = requireFlag(flags, "name");
|
|
52
|
+
const result = await client.callTool("create_shredder_endpoint", { name });
|
|
53
|
+
ok(ctx, `Created shredder endpoint "${name}".`);
|
|
54
|
+
printResult(io, flags, result);
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function shredderDelete(ctx) {
|
|
59
|
+
const { client, positionals, flags, io } = ctx;
|
|
60
|
+
const id = requirePositional(positionals, 0, "endpoint-id");
|
|
61
|
+
if (!flags.yes) {
|
|
62
|
+
io.error(`Re-run with --yes to confirm: ${ctx.bin} shredder delete ${id} --yes`);
|
|
63
|
+
return 1;
|
|
64
|
+
}
|
|
65
|
+
const result = await client.callTool("delete_shredder_endpoint", { endpoint_id: id });
|
|
66
|
+
ok(ctx, "Shredder endpoint deleted.");
|
|
67
|
+
printResult(io, flags, result);
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function shredderRun(ctx) {
|
|
72
|
+
const { client, positionals, flags, io } = ctx;
|
|
73
|
+
const id = requirePositional(positionals, 0, "endpoint-id");
|
|
74
|
+
const text = readBodyInput(flags);
|
|
75
|
+
if (text === undefined) {
|
|
76
|
+
throw new CliError("Provide the prose to shred with --body <text>, --file <path>, or --file - (stdin).");
|
|
77
|
+
}
|
|
78
|
+
const args = compact({
|
|
79
|
+
endpoint_id: id,
|
|
80
|
+
text,
|
|
81
|
+
coverage: flagNum(flags.coverage),
|
|
82
|
+
attempts_per_unit: flagNum(flags.attempts),
|
|
83
|
+
});
|
|
84
|
+
const result = await client.callTool("run_shred", args);
|
|
85
|
+
ok(ctx, "Shred complete.");
|
|
86
|
+
printResult(io, flags, result);
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function shredderRuns(ctx) {
|
|
91
|
+
const { client, flags, io } = ctx;
|
|
92
|
+
const args = compact({
|
|
93
|
+
endpoint_id: flagStr(flags.endpoint),
|
|
94
|
+
limit: flagNum(flags.limit),
|
|
95
|
+
});
|
|
96
|
+
const result = await client.callTool("list_shred_runs", args);
|
|
97
|
+
printResult(io, flags, result);
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
package/lib/commands.mjs
CHANGED