@newpeak/barista-cli 0.1.19 → 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.
Files changed (49) hide show
  1. package/LICENSE +20 -20
  2. package/README.ja.md +340 -340
  3. package/README.md +341 -340
  4. package/README.vi.md +340 -340
  5. package/README.zh.md +340 -340
  6. package/bin/barista +6 -6
  7. package/dist/commands/liberica/client-price/create.d.ts.map +1 -1
  8. package/dist/commands/liberica/client-price/create.js +9 -1
  9. package/dist/commands/liberica/client-price/create.js.map +1 -1
  10. package/dist/commands/liberica/client-price/update.d.ts.map +1 -1
  11. package/dist/commands/liberica/client-price/update.js +28 -2
  12. package/dist/commands/liberica/client-price/update.js.map +1 -1
  13. package/dist/commands/liberica/materials/create.d.ts.map +1 -1
  14. package/dist/commands/liberica/materials/create.js +131 -0
  15. package/dist/commands/liberica/materials/create.js.map +1 -1
  16. package/dist/commands/liberica/materials/list.d.ts.map +1 -1
  17. package/dist/commands/liberica/materials/list.js +46 -14
  18. package/dist/commands/liberica/materials/list.js.map +1 -1
  19. package/dist/commands/liberica/materials/update.d.ts.map +1 -1
  20. package/dist/commands/liberica/materials/update.js +129 -1
  21. package/dist/commands/liberica/materials/update.js.map +1 -1
  22. package/dist/commands/liberica/supplier-price/create.d.ts.map +1 -1
  23. package/dist/commands/liberica/supplier-price/create.js +11 -1
  24. package/dist/commands/liberica/supplier-price/create.js.map +1 -1
  25. package/dist/commands/liberica/supplier-price/update.d.ts.map +1 -1
  26. package/dist/commands/liberica/supplier-price/update.js +28 -2
  27. package/dist/commands/liberica/supplier-price/update.js.map +1 -1
  28. package/dist/index.js +1 -1
  29. package/dist/types/client-price.d.ts +2 -0
  30. package/dist/types/client-price.d.ts.map +1 -1
  31. package/dist/types/index.d.ts +1 -1
  32. package/dist/types/index.d.ts.map +1 -1
  33. package/dist/types/material.d.ts +135 -2
  34. package/dist/types/material.d.ts.map +1 -1
  35. package/dist/types/supplier-price.d.ts +3 -1
  36. package/dist/types/supplier-price.d.ts.map +1 -1
  37. package/package.json +63 -63
  38. package/dist/commands/arabica/enterprise/get.d.ts +0 -3
  39. package/dist/commands/arabica/enterprise/get.d.ts.map +0 -1
  40. package/dist/commands/arabica/enterprise/get.js +0 -94
  41. package/dist/commands/arabica/enterprise/get.js.map +0 -1
  42. package/dist/commands/arabica/enterprise/index.d.ts +0 -3
  43. package/dist/commands/arabica/enterprise/index.d.ts.map +0 -1
  44. package/dist/commands/arabica/enterprise/index.js +0 -18
  45. package/dist/commands/arabica/enterprise/index.js.map +0 -1
  46. package/dist/commands/arabica/enterprise/list.d.ts +0 -3
  47. package/dist/commands/arabica/enterprise/list.d.ts.map +0 -1
  48. package/dist/commands/arabica/enterprise/list.js +0 -71
  49. package/dist/commands/arabica/enterprise/list.js.map +0 -1
