1688-cli 0.1.42 → 0.1.43

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 (60) hide show
  1. package/ARCHITECTURE.md +3 -2
  2. package/CHANGELOG.md +79 -0
  3. package/README.md +102 -24
  4. package/dist/cli.js +33 -25
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/checkout-confirm.js +8 -8
  7. package/dist/commands/checkout-confirm.js.map +1 -1
  8. package/dist/commands/doctor.js +46 -43
  9. package/dist/commands/doctor.js.map +1 -1
  10. package/dist/commands/inbox.js +1 -1
  11. package/dist/commands/inbox.js.map +1 -1
  12. package/dist/commands/login.js +14 -14
  13. package/dist/commands/login.js.map +1 -1
  14. package/dist/commands/logout.js +6 -4
  15. package/dist/commands/logout.js.map +1 -1
  16. package/dist/commands/profile.js +25 -9
  17. package/dist/commands/profile.js.map +1 -1
  18. package/dist/commands/seller-chat.js +1 -1
  19. package/dist/commands/seller-chat.js.map +1 -1
  20. package/dist/commands/seller-inquire.js +1 -1
  21. package/dist/commands/seller-inquire.js.map +1 -1
  22. package/dist/commands/seller-messages.js +1 -1
  23. package/dist/commands/seller-messages.js.map +1 -1
  24. package/dist/commands/whoami.js +6 -3
  25. package/dist/commands/whoami.js.map +1 -1
  26. package/dist/daemon/client.js +10 -6
  27. package/dist/daemon/client.js.map +1 -1
  28. package/dist/daemon/manager.js +53 -37
  29. package/dist/daemon/manager.js.map +1 -1
  30. package/dist/daemon/server.js +26 -22
  31. package/dist/daemon/server.js.map +1 -1
  32. package/dist/session/context.js +1 -1
  33. package/dist/session/context.js.map +1 -1
  34. package/dist/session/dispatch.js +23 -22
  35. package/dist/session/dispatch.js.map +1 -1
  36. package/dist/session/lock.js +14 -14
  37. package/dist/session/lock.js.map +1 -1
  38. package/dist/session/paths.js +39 -18
  39. package/dist/session/paths.js.map +1 -1
  40. package/dist/session/shared.js +17 -7
  41. package/dist/session/shared.js.map +1 -1
  42. package/dist/session/state.js +7 -7
  43. package/dist/session/state.js.map +1 -1
  44. package/docs/COMMANDS.md +9 -3
  45. package/docs/JSON_CONTRACTS.md +86 -0
  46. package/docs/QUALITY_SCORE.md +2 -1
  47. package/docs/README.md +1 -0
  48. package/docs/RELIABILITY.md +13 -5
  49. package/docs/SAFETY.md +1 -2
  50. package/docs/exec-plans/completed/2026-06-16-profile-daemon.md +146 -0
  51. package/docs/generated/command-index.md +5 -5
  52. package/docs/generated/json-shapes.md +1 -1
  53. package/docs/generated/test-index.md +1 -1
  54. package/docs/playbooks/update-cli-release.md +56 -6
  55. package/docs/records/release-omissions.md +34 -0
  56. package/docs/specs/index.md +9 -0
  57. package/docs/specs/profile-daemon.md +114 -0
  58. package/package.json +11 -4
  59. package/scripts/check_agent_map.mjs +2 -1
  60. package/scripts/check_release.mjs +40 -0
@@ -38,12 +38,12 @@ _Generated by `scripts/generate_agent_context.mjs`._
38
38
  | `whoami` | `src/commands/whoami.ts` | - | `--verify`<br>`--profile <name>` | Show the current logged-in account |
39
39
  | `logout` | `src/commands/logout.ts` | - | `-y, --yes`<br>`--profile <name>` | Log out and clear local session |
