@letterstory/cli 0.48.0 → 0.49.1
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/README.md +4 -0
- package/lib/cli.mjs +3 -1
- package/lib/commands/admin.mjs +73 -2
- package/lib/commands/kernel.mjs +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -388,6 +388,10 @@ letterstory admin crm slack-channels [--all] # Watchdog channels + the
|
|
|
388
388
|
letterstory admin crm link-slack <account-id> C0123ABC # the CRM's watch-only Slack link (`none` unlinks)
|
|
389
389
|
letterstory admin crm import leads.csv --dry-run # bulk-import leads: what would be created/matched
|
|
390
390
|
letterstory admin crm import leads.csv --tag "YC W26" # …and for real (dedupes by domain, then company name)
|
|
391
|
+
letterstory admin crm capture thread.png --context "this is for tryordinal.com" --dry-run
|
|
392
|
+
# a screenshot → a lead: what it read, which account
|
|
393
|
+
letterstory admin crm capture thread.png --context "this is for tryordinal.com" # …and for real
|
|
394
|
+
letterstory admin crm capture --text-file notes.txt # pasted text or notes work the same way
|
|
391
395
|
|
|
392
396
|
# One-click onboarding of a won client (key needs crm:write + fleet:onboard + org:create)
|
|
393
397
|
letterstory admin crm onboard <account-id> --domain acme.com \
|
package/lib/cli.mjs
CHANGED
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
} from "./commands.mjs";
|
|
55
55
|
|
|
56
56
|
// Keep in sync with cli/package.json.
|
|
57
|
-
export const VERSION = "0.
|
|
57
|
+
export const VERSION = "0.49.1";
|
|
58
58
|
|
|
59
59
|
// Flags that never take a value. Listing them explicitly means `deploy get --json <id>`
|
|
60
60
|
// can't accidentally swallow the id as --json's value.
|
|
@@ -563,6 +563,8 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
|
|
|
563
563
|
ledger entry. Written by \`npm run lab --
|
|
564
564
|
publish\` in the kernels repo.
|
|
565
565
|
admin crm import <file.csv> [--source <name>] [--tag "…"] [--dry-run]
|
|
566
|
+
| capture [shot.png …] [--text "…" | --text-file f] [--context "this is for acme.com"]
|
|
567
|
+
[--account <id>] [--dry-run] screenshots / a thread / a note → a lead
|
|
566
568
|
| signals [--status new] [--intent qualified] [--source rb2b] [--account <id>]
|
|
567
569
|
| record --title "…" [--source bookface] [--kind other] [--intent qualified]
|
|
568
570
|
[--name …] [--email …] [--company …] [--domain …] [--linkedin …] [--detail …]
|
package/lib/commands/admin.mjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// admin tuning-context [--q "<question>"] (tuning:experiment)
|
|
9
9
|
// admin tuning-import <brief-results.json> [--experiment <id>] (tuning:experiment)
|
|
10
10
|
// admin evals scoreboard|cases|runs|run|triage|guard|retire … (fleet:read / tuning:experiment)
|
|
11
|
-
// admin crm import|signals|record|signal|accounts|account|score|slack-channels|link-slack|white-glove|set-white-glove|churn|record-churn|undo-churn|onboard|onboarding|retry-onboarding|onboard-plan|payment-link … (crm:read / crm:write)
|
|
11
|
+
// admin crm import|capture|signals|record|signal|accounts|account|score|slack-channels|link-slack|white-glove|set-white-glove|churn|record-churn|undo-churn|onboard|onboarding|retry-onboarding|onboard-plan|payment-link … (crm:read / crm:write)
|
|
12
12
|
// admin create-org --domain acme.com [--name "Acme"] [--test] [--no-key] [--key-name N]
|
|
13
13
|
// [--capabilities a,b] [--onboard] [--about "…"] [--sitemap <url>]
|
|
14
14
|
// [--cms <provider>] [--posts N] [--seers suggest|skip] [--no-visuals]
|
|
@@ -627,6 +627,75 @@ function onboardBody(flags) {
|
|
|
627
627
|
});
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
+
const CRM_CAPTURE_TYPES = {
|
|
631
|
+
png: "image/png",
|
|
632
|
+
jpg: "image/jpeg",
|
|
633
|
+
jpeg: "image/jpeg",
|
|
634
|
+
gif: "image/gif",
|
|
635
|
+
webp: "image/webp",
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* `admin crm capture [image…] [--text "…" | --text-file f] [--context "this is for acme.com"]
|
|
640
|
+
* [--account id] [--dry-run]` — screenshots, a pasted thread or a note → a lead. The same
|
|
641
|
+
* captureLead the CRM's paste box and Slack's "Send to CRM" call (POST /api/superadmin/crm/capture).
|
|
642
|
+
*/
|
|
643
|
+
async function cmdAdminCrmCapture(ctx, paths) {
|
|
644
|
+
const { flags, io } = ctx;
|
|
645
|
+
const usage =
|
|
646
|
+
'Usage: admin crm capture [image.png …] [--text "…" | --text-file notes.txt] [--context "this is for acme.com"] [--account <id>] [--dry-run]';
|
|
647
|
+
const images = paths.map((path) => {
|
|
648
|
+
const media_type = CRM_CAPTURE_TYPES[path.split(".").pop()?.toLowerCase() ?? ""];
|
|
649
|
+
if (!media_type) throw new CliError(`${path}: only png, jpg, gif and webp screenshots can be read`);
|
|
650
|
+
try {
|
|
651
|
+
return { media_type, data: readFileSync(path).toString("base64") };
|
|
652
|
+
} catch (err) {
|
|
653
|
+
throw new CliError(`Could not read ${path}: ${err.message}`);
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
let text = flagStr(flags.text);
|
|
657
|
+
const textFile = flagStr(flags["text-file"]);
|
|
658
|
+
if (textFile) {
|
|
659
|
+
try {
|
|
660
|
+
text = readFileSync(textFile, "utf8");
|
|
661
|
+
} catch (err) {
|
|
662
|
+
throw new CliError(`Could not read ${textFile}: ${err.message}`);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
if (images.length === 0 && !text) throw new CliError(usage);
|
|
666
|
+
const r = await staffPost(
|
|
667
|
+
ctx,
|
|
668
|
+
`${CRM}/capture`,
|
|
669
|
+
compact({
|
|
670
|
+
images: images.length ? images : undefined,
|
|
671
|
+
text,
|
|
672
|
+
context: flagStr(flags.context),
|
|
673
|
+
account_id: flagStr(flags.account),
|
|
674
|
+
source: flagStr(flags.source) ?? "agent",
|
|
675
|
+
dry_run: flagBool(flags["dry-run"]) || undefined,
|
|
676
|
+
})
|
|
677
|
+
);
|
|
678
|
+
if (flagBool(flags.json)) return printResult(io, flags, r);
|
|
679
|
+
const verb = r.dryRun
|
|
680
|
+
? r.accountId
|
|
681
|
+
? "would add to"
|
|
682
|
+
: "would create"
|
|
683
|
+
: r.duplicate
|
|
684
|
+
? "already captured →"
|
|
685
|
+
: r.accountCreated
|
|
686
|
+
? "created"
|
|
687
|
+
: "added to";
|
|
688
|
+
io.log(
|
|
689
|
+
`${verb} ${r.accountName ?? "a new account"}${r.accountUrl ? ` ${r.accountUrl}` : ""}${r.matchedVia ? ` (via ${r.matchedVia})` : ""}`
|
|
690
|
+
);
|
|
691
|
+
if (r.read) {
|
|
692
|
+
io.log(` ${r.read.title}`);
|
|
693
|
+
if (r.contacts.length)
|
|
694
|
+
io.log(` contacts: ${r.contacts.map((p) => p.name + (p.email ? ` <${p.email}>` : "")).join(", ")}`);
|
|
695
|
+
if (r.read.notes) io.log(` notes: ${r.read.notes}`);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
630
699
|
/**
|
|
631
700
|
* `admin crm …` — the headless half of the staff CRM, so a background agent can watch the
|
|
632
701
|
* pipeline and record the signals that have no webhook (Bookface, tweet likes, DMs).
|
|
@@ -641,6 +710,8 @@ async function cmdAdminCrm(ctx) {
|
|
|
641
710
|
switch (sub) {
|
|
642
711
|
case "import":
|
|
643
712
|
return cmdAdminCrmImport(ctx, id);
|
|
713
|
+
case "capture":
|
|
714
|
+
return cmdAdminCrmCapture(ctx, ctx.positionals.slice(1));
|
|
644
715
|
case "signals": {
|
|
645
716
|
const params = new URLSearchParams(
|
|
646
717
|
compact({
|
|
@@ -875,7 +946,7 @@ async function cmdAdminCrm(ctx) {
|
|
|
875
946
|
}
|
|
876
947
|
default:
|
|
877
948
|
throw new CliError(
|
|
878
|
-
"Usage: admin crm import|signals|record|signal|accounts|account|score|slack-channels|link-slack|white-glove|set-white-glove|churn|record-churn|undo-churn|onboard|onboarding|retry-onboarding|onboard-plan|payment-link … (see --help)"
|
|
949
|
+
"Usage: admin crm import|capture|signals|record|signal|accounts|account|score|slack-channels|link-slack|white-glove|set-white-glove|churn|record-churn|undo-churn|onboard|onboarding|retry-onboarding|onboard-plan|payment-link … (see --help)"
|
|
879
950
|
);
|
|
880
951
|
}
|
|
881
952
|
}
|
package/lib/commands/kernel.mjs
CHANGED
|
@@ -123,6 +123,10 @@ export const ARGS = {
|
|
|
123
123
|
// field a template resolves to, sent by a caller who has their own.
|
|
124
124
|
skeleton: { value: (flags) => readJsonFileFlag(flags, "skeleton-file") },
|
|
125
125
|
brief_json: { value: (flags) => readJsonFileFlag(flags, "brief-json-file") },
|
|
126
|
+
// A deep patch over the kernel's config for THIS run only (2026-10-02): how a run names a
|
|
127
|
+
// writer without a new kernel version — `--config-patch-file patch.json` with
|
|
128
|
+
// `{ "model": "echo/echo" }`, `repairModel`, `quality.model` and the rest of the config.
|
|
129
|
+
config_patch: { value: (flags) => readJsonFileFlag(flags, "config-patch-file") },
|
|
126
130
|
// A TEMPLATE INSTEAD OF HAND-BUILDING THOSE. `--template <key>` resolves one of your
|
|
127
131
|
// templates against the material you sent and fills `skeleton`, `target_word_count` and
|
|
128
132
|
// `brief_json` for this call — and the finished run comes back ASSEMBLED rather than as
|