@letterstory/cli 0.177.158 → 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 +1 -1
- package/lib/commands/visits.mjs +38 -4
- package/package.json +1 -1
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.
|
|
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;
|
package/lib/commands/visits.mjs
CHANGED
|
@@ -23,12 +23,14 @@
|
|
|
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 --
|
|
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]
|
|
33
|
+
// letterstory visits transact learnings [--since 7d]
|
|
32
34
|
|
|
33
35
|
import { CliError } from "../client.mjs";
|
|
34
36
|
import { flagStr, printResult, argsFromFlags } from "./shared.mjs";
|
|
@@ -146,6 +148,12 @@ export const ARGS = {
|
|
|
146
148
|
site_id: "site",
|
|
147
149
|
source_id: { positional: 0, label: "source id" },
|
|
148
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 },
|
|
149
157
|
limit: { flag: "limit", type: "num" },
|
|
150
158
|
},
|
|
151
159
|
visitors_set_transact_ask_test: {
|
|
@@ -178,6 +186,7 @@ export const ARGS = {
|
|
|
178
186
|
update: { flag: "update", type: "bool" },
|
|
179
187
|
},
|
|
180
188
|
visitors_list_transact_asks: { site_id: "site", days, limit: { flag: "limit", type: "num" } },
|
|
189
|
+
visitors_get_transact_learnings: { site_id: "site", days },
|
|
181
190
|
visitors_export: {
|
|
182
191
|
site_id: "site",
|
|
183
192
|
days,
|
|
@@ -350,7 +359,7 @@ function transactLines(t) {
|
|
|
350
359
|
return lines;
|
|
351
360
|
}
|
|
352
361
|
|
|
353
|
-
/** `visits transact`: read it; `on` / `off`; `add <kind> …`; `source <id>`; `remove <id>`; `test "…"`; `pr`; `asks`. */
|
|
362
|
+
/** `visits transact`: read it; `on` / `off`; `add <kind> …`; `source <id>`; `search "…"`; `remove <id>`; `test "…"`; `pr`; `asks`; `learnings`. */
|
|
354
363
|
async function visitsTransact(ctx) {
|
|
355
364
|
const { flags, io } = ctx;
|
|
356
365
|
const sub = ctx.positionals[0];
|
|
@@ -378,6 +387,18 @@ async function visitsTransact(ctx) {
|
|
|
378
387
|
);
|
|
379
388
|
return 0;
|
|
380
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
|
+
}
|
|
381
402
|
if (sub === "remove") {
|
|
382
403
|
const result = await call(rest, "visitors_remove_transact_source");
|
|
383
404
|
printResult(io, flags, result, () => "Removed");
|
|
@@ -412,6 +433,17 @@ async function visitsTransact(ctx) {
|
|
|
412
433
|
printResult(io, flags, await call(rest, "visitors_open_transact_pr"));
|
|
413
434
|
return 0;
|
|
414
435
|
}
|
|
436
|
+
if (sub === "learnings") {
|
|
437
|
+
const result = await call(rest, "visitors_get_transact_learnings");
|
|
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")
|
|
444
|
+
);
|
|
445
|
+
return 0;
|
|
446
|
+
}
|
|
415
447
|
if (sub === "asks") {
|
|
416
448
|
const result = await call(rest, "visitors_list_transact_asks");
|
|
417
449
|
printResult(io, flags, result, (r) => {
|
|
@@ -427,7 +459,9 @@ async function visitsTransact(ctx) {
|
|
|
427
459
|
return 0;
|
|
428
460
|
}
|
|
429
461
|
if (sub !== undefined)
|
|
430
|
-
throw new CliError(
|
|
462
|
+
throw new CliError(
|
|
463
|
+
"Usage: visits transact [on|off|add <kind>|source <id>|search <query>|remove <id>|test|pr|asks|learnings]"
|
|
464
|
+
);
|
|
431
465
|
const result = await call(ctx, "visitors_get_transact");
|
|
432
466
|
printResult(io, flags, result, (t) => transactLines(t).join("\n"));
|
|
433
467
|
return 0;
|