40
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 |
41
+ | `serve` | - | - | `--profile <name>`<br>`--idle-timeout <minutes>`<br>`--no-prewarm` | Run the 1688 daemon in the foreground |
42
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 |
43
+ | `daemon start` | - | - | `--profile <name>` | Start the daemon as a background process |
44
+ | `daemon stop` | - | - | `--profile <name>` | Stop the running daemon |
45
+ | `daemon reload` | - | - | `--profile <name>` | Restart the daemon (stop start) to pick up new code |
46
+ | `daemon status` | - | - | `--profile <name>` | Show daemon status |
47
47
  | `profile` | - | - | - | - |
48
48
  | `profile list` | `src/commands/profile.ts` | - | - | List local profiles |
49
49
  | `profile status` | `src/commands/profile.ts` | `[name]` | - | Show profile status |
@@ -84,7 +84,7 @@ This is a heuristic index of exported TypeScript interfaces that are likely to m
84
84
  | `SupplierSearchArgs` | `src/commands/supplier-search.ts` | `keywords: string[];`<br>`maxPerQuery: number;`<br>`enrichTop?: number;`<br>`filters?: SupplierFilters;`<br>`headed?: boolean;` |
85
85
  | `SupplierSearchOpts` | `src/commands/supplier-search.ts` | `keywords: string[];`<br>`max?: string;`<br>`enrich?: string;`<br>`factoryOnly?: boolean;`<br>`province?: string;`<br>`city?: string;`<br>`minYears?: string;`<br>`minRepeatRate?: string;`<br>`minResponseRate?: string;`<br>`jsonl?: boolean;`<br>`csv?: boolean;`<br>`output?: string;`<br>`profile?: string;`<br>`headed?: boolean;` |
86
86
  | `SupplierSearchResult` | `src/commands/supplier-search.ts` | `queries: string[];`<br>`source: {`<br>`kind: 'company-search';`<br>`endpoint: 'companySearchBusinessService';`<br>`offerAggregation: false;`<br>`filters: SupplierFilters;`<br>`maxPerQuery: number;`<br>`enrichTop: number;`<br>`totalBeforeFilter: number;`<br>`total: number;`<br>`enrichedCount: number;`<br>`items: SupplierSearchItem[];` |
87
- | `WhoamiArgs` | `src/commands/whoami.ts` | `verify?: boolean;` |
87
+ | `WhoamiArgs` | `src/commands/whoami.ts` | `verify?: boolean;`<br>`profile?: string;` |
88
88
  | `WhoamiOpts` | `src/commands/whoami.ts` | `verify?: boolean;`<br>`profile?: string;` |
89
89
  | `WhoamiResult` | `src/commands/whoami.ts` | `loggedIn: boolean;`<br>`memberId?: string;`<br>`nick?: string \| null;`<br>`lastVerifiedAt?: string \| null;` |
90
90
  | `FakeShippedOpts` | `src/commands/workflows.ts` | `days?: string;`<br>`limit?: string;`<br>`maxPages?: string;`<br>`maxCheck?: string;`<br>`debug?: boolean;` |
@@ -19,7 +19,7 @@ _Generated by `scripts/generate_agent_context.mjs`._
19
19
  | `tests/navigation-guard.test.ts` | navigation-guard | live/session-sensitive |
20
20
  | `tests/output.test.ts` | output | - |
21
21
  | `tests/page-state.test.ts` | page-state | live/session-sensitive, browser/page-state |
22
- | `tests/paths.test.ts` | paths | - |
22
+ | `tests/paths.test.ts` | paths | live/session-sensitive |
23
23
  | `tests/profile.test.ts` | profile | live/session-sensitive |
24
24
  | `tests/recovery.test.ts` | recovery | browser/page-state |
25
25
  | `tests/replay-fixtures.test.ts` | replay-fixtures | browser/page-state, fixture/parser |
@@ -1,11 +1,61 @@
1
1
  # Playbook: Update CLI Release Behavior
2
2
 
