@wrangled/cli 0.3.44 → 0.3.46

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/playbooks.js CHANGED
@@ -62,7 +62,7 @@ export const metaAdsPlaybook = `# Facebook ads agent playbook (practice mode)
62
62
 
63
63
  You are the daily Facebook ads agent for one client workspace in ${brand.name}. Each run you read the client's Meta results, write new ad ideas grounded in what already wins, make one image per idea, and propose pauses and budget changes. A person approves or rejects every proposal on the approvals page in the ${brand.name} web app.
64
64
 
65
- You work only through the \`${cli}\` CLI. Every command acts on the one workspace the saved API key belongs to. Add \`--format json\` whenever you need to read a field.
65
+ You work only through the \`${cli}\` CLI. Every command acts on one workspace, picked by \`--client\` or by a client file in this folder or above it, otherwise the default login. \`${cli} whoami\` says which one and why. Add \`--format json\` whenever you need to read a field.
66
66
 
67
67
  ## Rules that never bend
68
68
 
@@ -364,7 +364,7 @@ You are the weekly P3 refresh hand for one client workspace in ${brand.name}. Ea
364
364
 
365
365
  The program has already done the counting. Its draft ranks the ad sets, picks the audience template, and lists every P1 winner, marked new, already in P3, or unresolved. Your job is the judgment: which ad set to retire and why, which winners look worn out, and a short summary a busy owner can read.
366
366
 
367
- You work only through the \`${cli}\` CLI. Every command acts on the one workspace the saved API key belongs to. Pass \`--agent p3_refresh\` to every \`agent\` command; without it they act on a different hand. Add \`--format json\` whenever you need to read a field.
367
+ You work only through the \`${cli}\` CLI. Every command acts on one workspace, picked by \`--client\` or by a client file in this folder or above it, otherwise the default login. \`${cli} whoami\` says which one and why. Pass \`--agent p3_refresh\` to every \`agent\` command; without it they act on a different hand. Add \`--format json\` whenever you need to read a field.
368
368
 
369
369
  ## Rules that never bend
370
370
 
@@ -582,7 +582,7 @@ export const mapOffersPlaybook = `# Map offers playbook
582
582
 
583
583
  You draft one client workspace's offers and funnels map in ${brand.name}: what the client sells, in what order (the offer stack), and the steps a person walks from first seeing an ad to buying (each funnel). You write it from the client's own data. When you save it, ${brand.name} checks it against that data, and a map whose every step can be counted goes live at once. A person can undo it in the ${brand.name} web app.
584
584
 
585
- You work only through the \`${cli}\` CLI. Every command acts on the one workspace the saved API key belongs to. Add \`--format json\` whenever you need to read a field.
585
+ You work only through the \`${cli}\` CLI. Every command acts on one workspace, picked by \`--client\` or by a client file in this folder or above it, otherwise the default login. \`${cli} whoami\` says which one and why. Add \`--format json\` whenever you need to read a field.
586
586
 
587
587
  ## Rules that never bend
588
588
 
@@ -737,7 +737,7 @@ You draft one client workspace's two own lists of ad words in ${brand.name}: its
737
737
 
738
738
  You only suggest. Each value you add is marked not yet confirmed, and agents may use it at once. An Owner or Admin confirms, renames, merges or retires it on the Ad words page in the ${brand.name} web app.
739
739
 
740
- You work only through the \`${cli}\` CLI. Every command acts on the one workspace the saved API key belongs to.
740
+ You work only through the \`${cli}\` CLI. Every command acts on one workspace, picked by \`--client\` or by a client file in this folder or above it, otherwise the default login. \`${cli} whoami\` says which one and why.
741
741
 
742
742
  ## Rules that never bend
743
743
 
@@ -843,7 +843,7 @@ You do not work out the tags yourself. The server's tagger does: \`${cli} ads au
843
843
 
844
844
  Every tag the tagger saves is proposed: usable at once, marked not yet confirmed. You never confirm, fix or reject tags; an API key cannot. A person checks the ads that carry the top 20% of spend on the Tag check page in the ${brand.name} web app.
845
845
 
846
- You work only through the \`${cli}\` CLI. Every command acts on the one workspace the saved API key belongs to.
846
+ You work only through the \`${cli}\` CLI. Every command acts on one workspace, picked by \`--client\` or by a client file in this folder or above it, otherwise the default login. \`${cli} whoami\` says which one and why.
847
847
 
848
848
  ## Rules that never bend
849
849
 
@@ -931,7 +931,7 @@ You work out how one client names its Facebook campaigns, ad sets and ads, and w
931
931
 
932
932
  You only suggest. The key you save waits, not yet confirmed. An Owner or Admin answers your questions on the Ad words page's Naming tab in the ${brand.name} web app and then confirms the key. Nothing uses it until then.
933
933
 
934
- You work only through the \`${cli}\` CLI. Every command acts on the one workspace the saved API key belongs to.
934
+ You work only through the \`${cli}\` CLI. Every command acts on one workspace, picked by \`--client\` or by a client file in this folder or above it, otherwise the default login. \`${cli} whoami\` says which one and why.
935
935
 
936
936
  ## Rules that never bend
937
937
 
@@ -1223,7 +1223,7 @@ export const storyPlaybook = `# Weekly story hand playbook
1223
1223
 
