1688-cli 0.1.41 → 0.1.42

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 (83) hide show
  1. package/AGENTS.md +112 -318
  2. package/ARCHITECTURE.md +106 -0
  3. package/README.md +100 -10
  4. package/dist/cli.js +98 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/cart-list.js +2 -1
  7. package/dist/commands/cart-list.js.map +1 -1
  8. package/dist/commands/compare.js +107 -0
  9. package/dist/commands/compare.js.map +1 -0
  10. package/dist/commands/doctor.js +19 -5
  11. package/dist/commands/doctor.js.map +1 -1
  12. package/dist/commands/offer.js +7 -5
  13. package/dist/commands/offer.js.map +1 -1
  14. package/dist/commands/order-list.js +4 -2
  15. package/dist/commands/order-list.js.map +1 -1
  16. package/dist/commands/order-logistics.js +4 -2
  17. package/dist/commands/order-logistics.js.map +1 -1
  18. package/dist/commands/research.js +142 -0
  19. package/dist/commands/research.js.map +1 -0
  20. package/dist/commands/search.js +59 -18
  21. package/dist/commands/search.js.map +1 -1
  22. package/dist/commands/seller-messages.js +7 -4
  23. package/dist/commands/seller-messages.js.map +1 -1
  24. package/dist/commands/sourcing-utils.js +438 -0
  25. package/dist/commands/sourcing-utils.js.map +1 -0
  26. package/dist/commands/supplier-inspect.js +559 -0
  27. package/dist/commands/supplier-inspect.js.map +1 -0
  28. package/dist/commands/supplier-search.js +522 -0
  29. package/dist/commands/supplier-search.js.map +1 -0
  30. package/dist/daemon/protocol.js +2 -1
  31. package/dist/daemon/protocol.js.map +1 -1
  32. package/dist/session/dispatch.js +2 -0
  33. package/dist/session/dispatch.js.map +1 -1
  34. package/dist/session/im-ws.js +8 -5
  35. package/dist/session/im-ws.js.map +1 -1
  36. package/dist/session/paths.js +17 -4
  37. package/dist/session/paths.js.map +1 -1
  38. package/dist/session/search-mtop.js +53 -0
  39. package/dist/session/search-mtop.js.map +1 -1
  40. package/dist/session/supplier-search.js +403 -0
  41. package/dist/session/supplier-search.js.map +1 -0
  42. package/dist/util/encoding.js +8 -0
  43. package/dist/util/encoding.js.map +1 -0
  44. package/dist/util/temp.js +6 -0
  45. package/dist/util/temp.js.map +1 -0
  46. package/docs/AGENT_MAPS_PLAN.md +171 -0
  47. package/docs/AGENT_WORKING_PRINCIPLES.md +143 -0
  48. package/docs/COMMANDS.md +199 -0
  49. package/docs/FEATURES.md +45 -0
  50. package/docs/JSON_CONTRACTS.md +390 -0
  51. package/docs/QUALITY_SCORE.md +60 -0
  52. package/docs/README.md +35 -0
  53. package/docs/RELIABILITY.md +61 -0
  54. package/docs/SAFETY.md +100 -0
  55. package/docs/WORKFLOW.md +82 -0
  56. package/docs/exec-plans/README.md +9 -0
  57. package/docs/exec-plans/active/README.md +4 -0
  58. package/docs/exec-plans/completed/2026-05-28-sourcing-research-v1.md +125 -0
  59. package/docs/exec-plans/completed/2026-05-31-supplier-inspect-v1.md +113 -0
  60. package/docs/exec-plans/completed/2026-06-04-supplier-search-v1.md +81 -0
  61. package/docs/exec-plans/completed/2026-06-07-windows-cli-compatibility.md +138 -0
  62. package/docs/exec-plans/completed/README.md +4 -0
  63. package/docs/exec-plans/tech-debt-tracker.md +5 -0
  64. package/docs/generated/command-index.md +54 -0
  65. package/docs/generated/json-shapes.md +111 -0
  66. package/docs/generated/module-map.md +13 -0
  67. package/docs/generated/test-index.md +34 -0
  68. package/docs/playbooks/add-command.md +15 -0
  69. package/docs/playbooks/add-mtop-capture.md +13 -0
  70. package/docs/playbooks/change-json-output.md +11 -0
  71. package/docs/playbooks/debug-risk-control.md +12 -0
  72. package/docs/playbooks/update-cli-release.md +11 -0
  73. package/docs/specs/checkout-and-orders.md +30 -0
  74. package/docs/specs/seller-im.md +28 -0
  75. package/docs/specs/sourcing-research.md +186 -0
  76. package/docs/specs/supplier-inspect.md +144 -0
  77. package/docs/specs/supplier-search.md +179 -0
  78. package/docs/specs/windows-cli-compatibility.md +123 -0
  79. package/package.json +12 -2
  80. package/scripts/check_agent_map.mjs +86 -0
  81. package/scripts/fix_bin_mode.mjs +18 -0
  82. package/scripts/generate_agent_context.mjs +253 -0
  83. package/scripts/postinstall.mjs +12 -4
