@binaryandthread/cli 0.4.4 → 0.4.6

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 CHANGED
@@ -27,6 +27,30 @@ unambiguous form.)
27
27
  > `npx bt`, `npx btn`, and `npx binaryandthread` are **different, unscoped packages owned by
28
28
  > strangers** — never run them. Always install the full scoped name.
29
29
 
30
+ ## The ones you forward
31
+
32
+ People forward commands, not shops. Each of these installs nothing, buys nothing, and costs the
33
+ person you send it to about four seconds.
34
+
35
+ ```bash
36
+ npx @binaryandthread/cli fortune # a real aphorism from the trade, never an invented one
37
+ npx @binaryandthread/cli brew # ask a clothing company for coffee, get RFC 2324
38
+ npx @binaryandthread/cli init # the welcome, and the three commands that matter
39
+ npx @binaryandthread/cli browse # the whole catalogue, as a numbered table
40
+ ```
41
+
42
+ `fortune` draws from a fixed pool of genuine, attributable lines. Nothing in it was made up, which
43
+ is the only reason it is worth passing on.
44
+
45
+ `brew` is the house joke, and it is the one design two separate strangers have laughed at. Ask for
46
+ coffee and the shop answers **`418 i'm a teapot`**, which is a real HTTP status code from a real
47
+ April Fools' RFC that somehow never died. The article is at
48
+ [/guide/the-joke-that-would-not-die](https://binaryandthread.com/guide/the-joke-that-would-not-die);
49
+ the garment exists too.
50
+
51
+ There are a dozen or so other responses hidden in here for commands a developer types by reflex.
52
+ Listing them would defeat the point.
53
+
30
54
  ## Commands
31
55
 
32
56
  | command | what it does |
@@ -44,6 +68,21 @@ unambiguous form.)
44
68
  | `bt drops` | terminal-visible drops |
45
69
  | `bt forget` | wipe your local session + config (keychain token, cart, email) |
46
70
 
71
+ Ten more that the CLI has always had and this table has never listed:
72
+
73
+ | command | what it does |
74
+ | --- | --- |
75
+ | `bt init` | the first-run welcome and the three-command happy path. What the bare `bt` points a newcomer at |
76
+ | `bt buy <n\|slug>` | stage and checkout in one, for when you already know what you want |
77
+ | `bt status` | working-tree state: what is staged, what is in flight |
78
+ | `bt config [sub] [key] [value]` | local preferences (email, region, default fit). **The auth token is never stored here** |
79
+ | `bt token` | prints your keychain JWT for an MCP config. A bearer credential, treat it like one |
80
+ | `bt completion <shell>` | a shell completion script, to eval in your rc |
81
+ | `bt doctor` | local diagnostics for a bug report. Sends nothing |
82
+ | `bt report [message]` | files a bug report: a redacted snapshot, never cards or tokens |
83
+ | `bt brew` | see above |
84
+ | `bt fortune` | see above |
85
+
47
86
  ## Config (all optional, env overrides the baked-in prod defaults)
48
87
 
49
88
  | var | notes |
package/dist/bin.js CHANGED
@@ -36,6 +36,7 @@ import {
36
36
  isCartTaxInclusive,
37
37
  lineColour,
38
38
  ok,
39
+ orderStage,
39
40
  priceLine,
40
41
  printResult,
41
42
  productColours,
@@ -55,7 +56,7 @@ import {
55
56
  versionLine,
56
57
  warn,
57
58
  working
58
- } from "./chunk-PG7YCPAN.js";
59
+ } from "./chunk-5W5O6G6Y.js";
59
60
  import {
60
61
  __require
61
62
  } from "./chunk-7OCVIDC7.js";
@@ -104,7 +105,7 @@ function makeLogger(debug, write = (s) => process.stderr.write(s)) {
104
105
  }
105
106
 
106
107
  // src/version.ts
107
- var VERSION = "0.4.4";
108
+ var VERSION = "0.4.6";
108
109
 
109
110
  // src/eggs.ts
