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,171 @@
1
+ # Agent Maps Plan
2
+
3
+ Date: 2026-05-28
4
+
5
+ ## Sources Reviewed
6
+
7
+ - OpenAI: <https://openai.com/zh-Hans-CN/index/harness-engineering/>
8
+ - Reference repo: `/Users/nobodyjack2050/code/go-backend`
9
+
10
+ ## OpenAI Article Takeaways
11
+
12
+ The article's core lesson is that agent-first engineering needs maps and
13
+ feedback loops more than huge instruction files. The useful pattern is:
14
+
15
+ - Keep `AGENTS.md` short. It should be a table of contents and routing layer,
16
+ not a full manual.
17
+ - Put durable knowledge in versioned repo files, especially `docs/`, because
18
+ knowledge outside the repo is invisible to agents.
19
+ - Use progressive disclosure: start agents at a small map, then point them to
20
+ the precise product spec, playbook, architecture note, or generated index.
21
+ - Make the app and repo readable to agents: logs, metrics, traces, screenshots,
22
+ DOM state, generated indexes, and reproducible commands should all be
23
+ queryable.
24
+ - Encode taste and architecture as mechanical checks where possible. Guidance
25
+ that matters repeatedly should become lint, tests, generated docs checks, or
26
+ verification commands.
27
+ - Treat plans as first-class repo artifacts for complex work so progress,
28
+ decisions, and blockers survive conversation loss.
29
+ - Add recurring cleanup. As agent throughput rises, drift becomes normal unless
30
+ quality rules and doc-gardening are part of the system.
31
+
32
+ ## go-backend Agent Map Pattern
33
+
34
+ `go-backend` implements this pattern with several concrete artifacts:
35
+
36
+ - `AGENTS.md`: short "Agent Map" with first-read links, project shape, common
37
+ commands, task routing, hard rules, and done criteria.
38
+ - `ARCHITECTURE.md`: system map with layer responsibilities, dependency rules,
39
+ major domains, generated code rules, and verification surfaces.
40
+ - `docs/README.md`: documentation map and maintenance rules.
41
+ - `docs/specs`, `docs/design-docs`, `docs/integrations`,
42
+ `docs/playbooks`, `docs/references`: durable context split by use.
43
+ - `docs/exec-plans/active` and `docs/exec-plans/completed`: long-running
44
+ state for complex work.
45
+ - `docs/generated/*`: generated repo indexes such as API, proto, DB schema,
46
+ package map, test index, and OpenAPI summary.
47
+ - `scripts/generate_agent_context.sh`: builds generated indexes.
48
+ - `make agent-context`, `make agent-verify`, `make eval-agent`: standard
49
+ commands for regenerating context and proving agent-readiness.
50
+ - `docs/evals/graders/agent-map.sh`: deterministic check that the map exists
51
+ and points to verification/playbooks.
52
+ - `docs/QUALITY_SCORE.md`: blunt scorecard for agent-readiness and known gaps.
53
+
54
+ The important design choice is not the exact file names. It is the loop:
55
+ small map -> routed docs -> generated indexes -> mechanical verification ->
56
+ quality score -> cleanup.
57
+
58
+ ## Proposed Agent Maps For 1688-cli
59
+
60
+ `1688-cli` should use a smaller version of the same system. This repo is a
61
+ TypeScript CLI with browser automation, daemon IPC, JSON contracts, and real
62
+ buyer write actions, so the map should emphasize command ownership, output
63
+ shape stability, risk-control recovery, and approval boundaries.
64
+
65
+ ### Target Structure
66
+
67
+ ```text
68
+ AGENTS.md
69
+ ARCHITECTURE.md
70
+ docs/
71
+ README.md
72
+ WORKFLOW.md
73
+ COMMANDS.md
74
+ JSON_CONTRACTS.md
75
+ SAFETY.md
76
+ RELIABILITY.md
77
+ QUALITY_SCORE.md
78
+ specs/
79
+ sourcing-research.md
80
+ seller-im.md
81
+ checkout-and-orders.md
82
+ playbooks/
83
+ add-command.md
84
+ change-json-output.md
85
+ debug-risk-control.md
86
+ add-mtop-capture.md
87
+ update-cli-release.md
88
+ generated/
89
+ command-index.md
90
+ module-map.md
91
+ test-index.md
92
+ json-shapes.md
93
+ exec-plans/
94
+ active/
95
+ completed/
96
+ tech-debt-tracker.md
97
+ scripts/
98
+ generate_agent_context.mjs
99
+ check_agent_map.mjs
100
+ ```
101
+
102
+ ### `AGENTS.md` Target Role
103
+
104
+ Keep only the short, high-signal contract:
105
+
106
+ - First read: `ARCHITECTURE.md`, `docs/README.md`, `docs/SAFETY.md`,
107
+ `docs/COMMANDS.md`, and `docs/JSON_CONTRACTS.md`.
108
+ - Project shape: `src/commands`, `src/session`, `src/daemon`, `src/io`,
109
+ `src/auth`, `src/util`.
110
+ - Common commands: `pnpm build`, `pnpm test`, `pnpm typecheck`, future
111
+ `pnpm agent-context`, future `pnpm agent-verify`.
112
+ - Task routing: new command, JSON shape change, browser/session flow,
113
+ daemon/protocol change, checkout/order safety, seller IM, release/update.
114
+ - Hard rules: never place orders without prepare plus current-turn approval,
115
+ never silently retry login/risk-control loops, preserve JSON compatibility,
116
+ do not handwave browser verification failures.
117
+
118
+ The current detailed CLI operation contract can move into `docs/COMMANDS.md`,
119
+ `docs/JSON_CONTRACTS.md`, and `docs/SAFETY.md`.
120
+
121
+ ### Generated Context
122
+
123
+ `scripts/generate_agent_context.mjs` should generate:
124
+
125
+ - `docs/generated/command-index.md`: Commander commands/options from
126
+ `src/cli.ts`, mapped to `src/commands/*.ts`.
127
+ - `docs/generated/module-map.md`: top-level source directories and file counts.
128
+ - `docs/generated/test-index.md`: test files, if present, plus risk notes for
129
+ browser/session/integration-style tests.
130
+ - `docs/generated/json-shapes.md`: exported result interfaces from command
131
+ modules, especially stable agent-facing payloads.
132
+
133
+ This gives agents a fast way to understand the repo without reading every file.
134
+
135
+ ### Verification Gate
136
+
137
+ Add scripts/Make targets roughly equivalent to:
138
+
139
+ ```bash
140
+ pnpm agent-context # generate docs/generated/*
141
+ pnpm agent-verify # typecheck, tests, generated docs freshness, agent map check
142
+ pnpm eval-agent # deterministic repo-specific graders, later
143
+ ```
144
+
145
+ Initial `agent-verify` can stay modest:
146
+
147
+ - `pnpm typecheck`
148
+ - `pnpm test`
149
+ - generate context and fail if `docs/generated/*` changes
150
+ - check that `AGENTS.md`, `ARCHITECTURE.md`, `docs/README.md`, and core
151
+ playbooks exist
152
+
153
+ ### Rollout Order
154
+
155
+ 1. Add `docs/README.md`, `ARCHITECTURE.md`, `docs/COMMANDS.md`,
156
+ `docs/JSON_CONTRACTS.md`, `docs/SAFETY.md`, and `docs/WORKFLOW.md`.
157
+ 2. Move durable detail out of `AGENTS.md`, keeping `AGENTS.md` as a concise
158
+ routing map.
159
+ 3. Add `scripts/generate_agent_context.mjs` and generated indexes.
160
+ 4. Add `agent-context` and `agent-verify` package scripts.
161
+ 5. Add playbooks for the workflows that repeat most often.
162
+ 6. Add `QUALITY_SCORE.md` and update it whenever the map reveals a new gap.
163
+
164
+ ## Open Questions
165
+
166
+ - Whether to preserve the current long `AGENTS.md` for external skill registry
167
+ compatibility, or split it while keeping a compact compatibility section.
168
+ - Whether generated JSON-shape docs should parse TypeScript AST or start with a
169
+ simple regex-based extractor.
170
+ - Whether browser/risk-control verification should be part of the default gate
171
+ or a separate live/manual gate.
@@ -0,0 +1,143 @@
1
+ # Agent Working Principles
2
+
3
+ These principles apply to all coding agents working in this repository. The
4
+ first half is a reusable baseline shared with other agent-ready repositories;
5
+ the second half adds `1688-cli`-specific rules for buyer safety, JSON
6
+ contracts, and browser automation.
7
+
8
+ Tradeoff: these guidelines bias toward caution over speed. For trivial tasks,
9
+ use judgment.
10
+
11
+ ## 1. Think Before Coding
12
+
13
+ Don't assume. Don't hide confusion. Surface tradeoffs.
14
+
15
+ Before implementing:
16
+
17
+ - State assumptions explicitly when they matter.
18
+ - If multiple interpretations exist, present them instead of picking silently.
19
+ - If a simpler approach exists, say so.
20
+ - Push back when a request conflicts with safety, compatibility, or the repo's
21
+ existing architecture.
22
+ - Ask only when the missing answer changes product behavior, account safety,
23
+ checkout/order behavior, data retention, or a breaking contract.
24
+
25
+ ## 2. Simplicity First
26
+
27
+ Minimum code that solves the problem. Nothing speculative.
28
+
29
+ - No features beyond what was asked.
30
+ - No abstractions for single-use code.
31
+ - No flexibility or configurability that was not requested.
32
+ - No broad error handling that hides the real failure.
33
+ - If the implementation is much larger than the problem, simplify it.
34
+
35
+ Ask yourself: would a senior engineer say this is overcomplicated? If yes,
36
+ rewrite it smaller.
37
+
38
+ ## 3. Surgical Changes
39
+
40
+ Touch only what you must. Clean up only your own mess.
41
+
42
+ When editing existing code:
43
+
44
+ - Do not improve adjacent code, comments, or formatting unless needed.
45
+ - Do not refactor unrelated behavior.
46
+ - Match existing style, even if you would design it differently.
47
+ - If you notice unrelated dead code or risk, mention it; do not delete it.
48
+
49
+ When your changes create orphans:
50
+
51
+ - Remove imports, variables, files, and functions that your changes made unused.
52
+ - Do not remove pre-existing dead code unless asked.
53
+
54
+ Every changed line should trace directly to the user's request.
55
+
56
+ ## 4. Goal-Driven Execution
57
+
58
+ Define success criteria. Loop until verified.
59
+
60
+ Transform tasks into verifiable goals:
61
+
62
+ - "Add validation" -> write invalid-input tests, then make them pass.
63
+ - "Fix the bug" -> reproduce it or narrow it, then make the check pass.
64
+ - "Refactor X" -> keep behavior stable and run the relevant gate.
65
+ - "Add command" -> implement, document, update generated context, and verify.
66
+
67
+ For multi-step tasks, use a brief plan:
68
+
69
+ ```text
70
+ 1. [Step] -> verify: [check]
71
+ 2. [Step] -> verify: [check]
72
+ 3. [Step] -> verify: [check]
73
+ ```
74
+
75
+ Strong success criteria let agents loop independently. Weak criteria such as
76
+ "make it work" require clarification or a conservative assumption.
77
+
78
+ ## 5. Read The Map First
79
+
80
+ - Start with `AGENTS.md`, then load only the relevant deeper docs.
81
+ - Use `ARCHITECTURE.md` to find the owning layer before changing code.
82
+ - Use `docs/generated/*` for fast orientation instead of hand-building stale
83
+ inventories.
84
+ - Do not rely on chat history for durable decisions; write important context
85
+ into docs or an ExecPlan.
86
+
87
+ ## 6. Work In Small Verified Slices
88
+
89
+ - Prefer one bounded change that can be tested independently.
90
+ - Run focused checks first, then the default gate when risk warrants it.
91
+ - Use `pnpm agent-context` after command, JSON contract, source layout, or test
92
+ layout changes.
93
+ - Use `pnpm agent-verify` as the default green gate before handoff.
94
+
95
+ ## 7. Preserve Buyer Safety
96
+
97
+ - Treat 1688 as a real buyer account with real sellers, cart state, orders, and
98
+ session risk controls.
99
+ - Never place an order without the prepare plus current-turn approval protocol.
100
+ - Never send seller messages unless the user requested the specific send or
101
+ approved the exact message.
102
+ - Do not force logout, force login reset, or global package upgrades without
103
+ explicit current-turn approval.
104
+ - Login and slider/risk-control flows require the user; do not silently loop.
105
+
106
+ ## 8. Protect JSON Contracts
107
+
108
+ - Agent-facing JSON is part of the product surface.
109
+ - Prefer additive fields over renamed or removed fields.
110
+ - Keep `--json`, `--get`, `--pick`, and watch-mode line-delimited JSON stable.
111
+ - Update `docs/JSON_CONTRACTS.md` when output shape changes.
112
+ - Add tests or fixtures when parser changes affect stable JSON.
113
+
114
+ ## 9. Make Failures Inspectable
115
+
116
+ - Preserve `requestId`, `errorCode`, `pageState`, `verification`, and
117
+ `artifactDir` when browser/session flows fail.
118
+ - Use `1688 debug list`, `1688 debug last`, and `1688 debug show <requestId>`
119
+ to inspect recent command events.
120
+ - Do not hide failures by broad retry loops or vague error messages.
121
+ - Record exact command and failure summary in ExecPlans or final responses when
122
+ verification cannot pass.
123
+ - Distinguish system-level failure from item-level failure in batch workflows.
124
+
125
+ ## 10. Browser Automation Discipline
126
+
127
+ - Prefer mtop/structured payload parsing over fragile DOM scraping.
128
+ - Keep locator changes scoped and add fixture-backed tests where practical.
129
+ - Use `--headed` as the manual escape hatch for slider verification.
130
+ - Probe scripts are for discovery; stable behavior belongs in `src/`, `tests/`,
131
+ and docs.
132
+ - Avoid aggressive bulk scraping patterns that increase WAF/risk-control
133
+ exposure.
134
+
135
+ ## 11. Documentation Discipline
136
+
137
+ - Update command docs when command names, flags, examples, or behavior change.
138
+ - Update safety docs when write actions or approval boundaries change.
139
+ - Promote repeated debugging steps into playbooks.
140
+ - Keep feature ideas in `docs/FEATURES.md` and long-running work in
141
+ `docs/exec-plans/`.
142
+ - Keep `AGENTS.md` short; move durable detail into `docs/`.
143
+
@@ -0,0 +1,199 @@
1
+ # Command Catalog
2
+
3
+ Commands are organized by buyer journey: sourcing -> inquiry -> cart ->
4
+ checkout -> tracking -> post-sale.
5
+
6
+ ## Sourcing
7
+
8
+ ```bash
9
+ 1688 search <keyword> # keyword search; --max N to limit
10
+ 1688 search <keyword> --sort best-selling --price-max 50 --exclude-ads
11
+ 1688 search --headed # open window if slider verification appears
12
+ 1688 research <keyword...> # multi-keyword research, scoring, export
13
+ 1688 similar <offerId> # find similar offers from other suppliers
14
+ 1688 image-search <pathOrUrl> # local .jpg/.png/.webp or http(s) URL
15
+ 1688 offer <offerId> # product detail, SKUs, price tiers, package info
16
+ 1688 compare <offerId...> # compare offer details for sourcing
17
+ 1688 supplier inspect <target> # supplier/factory trust signals from offerId or b2b-* memberId
18
+ 1688 supplier search <keyword...> # supplier discovery from 1688 company search
19
+ 1688 supplier research <keyword...> # supplier scoring + inspect enrichment from company search
20
+ ```
21
+
22
+ Research-oriented `search` filters:
23
+
24
+ ```bash
25
+ --sort relevance|best-selling|price-asc|price-desc
26
+ --price-min <n>
27
+ --price-max <n>
28
+ --province <name>
29
+ --city <name>
30
+ --verified any|factory|business|super-factory
31
+ --min-turnover <n>
32
+ --exclude-ads
33
+ ```
34
+
35
+ `research` adds:
36
+
37
+ ```bash
38
+ --max-per-query <n>
39
+ --enrich top:N|N|0|none
40
+ --jsonl
41
+ --csv
42
+ --output <file>
43
+ ```
44
+
45
+ Supplier company-search commands:
46
+
47
+ ```bash
48
+ 1688 supplier search 键盘 --factory-only --json
49
+ 1688 supplier research 键盘 --enrich top:10 --csv
50
+ ```
51
+
52
+ `supplier search` and `supplier research` use 1688's company search source
53
+ (`companySearchBusinessService`). They do not aggregate suppliers from offer
54
+ search results. Shared flags:
55
+
56
+ ```bash
57
+ --max <n>
58
+ --factory-only
59
+ --province <name>
60
+ --city <name>
61
+ --min-years <n>
62
+ --min-repeat-rate <n> # accepts 0.4 or 40
63
+ --min-response-rate <n> # accepts 0.6 or 60
64
+ --enrich top:N|N|all|0|none
65
+ --jsonl
66
+ --csv
67
+ --output <file>
68
+ ```
69
+
70
+ `supplier search` defaults to `--enrich 0`. `supplier research` defaults to
71
+ `--enrich top:10`.
72
+
73
+ ## Pre-Sale Inquiry
74
+
75
+ ```bash
76
+ 1688 seller inquire <offerId> <message>
77
+ 1688 seller messages --offer <offerId>
78
+ 1688 seller messages --offer <offerId> --watch [--interval N]
79
+ ```
80
+
81
+ `--watch` is long-running and emits one line of JSON per newly-arrived message
82
+ when stdout is piped. Default interval is 30 seconds, minimum is 10 seconds.
83
+
84
+ ## Cart
85
+
86
+ ```bash
87
+ 1688 cart list
88
+ 1688 cart add <offerId> --sku <skuId> --qty N
89
+ 1688 cart remove <cartId>
90
+ ```
91
+
92
+ `cart add` returns `{added, isNewRow, addedQuantity}` so pipelines can pick up
93
+ the cart row reliably.
94
+
95
+ ## Checkout
96
+
97
+ ```bash
98
+ 1688 checkout prepare <cartId>...
99
+ 1688 checkout confirm <cartId>...
100
+ 1688 checkout confirm <cartId>... --agent
101
+ ```
102
+
103
+ `prepare` is read-only. `confirm` places a real order and must follow the
104
+ approval protocol in `docs/SAFETY.md`.
105
+
106
+ ## Order Tracking
107
+
108
+ ```bash
109
+ 1688 order list
110
+ 1688 order list --status waitsellersend
111
+ 1688 order list --status waitbuyerreceive
112
+ 1688 order get <orderId>
113
+ 1688 order logistics <orderId>
114
+ 1688 shipped <orderId>
115
+ 1688 stuck [--days N]
116
+ 1688 fake-shipped [--days N] [--debug]
117
+ 1688 seller-history <sellerName>
118
+ ```
119
+
120
+ Status filters:
121
+
122
+ | Value | Meaning |
123
+ |---|---|
124
+ | `all` | All orders |
125
+ | `waitbuyerpay` | Pending payment |
126
+ | `waitsellersend` | Paid, seller has not shipped |
127
+ | `waitbuyerreceive` | Shipped, awaiting delivery |
128
+ | `success` | Completed |
129
+ | `cancel` | Canceled |
130
+
131
+ ## Post-Sale Chat
132
+
133
+ ```bash
134
+ 1688 seller chat <orderId|loginId> <message>
135
+ 1688 seller chat <orderId> <message> --no-card
136
+ 1688 seller messages <orderId>
137
+ 1688 seller messages <orderId> --watch
138
+ ```
139
+
140
+ With an `orderId`, chat auto-attaches the order card unless `--no-card` is
141
+ given.
142
+
143
+ ## Account And Daemon
144
+
145
+ ```bash
146
+ 1688 login
147
+ 1688 login --headed
148
+ 1688 login --force
149
+ 1688 logout [--yes]
150
+ 1688 whoami [--verify]
151
+ 1688 doctor [--no-launch]
152
+ 1688 daemon start | stop | status | reload
153
+ 1688 serve
154
+ ```
155
+
156
+ ## Output Flags
157
+
158
+ Every command supports:
159
+
160
+ ```bash
161
+ --json # force JSON output even in a TTY
162
+ --pretty # indent JSON by 2 spaces
163
+ --get <path> # print one field by dot-path
164
+ --pick <paths> # comma-separated dot-paths as a JSON object
165
+ ```
166
+
167
+ Examples:
168
+
169
+ ```bash
170
+ 1688 offer X --get supplier.name
171
+ 1688 offer X --get supplier
172
+ 1688 offer X --get 'skus[*].price'
173
+ 1688 offer X --pick price,supplier.name
174
+ 1688 offer X --json --pretty
175
+ 1688 research 手机壳 数据线 --jsonl
176
+ 1688 research 手机壳 --csv --output research.csv
177
+ 1688 compare 123 456 --csv
178
+ 1688 supplier inspect 628196518518 --json --pretty
179
+ 1688 supplier search 键盘 --json --pretty
180
+ 1688 supplier research 键盘 --csv --output suppliers.csv
181
+ ```
182
+
183
+ ## Agent-Friendly Pipelines
184
+
185
+ ```bash
186
+ 1688 search 雨伞 | jq '.offers[0:5]'
187
+ 1688 order list --status waitsellersend | jq '.orders[] | {id: .orderId, paid: .paidAt}'
188
+ id=$(1688 cart add <offerId> --sku <skuId> --qty 1 | jq -r '.added.cartId')
189
+ ```
190
+
191
+ PowerShell without `jq`:
192
+
193
+ ```powershell
194
+ 1688 offer <offerId> --get supplier.name
195
+ 1688 supplier search 键盘 --pick total,source.kind,'items[0].supplier.companyName'
196
+ $added = 1688 cart add <offerId> --sku <skuId> --qty 1 --json | ConvertFrom-Json
197
+ 1688 cart remove $added.added.cartId
198
+ 1688 supplier research 键盘 --csv --output "$env:TEMP\suppliers.csv"
199
+ ```
@@ -0,0 +1,45 @@
1
+ # Feature Backlog
2
+
3
+ This file records product ideas that should survive chat context loss. Status
4
+ is intentionally lightweight: `Idea`, `Planned`, `Active`, or `Done`.
5
+
6
+ Last updated: 2026-06-04
7
+
8
+ ## Sourcing Research
9
+
10
+ | Feature | Status | Notes |
11
+ |---|---|---|
12
+ | `1688 search --sort` | Done | Added `relevance`, `best-selling`, `price-asc`, and `price-desc`; local deterministic sorting is the contract, with remote sort hints where known. |
13
+ | Search filters | Done | Added price range, province/city, verified supplier, minimum turnover/order count, and optional ad exclusion. |
14
+ | `1688 research <keyword...>` | Done | Multi-keyword research records `sourceKeyword`, rank, demand signals, supplier trust signals, score, JSON/JSONL/CSV output. |
15
+ | Top-N enrichment | Done | `research --enrich top:N` enriches only top N results through `offer` detail extraction. |
16
+ | Supplier quality fields | Planned | Basic service tags, product badges, demand, and verification fields are additive; deeper trade-service scores still need reliable payload mapping. |
17
+ | `1688 supplier inspect` | Done | Inspect supplier/factory trust signals from offerId or `b2b-*` memberId. loginId-only lookup is intentionally rejected until a deterministic resolver exists. |
18
+ | `1688 supplier search` | Done | Supplier discovery now comes from 1688 company search (`companySearchBusinessService`) with GBK keyword encoding, not offer-result aggregation. |
19
+ | `1688 supplier research` | Done | Scores company-search suppliers and optionally enriches top N via `supplier inspect`; supports JSONL/CSV export. |
20
+ | `1688 compare <offerId...>` | Done | Compares price tiers, MOQ, sales signals, supplier identity, SKU depth, stock, freight/package hints, and score. |
21
+ | Export formats | Done | Added `--jsonl` and `--csv` for research datasets while keeping normal command JSON stable for agents. |
22
+ | Sourcing score | Done | Computed, explainable V1 score from price, demand, supplier tenure, verification, tags, and ad status. |
23
+
24
+ ## Agent Maps
25
+
26
+ | Feature | Status | Notes |
27
+ |---|---|---|
28
+ | Short agent entrypoint | Done | `AGENTS.md` is now a concise routing map; durable detail moved into `docs/`. |
29
+ | Documentation map | Done | `docs/README.md` now maps commands, JSON contracts, safety, reliability, workflow, specs, playbooks, exec plans, and generated indexes. |
30
+ | Architecture map | Done | `ARCHITECTURE.md` describes CLI layers, command ownership, session/daemon boundaries, and verification surfaces. |
31
+ | Specs directory | Done | Domain specs live under `docs/specs/` instead of `docs/product-specs/`. |
32
+ | Playbooks | Done | Added playbooks for adding commands, changing JSON output, debugging risk control, adding mtop capture, and release/update work. |
33
+ | Generated context | Done | `scripts/generate_agent_context.mjs` generates command, module, test, and JSON-shape indexes under `docs/generated/`. |
34
+ | Agent verification gate | Done | Added `pnpm agent-context`, `pnpm docs-check`, `pnpm agent-map-check`, `pnpm test:unit`, and `pnpm agent-verify`. |
35
+ | Agent map grader | Done | `scripts/check_agent_map.mjs` checks required docs, generated indexes, package scripts, and short-map constraints. |
36
+ | Quality score | Done | `docs/QUALITY_SCORE.md` tracks agent-readiness, known gaps, and latest verification. |
37
+ | Live doctor gate split | Planned | Full `pnpm test` still includes `tests/doctor-live.test.ts`; consider adding explicit `pnpm test:live` and making `pnpm test` deterministic or clearly documented. |
38
+ | JSON schema/snapshot tests | Idea | Add tests that lock stable agent-facing JSON contracts beyond the heuristic `docs/generated/json-shapes.md` index. |
39
+ | AST-based JSON shape index | Idea | Replace the current regex/heuristic interface extractor with TypeScript AST parsing when shape extraction needs more precision. |
40
+
41
+ ## Platform Compatibility
42
+
43
+ | Feature | Status | Notes |
44
+ |---|---|---|
45
+ | Windows CLI compatibility baseline | Done | Implemented cross-platform build, root-hashed Windows named-pipe daemon isolation, platform-aware doctor/postinstall hints, `os.tmpdir()` debug paths, PowerShell docs, and deterministic tests. Verified with focused tests, `pnpm build`, `pnpm test:unit`, `pnpm agent-verify`, and `npm pack --dry-run`; manual Windows smoke checklist remains documented in the spec. |