1224
1224
  You write the weekly story for one client workspace in ${brand.name}: a one-screen read of how the frontend marketing did (ad spend, leads, sales from the ads, cost per new customer and order value), why, what is working and what isn't, what the data can't tell us, and what to do next, then a short big picture of backend revenue, with a shorter part for the client. It covers the 7 days that ended yesterday in the client's time zone, beside the 30 days that ended then, each compared with the period before. ${brand.name} checks every number: it runs each query behind the story itself when you save, and keeps the rows it got.
1225
1225
 
1226
- You work only through the \`${cli}\` CLI. Every command acts on the one workspace the saved API key belongs to. Pass \`--agent skill\` to every \`agent\` command. Add \`--format json\` whenever you need to read a field.
1226
+ You work only through the \`${cli}\` CLI. Every command acts on one workspace, picked by \`--client\` or by a client file in this folder or above it, otherwise the default login. \`${cli} whoami\` says which one and why. Pass \`--agent skill\` to every \`agent\` command. Add \`--format json\` whenever you need to read a field.
1227
1227
 
1228
1228
  ## Rules that never bend
1229
1229
 
@@ -1471,7 +1471,7 @@ After each weekly winners and flops report, you write down why the winners won a
1471
1471
 
1472
1472
  No person approves lessons. Write only what the numbers show.
1473
1473
 
1474
- You work only through the \`${cli}\` CLI. Every command acts on the one workspace the saved API key belongs to.
1474
+ You work only through the \`${cli}\` CLI. Every command acts on one workspace, picked by \`--client\` or by a client file in this folder or above it, otherwise the default login. \`${cli} whoami\` says which one and why.
1475
1475
 
1476
1476
  ## Rules that never bend
1477
1477
 
@@ -1594,7 +1594,7 @@ export const weeklyLoopPlaybook = `# Weekly loop playbook (sample)
1594
1594
 
1595
1595
  A sample to borrow from, not a schedule, for a local orchestrator agent that runs a client's Facebook ads with its owner. It reads what sold, learns from it, gathers fresh material, gets new ads made, has them published through Adzara, and later reads their results back. It is written as a week, but its steps can run daily, several times a week or weekly, each on its own rhythm: the winners report covers whatever dates you ask for. ${brand.name} supplies the data and keeps no part of the loop's decisions.
1596
1596
 
1597
- Every \`${cli}\` command acts on the one workspace the saved API key belongs to. Each step also names the MCP tool that does the same, for an agent connected over MCP without a shell.
1597
+ Every \`${cli}\` command acts on one workspace, picked by \`--client\` or by a client file in this folder or above it, otherwise the default login. \`${cli} whoami\` says which one and why. Each step also names the MCP tool that does the same, for an agent connected over MCP without a shell.
1598
1598
 
1599
1599
  ## Rules that never bend
1600
1600
 
@@ -1704,7 +1704,7 @@ export const pagesPlaybook = `# Page playbook
1704
1704
 
1705
1705
  You write one landing page for a client workspace in ${brand.name}: a page for a step of the client's funnel, or a new version of a page that already runs. ${brand.name} does not build pages. It hands you what already works, and takes the finished page back so its results count. A person approves every page before it goes online.
1706
1706
 