110
111
  function teapot() {
@@ -524,7 +525,7 @@ function registerBrowse(program, makeClient2, loadConfig2) {
524
525
  program.command("browse").alias("ls").description("list what's in stock on a branch.").option("--branch <branch>", "main (live) or next (terminal-only drops)").option("--pick", "opt into the arrow-key picker (default is the numbered table \u2014 use bt stage <n>)").option("--plain", "force the static table (the default; kept for back-compat)").action(async (opts) => {
525
526
  const { json, brand } = resolveOutput(program);
526
527
  if (opts.pick && !json && brand.color && process.stdout.isTTY && process.stdin.isTTY) {
527
- const { runInteractiveBrowse } = await import("./interactive-HI3LDK5U.js");
528
+ const { runInteractiveBrowse } = await import("./interactive-I6KDKLEO.js");
528
529
  const handled = await runInteractiveBrowse(makeClient2(), loadConfig2(), { branch: opts.branch, brand });
529
530
  if (handled) return;
530
531
  }
@@ -1093,11 +1094,8 @@ function registerCheckout(program, makeClient2, loadConfig2) {
1093
1094
  // src/commands/order.ts
1094
1095
  var STAGES = ["staged", "committed", "printed", "shipped", "delivered"];
1095
1096
  function stageIndex(o) {
1096
- const f = (o.fulfillment_status ?? "").toLowerCase();
1097
- if (f.includes("delivered")) return 4;
1098
- if (f.includes("shipped")) return 3;
1099
- if (f.includes("fulfilled") || f.includes("printed") || f.includes("partially_shipped")) return 2;
1100
- return 1;
1097
+ const stage = orderStage(o);
1098
+ return stage === "reverted" ? -1 : STAGES.indexOf(stage);
1101
1099
  }
1102
1100
  function timelineGraph(idx) {
1103
1101
  const dots = STAGES.map((_s, i) => i <= idx ? "\u25CF" : "\u25CB").join("\u2500\u2500");
@@ -1130,12 +1128,18 @@ async function runOrder(client, config, args) {
1130
1128
  const itemLabel = first ? `${first.title ?? "item"}${first.variant_title ? ` \xB7 ${first.variant_title}` : ""}` : "your order";
1131
1129
  const style = brandOf(args);
1132
1130
  const lines = [];
1133
- lines.push(`${display} ${itemLabel} ${cyan(style, timelineGraph(idx))} ${STAGES[idx]}`);
1134
- lines.push(` ${STAGES.join(" \u2192 ")}${idx === 4 ? " \u{1F389}" : ""}`);
1131
+ const stageWord = idx < 0 ? "reverted" : STAGES[idx];
1132
+ if (idx < 0) {
1133
+ lines.push(`${display} ${itemLabel} reverted`);
1134
+ lines.push(` this order was canceled or refunded. nothing ships.`);
1135
+ } else {
1136
+ lines.push(`${display} ${itemLabel} ${cyan(style, timelineGraph(idx))} ${stageWord}`);
1137
+ lines.push(` ${STAGES.join(" \u2192 ")}${idx === 4 ? " \u{1F389}" : ""}`);
1138
+ }
1135
1139
  lines.push(` total ${cyan(style, total)}${taxSuffix(orderTaxInclusive)}`);
1136
1140
  return {
1137
1141
  lines,
1138
- json: args.json ? { display_id: display, stage: STAGES[idx], total: o.total ?? null, currency: o.currency_code ?? null } : void 0
1142
+ json: args.json ? { display_id: display, stage: stageWord, total: o.total ?? null, currency: o.currency_code ?? null } : void 0
1139
1143
  };
1140
1144
  }
1141
1145
  function registerOrder(program, makeClient2, loadConfig2) {
@@ -1192,16 +1196,8 @@ function registerToken(program) {
1192
1196
  }
1193
1197
 
1194
1198
  // src/commands/log-graph.ts
1195
- function orderStage(o) {
1196
- const status = (o.status ?? "").toLowerCase();
1197
- if (status.includes("cancel") || status.includes("refund") || status.includes("revert")) {
1198
- return "reverted";
1199
- }
1200
- const f = (o.fulfillment_status ?? "").toLowerCase();
1201
- if (f.includes("delivered")) return "delivered";
1202
- if (f.includes("shipped")) return "shipped";
1203
- if (f.includes("fulfilled") || f.includes("printed") || f.includes("partially")) return "printed";
1204
- return "committed";
1199
+ function orderStage2(o) {
1200
+ return orderStage(o);
1205
1201
  }
1206
1202
  function shortHash(o) {
1207
1203
  const seed = `${o.display_id ?? ""}:${o.created_at ?? ""}`;
@@ -1219,19 +1215,19 @@ function label(o) {
1219
1215
  return `${first.title ?? "order"}${first.variant_title ? ` \xB7 ${first.variant_title}` : ""}`;
1220
1216
  }
1221
1217
  function hasLiveHead(orders) {
1222
- return orders.some((o) => orderStage(o) !== "reverted");
1218
+ return orders.some((o) => orderStage2(o) !== "reverted");
1223
1219
  }
1224
1220
  function renderOneline(orders, style) {
1225
1221
  if (orders.length === 0) return [];
1226
1222
  const live = hasLiveHead(orders);
1227
- const headIdx = live ? orders.findIndex((o) => orderStage(o) !== "reverted") : -1;
1223
+ const headIdx = live ? orders.findIndex((o) => orderStage2(o) !== "reverted") : -1;
1228
1224
  const lines = [];
1229
1225
  if (!live) {
1230
1226
  lines.push(dim(style, "(detached HEAD) you have no committed fits. literally nothing to wear. we don't judge."));
1231
1227
  }
1232
1228
  orders.forEach((o, i) => {
1233
1229
  const hash = shortHash(o);
1234
- const stage = orderStage(o);
1230
+ const stage = orderStage2(o);
1235
1231
  const ref = i === headIdx ? "(HEAD -> main) " : "";
1236
1232
  const tail = stage === "delivered" ? "delivered \u{1F389}" : stage;
1237
1233
  lines.push(`${hash} ${ref}${label(o).padEnd(34)} ${tail}`);
@@ -1241,14 +1237,14 @@ function renderOneline(orders, style) {
1241
1237
  function renderGraph(orders, style) {
1242
1238
  if (orders.length === 0) return [];
1243
1239
  const live = hasLiveHead(orders);
1244
- const headIdx = live ? orders.findIndex((o) => orderStage(o) !== "reverted") : -1;
1240
+ const headIdx = live ? orders.findIndex((o) => orderStage2(o) !== "reverted") : -1;
1245
1241
  const lines = [];
1246
1242
  if (!live) {
1247
1243
  lines.push(dim(style, "(detached HEAD) no committed fits. literally nothing to wear. we don't judge."));
1248
1244
  }
1249
1245
  orders.forEach((o, i) => {
1250
1246
  const hash = shortHash(o);
1251
- const stage = orderStage(o);
1247
+ const stage = orderStage2(o);
1252
1248
  const ref = i === headIdx ? " (HEAD -> main)" : "";
1253
1249
  const node = stage === "delivered" ? green(style, "*") : "*";
1254
1250
  const tail = stage === "delivered" ? `${stage} ${green(style, "\u{1F389}")}` : stage;
@@ -1262,7 +1258,7 @@ function renderGraph(orders, style) {
1262
1258
  function renderFlat(orders) {
1263
1259
  return orders.map((o) => {
1264
1260
  const display = String(o.display_id ?? "");
1265
- return `${display.padEnd(8)} ${label(o).padEnd(36)} ${orderStage(o)}`;
1261
+ return `${display.padEnd(8)} ${label(o).padEnd(36)} ${orderStage2(o)}`;
1266
1262
  });
1267
1263
  }
1268
1264
 
@@ -2060,7 +2056,7 @@ function buildProgram() {
2060
2056
  "the binary & thread terminal store. techno-minimalist clothing & lifestyle, bought with the ceremony of a deploy.\nprimary invocation: npx @binaryandthread/cli (a bare `bt` may collide with another binary)"
2061
2057
  ).version(versionLine(VERSION), "-v, --version", "print the version").option("--json", "machine-readable output", false).option("--no-color", "disable ANSI colour + inline images (also honours NO_COLOR)").option("--debug, --verbose", "trace requests to stderr (redacted) \u2014 for bug reports (d15)").option("--region <cc>", "ship-to country for this command (ISO-2, overrides your saved region)").showSuggestionAfterError();
2062
2058
  program.addHelpText("beforeAll", "\n bt \u2014 the binary & thread terminal store. new here? \u2192 bt init\n");
2063
- program.command("brew").argument("[what]", "what to brew").description("we make clothing, not coffee.").action(() => {
2059
+ program.command("brew").alias("teapot").argument("[what]", "what to brew").description("we make clothing, not coffee.").action(() => {
2064
2060
  process.stdout.write(teapot() + "\n");
2065
2061
  });
2066
2062
  registerEggs(program);