@@ -0,0 +1,390 @@
1
+ # JSON Contracts
2
+
3
+ The CLI auto-switches to JSON when stdout is piped. Stable JSON output is part
4
+ of the agent contract. Prefer additive changes; do not rename or remove fields
5
+ without an explicit breaking-change decision.
6
+
7
+ ## Output Rules
8
+
9
+ - `--json` forces JSON in a TTY.
10
+ - `--pretty` indents JSON by two spaces.
11
+ - `--get <path>` prints one dot-path. Scalars are raw lines; objects and arrays
12
+ remain JSON.
13
+ - `--pick <paths>` emits a JSON object with each requested path as a key.
14
+ - Watch commands emit line-delimited JSON, one object per new event/message.
15
+
16
+ ## `whoami`
17
+
18
+ ```ts
19
+ { loggedIn: true, memberId: string, nick: string, lastVerifiedAt: string }
20
+ { loggedIn: false }
21
+ ```
22
+
23
+ ## `search`, `similar`, `image-search`
24
+
25
+ ```ts
26
+ {
27
+ keyword?: string,
28
+ imageId?: string,
29
+ offerId?: string,
30
+ sort?: "relevance" | "best-selling" | "price-asc" | "price-desc",
31
+ filters?: object,
32
+ totalBeforeFilter?: number,
33
+ total: number,
34
+ offers: Array<{
35
+ offerId: string,
36
+ title: string,
37
+ price: { text: string, min: number | null, max: number | null },
38
+ supplier: { name: string | null, shopUrl: string | null, years: number | null },
39
+ location: { province: string | null, city: string | null },
40
+ bizType: string | null,
41
+ verified: { factory: boolean, business: boolean, superFactory: boolean },
42
+ tags: string[],
43
+ serviceTags?: string[],
44
+ productBadges?: string[],
45
+ demand?: {
46
+ orderCountText: string | null,
47
+ orderCount: number | null,
48
+ repurchaseRateText: string | null,
49
+ repurchaseRate: number | null,
50
+ },
51
+ isP4P: boolean,
52
+ turnover: string | null,
53
+ url: string,
54
+ image: string | null,
55
+ }>
56
+ }
57
+ ```
58
+
59
+ ## `research`
60
+
61
+ Normal JSON result:
62
+
63
+ ```ts
64
+ {
65
+ queries: string[],
66
+ sort: "relevance" | "best-selling" | "price-asc" | "price-desc",
67
+ filters: object,
68
+ maxPerQuery: number,
69
+ enrichTop: number,
70
+ total: number,
71
+ enrichedCount: number,
72
+ items: Array<{
73
+ sourceKeyword: string,
74
+ sourceRank: number,
75
+ globalRank: number,
76
+ offer: Offer,
77
+ demand: {
78
+ turnoverText: string | null,
79
+ orderCount: number | null,
80
+ repurchaseRate: number | null,
81
+ },
82
+ supplier: {
83
+ years: number | null,
84
+ verified: Offer["verified"],
85
+ tags: string[],
86
+ isAd: boolean,
87
+ },
88
+ score: number,
89
+ scoreBreakdown: Array<{ name: string, points: number, reason: string }>,
90
+ enriched?: OfferDetailSummary,
91
+ error?: { code: string, message: string },
92
+ }>,
93
+ }
94
+ ```
95
+
96
+ `--jsonl` emits one research item per line. `--csv` emits a CSV table.
97
+
98
+ ## `compare`
99
+
100
+ ```ts
101
+ {
102
+ total: number,
103
+ ok: number,
104
+ failed: number,
105
+ items: Array<{
106
+ offerId: string,
107
+ ok: boolean,
108
+ score: number | null,
109
+ scoreBreakdown: Array<{ name: string, points: number, reason: string }>,
110
+ summary: OfferDetailSummary | null,
111
+ error?: { code: string, message: string },
112
+ }>,
113
+ }
114
+ ```
115
+
116
+ ## `supplier inspect`
117
+
118
+ ```ts
119
+ {
120
+ target: {
121
+ input: string,
122
+ type: "offerId" | "memberId",
123
+ offerId: string | null,
124
+ memberId: string | null,
125
+ },
126
+ supplier: {
127
+ name: string | null,
128
+ loginId: string | null,
129
+ memberId: string | null,
130
+ userId: string | null,
131
+ companyId: string | null,
132
+ shopUrl: string | null,
133
+ shopUrls: Record<string, string>,
134
+ identity: string | null,
135
+ signs: Record<string, boolean>,
136
+ },
137
+ factory: {
138
+ isFactory: boolean,
139
+ superFactory: boolean,
140
+ tpYears: number | null,
141
+ medalLevel: string | null,
142
+ thirdPartyAuthProvider: string | null,
143
+ establishedAtText: string | null,
144
+ location: string | null,
145
+ address: string | null,
146
+ coordinates: { latitude: number | null, longitude: number | null },
147
+ productionService: string | null,
148
+ employeeScale: string | null,
149
+ workerCount: string | null,
150
+ profile: string | null,
151
+ tags: string[],
152
+ },
153
+ trust: {
154
+ companyLabel: string | null,
155
+ retentionRate: number | null,
156
+ companyIcons: Array<{ title: string, link: string | null }>,
157
+ shopTags: string[],
158
+ serviceScores: Array<{ key: string, label: string, score: number | null }>,
159
+ },
160
+ offers: { availableCount: number | null, source: "factory-card-dom" | null },
161
+ sources: {
162
+ offerUrl: string | null,
163
+ factoryCardUrl: string | null,
164
+ shopcardCaptured: boolean,
165
+ factoryCardCaptured: boolean,
166
+ },
167
+ warnings: string[],
168
+ }
169
+ ```
170
+
171
+ V1 supports offerId, offer URL, `b2b-*` memberId, and factory-card URL.
172
+ loginId-only input is rejected because live probing showed it can resolve to
173
+ the wrong supplier.
174
+
175
+ ## `supplier search`, `supplier research`
176
+
177
+ Supplier discovery uses 1688 company search
178
+ (`companySearchBusinessService`). It must not be treated as offer-search
179
+ supplier aggregation.
180
+
181
+ ```ts
182
+ {
183
+ queries: string[],
184
+ source: {
185
+ kind: "company-search",
186
+ endpoint: "companySearchBusinessService",
187
+ offerAggregation: false,
188
+ },
189
+ filters: {
190
+ factoryOnly: boolean,
191
+ province: string | null,
192
+ city: string | null,
193
+ minYears: number | null,
194
+ minRepeatRate: number | null,
195
+ minResponseRate: number | null,
196
+ },
197
+ maxPerQuery: number,
198
+ enrichTop: number,
199
+ totalBeforeFilter: number,
200
+ total: number,
201
+ enrichedCount: number,
202
+ items: Array<{
203
+ sourceKeyword: string,
204
+ sourceRank: number,
205
+ globalRank: number,
206
+ supplier: {
207
+ companyName: string,
208
+ loginId: string | null,
209
+ memberId: string | null,
210
+ enterpriseId: string | null,
211
+ realUserId: string | null,
212
+ companyId: string | null,
213
+ shopUrl: string | null,
214
+ factoryCardUrl: string | null,
215
+ domainUri: string | null,
216
+ location: {
217
+ province: string | null,
218
+ city: string | null,
219
+ address: string | null,
220
+ latitude: number | null,
221
+ longitude: number | null,
222
+ },
223
+ productionService: string | null,
224
+ businessMode: string | null,
225
+ tp: {
226
+ memberLevel: string | null,
227
+ serviceYears: number | null,
228
+ tpNum: number | null,
229
+ },
230
+ factory: {
231
+ isFactory: boolean,
232
+ factoryTag: string | null,
233
+ factoryLevel: string | null,
234
+ shiliFactory: boolean,
235
+ shiliCompany: boolean,
236
+ superFactory: boolean,
237
+ businessInspection: boolean,
238
+ factoryInspection: boolean,
239
+ qiJianCompany: boolean,
240
+ safePurchase: boolean,
241
+ trust: boolean,
242
+ },
243
+ service: {
244
+ compositeScore: number | null,
245
+ wwResponseRate: number | null,
246
+ repeatRate: number | null,
247
+ complianceRate: number | null,
248
+ },
249
+ demand: {
250
+ payOrderCount3m: number | null,
251
+ payAmount3m: number | null,
252
+ fuzzyPayAmount3m: string | null,
253
+ saleQuantity3m: number | null,
254
+ memberBookedCount: number | null,
255
+ },
256
+ tags: string[],
257
+ offersPreview: Array<{
258
+ offerId: string | null,
259
+ title: string,
260
+ url: string | null,
261
+ price: { text: string | null, value: number | null },
262
+ unit: string | null,
263
+ image: string | null,
264
+ bookedCount: number | null,
265
+ saleQuantity: number | null,
266
+ quantitySumMonth: number | null,
267
+ brief: string | null,
268
+ }>,
269
+ },
270
+ score: number,
271
+ scoreBreakdown: Array<{ name: string, points: number, reason: string }>,
272
+ inspect?: SupplierInspectResult,
273
+ error?: { code: string, message: string },
274
+ }>,
275
+ }
276
+ ```
277
+
278
+ `supplier search` defaults to `--enrich 0`; `supplier research` defaults to
279
+ `--enrich top:10`. `--jsonl` emits one supplier item per line. `--csv` emits a
280
+ CSV table.
281
+
282
+ ## `offer`
283
+
284
+ ```ts
285
+ {
286
+ offerId: string,
287
+ title: string,
288
+ url: string,
289
+ priceRange: string | null,
290
+ priceMin: number | null,
291
+ priceMax: number | null,
292
+ unitName: string | null,
293
+ minOrderQty: number | null,
294
+ mixOrderQty: number | null,
295
+ priceTiers: Array<{ minQty: number, price: number }>,
296
+ detailUrl: string | null,
297
+ attributes: Array<{ name: string, value: string }>,
298
+ packageInfo: Array<{
299
+ skuId: string,
300
+ spec: string,
301
+ length: number | null,
302
+ width: number | null,
303
+ height: number | null,
304
+ weight: number | null,
305
+ volume: number | null,
306
+ }>,
307
+ supplier: {
308
+ name: string | null,
309
+ loginId: string | null,
310
+ memberId: string | null,
311
+ userId: string | null,
312
+ },
313
+ freight: {
314
+ receiveAddress: string | null,
315
+ sendArea: string | null,
316
+ province: string | null,
317
+ city: string | null,
318
+ unitWeight: number | null,
319
+ },
320
+ saledCount: number | null,
321
+ categoryId: string | null,
322
+ options: Array<{ prop: string, values: Array<{ name: string, imageUrl: string | null }> }>,
323
+ skus: Array<{
324
+ skuId: string,
325
+ specs: string,
326
+ price: number | null,
327
+ multiPrice: number | null,
328
+ stock: number | null,
329
+ saleCount: number,
330
+ image: string | null,
331
+ }>,
332
+ mainImage: string | null,
333
+ images: string[],
334
+ }
335
+ ```
336
+
337
+ ## `seller messages`
338
+
339
+ One-shot result:
340
+
341
+ ```ts
342
+ {
343
+ conversation: string,
344
+ total: number,
345
+ messages: Array<{
346
+ sender: string,
347
+ time: string | null,
348
+ isMine: boolean,
349
+ content: string,
350
+ read: boolean,
351
+ kind: "text" | "offerCard" | "orderCard" | "autoReply"
352
+ | "assessment" | "image" | "other",
353
+ card?: {
354
+ title: string | null,
355
+ price: string | null,
356
+ image: string | null,
357
+ url: string | null,
358
+ },
359
+ messageId?: string,
360
+ }>,
361
+ }
362
+ ```
363
+
364
+ Watch mode emits one object per new message:
365
+
366
+ ```ts
367
+ { conversation: string, message: Message }
368
+ ```
369
+
370
+ ## `cart add`
371
+
372
+ ```ts
373
+ {
374
+ ok: boolean,
375
+ added: CartItem,
376
+ isNewRow: boolean,
377
+ addedQuantity: number,
378
+ }
379
+ ```
380
+
381
+ ## `order list`
382
+
383
+ Orders include buyer actions, service entries, and display badges. Preserve
384
+ `actions[]`, `services[]`, and `badges[]` because downstream agents use them to
385
+ decide what follow-up is possible.
386
+
387
+ ## Generated Shape Index
388
+
389
+ Run `pnpm agent-context` to refresh `docs/generated/json-shapes.md`, which
390
+ indexes exported TypeScript interfaces from command modules.
@@ -0,0 +1,60 @@
1
+ # Quality Score
2
+
3
+ This file tracks agent-readiness and known quality gaps. Keep it blunt and
4
+ mechanical; it is a map for improvement, not a blame document.
5
+
6
+ ## Current Score
7
+
8
+ Overall: 6 / 10
9
+
10
+ ## Strengths
11
+
12
+ - Clear buyer-journey command surface exists: sourcing, inquiry, cart,
13
+ checkout, tracking, and post-sale chat.
14
+ - Commands expose JSON automatically when piped and support `--json`,
15
+ `--pretty`, `--get`, and `--pick`.
16
+ - Real browser/session behavior is centralized under `src/session`.
17
+ - The daemon gives agents a warm, shared browser context.
18
+ - Checkout and feedback write actions already have explicit safety protocols.
19
+ - Deterministic Vitest coverage exists for output, mtop parsing, recovery,
20
+ page-state, inbox cards, and fixtures through `pnpm test:unit`.
21
+ - Agent map docs and generated indexes now exist.
22
+
23
+ ## Gaps Blocking Higher Agent Autonomy
24
+
25
+ - `AGENTS.md` was historically long; future work should keep it short and keep
26
+ durable detail in `docs/`.
27
+ - Generated context is heuristic and should improve as command/result types
28
+ evolve.
29
+ - Browser/live verification is not part of the default gate and needs explicit
30
+ manual/probe checks.
31
+ - Sourcing research fields such as repurchase rate, supplier scores, and
32
+ service badges are not yet normalized.
33
+ - Some probe scripts are exploratory and not documented as stable workflows.
34
+ - JSON compatibility policy exists in docs but is not yet enforced by schema
35
+ tests.
36
+
37
+ ## Last Known Verification Snapshot
38
+
39
+ On 2026-05-28, `pnpm agent-verify` passed:
40
+
41
+ - `pnpm typecheck`
42
+ - `pnpm test:unit` (22 files, 151 tests)
43
+ - `pnpm docs-check`
44
+ - `pnpm agent-map-check`
45
+
46
+ On 2026-05-28, full `pnpm test` failed in `tests/doctor-live.test.ts` because
47
+ the live doctor checks returned `DOCTOR_FAILED` in the current local
48
+ environment. The default agent gate uses `pnpm test:unit` to keep live checks
49
+ explicit.
50
+
51
+ ## Quality Targets
52
+
53
+ - 6 / 10: short map, docs map, generated indexes, and default verification
54
+ gate exist.
55
+ - 7 / 10: JSON contract tests cover all stable command outputs and docs-check
56
+ runs in CI.
57
+ - 8 / 10: browser/live verification playbooks are repeatable and key mtop
58
+ payloads have fixture-backed parsers.
59
+ - 9 / 10: sourcing research scoring, supplier-quality extraction, and
60
+ autonomous inbox workflows have deterministic harness tests.
package/docs/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Documentation Map
2
+
3
+ This directory is the canonical knowledge base for agents and humans working on
4
+ `1688-cli`. Keep `AGENTS.md` short and put durable context here.
5
+
6
+ ## Start Here
7
+
8
+ - Agent working principles: [`AGENT_WORKING_PRINCIPLES.md`](AGENT_WORKING_PRINCIPLES.md)
9
+ - Repository architecture: [`../ARCHITECTURE.md`](../ARCHITECTURE.md)
10
+ - Default workflow: [`WORKFLOW.md`](WORKFLOW.md)
11
+ - Command catalog: [`COMMANDS.md`](COMMANDS.md)
12
+ - JSON contracts: [`JSON_CONTRACTS.md`](JSON_CONTRACTS.md)
13
+ - Safety rules: [`SAFETY.md`](SAFETY.md)
14
+ - Reliability notes: [`RELIABILITY.md`](RELIABILITY.md)
15
+ - Quality score: [`QUALITY_SCORE.md`](QUALITY_SCORE.md)
16
+ - Feature backlog: [`FEATURES.md`](FEATURES.md)
17
+ - Agent maps plan: [`AGENT_MAPS_PLAN.md`](AGENT_MAPS_PLAN.md)
18
+
19
+ ## Domain Knowledge
20
+
21
+ - Specs: [`specs/`](specs/)
22
+ - Repeatable playbooks: [`playbooks/`](playbooks/)
23
+ - Generated repository indexes: [`generated/`](generated/)
24
+ - Long-running plans: [`exec-plans/`](exec-plans/)
25
+
26
+ ## Maintenance Rules
27
+
28
+ - Update command docs when command names, flags, behavior, or examples change.
29
+ - Update JSON contracts when agent-facing output shape changes.
30
+ - Update safety docs when a write action, approval boundary, login flow, or
31
+ checkout behavior changes.
32
+ - Add or update a playbook when an agent repeats the same workflow twice.
33
+ - Run `pnpm agent-context` after changing commands, exported result
34
+ interfaces, source layout, or tests.
35
+ - Run `pnpm agent-verify` before handoff, or record the exact blocker.
@@ -0,0 +1,61 @@
1
+ # Reliability
2
+
3
+ `1688-cli` depends on a live website, browser automation, mtop responses, and a
4
+ real logged-in buyer session. Reliability work should make failures explicit
5
+ and recoverable for agents.
6
+
7
+ ## Daemon
8
+
9
+ The daemon routes commands through one persistent Chromium context.
10
+
11
+ Benefits:
12
+
13
+ - Saves Chrome cold-start time.
14
+ - Keeps one continuous logged-in session.
15
+ - Adds inter-command jitter.
16
+
17
+ Use `1688 daemon start` near the beginning of a session with multiple 1688
18
+ commands. The daemon auto-stops after inactivity. Run `1688 daemon reload`
19
+ after package updates.
20
+
21
+ `login`, `logout`, and `doctor` stay inline because they need interactive UI,
22
+ browser windows, or environment checks.
23
+
24
+ ## Watch Mode
25
+
26
+ `1688 seller messages ... --watch` is designed to stay alive.
27
+
28
+ - It prints a baseline line to stderr.
29
+ - It emits one JSON object to stdout for each newly-arrived message.
30
+ - History is not re-emitted.
31
+ - Deduplication uses server-side `messageId` when present.
32
+ - It exits cleanly on SIGINT.
33
+
34
+ Agent loops should parse stdout line by line and should not assume the process
35
+ will exit by itself.
36
+
37
+ ## Browser Recovery
38
+
39
+ Commands should detect and report:
40
+
41
+ - login redirects
42
+ - risk-control / slider pages
43
+ - closed browser windows
44
+ - empty mtop captures
45
+ - network failures
46
+
47
+ Use structured `CliError` exit codes so agents can choose the next safe step.
48
+
49
+ ## Probes And Fixtures
50
+
51
+ Probe scripts under `scripts/probe-*.mjs` are useful for discovering page
52
+ behavior, selectors, and mtop payloads. They are not stable automated tests.
53
+
54
+ Stable behavior belongs in `tests/` with fixtures where possible.
55
+
56
+ ## Live-Service Boundaries
57
+
58
+ `pnpm test:unit` is the deterministic default. `pnpm test` also runs live
59
+ doctor checks and may depend on local browser/session state. Browser or
60
+ account-mutating checks should be explicit, bounded, and documented in the
61
+ final response when they cannot be run.
package/docs/SAFETY.md ADDED
@@ -0,0 +1,100 @@
1
+ # Safety
2
+
3
+ This tool operates a real 1688 buyer account. Some commands read public or
4
+ account data; others contact sellers, mutate cart state, submit feedback, or
5
+ place orders. Treat write actions as explicit user-authorized operations.
6
+
7
+ ## Exit Codes
8
+
9
+ | Code | Meaning | Agent behavior |
10
+ |---:|---|---|
11
+ | 0 | Success | Continue. |
12
+ | 2 | Bad invocation | Fix arguments or report the bad input. |
13
+ | 3 | Not logged in / session expired | Tell the user to run `1688 login`; do not loop. |
14
+ | 4 | Risk control / slider verification | Tell the user to rerun once with `--headed`; do not silently retry. |
15
+ | 5 | Another 1688 command is running | Wait only if the task naturally allows it; otherwise report lock busy. |
16
+ | 6 | Chromium missing | Report dependency issue. |
17
+ | 7 | Login wait timeout | Report timeout. |
18
+ | 8 | Login finished but cookies missing | Report login cookie issue. |
19
+ | 9 | Network error | Report or retry only when safe and bounded. |
20
+ | 130 | User canceled | Stop. |
21
+
22
+ ## Login And Logout
23
+
24
+ - `1688 login` opens a user-interactive QR/browser flow. Only run it when the
25
+ user explicitly asks to log in.
26
+ - In non-interactive sessions, `1688 login` saves a QR PNG to
27
+ `~/.1688/login-qr.png` and prints `QR saved as PNG: <path>` on stderr.
28
+ Surface that file/path to the user and wait for the command to exit.
29
+ - Do not open the raw QR URL in a browser.
30
+ - `1688 logout --yes` destroys the cached session. Do not pass `--yes` without
31
+ explicit current-turn confirmation.
32
+
33
+ ## Risk Control
34
+
35
+ - If exit code `4` appears, tell the user to rerun the same command once with
36
+ `--headed`.
37
+ - The user must solve the slider manually.
38
+ - Do not silently retry the same blocked command.
39
+
40
+ ## Seller Contact
41
+
42
+ These commands contact real sellers:
43
+
44
+ ```bash
45
+ 1688 seller inquire <offerId> <message>
46
+ 1688 seller chat <orderId|loginId> <message>
47
+ ```
48
+
49
+ Before sending, show the message and target context unless the user has already
50
+ given an explicit current-turn send instruction.
51
+
52
+ ## Cart Mutations
53
+
54
+ These commands mutate buyer cart state:
55
+
56
+ ```bash
57
+ 1688 cart add <offerId> --sku <skuId> --qty N
58
+ 1688 cart remove <cartId>
59
+ ```
60
+
61
+ For agent use, show the offer/SKU/quantity or cart row being changed and run
62
+ only after the user approves that action.
63
+
64
+ ## Checkout Protocol
65
+
66
+ `1688 checkout confirm` places a real order. It does not pay automatically, but
67
+ it commits the buyer to the seller.
68
+
69
+ Agent protocol:
70
+
71
+ 1. Run `1688 checkout prepare <cartIds...>`.
72
+ 2. Show the full preview: total, items, address, seller, and cart IDs.
73
+ 3. Wait for explicit current-turn approval such as "yes, place it" or
74
+ "下单吧".
75
+ 4. Run `1688 checkout confirm <cartIds...> --agent`.
76
+ 5. Report the final order ID and URL.
77
+
78
+ Never run `--agent` without this prepare plus approval cycle. Never infer
79
+ authorization from older messages.
80
+
81
+ ## Feedback Submission
82
+
83
+ `1688 feedback "<message>"` prepares a GitHub issue URL. That is safe by
84
+ default.
85
+
86
+ `1688 feedback "<message>" --submit` posts publicly through `gh`. Do not add
87
+ `--submit` unless the user explicitly asks to submit/post the issue.
88
+
89
+ ## Update Awareness
90
+
91
+ `1688 doctor --no-launch --json` reports version information. Any JSON-mode
92
+ command may also emit an update notice on stderr.
93
+
94
+ Rules:
95
+
96
+ - In an interactive session, ask once before running the printed global install
97
+ command.
98
+ - In non-interactive loops, do not upgrade automatically.
99
+ - After an approved package update, run `1688 daemon reload`.
100
+