cbs-4px-merchant-cli 0.0.7 → 0.0.8

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 (65) hide show
  1. package/README.4px.md +38 -5
  2. package/README.cainiao.md +38 -5
  3. package/README.md +38 -5
  4. package/dist/cli.js +242 -1
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/address.js +6 -26
  7. package/dist/commands/address.js.map +1 -1
  8. package/dist/commands/claim.js +14 -34
  9. package/dist/commands/claim.js.map +1 -1
  10. package/dist/commands/config.js +222 -0
  11. package/dist/commands/config.js.map +1 -1
  12. package/dist/commands/country.js +6 -26
  13. package/dist/commands/country.js.map +1 -1
  14. package/dist/commands/customs.js +17 -65
  15. package/dist/commands/customs.js.map +1 -1
  16. package/dist/commands/finance.js +56 -204
  17. package/dist/commands/finance.js.map +1 -1
  18. package/dist/commands/label.js +6 -26
  19. package/dist/commands/label.js.map +1 -1
  20. package/dist/commands/notice.js +22 -86
  21. package/dist/commands/notice.js.map +1 -1
  22. package/dist/commands/onboarding.d.ts +79 -0
  23. package/dist/commands/onboarding.js +384 -0
  24. package/dist/commands/onboarding.js.map +1 -0
  25. package/dist/commands/order.d.ts +26 -0
  26. package/dist/commands/order.js +254 -58
  27. package/dist/commands/order.js.map +1 -1
  28. package/dist/commands/pickup.js +29 -97
  29. package/dist/commands/pickup.js.map +1 -1
  30. package/dist/commands/platform.d.ts +26 -0
  31. package/dist/commands/platform.js +254 -0
  32. package/dist/commands/platform.js.map +1 -0
  33. package/dist/commands/problem.js +56 -170
  34. package/dist/commands/problem.js.map +1 -1
  35. package/dist/commands/product.js +52 -155
  36. package/dist/commands/product.js.map +1 -1
  37. package/dist/commands/service.js +64 -186
  38. package/dist/commands/service.js.map +1 -1
  39. package/dist/commands/skill.d.ts +1 -1
  40. package/dist/commands/skill.js +1 -1
  41. package/dist/commands/track.js +20 -74
  42. package/dist/commands/track.js.map +1 -1
  43. package/dist/commands/update.js +1 -1
  44. package/dist/digital-employee-skills/cbs-4px-merchant-cli-order-fulfillment.zip +0 -0
  45. package/dist/digital-employee-skills/cbs-cainiao-merchant-cli-order-fulfillment.zip +0 -0
  46. package/dist/index.js +0 -0
  47. package/dist/services/api-client.d.ts +38 -1
  48. package/dist/services/api-client.js +275 -9
  49. package/dist/services/api-client.js.map +1 -1
  50. package/dist/types/index.d.ts +294 -0
  51. package/dist/utils/confirm.d.ts +18 -0
  52. package/dist/utils/confirm.js +50 -0
  53. package/dist/utils/confirm.js.map +1 -0
  54. package/dist/utils/run-command.d.ts +24 -0
  55. package/dist/utils/run-command.js +58 -0
  56. package/dist/utils/run-command.js.map +1 -0
  57. package/package.json +2 -1
  58. package/scripts/postinstall.js +1 -1
  59. package/skill/SKILL.md +112 -4
  60. package/skill/package.json +3 -1
  61. package/skill/reference/index.md +30 -3
  62. package/skill/reference/onboarding.md +573 -0
  63. package/skill/reference/order.md +194 -0
  64. package/skill/reference/platform.md +317 -0
  65. package/skill/reference/update.md +1 -1
@@ -238,3 +238,197 @@ fmc order country 日本 --output json
238
238
  二字码 US
239
239
  三字码 USA
