release: 0.2.0421.2

This commit is contained in:
2026-04-21 17:10:06 +08:00
parent 55324a5bb7
commit 968cc88c62
19 changed files with 2832 additions and 178 deletions
@@ -0,0 +1,217 @@
# Market Export Range Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Add configurable CSV export ranges for the Xingtu market plugin, defaulting to the first 5 pages and supporting current page, preset ranges, all pages, and custom page counts.
**Architecture:** Keep filter and sort scoped to the current page, and introduce a dedicated batch-export path that only runs when exporting. Extend the toolbar with export-range controls, extract page-navigation/signature helpers, and add a focused controller that iterates pages, harvests lazy-loaded DOM fields, merges records by `authorId`, and returns a single record set for CSV generation.
**Tech Stack:** TypeScript, Vitest, jsdom, Chrome MV3 content script
---
### Task 1: Extend Toolbar Controls For Export Range
**Files:**
- Modify: `src/content/market/plugin-toolbar.ts`
- Test: `tests/market-content-entry.test.ts`
- [ ] **Step 1: Write the failing tests**
Add tests that assert:
- the toolbar defaults to `前5页`
- selecting `自定义` shows and uses a page-count input
- invalid custom values prevent export
- export mode disables toolbar controls during a running task
- [ ] **Step 2: Run tests to verify they fail**
Run: `npm test -- tests/market-content-entry.test.ts -t "export range"`
Expected: FAIL because the toolbar has no range selector or custom input behavior.
- [ ] **Step 3: Write the minimal implementation**
Update `plugin-toolbar.ts` to:
- add an export-range `<select>`
- add a custom page-count `<input>`
- add status text support
- expose helpers for reading range state and toggling disabled/running UI
- [ ] **Step 4: Run tests to verify they pass**
Run: `npm test -- tests/market-content-entry.test.ts -t "export range"`
Expected: PASS
- [ ] **Step 5: Commit**
```bash
git add src/content/market/plugin-toolbar.ts tests/market-content-entry.test.ts
git commit -m "feat: add export range toolbar controls"
```
### Task 2: Add Batch Export Coverage
**Files:**
- Modify: `tests/market-content-entry.test.ts`
- Modify: `tests/market-dom-sync.test.ts`
- Test: `tests/market-content-entry.test.ts`
- [ ] **Step 1: Write the failing tests**
Add tests that assert:
- `当前页` exports only the current page
- `前5页` iterates through pages until it reaches page 5 or runs out of pages
- `全部` stops when the next-page control is no longer usable
- repeated authors across pages are merged by `authorId`
- empty fields from later pages do not erase existing populated fields
- page export waits for page signature change before harvesting the next page
- [ ] **Step 2: Run tests to verify they fail**
Run: `npm test -- tests/market-content-entry.test.ts`
Expected: FAIL on the new batch-export expectations.
- [ ] **Step 3: Write the minimal implementation scaffolding**
Only introduce the minimum new helpers/types needed to make the tests compile:
- export range type(s)
- page signature helpers
- harness utilities in tests
- [ ] **Step 4: Run tests to verify the failures are now behavioral**
Run: `npm test -- tests/market-content-entry.test.ts`
Expected: FAIL because batch export logic is still missing, not because types/selectors are missing.
- [ ] **Step 5: Commit**
```bash
git add tests/market-content-entry.test.ts tests/market-dom-sync.test.ts src/content/market/types.ts
git commit -m "test: cover multi-page export behavior"
```
### Task 3: Implement Batch Export Controller
**Files:**
- Create: `src/content/market/export-range-controller.ts`
- Modify: `src/content/market/types.ts`
- Modify: `src/content/market/dom-sync.ts`
- Modify: `src/content/market/result-store.ts`
- Test: `tests/market-content-entry.test.ts`
- Test: `tests/market-dom-sync.test.ts`
- [ ] **Step 1: Write the failing tests**
Add focused tests for:
- reading a page signature from current DOM
- detecting/using the next-page control
- merging rows by `authorId` with non-empty-field preference
- [ ] **Step 2: Run tests to verify they fail**
Run: `npm test -- tests/market-dom-sync.test.ts`
Expected: FAIL because these helpers/controller do not exist yet.
- [ ] **Step 3: Write the minimal implementation**
Implement `export-range-controller.ts` to:
- normalize export targets (`current`, `count`, `all`)
- harvest current page rows with the existing lazy-load scroll path
- read page signatures
- click/advance pagination and wait for signature change
- merge pages by `authorId` without overwriting non-empty fields
- return a final `MarketRecord[]`
Keep `dom-sync.ts` focused on DOM reads:
- page signature
- next-page element lookup
- next-page enabled check
- [ ] **Step 4: Run tests to verify they pass**
Run:
- `npm test -- tests/market-dom-sync.test.ts`
- `npm test -- tests/market-content-entry.test.ts`
Expected: PASS
- [ ] **Step 5: Commit**
```bash
git add src/content/market/export-range-controller.ts src/content/market/dom-sync.ts src/content/market/result-store.ts src/content/market/types.ts tests/market-content-entry.test.ts tests/market-dom-sync.test.ts
git commit -m "feat: add multi-page export controller"
```
### Task 4: Wire Controller Into Market Entry
**Files:**
- Modify: `src/content/market/index.ts`
- Modify: `src/content/market/plugin-toolbar.ts`
- Test: `tests/market-content-entry.test.ts`
- [ ] **Step 1: Write the failing tests**
Add tests that assert:
- `导出CSV` uses the selected range
- progress text updates while exporting
- controls are re-enabled on success and failure
- invalid custom input blocks export without calling CSV builder
- [ ] **Step 2: Run tests to verify they fail**
Run: `npm test -- tests/market-content-entry.test.ts`
Expected: FAIL because `market/index.ts` still always exports current-page records.
- [ ] **Step 3: Write the minimal implementation**
Update `market/index.ts` to:
- parse toolbar export range
- keep current-page export for `当前页`
- delegate batch modes to `export-range-controller.ts`
- update toolbar running/error/progress state
- preserve existing current-page lazy-load harvest path
- [ ] **Step 4: Run tests to verify they pass**
Run: `npm test -- tests/market-content-entry.test.ts`
Expected: PASS
- [ ] **Step 5: Commit**
```bash
git add src/content/market/index.ts src/content/market/plugin-toolbar.ts tests/market-content-entry.test.ts
git commit -m "feat: wire export range selection into market export"
```
### Task 5: Verify End-To-End
**Files:**
- Modify: `docs/superpowers/plans/2026-04-21-market-export-range.md`
- [ ] **Step 1: Run targeted regression tests**
Run:
- `npm test -- tests/market-content-entry.test.ts`
- `npm test -- tests/market-dom-sync.test.ts`
Expected: PASS
- [ ] **Step 2: Run the full suite**
Run: `npm test`
Expected: PASS with all test files green.
- [ ] **Step 3: Run the build**
Run: `npm run build`
Expected: PASS and emit updated `dist/` bundles.
- [ ] **Step 4: Mark the plan status**
Update this documents checkboxes to reflect completed steps.
- [ ] **Step 5: Commit**
```bash
git add docs/superpowers/plans/2026-04-21-market-export-range.md
git commit -m "docs: record export range implementation progress"
```