@brew.new/cli 0.4.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brew
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # brew-cli
2
+
3
+ Official agent-first command-line interface for the [Brew](https://brew.new)
4
+ public API — manage contacts, email designs, campaigns, automations,
5
+ audiences, domains, and analytics from the terminal, a script, or an AI
6
+ agent.
7
+
8
+ Built as a thin shell over [`@brew.new/sdk`](https://www.npmjs.com/package/@brew.new/sdk):
9
+ the SDK carries the typed transport (retries, idempotency, error
10
+ envelopes, types generated from the canonical OpenAPI spec), the CLI adds
11
+ the command surface and the agent contract. One source of truth end to
12
+ end: Zod contracts → OpenAPI → SDK → CLI, drift-gated at every hop.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install -g @brew.new/cli # or run without installing:
18
+ npx @brew.new/cli --help
19
+ ```
20
+
21
+ ```bash
22
+ brew install getbrew/tap/brew-cli # standalone binary (macOS/Linux)
23
+ ```
24
+
25
+ Prebuilt binaries for macOS (arm64/x64), Linux (x64/arm64), and Windows
26
+ are attached to every [GitHub Release](https://github.com/GetBrew/brew-cli/releases).
27
+
28
+ ## Quick start
29
+
30
+ ```bash
31
+ brew-cli login # paste an API key from https://brew.new/settings/api
32
+ brew-cli doctor # trust check: auth, reachability, CLI-vs-API drift (exit-code gated)
33
+ brew-cli whoami
34
+ brew-cli contacts search --filter email:equals:jane@example.com
35
+ brew-cli emails list --limit 10
36
+ brew-cli emails send em_123 --test --to you@company.com
37
+ ```
38
+
39
+ Every command supports `--json` (automatic when stdout is piped), prints
40
+ data on stdout and progress on stderr, and documents itself:
41
+
42
+ ```bash
43
+ brew-cli emails send --help
44
+ ```
45
+
46
+ ## Authentication
47
+
48
+ | Precedence | Source |
49
+ | --- | --- |
50
+ | 1 | `--api-key <key>` flag |
51
+ | 2 | `BREW_API_KEY` environment variable |
52
+ | 3 | `~/.config/brew-cli/config.json` (written by `brew-cli login`, mode 0600) |
53
+
54
+ Keys are created at [brew.new/settings/api](https://brew.new/settings/api).
55
+ A key is scoped either to ONE brand or to the whole organization.
56
+ Organization-scoped keys must name a brand on brand-scoped commands:
57
+ `--brand <brandId>`, `BREW_BRAND_ID`, or `brew-cli config set brandId …`.
58
+ Other environments: `--api-url http://localhost:3000/api` or
59
+ `BREW_API_URL`.
60
+
61
+ ## Agent contract
62
+
63
+ Designed for AI agents as first-class users:
64
+
65
+ - **Structured everything** — `--json` prints API envelopes verbatim;
66
+ auto-enabled when stdout is not a TTY. Errors are JSON envelopes on
67
+ stderr with stable `code`s and the `x-request-id`.
68
+ - **Semantic exit codes** — `0` ok · `1` API/runtime · `2` usage ·
69
+ `3` auth · `4` confirmation required.
70
+ - **Confirmation protocol** — irreversible commands (sends, deletes,
71
+ trigger fires) never hang waiting for input: non-interactive callers
72
+ get exit `4` plus a JSON envelope containing a ready-to-run
73
+ `confirmCommand`; pass `--yes` to proceed. Humans on a TTY get a y/N
74
+ prompt. Test sends (`emails send --test`) skip the gate.
75
+ - **No fuzzy matching** — unknown commands fail hard with exit 2.
76
+ - **Machine-readable discovery** — `brew-cli docs --agent` prints the
77
+ full manifest (commands, flags, classes, routes, env, exit codes);
78
+ `brew-cli docs api` fetches the live `GET /v1/help` catalog;
79
+ `brew-cli api <method> <path>` is the raw escape hatch for anything
80
+ the CLI has no dedicated command for yet.
81
+ - **Pipes and stdin** — `--input <json|->` and `--file <path|->`
82
+ everywhere bodies or files are needed; `--all` drains cursor
83
+ pagination; `--idempotency-key` makes retries safe across process
84
+ restarts.
85
+
86
+ ## Command reference
87
+
88
+ The full generated reference lives in
89
+ [`docs/commands/README.md`](./docs/commands/README.md). Resource groups:
90
+ `contacts`, `fields`, `emails`, `sends`, `audiences`, `automations`
91
+ (+ `triggers`, `runs`), `analytics`, `brand`, `content`, `templates`,
92
+ plus `login`/`logout`/`whoami`/`config`/`usage`/`health`/`docs`/`api`.
93
+
94
+ ## How this repo stays in sync with the API, MCP, and SDK
95
+
96
+ The app repo's Zod contracts generate the OpenAPI spec, which is mirrored
97
+ byte-identically into this repo (`openapi/public-api-v1.yaml`) and the
98
+ SDK. Two parity tests gate CI here:
99
+
100
+ - **SDK parity** walks the installed `@brew.new/sdk` client and fails if
101
+ any method lacks a command or a reviewed skip entry — so an SDK upgrade
102
+ that ships new surface fails the build until the CLI ships it too.
103
+ - **Spec parity** walks the vendored spec and fails on any operation
104
+ without a command route or a reviewed skip — including operations the
105
+ SDK itself has not wrapped yet, making this repo the outermost
106
+ completeness sentinel of the whole chain.
107
+ - **The nightly spec-drift sentinel** downloads the live published spec
108
+ and diffs it against the vendored copy, opening a labeled issue the day
109
+ the real API grows past this CLI.
110
+ - **`brew-cli doctor`** closes the loop at runtime: it diffs the installed
111
+ command surface against the server's live `GET /v1/help` catalog and
112
+ exit-codes the verdict, so agents can gate work on a current, authed,
113
+ in-sync CLI. Agents: see [`skills/brew-cli/SKILL.md`](./skills/brew-cli/SKILL.md).
114
+
115
+ Contributor guide: [`AGENTS.md`](./AGENTS.md) · Release process:
116
+ [`RELEASING.md`](./RELEASING.md).
117
+
118
+ ## License
119
+
120
+ MIT