@newpeak/barista-cli 0.1.20 → 0.1.21
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 +20 -20
- package/README.ja.md +340 -340
- package/README.md +341 -340
- package/README.vi.md +340 -340
- package/README.zh.md +340 -340
- package/bin/barista +6 -6
- package/dist/commands/liberica/materials/create.d.ts.map +1 -1
- package/dist/commands/liberica/materials/create.js +131 -0
- package/dist/commands/liberica/materials/create.js.map +1 -1
- package/dist/commands/liberica/materials/list.d.ts.map +1 -1
- package/dist/commands/liberica/materials/list.js +46 -14
- package/dist/commands/liberica/materials/list.js.map +1 -1
- package/dist/commands/liberica/materials/update.d.ts.map +1 -1
- package/dist/commands/liberica/materials/update.js +129 -1
- package/dist/commands/liberica/materials/update.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/material.d.ts +135 -2
- package/dist/types/material.d.ts.map +1 -1
- package/package.json +63 -63
- package/dist/commands/arabica/enterprise/get.d.ts +0 -3
- package/dist/commands/arabica/enterprise/get.d.ts.map +0 -1
- package/dist/commands/arabica/enterprise/get.js +0 -94
- package/dist/commands/arabica/enterprise/get.js.map +0 -1
- package/dist/commands/arabica/enterprise/index.d.ts +0 -3
- package/dist/commands/arabica/enterprise/index.d.ts.map +0 -1
- package/dist/commands/arabica/enterprise/index.js +0 -18
- package/dist/commands/arabica/enterprise/index.js.map +0 -1
- package/dist/commands/arabica/enterprise/list.d.ts +0 -3
- package/dist/commands/arabica/enterprise/list.d.ts.map +0 -1
- package/dist/commands/arabica/enterprise/list.js +0 -71
- package/dist/commands/arabica/enterprise/list.js.map +0 -1
package/README.zh.md
CHANGED
|
@@ -1,340 +1,340 @@
|
|
|
1
|
-
# ☕ Barista CLI
|
|
2
|
-
|
|
3
|
-
> **让 AI 助手操控生产管理系统** — Bridge AI tools (Claude Code, OpenCode, OpenClaw) to enterprise SaaS
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@newpeak/barista-cli)
|
|
6
|
-
[](LICENSE)
|
|
7
|
-
[](https://www.npmjs.com/package/@newpeak/barista-cli)
|
|
8
|
-
[](https://nodejs.org/)
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## ⚡ Quick Start
|
|
13
|
-
|
|
14
|
-
### 1. Install
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install -g @newpeak/barista-cli
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### 2. Authenticate
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
# AI needs credentials to operate on behalf of user
|
|
24
|
-
barista liberica auth login prod-cn your-tenant your-username your-password
|
|
25
|
-
|
|
26
|
-
# Interactive login (prompts for missing info)
|
|
27
|
-
barista liberica auth login
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### 3. AI Integration
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
// In Claude Code / OpenCode / OpenClaw:
|
|
34
|
-
const orders = await $`barista liberica orders list --env prod-cn --tenant your-tenant --json`
|
|
35
|
-
const { success, data } = JSON.parse(orders.stdout)
|
|
36
|
-
|
|
37
|
-
// AI parses and acts on the data
|
|
38
|
-
if (data.items.length > 0) {
|
|
39
|
-
console.log(`Found ${data.pagination.total} orders`)
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
**[View AI Integration Examples →](#ai-integration)**
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## 🤖 AI Integration
|
|
48
|
-
|
|
49
|
-
Barista CLI is designed for AI coding assistants. Every output is structured, every error is actionable.
|
|
50
|
-
|
|
51
|
-
### Supported AI Tools
|
|
52
|
-
|
|
53
|
-
| AI Tool | Integration Method | Status |
|
|
54
|
-
|---------|-------------------|--------|
|
|
55
|
-
| **Claude Code** | `$` backticks + `--json` | ✅ Verified |
|
|
56
|
-
| **OpenCode** | Shell command + JSON parse | ✅ Verified |
|
|
57
|
-
| **OpenClaw** | Shell command + JSON parse | ✅ Verified |
|
|
58
|
-
| **Cursor** | Terminal integration | ✅ Compatible |
|
|
59
|
-
| **Continue** | CLI subprocess | ✅ Compatible |
|
|
60
|
-
|
|
61
|
-
### Integration Pattern
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
// 1. Execute command with JSON output
|
|
65
|
-
const result = await $`barista liberica orders list \
|
|
66
|
-
--env prod-cn \
|
|
67
|
-
--tenant your-tenant \
|
|
68
|
-
--status pending \
|
|
69
|
-
--json \
|
|
70
|
-
--page 1 \
|
|
71
|
-
--size 50`
|
|
72
|
-
|
|
73
|
-
// 2. Parse structured response
|
|
74
|
-
const { success, data, meta } = JSON.parse(result.stdout)
|
|
75
|
-
|
|
76
|
-
if (!success) {
|
|
77
|
-
throw new Error(`API Error: ${meta.code || meta.error?.code} - ${meta.message || meta.error?.message}`)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// 3. Work with data
|
|
81
|
-
const pendingOrders = data.items
|
|
82
|
-
console.log(`Found ${data.pagination.total} pending orders`)
|
|
83
|
-
|
|
84
|
-
// 4. Execute operations safely
|
|
85
|
-
for (const order of pendingOrders) {
|
|
86
|
-
// Always dry-run first (AI safety)
|
|
87
|
-
const preview = await $`barista liberica orders cancel ${order.id} --dry-run`
|
|
88
|
-
|
|
89
|
-
// Parse preview, verify, then execute with --force
|
|
90
|
-
// ...
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Response Envelope
|
|
95
|
-
|
|
96
|
-
All JSON responses follow this structure:
|
|
97
|
-
|
|
98
|
-
```json
|
|
99
|
-
{
|
|
100
|
-
"success": true,
|
|
101
|
-
"data": {
|
|
102
|
-
"items": [...],
|
|
103
|
-
"pagination": { "page": 1, "size": 20, "total": 150 }
|
|
104
|
-
},
|
|
105
|
-
"meta": {
|
|
106
|
-
"requestId": "req-abc123",
|
|
107
|
-
"timestamp": "2024-01-15T10:30:00Z",
|
|
108
|
-
"environment": "prod-cn",
|
|
109
|
-
"tenant": "your-tenant"
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**Error format:**
|
|
115
|
-
|
|
116
|
-
```json
|
|
117
|
-
{
|
|
118
|
-
"success": false,
|
|
119
|
-
"error": {
|
|
120
|
-
"code": "A150001",
|
|
121
|
-
"message": "Order not found"
|
|
122
|
-
},
|
|
123
|
-
"meta": {
|
|
124
|
-
"requestId": "req-xyz789",
|
|
125
|
-
"timestamp": "2024-01-15T10:30:00Z"
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### Skills for Claude Code
|
|
131
|
-
|
|
132
|
-
Install reusable skill files:
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
# Skills are located at ~/.barista/claude/skills/
|
|
136
|
-
barista skills install
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
**Available skills:**
|
|
140
|
-
- `orders.md` — Order management workflow
|
|
141
|
-
- `products.md` — Product search and sync
|
|
142
|
-
- `warehouses.md` — Inventory operations
|
|
143
|
-
- `subscriptions.md` — Arabica subscription management
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## 🚀 Features
|
|
148
|
-
|
|
149
|
-
### AI-First Design
|
|
150
|
-
|
|
151
|
-
| Feature | Description |
|
|
152
|
-
|---------|-------------|
|
|
153
|
-
| 🤖 **JSON-First Output** | All commands support `--json` for AI parsing |
|
|
154
|
-
| 📦 **Structured Responses** | Consistent `{success, data, meta}` envelope |
|
|
155
|
-
| 🔄 **Idempotent Operations** | Safe for AI retry loops |
|
|
156
|
-
| 🛡️ **Dry-Run by Default** | Destructive operations preview before execution |
|
|
157
|
-
| 🔐 **Secure Storage** | Credentials in system keychain, not env vars |
|
|
158
|
-
|
|
159
|
-
### Enterprise Connectivity
|
|
160
|
-
|
|
161
|
-
| Service | Capabilities |
|
|
162
|
-
|---------|-------------|
|
|
163
|
-
| ☕ **Liberica** | Orders, products, inventory, warehouses, production planning |
|
|
164
|
-
| 🛒 **Arabica** | Subscription plans, billing, invoices, enterprise management |
|
|
165
|
-
| 🔗 **Cross-Service** | Quote from order, sync between systems |
|
|
166
|
-
|
|
167
|
-
### Operational Safety
|
|
168
|
-
|
|
169
|
-
- 📊 **Audit Trail** — Every operation logged with request ID
|
|
170
|
-
- ⚠️ **Confirmation Guards** — `--dry-run` / `--force` for write operations
|
|
171
|
-
- 🏢 **Multi-Tenant Isolation** — Credentials isolated per tenant
|
|
172
|
-
|
|
173
|
-
---
|
|
174
|
-
|
|
175
|
-
## 🔧 Command Reference
|
|
176
|
-
|
|
177
|
-
### Core Pattern
|
|
178
|
-
|
|
179
|
-
```
|
|
180
|
-
barista <service> <resource> <action> [options]
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### Global Options
|
|
184
|
-
|
|
185
|
-
| Option | Description | Default |
|
|
186
|
-
|--------|-------------|---------|
|
|
187
|
-
| `--env` | Environment (dev\|test\|prod-cn\|prod-jp) | `dev` |
|
|
188
|
-
| `--tenant` | Tenant name | - |
|
|
189
|
-
| `--json` | JSON output | `false` |
|
|
190
|
-
| `--dry-run` | Preview mode (recommended for AI) | `false` |
|
|
191
|
-
| `--force` | Skip confirmation | `false` |
|
|
192
|
-
| `--page` | Page number | `1` |
|
|
193
|
-
| `--size` | Page size (max items) | `20` |
|
|
194
|
-
|
|
195
|
-
### Quick Reference
|
|
196
|
-
|
|
197
|
-
| Command | Description |
|
|
198
|
-
|---------|-------------|
|
|
199
|
-
| `barista context show` | Show current env/tenant context |
|
|
200
|
-
| `barista context use-env <env>` | Switch environment |
|
|
201
|
-
| `barista liberica orders list --json` | List orders (AI format) |
|
|
202
|
-
| `barista liberica orders get <id> --json` | Get order detail |
|
|
203
|
-
| `barista liberica orders create --dry-run ...` | Preview create |
|
|
204
|
-
| `barista liberica products search --keyword <kw> --json` | Search products |
|
|
205
|
-
| `barista arabica plans list --json` | List subscription plans |
|
|
206
|
-
| `barista arabica invoices list --json` | List invoices |
|
|
207
|
-
|
|
208
|
-
**[→ Full Command Reference](./docs/commands/REFERENCE.md)**
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## 🛡️ AI Safety Guidelines
|
|
213
|
-
|
|
214
|
-
### 1. Always Dry-Run First
|
|
215
|
-
|
|
216
|
-
```typescript
|
|
217
|
-
// ❌ Wrong - executing blindly
|
|
218
|
-
await $`barista liberica orders cancel 12345`
|
|
219
|
-
|
|
220
|
-
// ✅ Correct - preview first
|
|
221
|
-
const preview = await $`barista liberica orders cancel 12345 --dry-run`
|
|
222
|
-
// Parse preview, verify correctness, then:
|
|
223
|
-
await $`barista liberica orders cancel 12345 --force`
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### 2. Check Success Before Proceeding
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
const result = JSON.parse(stdout)
|
|
230
|
-
if (!result.success) {
|
|
231
|
-
// Handle error, don't continue
|
|
232
|
-
throw new Error(result.error?.message || result.meta?.message)
|
|
233
|
-
}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
### 3. Use Request IDs for Debugging
|
|
237
|
-
|
|
238
|
-
```typescript
|
|
239
|
-
const { meta } = JSON.parse(stdout)
|
|
240
|
-
console.log(`Request ID: ${meta.requestId}`)
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### 4. Respect Rate Limits
|
|
244
|
-
|
|
245
|
-
- Add delays between bulk operations
|
|
246
|
-
- Use `--size 100` for bulk fetches
|
|
247
|
-
- Cache responses when appropriate
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
## ⚙️ Configuration
|
|
252
|
-
|
|
253
|
-
### File Location
|
|
254
|
-
|
|
255
|
-
`~/.barista/config.yaml`
|
|
256
|
-
|
|
257
|
-
### Quick Config
|
|
258
|
-
|
|
259
|
-
```yaml
|
|
260
|
-
defaults:
|
|
261
|
-
env: prod-cn
|
|
262
|
-
tenant: your-tenant
|
|
263
|
-
service: liberica
|
|
264
|
-
|
|
265
|
-
environments:
|
|
266
|
-
prod-cn:
|
|
267
|
-
liberica:
|
|
268
|
-
baseUrl: "https://{tenant}.newpeaksh.com"
|
|
269
|
-
timeout: 60000
|
|
270
|
-
arabica:
|
|
271
|
-
baseUrl: "https://www.newpeaksh.com"
|
|
272
|
-
timeout: 60000
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
### Authentication
|
|
276
|
-
|
|
277
|
-
```bash
|
|
278
|
-
# Credential login (recommended)
|
|
279
|
-
barista liberica auth login <env> <tenant> <username> <password>
|
|
280
|
-
|
|
281
|
-
# Check auth status
|
|
282
|
-
barista auth status
|
|
283
|
-
|
|
284
|
-
# Logout
|
|
285
|
-
barista auth logout --service liberica --env prod-cn
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
## ❓ Troubleshooting
|
|
291
|
-
|
|
292
|
-
### Auth Failures
|
|
293
|
-
|
|
294
|
-
```bash
|
|
295
|
-
# Check current status
|
|
296
|
-
barista auth status
|
|
297
|
-
|
|
298
|
-
# Re-authenticate
|
|
299
|
-
barista liberica auth login prod-cn your-tenant your-username your-password
|
|
300
|
-
|
|
301
|
-
# Check context
|
|
302
|
-
barista context show
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
### API Errors
|
|
306
|
-
|
|
307
|
-
```bash
|
|
308
|
-
# Always use --json to get error codes
|
|
309
|
-
barista liberica orders list --json
|
|
310
|
-
|
|
311
|
-
# Error response includes requestId for debugging
|
|
312
|
-
# "requestId": "req-abc123"
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
### Timeout Issues
|
|
316
|
-
|
|
317
|
-
```bash
|
|
318
|
-
# Switch to closer environment
|
|
319
|
-
barista context use-env dev
|
|
320
|
-
|
|
321
|
-
# Or adjust timeout in config.yaml
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
---
|
|
325
|
-
|
|
326
|
-
## 📚 Related Projects
|
|
327
|
-
|
|
328
|
-
| Project | Description |
|
|
329
|
-
|---------|-------------|
|
|
330
|
-
| ☕ Liberica Backend | Production management SaaS backend |
|
|
331
|
-
| 🖥️ Liberica Frontend | Production management web UI |
|
|
332
|
-
| 📱 Liberica Mobile | Production management mobile app |
|
|
333
|
-
| 🛒 Arabica Backend | Online subscription SaaS backend |
|
|
334
|
-
| 🌐 Arabica Frontend | Online subscription web UI |
|
|
335
|
-
|
|
336
|
-
---
|
|
337
|
-
|
|
338
|
-
## 📄 License
|
|
339
|
-
|
|
340
|
-
[MIT](LICENSE) © Newpeak Technology
|
|
1
|
+
# ☕ Barista CLI
|
|
2
|
+
|
|
3
|
+
> **让 AI 助手操控生产管理系统** — Bridge AI tools (Claude Code, OpenCode, OpenClaw) to enterprise SaaS
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@newpeak/barista-cli)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://www.npmjs.com/package/@newpeak/barista-cli)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## ⚡ Quick Start
|
|
13
|
+
|
|
14
|
+
### 1. Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g @newpeak/barista-cli
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 2. Authenticate
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# AI needs credentials to operate on behalf of user
|
|
24
|
+
barista liberica auth login prod-cn your-tenant your-username your-password
|
|
25
|
+
|
|
26
|
+
# Interactive login (prompts for missing info)
|
|
27
|
+
barista liberica auth login
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 3. AI Integration
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// In Claude Code / OpenCode / OpenClaw:
|
|
34
|
+
const orders = await $`barista liberica orders list --env prod-cn --tenant your-tenant --json`
|
|
35
|
+
const { success, data } = JSON.parse(orders.stdout)
|
|
36
|
+
|
|
37
|
+
// AI parses and acts on the data
|
|
38
|
+
if (data.items.length > 0) {
|
|
39
|
+
console.log(`Found ${data.pagination.total} orders`)
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**[View AI Integration Examples →](#ai-integration)**
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 🤖 AI Integration
|
|
48
|
+
|
|
49
|
+
Barista CLI is designed for AI coding assistants. Every output is structured, every error is actionable.
|
|
50
|
+
|
|
51
|
+
### Supported AI Tools
|
|
52
|
+
|
|
53
|
+
| AI Tool | Integration Method | Status |
|
|
54
|
+
|---------|-------------------|--------|
|
|
55
|
+
| **Claude Code** | `$` backticks + `--json` | ✅ Verified |
|
|
56
|
+
| **OpenCode** | Shell command + JSON parse | ✅ Verified |
|
|
57
|
+
| **OpenClaw** | Shell command + JSON parse | ✅ Verified |
|
|
58
|
+
| **Cursor** | Terminal integration | ✅ Compatible |
|
|
59
|
+
| **Continue** | CLI subprocess | ✅ Compatible |
|
|
60
|
+
|
|
61
|
+
### Integration Pattern
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// 1. Execute command with JSON output
|
|
65
|
+
const result = await $`barista liberica orders list \
|
|
66
|
+
--env prod-cn \
|
|
67
|
+
--tenant your-tenant \
|
|
68
|
+
--status pending \
|
|
69
|
+
--json \
|
|
70
|
+
--page 1 \
|
|
71
|
+
--size 50`
|
|
72
|
+
|
|
73
|
+
// 2. Parse structured response
|
|
74
|
+
const { success, data, meta } = JSON.parse(result.stdout)
|
|
75
|
+
|
|
76
|
+
if (!success) {
|
|
77
|
+
throw new Error(`API Error: ${meta.code || meta.error?.code} - ${meta.message || meta.error?.message}`)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 3. Work with data
|
|
81
|
+
const pendingOrders = data.items
|
|
82
|
+
console.log(`Found ${data.pagination.total} pending orders`)
|
|
83
|
+
|
|
84
|
+
// 4. Execute operations safely
|
|
85
|
+
for (const order of pendingOrders) {
|
|
86
|
+
// Always dry-run first (AI safety)
|
|
87
|
+
const preview = await $`barista liberica orders cancel ${order.id} --dry-run`
|
|
88
|
+
|
|
89
|
+
// Parse preview, verify, then execute with --force
|
|
90
|
+
// ...
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Response Envelope
|
|
95
|
+
|
|
96
|
+
All JSON responses follow this structure:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"success": true,
|
|
101
|
+
"data": {
|
|
102
|
+
"items": [...],
|
|
103
|
+
"pagination": { "page": 1, "size": 20, "total": 150 }
|
|
104
|
+
},
|
|
105
|
+
"meta": {
|
|
106
|
+
"requestId": "req-abc123",
|
|
107
|
+
"timestamp": "2024-01-15T10:30:00Z",
|
|
108
|
+
"environment": "prod-cn",
|
|
109
|
+
"tenant": "your-tenant"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Error format:**
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"success": false,
|
|
119
|
+
"error": {
|
|
120
|
+
"code": "A150001",
|
|
121
|
+
"message": "Order not found"
|
|
122
|
+
},
|
|
123
|
+
"meta": {
|
|
124
|
+
"requestId": "req-xyz789",
|
|
125
|
+
"timestamp": "2024-01-15T10:30:00Z"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Skills for Claude Code
|
|
131
|
+
|
|
132
|
+
Install reusable skill files:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Skills are located at ~/.barista/claude/skills/
|
|
136
|
+
barista skills install
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Available skills:**
|
|
140
|
+
- `orders.md` — Order management workflow
|
|
141
|
+
- `products.md` — Product search and sync
|
|
142
|
+
- `warehouses.md` — Inventory operations
|
|
143
|
+
- `subscriptions.md` — Arabica subscription management
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 🚀 Features
|
|
148
|
+
|
|
149
|
+
### AI-First Design
|
|
150
|
+
|
|
151
|
+
| Feature | Description |
|
|
152
|
+
|---------|-------------|
|
|
153
|
+
| 🤖 **JSON-First Output** | All commands support `--json` for AI parsing |
|
|
154
|
+
| 📦 **Structured Responses** | Consistent `{success, data, meta}` envelope |
|
|
155
|
+
| 🔄 **Idempotent Operations** | Safe for AI retry loops |
|
|
156
|
+
| 🛡️ **Dry-Run by Default** | Destructive operations preview before execution |
|
|
157
|
+
| 🔐 **Secure Storage** | Credentials in system keychain, not env vars |
|
|
158
|
+
|
|
159
|
+
### Enterprise Connectivity
|
|
160
|
+
|
|
161
|
+
| Service | Capabilities |
|
|
162
|
+
|---------|-------------|
|
|
163
|
+
| ☕ **Liberica** | Orders, products, inventory, warehouses, production planning |
|
|
164
|
+
| 🛒 **Arabica** | Subscription plans, billing, invoices, enterprise management |
|
|
165
|
+
| 🔗 **Cross-Service** | Quote from order, sync between systems |
|
|
166
|
+
|
|
167
|
+
### Operational Safety
|
|
168
|
+
|
|
169
|
+
- 📊 **Audit Trail** — Every operation logged with request ID
|
|
170
|
+
- ⚠️ **Confirmation Guards** — `--dry-run` / `--force` for write operations
|
|
171
|
+
- 🏢 **Multi-Tenant Isolation** — Credentials isolated per tenant
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## 🔧 Command Reference
|
|
176
|
+
|
|
177
|
+
### Core Pattern
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
barista <service> <resource> <action> [options]
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Global Options
|
|
184
|
+
|
|
185
|
+
| Option | Description | Default |
|
|
186
|
+
|--------|-------------|---------|
|
|
187
|
+
| `--env` | Environment (dev\|test\|prod-cn\|prod-jp) | `dev` |
|
|
188
|
+
| `--tenant` | Tenant name | - |
|
|
189
|
+
| `--json` | JSON output | `false` |
|
|
190
|
+
| `--dry-run` | Preview mode (recommended for AI) | `false` |
|
|
191
|
+
| `--force` | Skip confirmation | `false` |
|
|
192
|
+
| `--page` | Page number | `1` |
|
|
193
|
+
| `--size` | Page size (max items) | `20` |
|
|
194
|
+
|
|
195
|
+
### Quick Reference
|
|
196
|
+
|
|
197
|
+
| Command | Description |
|
|
198
|
+
|---------|-------------|
|
|
199
|
+
| `barista context show` | Show current env/tenant context |
|
|
200
|
+
| `barista context use-env <env>` | Switch environment |
|
|
201
|
+
| `barista liberica orders list --json` | List orders (AI format) |
|
|
202
|
+
| `barista liberica orders get <id> --json` | Get order detail |
|
|
203
|
+
| `barista liberica orders create --dry-run ...` | Preview create |
|
|
204
|
+
| `barista liberica products search --keyword <kw> --json` | Search products |
|
|
205
|
+
| `barista arabica plans list --json` | List subscription plans |
|
|
206
|
+
| `barista arabica invoices list --json` | List invoices |
|
|
207
|
+
|
|
208
|
+
**[→ Full Command Reference](./docs/commands/REFERENCE.md)**
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 🛡️ AI Safety Guidelines
|
|
213
|
+
|
|
214
|
+
### 1. Always Dry-Run First
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
// ❌ Wrong - executing blindly
|
|
218
|
+
await $`barista liberica orders cancel 12345`
|
|
219
|
+
|
|
220
|
+
// ✅ Correct - preview first
|
|
221
|
+
const preview = await $`barista liberica orders cancel 12345 --dry-run`
|
|
222
|
+
// Parse preview, verify correctness, then:
|
|
223
|
+
await $`barista liberica orders cancel 12345 --force`
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 2. Check Success Before Proceeding
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
const result = JSON.parse(stdout)
|
|
230
|
+
if (!result.success) {
|
|
231
|
+
// Handle error, don't continue
|
|
232
|
+
throw new Error(result.error?.message || result.meta?.message)
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### 3. Use Request IDs for Debugging
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
const { meta } = JSON.parse(stdout)
|
|
240
|
+
console.log(`Request ID: ${meta.requestId}`)
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### 4. Respect Rate Limits
|
|
244
|
+
|
|
245
|
+
- Add delays between bulk operations
|
|
246
|
+
- Use `--size 100` for bulk fetches
|
|
247
|
+
- Cache responses when appropriate
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## ⚙️ Configuration
|
|
252
|
+
|
|
253
|
+
### File Location
|
|
254
|
+
|
|
255
|
+
`~/.barista/config.yaml`
|
|
256
|
+
|
|
257
|
+
### Quick Config
|
|
258
|
+
|
|
259
|
+
```yaml
|
|
260
|
+
defaults:
|
|
261
|
+
env: prod-cn
|
|
262
|
+
tenant: your-tenant
|
|
263
|
+
service: liberica
|
|
264
|
+
|
|
265
|
+
environments:
|
|
266
|
+
prod-cn:
|
|
267
|
+
liberica:
|
|
268
|
+
baseUrl: "https://{tenant}.newpeaksh.com"
|
|
269
|
+
timeout: 60000
|
|
270
|
+
arabica:
|
|
271
|
+
baseUrl: "https://www.newpeaksh.com"
|
|
272
|
+
timeout: 60000
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Authentication
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
# Credential login (recommended)
|
|
279
|
+
barista liberica auth login <env> <tenant> <username> <password>
|
|
280
|
+
|
|
281
|
+
# Check auth status
|
|
282
|
+
barista auth status
|
|
283
|
+
|
|
284
|
+
# Logout
|
|
285
|
+
barista auth logout --service liberica --env prod-cn
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## ❓ Troubleshooting
|
|
291
|
+
|
|
292
|
+
### Auth Failures
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Check current status
|
|
296
|
+
barista auth status
|
|
297
|
+
|
|
298
|
+
# Re-authenticate
|
|
299
|
+
barista liberica auth login prod-cn your-tenant your-username your-password
|
|
300
|
+
|
|
301
|
+
# Check context
|
|
302
|
+
barista context show
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### API Errors
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Always use --json to get error codes
|
|
309
|
+
barista liberica orders list --json
|
|
310
|
+
|
|
311
|
+
# Error response includes requestId for debugging
|
|
312
|
+
# "requestId": "req-abc123"
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Timeout Issues
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
# Switch to closer environment
|
|
319
|
+
barista context use-env dev
|
|
320
|
+
|
|
321
|
+
# Or adjust timeout in config.yaml
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## 📚 Related Projects
|
|
327
|
+
|
|
328
|
+
| Project | Description |
|
|
329
|
+
|---------|-------------|
|
|
330
|
+
| ☕ Liberica Backend | Production management SaaS backend |
|
|
331
|
+
| 🖥️ Liberica Frontend | Production management web UI |
|
|
332
|
+
| 📱 Liberica Mobile | Production management mobile app |
|
|
333
|
+
| 🛒 Arabica Backend | Online subscription SaaS backend |
|
|
334
|
+
| 🌐 Arabica Frontend | Online subscription web UI |
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## 📄 License
|
|
339
|
+
|
|
340
|
+
[MIT](LICENSE) © Newpeak Technology
|