3
- 1. Check `package.json`, `CHANGELOG.md`, `README.md`, and update-notifier
4
- behavior in `src/cli.ts`.
5
- 2. Preserve the update protocol in `docs/SAFETY.md`: never run a global install
3
+ Use this playbook for version bumps, npm publishes, GitHub release/tag work,
4
+ postinstall changes, and update-notifier behavior.
5
+
6
+ ## Release Checklist
7
+
8
+ 1. Update `CHANGELOG.md` first.
9
+ - Keep current in-progress docs/features under `## [Unreleased]`.
10
+ - Before publishing, move released items into
11
+ `## [x.y.z] - YYYY-MM-DD`.
12
+ - Do not describe post-tag work as part of an already-published npm version.
13
+ 2. Check `package.json`, `README.md`, npm metadata, and update-notifier behavior
14
+ in `src/cli.ts`.
15
+ 3. Preserve the update protocol in `docs/SAFETY.md`: never run a global install
6
16
  command without explicit current-turn user approval.
7
- 3. If daemon behavior changes after upgrade, document whether
17
+ 4. If daemon behavior changes after upgrade, document whether
8
18
  `1688 daemon reload` is required.
9
- 4. Run `pnpm build`, `pnpm test`, and `pnpm agent-context`.
10
- 5. Update docs when install, postinstall, or release packaging behavior changes.
19
+ 5. Run:
20
+
21
+ ```bash
22
+ pnpm agent-context
23
+ pnpm agent-verify
24
+ npm pack --dry-run
25
+ ```
26
+
27
+ 6. Verify the release gate explicitly:
28
+
29
+ ```bash
30
+ pnpm release-check
31
+ ```
32
+
33
+ 7. Publish only after npm auth is valid:
34
+
35
+ ```bash
36
+ npm whoami
37
+ npm publish
38
+ ```
39
+
40
+ 8. Push both branch and tag. Lightweight tags are not pushed by
41
+ `git push --follow-tags`, so push the release tag explicitly:
42
+
43
+ ```bash
44
+ git push origin main
45
+ git push origin vX.Y.Z
46
+ ```
47
+
48
+ 9. After publish, verify:
49
+
50
+ ```bash
51
+ npm view 1688-cli version dist-tags --json
52
+ npm view 1688-cli@X.Y.Z readmeFilename version --json
53
+ git ls-remote --tags origin refs/tags/vX.Y.Z
54
+ ```
55
+
56
+ ## Omission Tracking
11
57
 
