@crossly/buyer-cli 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Crossly
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 CHANGED
@@ -1,3 +1,104 @@
1
- # Temporary Holding Version
1
+ # @crossly/buyer-cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Your Crossly shopping, from the terminal.
4
+
5
+ > **Not on npm yet.** `@crossly/buyer-cli` is unreleased — the install command below
6
+ > will 404 until the first publish. To try it now, clone this repo and build from
7
+ > source. Star or watch to hear when it lands.
8
+
9
+ ```bash
10
+ npm i -g @crossly/buyer-cli
11
+ crossly-buyer login --token crossly_oat_...
12
+ crossly-buyer cart get
13
+ ```
14
+
15
+ ## Two binaries, because two APIs
16
+
17
+ | | |
18
+ |---|---|
19
+ | `crossly` ([@crossly/cli](https://github.com/crossly-dev/crossly-cli)) | a seller's **store** — 287 commands |
20
+ | `crossly-buyer` (this) | a person's **own shopping** — 30 commands |
21
+
22
+ Different credentials, so different binaries rather than one with a `--buyer` flag. If only `CROSSLY_PAT` is set, this CLI says so and points you at the other one instead of failing with an opaque 403.
23
+
24
+ ## Commands
25
+
26
+ ```
27
+ profile get
28
+ orders list
29
+ cashback list
30
+ cart get add remove quote
31
+ wishlists list items create add
32
+ activity report list preferences
33
+ offers make
34
+ agent list start get delete say react act
35
+ vault worth holdings history watchlist exits exit indexes index
36
+ ```
37
+
38
+ Every command takes `--help`, and **`--help` never touches the network or needs a token** — it works on a plane.
39
+
40
+ ```bash
41
+ crossly-buyer offers make --help
42
+ crossly-buyer offers make --listingSlug vintage-levis-501 --amountCents 4500
43
+ ```
44
+
45
+ ## Nothing here spends money
46
+
47
+ `cart quote` prices a basket. `offers make` proposes a number. No command completes a purchase — paying happens on Crossly, with you present.
48
+
49
+ ## For scripts and agents
50
+
51
+ `--json` on everything, byte-faithful to what the API returned. `--ndjson` on lists, one object per line. `--dry-run` prints what would be sent and sends nothing.
52
+
53
+ Exit codes distinguish **remedies**, which is the point:
54
+
55
+ | code | meaning | what to do |
56
+ |---|---|---|
57
+ | `0` | ok | |
58
+ | `1` | the API said no, or the network failed | read the message |
59
+ | `2` | you typed something wrong | nothing was sent |
60
+ | `4` | not authenticated | `crossly-buyer login` |
61
+ | `5` | authenticated, but missing a scope | re-consent — **not** re-login |
62
+
63
+ Code `5` exists because "your token expired" and "you were never granted `buyer:cashback:read`" need different fixes, and a wrapper that collapses them will guess wrong on the scope case.
64
+
65
+ ## Money renders as money
66
+
67
+ Columns ending in `Cents` are formatted as `$45.00` in table output. `--json` leaves the raw integer alone — a script piping to `jq` is the second-biggest consumer of this tool, and reshaping "helpfully" breaks it silently.
68
+
69
+ ## Auth
70
+
71
+ ```bash
72
+ crossly-buyer login --token crossly_oat_... # stored 0600 at ~/.crossly/buyer-auth.json
73
+ crossly-buyer whoami
74
+ crossly-buyer logout
75
+ ```
76
+
77
+ `CROSSLY_BUYER_TOKEN` in the environment takes precedence, so CI needs no file and a shell can override a stale token without logging out.
78
+
79
+ Stored separately from the seller CLI's `~/.crossly/auth.json` on purpose — sharing one file would mean `crossly login` and `crossly-buyer login` silently overwrite each other.
80
+
81
+ A seller PAT is refused **at login**, not at first use. Storing it would make every later command fail with an unrelated-looking 403.
82
+
83
+ ## Also available
84
+
85
+ - [`@crossly/buyer-sdk`](https://github.com/crossly-dev/crossly-sdk/tree/main/buyer) — TypeScript client
86
+ - [`@crossly/buyer-mcp`](https://github.com/crossly-dev/crossly-mcp/tree/main/buyer) — the same surface as MCP tools
87
+
88
+ ## Building from source
89
+
90
+ The command tree is generated from the [`@crossly/buyer-mcp`](https://github.com/crossly-dev/crossly-mcp/tree/main/buyer) tool registry, so a tool added there is a command here with no second list (a test fails if the map and the registry drift).
91
+
92
+ In the Crossly monorepo:
93
+
94
+ ```bash
95
+ pnpm --filter @crossly/buyer-cli test # no build needed: the tests read buyer-mcp and buyer-sdk from source
96
+ pnpm --filter @crossly/buyer-cli build:deps # builds buyer-sdk, then buyer-mcp (what the binary imports at run time)
97
+ pnpm --filter @crossly/buyer-cli build
98
+ ```
99
+
100
+ `pnpm -r build` does the same in dependency order.
101
+
102
+ ## License
103
+
104
+ MIT
package/dist/auth.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ export declare const AUTH_PATH: string;
2
+ export interface StoredAuth {
3
+ token: string;
4
+ /** Scopes the token was granted, when the issuer told us. */
5
+ scopes?: string[];
6
+ baseUrl?: string;
7
+ savedAt?: string;
8
+ }
9
+ export declare function save(auth: StoredAuth): void;
10
+ export declare function load(): StoredAuth | null;
11
+ export declare function clear(): boolean;
12
+ /**
13
+ * The token to use, preferring the environment.
14
+ *
15
+ * Env first so CI can inject one without writing a file, and so a shell can
16
+ * override a stale stored token without logging out.
17
+ */
18
+ export declare function resolveToken(): {
19
+ token: string;
20
+ baseUrl?: string;
21
+ };
22
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,SAAS,QAAiD,CAAC;AAExE,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAU3C;AAED,wBAAgB,IAAI,IAAI,UAAU,GAAG,IAAI,CAOxC;AAED,wBAAgB,KAAK,IAAI,OAAO,CAI/B;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAoBlE"}
package/dist/auth.js ADDED
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Where the buyer token lives.
3
+ *
4
+ * ── A FILE, NOT THE OS KEYCHAIN ──────────────────────────────────────
5
+ * Same reasoning as @crossly/cli: every keychain binding is a native module,
6
+ * and a native module in a globally-installed CLI turns `npm i -g` into a
7
+ * compiler error on someone's laptop. A 0600 file in the user's home directory
8
+ * is what gh, aws and stripe ship, and it is the right trade.
9
+ *
10
+ * ── SEPARATE FILE FROM THE SELLER CLI ────────────────────────────────
11
+ * `~/.crossly/auth.json` holds a seller token, this holds a buyer one. Sharing
12
+ * one file would mean `crossly login` and `crossly-buyer login` overwrite each
13
+ * other, and the symptom — every other command 403s until you log in again —
14
+ * would be maddening to diagnose.
15
+ */
16
+ import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
17
+ import { homedir } from 'node:os';
18
+ import { dirname, join } from 'node:path';
19
+ import { CliError, EXIT } from './exit.js';
20
+ export const AUTH_PATH = join(homedir(), '.crossly', 'buyer-auth.json');
21
+ export function save(auth) {
22
+ mkdirSync(dirname(AUTH_PATH), { recursive: true });
23
+ writeFileSync(AUTH_PATH, JSON.stringify({ ...auth, savedAt: new Date().toISOString() }, null, 2));
24
+ // Best-effort: chmod is a no-op on Windows, which is why the file also lives
25
+ // under the user profile rather than anywhere shared.
26
+ try {
27
+ chmodSync(AUTH_PATH, 0o600);
28
+ }
29
+ catch {
30
+ /* windows */
31
+ }
32
+ }
33
+ export function load() {
34
+ if (!existsSync(AUTH_PATH))
35
+ return null;
36
+ try {
37
+ return JSON.parse(readFileSync(AUTH_PATH, 'utf8'));
38
+ }
39
+ catch {
40
+ return null;
41
+ }
42
+ }
43
+ export function clear() {
44
+ if (!existsSync(AUTH_PATH))
45
+ return false;
46
+ rmSync(AUTH_PATH);
47
+ return true;
48
+ }
49
+ /**
50
+ * The token to use, preferring the environment.
51
+ *
52
+ * Env first so CI can inject one without writing a file, and so a shell can
53
+ * override a stale stored token without logging out.
54
+ */
55
+ export function resolveToken() {
56
+ const fromEnv = process.env.CROSSLY_BUYER_TOKEN;
57
+ if (fromEnv)
58
+ return { token: fromEnv, baseUrl: process.env.CROSSLY_API_BASE_URL };
59
+ const stored = load();
60
+ if (stored?.token) {
61
+ return { token: stored.token, baseUrl: process.env.CROSSLY_API_BASE_URL ?? stored.baseUrl };
62
+ }
63
+ // Name the seller token explicitly: someone with CROSSLY_PAT already exported
64
+ // will otherwise assume this CLI should have picked it up.
65
+ const hint = process.env.CROSSLY_PAT
66
+ ? '\n\nNote: CROSSLY_PAT is set, but that is a SELLER token. The buyer API is a ' +
67
+ 'separate principal and will reject it — use `crossly` for store commands.'
68
+ : '';
69
+ throw new CliError(`Not authenticated. Run \`crossly-buyer login\`, or set CROSSLY_BUYER_TOKEN.${hint}`, EXIT.unauthenticated);
70
+ }
71
+ //# sourceMappingURL=auth.js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,KAAK;IACnB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,MAAM,CAAC,SAAS,CAAC,CAAC;IAClB,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAChD,IAAI,OAAO;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,CAAC;IAElF,MAAM,MAAM,GAAG,IAAI,EAAE,CAAC;IACtB,IAAI,MAAM,EAAE,KAAK,EAAE,CAAC;QAClB,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;IAC9F,CAAC;IAED,8EAA8E;IAC9E,2DAA2D;IAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW;QAClC,CAAC,CAAC,+EAA+E;YAC/E,2EAA2E;QAC7E,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,IAAI,QAAQ,CAChB,8EAA8E,IAAI,EAAE,EACpF,IAAI,CAAC,eAAe,CACrB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The command tree, derived from the buyer MCP registry.
3
+ *
4
+ * ── WHY THE MAP IS EXPLICIT HERE ─────────────────────────────────────
5
+ * `@crossly/cli` derives 287 commands from tool names by rule, because at that
6
+ * size a rule is the only maintainable option and a wrong guess costs one odd
7
+ * verb. There are THIRTY buyer tools. A rule over that few names would produce
8
+ * `crossly-buyer my get-my-cart` and similar, which is worse in every way than
9
+ * writing `cart get` down once.
10
+ *
11
+ * The guard test asserts this map covers the registry exactly, so adding a tool
12
+ * without a command here fails the build rather than silently shipping a CLI
13
+ * that is missing an endpoint.
14
+ */
15
+ import { ALL_TOOLS, type ToolDef } from '@crossly/buyer-mcp/registry';
16
+ export interface Command {
17
+ /** Noun the user types first, e.g. `cart`. */
18
+ group: string;
19
+ /** Verb after the noun, e.g. `get`. */
20
+ verb: string;
21
+ /** The MCP tool this runs. */
22
+ tool: string;
23
+ }
24
+ export declare const COMMANDS: Command[];
25
+ export declare const TOOL_BY_COMMAND: Map<string, ToolDef>;
26
+ /** Groups in a stable order, for help output. */
27
+ export declare function groups(): Map<string, Command[]>;
28
+ export { ALL_TOOLS };
29
+ export type { ToolDef };
30
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,WAAW,OAAO;IACtB,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAgDD,eAAO,MAAM,QAAQ,EAAE,OAAO,EAG5B,CAAC;AAEH,eAAO,MAAM,eAAe,sBAM3B,CAAC;AAEF,iDAAiD;AACjD,wBAAgB,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAO/C;AAED,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,YAAY,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The command tree, derived from the buyer MCP registry.
3
+ *
4
+ * ── WHY THE MAP IS EXPLICIT HERE ─────────────────────────────────────
5
+ * `@crossly/cli` derives 287 commands from tool names by rule, because at that
6
+ * size a rule is the only maintainable option and a wrong guess costs one odd
7
+ * verb. There are THIRTY buyer tools. A rule over that few names would produce
8
+ * `crossly-buyer my get-my-cart` and similar, which is worse in every way than
9
+ * writing `cart get` down once.
10
+ *
11
+ * The guard test asserts this map covers the registry exactly, so adding a tool
12
+ * without a command here fails the build rather than silently shipping a CLI
13
+ * that is missing an endpoint.
14
+ */
15
+ import { ALL_TOOLS } from '@crossly/buyer-mcp/registry';
16
+ /**
17
+ * tool name → `<group> <verb>`.
18
+ *
19
+ * Read the right-hand column aloud: "cart get", "cart add", "offers make".
20
+ * That is the whole test for whether a name is right.
21
+ */
22
+ const MAP = {
23
+ get_my_shopping_profile: 'profile get',
24
+ list_my_purchases: 'orders list',
25
+ get_my_cashback: 'cashback list',
26
+ get_my_cart: 'cart get',
27
+ add_to_my_cart: 'cart add',
28
+ remove_from_my_cart: 'cart remove',
29
+ quote_my_cart: 'cart quote',
30
+ list_my_wishlists: 'wishlists list',
31
+ get_my_wishlist_items: 'wishlists items',
32
+ create_my_wishlist: 'wishlists create',
33
+ add_to_my_wishlist: 'wishlists add',
34
+ report_shopping_activity: 'activity report',
35
+ list_my_shopping_activity: 'activity list',
36
+ get_my_shopping_preferences: 'activity preferences',
37
+ offer_on_listing: 'offers make',
38
+ list_shopping_agent_sessions: 'agent list',
39
+ start_shopping_agent: 'agent start',
40
+ get_shopping_agent_session: 'agent get',
41
+ delete_shopping_agent_session: 'agent delete',
42
+ talk_to_shopping_agent: 'agent say',
43
+ react_to_agent_option: 'agent react',
44
+ act_on_agent_option: 'agent act',
45
+ // Vault Markets, read only: what the vault is worth, and the quotes behind it.
46
+ get_my_vault_worth: 'vault worth',
47
+ list_my_vault_holdings: 'vault holdings',
48
+ get_my_vault_history: 'vault history',
49
+ list_my_vault_watchlist: 'vault watchlist',
50
+ list_my_instant_exit_quotes: 'vault exits',
51
+ get_my_instant_exit_quote: 'vault exit',
52
+ list_vault_indexes: 'vault indexes',
53
+ get_vault_index: 'vault index',
54
+ };
55
+ export const COMMANDS = Object.entries(MAP).map(([tool, path]) => {
56
+ const [group, verb] = path.split(' ');
57
+ return { group: group, verb: verb, tool };
58
+ });
59
+ export const TOOL_BY_COMMAND = new Map(COMMANDS.map((c) => {
60
+ const tool = ALL_TOOLS.find((t) => t.name === c.tool);
61
+ if (!tool)
62
+ throw new Error(`commands.ts maps ${c.tool}, which is not in the registry`);
63
+ return [`${c.group} ${c.verb}`, tool];
64
+ }));
65
+ /** Groups in a stable order, for help output. */
66
+ export function groups() {
67
+ const out = new Map();
68
+ for (const c of COMMANDS) {
69
+ if (!out.has(c.group))
70
+ out.set(c.group, []);
71
+ out.get(c.group).push(c);
72
+ }
73
+ return out;
74
+ }
75
+ export { ALL_TOOLS };
76
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,SAAS,EAAgB,MAAM,6BAA6B,CAAC;AAWtE;;;;;GAKG;AACH,MAAM,GAAG,GAA2B;IAClC,uBAAuB,EAAE,aAAa;IACtC,iBAAiB,EAAE,aAAa;IAChC,eAAe,EAAE,eAAe;IAEhC,WAAW,EAAE,UAAU;IACvB,cAAc,EAAE,UAAU;IAC1B,mBAAmB,EAAE,aAAa;IAClC,aAAa,EAAE,YAAY;IAE3B,iBAAiB,EAAE,gBAAgB;IACnC,qBAAqB,EAAE,iBAAiB;IACxC,kBAAkB,EAAE,kBAAkB;IACtC,kBAAkB,EAAE,eAAe;IAEnC,wBAAwB,EAAE,iBAAiB;IAC3C,yBAAyB,EAAE,eAAe;IAC1C,2BAA2B,EAAE,sBAAsB;IAEnD,gBAAgB,EAAE,aAAa;IAE/B,4BAA4B,EAAE,YAAY;IAC1C,oBAAoB,EAAE,aAAa;IACnC,0BAA0B,EAAE,WAAW;IACvC,6BAA6B,EAAE,cAAc;IAC7C,sBAAsB,EAAE,WAAW;IACnC,qBAAqB,EAAE,aAAa;IACpC,mBAAmB,EAAE,WAAW;IAEhC,+EAA+E;IAC/E,kBAAkB,EAAE,aAAa;IACjC,sB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AAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5C,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
package/dist/exit.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Exit codes.
3
+ *
4
+ * Distinct codes for distinct remedies — that is the whole point. A script
5
+ * wrapping this needs to tell "your token expired, re-auth" from "you asked for
6
+ * a scope you were never granted, send the user back through consent" from "the
7
+ * listing does not exist". Collapsing all of those into 1 makes the wrapper
8
+ * guess, and it will guess wrong on the scope case.
9
+ *
10
+ * Matches @crossly/cli so a script can treat both the same way.
11
+ */
12
+ export declare const EXIT: {
13
+ readonly ok: 0;
14
+ /** The request was well-formed and the API said no, or the network failed. */
15
+ readonly failure: 1;
16
+ /** The user typed something wrong. Nothing was sent. */
17
+ readonly usage: 2;
18
+ /** No token, or the token is rejected. Remedy: authenticate. */
19
+ readonly unauthenticated: 4;
20
+ /** Authenticated, but the token lacks the scope. Remedy: re-consent. */
21
+ readonly forbiddenScope: 5;
22
+ };
23
+ export type ExitCode = (typeof EXIT)[keyof typeof EXIT];
24
+ export declare class CliError extends Error {
25
+ readonly code: ExitCode;
26
+ /** The API's correlation id, when there was one — the thread back to logs. */
27
+ readonly correlationId?: string;
28
+ constructor(message: string, code?: ExitCode, correlationId?: string);
29
+ }
30
+ /**
31
+ * Map a thrown error onto an exit code.
32
+ *
33
+ * The scope case is why this is a function rather than a constant: a 403 whose
34
+ * body mentions a scope is a DIFFERENT problem from a 403 that does not, and
35
+ * only the message distinguishes them.
36
+ */
37
+ export declare function exitCodeFor(err: unknown): ExitCode;
38
+ //# sourceMappingURL=exit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit.d.ts","sourceRoot":"","sources":["../src/exit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI;;IAEf,8EAA8E;;IAE9E,wDAAwD;;IAExD,gEAAgE;;IAEhE,wEAAwE;;CAEhE,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,OAAO,IAAI,CAAC,CAAC;AAExD,qBAAa,QAAS,SAAQ,KAAK;IACjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;gBAEpB,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,QAAuB,EAAE,aAAa,CAAC,EAAE,MAAM;CAMnF;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,CAUlD"}
package/dist/exit.js ADDED
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Exit codes.
3
+ *
4
+ * Distinct codes for distinct remedies — that is the whole point. A script
5
+ * wrapping this needs to tell "your token expired, re-auth" from "you asked for
6
+ * a scope you were never granted, send the user back through consent" from "the
7
+ * listing does not exist". Collapsing all of those into 1 makes the wrapper
8
+ * guess, and it will guess wrong on the scope case.
9
+ *
10
+ * Matches @crossly/cli so a script can treat both the same way.
11
+ */
12
+ export const EXIT = {
13
+ ok: 0,
14
+ /** The request was well-formed and the API said no, or the network failed. */
15
+ failure: 1,
16
+ /** The user typed something wrong. Nothing was sent. */
17
+ usage: 2,
18
+ /** No token, or the token is rejected. Remedy: authenticate. */
19
+ unauthenticated: 4,
20
+ /** Authenticated, but the token lacks the scope. Remedy: re-consent. */
21
+ forbiddenScope: 5,
22
+ };
23
+ export class CliError extends Error {
24
+ code;
25
+ /** The API's correlation id, when there was one — the thread back to logs. */
26
+ correlationId;
27
+ constructor(message, code = EXIT.failure, correlationId) {
28
+ super(message);
29
+ this.name = 'CliError';
30
+ this.code = code;
31
+ this.correlationId = correlationId;
32
+ }
33
+ }
34
+ /**
35
+ * Map a thrown error onto an exit code.
36
+ *
37
+ * The scope case is why this is a function rather than a constant: a 403 whose
38
+ * body mentions a scope is a DIFFERENT problem from a 403 that does not, and
39
+ * only the message distinguishes them.
40
+ */
41
+ export function exitCodeFor(err) {
42
+ if (err instanceof CliError)
43
+ return err.code;
44
+ const status = err?.status;
45
+ if (status === 401)
46
+ return EXIT.unauthenticated;
47
+ if (status === 403) {
48
+ const text = `${err?.code ?? ''} ${err?.message ?? ''}`;
49
+ return /scope/i.test(text) ? EXIT.forbiddenScope : EXIT.failure;
50
+ }
51
+ return EXIT.failure;
52
+ }
53
+ //# sourceMappingURL=exit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit.js","sourceRoot":"","sources":["../src/exit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,EAAE,EAAE,CAAC;IACL,8EAA8E;IAC9E,OAAO,EAAE,CAAC;IACV,wDAAwD;IACxD,KAAK,EAAE,CAAC;IACR,gEAAgE;IAChE,eAAe,EAAE,CAAC;IAClB,wEAAwE;IACxE,cAAc,EAAE,CAAC;CACT,CAAC;AAIX,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAW;IACxB,8EAA8E;IACrE,aAAa,CAAU;IAEhC,YAAY,OAAe,EAAE,OAAiB,IAAI,CAAC,OAAO,EAAE,aAAsB;QAChF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,IAAI,GAAG,YAAY,QAAQ;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC;IAE7C,MAAM,MAAM,GAAI,GAA2B,EAAE,MAAM,CAAC;IACpD,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC,eAAe,CAAC;IAChD,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,GAAI,GAAyB,EAAE,IAAI,IAAI,EAAE,IAAK,GAAa,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;QAC1F,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IAClE,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC;AACtB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export declare function main(argv: string[]): Promise<number>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AA+LA,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA6D1D"}
package/dist/index.js ADDED
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * crossly-buyer — the Crossly Buyer API from the terminal.
4
+ *
5
+ * A shopper's account: cart, orders, wishlists, offers, cashback. For a
6
+ * seller's store — listings, crossposting, fulfilment — use `crossly`
7
+ * (@crossly/cli). They are different APIs with different credentials, which is
8
+ * why they are different binaries rather than one with a `--buyer` flag.
9
+ *
10
+ * NOTHING HERE SPENDS MONEY. `cart quote` prices a basket and `offers make`
11
+ * proposes a number; `agent act --type buy` returns a quote; no command
12
+ * completes a purchase.
13
+ */
14
+ import { createBuyerClient } from '@crossly/buyer-sdk';
15
+ import { configureClient } from '@crossly/buyer-mcp/api';
16
+ import { TOOL_BY_COMMAND, groups } from './commands.js';
17
+ import { CliError, EXIT, exitCodeFor } from './exit.js';
18
+ import { render } from './output.js';
19
+ import * as auth from './auth.js';
20
+ const BIN = 'crossly-buyer';
21
+ /** Flags the CLI consumes itself; everything else belongs to the tool schema. */
22
+ const GLOBAL_FLAGS = new Set(['json', 'ndjson', 'help', 'version', 'dry-run']);
23
+ function parseArgv(argv) {
24
+ const positional = [];
25
+ const flags = {};
26
+ for (let i = 0; i < argv.length; i += 1) {
27
+ const arg = argv[i];
28
+ if (!arg.startsWith('--')) {
29
+ positional.push(arg);
30
+ continue;
31
+ }
32
+ const body = arg.slice(2);
33
+ const eq = body.indexOf('=');
34
+ if (eq !== -1) {
35
+ flags[body.slice(0, eq)] = body.slice(eq + 1);
36
+ continue;
37
+ }
38
+ const next = argv[i + 1];
39
+ if (next !== undefined && !next.startsWith('--')) {
40
+ flags[body] = next;
41
+ i += 1;
42
+ }
43
+ else {
44
+ flags[body] = true;
45
+ }
46
+ }
47
+ return { positional, flags };
48
+ }
49
+ /** `--limit 25` arrives as a string; the schema says integer. Coerce by schema. */
50
+ function coerce(tool, flags) {
51
+ const props = tool.inputSchema.properties;
52
+ const out = {};
53
+ for (const [key, raw] of Object.entries(flags)) {
54
+ if (GLOBAL_FLAGS.has(key))
55
+ continue;
56
+ const spec = props[key];
57
+ if (!spec) {
58
+ const known = Object.keys(props).sort();
59
+ throw new CliError(`Unknown flag --${key}. ` +
60
+ (known.length ? `This command accepts: ${known.map((k) => `--${k}`).join(', ')}` : 'This command takes no flags.'), EXIT.usage);
61
+ }
62
+ if (spec.type === 'integer' || spec.type === 'number') {
63
+ const n = Number(raw);
64
+ if (!Number.isFinite(n))
65
+ throw new CliError(`--${key} expects a number, got "${raw}".`, EXIT.usage);
66
+ out[key] = n;
67
+ }
68
+ else if (spec.type === 'boolean') {
69
+ out[key] = raw === true || raw === 'true';
70
+ }
71
+ else {
72
+ out[key] = String(raw);
73
+ }
74
+ }
75
+ const missing = (tool.inputSchema.required ?? []).filter((k) => out[k] === undefined);
76
+ if (missing.length) {
77
+ throw new CliError(`Missing required flag${missing.length > 1 ? 's' : ''}: ${missing.map((m) => `--${m}`).join(', ')}`, EXIT.usage);
78
+ }
79
+ return out;
80
+ }
81
+ function topHelp() {
82
+ const lines = [
83
+ `${BIN} — your Crossly shopping, from the terminal`,
84
+ '',
85
+ ` ${BIN} <group> <command> [flags]`,
86
+ '',
87
+ ];
88
+ for (const [group, cmds] of groups()) {
89
+ lines.push(` ${group}`);
90
+ for (const c of cmds) {
91
+ const tool = TOOL_BY_COMMAND.get(`${c.group} ${c.verb}`);
92
+ // One line each: the first sentence of the tool description.
93
+ const first = tool.description.split(/(?<=\.)\s/)[0] ?? tool.description;
94
+ lines.push(` ${c.verb.padEnd(13)} ${first.slice(0, 92)}`);
95
+ }
96
+ lines.push('');
97
+ }
98
+ lines.push(' auth', ' login Store a buyer OAuth token', ' logout Forget the stored token', ' whoami Show who the stored token belongs to', '', ' Global flags: --json --ndjson --dry-run --help --version', '', ` Managing a STORE rather than shopping? That is \`crossly\` (@crossly/cli) —`, ' a different API with a different token.', '');
99
+ return lines.join('\n');
100
+ }
101
+ function commandHelp(group, verb, tool) {
102
+ const props = tool.inputSchema.properties;
103
+ const required = new Set(tool.inputSchema.required ?? []);
104
+ const lines = [`${BIN} ${group} ${verb}`, '', ` ${tool.description}`, ''];
105
+ const keys = Object.keys(props);
106
+ if (keys.length) {
107
+ lines.push(' Flags:');
108
+ for (const k of keys) {
109
+ const spec = props[k];
110
+ const tag = required.has(k) ? ' (required)' : '';
111
+ lines.push(` --${k} <${spec.type ?? 'string'}>${tag}`);
112
+ if (spec.description)
113
+ lines.push(` ${spec.description}`);
114
+ }
115
+ }
116
+ else {
117
+ lines.push(' Takes no flags.');
118
+ }
119
+ lines.push('');
120
+ return lines.join('\n');
121
+ }
122
+ async function runAuth(verb, flags) {
123
+ if (verb === 'logout') {
124
+ process.stdout.write(auth.clear() ? 'Logged out.\n' : 'Was not logged in.\n');
125
+ return EXIT.ok;
126
+ }
127
+ if (verb === 'login') {
128
+ const token = typeof flags.token === 'string' ? flags.token : undefined;
129
+ if (!token) {
130
+ process.stdout.write('Pass a buyer OAuth token:\n\n' +
131
+ ` ${BIN} login --token crossly_oat_...\n\n` +
132
+ 'Buyer tokens come from the Crossly OAuth consent screen — there is no\n' +
133
+ 'buyer equivalent of a personal access token, because the scopes are\n' +
134
+ 'granted by a person agreeing to them.\n');
135
+ return EXIT.usage;
136
+ }
137
+ // Validate by constructing a client: wrong-kind tokens throw here with a
138
+ // message that names the mistake, rather than being stored and failing
139
+ // on every subsequent command.
140
+ createBuyerClient({ token });
141
+ auth.save({ token });
142
+ process.stdout.write(`Saved to ${auth.AUTH_PATH}\n`);
143
+ return EXIT.ok;
144
+ }
145
+ if (verb === 'whoami') {
146
+ const { token, baseUrl } = auth.resolveToken();
147
+ const client = createBuyerClient({ token, ...(baseUrl ? { baseUrl } : {}) });
148
+ const profile = await client.profile.get();
149
+ process.stdout.write(render(profile, { json: flags.json === true }) + '\n');
150
+ return EXIT.ok;
151
+ }
152
+ throw new CliError(`Unknown auth command: ${verb}`, EXIT.usage);
153
+ }
154
+ export async function main(argv) {
155
+ const { positional, flags } = parseArgv(argv);
156
+ if (flags.version === true) {
157
+ process.stdout.write('0.1.0\n');
158
+ return EXIT.ok;
159
+ }
160
+ if (!positional.length || (flags.help === true && positional.length === 0)) {
161
+ process.stdout.write(topHelp());
162
+ return positional.length ? EXIT.ok : EXIT.usage;
163
+ }
164
+ const [first, second] = positional;
165
+ // `login` / `logout` / `whoami` read better without an `auth` prefix.
166
+ if (first === 'login' || first === 'logout' || first === 'whoami') {
167
+ return runAuth(first, flags);
168
+ }
169
+ if (first === 'auth' && second)
170
+ return runAuth(second, flags);
171
+ if (!second) {
172
+ const cmds = groups().get(first);
173
+ if (!cmds)
174
+ throw new CliError(`Unknown group: ${first}. Run \`${BIN}\` to see them.`, EXIT.usage);
175
+ process.stdout.write(`${BIN} ${first} <command>\n\n` + cmds.map((c) => ` ${c.verb}`).join('\n') + '\n\n');
176
+ return EXIT.usage;
177
+ }
178
+ const key = `${first} ${second}`;
179
+ const tool = TOOL_BY_COMMAND.get(key);
180
+ if (!tool) {
181
+ throw new CliError(`Unknown command: ${key}. Run \`${BIN}\` to see them.`, EXIT.usage);
182
+ }
183
+ // --help must never touch the network or require a token. This is the bug
184
+ // that shipped in the seller CLI: two branches missed the check and
185
+ // `inventory export --help` exited 4 for anyone not logged in.
186
+ if (flags.help === true) {
187
+ process.stdout.write(commandHelp(first, second, tool));
188
+ return EXIT.ok;
189
+ }
190
+ const args = coerce(tool, flags);
191
+ if (flags['dry-run'] === true) {
192
+ process.stdout.write(render({ tool: tool.name, args, wouldSend: true }, { json: flags.json === true }) + '\n');
193
+ return EXIT.ok;
194
+ }
195
+ const { token, baseUrl } = auth.resolveToken();
196
+ configureClient(createBuyerClient({ token, ...(baseUrl ? { baseUrl } : {}) }));
197
+ const result = await tool.handler(args);
198
+ process.stdout.write(render(result, { json: flags.json === true, ndjson: flags.ndjson === true }) + '\n');
199
+ return EXIT.ok;
200
+ }
201
+ // Only run when executed, not when imported by a test.
202
+ if (process.argv[1] && /buyer-cli[\\/](dist|src)[\\/]index\.(js|ts)$/.test(process.argv[1])) {
203
+ main(process.argv.slice(2))
204
+ .then((code) => process.exit(code))
205
+ .catch((err) => {
206
+ const code = exitCodeFor(err);
207
+ const msg = err instanceof Error ? err.message : String(err);
208
+ process.stderr.write(`${msg}\n`);
209
+ const correlationId = err?.correlationId;
210
+ if (correlationId)
211
+ process.stderr.write(`correlationId: ${correlationId}\n`);
212
+ process.exit(code);
213
+ });
214
+ }
215
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,EAAgB,MAAM,eAAe,CAAC;AACtE,OAAO,E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AAC,CAAC;IACxC,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC,GAAG,IAAI,CACpF,CAAC;IACF,OAAO,IAAI,CAAC,EAAE,CAAC;AACjB,CAAC;AAED,uDAAuD;AACvD,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,8CAA8C,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5F,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACxB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAClC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QACtB,MAAM,IAAI,GAAa,WAAW,CAAC,GAAG,CAAC,CAAC;QACxC,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;QACjC,MAAM,aAAa,GAAI,GAAkC,EAAE,aAAa,CAAC;QACzE,IAAI,aAAa;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,aAAa,IAAI,CAAC,CAAC;QAC7E,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Rendering.
3
+ *
4
+ * Two modes and no cleverness: `--json` prints exactly what the API returned,
5
+ * anything else prints a table a person can read. The JSON mode must stay
6
+ * byte-faithful — a script piping to `jq` is the second-biggest consumer of
7
+ * this tool after a human, and reshaping "helpfully" breaks it silently.
8
+ */
9
+ export interface RenderOpts {
10
+ json?: boolean;
11
+ ndjson?: boolean;
12
+ }
13
+ export declare function render(value: unknown, opts?: RenderOpts): string;
14
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAyDD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,GAAE,UAAe,GAAG,MAAM,CA+BpE"}
package/dist/output.js ADDED
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Rendering.
3
+ *
4
+ * Two modes and no cleverness: `--json` prints exactly what the API returned,
5
+ * anything else prints a table a person can read. The JSON mode must stay
6
+ * byte-faithful — a script piping to `jq` is the second-biggest consumer of
7
+ * this tool after a human, and reshaping "helpfully" breaks it silently.
8
+ */
9
+ /** The rows inside a `{ data, meta }` envelope, or the value itself. */
10
+ function rowsOf(value) {
11
+ if (Array.isArray(value))
12
+ return value;
13
+ if (value && typeof value === 'object') {
14
+ const data = value.data;
15
+ if (Array.isArray(data))
16
+ return data;
17
+ }
18
+ return null;
19
+ }
20
+ function cell(v) {
21
+ if (v === null || v === undefined)
22
+ return '';
23
+ if (typeof v === 'object')
24
+ return Array.isArray(v) ? `[${v.length}]` : '{…}';
25
+ return String(v);
26
+ }
27
+ /**
28
+ * Money arrives from this API in CENTS, always. Rendering 4500 as "4500" in a
29
+ * column headed `amountCents` is technically honest and reads as $4,500 to
30
+ * every human who glances at it, so columns ending in `Cents` are formatted.
31
+ */
32
+ function isMoneyColumn(key) {
33
+ return /cents$/i.test(key);
34
+ }
35
+ function formatMoney(v) {
36
+ const n = typeof v === 'number' ? v : Number(v);
37
+ if (!Number.isFinite(n))
38
+ return cell(v);
39
+ return `$${(n / 100).toFixed(2)}`;
40
+ }
41
+ function table(rows) {
42
+ if (!rows.length)
43
+ return '(none)';
44
+ // Union of keys, so a row missing a field still lines up.
45
+ const keys = [];
46
+ for (const row of rows)
47
+ for (const k of Object.keys(row))
48
+ if (!keys.includes(k))
49
+ keys.push(k);
50
+ const render = (row, k) => isMoneyColumn(k) ? formatMoney(row[k]) : cell(row[k]);
51
+ const widths = keys.map((k) => Math.max(k.length, ...rows.map((r) => render(r, k).length)));
52
+ const line = (cells) => cells.map((c, i) => c.padEnd(widths[i])).join(' ').replace(/\s+$/, '');
53
+ return [
54
+ line(keys),
55
+ line(widths.map((w) => '─'.repeat(w))),
56
+ ...rows.map((r) => line(keys.map((k) => render(r, k)))),
57
+ ].join('\n');
58
+ }
59
+ export function render(value, opts = {}) {
60
+ if (opts.json)
61
+ return JSON.stringify(value, null, 2);
62
+ if (opts.ndjson) {
63
+ const rows = rowsOf(value);
64
+ if (rows)
65
+ return rows.map((r) => JSON.stringify(r)).join('\n');
66
+ return JSON.stringify(value);
67
+ }
68
+ const rows = rowsOf(value);
69
+ if (rows) {
70
+ const objects = rows.filter((r) => !!r && typeof r === 'object' && !Array.isArray(r));
71
+ if (objects.length === rows.length)
72
+ return table(objects);
73
+ }
74
+ // A single object renders as key/value pairs rather than a one-row table —
75
+ // a profile with twelve fields is unreadable sideways.
76
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
77
+ const obj = value.data ?? value;
78
+ if (obj && typeof obj === 'object' && !Array.isArray(obj)) {
79
+ const entries = Object.entries(obj);
80
+ const w = Math.max(...entries.map(([k]) => k.length), 0);
81
+ return entries
82
+ .map(([k, v]) => `${k.padEnd(w)} ${isMoneyColumn(k) ? formatMoney(v) : cell(v)}`)
83
+ .join('\n');
84
+ }
85
+ }
86
+ return String(value);
87
+ }
88
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot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AAM,GAAG,GAAI,KAA4B,CAAC,IAAI,IAAI,KAAK,CAAC;QACxD,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAA8B,CAAC,CAAC;YAC/D,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;YACzD,OAAO,OAAO;iBACX,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;iBACjF,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@crossly/buyer-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Your Crossly shopping from the terminal — cart, orders, wishlists, offers and cashback.",
5
+ "license": "MIT",
6
+ "homepage": "https://crossly.net",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/crossly-dev/crossly-cli.git",
10
+ "directory": "buyer"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/crossly-dev/crossly-cli/issues"
14
+ },
15
+ "keywords": [
16
+ "crossly",
17
+ "buyer",
18
+ "cli",
19
+ "shopping",
20
+ "cart",
21
+ "cashback",
22
+ "marketplace"
23
+ ],
24
+ "type": "module",
25
+ "bin": {
26
+ "crossly-buyer": "./dist/index.js"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "README.md"
37
+ ],
38
+ "dependencies": {
39
+ "@crossly/buyer-sdk": "0.1.0",
40
+ "@crossly/buyer-mcp": "0.1.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^22.10.0",
44
+ "typescript": "^5.7.2",
45
+ "vitest": "^2.1.8"
46
+ },
47
+ "engines": {
48
+ "node": ">=18"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "scripts": {
54
+ "build": "tsc",
55
+ "_typecheck_note": "buyer-mcp's and buyer-sdk's dist/ are gitignored and their exports maps type there, so `tsc --noEmit` alone fails on a fresh clone (TS2307 on @crossly/buyer-mcp/registry) or checks against a stale registry (the round-6 vault tools missing). `pnpm -r build` gets away with it because it is topologically ordered AND emits; `pnpm -r typecheck` is ordered but emits nothing, so both dependencies are built here, SDK first (pnpm runs a filtered set in dependency order). Tests need no build: vitest.config.ts reads both packages from source.",
56
+ "typecheck": "pnpm --filter @crossly/buyer-sdk --filter @crossly/buyer-mcp build && tsc --noEmit",
57
+ "build:deps": "pnpm --filter @crossly/buyer-sdk --filter @crossly/buyer-mcp build",
58
+ "test": "vitest run",
59
+ "test:watch": "vitest"
60
+ }
6
61
  }