package/README.vi.md CHANGED
@@ -1,340 +1,340 @@
1
- # ☕ Barista CLI
2
-
3
- > **Để AI assistants điều khiển hệ thống quản lý sản xuất** — Kết nối AI tools (Claude Code, OpenCode, OpenClaw) với SaaS doanh nghiệp
4
-
5
- [![npm version](https://img.shields.io/npm/v/@newpeak/barista-cli.svg?style=flat-square)](https://www.npmjs.com/package/@newpeak/barista-cli)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](LICENSE)
7
- [![Weekly Downloads](https://img.shields.io/npm/dw/@newpeak/barista-cli?style=flat-square)](https://www.npmjs.com/package/@newpeak/barista-cli)
8
- [![Node.js](https://img.shields.io/badge/Node.js-18%2B-brightgreen?style=flat-square)](https://nodejs.org/)
9
-
10
- ---
11
-
12
- ## ⚡ Khởi Đầu Nhanh
13
-
14
- ### 1. Cài Đặt
15
-
16
- ```bash
17
- npm install -g @newpeak/barista-cli
18
- ```
19
-
20
- ### 2. Xác Thực
21
-
22
- ```bash
23
- # AI cần credentials để hoạt động thay mặt người dùng
24
- barista liberica auth login prod-cn your-tenant your-username your-password
25
-
26
- # Đăng nhập tương tác (nhắc nhập thông tin còn thiếu)
27
- barista liberica auth login
28
- ```
29
-
30
- ### 3. Tích Hợp AI
31
-
32
- ```typescript
33
- // Trong 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 phân tích và xử lý dữ liệu
38
- if (data.items.length > 0) {
39
- console.log(`Found ${data.pagination.total} orders`)
40
- }
41
- ```
42
-
43
- **[Xem ví dụ tích hợp AI →](#ai-integration)**
44
-
45
- ---
46
-
47
- ## 🤖 Tích Hợp AI
48
-
49
- Barista CLI được thiết kế cho AI coding assistants. Mọi đầu ra đều có cấu trúc, mọi lỗi đều có thể xử lý.
50
-
51
- ### Các AI Tools Được Hỗ Trợ
52
-
53
- | AI Tool | Phương Thức Tích Hợp | Trạng Thái |
54
- |---------|----------------------|------------|
55
- | **Claude Code** | `$` backticks + `--json` | ✅ Đã xác minh |
56
- | **OpenCode** | Shell command + JSON parse | ✅ Đã xác minh |
57
- | **OpenClaw** | Shell command + JSON parse | ✅ Đã xác minh |
58
- | **Cursor** | Terminal integration | ✅ Tương thích |
59
- | **Continue** | CLI subprocess | ✅ Tương thích |
60
-
61
- ### Mẫu Tích Hợp
62
-
63
- ```typescript
64
- // 1. Thực thi lệnh với đầu ra JSON
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. Phân tích phản hồi có cấu trúc
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. Xử lý dữ liệu
81
- const pendingOrders = data.items
82
- console.log(`Found ${data.pagination.total} pending orders`)
83
-
84
- // 4. Thực thi thao tác an toàn
85
- for (const order of pendingOrders) {
86
- // Luôn chạy dry-run trước (an toàn cho AI)
87
- const preview = await $`barista liberica orders cancel ${order.id} --dry-run`
88
-
89
- // Phân tích preview, xác minh, rồi thực thi với --force
90
- // ...
91
- }
92
- ```
93
-
94
- ### Response Envelope
95
-
96
- Tất cả phản hồi JSON đều theo cấu trúc này:
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
- **Định dạng lỗi:**
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 cho Claude Code
131
-
132
- Cài đặt các file skill có thể tái sử dụng:
133
-
134
- ```bash
135
- # Skills nằm tại ~/.barista/claude/skills/
136
- barista skills install
137
- ```
138
-
139
- **Các skills có sẵn:**
140
- - `orders.md` — Quy trình quản lý đơn hàng
141
- - `products.md` — Tìm kiếm và đồng bộ sản phẩm
142
- - `warehouses.md` — Thao tác kho hàng
143
- - `subscriptions.md` — Quản lý đăng ký Arabica
144
-
145
- ---
146
-
147
- ## 🚀 Tính Năng
148
-
149
- ### Thiết Kế AI-First
150
-
151
- | Tính Năng | Mô Tả |
152
- |-----------|--------|
153
- | 🤖 **JSON-First Output** | Tất cả lệnh hỗ trợ `--json` để AI phân tích |
154
- | 📦 **Structured Responses** | Cấu trúc nhất quán `{success, data, meta}` |
155
- | 🔄 **Idempotent Operations** | An toàn cho AI retry loops |
156
- | 🛡️ **Dry-Run by Default** | Xem trước các thao tác nguy hiểm trước khi thực thi |
157
- | 🔐 **Secure Storage** | Credentials lưu trong system keychain, không phải env vars |
158
-
159
- ### Kết Nối Doanh Nghiệp
160
-
161
- | Dịch Vụ | Khả Năng |
162
- |---------|----------|
163
- | ☕ **Liberica** | Đơn hàng, sản phẩm, tồn kho, kho hàng, lập kế hoạch sản xuất |
164
- | 🛒 **Arabica** | Gói đăng ký, thanh toán, hóa đơn, quản lý doanh nghiệp |
165
- | 🔗 **Cross-Service** | Báo giá từ đơn hàng, đồng bộ giữa các hệ thống |
166
-
167
- ### An Toàn Vận Hành
168
-
169
- - 📊 **Audit Trail** — Mỗi thao tác được ghi log với request ID
170
- - ⚠️ **Confirmation Guards** — `--dry-run` / `--force` cho các thao tác ghi
171
- - 🏢 **Multi-Tenant Isolation** — Credentials được cô lập theo từng tenant
172
-
173
- ---
174
-
175
- ## 🔧 Tham Khảo Lệnh
176
-
177
- ### Mẫu Cơ Bản
178
-
179
- ```
180
- barista <service> <resource> <action> [options]
181
- ```
182
-
183
- ### Các Tùy Chọn Toàn Cục
184
-
185
- | Tùy Chọn | Mô Tả | Mặc Định |
186
- |----------|--------|----------|
187
- | `--env` | Môi trường (dev\|test\|prod-cn\|prod-jp) | `dev` |
188
- | `--tenant` | Tên tenant | - |
189
- | `--json` | Đầu ra JSON | `false` |
190
- | `--dry-run` | Chế độ xem trước (khuyến nghị cho AI) | `false` |
191
- | `--force` | Bỏ qua xác nhận | `false` |
192
- | `--page` | Số trang | `1` |
193
- | `--size` | Kích thước trang (tối đa) | `20` |
194
-
195
- ### Tham Khảo Nhanh
196
-
197
- | Lệnh | Mô Tả |
198
- |------|--------|
199
- | `barista context show` | Hiển thị context env/tenant hiện tại |
200
- | `barista context use-env <env>` | Chuyển đổi môi trường |
201
- | `barista liberica orders list --json` | Liệt kê đơn hàng (định dạng AI) |
202
- | `barista liberica orders get <id> --json` | Xem chi tiết đơn hàng |
203
- | `barista liberica orders create --dry-run ...` | Xem trước tạo mới |
204
- | `barista liberica products search --keyword <kw> --json` | Tìm kiếm sản phẩm |
205
- | `barista arabica plans list --json` | Liệt kê gói đăng ký |
206
- | `barista arabica invoices list --json` | Liệt kê hóa đơn |
207
-
208
- **[→ Tham Khảo Lệnh Chi Tiết](./docs/commands/REFERENCE.md)**
209
-
210
- ---
211
-
212
- ## 🛡️ Hướng Dẫn An Toàn AI
213
-
214
- ### 1. Luôn Chạy Dry-Run Trước
215
-
216
- ```typescript
217
- // ❌ Sai — Thực thi mù quáng
218
- await $`barista liberica orders cancel 12345`
219
-
220
- // ✅ Đúng — Xem trước trước
221
- const preview = await $`barista liberica orders cancel 12345 --dry-run`
222
- // Phân tích preview, xác minh, rồi:
223
- await $`barista liberica orders cancel 12345 --force`
224
- ```
225
-
226
- ### 2. Kiểm Tra Success Trước Khi Tiếp Tục
227
-
228
- ```typescript
229
- const result = JSON.parse(stdout)
230
- if (!result.success) {
231
- // Xử lý lỗi, không tiếp tục
232
- throw new Error(result.error?.message || result.meta?.message)
233
- }
234
- ```
235
-
236
- ### 3. Sử Dụng Request ID Để Debug
237
-
238
- ```typescript
239
- const { meta } = JSON.parse(stdout)
240
- console.log(`Request ID: ${meta.requestId}`)
241
- ```
242
-
243
- ### 4. Tuân Thủ Rate Limits
244
-
245
- - Thêm độ trễ giữa các thao tác hàng loạt
246
- - Sử dụng `--size 100` cho fetch hàng loạt
247
- - Cache responses khi phù hợp
248
-
249
- ---
250
-
251
- ## ⚙️ Cấu Hình
252
-
253
- ### Vị Trí File
254
-
255
- `~/.barista/config.yaml`
256
-
257
- ### Cấu Hình Nhanh
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
- ### Xác Thực
276
-
277
- ```bash
278
- # Đăng nhập bằng credentials (khuyến nghị)
279
- barista liberica auth login <env> <tenant> <username> <password>
280
-
281
- # Kiểm tra trạng thái đăng nhập
282
- barista auth status
283
-
284
- # Đăng xuất
285
- barista auth logout --service liberica --env prod-cn
286
- ```
287
-
288
- ---
289
-
290
- ## ❓ Xử Lý Sự Cố
291
-
292
- ### Lỗi Xác Thực
293
-
294
- ```bash
295
- # Kiểm tra trạng thái hiện tại
296
- barista auth status
297
-
298
- # Đăng nhập lại
299
- barista liberica auth login prod-cn your-tenant your-username your-password
300
-
301
- # Kiểm tra context
302
- barista context show
303
- ```
304
-
305
- ### Lỗi API
306
-
307
- ```bash
308
- # Luôn sử dụng --json để nhận mã lỗi
309
- barista liberica orders list --json
310
-
311
- # Phản hồi lỗi bao gồm requestId để debug
312
- # "requestId": "req-abc123"
313
- ```
314
-
315
- ### Vấn Đề Timeout
316
-
317
- ```bash
318
- # Chuyển sang môi trường gần hơn
319
- barista context use-env dev
320
-
321
- # Hoặc điều chỉnh timeout trong config.yaml
322
- ```
323
-
324
- ---
325
-
326
- ## 📚 Các Dự Án Liên Quan
327
-
328
- | Dự Án | Mô Tả |
329
- |--------|--------|
330
- | ☕ Liberica Backend | SaaS backend quản lý sản xuất |
331
- | 🖥️ Liberica Frontend | Web UI quản lý sản xuất |
332
- | 📱 Liberica Mobile | Ứng dụng di động quản lý sản xuất |
333
- | 🛒 Arabica Backend | SaaS backend đăng ký trực tuyến |
334
- | 🌐 Arabica Frontend | Web UI đăng ký trực tuyến |
335
-
336
- ---
337
-
338
- ## 📄 Giấy Phép
339
-
340
- [MIT](LICENSE) © Newpeak Technology
1
+ # ☕ Barista CLI
2
+
3
+ > **Để AI assistants điều khiển hệ thống quản lý sản xuất** — Kết nối AI tools (Claude Code, OpenCode, OpenClaw) với SaaS doanh nghiệp
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@newpeak/barista-cli.svg?style=flat-square)](https://www.npmjs.com/package/@newpeak/barista-cli)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](LICENSE)
7
+ [![Weekly Downloads](https://img.shields.io/npm/dw/@newpeak/barista-cli?style=flat-square)](https://www.npmjs.com/package/@newpeak/barista-cli)
8
+ [![Node.js](https://img.shields.io/badge/Node.js-18%2B-brightgreen?style=flat-square)](https://nodejs.org/)
9
+
10
+ ---
11
+
12
+ ## ⚡ Khởi Đầu Nhanh
13
+
14
+ ### 1. Cài Đặt
15
+
16
+ ```bash
17
+ npm install -g @newpeak/barista-cli
18
+ ```
19
+
20
+ ### 2. Xác Thực
21
+
22
+ ```bash
23
+ # AI cần credentials để hoạt động thay mặt người dùng
24
+ barista liberica auth login prod-cn your-tenant your-username your-password
25
+
26
+ # Đăng nhập tương tác (nhắc nhập thông tin còn thiếu)
27
+ barista liberica auth login
28
+ ```
29
+
30
+ ### 3. Tích Hợp AI
31
+
32
+ ```typescript
33
+ // Trong 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 phân tích và xử lý dữ liệu
38
+ if (data.items.length > 0) {
39
+ console.log(`Found ${data.pagination.total} orders`)
40
+ }
41
+ ```
42
+
43
+ **[Xem ví dụ tích hợp AI →](#ai-integration)**
44
+
45
+ ---
46
+
47
+ ## 🤖 Tích Hợp AI
48
+
49
+ Barista CLI được thiết kế cho AI coding assistants. Mọi đầu ra đều có cấu trúc, mọi lỗi đều có thể xử lý.
50
+
51
+ ### Các AI Tools Được Hỗ Trợ
52
+
53
+ | AI Tool | Phương Thức Tích Hợp | Trạng Thái |
54
+ |---------|----------------------|------------|
55
+ | **Claude Code** | `$` backticks + `--json` | ✅ Đã xác minh |
56
+ | **OpenCode** | Shell command + JSON parse | ✅ Đã xác minh |
57
+ | **OpenClaw** | Shell command + JSON parse | ✅ Đã xác minh |
58
+ | **Cursor** | Terminal integration | ✅ Tương thích |
59
+ | **Continue** | CLI subprocess | ✅ Tương thích |
60
+
61
+ ### Mẫu Tích Hợp
62
+
63
+ ```typescript
64
+ // 1. Thực thi lệnh với đầu ra JSON
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. Phân tích phản hồi có cấu trúc
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. Xử lý dữ liệu
81
+ const pendingOrders = data.items
82
+ console.log(`Found ${data.pagination.total} pending orders`)
83
+
84
+ // 4. Thực thi thao tác an toàn
85
+ for (const order of pendingOrders) {
86
+ // Luôn chạy dry-run trước (an toàn cho AI)
87
+ const preview = await $`barista liberica orders cancel ${order.id} --dry-run`
88
+
89
+ // Phân tích preview, xác minh, rồi thực thi với --force
90
+ // ...
91
+ }
92
+ ```
93
+
94
+ ### Response Envelope
95
+
96
+ Tất cả phản hồi JSON đều theo cấu trúc này:
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
+ **Định dạng lỗi:**
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 cho Claude Code
131
+
132
+ Cài đặt các file skill có thể tái sử dụng:
133
+
134
+ ```bash
135
+ # Skills nằm tại ~/.barista/claude/skills/
136
+ barista skills install
137
+ ```
138
+
139
+ **Các skills có sẵn:**
140
+ - `orders.md` — Quy trình quản lý đơn hàng
141
+ - `products.md` — Tìm kiếm và đồng bộ sản phẩm
142
+ - `warehouses.md` — Thao tác kho hàng
143
+ - `subscriptions.md` — Quản lý đăng ký Arabica
144
+
145
+ ---
146
+
147
+ ## 🚀 Tính Năng
148
+
149
+ ### Thiết Kế AI-First
150
+
151
+ | Tính Năng | Mô Tả |
152
+ |-----------|--------|
153
+ | 🤖 **JSON-First Output** | Tất cả lệnh hỗ trợ `--json` để AI phân tích |
154
+ | 📦 **Structured Responses** | Cấu trúc nhất quán `{success, data, meta}` |
155
+ | 🔄 **Idempotent Operations** | An toàn cho AI retry loops |
156
+ | 🛡️ **Dry-Run by Default** | Xem trước các thao tác nguy hiểm trước khi thực thi |
157
+ | 🔐 **Secure Storage** | Credentials lưu trong system keychain, không phải env vars |
158
+
159
+ ### Kết Nối Doanh Nghiệp
160
+
161
+ | Dịch Vụ | Khả Năng |
162
+ |---------|----------|
163
+ | ☕ **Liberica** | Đơn hàng, sản phẩm, tồn kho, kho hàng, lập kế hoạch sản xuất |
164
+ | 🛒 **Arabica** | Gói đăng ký, thanh toán, hóa đơn, quản lý doanh nghiệp |
165
+ | 🔗 **Cross-Service** | Báo giá từ đơn hàng, đồng bộ giữa các hệ thống |
166
+
167
+ ### An Toàn Vận Hành
168
+
169
+ - 📊 **Audit Trail** — Mỗi thao tác được ghi log với request ID
170
+ - ⚠️ **Confirmation Guards** — `--dry-run` / `--force` cho các thao tác ghi
171
+ - 🏢 **Multi-Tenant Isolation** — Credentials được cô lập theo từng tenant
172
+
173
+ ---
174
+
175
+ ## 🔧 Tham Khảo Lệnh
176
+
177
+ ### Mẫu Cơ Bản
178
+
179
+ ```
180
+ barista <service> <resource> <action> [options]
181
+ ```
182
+
183
+ ### Các Tùy Chọn Toàn Cục
184
+
185
+ | Tùy Chọn | Mô Tả | Mặc Định |
186
+ |----------|--------|----------|
187
+ | `--env` | Môi trường (dev\|test\|prod-cn\|prod-jp) | `dev` |
188
+ | `--tenant` | Tên tenant | - |
189
+ | `--json` | Đầu ra JSON | `false` |
190
+ | `--dry-run` | Chế độ xem trước (khuyến nghị cho AI) | `false` |
191
+ | `--force` | Bỏ qua xác nhận | `false` |
192
+ | `--page` | Số trang | `1` |
193
+ | `--size` | Kích thước trang (tối đa) | `20` |
194
+
195
+ ### Tham Khảo Nhanh
196
+
197
+ | Lệnh | Mô Tả |
198
+ |------|--------|
199
+ | `barista context show` | Hiển thị context env/tenant hiện tại |
200
+ | `barista context use-env <env>` | Chuyển đổi môi trường |
201
+ | `barista liberica orders list --json` | Liệt kê đơn hàng (định dạng AI) |
202
+ | `barista liberica orders get <id> --json` | Xem chi tiết đơn hàng |
203
+ | `barista liberica orders create --dry-run ...` | Xem trước tạo mới |
204
+ | `barista liberica products search --keyword <kw> --json` | Tìm kiếm sản phẩm |
205
+ | `barista arabica plans list --json` | Liệt kê gói đăng ký |
206
+ | `barista arabica invoices list --json` | Liệt kê hóa đơn |
207
+
208
+ **[→ Tham Khảo Lệnh Chi Tiết](./docs/commands/REFERENCE.md)**
209
+
210
+ ---
211
+
212
+ ## 🛡️ Hướng Dẫn An Toàn AI
213
+
214
+ ### 1. Luôn Chạy Dry-Run Trước
215
+
216
+ ```typescript
217
+ // ❌ Sai — Thực thi mù quáng
218
+ await $`barista liberica orders cancel 12345`
219
+
220
+ // ✅ Đúng — Xem trước trước
221
+ const preview = await $`barista liberica orders cancel 12345 --dry-run`
222
+ // Phân tích preview, xác minh, rồi:
223
+ await $`barista liberica orders cancel 12345 --force`
224
+ ```
225
+
226
+ ### 2. Kiểm Tra Success Trước Khi Tiếp Tục
227
+
228
+ ```typescript
229
+ const result = JSON.parse(stdout)
230
+ if (!result.success) {
231
+ // Xử lý lỗi, không tiếp tục
232
+ throw new Error(result.error?.message || result.meta?.message)
233
+ }
234
+ ```
235
+
236
+ ### 3. Sử Dụng Request ID Để Debug
237
+
238
+ ```typescript
239
+ const { meta } = JSON.parse(stdout)
240
+ console.log(`Request ID: ${meta.requestId}`)
241
+ ```
242
+
243
+ ### 4. Tuân Thủ Rate Limits
244
+
245
+ - Thêm độ trễ giữa các thao tác hàng loạt
246
+ - Sử dụng `--size 100` cho fetch hàng loạt
247
+ - Cache responses khi phù hợp
248
+
249
+ ---
250
+
251
+ ## ⚙️ Cấu Hình
252
+
253
+ ### Vị Trí File
254
+
255
+ `~/.barista/config.yaml`
256
+
257
+ ### Cấu Hình Nhanh
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
+ ### Xác Thực
276
+
277
+ ```bash
278
+ # Đăng nhập bằng credentials (khuyến nghị)
279
+ barista liberica auth login <env> <tenant> <username> <password>
280
+
281
+ # Kiểm tra trạng thái đăng nhập
282
+ barista auth status
283
+
284
+ # Đăng xuất
285
+ barista auth logout --service liberica --env prod-cn
286
+ ```
287
+
288
+ ---
289
+
290
+ ## ❓ Xử Lý Sự Cố
291
+
292
+ ### Lỗi Xác Thực
293
+
294
+ ```bash
295
+ # Kiểm tra trạng thái hiện tại
296
+ barista auth status
297
+
298
+ # Đăng nhập lại
299
+ barista liberica auth login prod-cn your-tenant your-username your-password
300
+
301
+ # Kiểm tra context
302
+ barista context show
303
+ ```
304
+
305
+ ### Lỗi API
306
+
307
+ ```bash
308
+ # Luôn sử dụng --json để nhận mã lỗi
309
+ barista liberica orders list --json
310
+
311
+ # Phản hồi lỗi bao gồm requestId để debug
312
+ # "requestId": "req-abc123"
313
+ ```
314
+
315
+ ### Vấn Đề Timeout
316
+
317
+ ```bash
318
+ # Chuyển sang môi trường gần hơn
319
+ barista context use-env dev
320
+
321
+ # Hoặc điều chỉnh timeout trong config.yaml
322
+ ```
323
+
324
+ ---
325
+
326
+ ## 📚 Các Dự Án Liên Quan
327
+
328
+ | Dự Án | Mô Tả |
329
+ |--------|--------|
330
+ | ☕ Liberica Backend | SaaS backend quản lý sản xuất |
331
+ | 🖥️ Liberica Frontend | Web UI quản lý sản xuất |
332
+ | 📱 Liberica Mobile | Ứng dụng di động quản lý sản xuất |
333
+ | 🛒 Arabica Backend | SaaS backend đăng ký trực tuyến |
334
+ | 🌐 Arabica Frontend | Web UI đăng ký trực tuyến |
335
+
336
+ ---
337
+
338
+ ## 📄 Giấy Phép
339
+
340
+ [MIT](LICENSE) © Newpeak Technology