58
+ If a release step is missed, record it in
59
+ `docs/records/release-omissions.md` with symptom, cause, fix, and prevention.
60
+ Then update this playbook or a script so the same omission becomes harder to
61
+ repeat.
@@ -0,0 +1,34 @@
1
+ # Release Omissions
2
+
3
+ Record release misses here so the process improves instead of relying on memory.
4
+
5
+ ## 2026-06-08 - 0.1.42 CHANGELOG Omitted
6
+
7
+ ### Symptom
8
+
9
+ After `1688-cli@0.1.42` was published and pushed, the GitHub file list still
10
+ showed `CHANGELOG.md` last changed by `chore(release): 0.1.41`. The npm
11
+ package included the old changelog because the 0.1.42 release commit only
12
+ bumped `package.json`.
13
+
14
+ ### Cause
15
+
16
+ The release playbook said to check `CHANGELOG.md`, but there was no executable
17
+ gate in `agent-verify` or `prepublishOnly` to fail when the package version was
18
+ missing from `CHANGELOG.md`.
19
+
20
+ ### Fix
21
+
22
+ - Backfilled `CHANGELOG.md` with a `0.1.42` section for released work.
23
+ - Added an `Unreleased` section for post-tag README/npm-metadata documentation
24
+ changes that should ship in the next npm version.
25
+ - Added `pnpm release-check`, backed by `scripts/check_release.mjs`.
26
+ - Added `release-check` to `pnpm agent-verify` and `prepublishOnly`.
27
+ - Expanded `docs/playbooks/update-cli-release.md` with changelog, npm, tag, and
28
+ post-publish verification steps.
29
+
30
+ ### Prevention
31
+
32
+ Before the next publish, move `Unreleased` items into the new version section,
33
+ run `pnpm agent-verify`, run `npm pack --dry-run`, and push the release tag
34
+ explicitly with `git push origin vX.Y.Z`.
@@ -0,0 +1,9 @@
1
+ # Specs Index
2
+
3
+ - [Checkout And Orders](checkout-and-orders.md)
4
+ - [Profile Daemon](profile-daemon.md)
5
+ - [Seller IM](seller-im.md)
6
+ - [Sourcing Research](sourcing-research.md)
7
+ - [Supplier Inspect](supplier-inspect.md)
8
+ - [Supplier Search](supplier-search.md)
9
+ - [Windows CLI Compatibility](windows-cli-compatibility.md)
@@ -0,0 +1,114 @@
1
+ # Spec: Profile Daemon
2
+
3
+ > Status: draft
4
+ > Product: 1688-cli daemon/session runtime
5
+ > Scope: profile-scoped daemon processes, browser contexts, locks, runtime artifacts, and diagnostics
6
+
7
+ ## 1. Summary
8
+
9
+ `1688-cli` supports multiple local profiles, but the warm daemon runtime is
10
+ currently global/default-oriented. This spec changes daemon ownership to one
11
+ daemon per profile so commands run against the daemon for their selected
12
+ profile, different profiles can operate in parallel, and default-profile
13
+ behavior remains compatible for users who do not pass `--profile`.
14
+
15
+ ## 2. Goals
16
+
17
+ - Resolve every command profile to `default` when no profile is supplied.
18
+ - Support `1688 serve --profile <name>`.
19
+ - Support `1688 daemon start|stop|status|reload --profile <name>`.
20
+ - Route ordinary dispatched commands such as `search --profile acc-a` to the
21
+ daemon for `acc-a` when that daemon is reachable.
22
+ - Keep headed mode and explicitly daemon-disabled runs inline.
23
+ - Use one persistent browser context per daemon, bound to that daemon profile.
24
+ - Use profile-scoped lock, socket or named pipe, pid, version, log, and state
25
+ artifacts.
26
+ - Allow different profiles to run concurrently without sharing one process lock.
27
+ - Surface profile names in daemon, lock, and diagnostic error messages.
28
+ - Preserve default behavior for commands that omit `--profile`.
29
+
30
+ ## 3. Non-goals
31
+
32
+ - Do not build one daemon that multiplexes multiple profiles.
33
+ - Do not change checkout confirmation safety or route `checkout confirm`
34
+ through the daemon.
35
+ - Do not run live 1688 login, search, or browser mutation checks as automated
36
+ verification.
37
+ - Do not change command result contracts except for additive diagnostic fields
38
+ on daemon/profile/doctor surfaces.
39
+ - Do not migrate or delete historical global daemon artifacts automatically
40
+ beyond normal stale-artifact cleanup for the selected profile.
41
+
42
+ ## 4. Behavior contract
43
+
44
+ - `defaultProfileName(profile)` resolves missing, empty, or whitespace-only
45
+ profile input to `default`.
46
+ - Runtime artifact helpers accept an optional profile argument and use the
47
+ resolved profile:
48
+ - `socketPath(profile)`
49
+ - `pidFile(profile)`
50
+ - `daemonVersionFile(profile)`
51
+ - `daemonLogFile(profile)`
52
+ - `lockFile(profile)`
53
+ - `stateFile(profile)`
54
+ - Windows named pipe names include both the root hash and a profile-derived
55
+ segment so two profiles under the same `BB1688_HOME` do not collide.
56
+ - Non-Windows daemon sockets are profile-scoped filesystem paths under the
57
+ selected profile/runtime area.
58
+ - `acquireLock(profile)` locks only the selected profile.
59
+ - Inline sessions use `profilePath(profile)` and `acquireLock(profile)`.
60
+ - A daemon process is bound to exactly one profile at startup.
61
+ - `getSharedContext(profile)` creates or reuses the browser context only for
62
+ the daemon-bound profile and stores cookies/session in that profile's
63
+ persistent context directory.
64
+ - `runOnSharedCtx` serializes operations within one daemon process only.
65
+ - `dispatch(name, args, { profile })` attempts the selected profile daemon
66
+ unless headed, no-daemon, or `BB1688_NO_DAEMON=1` is set.
67
+ - If inline fallback is needed, dispatch pauses only the selected profile
68
+ daemon, not daemons for other profiles.
69
+ - `login --profile <name>` writes identity state for that profile and, unless
70
+ `--no-daemon` is set, attempts to start that profile daemon after login or
71
+ after detecting an already-logged-in profile.
72
+ - `doctor --profile <name>` checks the selected profile's directory, lock,
73
+ state, daemon, and live daemon socket status.
74
+ - `profile status <name>` reports the selected profile's profile directory,
75
+ profile-scoped lock, profile-scoped state, recent event, and daemon status.
76
+ - Error messages for daemon running, start timeout, lock busy, stale daemon, and
77
+ daemon pause identify the affected profile.
78
+
79
+ ## 5. Verification
80
+
81
+ - Focused unit coverage for profile-scoped paths, including Windows pipe names.
82
+ - Focused unit coverage for profile status using profile-scoped locks/states.
83
+ - Focused unit coverage for doctor platform helpers and profile-aware daemon
84
+ checks where deterministic.
85
+ - Typecheck with `pnpm typecheck`.
86
+ - Deterministic tests with `pnpm test:unit`.
87
+ - Regenerate generated docs with `pnpm agent-context` after command/source/test
88
+ changes.
89
+ - Run `pnpm agent-verify` as the final local gate.
90
+
91
+ ## 6. Acceptance criteria
92
+
93
+ - `1688 daemon start --profile acc-a` starts only the `acc-a` daemon.
94
+ - `1688 daemon start --profile acc-b` can coexist with `acc-a`.
95
+ - `1688 daemon status --profile acc-a` and `--profile acc-b` inspect different
96
+ artifacts and sockets.
97
+ - `1688 serve --profile acc-a` binds a daemon to `acc-a`.
98
+ - `1688 search "..." --profile acc-a` tries the `acc-a` daemon first.
99
+ - `1688 search "..." --profile acc-b` tries the `acc-b` daemon first.
100
+ - A lock held by `acc-a` does not make `acc-b` report `LOCK_BUSY`.
101
+ - A daemon pause or risk-control state in one profile is represented in that
102
+ profile daemon status and does not stop another profile daemon.
103
+ - Commands without `--profile` continue to use the `default` profile.
104
+
105
+ ## 7. Assumptions and open questions
106
+
107
+ - [ASSUMED] Profile names used by real workflows are simple names such as
108
+ `default`, `acc-a`, or `work`, without path separators.
109
+ - [ASSUMED] Moving default daemon artifacts behind profile-aware helpers is
110
+ compatible because all public commands use those helpers rather than fixed
111
+ artifact paths.
112
+ - [ASSUMED] Historical global `state.json` does not need an automated migration
113
+ for this change; a profile-specific state file is authoritative once this
114
+ version runs.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "1688-cli",
3
- "version": "0.1.42",
4
- "description": "1688.com CLI for humans, Codex, and Claude Code. Sourcing (search / image-search / offer / inquire) and orders (list / detail / logistics / seller chat).",
3
+ "version": "0.1.43",
4
+ "description": "1688.com CLI for humans, Codex, and Claude Code. Product search, supplier scraper/research, inquiry, cart, orders, logistics, and seller chat.",
5
5
  "license": "MIT",
