@binaryandthread/cli 0.1.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/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # @binaryandthread/cli — `bt`
2
+
3
+ Buy a Binary & Thread heavyweight tee **from your terminal**, with the ceremony of a production
4
+ deploy. A small, well-tested client over the Store API — the card never touches the terminal.
5
+
6
+ > `bt` is a dumb client. Every dangerous operation (payment, fulfilment) lives in the backend.
7
+ > Checkout hands you a URL; you pay on the storefront's Stripe page in your own browser.
8
+
9
+ ## Install
10
+
11
+ Zero-config — it ships pointed at the live store (the publishable key is public by design):
12
+
13
+ ```bash
14
+ # soft-launch tarball (friends): install the .tgz you were handed
15
+ npm i -g ./binaryandthread-cli-0.1.0.tgz
16
+ bt browse
17
+
18
+ # or, once published:
19
+ npx @binaryandthread/cli browse
20
+ ```
21
+
22
+ A bare `bt` may collide with another binary on your `PATH`; `npx @binaryandthread/cli …` is the
23
+ unambiguous form.
24
+
25
+ ## Commands
26
+
27
+ | command | what it does |
28
+ | --- | --- |
29
+ | `bt browse` | the catalog (interactive ↑/↓ picker on a TTY; `--json` for scripts) |
30
+ | `bt search <q>` | filter the catalog |
31
+ | `bt view <handle>` | one tee — specs + mockup (`--colour black` renders the black row) |
32
+ | `bt stage <handle>` | add to your cart (`--size`, `--colour`) |
33
+ | `bt cart` / `bt unstage <ref>` | show / remove a line |
34
+ | `bt checkout` | mint a checkout, hand off to the browser to pay, then poll |
35
+ | `bt order <id>` / `bt log` | track an order / your order history (when logged in) |
36
+ | `bt login` / `bt whoami` / `bt logout` | magic-link auth → JWT in your OS keychain |
37
+ | `bt drops` | terminal-visible drops |
38
+ | `bt forget` | wipe your local session + config (keychain token, cart, email) |
39
+
40
+ ## Config (all optional — env overrides the baked-in prod defaults)
41
+
42
+ | var | notes |
43
+ | --- | --- |
44
+ | `BT_API_URL` | Store API base URL (default: production; set for local dev / staging) |
45
+ | `BT_PUBLISHABLE_KEY` | the **publishable** key — public by design (a secret `sk_` key is rejected) |
46
+ | `NO_COLOR` / `--no-color` | plain output, no ANSI / inline images |
47
+ | `--json` | machine-readable output for scripts / CI |
48
+
49
+ Your auth token is **never** stored in config — it lives in the OS keychain (`bt login`).
50
+ Local config (cart id, email, defaults) lives at `~/.config/bt/config.json`.
51
+
52
+ ## Scripting: `--json` output & exit codes
53
+
54
+ Every command takes `--json` for stable, machine-readable output. `bt checkout --json` (or `--yes`)
55
+ skips the interactive confirm so it never hangs in CI. Field shapes (stable — safe to depend on):
56
+
57
+ | command | `--json` shape |
58
+ | --- | --- |
59
+ | `bt browse` / `bt search` | `[{ id, handle, title, price, currency, colours[], channel_stage }]` |
60
+ | `bt view <handle>` | `{ id, handle, title, price, currency, colours[], sizes[] }` |
61
+ | `bt cart` | `{ cart_id, items: [{ id, title, colour, qty, total }], total, currency }` |
62
+ | `bt checkout` | `{ status: "placed"\|"timeout"\|"expired", order_id?, display_id?, checkout_url? }` |
63
+ | `bt whoami` | `{ authenticated, tier, commits, standing_pct, token_expires_at, token_expired }` |
64
+ | `bt order <id>` | `{ display_id, status, fulfillment_status?, tracking? }` |
65
+
66
+ **Errors** (`--json`) come back as `{ "error": { "code", "type", "message" } }` and the process
67
+ exits with a distinct code so CI/agents can branch:
68
+
69
+ | exit | type | meaning |
70
+ | --- | --- | --- |
71
+ | `0` | — | success |
72
+ | `65` | `client_error` / `stale_cart` | bad request / re-stage the cart |
73
+ | `69` | `not_found` | no such product/order |
74
+ | `75` | `rate_limited` / `upstream` | temporary — retry later (a `429` is auto-retried honoring `Retry-After`) |
75
+ | `77` | `auth` | not logged in / forbidden — run `bt login` |
76
+ | `1` | `error` | anything else |
77
+
78
+ **Rate limits:** the client auto-retries `429` responses, honoring the server's `Retry-After`
79
+ (capped at 10s) before falling back to jittered exponential backoff. A persistent `429` surfaces as
80
+ exit `75` / `type: "rate_limited"`.
81
+
82
+ The **MCP server** mirrors these as `structuredContent` on every tool result (e.g. `cart_id`,
83
+ `session_id`, `order_id`, `products[]`) so an agent can chain tools without parsing prose.