@letterstory/cli 0.82.4 → 0.83.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 CHANGED
@@ -57,7 +57,7 @@ import {
57
57
  } from "./commands.mjs";
58
58
 
59
59
  // Keep in sync with cli/package.json.
60
- export const VERSION = "0.82.4";
60
+ export const VERSION = "0.83.0";
61
61
 
62
62
  // Flags that never take a value. Listing them explicitly means `deploy get --json <id>`
63
63
  // can't accidentally swallow the id as --json's value. Every `type: "bool"` flag (and its
@@ -333,16 +333,20 @@ Collections:
333
333
  collections autopen <id> [--template <key>|none] [--kernel-family <name>|org]
334
334
  [--mention off|subtle|woven] [--outline-depth barebones|fleshed_out]
335
335
  [--direction-gate true|false] [--auto-start true|false]
336
- [--prefer <site> …|none]
336
+ [--prefer <site> …|none] [--client-one-in <n>]
337
337
  The Auto-Pen settings the app's panel writes. --template binds a content
338
338
  template (from 'templates list') as this collection's default, which is how
339
339
  a template you author here actually gets used. A patch: unset flags are
340
340
  left alone. --prefer REPLACES the preferred sources: SITES research
341
341
  searches for every post's topic and reaches for first when a figure fits
342
342
  (a URL is saved as its site) — your own site included; 'none' clears them.
343
- collections cite-preferred <id> [--limit <n>] [--dry-run]
344
- Bring published posts up to the preferred sources: each eligible post gets
345
- at most one preferred figure, linked on the figure, then republishes.
343
+ collections preview-preferred <id>
344
+ Step 1: check every published post with a Sources list against the
345
+ preferred sites — dry, nothing written. Proposals are judged by fit.
346
+ collections preferred-preview <id>
347
+ Step 2: the proposals ranked, what the ceiling chooses, and the 1-in-N.
348
+ collections cite-preferred <id>
349
+ Step 3: apply exactly the chosen sentences, then republish.
346
350
 
347
351
  Authors (the per-collection author bank — recurring bylines):
348
352
  authors list <collection-id> List the bank + byline distribution
@@ -47,10 +47,14 @@ export const ARGS = {
47
47
  regenerate_topic_map: { value: (flags) => (flags["no-topic-map"] === undefined ? undefined : false) },
48
48
  stock_headlines: { value: (flags) => (flags["no-headlines"] === undefined ? undefined : false) },
49
49
  },
50
+ preview_preferred_sources: {
51
+ collection_id: { positional: 0, label: "collection-id", required: true },
52
+ },
53
+ get_preferred_sources_preview: {
54
+ collection_id: { positional: 0, label: "collection-id", required: true },
55
+ },
50
56
  cite_preferred_sources: {
51
57
  collection_id: { positional: 0, label: "collection-id", required: true },
52
- limit: { flag: "limit", type: "num" },
53
- dry_run: { value: (flags) => (flags["dry-run"] === true ? true : undefined) },
54
58
  },
55
59
  update_auto_pen_config: {
56
60
  collection_id: { positional: 0, label: "collection-id", required: true },
@@ -76,6 +80,8 @@ export const ARGS = {
76
80
  auto_start_on_curate: stringBool("auto-start"),
77
81
  // Replaces the collection's preferred sources; `--prefer none` clears them.
78
82
  preferred_sources: { value: (flags) => preferredSourcesFlag(flags.prefer) },
83
+ // The ceiling on the client's own site: at most one in N published posts cites it.
84
+ client_one_in: { flag: "client-one-in", type: "num" },
79
85
  },
80
86
  };
81
87
 
@@ -106,11 +112,15 @@ export async function cmdCollections(ctx) {
106
112
  return collectionsAutoPen(rest);
107
113
  case "activate":
108
114
  return collectionsActivate(rest);
115
+ case "preview-preferred":
116
+ return collectionsPreviewPreferred(rest);
117
+ case "preferred-preview":
118
+ return collectionsReadPreferredPreview(rest);
109
119
  case "cite-preferred":
110
120
  return collectionsCitePreferred(rest);
111
121
  default:
112
122
  throw new CliError(
113
- `Unknown collections subcommand: ${sub ?? "(none)"}. Try: list, new, update, delete, assign, autopen, activate, cite-preferred`
123
+ `Unknown collections subcommand: ${sub ?? "(none)"}. Try: list, new, update, delete, assign, autopen, activate, preview-preferred, preferred-preview, cite-preferred`
114
124
  );
115
125
  }