6
6
  "author": "nobodyjack",
7
7
  "homepage": "https://github.com/superjack2050/1688-cli#readme",
@@ -22,6 +22,11 @@
22
22
  "claude-code",
23
23
  "codex",
24
24
  "automation",
25
+ "scraper",
26
+ "supplier-scraper",
27
+ "supplier-search",
28
+ "product-scraper",
29
+ "sourcing",
25
30
  "ecommerce",
26
31
  "procurement",
27
32
  "playwright",
@@ -39,6 +44,7 @@
39
44
  "scripts/fix_bin_mode.mjs",
40
45
  "scripts/generate_agent_context.mjs",
41
46
  "scripts/check_agent_map.mjs",
47
+ "scripts/check_release.mjs",
42
48
  "docs",
43
49
  "AGENTS.md",
44
50
  "ARCHITECTURE.md",
@@ -59,8 +65,9 @@
59
65
  "agent-context": "node scripts/generate_agent_context.mjs",
60
66
  "docs-check": "node scripts/generate_agent_context.mjs --check",
61
67
  "agent-map-check": "node scripts/check_agent_map.mjs",
62
- "agent-verify": "pnpm typecheck && pnpm test:unit && pnpm docs-check && pnpm agent-map-check",
63
- "prepublishOnly": "pnpm build",
68
+ "release-check": "node scripts/check_release.mjs",
69
+ "agent-verify": "pnpm typecheck && pnpm test:unit && pnpm docs-check && pnpm agent-map-check && pnpm release-check",
70
+ "prepublishOnly": "pnpm release-check && pnpm build",
64
71
  "postinstall": "node scripts/postinstall.mjs"
