@wrangled/cli 0.3.48 → 0.3.49
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/dist/guide.js +34 -0
- package/dist/main.js +99 -0
- package/package.json +1 -1
package/dist/guide.js
CHANGED
|
@@ -17,6 +17,24 @@ export const funnelTestExample = {
|
|
|
17
17
|
split_method: "adzara_ads",
|
|
18
18
|
evidence: [{ kind: "customer_words", ref: "sales call 2026-09-30", note: "I didn't know what the webinar was about." }],
|
|
19
19
|
};
|
|
20
|
+
/** The dashboard the guide shows; the app's parser must accept it (src/lib/cli-consistency.test.ts). */
|
|
21
|
+
export const dashboardExample = {
|
|
22
|
+
title: "Daily ads and leads",
|
|
23
|
+
dateRange: { default: "30d", picker: true },
|
|
24
|
+
panels: [
|
|
25
|
+
{
|
|
26
|
+
id: "spend",
|
|
27
|
+
title: "Ad spend by day",
|
|
28
|
+
sql: "SELECT date, sum(spend) AS spend FROM daily_funnel WHERE date BETWEEN {{from}} AND {{to}} GROUP BY date ORDER BY date",
|
|
29
|
+
chart: "line",
|
|
30
|
+
x: "date",
|
|
31
|
+
y: ["spend"],
|
|
32
|
+
format: { spend: "money" },
|
|
33
|
+
width: 2,
|
|
34
|
+
},
|
|
35
|
+
{ id: "leads", title: "Leads", sql: "SELECT sum(leads) AS leads FROM daily_funnel WHERE date BETWEEN {{from}} AND {{to}}", chart: "number", y: ["leads"], format: { leads: "count" } },
|
|
36
|
+
],
|
|
37
|
+
};
|
|
20
38
|
export const guide = `# ${brand.name} CLI
|
|
21
39
|
|
|
22
40
|
\`${cli}\` gives read-only SQL access to one client's marketing data warehouse (ad spend, orders, and other synced sources), runs paid generation and research tools for that client, and keeps the creative ledger. Each API key belongs to exactly one workspace, and every command works only in that workspace.
|
|
@@ -266,6 +284,20 @@ Each section's \`audience\` is \`staff\`, \`client\` or \`both\`; a person on st
|
|
|
266
284
|
|
|
267
285
|
The story hand writes it each week. Its playbook installs with \`${cli} skill install story\` as the \`${STORY_SKILL_NAME}\` skill and prints with \`${cli} docs story\`.
|
|
268
286
|
|
|
287
|
+
## Team dashboards
|
|
288
|
+
|
|
289
|
+
A team dashboard is a page of charts the team opens for one client, such as daily ad spend, leads and cost per lead with a date picker. You write it as a short spec; ${brand.name} saves it and reads every number live each time someone opens it, so nothing is copied out. \`${cli} dashboards create --file spec.json\` publishes one (or pipe the spec on stdin):
|
|
290
|
+
|
|
291
|
+
\`\`\`json
|
|
292
|
+
${JSON.stringify(dashboardExample)}
|
|
293
|
+
\`\`\`
|
|
294
|
+
|
|
295
|
+
Each panel is one SQL query and how to draw it: \`chart\` is \`line\`, \`bar\`, \`area\`, \`table\` or \`number\`. A line, bar or area panel names its \`x\` column and its \`y\` columns; a number panel one \`y\` column. \`format\` marks columns as \`money\`, \`count\` or \`percent\`, and \`width\` 2 takes the full row. \`dateRange.default\` is \`7d\`, \`30d\`, \`90d\`, \`this-month\` or \`last-month\`, and \`picker\` shows a date picker. Write \`{{from}}\` and \`{{to}}\` where the page's first and last day go; the server binds them as dates in the client's reporting time zone, and refuses any other \`{{...}}\`. A dashboard has at most 20 panels and 20 KB of SQL in each.
|
|
296
|
+
|
|
297
|
+
Before saving, the server runs every panel once over the default range as this workspace's reader. A panel that fails, or lacks a column it names, refuses the whole spec with the panel's id and, when it knows one, a hint at the right name. The answer has \`url\`, the link that opens the dashboard for this client: give it to the person who asked.
|
|
298
|
+
|
|
299
|
+
\`${cli} dashboards update <slug> --file spec.json\` publishes the next version of the whole spec, \`${cli} dashboards rollback <slug> --version <n>\` publishes an earlier version's spec again as the next version, and \`${cli} dashboards archive <slug>\` takes one down. \`${cli} dashboards list\` lists them, and \`${cli} dashboards show <slug> --data\` prints the spec, every version, and each panel's rows now (\`--from\` and \`--to\` pick the days), so you can check the numbers.
|
|
300
|
+
|
|
269
301
|
## The Facebook ads agent
|
|
270
302
|
|
|
271
303
|
The daily Facebook ads agent follows its own playbook: install it with \`${cli} skill install meta-ads\` (or \`--codex\` for an AGENTS.md in the current directory) and read it with \`${cli} docs meta-ads\`. It works in runs (\`${cli} agent start\`, \`${cli} agent finish\`), reads and suggests settled facts (\`${cli} facts\`), keeps a brand profile (\`${cli} brand\`), and makes proposals (\`${cli} proposals\`) that a person approves in the web app. Nothing it does is sent to Meta.
|
|
@@ -383,6 +415,8 @@ ${cli} voice lists where that voice comes from: the competitors
|
|
|
383
415
|
${cli} voice suggest competitor|subreddit|search_phrase "<value>" [--note <why>] suggest a competitor, subreddit or Reddit search phrase for a person to approve
|
|
384
416
|
${cli} story [--json] | story list | story show <version> the weekly story, its versions, and the rows behind each sentence
|
|
385
417
|
${cli} story submit --file <story.json> save the next version of the weekly story
|
|
418
|
+
${cli} dashboards list | dashboards show <slug> [--data] [--from <date>] [--to <date>] the team dashboards, one's panels and versions, and its numbers now
|
|
419
|
+
${cli} dashboards create --file <spec.json> | dashboards update <slug> --file <spec.json> | dashboards rollback <slug> --version <n> | dashboards archive <slug>
|
|
386
420
|
${cli} worker list | worker runs <hand-id | skill> [--limit <n>] | worker run-now <hand-id | skill> this workspace's scheduled hands, their runs and costs, and Run now
|
|
387
421
|
${cli} skill install [${PLAYBOOK_CHOICES}] [--project] [--codex] install a Claude Code skill (or the playbook for Codex)
|
|
388
422
|
${cli} docs [${PLAYBOOK_CHOICES}] print this guide, or a hand's playbook
|
package/dist/main.js
CHANGED
|
@@ -1806,6 +1806,83 @@ const commands = {
|
|
|
1806
1806
|
printStory(story);
|
|
1807
1807
|
},
|
|
1808
1808
|
},
|
|
1809
|
+
"dashboards list": {
|
|
1810
|
+
usage: "dashboards list the team dashboards, the most recently changed first, with the link that opens each",
|
|
1811
|
+
async run(args, options) {
|
|
1812
|
+
if (args.length > 0)
|
|
1813
|
+
throw new CliError("Usage: dashboards list", exitCodes.usage);
|
|
1814
|
+
const { dashboards } = await api(await resolveConnection(options), DASHBOARDS_PATH);
|
|
1815
|
+
if (options.format === "json")
|
|
1816
|
+
return printJson({ dashboards });
|
|
1817
|
+
if (dashboards.length === 0)
|
|
1818
|
+
return console.log("No dashboards yet.");
|
|
1819
|
+
console.log(renderTable(["slug", "title", "version", "updated", "url"], dashboards.map((d) => ({ ...d, updated: d.updatedAt }))));
|
|
1820
|
+
},
|
|
1821
|
+
},
|
|
1822
|
+
"dashboards show": {
|
|
1823
|
+
usage: "dashboards show <slug> [--data] [--from <date>] [--to <date>] one dashboard's panels and versions; --data reads every panel's rows now",
|
|
1824
|
+
async run(args, options) {
|
|
1825
|
+
if (args.length !== 1)
|
|
1826
|
+
throw new CliError("Usage: dashboards show <slug> [--data] [--from <date>] [--to <date>]", exitCodes.usage);
|
|
1827
|
+
if (!options.data && (options.from !== undefined || options.to !== undefined))
|
|
1828
|
+
throw new CliError("--from and --to go with --data.", exitCodes.usage);
|
|
1829
|
+
const connection = await resolveConnection(options);
|
|
1830
|
+
const { dashboard } = await api(connection, dashboardPath(args[0]));
|
|
1831
|
+
let data;
|
|
1832
|
+
if (options.data) {
|
|
1833
|
+
const range = new URLSearchParams(Object.entries({ from: options.from, to: options.to }).filter((e) => e[1] !== undefined));
|
|
1834
|
+
data = JSON.parse(await apiText(connection, `${dashboardPath(args[0])}/data${range.size > 0 ? `?${range}` : ""}`), keepRawNumbers);
|
|
1835
|
+
}
|
|
1836
|
+
if (options.format === "json")
|
|
1837
|
+
return printJson(data ? { dashboard, data } : { dashboard });
|
|
1838
|
+
printDashboard(dashboard, data);
|
|
1839
|
+
},
|
|
1840
|
+
},
|
|
1841
|
+
"dashboards create": {
|
|
1842
|
+
usage: "dashboards create --file <spec.json> | < spec.json publish a new dashboard once every panel runs",
|
|
1843
|
+
async run(args, options) {
|
|
1844
|
+
if (args.length > 0)
|
|
1845
|
+
throw new CliError("Usage: dashboards create --file <spec.json> | < spec.json", exitCodes.usage);
|
|
1846
|
+
const { dashboard } = await api(await resolveConnection(options), DASHBOARDS_PATH, await readToolInput(options));
|
|
1847
|
+
if (options.format === "json")
|
|
1848
|
+
return printJson({ dashboard });
|
|
1849
|
+
console.log(`Published dashboard ${dashboard.slug}, version ${dashboard.version}.\n${dashboard.url}`);
|
|
1850
|
+
},
|
|
1851
|
+
},
|
|
1852
|
+
"dashboards update": {
|
|
1853
|
+
usage: "dashboards update <slug> --file <spec.json> | < spec.json publish the dashboard's next version once every panel runs",
|
|
1854
|
+
async run(args, options) {
|
|
1855
|
+
if (args.length !== 1)
|
|
1856
|
+
throw new CliError("Usage: dashboards update <slug> --file <spec.json> | < spec.json", exitCodes.usage);
|
|
1857
|
+
const { dashboard } = await api(await resolveConnection(options), dashboardPath(args[0]), await readToolInput(options), "PUT");
|
|
1858
|
+
if (options.format === "json")
|
|
1859
|
+
return printJson({ dashboard });
|
|
1860
|
+
console.log(`Published dashboard ${dashboard.slug}, version ${dashboard.version}.\n${dashboard.url}`);
|
|
1861
|
+
},
|
|
1862
|
+
},
|
|
1863
|
+
"dashboards rollback": {
|
|
1864
|
+
usage: "dashboards rollback <slug> --version <n> publish an earlier version's spec again, as the next version",
|
|
1865
|
+
async run(args, options) {
|
|
1866
|
+
if (args.length !== 1 || options.version === undefined)
|
|
1867
|
+
throw new CliError("Usage: dashboards rollback <slug> --version <n>", exitCodes.usage);
|
|
1868
|
+
const version = wholeNumber(options.version, "--version");
|
|
1869
|
+
const { dashboard } = await api(await resolveConnection(options), `${dashboardPath(args[0])}/rollback`, { version });
|
|
1870
|
+
if (options.format === "json")
|
|
1871
|
+
return printJson({ dashboard });
|
|
1872
|
+
console.log(`Published version ${version}'s spec as dashboard ${dashboard.slug}, version ${dashboard.version}.\n${dashboard.url}`);
|
|
1873
|
+
},
|
|
1874
|
+
},
|
|
1875
|
+
"dashboards archive": {
|
|
1876
|
+
usage: "dashboards archive <slug> take a dashboard down; its versions are kept, and publishing at its slug brings it back",
|
|
1877
|
+
async run(args, options) {
|
|
1878
|
+
if (args.length !== 1)
|
|
1879
|
+
throw new CliError("Usage: dashboards archive <slug>", exitCodes.usage);
|
|
1880
|
+
const { archived } = await api(await resolveConnection(options), dashboardPath(args[0]), undefined, "DELETE");
|
|
1881
|
+
if (options.format === "json")
|
|
1882
|
+
return printJson({ archived });
|
|
1883
|
+
console.log(`Archived dashboard ${archived.slug}.`);
|
|
1884
|
+
},
|
|
1885
|
+
},
|
|
1809
1886
|
"story submit": {
|
|
1810
1887
|
usage: "story submit --file <story.json> | < story.json save the next version; the server runs each query and keeps its rows",
|
|
1811
1888
|
async run(args, options) {
|
|
@@ -2626,6 +2703,26 @@ function nameKeyLines(value) {
|
|
|
2626
2703
|
return ["", "Name patterns:", ...(patterns.length > 0 ? patterns : ["- none yet"]), "", "Open questions:", ...(questions.length > 0 ? questions : ["- none"])];
|
|
2627
2704
|
}
|
|
2628
2705
|
const STORIES_PATH = "/api/v1/stories";
|
|
2706
|
+
const DASHBOARDS_PATH = "/api/v1/dashboards";
|
|
2707
|
+
const dashboardPath = (slug) => `${DASHBOARDS_PATH}/${encodeURIComponent(slug)}`;
|
|
2708
|
+
function printDashboard(dashboard, data) {
|
|
2709
|
+
console.log(`${dashboard.title}: version ${dashboard.version}, updated ${dashboard.updatedAt}.\n${dashboard.url}`);
|
|
2710
|
+
const range = dashboard.spec.dateRange;
|
|
2711
|
+
if (range)
|
|
2712
|
+
console.log(`Default range ${range.default}${range.picker ? ", with a date picker" : ""}.`);
|
|
2713
|
+
console.log(`\n${renderTable(["panel", "title", "chart", "x", "y"], dashboard.spec.panels.map((p) => ({ panel: p.id, title: p.title, chart: p.chart, x: p.x, y: p.y?.join(", ") })))}`);
|
|
2714
|
+
console.log(`\nVersions:\n${renderTable(["version", "by", "at"], dashboard.versions.map((v) => ({ version: v.version, by: v.createdBy, at: v.createdAt })))}`);
|
|
2715
|
+
if (!data)
|
|
2716
|
+
return;
|
|
2717
|
+
console.log(`\nNumbers from ${data.range.from} to ${data.range.to}:`);
|
|
2718
|
+
for (const panel of data.panels) {
|
|
2719
|
+
console.log(`\n${panel.id}`);
|
|
2720
|
+
if ("error" in panel)
|
|
2721
|
+
console.log(`failed: ${panel.error.message}${panel.error.hint ? `\nHint: ${panel.error.hint}` : ""}`);
|
|
2722
|
+
else
|
|
2723
|
+
console.log(`${renderTable(panel.columns.map((c) => c.name), panel.rows)}${panel.truncated ? `\n(cut off at the ${panel.truncated.replace("_", " ")})` : ""}`);
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2629
2726
|
function printStory(story) {
|
|
2630
2727
|
const corrects = story.previousId ? `, correcting ${story.previousId}` : "";
|
|
2631
2728
|
console.log(`Story version ${story.version}, up to ${story.periodEnd}, saved ${story.createdAt} by ${story.author}${corrects}.`);
|
|
@@ -2902,6 +2999,7 @@ function parseOptions(argv) {
|
|
|
2902
2999
|
confidence: { type: "string" },
|
|
2903
3000
|
remove: { type: "boolean", default: false },
|
|
2904
3001
|
"dry-run": { type: "boolean", default: false },
|
|
3002
|
+
data: { type: "boolean", default: false },
|
|
2905
3003
|
skill: { type: "string" },
|
|
2906
3004
|
cron: { type: "string" },
|
|
2907
3005
|
"time-zone": { type: "string" },
|
|
@@ -3024,6 +3122,7 @@ function parseOptions(argv) {
|
|
|
3024
3122
|
confidence: values.confidence,
|
|
3025
3123
|
remove: values.remove,
|
|
3026
3124
|
dryRun: values["dry-run"],
|
|
3125
|
+
data: values.data,
|
|
3027
3126
|
schedule: {
|
|
3028
3127
|
skill: values.skill,
|
|
3029
3128
|
name: values.name,
|