@letterstory/cli 0.176.12 → 0.176.14
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 +15 -3
- package/lib/commands/automations.mjs +21 -1
- package/lib/commands/seers.mjs +31 -4
- 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.14";
|
|
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;
|
|
@@ -89,6 +89,8 @@ export const EXIT_PAYMENT_REQUIRED = 3;
|
|
|
89
89
|
// can't accidentally swallow the id as --json's value. Every `type: "bool"` flag (and its
|
|
90
90
|
// `negate` spelling) in a command's ARGS map must be listed; boolean-flags.test.ts enforces it.
|
|
91
91
|
export const BOOLEAN_FLAGS = new Set([
|
|
92
|
+
// automations set: stop reading a data feed.
|
|
93
|
+
"no-reads",
|
|
92
94
|
// vary start: pause the test running on the page first.
|
|
93
95
|
"pause-running",
|
|
94
96
|
// bench run: the spec was just changed.
|
|
@@ -378,6 +380,12 @@ export const BOOLEAN_FLAGS = new Set([
|
|
|
378
380
|
// A flag repeated more than once (e.g. `--topic a --topic b`, used by `strategy
|
|
379
381
|
// positioning set`) accumulates into an array; a single occurrence stays a plain
|
|
380
382
|
// string, so every existing single-value flag read is unaffected.
|
|
383
|
+
/**
|
|
384
|
+
* A switch that takes a VALUE under one command: `automations add|set --on "fri 09:00 America/New_York"`
|
|
385
|
+
* (the pin) while `on` is `automate`'s boolean. Scoped by the first word, so the global list stays.
|
|
386
|
+
*/
|
|
387
|
+
const VALUE_FLAGS_BY_COMMAND = { automations: new Set(["on"]) };
|
|
388
|
+
|
|
381
389
|
/**
|
|
382
390
|
* @param {string[]} argv
|
|
383
391
|
* @returns {{ positionals: string[], flags: Record<string, string | boolean | string[]> }}
|
|
@@ -385,6 +393,7 @@ export const BOOLEAN_FLAGS = new Set([
|
|
|
385
393
|
export function parseArgs(argv) {
|
|
386
394
|
const positionals = [];
|
|
387
395
|
const flags = {};
|
|
396
|
+
const valueFlags = VALUE_FLAGS_BY_COMMAND[argv[0]] ?? new Set();
|
|
388
397
|
const setFlag = (name, value) => {
|
|
389
398
|
if (Object.prototype.hasOwnProperty.call(flags, name)) {
|
|
390
399
|
flags[name] = [].concat(flags[name], value);
|
|
@@ -405,7 +414,7 @@ export function parseArgs(argv) {
|
|
|
405
414
|
}
|
|
406
415
|
const name = tok.slice(2);
|
|
407
416
|
const next = argv[i + 1];
|
|
408
|
-
if (BOOLEAN_FLAGS.has(name) || next === undefined || next.startsWith("--")) {
|
|
417
|
+
if ((BOOLEAN_FLAGS.has(name) && !valueFlags.has(name)) || next === undefined || next.startsWith("--")) {
|
|
409
418
|
flags[name] = true;
|
|
410
419
|
} else {
|
|
411
420
|
setFlag(name, next);
|
|
@@ -577,10 +586,13 @@ Reviewers:
|
|
|
577
586
|
automations dismiss <topic-id> --collection <id> Set one subject aside
|
|
578
587
|
automations add topic|series|signal|best --collection <id> [--topic <id>] [--goal <target-id>]
|
|
579
588
|
[--seer <id>] [--pace <n> | --on "fri 09:00 America/New_York"] [--brief <text>]
|
|
580
|
-
[--new-topic <name>] [--new-series <name>]
|
|
589
|
+
[--reads <seer-id> [--window <days>]] [--new-topic <name>] [--new-series <name>]
|
|
581
590
|
Add one (refused if it says the same as another).
|
|
582
591
|
--on pins it: one post a week, on that day and time
|
|
592
|
+
--reads: a data feed (a data_feed seer) whose records in
|
|
593
|
+
the window before each post are the post's own data
|
|
583
594
|
automations set <automation-id> --collection <id> [--pace <n> | --on "<day> <HH:MM> <tz>" | --unpin]
|
|
595
|
+
[--reads <seer-id> [--window <days>] | --no-reads]
|
|
584
596
|
[--pause | --resume] [--goal <id>] [--brief <text>] [--remap]
|
|
585
597
|
automations remove <automation-id> --collection <id>
|
|
586
598
|
automate options What an automation can be made of here: the triggers,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Same flag/positional/io conventions as posts.mjs — no commander, no color.
|
|
4
4
|
|
|
5
5
|
import { CliError } from "../client.mjs";
|
|
6
|
-
import { printResult, ok, argsFromFlags, refuseUnknownFlags } from "./shared.mjs";
|
|
6
|
+
import { flagStr, printResult, ok, argsFromFlags, refuseUnknownFlags } from "./shared.mjs";
|
|
7
7
|
|
|
8
8
|
const WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
9
9
|
|
|
@@ -23,6 +23,24 @@ export function parsePublishAt(text) {
|
|
|
23
23
|
return { weekday, time, timezone };
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* `--reads <seer-id> [--window <days>]` → { seer_id, window_days } (the tool's `reads`): a data
|
|
28
|
+
* feed the automation reads, the window ending at each post's publish instant (7 days unless set).
|
|
29
|
+
* `--no-reads` sends null (stop reading one).
|
|
30
|
+
*/
|
|
31
|
+
export function parseReads(flags) {
|
|
32
|
+
if (flags["no-reads"] === true) return null;
|
|
33
|
+
const seer = flagStr(flags.reads);
|
|
34
|
+
if (seer === undefined) {
|
|
35
|
+
if (flags.window !== undefined) throw new CliError("--window goes with --reads <seer-id>");
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const days = flags.window === undefined ? 7 : Number(flags.window);
|
|
39
|
+
if (!Number.isInteger(days) || days < 1)
|
|
40
|
+
throw new CliError("--window takes a whole number of days, e.g. --window 7");
|
|
41
|
+
return { seer_id: seer, window_days: days };
|
|
42
|
+
}
|
|
43
|
+
|
|
26
44
|
/** See `argsFromFlags` in shared.mjs; `scripts/parity-check.ts` diffs these keys against the tool. */
|
|
27
45
|
export const ARGS = {
|
|
28
46
|
list_automations: {
|
|
@@ -56,6 +74,7 @@ export const ARGS = {
|
|
|
56
74
|
seer_id: { flag: "seer" },
|
|
57
75
|
pace_per_week: { flag: "pace", type: "num" },
|
|
58
76
|
publish_at: { value: (flags) => parsePublishAt(flags.on) },
|
|
77
|
+
reads: { value: (flags) => parseReads(flags) ?? undefined },
|
|
59
78
|
brief: { flag: "brief" },
|
|
60
79
|
new_topic: {
|
|
61
80
|
value: (flags) => (typeof flags["new-topic"] === "string" ? { name: flags["new-topic"] } : undefined),
|
|
@@ -69,6 +88,7 @@ export const ARGS = {
|
|
|
69
88
|
automation_id: { positional: 0, label: "automation-id", required: true },
|
|
70
89
|
pace_per_week: { flag: "pace", type: "num" },
|
|
71
90
|
publish_at: { value: (flags) => (flags.unpin === true ? null : parsePublishAt(flags.on)) },
|
|
91
|
+
reads: { value: (flags) => parseReads(flags) },
|
|
72
92
|
paused: {
|
|
73
93
|
value: (flags) => (flags.pause === true ? true : flags.resume === true ? false : undefined),
|
|
74
94
|
},
|
package/lib/commands/seers.mjs
CHANGED
|
@@ -60,7 +60,7 @@ export const ARGS = {
|
|
|
60
60
|
// forever but never produce (auto mode is rejected without one).
|
|
61
61
|
collection_id: { flag: "collection" },
|
|
62
62
|
provider: { flag: "provider", required: true },
|
|
63
|
-
mode: { flag: "mode", enum: ["suggest", "auto"] },
|
|
63
|
+
mode: { flag: "mode", enum: ["suggest", "auto", "record"] },
|
|
64
64
|
poll_interval_minutes: { flag: "interval", type: "num" },
|
|
65
65
|
// The whole config document — provider source params plus the behavior keys
|
|
66
66
|
// (auto_draft_scope, template_key, mention_degree, kernel_family, relevance{…}).
|
|
@@ -72,7 +72,7 @@ export const ARGS = {
|
|
|
72
72
|
// --collection <uuid> sets it, --clear-collection sends null (the seer becomes
|
|
73
73
|
// detect-only — rejected if it's mode "auto"), neither leaves it unchanged.
|
|
74
74
|
collection_id: clearableValue("collection", "clear-collection"),
|
|
75
|
-
mode: { flag: "mode", enum: ["suggest", "auto"] },
|
|
75
|
+
mode: { flag: "mode", enum: ["suggest", "auto", "record"] },
|
|
76
76
|
enabled: { value: (flags) => readEnabledFlag(flags) },
|
|
77
77
|
poll_interval_minutes: { flag: "interval", type: "num" },
|
|
78
78
|
config: { value: (flags) => readJsonObjectFlag(flags, "config") },
|
|
@@ -84,6 +84,14 @@ export const ARGS = {
|
|
|
84
84
|
seer_id: { positional: 0, label: "seer-id", required: true },
|
|
85
85
|
limit: { flag: "limit", type: "num" },
|
|
86
86
|
offset: { flag: "offset", type: "num" },
|
|
87
|
+
// A window by each event's own date: `seers events <id> --since 2026-10-30T13:00:00Z`.
|
|
88
|
+
since: { flag: "since" },
|
|
89
|
+
until: { flag: "until" },
|
|
90
|
+
},
|
|
91
|
+
// `seers credential <id> --token "Bearer …"` (a private data feed's header value; --clear removes it).
|
|
92
|
+
set_seer_credential: {
|
|
93
|
+
seer_id: { positional: 0, label: "seer-id", required: true },
|
|
94
|
+
token: { value: (flags) => (flags.clear ? null : flagStr(flags.token)) },
|
|
87
95
|
},
|
|
88
96
|
dismiss_seer_event: {
|
|
89
97
|
seer_id: { positional: 0, label: "seer-id", required: true },
|
|
@@ -146,6 +154,8 @@ export async function cmdSeers(ctx) {
|
|
|
146
154
|
return seersRuns(rest);
|
|
147
155
|
case "balance":
|
|
148
156
|
return seersBalance(rest);
|
|
157
|
+
case "credential":
|
|
158
|
+
return seersCredential(rest);
|
|
149
159
|
case "events":
|
|
150
160
|
return seersEvents(rest);
|
|
151
161
|
case "dismiss":
|
|
@@ -170,7 +180,7 @@ export async function cmdSeers(ctx) {
|
|
|
170
180
|
return seersApply(rest);
|
|
171
181
|
default:
|
|
172
182
|
throw new CliError(
|
|
173
|
-
`Unknown seers subcommand: ${sub ?? "(none)"}. Try: list, get, create, update, delete, run, run-status, runs, balance, events, dismiss, headlines, held, release, discard, providers, connections, connect, export, apply`
|
|
183
|
+
`Unknown seers subcommand: ${sub ?? "(none)"}. Try: list, get, create, update, delete, run, run-status, runs, balance, events, credential, dismiss, headlines, held, release, discard, providers, connections, connect, export, apply`
|
|
174
184
|
);
|
|
175
185
|
}
|
|
176
186
|
}
|
|
@@ -340,6 +350,16 @@ async function seersBalance(ctx) {
|
|
|
340
350
|
|
|
341
351
|
// --- Events / headlines / holding pen ----------------------------------------------
|
|
342
352
|
|
|
353
|
+
async function seersCredential(ctx) {
|
|
354
|
+
const { client, positionals, flags, io } = ctx;
|
|
355
|
+
const args = argsFromFlags(ARGS.set_seer_credential, flags, positionals);
|
|
356
|
+
if (args.token === undefined) throw new CliError("Pass --token <header value> or --clear");
|
|
357
|
+
const result = await client.callTool("set_seer_credential", args);
|
|
358
|
+
ok(ctx, args.token === null ? "Credential removed." : "Credential stored.");
|
|
359
|
+
printResult(io, flags, result);
|
|
360
|
+
return 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
343
363
|
async function seersEvents(ctx) {
|
|
344
364
|
const { client, positionals, flags, io } = ctx;
|
|
345
365
|
const args = argsFromFlags(ARGS.list_seer_events, flags, positionals);
|
|
@@ -348,7 +368,14 @@ async function seersEvents(ctx) {
|
|
|
348
368
|
const lines = (r.events ?? []).map((e) => {
|
|
349
369
|
const blocked = e.auto_production_blocked_reason ? ` [blocked: ${e.auto_production_blocked_reason}]` : "";
|
|
350
370
|
const aliases = e.aliases?.length ? ` (+${e.aliases.length} aliases)` : "";
|
|
351
|
-
|
|
371
|
+
const fields =
|
|
372
|
+
e.payload?.fields && typeof e.payload.fields === "object"
|
|
373
|
+
? " " +
|
|
374
|
+
Object.entries(e.payload.fields)
|
|
375
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
376
|
+
.join(" ")
|
|
377
|
+
: "";
|
|
378
|
+
return `${e.id} [${e.status}] ${e.payload?.occurred_at ?? e.detected_at} ${e.title}${aliases}${blocked}${fields}`;
|
|
352
379
|
});
|
|
353
380
|
if (!lines.length) lines.push("No events detected yet.");
|
|
354
381
|
if (r.has_more) lines.push(`… more available (--offset ${r.next_offset})`);
|