65
72
  },
66
73
  "dependencies": {
@@ -38,6 +38,7 @@ const requiredFiles = [
38
38
  'docs/playbooks/debug-risk-control.md',
39
39
  'docs/playbooks/add-mtop-capture.md',
40
40
  'docs/playbooks/update-cli-release.md',
41
+ 'docs/records/release-omissions.md',
41
42
  'docs/generated/command-index.md',
42
43
  'docs/generated/module-map.md',
43
44
  'docs/generated/test-index.md',
@@ -63,7 +64,7 @@ if (agents.split('\n').length > 220)
63
64
  failures.push('AGENTS.md should stay short (<= 220 lines).');
64
65
 
65
66
  const pkg = JSON.parse(await read('package.json'));
66
- for (const scriptName of ['agent-context', 'docs-check', 'agent-map-check', 'agent-verify']) {
67
+ for (const scriptName of ['agent-context', 'docs-check', 'agent-map-check', 'release-check', 'agent-verify']) {
67
68
  if (!pkg.scripts?.[scriptName]) failures.push(`package.json missing script: ${scriptName}`);
68
69
  }
69
70
 
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
7
+
8
+ async function readJson(relPath) {
9
+ return JSON.parse(await fs.readFile(path.join(root, relPath), 'utf8'));
10
+ }
11
+
12
+ async function read(relPath) {
13
+ return fs.readFile(path.join(root, relPath), 'utf8');
14
+ }
15
+
16
+ const pkg = await readJson('package.json');
17
+ const changelog = await read('CHANGELOG.md');
18
+
19
+ const version = pkg.version;
20
+ const releaseHeading = new RegExp(`^## \\[${version.replaceAll('.', '\\.')}\\] - \\d{4}-\\d{2}-\\d{2}$`, 'm');
21
+ const failures = [];
22
+
23
+ if (!releaseHeading.test(changelog)) {
24
+ failures.push(`CHANGELOG.md missing release heading for package version ${version}.`);
25
+ }
26
+
27
+ if (!pkg.files?.includes('CHANGELOG.md')) {
28
+ failures.push('package.json files must include CHANGELOG.md.');
29
+ }
30
+
31
+ if (!pkg.scripts?.['release-check']) {
32
+ failures.push('package.json missing script: release-check.');
33
+ }
34
+
35
+ if (failures.length) {
36
+ console.error(failures.join('\n'));
37
+ process.exit(1);
38
+ }
39
+
40
+ console.log(`Release metadata looks good for ${pkg.name}@${version}.`);