clishop 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/.cursor/rules/commit-workflow.mdc +42 -0
- package/README.md +333 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3878 -0
- package/package.json +52 -0
- package/src/api.ts +89 -0
- package/src/auth.ts +117 -0
- package/src/commands/address.ts +213 -0
- package/src/commands/advertise.ts +702 -0
- package/src/commands/agent.ts +177 -0
- package/src/commands/auth.ts +122 -0
- package/src/commands/config.ts +56 -0
- package/src/commands/order.ts +334 -0
- package/src/commands/payment.ts +108 -0
- package/src/commands/review.ts +412 -0
- package/src/commands/search.ts +1319 -0
- package/src/commands/setup.ts +644 -0
- package/src/commands/status.ts +131 -0
- package/src/commands/store.ts +302 -0
- package/src/commands/support.ts +264 -0
- package/src/config.ts +127 -0
- package/src/index.ts +80 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
alwaysApply: true
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Commit Workflow
|
|
6
|
+
|
|
7
|
+
After completing any feature, fix, or meaningful change, **you must commit the work yourself** using git. Do not wait for the user to commit.
|
|
8
|
+
|
|
9
|
+
## Rules
|
|
10
|
+
|
|
11
|
+
1. **Commit after every completed feature or fix** — don't batch unrelated changes together.
|
|
12
|
+
2. **Use conventional commit messages** following this format:
|
|
13
|
+
```
|
|
14
|
+
<type>(<scope>): <short description>
|
|
15
|
+
```
|
|
16
|
+
Types: `feat`, `fix`, `refactor`, `chore`, `docs`, `test`, `style`, `perf`
|
|
17
|
+
Scope: the area of the codebase (e.g. `auth`, `agent`, `search`, `config`, `db`)
|
|
18
|
+
|
|
19
|
+
3. **Stage only the files relevant to that feature** — use `git add <specific files>` not `git add .` unless everything is related.
|
|
20
|
+
4. **Never commit** `.env`, `node_modules`, `dist`, `*.db`, or secrets.
|
|
21
|
+
5. **Check `git status` before committing** to make sure you're not including unwanted files.
|
|
22
|
+
6. **If working across multiple repos** (CLI + Backend), commit to each repo separately with its own message.
|
|
23
|
+
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
feat(auth): add login and register commands
|
|
28
|
+
feat(agent): implement agent CRUD with safety thresholds
|
|
29
|
+
fix(search): handle empty query results gracefully
|
|
30
|
+
chore(config): add environment variable support
|
|
31
|
+
docs: update README with command reference
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Multi-repo awareness
|
|
35
|
+
|
|
36
|
+
This workspace contains multiple repos:
|
|
37
|
+
- `CLISHOP2-CLI` — the CLI client
|
|
38
|
+
- `CLISHOP-BACKEND` — the API server
|
|
39
|
+
- `CLISHOP-WEB` — the website (future)
|
|
40
|
+
- `CLISHOP-VENDORSDK` — vendor SDK (future)
|
|
41
|
+
|
|
42
|
+
Always `cd` into the correct repo directory before running git commands.
|
package/README.md
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
# CLISHOP CLI
|
|
2
|
+
|
|
3
|
+
**CLISHOP** is a command-line shopping tool. Users search, browse, and buy products from multiple stores — all from the terminal. A single checkout covers items across stores.
|
|
4
|
+
|
|
5
|
+
- **Package**: `clishop`
|
|
6
|
+
- **Binary**: `clishop`
|
|
7
|
+
- **Runtime**: Node.js ≥ 18
|
|
8
|
+
- **Backend**: `https://clishop-backend.vercel.app/api`
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g clishop
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or from source:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
git clone https://github.com/DavooxBv2/CLISHOP.git
|
|
22
|
+
cd CLISHOP
|
|
23
|
+
npm install
|
|
24
|
+
npm run build
|
|
25
|
+
npm link # makes "clishop" available globally
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## First Run
|
|
29
|
+
|
|
30
|
+
Running `clishop` with no arguments triggers a guided setup wizard if the user hasn't completed setup. The wizard walks through:
|
|
31
|
+
|
|
32
|
+
1. Account creation or login
|
|
33
|
+
2. Agent configuration (optional — a default agent is created automatically)
|
|
34
|
+
3. Shipping address
|
|
35
|
+
4. Payment method (opens a secure browser link)
|
|
36
|
+
5. First product search
|
|
37
|
+
|
|
38
|
+
The wizard can also be re-run at any time:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
clishop setup
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Authentication
|
|
47
|
+
|
|
48
|
+
All commands except `--help`, `--version`, `register`, `login`, `config`, and `setup` require authentication.
|
|
49
|
+
|
|
50
|
+
Auth tokens are stored in the OS keychain via `keytar`. Refresh tokens are rotated automatically on expiry.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
clishop register # interactive: name, email, password
|
|
54
|
+
clishop login # interactive: email, password
|
|
55
|
+
clishop login -e user@example.com -p pass # non-interactive
|
|
56
|
+
clishop logout # clears local tokens
|
|
57
|
+
clishop whoami # prints current user name, email, id
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Non-interactive auth (for scripts / AI agents)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
clishop login --email <email> --password <password>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Both `-e` / `--email` and `-p` / `--password` flags are supported. If either is omitted, the CLI will prompt interactively.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Concepts
|
|
71
|
+
|
|
72
|
+
### Agents
|
|
73
|
+
|
|
74
|
+
Agents are **safety profiles** that control ordering behavior. Every user has a `default` agent created at registration.
|
|
75
|
+
|
|
76
|
+
Each agent has:
|
|
77
|
+
- `maxOrderAmount` — spending cap per order (in dollars)
|
|
78
|
+
- `requireConfirmation` — whether to prompt before placing an order
|
|
79
|
+
- `allowedCategories` / `blockedCategories` — category restrictions
|
|
80
|
+
- `defaultAddressId` — default shipping address
|
|
81
|
+
- `defaultPaymentMethodId` — default payment method
|
|
82
|
+
|
|
83
|
+
Use `--agent <name>` on any command to override the active agent for that invocation:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
clishop search headphones --agent work
|
|
87
|
+
clishop buy prod_xxx --agent work
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Stores
|
|
91
|
+
|
|
92
|
+
Products belong to stores (vendors). Stores are first-class entities with their own IDs (`stor_xxx`). The CLI displays the store name alongside products.
|
|
93
|
+
|
|
94
|
+
### IDs
|
|
95
|
+
|
|
96
|
+
All entities use short, prefixed IDs:
|
|
97
|
+
|
|
98
|
+
| Prefix | Entity | Example |
|
|
99
|
+
|--------|-----------------|--------------------|
|
|
100
|
+
| `prod_` | Product | `prod_a8k3m2x9p4w1` |
|
|
101
|
+
| `ordr_` | Order | `ordr_b7n4q1y8t3v6` |
|
|
102
|
+
| `addr_` | Address | `addr_c9j2w5r8m1k4` |
|
|
103
|
+
| `pymt_` | Payment method | `pymt_d3f8k1n7p2q9` |
|
|
104
|
+
| `stor_` | Store | `stor_e4g7j2m8r5t1` |
|
|
105
|
+
| `user_` | User | `user_f5h8k3n9s6v2` |
|
|
106
|
+
| `agnt_` | Agent | `agnt_g6j9l4p1t7w3` |
|
|
107
|
+
| `chkt_` | Checkout | `chkt_h7k1m5q2u8x4` |
|
|
108
|
+
|
|
109
|
+
### Money
|
|
110
|
+
|
|
111
|
+
All prices are stored and returned in **cents** (integer). The CLI converts to dollars for display. Example: `7999` = `$79.99`.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Command Reference
|
|
116
|
+
|
|
117
|
+
### Search & Browse
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
clishop search <query> # search for products
|
|
121
|
+
clishop search <query> --json # output raw JSON
|
|
122
|
+
clishop search <query> -c Electronics # filter by category
|
|
123
|
+
clishop search <query> --vendor AudioTech # filter by store/vendor
|
|
124
|
+
clishop search <query> --min-price 1000 # min price in cents
|
|
125
|
+
clishop search <query> --max-price 10000 # max price in cents
|
|
126
|
+
clishop search <query> --min-rating 4 # minimum star rating (1-5)
|
|
127
|
+
clishop search <query> --in-stock # only in-stock items
|
|
128
|
+
clishop search <query> -s price --order asc # sort by price ascending
|
|
129
|
+
clishop search <query> -p 2 -n 10 # page 2, 10 results per page
|
|
130
|
+
|
|
131
|
+
clishop product <productId> # view product details
|
|
132
|
+
clishop product <productId> --json # raw JSON output
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Sort options** (`-s`): `price`, `rating`, `relevance`, `newest`
|
|
136
|
+
|
|
137
|
+
### Ordering
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
clishop buy <productId> # quick-buy with defaults
|
|
141
|
+
clishop buy <productId> -q 3 # buy quantity 3
|
|
142
|
+
clishop buy <productId> --address <id> # specify shipping address
|
|
143
|
+
clishop buy <productId> --payment <id> # specify payment method
|
|
144
|
+
clishop buy <productId> -y # skip confirmation prompt
|
|
145
|
+
clishop buy <productId> --agent work # use a specific agent
|
|
146
|
+
|
|
147
|
+
clishop order list # list your orders
|
|
148
|
+
clishop order list --status pending # filter by status
|
|
149
|
+
clishop order list --json # raw JSON
|
|
150
|
+
clishop order show <orderId> # order details + tracking
|
|
151
|
+
clishop order show <orderId> --json
|
|
152
|
+
clishop order cancel <orderId> # cancel an order (interactive confirm)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Order statuses**: `pending`, `confirmed`, `processing`, `shipped`, `delivered`, `cancelled`
|
|
156
|
+
|
|
157
|
+
The `buy` command:
|
|
158
|
+
1. Fetches product info
|
|
159
|
+
2. Checks agent safety limits (max amount, category restrictions)
|
|
160
|
+
3. Shows a confirmation prompt (unless `-y` or agent has `requireConfirmation: false`)
|
|
161
|
+
4. Creates a checkout + order on the backend
|
|
162
|
+
5. Returns the order ID
|
|
163
|
+
|
|
164
|
+
### Agents
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
clishop agent list # list all agents (active marked with ●)
|
|
168
|
+
clishop agent show # show active agent details
|
|
169
|
+
clishop agent show <name> # show specific agent
|
|
170
|
+
clishop agent create <name> # interactive: create a new agent
|
|
171
|
+
clishop agent create <name> --max-amount 1000 # set max order amount ($)
|
|
172
|
+
clishop agent create <name> --no-confirm # don't require order confirmation
|
|
173
|
+
clishop agent use <name> # switch active agent
|
|
174
|
+
clishop agent update <name> # interactive: update agent settings
|
|
175
|
+
clishop agent delete <name> # delete an agent (cannot delete "default")
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Addresses
|
|
179
|
+
|
|
180
|
+
Addresses are scoped to the active agent.
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
clishop address list # list addresses for active agent
|
|
184
|
+
clishop address add # interactive: add an address
|
|
185
|
+
clishop address remove <addressId> # remove (soft-delete) an address
|
|
186
|
+
clishop address set-default <addressId> # set default address for active agent
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Address fields when adding:
|
|
190
|
+
- **Label**: e.g. "Home", "Office"
|
|
191
|
+
- **Street name and number**: e.g. "123 Main St"
|
|
192
|
+
- **Apartment/suite** (optional)
|
|
193
|
+
- **Postal / ZIP code**
|
|
194
|
+
- **City**
|
|
195
|
+
- **State / Province / Region** (optional — supports international addresses)
|
|
196
|
+
- **Country**
|
|
197
|
+
|
|
198
|
+
### Payment Methods
|
|
199
|
+
|
|
200
|
+
Payment methods are scoped to the active agent. The CLI never collects card details — it opens a secure browser link.
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
clishop payment list # list payment methods for active agent
|
|
204
|
+
clishop payment add # get a secure setup link (opens browser)
|
|
205
|
+
clishop payment remove <paymentId> # remove (soft-delete) a payment method
|
|
206
|
+
clishop payment set-default <paymentId> # set default payment for active agent
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Reviews
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
clishop review add <productId> # interactive: write a review (rating, title, body)
|
|
213
|
+
clishop review list # list your reviews
|
|
214
|
+
clishop review list --json # raw JSON
|
|
215
|
+
clishop review delete <reviewId> # delete a review
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Configuration
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
clishop config show # show current config (active agent, output format, path)
|
|
222
|
+
clishop config set-output human # set output format to human-readable
|
|
223
|
+
clishop config set-output json # set output format to JSON
|
|
224
|
+
clishop config reset # reset all config to defaults
|
|
225
|
+
clishop config path # print config file path
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Setup
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
clishop setup # run the first-time setup wizard
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Non-Interactive Usage (for AI Agents & Scripts)
|
|
237
|
+
|
|
238
|
+
The CLI is designed to work in automated/scripted environments:
|
|
239
|
+
|
|
240
|
+
### Login without prompts
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
clishop login -e <email> -p <password>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Skip order confirmation
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
clishop buy <productId> -y
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### JSON output for parsing
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
clishop search headphones --json
|
|
256
|
+
clishop order list --json
|
|
257
|
+
clishop order show <orderId> --json
|
|
258
|
+
clishop product <productId> --json
|
|
259
|
+
clishop review list --json
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Typical automated workflow
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# 1. Authenticate
|
|
266
|
+
clishop login -e user@example.com -p mypassword
|
|
267
|
+
|
|
268
|
+
# 2. Search for a product
|
|
269
|
+
clishop search "wireless headphones" --json
|
|
270
|
+
|
|
271
|
+
# 3. View product details (use a product ID from search results)
|
|
272
|
+
clishop product prod_a8k3m2x9p4w1 --json
|
|
273
|
+
|
|
274
|
+
# 4. Buy it (skip confirmation)
|
|
275
|
+
clishop buy prod_a8k3m2x9p4w1 -y
|
|
276
|
+
|
|
277
|
+
# 5. Check order status
|
|
278
|
+
clishop order list --json
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Using a specific agent
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
clishop buy prod_xxx --agent work -y
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Exit codes
|
|
288
|
+
|
|
289
|
+
- `0` — success
|
|
290
|
+
- `1` — error (auth failure, not found, validation error, API error)
|
|
291
|
+
|
|
292
|
+
Errors are printed to stderr. On failure, check the error message for details.
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Configuration Storage
|
|
297
|
+
|
|
298
|
+
| Data | Location |
|
|
299
|
+
|------|----------|
|
|
300
|
+
| CLI config (agents, preferences) | `~/.config/clishop/config.json` (or OS equivalent) |
|
|
301
|
+
| Auth tokens | OS keychain (via `keytar`) |
|
|
302
|
+
|
|
303
|
+
The config file path can be found with:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
clishop config path
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Environment Variables
|
|
312
|
+
|
|
313
|
+
| Variable | Purpose | Default |
|
|
314
|
+
|----------|---------|---------|
|
|
315
|
+
| `CLISHOP_API_URL` | Override the backend API URL | `https://clishop-backend.vercel.app/api` |
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Architecture
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
CLISHOP CLI (this repo)
|
|
323
|
+
│
|
|
324
|
+
├── Calls CLISHOP-BACKEND over HTTPS
|
|
325
|
+
│ └── https://clishop-backend.vercel.app/api
|
|
326
|
+
│
|
|
327
|
+
├── Stores config locally (conf)
|
|
328
|
+
│ └── ~/.config/clishop/config.json
|
|
329
|
+
│
|
|
330
|
+
└── Stores auth tokens in OS keychain (keytar)
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
The CLI is a pure client. It does not own the database, vendor integrations, or order orchestration. All data operations go through the backend API.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|