@letterstory/cli 0.177.159 → 0.177.160

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
@@ -93,7 +93,7 @@ import {
93
93
  import { fetchParkedSections, withoutParked } from "./parked.mjs";
94
94
 
95
95
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
96
- export const VERSION = "0.177.159";
96
+ export const VERSION = "0.177.160";
97
97
 
98
98
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
99
99
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -23,9 +23,10 @@
23
23
  // letterstory visits shortcut [mod+e | default] your own key for Letter Edit's card (⌘L by default)
24
24
  // letterstory visits transact [on|off] [--host acme.com] Transact: agents' questions answered from your sources, cited
25
25
  // letterstory visits transact add folder /answers | page <url> | site https://docs.acme.com/answers
26
- // letterstory visits transact add text --title "Question?" --text "Reviewed public answer" [--ask <id>]
26
+ // letterstory visits transact add text --text "Knowledge agents should know" [--title "Question?"] [--ask <id>]
27
27
  // letterstory visits transact pr [--repo owner/name] [--base branch] the line and the missed answers, as one pull request
28
- // letterstory visits transact source <source-id> | --folder /docs
28
+ // letterstory visits transact source <source-id> | --folder /docs | --section /blog
29
+ // letterstory visits transact search "sso" the knowledge base and the site's pages, as an ask searches them
29
30
  // letterstory visits transact remove <source-id>
30
31
  // letterstory visits transact test "What does it cost?"
31
32
  // letterstory visits transact asks [--since 7d] [--limit 50]
@@ -147,6 +148,12 @@ export const ARGS = {
147
148
  site_id: "site",
148
149
  source_id: { positional: 0, label: "source id" },
149
150
  folder: "folder",
151
+ section: "section",
152
+ limit: { flag: "limit", type: "num" },
153
+ },
154
+ visitors_search_transact_knowledge: {
155
+ site_id: "site",
156
+ query: { positional: 0, label: "query", required: true },
150
157
  limit: { flag: "limit", type: "num" },
151
158
  },
152
159
  visitors_set_transact_ask_test: {
@@ -352,7 +359,7 @@ function transactLines(t) {
352
359
  return lines;
353
360
  }
354
361
 
355
- /** `visits transact`: read it; `on` / `off`; `add <kind> …`; `source <id>`; `remove <id>`; `test "…"`; `pr`; `asks`; `learnings`. */
362
+ /** `visits transact`: read it; `on` / `off`; `add <kind> …`; `source <id>`; `search "…"`; `remove <id>`; `test "…"`; `pr`; `asks`; `learnings`. */
356
363
  async function visitsTransact(ctx) {
357
364
  const { flags, io } = ctx;
358
365
  const sub = ctx.positionals[0];
@@ -380,6 +387,18 @@ async function visitsTransact(ctx) {
380
387
  );
381
388
  return 0;
382
389
  }
390
+ if (sub === "search") {
391
+ const result = await call(rest, "visitors_search_transact_knowledge");
392
+ printResult(io, flags, result, (r) => {
393
+ const hits = (label, rows) =>
394
+ rows.length
395
+ ? [label, ...rows.map((h) => ` ${h.title}${h.url ? ` ${h.url}` : ""}\n ${h.snippet}`)]
396
+ : [];
397
+ const lines = [...hits("Structured", r.structured), ...hits("Unstructured", r.unstructured)];
398
+ return lines.length ? lines.join("\n") : "Nothing found";
399
+ });
400
+ return 0;
401
+ }
383
402
  if (sub === "remove") {
384
403
  const result = await call(rest, "visitors_remove_transact_source");
385
404
  printResult(io, flags, result, () => "Removed");
@@ -416,8 +435,12 @@ async function visitsTransact(ctx) {
416
435
  }
417
436
  if (sub === "learnings") {
418
437
  const result = await call(rest, "visitors_get_transact_learnings");
419
- printResult(io, flags, result, (r) =>
420
- r.learnings.length ? r.learnings.map((l) => `- ${l.text}`).join("\n") : "No asks yet"
438
+ printResult(
439
+ io,
440
+ flags,
441
+ result,
442
+ (r) =>
443
+ r.refused ?? (r.learnings.length ? r.learnings.map((l) => `- ${l.text}`).join("\n") : "No themes yet")
421
444
  );
422
445
  return 0;
423
446
  }
@@ -436,7 +459,9 @@ async function visitsTransact(ctx) {
436
459
  return 0;
437
460
  }
438
461
  if (sub !== undefined)
439
- throw new CliError("Usage: visits transact [on|off|add <kind>|source <id>|remove <id>|test|pr|asks]");
462
+ throw new CliError(
463
+ "Usage: visits transact [on|off|add <kind>|source <id>|search <query>|remove <id>|test|pr|asks|learnings]"
464
+ );
440
465
  const result = await call(ctx, "visitors_get_transact");
441
466
  printResult(io, flags, result, (t) => transactLines(t).join("\n"));
442
467
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.177.159",
3
+ "version": "0.177.160",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",