1707
- You work only through the \`${cli}\` CLI. Every command acts on the one workspace the saved API key belongs to. Add \`--format json\` whenever you need to read a field.
1707
+ You work only through the \`${cli}\` CLI. Every command acts on one workspace, picked by \`--client\` or by a client file in this folder or above it, otherwise the default login. \`${cli} whoami\` says which one and why. Add \`--format json\` whenever you need to read a field.
1708
1708
 
1709
1709
  ## Rules that never bend
1710
1710
 
@@ -1808,7 +1808,7 @@ Once a week you turn the funnel's costliest leaks into test ideas, put them to t
1808
1808
 
1809
1809
  ${brand.name} keeps the record of each test and no approvals. The owner says yes or no to each idea in your own session, and a change goes live through its own path, never through this playbook.
1810
1810
 
1811
- You work only through the \`${cli}\` CLI. Every command acts on the one workspace the saved API key belongs to.
1811
+ You work only through the \`${cli}\` CLI. Every command acts on one workspace, picked by \`--client\` or by a client file in this folder or above it, otherwise the default login. \`${cli} whoami\` says which one and why.
1812
1812
 
1813
1813
  ## Rules that never bend
1814
1814
 
@@ -151,7 +151,7 @@ async function execute(claim, dir, options, signal, log) {
151
151
  const skillsDir = join(dir, claim.harness === "claude" ? ".claude" : ".codex", "skills");
152
152
  await installSkillFolder(skillsDir, claim.skill.name, unpackSkill(claim.skill, await getSigned(claim.skill.url)), []);
153
153
  const configHome = join(dir, ".config");
154
- await writeCredentials({ apiKey: claim.runKey, apiUrl: options.apiUrl }, configHome);
154
+ await writeCredentials({ apiKey: claim.runKey, apiUrl: options.apiUrl }, { configHome });
155
155
  const binDir = join(dir, ".bin");
156
156
  await mkdir(binDir);
157
157
  await writeFile(join(binDir, brand.slug), cliShim(options.cliMain), { mode: 0o755 });
package/dist/skills.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createHash, randomBytes } from "node:crypto";
2
2
  import { lstat, mkdir, readdir, readFile, rename, rm, writeFile } from "node:fs/promises";
3
3
  import { dirname, join } from "node:path";
4
- import { CliError, exitCodes, readCredentials, resolveApiUrl, UnreadableCredentialsError } from "./api.js";
4
+ import { chosenApiUrl, CliError, exitCodes } from "./api.js";
5
5
  import { envPrefix } from "./brand.js";
6
6
  import { firstSymlink, inRunFolder } from "./files.js";
7
7
  import { readSkillZip, refuseOversizedFiles, refuseOversizedZip, refuseTooManyFiles, SKILL_NAME_PATTERN, SkillZipError, zipSkillFiles, } from "./skill-zip.js";
@@ -9,16 +9,11 @@ export const OPERATOR_TOKEN_ENV = `${envPrefix}_OPERATOR_TOKEN`;
9
9
  // Env files hold secrets, and a published skill reaches every workspace.
10
10
  const skipped = (entry) => [".git", "node_modules", ".DS_Store", ".env", ".envrc"].includes(entry) || entry.startsWith(".env.");
11
11
  /** Operator commands (the skill library, promoting and dropping a scheduled hand's candidate) take the operator token, never the workspace API key. */
12
- export async function operatorConnection(apiUrlFlag) {
12
+ export async function operatorConnection(options) {
13
13
  const token = process.env[OPERATOR_TOKEN_ENV];
14
14
  if (!token)
15
15
  throw new CliError(`Set ${OPERATOR_TOKEN_ENV} to the server's OPERATOR_TOKEN for operator commands.`, exitCodes.auth);
16
- const stored = await readCredentials().catch((error) => {
17
- if (error instanceof UnreadableCredentialsError)
18
- return null;
19
- throw error;
20
- });
21
- const apiUrl = resolveApiUrl(apiUrlFlag, stored);
16
+ const apiUrl = await chosenApiUrl(options);
22
17
  return { apiUrl, apiKey: token, rejected: `The operator token in ${OPERATOR_TOKEN_ENV} was rejected by ${apiUrl}.` };
23
18
  }
24
19
  /** `my-skill` or `my-skill@3`; a null version means the latest published one. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrangled/cli",
3
- "version": "0.3.44",
3
+ "version": "0.3.46",
4
4
  "description": "Command-line access to your marketing data warehouse, for people and coding agents",
5
5
  "type": "module",
6
6
  "bin": {