@letterstory/cli 0.167.1 → 0.168.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/lib/cli.mjs +34 -27
- package/lib/commands/admin.mjs +131 -109
- package/lib/commands/insights.mjs +7 -2
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -75,7 +75,7 @@ import {
|
|
|
75
75
|
} from "./commands.mjs";
|
|
76
76
|
|
|
77
77
|
// Matches cli/package.json; publish-cli.yml rewrites both to the published version.
|
|
78
|
-
export const VERSION = "0.
|
|
78
|
+
export const VERSION = "0.168.1";
|
|
79
79
|
|
|
80
80
|
/** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
|
|
81
81
|
export const EXIT_PAYMENT_REQUIRED = 3;
|
|
@@ -84,6 +84,8 @@ export const EXIT_PAYMENT_REQUIRED = 3;
|
|
|
84
84
|
// can't accidentally swallow the id as --json's value. Every `type: "bool"` flag (and its
|
|
85
85
|
// `negate` spelling) in a command's ARGS map must be listed; boolean-flags.test.ts enforces it.
|
|
86
86
|
export const BOOLEAN_FLAGS = new Set([
|
|
87
|
+
// admin crm prospect-org: start (or retry) the org prepared for the booked call.
|
|
88
|
+
"start",
|
|
87
89
|
// site research-builds: run now even when the stored pass is under an hour old.
|
|
88
90
|
"fresh",
|
|
89
91
|
// admin letterpress status | gaps: the customers' reading (no test or demo orgs).
|
|
@@ -158,12 +160,9 @@ export const BOOLEAN_FLAGS = new Set([
|
|
|
158
160
|
"moves",
|
|
159
161
|
"enroll",
|
|
160
162
|
"unenroll",
|
|
163
|
+
// admin demo set --release
|
|
164
|
+
"release",
|
|
161
165
|
"clean-slate",
|
|
162
|
-
// admin recipes list --tab --enabled-only, save --enable|--disable, import --retire-missing
|
|
163
|
-
"enabled-only",
|
|
164
|
-
"enable",
|
|
165
|
-
"disable",
|
|
166
|
-
"retire-missing",
|
|
167
166
|
// admin crm record-outcome --draft
|
|
168
167
|
"draft",
|
|
169
168
|
// admin crm reach-outs --fresh
|
|
@@ -892,28 +891,26 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
|
|
|
892
891
|
read-only SQL across every org; --sql prints
|
|
893
892
|
the queries behind the answer. Needs the
|
|
894
893
|
fleet:query capability on the staff key.
|
|
895
|
-
admin recipes list
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
vocab says what
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
admin recipes
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
[--when-not-to-use …] [--example …] [--moves-json <json>] [--primitives a,b|none] [--outcomes a,b|none]
|
|
911
|
-
[--company-types a,b|none] [--enable|--disable] [--position n]
|
|
894
|
+
admin recipes list | show <id|name> | vocab | stats Recipes: Letter's one library of direction for
|
|
895
|
+
Letterpress on Plan, Build and Fix (/superadmin/recipes),
|
|
896
|
+
five fields each: name, recipe, when to use, when not to
|
|
897
|
+
use, weight. vocab says what each field means; stats how
|
|
898
|
+
often runs followed each recipe (and the share of the
|
|
899
|
+
runs that had it) and how its suggestions fare. Needs
|
|
900
|
+
recipes:read.
|
|
901
|
+
admin recipes list --approach <seo|geo|agent_conviction|inbound_conversion|outbound|other>
|
|
902
|
+
One approach's recipes, read from their own words.
|
|
903
|
+
admin recipes export [--out recipes.json] The library as a file import reads back.
|
|
904
|
+
admin recipes import <file> [--dry-run] Write a library in one call: each recipe matched by id,
|
|
905
|
+
else name, then changed or created. --dry-run writes
|
|
906
|
+
nothing. Exits 1 if any row failed.
|
|
907
|
+
admin recipes save [<id>] [--file <recipe.json>] [--name …] [--recipe …] [--when-to-use …]
|
|
908
|
+
[--when-not-to-use …] [--weight 1..10]
|
|
912
909
|
Create one (no id) or change one. Needs recipes:write.
|
|
913
|
-
admin recipes delete <id> --yes Delete for good
|
|
910
|
+
admin recipes delete <id> --yes Delete for good.
|
|
914
911
|
admin letterpress status [--customers] Letterpress as it runs now: per lens its mode, bar, recipes,
|
|
915
912
|
runs, model and prompt hash, how often the shadow agreed,
|
|
916
|
-
how runs grounded (
|
|
913
|
+
how runs grounded (a recipe / none). Needs recipes:read.
|
|
917
914
|
admin letterpress gaps [--customers] The gaps the numbers show, each with the one call that
|
|
918
915
|
addresses it, pre-filled. Needs recipes:read.
|
|
919
916
|
admin letterpress replay <run-id> A Build or Fix run through today's checks and settings, no
|
|
@@ -938,11 +935,18 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
|
|
|
938
935
|
admin demo set <org-id> [--enroll] [--phantom parked] [--search-console hidden] [--inject <key>]... [--save-as n]
|
|
939
936
|
Set what a demo org shows (merged); 'shown' puts a thing
|
|
940
937
|
back. --file takes a scenario as JSON. Needs demo:write.
|
|
941
|
-
admin demo reset <org-id> <scenario> [--clean-slate] [--close-prs since_applied|all_open|none]
|
|
938
|
+
admin demo reset <org-id> <scenario> [--clean-slate] [--close-prs since_applied|all_open|none] [--hold <min>]
|
|
942
939
|
Undo the last take (its PRs closed, builds archived), then
|
|
943
940
|
show a scenario: real, fresh_geo, fresh_seo, after_approve
|
|
944
941
|
or a saved one. --clean-slate closes every open PR and
|
|
945
|
-
archives every build.
|
|
942
|
+
archives every build. --hold <min> starts a demo: no automatic
|
|
943
|
+
reset for that long. Ends with the readiness check.
|
|
944
|
+
admin demo set <org-id> --auto-reset <scenario>|off [--every <min>] [--release]
|
|
945
|
+
Reset on its own every <min> (default 30) once idle 15
|
|
946
|
+
min and not held; --release ends a hold.
|
|
947
|
+
admin demo check <org-id> Is it ready to show? Competitors, targets, answers, the
|
|
948
|
+
Plan's rows, the issues open, no PR open, GitHub, the
|
|
949
|
+
phantom's site. Exits 1 when not ready.
|
|
946
950
|
admin brand-detection <org-id> [--term <t>]... [--exact <t>]... [--exclude <phrase>]... [--note "…"] | --clear [--note "…"]
|
|
947
951
|
How a client's brand is detected in AI answers, with
|
|
948
952
|
every earlier setting; with flags, set the exact set
|
|
@@ -1082,6 +1086,8 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
|
|
|
1082
1086
|
[--slack a@acme.com,b@acme.com] [--invite a@acme.com[:admin]]… [--no-checklist]
|
|
1083
1087
|
| onboarding <account-id> | retry-onboarding <onboarding-id>
|
|
1084
1088
|
| onboard-plan <account-id> [--refresh]
|
|
1089
|
+
| prospect-org <account-id> [--start] [--domain acme.com] the org prepared for their booked call
|
|
1090
|
+
| prospect-orgs [--status preparing|ready|failed|skipped|parked|converted] [--limit 50]
|
|
1085
1091
|
| payment-link <account-id> [--amount-cents N] [--description "…"] [--plan starter] [--ratio N] [--why "…"] [--first-invoice-credit-cents N]
|
|
1086
1092
|
The staff CRM's pipeline: bulk-importing a
|
|
1087
1093
|
CSV of leads, the inbound signal
|
|
@@ -1477,6 +1483,7 @@ Insights:
|
|
|
1477
1483
|
Measure → Reads: AI engines and people reading your sites, counted one way
|
|
1478
1484
|
insights questions [--period 14d|30d|90d] Measure → Questions: every question we ask, named / share / change / cited
|
|
1479
1485
|
insights pages [--period 14d|30d|90d] [--site own|phantoms|<key>] Measure → Pages: your pages AI answers cited, won questions first
|
|
1486
|
+
insights mentions [--site phantoms|<key>]... Measure → Pages → Naming you: which posts on your phantom sites name you
|
|
1480
1487
|
insights competitors [--period 14d|30d|90d] GEO → Competitors: share of mentions per brand, is it moving, by engine/question
|
|
1481
1488
|
insights question <key> [--period 14d|30d|90d] [--filter all|named_you|rival_not_you|no_one] [--limit n]
|
|
1482
1489
|
One By-question row: the wordings asked and the AI answers
|
package/lib/commands/admin.mjs
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// admin brand-detection <org-id> [--term t]... [--exact t]... [--exclude p]... [--note "…"] | --clear [--note "…"] (fleet:instrument)
|
|
21
21
|
// admin recipes list|show|vocab|export|import|save|delete … (recipes:read / recipes:write)
|
|
22
22
|
// admin letterpress settings|flip|set … (recipes:read / recipes:write)
|
|
23
|
-
// admin demo guide|list|show|set|reset … (demo:read / demo:write)
|
|
23
|
+
// admin demo guide|list|show|set|reset|check … (demo:read / demo:write)
|
|
24
24
|
// admin models runs|run|star|unstar|scoreboard|requests|request|sampling … (models:read / models:write)
|
|
25
25
|
// admin replays [--org <id>] [--target <id>] [--status …] [--limit n] (fleet:read)
|
|
26
26
|
// admin replay --org <id> [<response-id> | --target <id>] [--surface …] (fleet:replay)
|
|
@@ -2740,6 +2740,35 @@ function onboardingLines(o) {
|
|
|
2740
2740
|
].join("\n");
|
|
2741
2741
|
}
|
|
2742
2742
|
|
|
2743
|
+
function prospectOrgHeadline(p) {
|
|
2744
|
+
const call = p.callAt ? ` call ${p.callAt.slice(0, 16).replace("T", " ")}` : "";
|
|
2745
|
+
return `${p.status.padEnd(9)} ${p.accountName ?? p.accountId} ${p.domain || "(no domain)"}${call}${p.note ? ` — ${p.note}` : ""}`;
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
function prospectOrgLines(p) {
|
|
2749
|
+
if (!p) return "(no prospect org for this account)";
|
|
2750
|
+
const mark = { done: "✓", skipped: "–", failed: "✗", running: "…", pending: "·" };
|
|
2751
|
+
return [
|
|
2752
|
+
`${p.id} ${prospectOrgHeadline(p)}`,
|
|
2753
|
+
...(p.orgName ? [` org: ${p.orgName} (${p.orgId})`] : []),
|
|
2754
|
+
...p.steps.map(
|
|
2755
|
+
(s) =>
|
|
2756
|
+
` ${mark[s.status] ?? "?"} ${s.key.padEnd(16)} ${s.status}${s.detail ? ` ${s.detail}` : ""}${s.error ? `\n error: ${s.error}` : ""}`
|
|
2757
|
+
),
|
|
2758
|
+
...(p.competitors.length
|
|
2759
|
+
? [
|
|
2760
|
+
` competitors: ${p.competitors
|
|
2761
|
+
.map(
|
|
2762
|
+
(c) =>
|
|
2763
|
+
`${c.host}${c.employees != null ? ` (${c.employees} people)` : ""}${c.pages != null ? ` ${c.pages} pages` : ""}`
|
|
2764
|
+
)
|
|
2765
|
+
.join(", ")}`,
|
|
2766
|
+
]
|
|
2767
|
+
: []),
|
|
2768
|
+
...(p.openUrl ? [` open: ${p.openUrl}`] : []),
|
|
2769
|
+
].join("\n");
|
|
2770
|
+
}
|
|
2771
|
+
|
|
2743
2772
|
function dollars(cents) {
|
|
2744
2773
|
return `$${(cents / 100).toLocaleString("en-US", { maximumFractionDigits: 2 })}`;
|
|
2745
2774
|
}
|
|
@@ -3752,6 +3781,31 @@ async function cmdAdminCrm(ctx) {
|
|
|
3752
3781
|
onboardingLines(x.onboarding)
|
|
3753
3782
|
);
|
|
3754
3783
|
}
|
|
3784
|
+
case "prospect-org": {
|
|
3785
|
+
// admin crm prospect-org <account-id> [--start] [--domain acme.com] — the org prepared
|
|
3786
|
+
// for the account's booked call (docs/architecture/prospect-orgs.md). --start (or a
|
|
3787
|
+
// --domain) starts it by hand, or retries its failed steps; the key then needs
|
|
3788
|
+
// crm:write + org:create.
|
|
3789
|
+
if (!id) throw new CliError("Usage: admin crm prospect-org <account-id> [--start] [--domain acme.com]");
|
|
3790
|
+
if (flagBool(flags.start) || flags.domain) {
|
|
3791
|
+
const r = await staffPost(ctx, `${CRM}/accounts/${id}/prospect-org`, compact({ domain: flags.domain }));
|
|
3792
|
+
return out(r, (x) => prospectOrgLines(x.prospectOrg));
|
|
3793
|
+
}
|
|
3794
|
+
return out(await staffRequest(ctx, "GET", `${CRM}/accounts/${id}/prospect-org`), (x) =>
|
|
3795
|
+
prospectOrgLines(x.prospectOrg)
|
|
3796
|
+
);
|
|
3797
|
+
}
|
|
3798
|
+
case "prospect-orgs": {
|
|
3799
|
+
// admin crm prospect-orgs [--status ready] [--limit 50] — the orgs prepared for booked
|
|
3800
|
+
// calls, newest first.
|
|
3801
|
+
const q = new URLSearchParams(compact({ status: flags.status, limit: flags.limit }));
|
|
3802
|
+
const qs = q.toString() ? `?${q}` : "";
|
|
3803
|
+
return out(await staffRequest(ctx, "GET", `${CRM}/prospect-orgs${qs}`), (x) =>
|
|
3804
|
+
x.prospectOrgs.length
|
|
3805
|
+
? x.prospectOrgs.map((p) => prospectOrgHeadline(p)).join("\n")
|
|
3806
|
+
: "(no prospect orgs yet)"
|
|
3807
|
+
);
|
|
3808
|
+
}
|
|
3755
3809
|
case "onboard-plan": {
|
|
3756
3810
|
// admin crm onboard-plan <account-id> [--refresh] — what the calls say onboarding
|
|
3757
3811
|
// should set up (sites, Slack/app people, notes) + paid or not. --refresh re-reads.
|
|
@@ -3797,7 +3851,7 @@ async function cmdAdminCrm(ctx) {
|
|
|
3797
3851
|
}
|
|
3798
3852
|
default:
|
|
3799
3853
|
throw new CliError(
|
|
3800
|
-
"Usage: admin crm import|capture|outreach|signals|record|signal|accounts|account|score|slack-channels|link-slack|white-glove|set-white-glove|churn|revenue|reach-outs|replies|record-churn|draft-churn-reason|undo-churn|outcomes|record-outcome|renewals|track-record|weekly-note|at-risk|expansion-signals|collections|delivery-flags|pulse|case|onboard|onboarding|retry-onboarding|onboard-plan|payment-link … (see --help)"
|
|
3854
|
+
"Usage: admin crm import|capture|outreach|signals|record|signal|accounts|account|score|slack-channels|link-slack|white-glove|set-white-glove|churn|revenue|reach-outs|replies|record-churn|draft-churn-reason|undo-churn|outcomes|record-outcome|renewals|track-record|weekly-note|at-risk|expansion-signals|collections|delivery-flags|pulse|case|onboard|onboarding|retry-onboarding|onboard-plan|prospect-org|prospect-orgs|payment-link … (see --help)"
|
|
3801
3855
|
);
|
|
3802
3856
|
}
|
|
3803
3857
|
}
|
|
@@ -4932,58 +4986,27 @@ async function cmdAdminRepublish(ctx) {
|
|
|
4932
4986
|
|
|
4933
4987
|
const RECIPES = "/api/superadmin/recipes";
|
|
4934
4988
|
/** The fields a recipe file carries: what import_recipes reads back. */
|
|
4935
|
-
const RECIPE_FILE_FIELDS = [
|
|
4936
|
-
"id",
|
|
4937
|
-
"name",
|
|
4938
|
-
"tab",
|
|
4939
|
-
"outcomes",
|
|
4940
|
-
"company_types",
|
|
4941
|
-
"fits_when",
|
|
4942
|
-
"look_at",
|
|
4943
|
-
"when_to_use",
|
|
4944
|
-
"when_not_to_use",
|
|
4945
|
-
"example",
|
|
4946
|
-
"impact",
|
|
4947
|
-
"moves",
|
|
4948
|
-
"primitives",
|
|
4949
|
-
"enabled",
|
|
4950
|
-
"position",
|
|
4951
|
-
];
|
|
4989
|
+
const RECIPE_FILE_FIELDS = ["id", "name", "recipe", "when_to_use", "when_not_to_use", "weight"];
|
|
4952
4990
|
const RECIPES_USAGE =
|
|
4953
|
-
"Usage: admin recipes list [--
|
|
4991
|
+
"Usage: admin recipes list [--approach seo|geo|agent_conviction|inbound_conversion|outbound|other] | show <id|name> | vocab | stats | export [--out <file>] | import <file> [--dry-run] | save [<id>] [--file <recipe.json>] [--name …] [--recipe …] [--when-to-use …] [--when-not-to-use …] [--weight 1..10] | delete <id> --yes";
|
|
4954
4992
|
|
|
4955
4993
|
const recipeForFile = (r) => Object.fromEntries(RECIPE_FILE_FIELDS.map((k) => [k, r[k]]));
|
|
4956
4994
|
|
|
4995
|
+
/** A recipe's approaches (read from its words by the server), or "other". */
|
|
4996
|
+
const recipeApproaches = (r) => (r.approaches?.length ? r.approaches.join(", ") : "other");
|
|
4997
|
+
|
|
4957
4998
|
function recipeLine(r) {
|
|
4958
|
-
|
|
4959
|
-
r.outcomes?.length ? `outcomes ${r.outcomes.join(",")}` : "every outcome",
|
|
4960
|
-
r.company_types?.length ? `kinds ${r.company_types.join(",")}` : "every kind",
|
|
4961
|
-
r.tab === "plan"
|
|
4962
|
-
? `${r.moves?.length ?? 0} moves · stands up ${r.primitives?.length ? r.primitives.join(",") : "nothing"}`
|
|
4963
|
-
: null,
|
|
4964
|
-
]
|
|
4965
|
-
.filter(Boolean)
|
|
4966
|
-
.join(" · ");
|
|
4967
|
-
return `${String(r.position).padStart(4)} ${r.enabled ? "on " : "off"} ${r.tab.padEnd(5)} ${r.name} v${r.version} [${scope}] ${r.id}`;
|
|
4999
|
+
return `${String(r.weight).padStart(2)}/10 ${r.name} [${recipeApproaches(r)}] ${r.id}`;
|
|
4968
5000
|
}
|
|
4969
5001
|
|
|
4970
5002
|
function recipeDetail(r) {
|
|
4971
5003
|
return [
|
|
4972
|
-
`${r.name}
|
|
4973
|
-
`
|
|
4974
|
-
`
|
|
4975
|
-
`
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
` when to use: ${r.when_to_use || "—"}`,
|
|
4979
|
-
` when not to use: ${r.when_not_to_use || "—"}`,
|
|
4980
|
-
` example: ${r.example || "—"}`,
|
|
4981
|
-
r.tab === "plan"
|
|
4982
|
-
? ` moves:\n${(r.moves ?? []).map((m) => ` ${m.id}${m.stage ? ` · ${m.stage}` : ""}${m.after?.length ? ` · after ${m.after.join(",")}` : ""}${m.recommend ? " · recommend" : ""}${m.keep ? " · keep" : ""}${m.optional ? " · optional" : ""}${m.required ? " · required" : ""}${m.why ? ` · "${m.why}"` : ""}`).join("\n")}`
|
|
4983
|
-
: null,
|
|
4984
|
-
]
|
|
4985
|
-
.filter(Boolean)
|
|
4986
|
-
.join("\n");
|
|
5004
|
+
`${r.name} weight ${r.weight}/10 ${r.id}`,
|
|
5005
|
+
...(r.approaches ? [` approaches: ${recipeApproaches(r)}`] : []),
|
|
5006
|
+
` recipe: ${r.recipe || "—"}`,
|
|
5007
|
+
` when to use: ${r.when_to_use || "—"}`,
|
|
5008
|
+
` when not to use: ${r.when_not_to_use || "—"}`,
|
|
5009
|
+
].join("\n");
|
|
4987
5010
|
}
|
|
4988
5011
|
|
|
4989
5012
|
function readJson(path) {
|
|
@@ -5002,46 +5025,21 @@ function readRecipesFile(path) {
|
|
|
5002
5025
|
return recipes.map((r) => compact(recipeForFile(r)));
|
|
5003
5026
|
}
|
|
5004
5027
|
|
|
5005
|
-
/** A list flag for save: `a,b` (repeatable), `none` to clear it; a bare flag is a mistake. */
|
|
5006
|
-
function recipeListFlag(flags, name) {
|
|
5007
|
-
const v = flags[name];
|
|
5008
|
-
if (v === undefined) return undefined;
|
|
5009
|
-
if (v === true) throw new CliError(`--${name} needs a value: a,b or none`);
|
|
5010
|
-
return flagStr(v) === "none" ? [] : flagCsv(v);
|
|
5011
|
-
}
|
|
5012
|
-
|
|
5013
5028
|
/** The fields `admin recipes save` sets: one recipe from --file (or show --json's output), then flags over it. */
|
|
5014
5029
|
function recipeFromFlags(flags) {
|
|
5015
5030
|
const path = flagStr(flags.file);
|
|
5016
5031
|
const parsed = path ? readJson(path) : {};
|
|
5017
|
-
const base = parsed?.recipe
|
|
5032
|
+
const base = parsed?.recipe && typeof parsed.recipe === "object" ? parsed.recipe : parsed;
|
|
5018
5033
|
if (!base || typeof base !== "object" || Array.isArray(base) || Array.isArray(base.recipes)) {
|
|
5019
5034
|
throw new CliError("--file holds one recipe object; use admin recipes import for several");
|
|
5020
5035
|
}
|
|
5021
|
-
const movesFlag = flagStr(flags["moves-json"]);
|
|
5022
|
-
let moves;
|
|
5023
|
-
if (movesFlag !== undefined) {
|
|
5024
|
-
try {
|
|
5025
|
-
moves = JSON.parse(movesFlag);
|
|
5026
|
-
} catch (err) {
|
|
5027
|
-
throw new CliError(`--moves-json holds a JSON array of moves: ${err.message}`);
|
|
5028
|
-
}
|
|
5029
|
-
}
|
|
5030
5036
|
return compact({
|
|
5031
5037
|
...compact(recipeForFile(base)),
|
|
5032
5038
|
name: flagStr(flags.name),
|
|
5033
|
-
|
|
5034
|
-
look_at: flagStr(flags["look-at"]),
|
|
5039
|
+
recipe: flagStr(flags.recipe),
|
|
5035
5040
|
when_to_use: flagStr(flags["when-to-use"]),
|
|
5036
5041
|
when_not_to_use: flagStr(flags["when-not-to-use"]),
|
|
5037
|
-
|
|
5038
|
-
example: flagStr(flags.example),
|
|
5039
|
-
moves,
|
|
5040
|
-
primitives: recipeListFlag(flags, "primitives"),
|
|
5041
|
-
outcomes: recipeListFlag(flags, "outcomes"),
|
|
5042
|
-
company_types: recipeListFlag(flags, "company-types"),
|
|
5043
|
-
enabled: flagBool(flags.disable) ? false : flagBool(flags.enable) ? true : undefined,
|
|
5044
|
-
position: flagNum(flags.position),
|
|
5042
|
+
weight: flagNum(flags.weight),
|
|
5045
5043
|
});
|
|
5046
5044
|
}
|
|
5047
5045
|
|
|
@@ -5153,7 +5151,7 @@ async function cmdAdminLetterpress(ctx) {
|
|
|
5153
5151
|
`Letterpress, last ${s.days} days (settings v${s.settings.version}${s.settings.defaults_only ? ", defaults" : ""}, questions v${s.judgement_version})`,
|
|
5154
5152
|
...s.lenses.map(
|
|
5155
5153
|
(l) =>
|
|
5156
|
-
`${l.lens.padEnd(6)} ${l.mode.padEnd(6)} ${String(l.runs).padStart(3)} runs recipes ${l.recipes
|
|
5154
|
+
`${l.lens.padEnd(6)} ${l.mode.padEnd(6)} ${String(l.runs).padStart(3)} runs recipes ${l.recipes} followed a recipe ${l.followed.recipe} / none ${l.followed.none}${l.shadow ? ` shadow: top same ${l.shadow.top_same}/${l.shadow.runs}, order same ${l.shadow.order_same}` : ""}${l.drift?.pairs ? ` drift ${l.drift.changed}/${l.drift.pairs}` : ""}${l.prompt_hash ? ` prompt ${l.prompt_hash}` : ""}${l.model ? ` ${l.model}` : ""}`
|
|
5157
5155
|
),
|
|
5158
5156
|
s.surfaces.length
|
|
5159
5157
|
? `asks from: ${s.surfaces.map((x) => `${x.surface} ${x.runs}`).join(", ")}`
|
|
@@ -5234,7 +5232,7 @@ async function cmdAdminLetterpress(ctx) {
|
|
|
5234
5232
|
|
|
5235
5233
|
/**
|
|
5236
5234
|
* `admin recipes …` — the recipes page (/superadmin/recipes) for an agent: Letter's one library
|
|
5237
|
-
* of direction for Letterpress on Plan, Build and Fix
|
|
5235
|
+
* of direction for Letterpress on Plan, Build and Fix, five fields each. The loop for building it out is
|
|
5238
5236
|
* `vocab` (what a recipe can say) → `export --out recipes.json` → edit → `import recipes.json
|
|
5239
5237
|
* --dry-run` → `import recipes.json`; `stats` says how each recipe's suggestions fare. Reads need
|
|
5240
5238
|
* recipes:read on the staff key, writes recipes:write; every write is recorded as the key holder's.
|
|
@@ -5242,26 +5240,38 @@ async function cmdAdminLetterpress(ctx) {
|
|
|
5242
5240
|
async function cmdAdminRecipes(ctx) {
|
|
5243
5241
|
const { flags, positionals, io } = ctx;
|
|
5244
5242
|
const sub = positionals[0];
|
|
5245
|
-
const
|
|
5246
|
-
const all = async () =>
|
|
5247
|
-
(await staffRequest(ctx, "GET", tab ? `${RECIPES}?tab=${encodeURIComponent(tab)}` : RECIPES)).recipes ?? [];
|
|
5243
|
+
const all = async () => (await staffRequest(ctx, "GET", RECIPES)).recipes ?? [];
|
|
5248
5244
|
switch (sub) {
|
|
5249
5245
|
case "stats": {
|
|
5250
5246
|
const result = await staffRequest(ctx, "GET", `${RECIPES}/stats`);
|
|
5247
|
+
const pct = (share) => (share === null ? " —" : `${String(Math.round(share * 100)).padStart(3)}%`);
|
|
5251
5248
|
printResult(io, flags, result, (r) =>
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5249
|
+
[
|
|
5250
|
+
`Runs over the last ${r.usage_days ?? 30} days (followed / had it to choose from):`,
|
|
5251
|
+
...(r.usage?.length
|
|
5252
|
+
? r.usage.map(
|
|
5253
|
+
(u) =>
|
|
5254
|
+
`${String(u.runs).padStart(5)} runs ${pct(u.selected_share)} of ${String(u.offered).padEnd(4)} plan ${u.by_lens.plan} build ${u.by_lens.build} fix ${u.by_lens.fix} ${u.name}`
|
|
5255
|
+
)
|
|
5256
|
+
: [" No recipes yet."]),
|
|
5257
|
+
"",
|
|
5258
|
+
"What the passes show and people dismissed:",
|
|
5259
|
+
...(r.stats.length
|
|
5260
|
+
? r.stats.map(
|
|
5255
5261
|
(s) =>
|
|
5256
|
-
`${String(s.shown).padStart(5)} shown ${String(s.dismissed).padStart(4)} dismissed ${String(s.resolved ?? 0).padStart(4)} resolved ${String(s.built ?? 0).padStart(3)} built ${s.
|
|
5262
|
+
`${String(s.shown).padStart(5)} shown ${String(s.dismissed).padStart(4)} dismissed ${String(s.resolved ?? 0).padStart(4)} resolved ${String(s.built ?? 0).padStart(3)} built ${s.lens.padEnd(5)} ${s.recipe}${s.reasons.length ? `\n why: ${s.reasons.slice(0, 3).join(" · ")}` : ""}`
|
|
5257
5263
|
)
|
|
5258
|
-
|
|
5259
|
-
|
|
5264
|
+
: [" No suggestions from the passes yet."]),
|
|
5265
|
+
].join("\n")
|
|
5260
5266
|
);
|
|
5261
5267
|
return 0;
|
|
5262
5268
|
}
|
|
5263
5269
|
case "list": {
|
|
5264
|
-
const
|
|
5270
|
+
const approach = flagStr(flags.approach);
|
|
5271
|
+
const recipes = approach
|
|
5272
|
+
? ((await staffRequest(ctx, "GET", `${RECIPES}?approach=${encodeURIComponent(approach)}`)).recipes ??
|
|
5273
|
+
[])
|
|
5274
|
+
: await all();
|
|
5265
5275
|
printResult(io, flags, { recipes }, (r) =>
|
|
5266
5276
|
r.recipes.length ? r.recipes.map(recipeLine).join("\n") : "No recipes yet."
|
|
5267
5277
|
);
|
|
@@ -5280,23 +5290,11 @@ async function cmdAdminRecipes(ctx) {
|
|
|
5280
5290
|
[
|
|
5281
5291
|
...r.how_recipes_are_read.map((line) => `· ${line}`),
|
|
5282
5292
|
"",
|
|
5283
|
-
"
|
|
5284
|
-
...r.
|
|
5293
|
+
"Lenses (each reads the whole library):",
|
|
5294
|
+
...r.lenses.map((t) => ` ${t.id}: reads ${t.reads}`),
|
|
5285
5295
|
"",
|
|
5286
5296
|
"Fields:",
|
|
5287
5297
|
...r.fields.map((f) => ` ${f.name}: ${f.description}`),
|
|
5288
|
-
"",
|
|
5289
|
-
"A move's fields (plan):",
|
|
5290
|
-
...r.move_fields.map((f) => ` ${f.name}: ${f.description}`),
|
|
5291
|
-
"",
|
|
5292
|
-
`Actions a move may name: ${r.actions.join(", ")}`,
|
|
5293
|
-
`Evidence the moves can make a plan read: ${r.evidence.join(", ")}`,
|
|
5294
|
-
"",
|
|
5295
|
-
"Outcomes:",
|
|
5296
|
-
...r.outcomes.map((g) => ` ${g.id}${g.available ? "" : " (not available yet)"}: ${g.brief}`),
|
|
5297
|
-
"",
|
|
5298
|
-
`Company types: ${r.company_types.map((t) => `${t.id} (${t.label})`).join(", ")}`,
|
|
5299
|
-
`Primitives: ${r.primitives.map((p) => `${p.id} (${p.label})`).join(", ")}`,
|
|
5300
5298
|
].join("\n")
|
|
5301
5299
|
);
|
|
5302
5300
|
return 0;
|
|
@@ -5315,13 +5313,11 @@ async function cmdAdminRecipes(ctx) {
|
|
|
5315
5313
|
const result = await staffPost(ctx, `${RECIPES}/import`, {
|
|
5316
5314
|
recipes: readRecipesFile(path),
|
|
5317
5315
|
dry_run: flagBool(flags["dry-run"]),
|
|
5318
|
-
retire_missing: flagBool(flags["retire-missing"]),
|
|
5319
5316
|
});
|
|
5320
5317
|
const verb = {
|
|
5321
5318
|
create: "create",
|
|
5322
5319
|
update: "update",
|
|
5323
5320
|
unchanged: "same ",
|
|
5324
|
-
retire: "retire",
|
|
5325
5321
|
failed: "FAILED",
|
|
5326
5322
|
};
|
|
5327
5323
|
printResult(io, flags, result, (r) =>
|
|
@@ -5330,7 +5326,7 @@ async function cmdAdminRecipes(ctx) {
|
|
|
5330
5326
|
(row) =>
|
|
5331
5327
|
`${verb[row.action] ?? row.action} ${row.name}${row.changed.length && row.action !== "create" ? ` (${row.changed.join(", ")})` : ""}${row.error ? ` → ${row.error}` : ""}`
|
|
5332
5328
|
),
|
|
5333
|
-
`${r.dry_run ? "Would create" : "Created"} ${r.counts.created}, ${r.dry_run ? "update" : "updated"} ${r.counts.updated}
|
|
5329
|
+
`${r.dry_run ? "Would create" : "Created"} ${r.counts.created}, ${r.dry_run ? "update" : "updated"} ${r.counts.updated}; ${r.counts.unchanged} unchanged, ${r.counts.failed} failed.${r.dry_run ? " Nothing was written (--dry-run)." : ""}`,
|
|
5334
5330
|
].join("\n")
|
|
5335
5331
|
);
|
|
5336
5332
|
return result.counts?.failed ? 1 : 0;
|
|
@@ -5349,9 +5345,7 @@ async function cmdAdminRecipes(ctx) {
|
|
|
5349
5345
|
case "delete": {
|
|
5350
5346
|
const id = requirePositional(positionals, 1, "id");
|
|
5351
5347
|
if (!flagBool(flags.yes)) {
|
|
5352
|
-
io.error(
|
|
5353
|
-
`Re-run with --yes to delete for good: ${ctx.bin} admin recipes delete ${id} --yes (save --disable retires one and keeps it)`
|
|
5354
|
-
);
|
|
5348
|
+
io.error(`Re-run with --yes to delete for good: ${ctx.bin} admin recipes delete ${id} --yes`);
|
|
5355
5349
|
return 1;
|
|
5356
5350
|
}
|
|
5357
5351
|
const result = await staffRequest(ctx, "DELETE", `${RECIPES}/${encodeURIComponent(id)}`);
|
|
@@ -5783,7 +5777,7 @@ async function cmdAdminBilling(ctx) {
|
|
|
5783
5777
|
|
|
5784
5778
|
// `admin demo` — demo control (docs/architecture/demo-control.md): what each demo org shows,
|
|
5785
5779
|
// set, rehearsed and reset. The staff routes behind /superadmin/demo, the same functions and
|
|
5786
|
-
// schema as list_demo_orgs / get_demo_state / set_demo_state / reset_demo_state.
|
|
5780
|
+
// schema as list_demo_orgs / get_demo_state / set_demo_state / reset_demo_state / run_demo_readiness_check.
|
|
5787
5781
|
const DEMO = "/api/superadmin/demo";
|
|
5788
5782
|
const DEMO_ITEM_FLAGS = [
|
|
5789
5783
|
"phantom",
|
|
@@ -5798,7 +5792,15 @@ const DEMO_ITEM_FLAGS = [
|
|
|
5798
5792
|
"setup",
|
|
5799
5793
|
];
|
|
5800
5794
|
const DEMO_USAGE =
|
|
5801
|
-
"Usage: admin demo guide | list [--enrollable] | show <org-id> [--moves] | set <org-id> [--enroll] [--unenroll] [--file <state.json>] [--phantom parked|shown] [--main-blog …] [--visitors …] [--probes not_run|shown] [--cms hidden|shown] [--publish-target …] [--search-console …] [--github …] [--domain …] [--setup fresh|finished] [--domain-cap n] [--inject <key>]... [--hide <key>]... [--save-as <name>] | reset <org-id> <scenario> [--clean-slate] [--close-prs since_applied|all_open|none]";
|
|
5795
|
+
"Usage: admin demo guide | list [--enrollable] | show <org-id> [--moves] | set <org-id> [--enroll] [--unenroll] [--file <state.json>] [--phantom parked|shown] [--main-blog …] [--visitors …] [--probes not_run|shown] [--cms hidden|shown] [--publish-target …] [--search-console …] [--github …] [--domain …] [--setup fresh|finished] [--domain-cap n] [--inject <key>]... [--hide <key>]... [--save-as <name>] [--auto-reset <scenario>|off] [--every <minutes>] [--release] | reset <org-id> <scenario> [--clean-slate] [--close-prs since_applied|all_open|none] [--hold <minutes>] | check <org-id>";
|
|
5796
|
+
|
|
5797
|
+
const readinessLines = (r) =>
|
|
5798
|
+
r
|
|
5799
|
+
? [
|
|
5800
|
+
`${r.ok ? "READY" : "NOT READY"} (checked ${r.at})`,
|
|
5801
|
+
...r.checks.map((c) => ` ${c.ok ? "ok " : "FAIL"} ${c.label}: ${c.detail}`),
|
|
5802
|
+
].join("\n")
|
|
5803
|
+
: "Not checked yet.";
|
|
5802
5804
|
|
|
5803
5805
|
async function cmdAdminDemo(ctx) {
|
|
5804
5806
|
const { flags, positionals, io } = ctx;
|
|
@@ -5836,7 +5838,11 @@ async function cmdAdminDemo(ctx) {
|
|
|
5836
5838
|
(o) =>
|
|
5837
5839
|
`${o.enrolled ? "demo" : "test"} ${o.name} ${o.domain ?? "—"} ${o.scenario ?? ""}${
|
|
5838
5840
|
o.differs?.length ? ` [${o.differs.join(", ")}]` : ""
|
|
5839
|
-
}
|
|
5841
|
+
}${o.ready === true ? " ready" : o.ready === false ? " NOT READY" : ""}${
|
|
5842
|
+
o.auto_reset
|
|
5843
|
+
? ` auto ${o.auto_reset.scenario}/${o.auto_reset.every_minutes}m`
|
|
5844
|
+
: ""
|
|
5845
|
+
}${o.held ? ` held until ${o.held.until}` : ""} ${o.org_id}`
|
|
5840
5846
|
)
|
|
5841
5847
|
.join("\n")
|
|
5842
5848
|
: "No demo orgs yet."
|
|
@@ -5856,6 +5862,8 @@ async function cmdAdminDemo(ctx) {
|
|
|
5856
5862
|
...r.knobs.map((k) => ` ${k.item.padEnd(16)} real: ${k.real} · shown: ${k.shown} (${k.how})`),
|
|
5857
5863
|
` observations open: ${r.observations.open.map((o) => `${o.key}${o.injected ? " (demo)" : ""}`).join(", ") || "none"}`,
|
|
5858
5864
|
` answers: ${r.answers.map((q) => `${q.named}/${q.answers} ${q.text}`).join("; ") || "never probed"}`,
|
|
5865
|
+
` auto-reset: ${r.state.auto_reset ? `${r.state.auto_reset.scenario} every ${r.state.auto_reset.every_minutes} min, next due ${r.state.auto_reset.next_due_at}` : "off"}${r.state.held ? ` · held until ${r.state.held.until}` : ""}`,
|
|
5866
|
+
readinessLines(r.state.readiness),
|
|
5859
5867
|
].join("\n")
|
|
5860
5868
|
);
|
|
5861
5869
|
return 0;
|
|
@@ -5883,6 +5891,13 @@ async function cmdAdminDemo(ctx) {
|
|
|
5883
5891
|
enroll: flagBool(flags.enroll) || undefined,
|
|
5884
5892
|
unenroll: flagBool(flags.unenroll) || undefined,
|
|
5885
5893
|
save_as: flagStr(flags["save-as"]),
|
|
5894
|
+
auto_reset: flagStr(flags["auto-reset"])
|
|
5895
|
+
? {
|
|
5896
|
+
scenario: flagStr(flags["auto-reset"]) === "off" ? null : flagStr(flags["auto-reset"]),
|
|
5897
|
+
...(flagNum(flags.every) ? { every_minutes: flagNum(flags.every) } : {}),
|
|
5898
|
+
}
|
|
5899
|
+
: undefined,
|
|
5900
|
+
release_hold: flagBool(flags.release) || undefined,
|
|
5886
5901
|
});
|
|
5887
5902
|
if (!Object.keys(body).length) throw new CliError(DEMO_USAGE);
|
|
5888
5903
|
const result = await staffRequest(ctx, "PATCH", `${DEMO}/${encodeURIComponent(orgId)}`, body);
|
|
@@ -5899,11 +5914,18 @@ async function cmdAdminDemo(ctx) {
|
|
|
5899
5914
|
scenario,
|
|
5900
5915
|
close_prs: flagStr(flags["close-prs"]),
|
|
5901
5916
|
clean_slate: flagBool(flags["clean-slate"]) || undefined,
|
|
5917
|
+
hold_minutes: flagNum(flags.hold) ?? undefined,
|
|
5902
5918
|
})
|
|
5903
5919
|
);
|
|
5904
|
-
printResult(io, flags, result, (r) => r.notes.join("\n"));
|
|
5920
|
+
printResult(io, flags, result, (r) => [r.notes.join("\n"), readinessLines(r.readiness)].join("\n"));
|
|
5905
5921
|
return 0;
|
|
5906
5922
|
}
|
|
5923
|
+
case "check": {
|
|
5924
|
+
const orgId = requirePositional(positionals, 1, "org-id");
|
|
5925
|
+
const result = await staffPost(ctx, `${DEMO}/${encodeURIComponent(orgId)}/check`, {});
|
|
5926
|
+
printResult(io, flags, result, (r) => readinessLines(r.readiness));
|
|
5927
|
+
return result.readiness?.ok ? 0 : 1;
|
|
5928
|
+
}
|
|
5907
5929
|
default:
|
|
5908
5930
|
throw new CliError(DEMO_USAGE);
|
|
5909
5931
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// network, single-post, and top-posts levels (ported from phantomstory-cli's
|
|
3
3
|
// insights.ts); plus Measure's Overview (`summary`), GEO → Competitors
|
|
4
4
|
// (`competitors`), AI Visibility Bank (`bank`) and phantom Page Access (`access`);
|
|
5
|
-
// Measure → Reads (`reads`), Questions (`questions`)
|
|
5
|
+
// Measure → Reads (`reads`), Questions (`questions`), Pages (`pages`) and the posts naming you (`mentions`), and the live feed of what
|
|
6
6
|
// is reading the phantom sites (`activity`) — the same reads the web app renders.
|
|
7
7
|
|
|
8
8
|
import { CliError } from "../client.mjs";
|
|
@@ -42,6 +42,9 @@ export const ARGS = {
|
|
|
42
42
|
period: { flag: "period", enum: PERIODS },
|
|
43
43
|
sites: { flag: "site", type: "list" },
|
|
44
44
|
},
|
|
45
|
+
list_site_mentions: {
|
|
46
|
+
sites: { flag: "site", type: "list" },
|
|
47
|
+
},
|
|
45
48
|
get_recent_activity: {
|
|
46
49
|
phantom_id: { flag: "phantom" },
|
|
47
50
|
limit: { flag: "limit", type: "num" },
|
|
@@ -82,11 +85,13 @@ export async function cmdInsights(ctx) {
|
|
|
82
85
|
return call(rest, "list_measure_questions");
|
|
83
86
|
case "pages":
|
|
84
87
|
return call(rest, "list_cited_pages");
|
|
88
|
+
case "mentions":
|
|
89
|
+
return call(rest, "list_site_mentions");
|
|
85
90
|
case "activity":
|
|
86
91
|
return call(rest, "get_recent_activity");
|
|
87
92
|
default:
|
|
88
93
|
throw new CliError(
|
|
89
|
-
`Unknown insights subcommand: ${sub ?? "(none)"}. Try: summary, reads, questions, pages, competitors, question, detection, activity, site, post, top, bank, access`
|
|
94
|
+
`Unknown insights subcommand: ${sub ?? "(none)"}. Try: summary, reads, questions, pages, mentions, competitors, question, detection, activity, site, post, top, bank, access`
|
|
90
95
|
);
|
|
91
96
|
}
|
|
92
97
|
}
|