1688-cli 0.1.40 → 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.
- package/AGENTS.md +112 -318
- package/ARCHITECTURE.md +106 -0
- package/CHANGELOG.md +107 -0
- package/README.md +100 -10
- package/dist/cli.js +165 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/cart-add.js +15 -11
- package/dist/commands/cart-add.js.map +1 -1
- package/dist/commands/cart-list.js +13 -11
- package/dist/commands/cart-list.js.map +1 -1
- package/dist/commands/compare.js +107 -0
- package/dist/commands/compare.js.map +1 -0
- package/dist/commands/debug.js +101 -0
- package/dist/commands/debug.js.map +1 -0
- package/dist/commands/doctor.js +107 -4
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/image-search.js +2 -6
- package/dist/commands/image-search.js.map +1 -1
- package/dist/commands/inbox.js +16 -32
- package/dist/commands/inbox.js.map +1 -1
- package/dist/commands/offer.js +7 -5
- package/dist/commands/offer.js.map +1 -1
- package/dist/commands/order-list.js +4 -2
- package/dist/commands/order-list.js.map +1 -1
- package/dist/commands/order-logistics.js +4 -2
- package/dist/commands/order-logistics.js.map +1 -1
- package/dist/commands/profile.js +84 -0
- package/dist/commands/profile.js.map +1 -0
- package/dist/commands/research.js +142 -0
- package/dist/commands/research.js.map +1 -0
- package/dist/commands/search.js +157 -111
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/seller-messages.js +7 -4
- package/dist/commands/seller-messages.js.map +1 -1
- package/dist/commands/similar.js +2 -6
- package/dist/commands/similar.js.map +1 -1
- package/dist/commands/sourcing-utils.js +438 -0
- package/dist/commands/sourcing-utils.js.map +1 -0
- package/dist/commands/supplier-inspect.js +559 -0
- package/dist/commands/supplier-inspect.js.map +1 -0
- package/dist/commands/supplier-search.js +522 -0
- package/dist/commands/supplier-search.js.map +1 -0
- package/dist/daemon/client.js +2 -2
- package/dist/daemon/client.js.map +1 -1
- package/dist/daemon/protocol.js +2 -1
- package/dist/daemon/protocol.js.map +1 -1
- package/dist/io/output.js +31 -2
- package/dist/io/output.js.map +1 -1
- package/dist/session/config.js +82 -0
- package/dist/session/config.js.map +1 -0
- package/dist/session/dispatch.js +26 -3
- package/dist/session/dispatch.js.map +1 -1
- package/dist/session/events.js +151 -0
- package/dist/session/events.js.map +1 -0
- package/dist/session/im-cards.js +183 -0
- package/dist/session/im-cards.js.map +1 -0
- package/dist/session/im-ws.js +8 -5
- package/dist/session/im-ws.js.map +1 -1
- package/dist/session/navigation-guard.js +65 -0
- package/dist/session/navigation-guard.js.map +1 -0
- package/dist/session/paths.js +23 -4
- package/dist/session/paths.js.map +1 -1
- package/dist/session/search-capture.js +56 -6
- package/dist/session/search-capture.js.map +1 -1
- package/dist/session/search-mtop.js +53 -0
- package/dist/session/search-mtop.js.map +1 -1
- package/dist/session/supplier-search.js +403 -0
- package/dist/session/supplier-search.js.map +1 -0
- package/dist/util/encoding.js +8 -0
- package/dist/util/encoding.js.map +1 -0
- package/dist/util/temp.js +6 -0
- package/dist/util/temp.js.map +1 -0
- package/docs/AGENT_MAPS_PLAN.md +171 -0
- package/docs/AGENT_WORKING_PRINCIPLES.md +143 -0
- package/docs/COMMANDS.md +199 -0
- package/docs/FEATURES.md +45 -0
- package/docs/JSON_CONTRACTS.md +390 -0
- package/docs/QUALITY_SCORE.md +60 -0
- package/docs/README.md +35 -0
- package/docs/RELIABILITY.md +61 -0
- package/docs/SAFETY.md +100 -0
- package/docs/WORKFLOW.md +82 -0
- package/docs/exec-plans/README.md +9 -0
- package/docs/exec-plans/active/README.md +4 -0
- package/docs/exec-plans/completed/2026-05-28-sourcing-research-v1.md +125 -0
- package/docs/exec-plans/completed/2026-05-31-supplier-inspect-v1.md +113 -0
- package/docs/exec-plans/completed/2026-06-04-supplier-search-v1.md +81 -0
- package/docs/exec-plans/completed/2026-06-07-windows-cli-compatibility.md +138 -0
- package/docs/exec-plans/completed/README.md +4 -0
- package/docs/exec-plans/tech-debt-tracker.md +5 -0
- package/docs/generated/command-index.md +54 -0
- package/docs/generated/json-shapes.md +111 -0
- package/docs/generated/module-map.md +13 -0
- package/docs/generated/test-index.md +34 -0
- package/docs/playbooks/add-command.md +15 -0
- package/docs/playbooks/add-mtop-capture.md +13 -0
- package/docs/playbooks/change-json-output.md +11 -0
- package/docs/playbooks/debug-risk-control.md +12 -0
- package/docs/playbooks/update-cli-release.md +11 -0
- package/docs/specs/checkout-and-orders.md +30 -0
- package/docs/specs/seller-im.md +28 -0
- package/docs/specs/sourcing-research.md +186 -0
- package/docs/specs/supplier-inspect.md +144 -0
- package/docs/specs/supplier-search.md +179 -0
- package/docs/specs/windows-cli-compatibility.md +123 -0
- package/package.json +12 -2
- package/scripts/check_agent_map.mjs +86 -0
- package/scripts/fix_bin_mode.mjs +18 -0
- package/scripts/generate_agent_context.mjs +253 -0
- package/scripts/postinstall.mjs +12 -4
package/docs/WORKFLOW.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Workflow
|
|
2
|
+
|
|
3
|
+
This is the default workflow for AI agents and humans working in this
|
|
4
|
+
repository. Keep it executable and linked to deeper docs.
|
|
5
|
+
|
|
6
|
+
## Operating Model
|
|
7
|
+
|
|
8
|
+
- Humans set intent, constraints, priorities, and approval boundaries.
|
|
9
|
+
- Agents read the map, choose the smallest coherent slice, implement, verify,
|
|
10
|
+
and update durable docs.
|
|
11
|
+
- `AGENTS.md` is the fast entry point; this file is the default operating loop.
|
|
12
|
+
- Playbooks under `docs/playbooks/` hold repeatable task details.
|
|
13
|
+
- ExecPlans under `docs/exec-plans/` hold long-running state that should
|
|
14
|
+
survive chat history loss.
|
|
15
|
+
|
|
16
|
+
## Standard Task Brief
|
|
17
|
+
|
|
18
|
+
Capture or infer these fields before changing code:
|
|
19
|
+
|
|
20
|
+
```md
|
|
21
|
+
Goal:
|
|
22
|
+
Context:
|
|
23
|
+
Constraints:
|
|
24
|
+
Done when:
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Ask the human only when the missing choice changes product behavior, checkout
|
|
28
|
+
safety, data retention, account security, or external write actions.
|
|
29
|
+
|
|
30
|
+
## New Feature Flow
|
|
31
|
+
|
|
32
|
+
1. Read `AGENTS.md`, `ARCHITECTURE.md`, `docs/README.md`, and the relevant
|
|
33
|
+
product spec or playbook.
|
|
34
|
+
2. Locate the owning command/session/daemon/io layer.
|
|
35
|
+
3. For complex work, create or update an ExecPlan in
|
|
36
|
+
`docs/exec-plans/active/`.
|
|
37
|
+
4. Implement one bounded slice that can be verified independently.
|
|
38
|
+
5. Add or update deterministic tests near the changed code.
|
|
39
|
+
6. Update durable docs when command behavior, JSON output, safety rules, or
|
|
40
|
+
recurring workflow guidance changes.
|
|
41
|
+
7. Run the smallest verification ladder that proves the change, then climb if
|
|
42
|
+
risk increases.
|
|
43
|
+
|
|
44
|
+
## Bugfix Flow
|
|
45
|
+
|
|
46
|
+
1. Reproduce or narrow the failure with a test, probe, fixture, saved artifact,
|
|
47
|
+
or captured browser response.
|
|
48
|
+
2. Locate the smallest owning layer: CLI, command, session, daemon, io, auth,
|
|
49
|
+
or util.
|
|
50
|
+
3. Fix the root cause with minimal unrelated churn.
|
|
51
|
+
4. Add a regression test or document why one is not practical.
|
|
52
|
+
5. Run a focused test first, then `pnpm agent-verify` when the blast radius
|
|
53
|
+
warrants it.
|
|
54
|
+
|
|
55
|
+
## Verification Ladder
|
|
56
|
+
|
|
57
|
+
1. Focused checks: a single Vitest file, typecheck, or generated-context run.
|
|
58
|
+
2. Deterministic test gate: `pnpm test:unit`.
|
|
59
|
+
3. Agent gate: `pnpm agent-context`, then `pnpm agent-verify`.
|
|
60
|
+
4. Browser/live checks: `pnpm test` or manual/probe-based verification only
|
|
61
|
+
when the task touches real 1688 browser behavior and the user/session state
|
|
62
|
+
allows it.
|
|
63
|
+
|
|
64
|
+
## Human Approval Boundaries
|
|
65
|
+
|
|
66
|
+
Ask before doing any of these:
|
|
67
|
+
|
|
68
|
+
- Placing an order or using `checkout confirm --agent`.
|
|
69
|
+
- Logging out or forcing a login reset.
|
|
70
|
+
- Submitting a public GitHub issue with `feedback --submit`.
|
|
71
|
+
- Sending a real seller chat/inquiry unless the user asked for that specific
|
|
72
|
+
message to be sent.
|
|
73
|
+
- Running live/browser actions that can mutate cart, checkout, seller IM, or
|
|
74
|
+
account state.
|
|
75
|
+
- Making a breaking JSON contract change.
|
|
76
|
+
|
|
77
|
+
## Definition Of Done
|
|
78
|
+
|
|
79
|
+
- The change is implemented in the owning layer.
|
|
80
|
+
- Tests cover the behavior or the reason for no test is recorded.
|
|
81
|
+
- Relevant docs/specs/playbooks/generated indexes are updated.
|
|
82
|
+
- `pnpm agent-verify` passes, or the exact blocker is recorded.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Plan: Sourcing Research V1
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Deliver a complete first version of sourcing research:
|
|
6
|
+
|
|
7
|
+
- `search` supports research sort/filter flags.
|
|
8
|
+
- `research` runs multi-keyword sourcing research with scoring, dedupe,
|
|
9
|
+
export, and optional top-N enrichment.
|
|
10
|
+
- `compare` compares offer detail pages by sourcing-relevant fields.
|
|
11
|
+
- Docs, JSON contracts, generated indexes, and tests are updated.
|
|
12
|
+
|
|
13
|
+
## Context
|
|
14
|
+
|
|
15
|
+
- Spec: `docs/specs/sourcing-research.md`
|
|
16
|
+
- Backlog: `docs/FEATURES.md`
|
|
17
|
+
- Existing search command: `src/commands/search.ts`
|
|
18
|
+
- Search payload mapping: `src/session/search-mtop.ts`
|
|
19
|
+
- Offer detail command: `src/commands/offer.ts`
|
|
20
|
+
- CLI routing: `src/cli.ts`
|
|
21
|
+
- Output behavior: `src/io/output.ts`
|
|
22
|
+
- Agent rules: `docs/AGENT_WORKING_PRINCIPLES.md`
|
|
23
|
+
|
|
24
|
+
## Non-Goals
|
|
25
|
+
|
|
26
|
+
- Do not implement `supplier inspect` until reliable supplier-level payloads
|
|
27
|
+
are identified.
|
|
28
|
+
- Do not scrape every search result detail page by default.
|
|
29
|
+
- Do not change checkout/cart/seller-message behavior.
|
|
30
|
+
- Do not introduce remote writes.
|
|
31
|
+
|
|
32
|
+
## Design
|
|
33
|
+
|
|
34
|
+
1. Extend `search` with:
|
|
35
|
+
- `--sort`
|
|
36
|
+
- `--price-min`
|
|
37
|
+
- `--price-max`
|
|
38
|
+
- `--province`
|
|
39
|
+
- `--city`
|
|
40
|
+
- `--verified`
|
|
41
|
+
- `--min-turnover`
|
|
42
|
+
- `--exclude-ads`
|
|
43
|
+
|
|
44
|
+
Search remains one fast read-only command. Filtering and deterministic sort
|
|
45
|
+
happen locally on the collected result set. The search URL may include known
|
|
46
|
+
remote sort values, but local sorting remains the contract.
|
|
47
|
+
|
|
48
|
+
2. Add shared sourcing helpers:
|
|
49
|
+
- normalize sort/filter options
|
|
50
|
+
- parse turnover/order-count text
|
|
51
|
+
- score offers and offer details
|
|
52
|
+
- format JSONL/CSV exports
|
|
53
|
+
|
|
54
|
+
3. Add `research`:
|
|
55
|
+
- runs searches sequentially through existing daemon dispatch
|
|
56
|
+
- dedupes by offerId
|
|
57
|
+
- computes score/breakdown
|
|
58
|
+
- optionally enriches top N items through `offer`
|
|
59
|
+
- emits normal JSON/human output or explicit JSONL/CSV
|
|
60
|
+
|
|
61
|
+
4. Add `compare`:
|
|
62
|
+
- validates offer IDs
|
|
63
|
+
- fetches offer details sequentially
|
|
64
|
+
- returns item-level errors
|
|
65
|
+
- scores and sorts comparable summaries
|
|
66
|
+
|
|
67
|
+
5. Update docs and generated context.
|
|
68
|
+
|
|
69
|
+
## Self Review
|
|
70
|
+
|
|
71
|
+
- Risk: `sortType` URL behavior may vary by 1688 page version.
|
|
72
|
+
- Mitigation: keep local deterministic sorting as the public contract.
|
|
73
|
+
- Risk: supplier scores and repurchase rate may not exist in current payloads.
|
|
74
|
+
- Mitigation: include nullable fields and do not claim them as available.
|
|
75
|
+
- Risk: enrichment can trigger more browser/detail-page work.
|
|
76
|
+
- Mitigation: default enrichment to 0; require `--enrich top:N`.
|
|
77
|
+
- Risk: CSV/JSONL could bypass global output flags.
|
|
78
|
+
- Mitigation: explicit `--jsonl`/`--csv` modes only for `research`, with
|
|
79
|
+
validation against simultaneous use.
|
|
80
|
+
- Risk: item-level offer failures could abort useful research output.
|
|
81
|
+
- Mitigation: attach item errors and keep run output when at least one item
|
|
82
|
+
succeeds.
|
|
83
|
+
|
|
84
|
+
## Milestones
|
|
85
|
+
|
|
86
|
+
- [x] Expand spec and plan.
|
|
87
|
+
- [x] Implement search sort/filter helpers and flags.
|
|
88
|
+
- [x] Implement sourcing helper/scoring/export module.
|
|
89
|
+
- [x] Implement `research`.
|
|
90
|
+
- [x] Implement `compare`.
|
|
91
|
+
- [x] Add focused tests.
|
|
92
|
+
- [x] Update docs/backlog.
|
|
93
|
+
- [x] Run `pnpm agent-verify`.
|
|
94
|
+
|
|
95
|
+
## Verification
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pnpm test:unit
|
|
99
|
+
pnpm agent-context
|
|
100
|
+
pnpm agent-verify
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Decisions
|
|
104
|
+
|
|
105
|
+
- 2026-05-28: Keep `supplier inspect` out of V1 because reliable supplier-level
|
|
106
|
+
payloads are not yet mapped.
|
|
107
|
+
- 2026-05-28: Use local deterministic sorting/filtering as the contract even
|
|
108
|
+
when adding remote sort URL params.
|
|
109
|
+
- 2026-05-28: Enrichment defaults to off; top-N enrichment is explicit.
|
|
110
|
+
|
|
111
|
+
## Progress Log
|
|
112
|
+
|
|
113
|
+
- 2026-05-28: Created spec and plan. Self-review identified remote sort,
|
|
114
|
+
supplier-score availability, enrichment cost, export-mode validation, and
|
|
115
|
+
item-level failure handling as the main risks.
|
|
116
|
+
- 2026-05-28: Implemented `search` sort/filter controls, shared sourcing
|
|
117
|
+
scoring/export helpers, `research`, `compare`, and focused unit tests.
|
|
118
|
+
- 2026-05-28: Verification passed: `pnpm test:unit` (22 files, 151 tests),
|
|
119
|
+
`pnpm agent-context`, `pnpm agent-verify`, and `pnpm build`.
|
|
120
|
+
|
|
121
|
+
## Rollback
|
|
122
|
+
|
|
123
|
+
- Remove `research` and `compare` CLI entries and command files.
|
|
124
|
+
- Revert added `search` flags and helper usage.
|
|
125
|
+
- Regenerate agent context.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Plan: Supplier Inspect V1
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Deliver a read-only supplier inspection command backed by real 1688 payloads:
|
|
6
|
+
|
|
7
|
+
- `1688 supplier inspect <offerId|memberId|offerUrl|factoryCardUrl>`
|
|
8
|
+
- offerId path resolves supplier identity from offer detail and shopcard
|
|
9
|
+
- memberId path resolves factory-card data
|
|
10
|
+
- JSON contract and human output are documented
|
|
11
|
+
- loginId-only input is rejected until a deterministic resolver exists
|
|
12
|
+
|
|
13
|
+
## Context
|
|
14
|
+
|
|
15
|
+
- Spec: `docs/specs/supplier-inspect.md`
|
|
16
|
+
- Existing offer detail extraction: `src/commands/offer.ts`
|
|
17
|
+
- CLI routing: `src/cli.ts`
|
|
18
|
+
- Session dispatch: `src/session/dispatch.ts`
|
|
19
|
+
- Response parsing: `src/session/mtop.ts`
|
|
20
|
+
- Recovery behavior: `src/session/recovery.ts`
|
|
21
|
+
- Sourcing helpers/tests: `src/commands/sourcing-utils.ts`,
|
|
22
|
+
`tests/sourcing-utils.test.ts`
|
|
23
|
+
|
|
24
|
+
## Non-Goals
|
|
25
|
+
|
|
26
|
+
- Do not add write actions.
|
|
27
|
+
- Do not bulk crawl a supplier catalog.
|
|
28
|
+
- Do not silently resolve loginId by an unreliable URL.
|
|
29
|
+
- Do not change checkout/cart/seller-message behavior.
|
|
30
|
+
|
|
31
|
+
## Design
|
|
32
|
+
|
|
33
|
+
1. Add `src/commands/supplier-inspect.ts`.
|
|
34
|
+
- Normalize target into offerId or memberId.
|
|
35
|
+
- Reject loginId-only targets with `BAD_INPUT`.
|
|
36
|
+
- Use `withRecovery` for page-level failures.
|
|
37
|
+
|
|
38
|
+
2. OfferId path:
|
|
39
|
+
- Open `https://detail.1688.com/offer/<offerId>.html`.
|
|
40
|
+
- Capture `mtop.1688.moga.pc.shopcard`.
|
|
41
|
+
- Read `sellerModel` from `window.context`.
|
|
42
|
+
- If a memberId is found, enrich with factory card.
|
|
43
|
+
|
|
44
|
+
3. MemberId path:
|
|
45
|
+
- Open `https://sale.1688.com/factory/card.html?memberId=<memberId>`.
|
|
46
|
+
- Capture `mtop.com.alibaba.china.factory.card.common.fn.mtop.tpp.faas`.
|
|
47
|
+
- Parse visible factory-card text for available offer count.
|
|
48
|
+
|
|
49
|
+
4. Output:
|
|
50
|
+
- Normal human summary lists supplier identity, factory/authentication tags,
|
|
51
|
+
service scores, location, and offer count.
|
|
52
|
+
- JSON output follows the spec and remains nullable/additive.
|
|
53
|
+
|
|
54
|
+
5. Verification:
|
|
55
|
+
- Add focused unit tests for target normalization and data assembly.
|
|
56
|
+
- Run `pnpm typecheck`, `pnpm test:unit`, `pnpm agent-context`, and
|
|
57
|
+
`pnpm agent-map-check`.
|
|
58
|
+
- Run one live smoke command if session and risk-control state allow.
|
|
59
|
+
|
|
60
|
+
## Self Review
|
|
61
|
+
|
|
62
|
+
- Risk: factory card endpoint can time out or not fire.
|
|
63
|
+
- Mitigation: return partial supplier identity with a warning when offerId
|
|
64
|
+
data exists but factory-card enrichment fails.
|
|
65
|
+
- Risk: service score key names are not self-explanatory.
|
|
66
|
+
- Mitigation: keep raw keys and add best-effort labels.
|
|
67
|
+
- Risk: loginId direct lookup may return the wrong supplier.
|
|
68
|
+
- Mitigation: reject loginId-only input and document the limitation.
|
|
69
|
+
- Risk: available offer count only appears in rendered text.
|
|
70
|
+
- Mitigation: mark source as `factory-card-dom` and keep nullable.
|
|
71
|
+
|
|
72
|
+
## Milestones
|
|
73
|
+
|
|
74
|
+
- [x] Write spec and plan.
|
|
75
|
+
- [x] Implement command, parser, and CLI routing.
|
|
76
|
+
- [x] Add focused tests.
|
|
77
|
+
- [x] Update README, command catalog, JSON contracts, and feature backlog.
|
|
78
|
+
- [x] Regenerate agent context.
|
|
79
|
+
- [x] Run verification.
|
|
80
|
+
|
|
81
|
+
## Verification
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pnpm typecheck
|
|
85
|
+
pnpm test:unit
|
|
86
|
+
pnpm agent-context
|
|
87
|
+
pnpm agent-map-check
|
|
88
|
+
pnpm dev supplier inspect 628196518518 --json --pretty
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Passed on 2026-05-31:
|
|
92
|
+
|
|
93
|
+
- `pnpm dev supplier inspect 628196518518 --json --pretty`
|
|
94
|
+
- `pnpm typecheck`
|
|
95
|
+
- `pnpm test:unit`
|
|
96
|
+
- `pnpm docs-check`
|
|
97
|
+
- `pnpm agent-map-check`
|
|
98
|
+
- `pnpm agent-verify`
|
|
99
|
+
|
|
100
|
+
## Progress Log
|
|
101
|
+
|
|
102
|
+
- 2026-05-31: Live headed probe identified reliable offer `sellerModel`,
|
|
103
|
+
shopcard, and factory-card payloads. Direct loginId lookup was rejected after
|
|
104
|
+
probe showed it can resolve to the wrong factory.
|
|
105
|
+
- 2026-05-31: Implemented `supplier inspect`, CLI routing, dispatch registry,
|
|
106
|
+
parser helpers, focused tests, docs, generated agent context, and live smoke
|
|
107
|
+
verification.
|
|
108
|
+
|
|
109
|
+
## Rollback
|
|
110
|
+
|
|
111
|
+
- Remove `supplier inspect` CLI entry and command file.
|
|
112
|
+
- Remove tests and docs sections.
|
|
113
|
+
- Regenerate agent context.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Supplier Search V1
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Deliver supplier discovery and research backed by real 1688 company search:
|
|
6
|
+
|
|
7
|
+
- `1688 supplier search <keyword...>`
|
|
8
|
+
- `1688 supplier research <keyword...>`
|
|
9
|
+
- source must be `companySearchBusinessService`
|
|
10
|
+
- source must not be offer-result supplier aggregation
|
|
11
|
+
- optional top-N enrichment through `supplier inspect`
|
|
12
|
+
|
|
13
|
+
## Context Read
|
|
14
|
+
|
|
15
|
+
- Agent principles: `docs/AGENT_WORKING_PRINCIPLES.md`
|
|
16
|
+
- Sourcing spec: `docs/specs/sourcing-research.md`
|
|
17
|
+
- Supplier inspect spec: `docs/specs/supplier-inspect.md`
|
|
18
|
+
- New spec: `docs/specs/supplier-search.md`
|
|
19
|
+
- Existing search/capture patterns: `src/commands/search.ts`,
|
|
20
|
+
`src/session/search-capture.ts`
|
|
21
|
+
|
|
22
|
+
## Live Probe Findings
|
|
23
|
+
|
|
24
|
+
- Company search page:
|
|
25
|
+
`https://s.1688.com/company/company_search.htm?keywords=<GBK>`
|
|
26
|
+
- `s.1688.com` keywords must be GBK percent-encoded. UTF-8 encoding produced
|
|
27
|
+
mojibake/zero-result behavior.
|
|
28
|
+
- Business endpoint:
|
|
29
|
+
`search.1688.com/service/companySearchBusinessService`
|
|
30
|
+
- Payload path:
|
|
31
|
+
`data.data.companyWithOfferLists`
|
|
32
|
+
- Sample async response returned 14 suppliers with `pageCount=50` and
|
|
33
|
+
`docsReturn=14`.
|
|
34
|
+
- The async URL used `startIndex=6&asyncCount=14`, so V1 records a known
|
|
35
|
+
completeness boundary: stable service parsing first, optional SSR/DOM card
|
|
36
|
+
parsing later if exact first-page completeness is needed.
|
|
37
|
+
|
|
38
|
+
## Implementation
|
|
39
|
+
|
|
40
|
+
1. Add shared GBK percent encoder in `src/util/encoding.ts`.
|
|
41
|
+
2. Reuse the encoder in product search URL construction.
|
|
42
|
+
3. Add `src/session/supplier-search.ts`:
|
|
43
|
+
- request meta reader for `companySearchBusinessService`
|
|
44
|
+
- service payload parser
|
|
45
|
+
- supplier/offer-preview mapper
|
|
46
|
+
- response capture with `keep: "largest"` and settle window
|
|
47
|
+
4. Add `src/commands/supplier-search.ts`:
|
|
48
|
+
- `supplier search`
|
|
49
|
+
- `supplier research`
|
|
50
|
+
- scoring, filters, JSONL/CSV exports
|
|
51
|
+
- optional enrich through `supplier inspect`
|
|
52
|
+
5. Add CLI and dispatch registry wiring.
|
|
53
|
+
6. Add deterministic unit tests.
|
|
54
|
+
7. Update README, command catalog, JSON contracts, feature backlog, and specs.
|
|
55
|
+
8. Regenerate agent indexes.
|
|
56
|
+
|
|
57
|
+
## Decisions
|
|
58
|
+
|
|
59
|
+
- Keep source provenance explicit in JSON:
|
|
60
|
+
`source.offerAggregation=false`.
|
|
61
|
+
- `supplier search` defaults to `--enrich 0`.
|
|
62
|
+
- `supplier research` defaults to `--enrich top:10`.
|
|
63
|
+
- Rate filters accept both fractions and percentages (`0.4` or `40`).
|
|
64
|
+
- Enrichment requires `memberId`; missing memberId is an item-level error.
|
|
65
|
+
- Do not use direct unauthenticated fetch for company service because it can
|
|
66
|
+
trigger `x5` interstitials; use browser-emitted responses.
|
|
67
|
+
|
|
68
|
+
## Verification
|
|
69
|
+
|
|
70
|
+
- `pnpm typecheck`
|
|
71
|
+
- `pnpm test:unit`
|
|
72
|
+
- `pnpm agent-context`
|
|
73
|
+
- `pnpm agent-verify`
|
|
74
|
+
|
|
75
|
+
## Rollback
|
|
76
|
+
|
|
77
|
+
- Remove supplier search/research CLI entries.
|
|
78
|
+
- Remove dispatch registry entry `supplier-search`.
|
|
79
|
+
- Remove `src/commands/supplier-search.ts`.
|
|
80
|
+
- Remove `src/session/supplier-search.ts`.
|
|
81
|
+
- Revert README/docs/spec/test/index updates.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Plan: Windows CLI Compatibility
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Deliver the Windows compatibility baseline from
|
|
6
|
+
`docs/specs/windows-cli-compatibility.md`: Windows-safe build/install scripts,
|
|
7
|
+
daemon named pipe isolation, platform-aware diagnostics, Windows-ready docs,
|
|
8
|
+
and deterministic verification.
|
|
9
|
+
|
|
10
|
+
## Context
|
|
11
|
+
|
|
12
|
+
- Source spec: `docs/specs/windows-cli-compatibility.md`
|
|
13
|
+
- Agent map: `AGENTS.md`
|
|
14
|
+
- Workflow: `docs/WORKFLOW.md`
|
|
15
|
+
- CLI/package surfaces: `package.json`, `scripts/postinstall.mjs`, `src/cli.ts`
|
|
16
|
+
- Path/daemon surfaces: `src/session/paths.ts`, `src/daemon/*`
|
|
17
|
+
- Diagnostic surface: `src/commands/doctor.ts`
|
|
18
|
+
- User docs: `README.md`, `docs/COMMANDS.md`
|
|
19
|
+
- Generated indexes: `docs/generated/*`
|
|
20
|
+
|
|
21
|
+
Existing behavior already has partial Windows support: daemon IPC uses a
|
|
22
|
+
named pipe on `win32`, postinstall checks common Windows Chrome paths, and
|
|
23
|
+
most runtime paths use `path.join`. Known gaps are shell `chmod` in
|
|
24
|
+
`package.json`, a fixed global named pipe, Unix-only doctor hints, Unix-only
|
|
25
|
+
README examples, and no deterministic Windows-specific tests.
|
|
26
|
+
|
|
27
|
+
## Non-goals
|
|
28
|
+
|
|
29
|
+
- Do not change 1688 login/risk-control behavior.
|
|
30
|
+
- Do not add a native Windows service, installer, or packaged executable.
|
|
31
|
+
- Do not add live Windows 1688 network checks to deterministic tests.
|
|
32
|
+
- Do not change existing command JSON shapes except additive diagnostics if
|
|
33
|
+
needed.
|
|
34
|
+
|
|
35
|
+
## Design
|
|
36
|
+
|
|
37
|
+
- Replace shell `chmod` with a Node script that sets executable mode only on
|
|
38
|
+
Unix-like platforms.
|
|
39
|
+
- Make Windows named pipe paths stable per root by hashing `root()`.
|
|
40
|
+
- Keep Unix socket paths unchanged.
|
|
41
|
+
- Centralize platform-specific diagnostic hint strings in `doctor`.
|
|
42
|
+
- Make postinstall resolve its pid file through `BB1688_HOME` and run
|
|
43
|
+
`npx.cmd` on Windows.
|
|
44
|
+
- Use `os.tmpdir()` for production debug/probe output helpers that currently
|
|
45
|
+
write hard-coded `/tmp` paths.
|
|
46
|
+
- Update README and command docs with PowerShell-safe examples while keeping
|
|
47
|
+
Unix examples for shell users.
|
|
48
|
+
- Add deterministic tests that simulate Windows behavior without requiring a
|
|
49
|
+
Windows host by exposing pure helper functions.
|
|
50
|
+
|
|
51
|
+
## Checklist
|
|
52
|
+
|
|
53
|
+
Spec and plan foundation:
|
|
54
|
+
|
|
55
|
+
- [x] Create Windows CLI compatibility spec.
|
|
56
|
+
- [x] Create active ExecPlan.
|
|
57
|
+
|
|
58
|
+
Implementation:
|
|
59
|
+
|
|
60
|
+
- [x] Add cross-platform bin-mode script and replace `chmod` build command.
|
|
61
|
+
- [x] Make Windows daemon named pipe unique per `BB1688_HOME` root.
|
|
62
|
+
- [x] Make postinstall daemon pid lookup, npx invocation, and retry hint
|
|
63
|
+
platform-aware.
|
|
64
|
+
- [x] Make doctor fix hints platform-aware.
|
|
65
|
+
- [x] Replace production hard-coded `/tmp` debug dump paths with `os.tmpdir()`.
|
|
66
|
+
- [x] Add deterministic tests for Windows path/doctor/build helpers.
|
|
67
|
+
|
|
68
|
+
Docs and maps:
|
|
69
|
+
|
|
70
|
+
- [x] Update README Windows command-line guidance.
|
|
71
|
+
- [x] Update `docs/COMMANDS.md` Windows examples.
|
|
72
|
+
- [x] Run `pnpm agent-context` after command/doc/test layout changes.
|
|
73
|
+
|
|
74
|
+
Verification:
|
|
75
|
+
|
|
76
|
+
- [x] Run focused Windows compatibility tests.
|
|
77
|
+
- [x] Run `pnpm build`.
|
|
78
|
+
- [x] Run `pnpm test:unit`.
|
|
79
|
+
- [x] Run `pnpm agent-verify`.
|
|
80
|
+
- [x] Run `npm pack --dry-run`.
|
|
81
|
+
|
|
82
|
+
## Verification
|
|
83
|
+
|
|
84
|
+
Focused:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pnpm exec vitest run tests/paths.test.ts tests/doctor.test.ts tests/fix-bin-mode.test.ts
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Package and project:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pnpm build
|
|
94
|
+
pnpm test:unit
|
|
95
|
+
pnpm agent-context
|
|
96
|
+
pnpm agent-verify
|
|
97
|
+
npm pack --dry-run
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Manual Windows smoke when a Windows machine is available:
|
|
101
|
+
|
|
102
|
+
```powershell
|
|
103
|
+
npm i -g 1688-cli
|
|
104
|
+
1688 --version
|
|
105
|
+
1688 doctor --no-launch --json
|
|
106
|
+
1688 daemon start
|
|
107
|
+
1688 daemon status --json
|
|
108
|
+
1688 daemon stop
|
|
109
|
+
1688 search 雨伞 --max 1 --json
|
|
110
|
+
1688 supplier search 键盘 --max 1 --json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Decisions
|
|
114
|
+
|
|
115
|
+
- 2026-06-07: Treat Windows support as a deterministic packaging/runtime
|
|
116
|
+
compatibility baseline, not a guarantee that live 1688 network calls pass in
|
|
117
|
+
CI without a logged-in account.
|
|
118
|
+
- 2026-06-07: Use `BB1688_HOME` root hashing for Windows named pipes so
|
|
119
|
+
tests and users with different homes do not collide.
|
|
120
|
+
|
|
121
|
+
## Progress Log
|
|
122
|
+
|
|
123
|
+
- 2026-06-07: Created spec and active plan from user request.
|
|
124
|
+
- 2026-06-07: Implemented the Windows compatibility baseline: Node-based bin
|
|
125
|
+
mode fixing, root-hashed Windows daemon named pipes, platform-aware
|
|
126
|
+
postinstall and doctor hints, `os.tmpdir()` debug paths, PowerShell docs, and
|
|
127
|
+
deterministic helper tests.
|
|
128
|
+
- 2026-06-07: Verified with focused Windows compatibility tests, `pnpm build`,
|
|
129
|
+
`pnpm test:unit`, `pnpm agent-context`, `pnpm agent-verify`, and
|
|
130
|
+
`npm pack --dry-run`. Manual Windows smoke remains documented for a real
|
|
131
|
+
Windows session.
|
|
132
|
+
|
|
133
|
+
## Rollback
|
|
134
|
+
|
|
135
|
+
- Restore `package.json` build script to its previous `chmod` form.
|
|
136
|
+
- Restore `socketPath()` to the fixed Windows pipe.
|
|
137
|
+
- Revert postinstall, doctor, docs, and tests added by this plan.
|
|
138
|
+
- Run `pnpm agent-context` after rollback if generated indexes changed.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Command Index
|
|
2
|
+
|
|
3
|
+
_Generated by `scripts/generate_agent_context.mjs`._
|
|
4
|
+
|
|
5
|
+
| Command | Source | Arguments | Options | Description |
|
|
6
|
+
|---|---|---|---|---|
|
|
7
|
+
| `login` | `src/commands/login.ts` | - | `--force`<br>`--timeout <seconds>`<br>`--profile <name>`<br>`--headed`<br>`--no-daemon` | Log in to 1688 by scanning a QR code (auto-starts daemon afterwards) |
|
|
8
|
+
| `search` | `src/commands/search.ts` | `<keyword>` | `--max <n>`<br>`--sort <sort>`<br>`--price-min <n>`<br>`--price-max <n>`<br>`--province <name>`<br>`--city <name>`<br>`--verified <kind>`<br>`--min-turnover <n>`<br>`--exclude-ads`<br>`--profile <name>`<br>`--headed` | Search 1688 by keyword |
|
|
9
|
+
| `research` | `src/commands/research.ts` | `<keywords...>` | `--max-per-query <n>`<br>`--sort <sort>`<br>`--price-min <n>`<br>`--price-max <n>`<br>`--province <name>`<br>`--city <name>`<br>`--verified <kind>`<br>`--min-turnover <n>`<br>`--exclude-ads`<br>`--enrich <spec>`<br>`--jsonl`<br>`--csv`<br>`--output <file>`<br>`--profile <name>`<br>`--headed` | Run multi-keyword sourcing research with scoring and optional enrichment |
|
|
10
|
+
| `compare` | `src/commands/compare.ts` | `<offerIds...>` | `--csv`<br>`--output <file>`<br>`--profile <name>`<br>`--headed` | Compare multiple offer detail pages for sourcing decisions |
|
|
11
|
+
| `supplier` | - | - | - | - |
|
|
12
|
+
| `supplier inspect` | `src/commands/supplier-inspect.ts` | `<target>` | `--profile <name>`<br>`--headed` | Inspect supplier signals from an offerId or b2b-* memberId |
|
|
13
|
+
| `supplier search` | `src/commands/supplier-search.ts` | `<keywords...>` | `--max <n>`<br>`--factory-only`<br>`--province <name>`<br>`--city <name>`<br>`--min-years <n>`<br>`--min-repeat-rate <n>`<br>`--min-response-rate <n>`<br>`--enrich <spec>`<br>`--jsonl`<br>`--csv`<br>`--output <file>`<br>`--profile <name>`<br>`--headed` | Search suppliers from 1688 company search |
|
|
14
|
+
| `supplier research` | `src/commands/supplier-search.ts` | `<keywords...>` | `--max <n>`<br>`--factory-only`<br>`--province <name>`<br>`--city <name>`<br>`--min-years <n>`<br>`--min-repeat-rate <n>`<br>`--min-response-rate <n>`<br>`--enrich <spec>`<br>`--jsonl`<br>`--csv`<br>`--output <file>`<br>`--profile <name>`<br>`--headed` | Run supplier research from 1688 company search with scoring and inspect enrichment |
|
|
15
|
+
| `image-search` | `src/commands/image-search.ts` | `<imagePathOrUrl>` | `--max <n>`<br>`--profile <name>`<br>`--headed` | Search 1688 by image (local file or http(s) URL) |
|
|
16
|
+
| `offer` | `src/commands/offer.ts` | `<offerId>` | `--profile <name>`<br>`--headed` | Show details of a single 1688 offer |
|
|
17
|
+
| `similar` | `src/commands/similar.ts` | `<offerId>` | `--max <n>`<br>`--profile <name>`<br>`--headed` | Find similar / 找同款 offers for a given offerId (compare suppliers, sorted by price), |
|
|
18
|
+
| `inbox` | `src/commands/inbox.ts` | - | `--limit <n>`<br>`--unread`<br>`--profile <name>`<br>`--headed` | List recent 旺旺 IM conversations (newest first) |
|
|
19
|
+
| `seller` | - | - | - | Seller communication (旺旺 IM |
|
|
20
|
+
| `seller inquire` | `src/commands/seller-inquire.ts` | `<offerId>`<br>`<message>` | `--to <sellerLoginId>`<br>`--profile <name>`<br>`--headed` | Pre-sale inquiry: send a product link question to seller (requires prior chat or --to), |
|
|
21
|
+
| `seller messages` | `src/commands/seller-messages.ts` | `[target]` | `--offer <offerId>`<br>`--limit <n>`<br>`--since <iso>`<br>`--watch`<br>`--interval <seconds>`<br>`--profile <name>`<br>`--headed` | Read recent messages from a seller conversation |
|
|
22
|
+
| `seller chat` | `src/commands/seller-chat.ts` | `<target>`<br>`<message>` | `--no-card`<br>`--prefix`<br>`--profile <name>`<br>`--headed` | Send to seller. With orderId: sends order card link message (use --no-card for follow-ups |
|
|
23
|
+
| `checkout` | - | - | - | - |
|
|
24
|
+
| `checkout confirm` | `src/commands/checkout-confirm.ts` | `<cartIds...>` | `-y, --yes`<br>`--agent`<br>`--profile <name>` | Place an order for selected cart items. Default: TTY prompt. --agent: no prompt after external approval., |
|
|
25
|
+
| `checkout prepare` | `src/commands/checkout-prepare.ts` | `<cartIds...>` | `--profile <name>`<br>`--headed` | Preview total/address/items for a checkout (does NOT place order) |
|
|
26
|
+
| `cart` | - | - | - | - |
|
|
27
|
+
| `cart add` | `src/commands/cart-add.ts` | `<offerId>` | `--sku <skuId>`<br>`--qty <n>`<br>`--profile <name>`<br>`--headed` | Add one item to cart (UI replay, ~15s) |
|
|
28
|
+
| `cart remove` | `src/commands/cart-remove.ts` | `<cartId>` | `--profile <name>`<br>`--headed` | Remove one item from cart by cartId (UI replay, ~10s) |
|
|
29
|
+
| `cart list` | `src/commands/cart-list.ts` | - | `--profile <name>`<br>`--headed` | List items in your cart |
|
|
30
|
+
| `shipped` | `src/commands/workflows.ts` | `<orderId>` | `--profile <name>`<br>`--headed` | Combined order detail logistics for one orderId |
|
|
31
|
+
| `stuck` | `src/commands/workflows.ts` | - | `--days <n>`<br>`--limit <n>`<br>`--profile <name>`<br>`--headed` | Orders paid but not shipped after N days (default 3) |
|
|
32
|
+
| `fake-shipped` | `src/commands/workflows.ts` | - | `--days <n>`<br>`--max-pages <n>`<br>`--max-check <n>`<br>`--limit <n>`<br>`--debug`<br>`--profile <name>`<br>`--headed` | Orders marked shipped but logistics frozen at 等待揽收 (likely 虚假发货) |
|
|
33
|
+
| `seller-history` | `src/commands/workflows.ts` | `<seller>` | `--max-pages <n>`<br>`--profile <name>`<br>`--headed` | All orders from a seller avg shipping days on-time rate |
|
|
34
|
+
| `order` | - | - | - | - |
|
|
35
|
+
| `order logistics` | `src/commands/order-logistics.ts` | `<orderId>` | `--max-scan-pages <n>`<br>`--status <s>`<br>`--profile <name>`<br>`--headed` | Show shipping status tracking number for an order |
|
|
36
|
+
| `order get` | `src/commands/order-get.ts` | `<orderId>` | `--max-scan-pages <n>`<br>`--status <s>`<br>`--profile <name>`<br>`--headed` | Show one order by orderId (scans recent pages) |
|
|
37
|
+
| `order list` | `src/commands/order-list.ts` | - | `--status <s>`<br>`--page <n>`<br>`--page-size <n>`<br>`--profile <name>`<br>`--headed` | List buyer orders |
|
|
38
|
+
| `whoami` | `src/commands/whoami.ts` | - | `--verify`<br>`--profile <name>` | Show the current logged-in account |
|
|
39
|
+
| `logout` | `src/commands/logout.ts` | - | `-y, --yes`<br>`--profile <name>` | Log out and clear local session |
|
|
40
|
+
| `doctor` | `src/commands/doctor.ts` | - | `--no-launch`<br>`--live`<br>`--profile <name>` | Check environment, profile, Chromium, and session |
|
|
41
|
+
| `serve` | - | - | `--idle-timeout <minutes>`<br>`--no-prewarm` | Run the 1688 daemon in the foreground |
|
|
42
|
+
| `daemon` | - | - | - | - |
|
|
43
|
+
| `daemon start` | - | - | - | Start the daemon as a background process |
|
|
44
|
+
| `daemon stop` | - | - | - | Stop the running daemon |
|
|
45
|
+
| `daemon reload` | - | - | - | Restart the daemon (stop start) to pick up new code |
|
|
46
|
+
| `daemon status` | - | - | - | Show daemon status |
|
|
47
|
+
| `profile` | - | - | - | - |
|
|
48
|
+
| `profile list` | `src/commands/profile.ts` | - | - | List local profiles |
|
|
49
|
+
| `profile status` | `src/commands/profile.ts` | `[name]` | - | Show profile status |
|
|
50
|
+
| `debug` | - | - | - | - |
|
|
51
|
+
| `debug list` | `src/commands/debug.ts` | - | `--limit <n>`<br>`--failed` | List recent command events |
|
|
52
|
+
| `debug last` | `src/commands/debug.ts` | - | `--failed` | Show the most recent command event |
|
|
53
|
+
| `debug show` | `src/commands/debug.ts` | `<requestId>` | - | Show events and artifact location for a request |
|
|
54
|
+
| `feedback` | `src/commands/feedback.ts` | `<message...>` | `--bug`<br>`--submit`<br>`--no-open`<br>`--json`<br>`--json-v2`<br>`--pretty`<br>`--get <path>`<br>`--pick <paths>` | Submit feedback or a bug report. Default: opens a pre-filled GitHub issue. With --submit: posts directly via the gh CLI., |
|