Files
xianyu-hunter-hermes-skill/skill/xianyu-hunter-monitor/references/web-cache-cleanup-2026-05.md
T

63 lines
2.5 KiB
Markdown

# Web Cache Cleanup Entry — 2026-05
BOSS requested a Web UI entry to clear xianyu-hunter cached collection results while optionally preserving Hermes-approved quality results.
Implemented in local clone:
```text
/Users/chick/.Hermes/workspace/research/xianyu-hunter
```
Files changed:
- `lib/task.mjs`
- Added `TaskManager.clearTaskCache(id, { mode, minScore })`.
- Refuses running tasks by returning `null`.
- `mode: 'all'`: clears `products.raw`, `products.coarseFiltered`, `products.fineFiltered`, `hermesAnalysis`, chat arrays; resets stage to `pending`.
- `mode: 'hermes-recommend'`: keeps only `fineFiltered` items with `item.hermesAnalysis.verdict === 'recommend'`.
- `mode: 'hermes-pass'`: keeps `recommend` or `caution` items whose score is >= `minScore`.
- For keep modes, retained items are written to all three product buckets so the task still visibly has cached quality results.
- Adds a log line and broadcasts `task:updated`.
- `server.mjs`
- Added `POST /api/tasks/:id/clear-cache` with JSON body:
```json
{ "mode": "all|hermes-recommend|hermes-pass", "minScore": 75 }
```
- `public/index.html`
- Header button: `清除缓存`.
- Modal `#clear-cache-modal-overlay` with scope (`active`/`all`), mode, min score, preview, and log.
- Cache-busted assets to `style.css?v=15` and `app.js?v=15`.
- `public/app.js`
- Added `showClearCacheModal`, `hideClearCacheModal`, `renderClearCachePreview`, `clearCacheFromModal`, `getClearTargets`, `countQualityItems`.
- Frontend can clean current selected task or all non-running tasks.
- Shows preview of raw/coarse/fine counts and how many quality items will be retained.
- `public/style.css`
- Added `.clear-cache-modal`, `.cache-warning`, `.cache-preview*`, `.cache-counts` styles.
Verification performed:
```bash
node --check public/app.js
node --check server.mjs
node --check lib/task.mjs
```
Restart caveat:
- `node tools/xianyu_ops.mjs start --port 3000` reported running but did not replace stale PID 9407, so new route initially 404'd.
- Correct recovery was to kill the stale listener (`kill 9407`) and start tracked server with `PORT=3000 node server.mjs`.
- Active verified process after implementation: PID 11594 from Hermes background session `proc_41df821080bd`.
Smoke test:
1. Fetch `/` and verify `app.js?v=15`, `clear-cache-modal-overlay`.
2. Create save-only `__cache_smoke_test__` task via `POST /api/tasks`.
3. Call `POST /api/tasks/<id>/clear-cache` with `{ "mode": "all" }`.
4. Verify response `ok: true` and all counts zero.
5. Delete smoke task.