240
240
  ```
241
+
242
+ ---
243
+
244
+ ## 下单与订单写操作
245
+
246
+ ### 状态模型
247
+
248
+ ```
249
+ 草稿(D) ⇄ order edit
250
+ │
251
+ └─ order forecast ─→ 预报(P) ─→ 履约中
252
+ ├─ order cancel 取消
253
+ └─ order intercept 拦截申请
254
+ ```
255
+
256
+ `order create` 带 `--draft` 保存草稿;不带则直接预报。默认应先建草稿,回查给用户确认后再 `forecast`。预报后不能编辑,拦截也不保证成功。
257
+
258
+ ### 订单 JSON
259
+
260
+ `create` / `edit` 读取 JSON 文件(传 `--file -` 可从 stdin 读取),因为接口本身接收嵌套 JSON body:
261
+
262
+ | 字段 | 类型 | 必填 | 说明 |
263
+ | --- | --- | --- | --- |
264
+ | `productCode` | string | **yes** | 物流产品代码;先用 `product recommend/search` 选 |
265
+ | `destinationCountry` | string | **yes** | 目的国 ISO2,如 `US` |
266
+ | `originCountry` | string | no | 始发国 ISO2,如 `CN` |
267
+ | `status` | string | no | `P` 预报(默认)、`D` 草稿;`--draft` 自动设 D |
268
+ | `customerOrderNo` | string | no | 客户参考号,建议传店铺订单号 |
269
+ | `sender` | object | no | `name` `company` `phone` `address` `country` `postcode` `city` `province` |
270
+ | `receiver` | object | no | `name` `company` `phone` `mobile` `address` `city` `province` `postcode` `country` `email` |
271
+ | `parcel` | object | no | `weight`(kg) `length` `width` `height`(cm) `dutyPayMode` |
272
+ | `declareItems` | array | no | 每项含 `ename` `cname` `qty` `unitPrice` `currency` `weight` `hsCode` |
273
+
274
+ 完整示例 `order.json`:
275
+
276
+ ```json
277
+ {
278
+ "productCode": "A65",
279
+ "destinationCountry": "US",
280
+ "originCountry": "CN",
281
+ "customerOrderNo": "SHOP-20260831-001",
282
+ "sender": {
283
+ "name": "深圳仓",
284
+ "phone": "13800000000",
285
+ "address": "宝安区 xx 路 1 号",
286
+ "country": "CN",
287
+ "province": "广东",
288
+ "city": "深圳",
289
+ "postcode": "518000"
290
+ },
291
+ "receiver": {
292
+ "name": "John Doe",
293
+ "mobile": "+1 555 0100",
294
+ "address": "123 Main St",
295
+ "city": "Portland",
296
+ "province": "OR",
297
+ "postcode": "97201",
298
+ "country": "US",
299
+ "email": "john@example.com"
300
+ },
301
+ "parcel": {
302
+ "weight": 1.2,
303
+ "length": 20,
304
+ "width": 15,
305
+ "height": 10,
306
+ "dutyPayMode": "DDU"
307
+ },
308
+ "declareItems": [
309
+ {
310
+ "ename": "Bluetooth Speaker",
311
+ "cname": "蓝牙音箱",
312
+ "qty": 2,
313
+ "unitPrice": 15.5,
314
+ "currency": "USD",
315
+ "weight": 0.5,
316
+ "hsCode": "8518220000"
317
+ }
318
+ ]
319
+ }
320
+ ```
321
+
322
+ 后端只硬校验 `productCode` 和 `destinationCountry`。CLI 还会对收件人姓名/地址/国家/邮编/电话、发件人、重量、申报品英文名/数量/单价缺失打印 `⚠`。有告警先补齐,不要直接提交。
323
+
324
+ ### `fmc order create`
325
+
326
+ 创建物流订单(写操作):
327
+
328
+ ```bash
329
+ # 推荐:先建草稿
330
+ fmc order create --file ./order.json --draft -y
331
+
332
+ # 只预览 JSON 请求,不发送
333
+ fmc order create --file ./order.json --draft --dry-run
334
+
335
+ # 从 stdin 读取
336
+ cat order.json | fmc order create --file - --draft -y
337
+
338
+ # 用户明确要求直接下单时,才省略 --draft
339
+ fmc order create --file ./order.json -y
340
+ ```
341
+
342
+ | Flag | Required | Description |
343
+ | --- | --- | --- |
344
+ | `--file <path>` | yes | JSON 文件路径;`-` 表示 stdin |
345
+ | `--draft` | no | 保存草稿,不直接预报 |
346
+ | `-y, --yes` | non-TTY yes | 跳过终端交互确认 |
347
+
348
+ 返回 `orderId`、物流单号、状态和客户单号。草稿确认无误后用 `forecast`。
349
+
350
+ ### `fmc order edit`
351
+
352
+ 只可编辑草稿或已取消订单。JSON 只传要改的字段;`sender` / `receiver` / `parcel` 内部也按非空字段覆盖,`declareItems` 一旦传入则整组替换。
353
+
354
+ ```bash
355
+ # 改后保持草稿
356
+ fmc order edit --order-id 1001 --file ./patch.json --draft -y
357
+
358
+ # 改完直接预报
359
+ fmc order edit --order-id 1001 --file ./patch.json -y
360
+ ```
361
+
362
+ | Flag | Required | Description |
363
+ | --- | --- | --- |
364
+ | `--order-id <id>` | yes | 订单 ID(数字) |
365
+ | `--file <path>` | yes | JSON 文件路径;`-` 表示 stdin |
366
+ | `--draft` | no | 保持草稿;不传则改完预报 |
367
+ | `-y, --yes` | non-TTY yes | 跳过终端交互确认 |
368
+
369
+ ### `fmc order forecast`
370
+
371
+ 将草稿提交为预报(写操作):
372
+
373
+ ```bash
374
+ fmc order forecast --ids 1001 -y
375
+ fmc order forecast --ids 1001,1002 -y
376
+ ```
377
+
378
+ | Flag | Required | Description |
379
+ | --- | --- | --- |
380
+ | `--ids <ids>` | yes | 草稿订单 ID,多个逗号分隔 |
381
+ | `-y, --yes` | non-TTY yes | 跳过终端交互确认 |
382
+
383
+ 批量预报可能部分成功。失败数大于 0 时应按 `failDetails` 逐单处理,不要整批重试。
384
+
385
+ ### `fmc order cancel`
386
+
387
+ 取消草稿或已预报订单(写操作):
388
+
389
+ ```bash
390
+ fmc order cancel --ids 1001 --reason "客户取消" -y
391
+ ```
392
+
393
+ | Flag | Required | Description |
394
+ | --- | --- | --- |
395
+ | `--ids <ids>` | yes | 订单 ID,多个逗号分隔 |
396
+ | `--reason <text>` | yes | 取消原因,优先使用用户原话 |
397
+ | `-y, --yes` | non-TTY yes | 跳过终端交互确认 |
398
+
399
+ ### `fmc order intercept`
400
+
401
+ 对已预报订单申请拦截(写操作):
402
+
403
+ ```bash
404
+ fmc order intercept --ids 1001 -y
405
+ ```
406
+
407
+ | Flag | Required | Description |
408
+ | --- | --- | --- |
409
+ | `--ids <ids>` | yes | 订单 ID,多个逗号分隔 |
410
+ | `-y, --yes` | non-TTY yes | 跳过终端交互确认 |
411
+
412
+ 拦截是申请制,不保证成功;已出库或已交接承运商的包裹可能拦不住,必须按每个订单的返回明细告知用户。
413
+
414
+ ### 完整下单流程
415
+
416
+ ```bash
417
+ # 1. 选产品并确认目的国
418
+ fmc product recommend --country US --weight 1.2
419
+ fmc order country 美国
420
+
421
+ # 2. 从地址簿取发件人,不要编造
422
+ fmc order address-book
423
+
424
+ # 3. 查 HS 编码并组织 order.json
425
+ fmc customs hscode search --name 蓝牙音箱
426
+
427
+ # 4. 建草稿,回查给用户核对
428
+ fmc order create --file ./order.json --draft -y
429
+ fmc order get FPX12345678
430
+
431
+ # 5. 用户确认后提交预报、取面单
432
+ fmc order forecast --ids 1001 -y
433
+ fmc label get FPX12345678
434
+ ```
@@ -0,0 +1,317 @@
1
+ # `fmc platform` command
2
+
3
+ 平台拉单:把电商平台(如 Amazon)的卖家账号订单同步到 BPortal,再推送给物流服务商履约。
4
+
5
+ 典型链路:
6
+
7
+ ```
8
+ account list → sync → sync-record list(轮询) → order list → order push
9
+ ```
10
+
11
+ > `platform sync` 与 `platform order push` 是**写操作**,默认会在终端二次确认。
12
+ > 非交互环境(管道、CI、AI Agent)必须显式加 `-y`,否则命令会拒绝执行并以退出码 1 结束。
13
+ > 想先看请求内容而不真正发送,用 `--dry-run`。
14
+
15
+ ## Command details
16
+
17
+ ### `fmc platform account list`
18
+
19
+ | Field | Value |
20
+ | --- | --- |
21
+ | **Name** | `platform account list` |
22
+ | **Description** | 查询已授权的卖家账号列表 |
23
+ | **Usage** | `fmc platform account list [flags]` |
24
+
25
+ 需要 API Key 认证。拉单前先用它拿到 `--seller-account-id`。
26
+
27
+ #### Options
28
+
29
+ | Flag | Type | Required | Description |
30
+ | --- | --- | --- | --- |
31
+ | `--page <num>` | number | no | 页码,默认 1 |
32
+ | `--size <num>` | number | no | 每页数量,默认 10,最大 100 |
33
+
34
+ 支持全局选项: `--output`, `--verbose`, `--dry-run`
35
+
36
+ #### Examples
37
+
38
+ ```bash
39
+ fmc platform account list
40
+ ```
41
+
42
+ ```bash
43
+ fmc platform account list --page 2 --size 20 --output json
44
+ ```
45
+
46
+ #### Output (text mode)
47
+
48
+ ```
49
+ 卖家账号列表
50
+ ────────────────────────────────────────────────────────────
51
+
52
+ 10086
53
+ 账号名称 my-amazon-store
54
+ 平台 AMAZON
55
+ 站点 US
56
+ 商户ID A1BCDEFGHIJKLM
57
+ 状态 已授权
58
+
59
+ 共 1 个账号
60
+ ```
61
+
62
+ ---
63
+
64
+ ### `fmc platform sync`
65
+
66
+ | Field | Value |
67
+ | --- | --- |
68
+ | **Name** | `platform sync` |
69
+ | **Description** | 从卖家账号拉取平台订单(异步写操作) |
70
+ | **Usage** | `fmc platform sync --seller-account-id <id> --time-from <time> --time-to <time> [flags]` |
71
+
72
+ 需要 API Key 认证。**写操作**,默认二次确认。
73
+
74
+ 拉单是异步的:接口只回执"任务已提交",实际拉到多少单要用 `platform sync-record list` 轮询。
75
+
76
+ #### Options
77
+
78
+ | Flag | Type | Required | Description |
79
+ | --- | --- | --- | --- |
80
+ | `--seller-account-id <id>` | string | yes | 卖家账号 ID(从 `platform account list` 获取) |
81
+ | `--time-from <time>` | string | yes | 订单起始时间 `yyyy-MM-dd HH:mm:ss` |
82
+ | `--time-to <time>` | string | yes | 订单截止时间 `yyyy-MM-dd HH:mm:ss` |
83
+ | `-y, --yes` | boolean | no | 跳过交互确认(非交互环境必传) |
84
+
85
+ 支持全局选项: `--output`, `--verbose`, `--dry-run`
86
+
87
+ #### Examples
88
+
89
+ ```bash
90
+ fmc platform sync --seller-account-id 10086 \
91
+ --time-from "2026-08-01 00:00:00" --time-to "2026-08-31 23:59:59"
92
+ ```
93
+
94
+ ```bash
95
+ # 脚本 / AI Agent 场景
96
+ fmc platform sync --seller-account-id 10086 \
97
+ --time-from "2026-08-01 00:00:00" --time-to "2026-08-31 23:59:59" -y --output json
98
+ ```
99
+
100
+ ```bash
101
+ # 只看会发出什么请求
102
+ fmc platform sync --seller-account-id 10086 \
103
+ --time-from "2026-08-01 00:00:00" --time-to "2026-08-31 23:59:59" --dry-run
104
+ ```
105
+
106
+ #### Output (text mode)
107
+
108
+ ```
109
+ ✔ 拉单任务已提交
110
+
111
+ 拉单为异步执行,请用 sync-record list 轮询结果
112
+ ```
113
+
114
+ ---
115
+
116
+ ### `fmc platform sync-record list`
117
+
118
+ | Field | Value |
119
+ | --- | --- |
120
+ | **Name** | `platform sync-record list` |
121
+ | **Description** | 查询平台订单拉取/同步记录 |
122
+ | **Usage** | `fmc platform sync-record list [flags]` |
123
+
124
+ 需要 API Key 认证。`platform sync` 的结果只在这里可见。
125
+
126
+ #### Options
127
+
128
+ | Flag | Type | Required | Description |
129
+ | --- | --- | --- | --- |
130
+ | `--page <num>` | number | no | 页码,默认 1 |
131
+ | `--size <num>` | number | no | 每页数量,默认 10,最大 100 |
132
+
133
+ 支持全局选项: `--output`, `--verbose`, `--dry-run`
134
+
135
+ #### Examples
136
+
137
+ ```bash
138
+ fmc platform sync-record list
139
+ ```
140
+
141
+ ```bash
142
+ fmc platform sync-record list --size 5 --output json
143
+ ```
144
+
145
+ #### Output (text mode)
146
+
147
+ ```
148
+ 拉单记录
149
+ ────────────────────────────────────────────────────────────
150
+
151
+ 9001
152
+ 卖家账号 my-amazon-store
153
+ 起始时间 2026-08-01 00:00:00
154
+ 截止时间 2026-08-31 23:59:59
155
+ 状态 已完成
156
+ 拉取总数 128
157
+ 实际入库 126
158
+
159
+ 共 1 条
160
+ ```
161
+
162
+ ---
163
+
164
+ ### `fmc platform order list`
165
+
166
+ | Field | Value |
167
+ | --- | --- |
168
+ | **Name** | `platform order list` |
169
+ | **Description** | 查询已拉取的平台订单列表 |
170
+ | **Usage** | `fmc platform order list [flags]` |
171
+
172
+ 需要 API Key 认证。
173
+
174
+ #### Options
175
+
176
+ | Flag | Type | Required | Description |
177
+ | --- | --- | --- | --- |
178
+ | `--status <code>` | string | no | 订单状态:`0` 待推送、`1` 已推送;不传查全部 |
179
+ | `--keyword <word>` | string | no | 关键字(平台订单号 / 客户订单号) |
180
+ | `--page <num>` | number | no | 页码,默认 1 |
181
+ | `--size <num>` | number | no | 每页数量,默认 10,最大 100 |
182
+
183
+ 支持全局选项: `--output`, `--verbose`, `--dry-run`
184
+
185
+ #### Examples
186
+
187
+ ```bash
188
+ # 待推送的订单
189
+ fmc platform order list --status 0
190
+ ```
191
+
192
+ ```bash
193
+ fmc platform order list --keyword 113-1234567-1234567
194
+ ```
195
+
196
+ #### Output (text mode)
197
+
198
+ ```
199
+ 平台订单列表
200
+ ────────────────────────────────────────────────────────────
201
+
202
+ [待推送] 20001
203
+ 平台单号 113-1234567-1234567
204
+ 客户单号 CO20260801001
205
+ 卖家账号 my-amazon-store
206
+ 收件人 John Smith
207
+ 目的国家 美国
208
+ 产品 美国专线
209
+ 金额 29.99 USD
210
+ 创建时间 2026-08-01 10:22:31
211
+
212
+ 共 1 条
213
+ ```
214
+
215
+ ---
216
+
217
+ ### `fmc platform order detail`
218
+
219
+ | Field | Value |
220
+ | --- | --- |
221
+ | **Name** | `platform order detail` |
222
+ | **Description** | 查询平台订单详情(含收件人、报关物品) |
223
+ | **Usage** | `fmc platform order detail <id> [flags]` |
224
+
225
+ 需要 API Key 认证。
226
+
227
+ #### Options
228
+
229
+ | Flag | Type | Required | Description |
230
+ | --- | --- | --- | --- |
231
+ | `<id>` | string | yes | 平台订单 ID(从 `platform order list` 获取) |
232
+
233
+ 支持全局选项: `--output`, `--verbose`, `--dry-run`
234
+
235
+ #### Examples
236
+
237
+ ```bash
238
+ fmc platform order detail 20001
239
+ ```
240
+
241
+ ```bash
242
+ fmc platform order detail 20001 --output json
243
+ ```
244
+
245
+ #### Output (text mode)
246
+
247
+ ```
248
+ 平台订单详情
249
+ ──────────────────────────────────────────────────
250
+ 订单ID 20001
251
+ 平台单号 113-1234567-1234567
252
+ 平台 AMAZON
253
+ 卖家账号 my-amazon-store
254
+ 推送状态 待推送
255
+
256
+ 收件信息
257
+ ────────────────────────────────────────
258
+ 收件人 John Smith
259
+ 国家 美国
260
+ 城市 Los Angeles
261
+ 邮编 90001
262
+
263
+ 物流与金额
264
+ ────────────────────────────────────────
265
+ 产品 美国专线
266
+ 订单金额 29.99 USD
267
+
268
+ 报关物品
269
+ ────────────────────────────────────────
270
+ Phone Case
271
+ SKU SKU001
272
+ 数量 2
273
+ 单价 14.99 USD
274
+ ```
275
+
276
+ ---
277
+
278
+ ### `fmc platform order push`
279
+
280
+ | Field | Value |
281
+ | --- | --- |
282
+ | **Name** | `platform order push` |
283
+ | **Description** | 将待推送的平台订单推送到物流服务商履约 |
284
+ | **Usage** | `fmc platform order push --ids <ids> [flags]` |
285
+
286
+ 需要 API Key 认证。**写操作**,默认二次确认。
287
+
288
+ 推送后订单进入履约流程,无法通过本 CLI 撤回;推送前建议先用 `platform order detail` 核对收件信息。
289
+
290
+ #### Options
291
+
292
+ | Flag | Type | Required | Description |
293
+ | --- | --- | --- | --- |
294
+ | `--ids <ids>` | string | yes | 平台订单 ID,多个用逗号分隔 |
295
+ | `-y, --yes` | boolean | no | 跳过交互确认(非交互环境必传) |
296
+
297
+ 支持全局选项: `--output`, `--verbose`, `--dry-run`
298
+
299
+ #### Examples
300
+
301
+ ```bash
302
+ fmc platform order push --ids 20001
303
+ ```
304
+
305
+ ```bash
306
+ fmc platform order push --ids 20001,20002,20003 -y
307
+ ```
308
+
309
+ ```bash
310
+ fmc platform order push --ids 20001 --dry-run
311
+ ```
312
+
313
+ #### Output (text mode)
314
+
315
+ ```
316
+ ✔ 已提交推送:1 个订单
317
+ ```
@@ -15,7 +15,7 @@ fmc skill install|status|uninstall [--agent <ids>] [--force] [--dry-run] [--outp
15
15
  完成后自动调用一次 `fmc skill install`,把新版 SKILL.md 同步到所有已检测到的
16
16
  AI 工具目录(`~/.qoder/skills/`、`~/.claude/skills/`、`~/.cursor/skills/` 等)。
17
17
 
18
- > **为何不靠 npm postinstall:**npm 11 默认拦截依赖包的安装期脚本,**且跳过时仍然退出 0**。
18
+ > **为何不靠 npm postinstall:**npm 12 默认拦截依赖包的安装期脚本,**且跳过时仍然退出 0**。
19
19
  > 所以 skill 铺设不能依赖生命周期钩子,`fmc skill install` 才是唯一可靠的入口;
20
20
  > postinstall 仅作为“能跑就顺便跑”的便利钩子保留。
21
21