116
126
  }
@@ -139,10 +149,36 @@ async function collectionsActivate(ctx) {
139
149
  }
140
150
 
141
151
  /**
142
- * `collections cite-preferred <id> [--limit <n>] [--dry-run]` — bring the collection's published
143
- * posts up to its preferred sources: each eligible post places at most one preferred figure and
144
- * republishes. The same function as the app's "Apply to published posts".
152
+ * `collections preview-preferred <id>` — step 1: queue a dry proposal per eligible published post
153
+ * (nothing is written to a post). The same preview as the app's "Preview published posts".
145
154
  */
155
+ async function collectionsPreviewPreferred(ctx) {
156
+ const { client, positionals, flags, io } = ctx;
157
+ const args = argsFromFlags(ARGS.preview_preferred_sources, flags, positionals);
158
+ const result = await client.callTool("preview_preferred_sources", args);
159
+ ok(
160
+ ctx,
161
+ `Queued ${result?.queued ?? 0} post${result?.queued === 1 ? "" : "s"} for a proposal. Read it with \`collections preferred-preview ${args.collection_id}\`.`
162
+ );
163
+ printResult(io, flags, result);
164
+ return 0;
165
+ }
166
+
167
+ /** `collections preferred-preview <id>` — step 2: the latest preview, ranked, and the 1-in-N it projects. */
168
+ async function collectionsReadPreferredPreview(ctx) {
169
+ const { client, positionals, flags, io } = ctx;
170
+ const args = argsFromFlags(ARGS.get_preferred_sources_preview, flags, positionals);
171
+ const r = await client.callTool("get_preferred_sources_preview", args);
172
+ const oneIn = r?.projected?.one_in ? `1 in ${r.projected.one_in}` : "none";
173
+ ok(
174
+ ctx,
175
+ `Preview ${r?.status}: ${r?.checked ?? 0}/${r?.total ?? 0} checked; ${r?.chosen?.length ?? 0} chosen, ${r?.held_by_ceiling?.length ?? 0} held by the ceiling, ${r?.below_bar?.length ?? 0} below the bar. Client cited in ${r?.projected?.citing_client ?? 0} of ${r?.projected?.of ?? 0} (${oneIn}).`
176
+ );
177
+ printResult(io, flags, r);
178
+ return 0;
179
+ }
180
+
181
+ /** `collections cite-preferred <id>` — step 3: apply exactly the latest finished preview's chosen sentences. */
146
182
  async function collectionsCitePreferred(ctx) {
147
183
  const { client, positionals, flags, io } = ctx;
148
184
  const args = argsFromFlags(ARGS.cite_preferred_sources, flags, positionals);
@@ -150,9 +186,7 @@ async function collectionsCitePreferred(ctx) {
150
186
  const n = result?.started?.length ?? 0;
151
187
  ok(
152
188
  ctx,
153
- result?.dry_run
154
- ? `Would run ${n} post${n === 1 ? "" : "s"}; ${result?.skipped?.length ?? 0} skipped.`
155
- : `Started ${n} post${n === 1 ? "" : "s"}${result?.republishes === false ? " (changes wait on the draft for approval)" : ""}; ${result?.skipped?.length ?? 0} skipped.`
189
+ `Started ${n} post${n === 1 ? "" : "s"}${result?.republishes === false ? " (changes wait on the draft for approval)" : ""}; ${result?.skipped?.length ?? 0} skipped.`
156
190
  );
157
191
  printResult(io, flags, result);
158
192
  return 0;
@@ -195,7 +229,7 @@ async function collectionsAutoPen(ctx) {
195
229
  const patch = argsFromFlags(ARGS.update_auto_pen_config, flags, positionals);
196
230
  if (Object.keys(patch).length === 1) {
197
231
  throw new CliError(
198
- "Nothing to change. Pass at least one of --template, --kernel-family, --mention, --outline-depth, --direction-gate, --auto-start, --prefer."
232
+ "Nothing to change. Pass at least one of --template, --kernel-family, --mention, --outline-depth, --direction-gate, --auto-start, --prefer, --client-one-in."
199
233
  );
200
234
  }
201
235
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.82.4",
3
+ "version": "0.83.0",
4
4
  "description": "Spin up and manage Letterstory phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",