Peach: Local-first video metadata scraper and media manager.
fix(web): clean up detail lifecycle and semantic routes
Peach local maintenance1e41b0608bad
diff --git a/AGENTS.md b/AGENTS.mdindex cb5409022..83a900079 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -1,8 +1,11 @@-# Peach agent contract+# Peach 智能体工作契约-This file is the single cross-agent entry point for Codex and Claude.+本文件是 Codex 与 Claude 共用的唯一项目入口。-Before changing the project, read these files in order:+面向用户阅读的 README、项目总览、状态、交接、复用清单、待办和 ADR 正文统一使用中文。+代码标识、命令、协议名、库名和无法准确翻译的专有名词保留英文;不要为了智能体处理方便混写英文叙述。++修改项目前,按顺序阅读:1. `README.md`2. `docs/STATUS.md`@@ -11,7 +14,7 @@ Before changing the project, read these files in order:5. `docs/HANDOFF.md`6. Relevant ADRs under `docs/adr/`-Working rules:+工作规则:- `R:\peach-app` is code and documentation. `R:\peach-data`, `R:\media`, `A:\` and `B:\` are runtime data or mounted media and must never be copied into Git.- `R:\peach-data\database\ledger.db` is the truth store. Tests use temporary databases only. A real migration requires a SQLite backup and before/after count checks.diff --git a/README.md b/README.mdindex 5f0b7b6c8..e822ad90d 100644--- a/README.md+++ b/README.md@@ -44,6 +44,16 @@ cd R:\peach-app& .\.venv\Scripts\peach.exe serve --port 8900```+在独立 worktree 中验证时,项目 venv 的 editable install 仍可能指向主目录;必须让+`PYTHONPATH` 指向当前 worktree 的 `src`,并先输出 `peach.__file__` 核对来源,避免用旧实现+得到假阳性:++```powershell+$env:PYTHONPATH = (Join-Path (Get-Location) 'src')+& R:\peach-app\.venv\Scripts\python.exe -c "import peach; print(peach.__file__)"+& R:\peach-app\.venv\Scripts\python.exe -m unittest discover -s tests -p 'test_*.py' -v+```+`serve` 默认只监听 `127.0.0.1:8900`。公网、反代、HTTPS 和认证属于后续部署阶段,不在开发命令中隐式开启。Windows 日常运行使用登录后托盘,而不是保留命令行窗口或注册系统服务。托盘在启动时声明diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex d6c68e94a..c7c6de21f 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -1,31 +1,31 @@-# Architecture+# 总体架构-## Product shape+## 产品形态Peach 是逻辑前后端分离、部署仍为一个进程的 FastAPI 模块化单体。默认单用户、本地自托管;在线追更、外部元数据和可插拔 AI 是正式能力。未来远程访问通过 VPN/Tunnel,或 DDNS + 反代 + HTTPS;应用端口不直接裸露公网。-## Core boundaries+## 核心边界1. **Ledger**:资产、行为、来源和知识的唯一真相源。SQLite 适合当前单用户规模。-2. **API/application**:FastAPI 承载页面、JSON、媒体响应和写入边界。-3. **Media Engine**:FastAPI 只持有一个 `MediaEngine`。本地文件是原生 backend;Stash 是公开协议 adapter,再按扫描、元数据、预览、流媒体逐项替换。+2. **API / 应用层**:FastAPI 承载页面、JSON、媒体响应和写入边界。+3. **Media Engine**:FastAPI 只持有一个 `MediaEngine`。本地文件是原生后端;Stash 是公开协议适配器,再按扫描、元数据、预览、流媒体逐项替换。4. **Web**:当前是无构建步骤的单页,保持移动端优先;不做 React 重写。-5. **AI providers**:`InferenceProvider` 与 `AgentProvider` 分离。AI 只产出带 provenance/confidence 的候选。-6. **Profiles**:默认单用户,数据模型预留 user/profile,不引入完整账号体系。-7. **Follow sources**:RSS/Atom 等成熟协议先归一化为只读候选;原始证据、review 和 ledger 写入分层。-8. **Jobs**:Peach 自己定义来源成本、磁盘闸门、进程归属、进度和 provenance;HTTP、调度、媒体探测、图片与协议解析使用成熟组件。-9. **HTTP/search**:网络 adapter 共用长生命周期 HTTPX transport;作品全文搜索使用 SQLite FTS5 trigram,短查询保留 LIKE fallback。+5. **AI Provider**:`InferenceProvider` 与 `AgentProvider` 分离。AI 只产出带来源和置信度的候选。+6. **Profile**:默认单用户,数据模型预留 user/profile,不引入完整账号体系。+7. **追更来源**:RSS/Atom 等成熟协议先归一化为只读候选;原始证据、复核和 ledger 写入分层。+8. **任务系统**:Peach 自己定义来源成本、磁盘闸门、进程归属、进度和来源证据;HTTP、调度、媒体探测、图片与协议解析使用成熟组件。+9. **HTTP / 搜索**:网络适配器共用长生命周期 HTTPX transport;作品全文搜索使用 SQLite FTS5 trigram,短查询保留 LIKE 回退。-## Data flow+## 数据流```text-local/network/online sources -> index/probe -> ledger.db- -> FastAPI -> web/player-Stash ----------------------- Media adapter --^-AI/external metadata -> reviewed candidates -> ledger+本地/网盘/在线来源 -> 索引/探测 -> ledger.db+ -> FastAPI -> Web/播放器+Stash ---------------- Media 适配器 --^+AI/外部元数据 -> 经复核的候选 -> ledger```-## Non-goals+## 明确不做- 微服务、消息总线、PostgreSQL- 重型前端框架迁移@@ -35,16 +35,16 @@ AI/external metadata -> reviewed candidates -> ledger关键取舍见 `docs/adr/`;Stash 的代码级证据见 `docs/STASH.md`。复用/自研边界及旧脚本继任关系见 `docs/REUSE.md`。-## Runtime data layout+## 运行数据目录-`R:\peach-data` is intentionally separate from the repository:+`R:\peach-data` 与代码仓库刻意分离:-- `database/`: SQLite truth store-- `generated/`: snapshots, posters, avatars and logos-- `sources/`: immutable/raw browser, follow, inventory and export inputs-- `state/`: curated local state and locks-- `secrets/`: local-only secret material-- `logs/`: current operational logs-- `archive/`: historical migration evidence and backups-- `inbox/`: transient imports awaiting processing-- `tools/`: machine-local managed runtimes such as FFmpeg; binaries and licenses stay outside Git+- `database/`:SQLite 真相库+- `generated/`:快照、海报、头像和厂牌 Logo+- `sources/`:浏览器、追更、盘点和导出等不可变原始输入+- `state/`:人工维护的本机状态和锁+- `secrets/`:仅本机保存的凭据材料+- `logs/`:当前运行日志+- `archive/`:历史迁移证据和备份+- `inbox/`:等待处理的临时导入+- `tools/`:FFmpeg 等本机托管运行时;二进制和许可证不进入 Gitdiff --git a/docs/HANDOFF.md b/docs/HANDOFF.mdindex 551e15563..445456b32 100644--- a/docs/HANDOFF.md+++ b/docs/HANDOFF.md@@ -1,293 +1,134 @@-# Handoff+# Peach 交接与长期工作约定-This is durable operating knowledge, not a per-session transcript.--## Zero-friction agent handoff--- Codex automatically discovers `AGENTS.md` in the project hierarchy.-- Claude Code automatically reads `CLAUDE.md`; this repository's `CLAUDE.md` imports `AGENTS.md`.-- Both agents therefore receive the same contract and the same mandatory reading order.-- Do not ask the outgoing agent to write a dated handoff. A task that changes reality must update `docs/STATUS.md`; a durable lesson changes this file or an ADR.-- Start every new task with `R:\peach-app` as the working directory and say only: “接手 Peach,按项目入口文件继续 STATUS 中的下一任务。”-- The user is not the message bus. Do not ask the user to copy technical conclusions to another agent; update the shared documents in the same change.-- If the worktree is dirty, inspect and preserve every existing diff. One agent owns a file while actively changing it; work on non-overlapping files or wait for that write to finish, then integrate the diff instead of recreating it.--## Parallel agent execution--- Codex is the coordinator for architecture, code ownership, review, migrations, real-ledger writes, service restarts and final verification. Claude is a parallel worker for bounded mechanical batches such as board reading, metadata candidate scraping and CSV reconciliation; handoff is not the goal.-- Parallel workers receive explicit input/output paths, network and cost policy, write boundary and acceptance criteria. They write `candidate` review artifacts only; they do not mark their own output `approved`, run `--apply`, alter migrations/ADR, or restart services.-- Use separate Git worktrees for concurrent code changes. Data-only batches may share the main checkout only when their sole writable artifact is outside Git and named in the task. Never let two agents edit the same file.-- The worktree is the edit buffer: run `python scripts/agent_worktree.py create --agent <agent> --task <slug>` from the integration checkout, do all edits/tests/commits in the returned path, then run `ready` there. The coordinating agent runs `integrate` only after review. “Last finisher automatically wins” is forbidden because completion order says nothing about dependency or correctness; Git three-way merge plus coordinator review is the arbitration layer.-- `bba0b77` is the concrete failure case. Codex did not use `git add .`, but still misclassified Claude's newly written `tests/test_scripts.py` as owned and staged it while leaving the required `scripts/probe.py` implementation unstaged. HEAD therefore contained a test for code that did not exist until Claude repaired it. Explicit filenames are necessary but insufficient: isolated worktrees, staged-path ownership review and implementation/test atomicity are mandatory.-- Never use `git add .`, `git add -A`, directory staging or globs. Before every worker commit, read `git diff --cached --name-status`; if any path was not assigned to that worker, unstage it. Workers do not merge, migrate the real ledger or restart production.-- Worker results return to the coordinating agent for vocabulary/provenance checks, deduplication, isolated tests and approval. The user does not relay reports between agents.-- `scripts/scrape_codes.py` and `scripts/creator_tags.py` are the standard review boundaries. Creator-board work exports `generated/creator-tags-review.csv`; workers may change `pending` to `candidate` or `skip`, while `approved` and the required backup remain coordinator actions.-- **Superseded 2026-08-14.** The earlier note that Claude refuses explicit sexual-act classification from- board images is not what happens. In one session Claude read 30 creator boards and assigned explicit- act and attribute tags for 27 creators — 4,518 videos, 27,295 `asset_tag` rows under `vision_creator`,- including 口交/足交/手交/乳交/骑乘/后入 — with no refusal, and a later reconciliation matched all 27- declared tag sets to the ledger exactly. Route board reading to Claude normally.-- The `ruth_lee` divergence was not a Claude/ledger disagreement either. The current ledger matches this- session's assignment exactly (7 tags × 310 assets). The mismatched conclusion came from an **earlier,- different** per-title pass that had no write step at all: `asset_tag` still holds zero rows with- `source='vision'`. The lesson is about persistence, not about model capability — see- "A conclusion that lives only in chat does not exist".--## Claude's actual boundary on this project--Stated so work is routed on fact rather than on a guessed refusal. Verified by what ran on 2026-08-14.--Does, without friction:--- Viewing explicit sexual imagery and classifying acts, attire, body attributes, setting and production- style, for cataloguing this personal library.-- Scraping public catalogue metadata (r18.dev, avsox, javbus) and mapping foreign categories to the- local vocabulary.-- Writing the code, regexes, batch jobs and reconciliation for all of the above, and generating- explicit-domain text such as tag names and Chinese titles.-- Naming a performer or studio from a code, filename, or an on-screen watermark or logo.--Will not, and these are firm:--- Anything involving minors or apparent minors. The library's 萝莉/学生/洛丽塔/制服 tags are treated- strictly as adult-performer genre labels; if real footage of a minor is ever found, the answer is to- stop and report it, not to catalogue it.-- Identifying a real person from their face. Attribution comes from codes, filenames, watermarks and- release metadata only — never from facial matching, and never linking media to a private individual's- real identity.-- Helping acquire or redistribute non-consensual material. This is not the current corpus state: the user- confirms all performers are adults and all material is consensual. `萝莉`/`学生`/`洛丽塔`/`制服`- describe adult role-play, while `泄露`/`流出` and the appearance of `G3104` are marketing/source-style- descriptions, not proof of provenance or consent. Catalogue those strings normally; only direct,- file-specific contradictory evidence warrants stopping and reporting.-- Destructive or outward-facing actions without explicit confirmation. Delete lists are produced as CSV- with evidence and confidence; the apply step is the user's.--Weak, not refused — route accordingly:--- Frame-level certainty from one still. Creator-level style inference is reliable; per-title claims from- a single frame are not, which is why `vision_creator` carries `confidence=0.6`.-- Reading dark, blurred or heavily mosaicked frames (`tuki_1154` was skipped for exactly this).-- Distinguishing a pirate-site watermark from an advertisement by filename alone — that needed an- extracted frame to settle (`jitumi.pw`).--## A conclusion that lives only in chat does not exist--Two failures of this shape occurred on 2026-08-14, so treat it as a rule.--An earlier per-title visual tagging pass read boards, stated its conclusions in conversation and said-they were stored. `asset_tag` holds zero rows with `source='vision'`; that pass had no write step and-left no CSV or log. Separately, `disposal-candidates.csv` was generated while `BNST033` was believed to-be entirely advertising. The belief was corrected in chat and in `docs/STATUS.md`, but the CSV was not-regenerated and still listed the genuine 3.2 GB feature `BNST033.mp4` for disposal.--Neither was a refusal — explicit tags including 足交/手交/足系 were written without obstruction in the-same session.--- A step that reaches a conclusion must write it to a file or the ledger in that same step.-- When a conclusion is revised, regenerate every artifact derived from it. Updating prose is not enough;- a stale delete list is more dangerous than no list.-- Record evidence beside the verdict. `ad-candidates.csv` carries a `verified` column naming the rows- confirmed by looking at an extracted frame, and a `排除` state for one row that proved to be real- content.-- Reconcile declared intent against the database before reporting completion. Comparing- `creator_tags.BOARDS` against actual `asset_tag` rows is what surfaced both problems.--Claude task endings are now covered by shared project hooks in `.claude/settings.json`: normal Stop,-StopFailure and SessionEnd invoke `scripts/job_status.py --write --hook-event`. The script records only a-sanitized lifecycle summary under `R:\peach-data\state`, recomputes every figure from the ledger and-generated artifacts, and atomically rewrites the `<!-- job-status -->` block in `docs/STATUS.md`. It does-not copy prompts, responses or credentials. Hard process kills and machine power loss cannot run a hook;-the next invocation repairs the live counts. Prose outside the managed block remains hand-maintained.--Codex does not currently expose an equivalent project task-completion hook. Its project contract still-requires the coordinating agent to update STATUS/HANDOFF in the same change; do not invent a brittle log-watcher to simulate lifecycle events.--## Referenced-product evidence register--“模仿/参考/对齐” requires current reproducible evidence before implementation. Record the source,-retrieval date/hash, exact behavior reused and intentional Peach deviation here. If evidence is not-available, write `未取得`; an approximation must not be described as a faithful reproduction.--- **Beeg card controls, verified 2026-08-15:** the current root loads- `https://beeg.com/dist/main.9442c3b8.css` (SHA-256- `E585B07CA0C312C28903DB939144B26A3C4BFBC9499F5997BDDE168A197CDB34`) and- `https://beeg.com/dist/main.9442c3b8.js` (SHA-256- `A7321F6E84D97417B588B6E98EEC86A15B30DC4C36B03537481CC55A4CF933E7`).- The verified counter is 36 px at top/right 12 px, uses `rgba(0,0,0,.24)`,- `saturate(180%) blur(12px)`, a 2 px white r=17 ring with circumference 106.814150222,- and scales to 1.2 on desktop hover. The save control uses the same translucent treatment at- bottom/right 12 px. Beeg starts the counter when preview playback is active and uses the preview- duration. Peach now also waits for a usable preview before showing/arming the ring, but intentionally- uses the user's five-second threshold before enlargement; metered still-image previews arm it when- frame cycling begins. The enlarged Peach overlay keeps centered -10/+10/detail controls because that- is the requested Peach interaction, not a claimed Beeg copy.-- **TikTok one-column transition, verified 2026-08-15:** the current page loads- `https://lf16-tiktok-web.tiktokcdn-us.com/obj/tiktok-web-tx/tiktok/webapp/main/react-v18/webapp-desktop/static/js/async/89993.30b4c2a9.js`- (SHA-256 `C4D4867C5C6C89DCE560D429A4686427C911267DCBB2787AEB31B7BD333E9088`).- Its current programmatic one-column scroll uses 200 ms, cubic-bezier(.2,.2,.4,.9), target- `offsetTop`, and temporarily disables/restores `scrollSnapType`. Peach reuses the measured duration- and easing for its two-video 100%-height track, while keeping its own preload and wheel/touch queue.-- **Apple transport controls, verified against the Apple HIG “Playing video” page on 2026-08-15:**- the evidence supports familiar, minimal transport controls and system-player semantics, but does not- provide reusable web SVG source for `gobackward.10`/`goforward.10`. Peach therefore uses its pinned- local icon subset plus explicit “后退/前进 10 秒” accessible labels; it does not claim an exact iOS- glyph copy.-- **Rule34 styling:** earlier code comments claimed Rule34-style tag colors without recorded DOM/CSS- evidence. Those claims were removed. Peach's tag colors are its own semantic categories.-- **CodexBar/T3 usage:** this is a reuse decision, not a copied Peach UI. CodexBar's public CLI/provider- documentation confirms local Claude/Codex cost aggregation; T3 Code's public README and the user's- current Usage screen establish the existing history surface. Peach has no token-log scanner or copied- dashboard implementation. Live remaining windows must still come from official provider surfaces.-- **Vercel design guidance, fetched 2026-08-15:** `https://vercel.com/design.md` (SHA-256- `07ED2923294AA326F65F9D9D4094B6E97BF7DE10C39ACD8BE935F2045C5A688F`) is used as a review- checklist, not a component source. Applied rules: establish hierarchy with type and spacing before- surfaces, keep one continuous canvas, avoid arbitrary icon tiles/nested cards/tiny muted copy, and use- motion only for state or continuity. Peach keeps functional source badges, filter tags and video-overlay- translucency because they encode state or preserve legibility over moving imagery.-- **kill-ai-slop, reviewed at commit `96d1ca568a1db7e1ef9a381644c744440f816ee4` on- 2026-08-15:** the Apache-2.0 project was used as a subtractive audit checklist. The current pass removes- the decorative page gradient, frosted navigation/drawer, excessive pill radii and an unnecessary nested- preference panel. It does not install the agent skill or copy its scanner into Peach.-- **Lucide Icons:** action and navigation glyphs use a pinned local subset of `lucide-static` 1.31.0- (ISC, npm integrity- `sha512-XFX9NO+gcLsOkXISmeQZYGJa2siGWZc/lgT/BK1b83h9RdOiz3cj1eQP5nWhELiB1KhW5ryk0nmMopOgm/CuSA==`).- The paths are embedded in `web/index.html`; attribution is in `web/vendor/lucide-LICENSE.txt`.- Brand/source marks and the timed preview ring remain separate because they are identities or data- visualizations, not general-purpose interface icons.--## Agent capacity and usage routing--- Use official quota windows for dispatch decisions, not API-equivalent dollar estimates. Codex exposes- live limits through App Server `account/rateLimits/read`; Claude usage is visible through Claude Code's- authenticated usage surface. Never print, copy or persist OAuth access tokens.-- T3 Code already provides the useful historical dashboard for Codex + Claude processed/cached/output- tokens and API-equivalent costs. CodexBar is the reference implementation for local log accounting and- provider quota fallback. Peach must not recreate their session-log scanner or couple to T3 Code's- undocumented localhost RPC.-- Route architecture, migrations, browser-dependent websites, final review/apply and long-running work to- Codex. Route bounded mechanical scraping, normalization, candidate CSV reconciliation, filename/code/- watermark extraction and reviewed board classification to Claude when its remaining window permits.-- Creator/performer attribution may use release codes, filenames, watermarks, studio metadata, aliases,- public profile links and cross-source consistency. A face may support same-library consistency review,- but a persisted identity requires non-face corroboration; never link media to an unrelated private- person's real-world identity from facial appearance alone.--Report backlog counts as **actionable / blocked / total**, never as a single number. "4,740" and-"10,196" were treated as contradictory PikPak figures when both were correct: 4,740 rows carry a-duration and can be sheeted, 5,445 carry none and need a probe pass first. `job_status.py` always prints-all three.--## A failure written as a plausible value is a permanent stall--`probe.py` persisted "ffprobe returned no duration" as `duration=0`. That is not a null and not a-failure marker, so the row vanished from probe's own `duration IS NULL` queue *and* failed the sheets-`duration>2` gate. 3,937 of the 4,034 blocked 115 rows lived in that gap for as long as the two-contradictory-looking status lines did. Nothing logged an error; the backlog simply never moved.--- A failed measurement must be stored as something no downstream query can mistake for a result.- `-1` is such a value here; `0`, `""` and `0.0` are not.-- Any job that writes a fact layer needs an explicit way to re-run over recorded failures- (`--redo zero|failed|all`), because the reason for failure is usually external and temporary — in- this case the CloudDrive mount was not visible to the process token that ran the original pass.-- When two status numbers look contradictory, suspect a state that neither query covers before- assuming one of them is wrong.--## Transfer cost is the real batch constraint, and it is measured per source--Verified 2026-08-15 against the mihomo connection counter, five files plus a 115 control:--| Source | Route | ffprobe one file | Nine-frame contact sheet |-| --- | --- | ---: | ---: |-| 115 | DIRECT `cdnfhnfile.115cdn.net` | ~25 MB | ~285 MB (1,074 MB source) |-| PikPak | proxied `*.mypikpak.net` | 12–52 MB | 163 MB / 13.7 s (385 MB source) |--- The older "25~40 s per PikPak frame, full extraction is 14 days" record does not reproduce. Measured- cost is ~18 MB and ~1.5 s per frame; the binding constraint is bytes, not wall clock. Full PikPak- sheeting is ~773 GB, a full PikPak probe pass ~207 GB, and creator sampling of 88 boards ~14 GB.-- `-probesize`/`-analyzeduration` do not reduce any of it. The traffic arrives as CloudDrive block- prefetches in fixed ~12.9 MiB units fanned across several CDN nodes, which is below FFmpeg's control.- Do not re-derive this by re-measuring; change the block behavior in CloudDrive or accept the cost.-- Creator boards (`--from-video`) fall back to a 60-second seek when duration is unknown, so creator- sampling does **not** require a probe pass first. That ordering saves the entire ~207 GB probe cost.-- The resident 200 GB sentinel counts proxy bytes only, which does cover PikPak. It does not see 115 at- all: the 98 GB spent probing 115 on 2026-08-15 was invisible to every ceiling. Use `--count-direct`- when the budget must cover a direct-routed source, and remember that mode cannot tell sources apart —- never run a 115 batch under a direct-counting PikPak ceiling, or 115 will trip it.--## Reuse before restore--- Read `docs/REUSE.md` before introducing a library, protocol implementation or restored legacy script.-- Search the current tree by capability and output contract, not only by the old filename. `scripts/scrape_codes.py` is the maintained successor to the removed `rm-javlookup.py`; restoring the old scraper is forbidden.-- The restructure was not a clean-room rewrite: probe, sheets, status, suggest, traffic watch, SHA1 sync, ledger and the web surface were migrated from legacy implementations. Treat them as inherited code until their behavior has been deliberately replaced and tested.-- Git history is recovery evidence, not an implementation catalog. Restore code only after proving no current successor or mature dependency covers the capability.--## Data safety--- Real ledger: `R:\peach-data\database\ledger.db`; WAL mode; normal browsing legitimately changes play/activity fields.-- Tests must create temporary SQLite databases and temporary media files.-- Before real migration: SQLite backup, asset/tag counts, `PRAGMA integrity_check`, migration version check, then service smoke test.-- Formal migrations `0000`–`0007` are applied to the real ledger. `0003` adds the local default profile, profile-scoped watch queue, typed entity links and entity search terms. `0004` adds synchronized SQLite FTS5 trigram search. `0005` backfills late compatibility tags into canonical relations. `0006` adds profile-scoped `asset_preference`. `0007` removes reviewed structural folder names (`门槛`, `视频`, `宣传文件`) from creator identity without deleting assets. Retain the pre-migration backups until a later verified migration.-- Media and runtime data remain under `R:\media` and `R:\peach-data`; they are not repository assets.--## Operations--- Main command: `peach serve|migrate` after editable installation. Windows 日常入口是当前用户- Startup 中的 `Peach.lnk`,它用项目 venv 的 `pythonw.exe -m peach.tray` 启动交互式托盘;- 不要同时新增系统服务、计划任务或注册表 Run 项。托盘单击打开 HTTPS,右键提供状态、- 重启、日志、检查更新和退出。它用进程期文件锁拒绝重复实例,并只终止自己创建的服务进程。-- 托盘必须在创建 Win32 窗口前启用 Per-Monitor V2 DPI;不要用清单缺失的 DPI-unaware- `pythonw` 进程让 Windows 位图缩放原生菜单。正常托盘动作不得弹模态 MessageBox。版本与- 更新子菜单读取缓存快照,显式检查在后台线程执行,通过 pystray 原生非模态通知反馈。-- `src/peach/__init__.py::__version__` 是版本唯一来源,`pyproject.toml` 用 setuptools- dynamic attr 生成包版本,FastAPI 和托盘都读取同一值。当前采用 pre-1.0 SemVer:修复升- patch,兼容功能升 minor,破坏性数据/接口变化升 minor 并配 ADR/迁移。Git 提交是构建标识,- `vX.Y.Z` 是本地发布点。检查更新只 fetch/比较;自动安装在并行工作树模型下保持禁用。-- `scripts/manage_tray_startup.ps1` 是唯一自启动安装/状态/卸载入口。托盘同时管理 HTTP- `0.0.0.0:80`(负责 mDNS)和 HTTPS `192.168.50.162:443`;LAN 地址可用- `PEACH_LAN_ADDRESS` 覆盖。服务输出追加到 `R:\peach-data\logs\tray-*.log`。仓库当前没有- Git remote,因此“检查更新”只报告本地提交和无更新源,不伪造自动升级能力。-- `peach serve` 默认用 Python zeroconf 发布唯一入口 `peach.local`;使用 `--no-mdns` 可关闭。必须保留迁移前已验证的 `Zeroconf()` 全合格网卡监听语义,不要改用只能发布服务/SRV 的 Windows `DnsServiceRegister`。隧道软件可能让自动路由选择落到 `198.18.0.0/15`;生产启动因此显式传 `--mdns-address 192.168.50.162`,只固定发布的 A 地址,不缩窄 Zeroconf 监听接口。注册在 FastAPI lifespan 中执行,不能在事件循环内同步阻塞。mDNS 修改的验收门槛是:单元测试、运行态 health、DNS-SD 查询、主机名解析,以及一台真实 LAN 客户端;监听端口枚举或注册回调不能单独证明可用。-- TLS 仅在同时提供 `--ssl-certfile` 和 `--ssl-keyfile` 时启用;`.local` 使用本地 CA,不使用 Let's Encrypt,证书和私钥留在 `R:\peach-data\secrets`。本地 CA 必须带 critical `CA:TRUE` 和 `keyCertSign,cRLSign`;生成脚本签发后必须用 OpenSSL 验证链。macOS/iOS 只安装并信任 `peach-local-ca.crt`,不得分发 CA key 或服务器 key。-- FastAPI is the only Web server. `web_contract.py` contains the stable JSON surface; do not recreate a parallel `http.server` or dynamic legacy loader.-- FFmpeg/ffprobe resolve from explicit environment overrides, then `R:\peach-data\tools\ffmpeg\bin`, then `PATH`. No active code may fall back to the Stash private directory.-- Long-running inventory helpers are under `scripts/`; their scheduled tasks use `R:\peach-app\.venv\Scripts\python.exe`. They use absolute data paths and may be interrupted/restarted where their own locking contract allows it.-- Probe, sheets, creator boards and traffic watch parse arguments only inside `main()`. They share `src/peach/jobs.py` for fail-closed disk checks, parameterized source policy and PID locks. Traffic watch stops only matching Peach Python process trees; never restore machine-wide ffmpeg termination.-- Stash, OpenCode Go, Feed, code scraping and performer-image imports use the shared HTTPX transport. Feed XML is parsed by feedparser, raster images by Pillow and source HTML by Beautiful Soup. New adapters must reuse these boundaries instead of adding urllib helpers, manual image headers or HTML regex parsing.-- Importing operational scripts must have no filesystem/network/database side effects. `scrape_codes.py` sends only catalog codes to declared metadata sources, writes a resumable review CSV, and dual-writes provenance only with `--apply`. `clean_names.py` previews first and creates a SQLite backup before every apply run.-- Check ports 80, 8900 and 9999 before starting or switching services.-- 115/PikPak playback depends on CloudDrive mounts `B:`/`A:`. Drive-letter visibility differs by Windows execution token; CloudDrive and Peach must see the same mount namespace. A running process or a drive check from another token proves nothing—test one known `/stream` through Peach. Restart CloudDrive only after proving no copy task and no active I/O.-- Browser-incompatible local/cloud containers are adapted by `TranscodeService`, not by Stash and not by front-end MIME guessing. Native MP4/WebM/Ogg stays direct; AVI and other unsupported suffixes are cached under `generated/transcodes` as H.264/AAC MP4 using a source size/mtime key, then served by the same Range endpoint. Never overwrite source media. A sandbox drive check is not authoritative because CloudDrive letters can be token-scoped.-- Never interpolate database metadata into inline JavaScript event attributes. Bind events after DOM insertion and keep metadata in text/data nodes; apostrophes in real studio names already caused a Firefox syntax failure.-- Ledger snapshot paths written before the project/data split are rebased by an exact configured legacy prefix. Do not add basename searches or arbitrary path fallbacks.-- Report verification separately: static/unit/API, desktop browser, 390×844 browser, and whether production was actually restarted.--## Architectural truth--- Ledger owns truth and behavior.-- Stash is a replaceable adapter; do not add new direct GraphQL helpers or private Stash FFmpeg paths.-- All Stash calls use `StashClient`. Imports persist the stable Scene ID and provenance in `media_binding`; do not regress to `stash_scene_id` as the only external reference.-- Canonical performer/studio/tag/creator truth belongs in `entity`, `entity_external_ref` and `asset_entity`. Flattened `asset_tag` rows are a temporary compatibility projection, not the target model.-- Item/detail/filter/search/facets/index/stats/top lists/related ranking use canonical relations. Flattened creator/studio fields remain only as response compatibility projections; do not use them for identity or matching.-- Performer/studio/creator/series names navigate to entity pages; only content tags are direct homepage filters. `entity_link.source_reference` is private provenance and must not become a clickable download link. “稍后看” writes `watch_queue`, never feedback. “喜欢/为什么喜欢” writes profile-scoped `asset_preference`; the note is user truth, while any future AI-derived taste facets must be stored separately with provenance/confidence/review.-- Navigation versus filtering is visually explicit: “换一批”, statistics, immerse, all-performers and all-tags are actions/destinations and never render as persistent filter state. The desktop rail reserves its large icons for destinations/actions; `看过`/`没看过` remain compact content-state chips. Main-list pagination is automatic, not a bottom “再来 60 个” button.-- Long-card enlargement and seek controls require five continuous hover seconds. Short cards keep immediate “稍后看”. A creator/studio/performer text link consumes the click and opens the entity page; it must never bubble into video expansion.-- Card identity is performer-first: use `performer_entities` for the portrait and performer-page link before falling back to creator/studio representative art. Keep this payload consistent across normal, related and review queues. Back buttons use the shared `backbtn`; closing the drawer for navigation must suppress immediate rail-hover reopening.-- Like and the private reason remain one profile preference. A non-empty reason implies Like, but the saved prose is not itself a ranking feature until a provenance-backed taste-facet pipeline exists; UI copy must not claim otherwise.-- Detail identity uses one compact row per entity, with a small performer portrait or studio logo immediately before its label; it is not a standalone bordered card. Legacy length labels (`短片-2分内` / `中片-10分内` / `长片-30分内` / `超长片`) stay in compatibility data but are not UI tags or facets; duration filtering is numeric minutes only.-- Detail feedback is a compact icon toolbar backed by the pinned Lucide set. Like/dislike/seen/Later/deletion candidate use accessible labels, hover explanations, semantic hover/active color and restrained motion. Later is not a separate full-width action. Orgasm count remains a separate icon row. “待删” always means candidate-only; actual deletion is a later reviewed CSV apply step.-- The desktop filter drawer may open only after the pointer enters the visible 72 px rail. Do not restore a hidden content-area hot zone.-- Source and studio marks use cached official assets with provenance. Missing studio logos show initials, never an arbitrary work/avatar. Current canonical studio coverage is 28/114 after the official kawaii asset was added (S1 was already cached); continue through the review queue instead of inventing logos.-- Entity portraits resolve `generated/avatars/<kind>-<entity_id>.img` first and carry content-type/provenance sidecars. Do not accept Stash's default SVG silhouette or search-result thumbnails as portraits; representative asset crops are fallback only.-- `scripts/import_stash_entities.py` is the transitional performer identity importer. It uses `StashClient`, exact canonical-name matches, stable external refs, dry-run by default and a required backup on apply. Only localhost Stash image URLs are accepted; placeholders and images below a 512 px short side are rejected. Only aliases explicitly marked `X:`/`Twitter:` become social links; plain `@handle` remains a search term because its network is ambiguous.-- Reviewed studio merging runs through `scripts/canonicalize_studios.py` (dry-run by default, backup required for apply). `PREMIUM` is a distinct studio; only Prestige Premium and Japanese Prestige spellings alias to `Prestige`.-- Keep FastAPI and the front end logically separate but deploy as a monolith.-- External sources and AI are supported only through explicit adapters and declared data boundaries.-- `FeedAdapter` is the first online-follow connector. It performs explicit bounded RSS/Atom discovery; `FeedSnapshotStore` separates immutable evidence under `sources/follow` from conditional-request cursors under `state/follow`. Do not make it poll on application startup or write ledger rows directly.-- AI provider layers are not equivalent: inference APIs and local coding/agent runtimes remain separate.-- Search terms of three or more characters use FTS5 trigram; shorter text falls back to LIKE because trigram cannot index shorter terms. FTS writes are maintained by migration triggers, not by Web startup repair.--## Recovery--Deprecated scripts and old dated documents were removed from the active tree during the `peach-app` restructure. They remain recoverable from Git history before the restructure commit. Former `_SHARED_STATE` content lives under `R:\peach-data\state`; it is deliberately outside version control. The pre-restructure root repository metadata is retained temporarily under `R:\peach-data\archive\peach-root-repo-backup-20260814` as a recovery copy.+本文件只保存跨任务长期有效的事实和工作规则,不记录逐次聊天流水。++## 无摩擦接手++- Codex 自动读取项目层级中的 `AGENTS.md`;Claude Code 通过 `CLAUDE.md` 导入同一文件。+- 两个智能体使用同一入口、同一必读顺序,不再生成按日期命名的临时交接文档。+- 新任务直接以 `R:\peach-app` 为工作目录,并说:“接手 Peach,按项目入口文件继续 STATUS 中的下一任务。”+- 改变运行事实的任务同时更新 `docs/STATUS.md`;长期规则更新本文件、`docs/REUSE.md` 或 ADR。+- 用户不是消息中转站。结论、进度、待办和证据必须写入共享文档或机器可读产物。+- 面向用户阅读的文档叙述统一使用中文;代码标识、命令、协议和专有名词保留英文。++## 并行智能体与 Git 工作树++- Codex 负责架构、文件归属、审核、迁移、真实 ledger 写入、服务重启和最终验收;Claude 适合并行执行抽帧板阅读、候选元数据刮削、CSV 对账等边界明确的机械批次。+- 并行任务必须给出输入/输出路径、网络和费用策略、写入边界、验收条件。工作者只产出 `candidate`,不得自行标为 `approved`、执行 `--apply`、改迁移/ADR 或重启服务。+- 并行代码改动使用 `scripts/agent_worktree.py create` 创建独立 worktree。工作者提交并运行 `ready`;协调者审核后运行 `integrate`。完成顺序不能决定覆盖顺序。+- 禁止 `git add .`、`git add -A`、目录或 glob 暂存。只暂存任务明确拥有的文件,并检查 `git diff --cached --name-status`。测试和对应实现必须原子提交。+- `bba0b77` 是已发生的反例:测试被误判为本任务文件而进入提交,对应 `probe.py` 未暂存,导致 HEAD 出现“测试指向不存在实现”。独立 worktree、暂存路径复核和实现/测试原子性因此是强制规则。+- 在 worktree 运行测试时,项目 venv 的 editable install 可能仍指向主目录。必须设置 `PYTHONPATH=<当前工作树>\src`,先输出 `peach.__file__` 核对来源,再运行测试。++## Claude 在本项目中的实际能力边界++2026-08-14 的真实执行证明 Claude 可以正常完成:++- 查看成人内容并分类行为、着装、身体属性、场景和制作风格;+- 从公开番号库刮削元数据并映射本地词表;+- 编写上述领域的代码、正则、批处理、对账和中文文本;+- 根据番号、文件名、画面水印、Logo 或发行元数据识别女优和厂牌。++此前“Claude 会拒绝露骨行为分类”的记录已废止。一次实际任务读取 30 张创作者板,为 27 位创作者、4,518 个视频写入 27,295 条 `vision_creator` 标签,含口交、足交、手交、乳交、骑乘和后入,最终 27/27 与 ledger 对账一致。++仍需遵守的边界:++- 不处理真实未成年人;本库经用户确认只有成年人。`萝莉`、`学生`、`洛丽塔`、`制服` 是成年角色扮演/题材标签,不能仅凭这些字符串停止编目。+- 不从人脸识别私人真实身份。持久归属必须有番号、文件名、水印、厂牌、公开链接等非人脸证据。+- 本库经用户确认均为自愿成人内容。`泄露`、`流出`、`G3104` 等是营销或来源风格词,不是非自愿证据;只有文件级直接反证才停止并报告。+- 删除和其他不可逆/对外动作先生成带证据和置信度的复核产物,执行步骤单独授权。+- 单帧逐条判断、过暗/模糊画面、仅靠文件名区分片源水印与广告都属于弱项,应降低置信度或补抽帧,不应伪装成确定事实。++## 只存在于聊天中的结论等于不存在++- 得出结论的同一步必须写入 ledger、CSV 或其他持久产物。+- 结论被修正时,所有派生产物必须重建;只改说明文字不够。过期删除清单比没有清单更危险。+- verdict 旁必须保存证据和来源;完成前把声明意图与数据库实际行对账。+- 历史视觉逐条任务曾在聊天里说“已保存”,但 `asset_tag` 中 `source='vision'` 为 0;根因是根本没有写入步骤,不是模型拒绝。+- `disposal-candidates.csv` 曾在 `BNST033` 判断修正后未重建,仍把真实 3.2 GB 正片列为待删;这是必须同步所有派生产物的直接证据。++Claude 的 `.claude/settings.json` 已配置 Stop、StopFailure、SessionEnd hook,调用 `scripts/job_status.py --write --hook-event`。脚本只记录脱敏生命周期摘要,重新从 ledger/产物计算数字,并原子更新 `docs/STATUS.md` 的 `<!-- job-status -->` 受管区块;不复制 prompt、response 或凭据。强制杀进程/断电无法运行 hook,下次调用会修复计数。Codex 暂无等价项目结束 hook,仍由协调者在同一改动里更新文档;不要用脆弱日志监听器模拟。++## 参考产品证据登记++凡用户要求“模仿/参考/对齐”,必须先取得当前可复现证据:实时行为加 DOM/CSS/JS;源码不可得时才使用精确截图测量。记录 URL、日期、版本/hash、复用行为和 Peach 的主动差异。证据不可得就写 `未取得`,不得把猜测描述成忠实复刻。++- **Beeg 卡片控件(2026-08-15)**:当前根页面加载 `https://beeg.com/dist/main.9442c3b8.css`(SHA-256 `E585B07CA0C312C28903DB939144B26A3C4BFBC9499F5997BDDE168A197CDB34`)和 `main.9442c3b8.js`(SHA-256 `A7321F6E84D97417B588B6E98EEC86A15B30DC4C36B03537481CC55A4CF933E7`)。计时圈为 36 px、上/右 12 px、`rgba(0,0,0,.24)`、`saturate(180%) blur(12px)`、2 px 白色圆环;桌面 hover 放大 1.2。稍后看控件使用同类透明处理,位于右下 12 px。Peach 等到预览可用后才启用计时圈,按用户要求连续悬停 5 秒才放大;放大层保留 Peach 自己的居中 -10/+10/详情控件。+- **Beeg 表面层(2026-08-15,同一 CSS/hash)**:暗色背景 `rgb(2,4,8)`,表面 `rgb(34,34,34)`;frost utility 使用 `rgba(38,40,44,.72)` + `saturate(1.8) blur(20px)`,以及 `rgba(30,30,30,.72)` + `blur(20px)`。Peach 使用这些实测值制作克制的侧栏/抽屉垂直插值和半透明粘性栏;插值是 Peach 主动适配,不声称 Beeg 使用完全相同的渐变。+- **TikTok 单列滚动(2026-08-15)**:当前 bundle `async/89993.30b4c2a9.js`(SHA-256 `C4D4867C5C6C89DCE560D429A4686427C911267DCBB2787AEB31B7BD333E9088`)使用 200 ms、`cubic-bezier(.2,.2,.4,.9)`、目标 `offsetTop`,滚动时临时禁用并恢复 `scrollSnapType`。Peach 复用时长和 easing,保留自己的两视频预载与 wheel/touch 队列。+- **Apple 播放控件(2026-08-15)**:Apple HIG “Playing video” 只支持熟悉、克制的传输控制语义,没有提供可复用的 `gobackward.10`/`goforward.10` Web SVG。Peach 使用固定版本的 Lucide 子集和明确的“后退/前进 10 秒”无障碍标签,不声称精确复制 iOS glyph。+- **Vercel 设计规范(2026-08-15)**:`https://vercel.com/design.md`(SHA-256 `07ED2923294AA326F65F9D9D4094B6E97BF7DE10C39ACD8BE935F2045C5A688F`)只作为评审清单:先用字体和间距建立层级、保持连续画布、避免任意图标瓷砖/嵌套卡片/微小灰字,动画只表达状态或连续性。+- **kill-ai-slop**:在 commit `96d1ca568a1db7e1ef9a381644c744440f816ee4` 上作为减法审计清单使用,不安装 skill、不复制 scanner。+- **Lucide**:通用操作和导航图标使用固定本地 `lucide-static` 1.31.0 子集(ISC);许可见 `web/vendor/lucide-LICENSE.txt`。品牌/来源 Logo 和计时圈不属于通用图标。+- **Rule34 样式**:旧代码注释没有 DOM/CSS 证据,已删除“Rule34-style”声明。当前标签颜色是 Peach 自有语义。+- **T3 Code/CodexBar 用量**:这是复用决策,不是 Peach UI 复制。T3 Code 已提供 Codex + Claude 历史 token/成本界面;实时剩余额度使用官方 Provider 入口,Peach 不再造日志扫描器。++## 智能体用量与任务路由++- 调度看官方配额窗口,不看 API 等价美元估算。Codex 使用 App Server `account/rateLimits/read`;Claude 使用 Claude Code 已登录用量界面。不得打印、复制或保存 OAuth token。+- Codex 负责架构、迁移、浏览器依赖网站、最终 review/apply 和长期任务;Claude 负责边界明确的刮削、归一化、候选 CSV 对账、文件名/番号/水印提取和经复核的风格板分类。+- 女优/创作者归属可使用发行番号、文件名、水印、厂牌、别名、公开链接和跨来源一致性。人脸最多用于同库一致性辅助,持久身份仍需非人脸证据。+- 待办数量统一报告“可执行 / 被阻塞 / 合计”。例如 PikPak 的 4,740 与 10,196 不是矛盾:前者有时长可抽帧,另有 5,445 条缺时长需先 probe。++## 批处理失败值与流量边界++- 测量失败不能写成下游可误认的正常值。`probe.py` 曾把“ffprobe 无时长”写成 `duration=0`,导致数据同时退出 `duration IS NULL` probe 队列又进不了 `duration>2` 抽帧队列。现在失败写 `-1`,并提供 `--redo zero|failed|all`。+- 两组状态数字看似矛盾时,先查是否有两边查询都遗漏的状态,不要直接认定其中一组错误。+- 2026-08-15 经 mihomo 实测:115 单文件 ffprobe 约 25 MB,九帧接触表约 285 MB;PikPak 单文件 probe 12–52 MB,九帧约 163 MB/13.7 秒。PikPak 抽帧的主要约束是字节而非耗时。+- `-probesize`/`-analyzeduration` 无法减少 CloudDrive 固定块预取。创作者板在未知时长时可回退到 60 秒 seek,因此无需先花约 207 GB 做全量 PikPak probe。+- 200 GB 守卫默认只统计代理流量,能覆盖 PikPak,不能看到直连 115;需要覆盖直连来源时显式使用 `--count-direct`,且不要在同一直接计量窗口混跑不同来源。++## 数据安全++- 真实 ledger:`R:\peach-data\database\ledger.db`,WAL 模式。正常浏览会合法写入播放/行为字段。+- 测试必须使用临时 SQLite 和临时媒体;不得写真实 ledger。+- 真实迁移前依次执行 SQLite 备份、asset/tag 计数、`PRAGMA integrity_check`、迁移版本检查、服务 smoke test。+- 正式迁移 `0000`–`0007` 已应用。`0003` 增加默认 profile、稍后看、实体链接和搜索词;`0004` 增加 FTS5 trigram;`0005` 回填晚到兼容标签;`0006` 增加 `asset_preference`;`0007` 从创作者身份中移除结构文件夹名 `门槛`、`视频`、`宣传文件`,不删除作品。+- 媒体和运行数据只在 `R:\media`、`R:\peach-data`,不进入仓库。++## 运行与部署++- 日常入口是当前用户 Startup 中的 `Peach.lnk`,使用项目 venv 的 `pythonw.exe -m peach.tray`。不再并存系统服务、计划任务或注册表 Run。+- 托盘单击打开 HTTPS;菜单提供状态、重启、日志、更新检查和退出。托盘只终止自己创建的 Peach 服务进程。+- 创建 Win32 窗口前必须启用 Per-Monitor V2 DPI。正常动作不弹模态 MessageBox;更新检查在后台线程执行,用 pystray 原生非模态通知反馈。+- `src/peach/__init__.py::__version__` 是版本唯一来源;采用 pre-1.0 SemVer。Git commit 是构建标识,`vX.Y.Z` 是本地发布点。更新检查只 fetch/比较,并行 worktree 模式下不自动覆盖安装。+- `scripts/manage_tray_startup.ps1` 是唯一自启动管理入口。托盘管理 HTTP `0.0.0.0:80` 和 HTTPS `192.168.50.162:443`,服务日志写入 `R:\peach-data\logs\tray-*.log`。+- `peach serve` 用 Python zeroconf 发布唯一入口 `peach.local`;生产显式使用 `--mdns-address 192.168.50.162` 固定 A 地址,但保留 `Zeroconf()` 全合格网卡监听。mDNS 验收必须包含单元测试、运行态 health、DNS-SD、主机名解析和真实 LAN 客户端。+- `.local` 使用本地 CA,不使用 Let's Encrypt。证书/私钥保存在 `R:\peach-data\secrets`。macOS/iOS 只安装并信任 `peach-local-ca.crt`,不得分发 CA key 或服务器 key。+- FastAPI 是唯一 Web server。不得恢复平行 `http.server` 或动态 legacy loader。+- FFmpeg/ffprobe 依次从显式环境变量、`R:\peach-data\tools\ffmpeg\bin`、`PATH` 解析;不得回退到 Stash 私有目录。+- 长任务只停止自己拥有且命令行匹配的 Python/FFmpeg 进程树,禁止全机终止 FFmpeg。+- 导入运维脚本不得触发文件、网络或数据库副作用。`scrape_codes.py` 默认写可续跑复核 CSV;`clean_names.py` 先预览,`--apply` 前备份 SQLite。+- 切换服务前检查 80、443、8900、9999 端口和实际进程归属。+- 115/PikPak 播放依赖 CloudDrive 的 `B:`/`A:`;盘符对 Windows token 可见性不同,最终以 Peach 对已知作品的 `/stream` 实测为准。+- 浏览器不支持的 AVI 等容器由 `TranscodeService` 缓存为 H.264/AAC MP4,再通过同一 Range 端点提供;永不改写原媒体。+- 数据库元数据不得插值到 inline JavaScript 事件属性。真实厂牌名中的撇号曾直接造成 Firefox 语法错误。+- 验证分开报告:静态/单元/API、桌面浏览器、390×844 手机、生产服务是否已重启。++## 当前架构真相++- Ledger 拥有真相和行为;Stash 是可替换适配器,不新增直接 GraphQL helper 或 Stash 私有 FFmpeg 路径。+- Stash 调用统一经过 `StashClient`;外部 Scene ID 和来源进入 `media_binding`。+- 规范女优/厂牌/标签/创作者进入 `entity`、`entity_external_ref`、`asset_entity`;扁平 `asset_tag` 和 creator/studio 字段只是兼容投影。+- 详情、筛选、搜索、facets、索引、统计、榜单和相关推荐使用规范关系。+- 女优、厂牌、创作者、系列名称进入资料页;只有内容标签直接筛选首页。`source_reference` 是私有来源,不开放为下载链接。+- “稍后看”写 `watch_queue`;“喜欢/为什么喜欢”写 profile 级 `asset_preference`。AI 只能把口味说明转成带来源/置信度/复核状态的候选,不能改写用户原文。+- Web 公共路由使用 `/performers/{name}`、`/studios/{name}`、`/creators/{name}`、`/series/{name}`;删除 `/entity/{kind}/{name}`。收起详情或导航离开时必须 pause、清空 `src`、调用 `load()` 并移除 video,不能只隐藏 DOM。+- “换一批”、统计、沉浸、全部女优、全部标签是动作/目的地,不显示为持续筛选状态。`看过`/`没看过` 只保留为紧凑状态 chip。+- 长卡连续 hover 5 秒才放大并显示 seek;短卡立即提供“稍后看”。实体文字链接必须消费点击,不能冒泡为展开视频。+- 卡片身份女优优先:先使用 `performer_entities` 头像和链接,再回退到创作者/厂牌代表图。+- 喜欢与原因属于同一 profile 偏好;非空原因隐含喜欢,但原文不能直接冒充推荐特征。+- 详情实体采用一行一个身份,小头像/Logo 紧邻名称,不使用独立大边框卡片。旧短/中/长片标签不再显示,时长筛选只使用分钟区间。+- 反馈使用 Lucide 紧凑图标工具栏。“待删”只表示候选,真正删除必须经过复核 CSV 的独立 apply。+- 桌面筛选抽屉只在指针进入可见 72 px 侧栏后打开,不恢复内容区隐藏热区。+- 厂牌 Logo 使用带来源的官方缓存;缺失时显示首字母,不得用任意作品图冒充。当前规范厂牌覆盖 28/114,继续走复核队列。+- 实体头像优先 `generated/avatars/<kind>-<entity_id>.img`;Stash 默认剪影和搜索结果缩略图不能作为头像。+- 厂牌归一化使用 `scripts/canonicalize_studios.py`,默认 dry-run,apply 前备份。`PREMIUM` 是独立厂牌;只把 Prestige Premium 和日文 Prestige 写法归并到 `Prestige`。+- FastAPI 与前端逻辑分离、单体部署;在线来源和 AI 只通过显式适配器进入。+- `FeedAdapter` 是首个追更连接器,显式、有界发现 RSS/Atom;不在应用启动时轮询,不直接写 ledger。+- AI 推理 API 与本地 coding/agent runtime 是不同层,不能伪装成一个等价接口。+- 3 字符以上搜索使用 FTS5 trigram;更短文本回退 LIKE。FTS 写入由迁移 trigger 维护,不在 Web 启动时修补。++## 恢复入口++项目重构时已从活动目录删除 deprecated 脚本和按日期文档,Git 历史仍可恢复。旧 `_SHARED_STATE` 已迁到 `R:\peach-data\state`。重构前根仓库元数据暂存于 `R:\peach-data\archive\peach-root-repo-backup-20260814`,仅作恢复证据。diff --git a/docs/REUSE.md b/docs/REUSE.mdindex b880addbf..1c0d9eefe 100644--- a/docs/REUSE.md+++ b/docs/REUSE.md@@ -1,63 +1,63 @@-# Reuse register+# 复用清单-This file is the implementation lookup table shared by Codex and Claude. Check it before adding or restoring code.+这是 Codex 与 Claude 共用的实现查找表。新增或恢复代码前必须先查本文件。-## Peach-owned domain logic+## Peach 必须自研的领域逻辑-These are product behavior and remain custom:+以下属于产品行为,继续由 Peach 实现:-- canonical performer/studio/creator/tag identity, aliases and provenance;-- profile behavior, watch queue, taste and recommendation ranking;-- local/115/PikPak/Stash/online binding and fallback policy;-- metered-source authorization, privacy classification and reviewed candidate import;-- private acquisition/source references and discovery keywords;-- creator-level visual sampling semantics;-- inference-provider versus agent-provider capability contracts;-- job ownership, progress, cancellation, cost and evidence rules.+- 女优、厂牌、创作者、标签的规范身份、别名和来源;+- profile 行为、稍后看、口味和推荐排序;+- 本地、115、PikPak、Stash、在线来源的绑定和回退策略;+- 计费来源授权、隐私分类和候选复核导入;+- 私有获取来源、出处引用和发现关键词;+- 创作者级视觉采样语义;+- 推理 Provider 与 Agent Provider 的能力契约;+- 任务归属、进度、取消、成本和证据规则。-## Required reuse+## 必须复用的成熟实现-| Capability | Reuse | Peach responsibility |+| 能力 | 复用实现 | Peach 负责 ||---|---|---|-| HTTP | project-wide `httpx.Client`/transport | source policy, DTO and redaction |-| RSS/Atom | `feedparser` | bounded fetch, snapshots, review and import |-| HTML adapters | Beautiful Soup or selectolax | source-specific selectors and provenance |-| Raster images | Pillow | portrait/logo quality and source policy |-| Search | SQLite FTS5 | indexed fields, ranking and profile-aware filters |-| Media probe/transcode | managed FFmpeg/ffprobe | job policy and Media Engine orchestration |-| HLS/DASH playback | hls.js or Shaka Player | stream plan, authorization and fallback order |-| Icons | pinned local Lucide subset | labels, state and interaction design |-| Scheduled polling | APScheduler when persistent feed config exists | job definitions and safety policy |-| Local file events | watchdog plus periodic reconciliation | media identity and missed-event repair |-| Transitional metadata/media | Stash GraphQL, CommunityScrapers and Stash job system | adapter, reconciliation and exit gates |-| LAN discovery | Python zeroconf | service lifecycle and real-client acceptance |-| Windows tray | pystray 0.19.5 (LGPLv3), Pillow and Win32 Per-Monitor V2 DPI | Peach service ownership, background update check, menu actions and brand mark |-| Agent usage/quota | official provider quota APIs; T3 Code/CodexBar for local history | task routing, redaction and stale-snapshot labeling |-| Video source/end-card evidence | existing FFmpeg frame extraction plus a reviewed OCR/vision adapter | opening/ending sample policy, provenance and incomplete-version candidates |-| Referenced product behavior | current live interaction plus versioned public DOM/CSS/JS, or exact screenshot measurements when source is unavailable | evidence register, accessibility, Peach-specific deviations and regression checks |--Do not introduce a dependency until its first consumer and isolated tests land in the same change.--## Maintained successors--| Removed/old name | Current implementation | Rule |+| HTTP | 全项目共用的 `httpx.Client`/transport | 来源策略、DTO、脱敏 |+| RSS/Atom | `feedparser` | 有界抓取、快照、复核、导入 |+| HTML 适配器 | Beautiful Soup 或 selectolax | 来源专用选择器和来源记录 |+| 位图 | Pillow | 头像/Logo 质量和来源策略 |+| 搜索 | SQLite FTS5 | 索引字段、排序、profile 感知筛选 |+| 媒体探测/转码 | Peach 管理的 FFmpeg/ffprobe | 任务策略和 Media Engine 编排 |+| HLS/DASH 播放 | hls.js 或 Shaka Player | 流方案、授权、回退顺序 |+| 图标 | 固定版本的本地 Lucide 子集 | 标签、状态和交互设计 |+| 定时轮询 | 持久追更配置落地后使用 APScheduler | 任务定义和安全策略 |+| 本地文件事件 | watchdog + 定期对账 | 媒体身份和漏报修复 |+| 过渡期元数据/媒体 | Stash GraphQL、CommunityScrapers、Stash 任务系统 | 适配、对账、退出门槛 |+| 局域网发现 | Python zeroconf | 服务生命周期和真实客户端验收 |+| Windows 托盘 | pystray 0.19.5(LGPLv3)、Pillow、Win32 Per-Monitor V2 DPI | Peach 服务归属、后台更新检查、菜单动作、品牌图标 |+| 智能体用量/配额 | Provider 官方配额接口;T3 Code/CodexBar 提供本地历史 | 任务路由、脱敏、过期快照标记 |+| 视频出处/片尾证据 | 现有 FFmpeg 抽帧 + 经复核的 OCR/视觉适配器 | 首尾采样策略、来源、不完整版候选 |+| 参考产品行为 | 当前线上交互 + 有版本的公开 DOM/CSS/JS;取不到源码时用精确截图测量 | 证据登记、无障碍、Peach 差异、回归检查 |++依赖的第一个消费者及其隔离测试必须在同一改动落地,否则不引入依赖。++## 已删除旧实现与当前继任者++| 已删除/旧名称 | 当前实现 | 规则 ||---|---|---|-| `rm-web.py` / `rm-web.html` | `src/peach/api.py`, `src/peach/web_contract.py`, `web/index.html` | never restore the HTTP server |-| `rm-javlookup.py` | `scripts/scrape_codes.py` | extend source adapters; do not fork another scraper |-| `rm-probe.py` | `scripts/probe.py` | move reusable policy into `src/peach`, preserve resume semantics |-| `rm-sheets.py` | `scripts/sheets.py` | share FFmpeg/job primitives; do not create another sheet pipeline |-| `rm-ledger.py` | `scripts/ledger.py` plus repository/migrations | new product reads belong in repositories, not this legacy CLI |-| `rm-status.py` | `scripts/status.py` | status is read-only |-| `rm-suggest.py` | `scripts/suggest.py` | ranking logic will move behind an application port |-| `rm-trafficwatch.py` | `scripts/traffic_watch.py` | stop only owned task process trees |-| `rm-sha1.py` | `scripts/sync_sha1_115.py` | reuse provider hashes; do not rehash cloud media blindly |--## Current replacement queue--Completed in the consolidation slice: shared Media/Job/HTTP boundaries, feedparser, Pillow, Beautiful Soup, FTS5, import-safe batch scripts and scoped task termination.--1. Add a Media Engine stream-plan API and a mature HLS/DASH player before using Stash transcodes in the browser.-2. Configure and evaluate Stash metadata providers before writing another source adapter.-3. Move remaining legacy status/suggest/ledger application logic behind repository/application ports, then delete obsolete CLI surfaces.-4. Do not build a token/cost log scanner inside Peach or bind to T3 Code's private RPC; use its UI/CodexBar and official live quota surfaces.-5. “模仿/参考/对齐” is not authorization to approximate from memory. Obtain and record reproducible evidence before implementation; otherwise mark the item `未取得` and keep it out of production.+| `rm-web.py` / `rm-web.html` | `src/peach/api.py`、`src/peach/web_contract.py`、`web/index.html` | 不得恢复旧 HTTP server |+| `rm-javlookup.py` | `scripts/scrape_codes.py` | 扩展来源适配器,不再分叉刮削器 |+| `rm-probe.py` | `scripts/probe.py` | 可复用策略移入 `src/peach`,保留续跑语义 |+| `rm-sheets.py` | `scripts/sheets.py` | 共用 FFmpeg/任务原语,不再新建抽帧管线 |+| `rm-ledger.py` | `scripts/ledger.py` + repository/migrations | 新产品读取进入 repository,不放回旧 CLI |+| `rm-status.py` | `scripts/status.py` | 状态命令只读 |+| `rm-suggest.py` | `scripts/suggest.py` | 排序逻辑逐步移到应用端口后 |+| `rm-trafficwatch.py` | `scripts/traffic_watch.py` | 只停止任务拥有的进程树 |+| `rm-sha1.py` | `scripts/sync_sha1_115.py` | 复用 Provider 哈希,不盲目重算网盘媒体 |++## 当前替换队列++已完成:共享 Media/Job/HTTP 边界、feedparser、Pillow、Beautiful Soup、FTS5、可安全导入的批处理脚本和按任务范围终止进程。++1. 浏览器使用 Stash 转码前,先增加 Media Engine 流方案 API 和成熟 HLS/DASH 播放器。+2. 编写新来源适配器前,先配置并评估 Stash 元数据 Provider。+3. 将剩余 status/suggest/ledger 应用逻辑移到 repository/application 端口,再删除旧 CLI 表面。+4. Peach 不做 token/成本日志扫描器,也不绑定 T3 Code 私有 RPC;使用其界面、CodexBar 和官方实时配额入口。+5. “模仿/参考/对齐”不等于允许凭记忆近似。先取得并登记可复现证据;否则标记 `未取得`,不得作为忠实复刻发布。diff --git a/docs/adr/0008-entity-pages-links-and-watch-queue.md b/docs/adr/0008-entity-pages-links-and-watch-queue.mdindex 9cdda8bbf..8ce654942 100644--- a/docs/adr/0008-entity-pages-links-and-watch-queue.md+++ b/docs/adr/0008-entity-pages-links-and-watch-queue.md@@ -1,28 +1,29 @@-# ADR 0008: Entity pages, link provenance and watch queue+# ADR-0008:实体资料页、链接来源与稍后看队列-- Status: Accepted-- Date: 2026-08-14+- 状态:已接受+- 日期:2026-08-14-## Context+## 背景-Peach needs durable performer, studio, creator and series pages instead of treating every name click as a transient list filter. Those pages need summaries, aliases, official/social/catalog links, personal source evidence and search terms. “Watch later” is a queue intent, not a like/dislike/watched judgment.+Peach 需要长期稳定的女优、厂牌、创作者和系列资料页,不能继续把每次名称点击都当成临时列表筛选。资料页需要简介、别名、官方/社交/目录链接、个人来源证据和搜索词。“稍后看”表达队列意图,不是喜欢、不喜欢或看过判断。-## Decision+## 决策-- Canonical identity remains in `entity`; summaries and low-cardinality descriptive fields remain in `metadata_json`.-- `entity_link` stores typed links. Official, social and catalog links are clickable. `source_reference` is private provenance: the API exposes its label/hostname but withholds the URL from the web client.-- `entity_search_term` stores user-maintained discovery or source-lookup vocabulary. Peach does not automatically search or download infringing copies.-- `watch_queue` is profile-scoped and separate from asset feedback. The first deployment seeds the single local default profile.-- Entity portraits are cached files with provenance. Network-sourced, verified images take priority; a representative contact-sheet crop is only a fallback. Stash is not accepted as a portrait source when it returns its default silhouette.-- Clear studio duplicates are merged by a reviewed, dry-run-first script. Old names survive as aliases and flattened `asset.studio` remains a compatibility projection.+- 规范身份继续保存在 `entity`;简介和低基数描述字段保存在 `metadata_json`。+- `entity_link` 保存带类型的链接。官方、社交和目录链接可点击;`source_reference` 是私有来源证据:API 只向 Web 暴露标签/主机名,不暴露完整 URL。+- `entity_search_term` 保存用户维护的发现或来源检索词。Peach 不自动搜索或下载侵权副本。+- `watch_queue` 按 profile 隔离,和作品反馈分开。首个部署使用单用户本地默认 profile。+- 实体头像使用带来源记录的本地缓存文件。经验证的联网图片优先;代表作品的接触表裁图只作回退。Stash 默认剪影不能作为头像来源。+- 明确的重复厂牌由“先预览、后复核”的脚本合并。旧名称保留为别名;扁平 `asset.studio` 继续作为兼容投影。+- Web 公共 URL 使用领域名词,不暴露内部 `entity` 表:`/performers/{name}`、`/studios/{name}`、`/creators/{name}`、`/series/{name}`。JSON 契约暂时保留 `/api/entity` 作为不绑定实现的兼容端点,直到另行拆分。-## Rejected+## 否决方案-- Encoding “watch later” as `feedback='seen'` or another overloaded asset flag.-- Making private acquisition/source URLs directly clickable in the web UI.-- Automatically merging studios solely because punctuation-normalized names collide.-- Treating a Stash placeholder image or search-engine thumbnail as a high-resolution performer portrait.+- 把“稍后看”编码为 `feedback='seen'` 或其他复用过度的作品标记。+- 在 Web 界面中直接开放私有获取/来源 URL。+- 仅因去标点后的名称碰撞就自动合并厂牌。+- 把 Stash 占位图或搜索结果缩略图当成高清女优头像。-## Consequences+## 影响-Entity pages can accumulate trusted metadata without changing the asset model, and future profiles get independent queues. Link and portrait importers require provenance and review, but Peach avoids turning personal source history into an automatic piracy workflow or low-quality image cache.+实体资料可以在不改变作品模型的前提下累积可信元数据,未来不同 profile 也能拥有独立队列。链接和头像导入器必须记录来源并经过复核;代价是多一层审核,但避免把私人来源历史变成自动侵权获取流程或低质量图片缓存。diff --git a/src/peach/api.py b/src/peach/api.pyindex 416caa6a6..7e05675ba 100644--- a/src/peach/api.py+++ b/src/peach/api.py@@ -228,8 +228,12 @@ def create_app(settings: PeachSettings | None = None) -> FastAPI:return response@app.api_route("/item/{item_id}", methods=["GET", "HEAD"])- @app.api_route("/entity/{kind}/{name:path}", methods=["GET", "HEAD"])+ @app.api_route("/performers/{name:path}", methods=["GET", "HEAD"])+ @app.api_route("/studios/{name:path}", methods=["GET", "HEAD"])+ @app.api_route("/creators/{name:path}", methods=["GET", "HEAD"])+ @app.api_route("/series/{name:path}", methods=["GET", "HEAD"])@app.api_route("/performers", methods=["GET", "HEAD"])+ @app.api_route("/creators", methods=["GET", "HEAD"])@app.api_route("/tags", methods=["GET", "HEAD"])@app.api_route("/stats", methods=["GET", "HEAD"])@app.api_route("/immerse", methods=["GET", "HEAD"])diff --git a/tests/test_fastapi_api.py b/tests/test_fastapi_api.pyindex b5cfdfd6a..8f0730a21 100644--- a/tests/test_fastapi_api.py+++ b/tests/test_fastapi_api.py@@ -194,12 +194,16 @@ class FastApiContractTests(unittest.IsolatedAsyncioTestCase):async def test_client_routes_serve_the_single_page_surface(self):await self.client.get("/?t=secret")- for path in ("/item/1", "/entity/performer/Alice", "/performers",- "/tags", "/stats", "/immerse"):+ for path in ("/item/1", "/performers/Alice", "/studios/Prestige",+ "/creators/luckydog11", "/series/Example", "/performers",+ "/creators", "/tags", "/stats", "/immerse"):response = await self.client.get(path)self.assertEqual(response.status_code, 200, path)self.assertIn("Peach test", response.text)+ removed = await self.client.get("/entity/performer/Alice")+ self.assertEqual(removed.status_code, 404)+async def test_standard_range_and_head_contract(self):headers = {"X-Token": "secret"}full = await self.client.get("/stream?id=1", headers=headers)diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex b0c053e2a..325b66cfb 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -14,6 +14,21 @@ class WebUiSourceTests(unittest.TestCase):self.assertNotIn('onload="if(this.naturalWidth', self.page)self.assertIn("img.addEventListener('error',fallback", self.page)+ def test_entity_routes_are_semantic_and_not_model_shaped(self):+ self.assertNotIn("route(`/entity/", self.page)+ self.assertIn("performer:'performers'", self.page)+ self.assertIn("studio:'studios'", self.page)+ self.assertIn("creator:'creators'", self.page)++ def test_detail_close_disposes_playback_source(self):+ self.assertIn("function disposeStage", self.page)+ self.assertIn("video.pause();video.removeAttribute('src');video.load();video.remove()", self.page)+ self.assertIn("$('#closeStage').onclick=()=>disposeStage(true)", self.page)++ def test_tag_geometry_uses_shared_tokens(self):+ self.assertIn("--tag-radius:999px", self.page)+ self.assertIn("border-radius:var(--tag-radius)", self.page)+if __name__ == "__main__":unittest.main()diff --git a/web/index.html b/web/index.htmlindex 500db7ffe..7580419ce 100644--- a/web/index.html+++ b/web/index.html@@ -15,19 +15,23 @@--tungsten:#0095F6; --tungsten-soft:#DCEEFD;--loupe:#127A72; --keep:#2E7D32; --meter:#B26A10; --drop:#C0392B;--tile:336px; --topH:56px; --railW:72px;+ --tag-radius:999px; --tag-pad-y:4px; --tag-pad-x:10px;+ --frost-panel:rgba(247,248,250,.82); --frost-light:rgba(255,255,255,.76);--sb:#3A3A40; --sb-hover:#55555E; /* 336 = 168×2,与目标站的模块单位一致 */}@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){- --ground:#020408; --surface:#161616; --sunk:#000; --hover:#202020;+ --ground:#020408; --surface:#222222; --sunk:#0B0D11; --hover:rgba(255,255,255,.07);--line:#3A3A3D; --line-soft:#2C2C30;--ink:#FFFFFF; --ink-2:#C9CDD4; --muted:#9AA0A8;--tungsten:#0095F6; --tungsten-soft:#0A2B45;+ --frost-panel:rgba(30,30,30,.72); --frost-light:rgba(38,40,44,.72);--loupe:#6FD0C8; --keep:#5FB95F; --meter:#E0912F; --drop:#FF5252;}}:root[data-theme="dark"]{- --ground:#020408; --surface:#161616; --sunk:#000; --hover:#202020;+ --ground:#020408; --surface:#222222; --sunk:#0B0D11; --hover:rgba(255,255,255,.07);--line:#3A3A3D; --line-soft:#2C2C30;--ink:#FFFFFF; --ink-2:#C9CDD4; --muted:#9AA0A8;--tungsten:#0095F6; --tungsten-soft:#0A2B45;+ --frost-panel:rgba(30,30,30,.72); --frost-light:rgba(38,40,44,.72);--loupe:#6FD0C8; --keep:#5FB95F; --meter:#E0912F; --drop:#FF5252;}*,*::before,*::after{box-sizing:border-box}@@ -59,7 +63,8 @@ button,input,textarea{font:inherit;color:inherit}/* ── 顶栏:无侧栏,图占主导 ── */.top{position:sticky;top:0;z-index:70;display:flex;align-items:center;gap:12px;height:var(--topH);padding:0 16px;border-bottom:1px solid var(--line-soft);- background:var(--ground)}+ background:color-mix(in srgb,var(--ground) 78%,transparent);+ backdrop-filter:saturate(1.8) blur(20px);-webkit-backdrop-filter:saturate(1.8) blur(20px)}.ib{background:none;border:0;border-radius:8px;cursor:pointer;width:40px;height:40px;flex:none;display:inline-flex;align-items:center;justify-content:center;color:var(--ink-2);padding:0;line-height:0;transition:background .12s,color .12s}@@ -85,7 +90,7 @@ button,input,textarea{font:inherit;color:inherit}/* ── 顶部三层:女优圆头像 / 厂牌 / 内容标签 ── */.tiers{position:relative;z-index:1;padding:10px 0 8px;border-bottom:1px solid var(--line-soft);- background:var(--ground)}+ background:linear-gradient(180deg,var(--frost-light),color-mix(in srgb,var(--ground) 88%,transparent))}.tier{display:flex;gap:14px;overflow-x:auto;scrollbar-width:none;padding:0 16px 8px;align-items:flex-start}.tier::-webkit-scrollbar{display:none}.tier:last-child{padding-bottom:2px}@@ -117,7 +122,8 @@ button,input,textarea{font:inherit;color:inherit}.tagbar{position:sticky;top:var(--topH);z-index:61;padding:9px 16px;transition:transform .22s ease, opacity .22s ease;border-bottom:1px solid var(--line-soft);- background:var(--ground);+ background:color-mix(in srgb,var(--ground) 78%,transparent);+ backdrop-filter:saturate(1.8) blur(20px);-webkit-backdrop-filter:saturate(1.8) blur(20px);display:flex;gap:7px;overflow-x:auto;scrollbar-width:none;align-items:center}.tagbar::-webkit-scrollbar{display:none}.pill{flex:none;padding:7px 15px;border:1px solid color-mix(in srgb,var(--line) 82%,transparent);@@ -132,8 +138,8 @@ button,input,textarea{font:inherit;color:inherit}/* 多标签交集筛选条 */.combo{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin:0 0 10px}-.combo .cb{display:inline-flex;align-items:center;gap:6px;padding:4px 8px 4px 11px;- border-radius:15px;border:1px solid var(--tungsten);color:var(--tungsten);+.combo .cb{display:inline-flex;align-items:center;gap:6px;padding:var(--tag-pad-y) 8px var(--tag-pad-y) 11px;+ border-radius:var(--tag-radius);border:1px solid var(--tungsten);color:var(--tungsten);background:var(--tungsten-soft);font-size:12.5px}.combo .cb b{cursor:pointer;opacity:.7;font-weight:400}.combo .cb b:hover{opacity:1}@@ -216,7 +222,6 @@ main{padding:14px 16px 90px}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--tile),1fr));gap:16px 8px}.card{cursor:pointer;display:flex;flex-direction:column;gap:8px;min-width:0;position:relative;transition:transform .18s ease,filter .18s ease;transform-origin:center}-.card.selected .pic{box-shadow:0 0 0 3px var(--tungsten)}.card.selected::after{content:'✓';position:absolute;top:8px;left:8px;z-index:7;width:27px;height:27px;border-radius:50%;display:grid;place-items:center;background:var(--tungsten);color:#15110b;font-weight:800;border:2px solid #fff}.pic{position:relative;aspect-ratio:16/9;background:#000;border-radius:4px;@@ -229,6 +234,7 @@ main{padding:14px 16px 90px}opacity:0;transition:opacity .2s}.hv.on{opacity:1}.card:hover .pic{box-shadow:0 0 0 1px color-mix(in srgb,var(--tungsten) 65%,transparent)}+.card.selected .pic,.card.selected:hover .pic{box-shadow:inset 0 0 0 3px var(--tungsten)}@media (hover:hover) and (pointer:fine){.card.longhover{transform:translateY(-7px) scale(1.065);z-index:8;filter:brightness(1.04)}}@@ -307,7 +313,7 @@ main{padding:14px 16px 90px}.flags i.later{background:var(--tungsten)}/* 标签语义分级 */.ctags{display:flex;flex-wrap:wrap;gap:5px}-.tg{padding:3px 8px;border-radius:6px;font-size:12.5px;border:1px solid var(--line);+.tg{padding:var(--tag-pad-y) var(--tag-pad-x);border-radius:var(--tag-radius);font-size:12.5px;border:1px solid var(--line);line-height:1.45;white-space:nowrap;cursor:pointer;color:var(--ink-2);background:color-mix(in srgb,var(--surface) 82%,var(--ground))}.tg.general,.tg.artist,.tg.character,.tg.copyright,.tg.meta{color:var(--ink-2);border-color:var(--line)}@@ -330,6 +336,7 @@ body[data-density="dense"] .card .meta .t{-webkit-line-clamp:1;white-space:nowra.stage{margin:0 0 22px;border-radius:5px;background:var(--surface);scroll-margin-top:calc(var(--topH) + 8px);border:1px solid var(--line);overflow:hidden}.stage[hidden]{display:none}+body.detail-open .tagbar{position:relative;top:auto;z-index:1;transform:none;opacity:1}.sgrid{display:grid;grid-template-columns:minmax(0,1fr) minmax(350px,390px)}.vwrap{background:#000;position:relative;display:flex;align-items:center;justify-content:center}.vwrap video{width:100%;max-height:76vh;display:block}@@ -360,7 +367,7 @@ body[data-density="dense"] .card .meta .t{-webkit-line-clamp:1;white-space:nowra.trace .bar u{position:absolute;inset:0 auto 0 0;background:color-mix(in srgb,var(--loupe) 26%,transparent);text-decoration:none}.trace .bar b{position:absolute;top:-3px;bottom:-3px;width:2px;background:var(--tungsten);border-radius:1px}.ticks{display:flex;justify-content:space-between;margin-top:4px;color:var(--muted)}-.fb{display:flex;align-items:center;gap:7px;margin:0 0 10px;padding:7px 0;border-top:1px solid var(--line-soft);border-bottom:1px solid var(--line-soft)}+.fb{display:flex;align-items:center;gap:7px;margin:2px 0 10px;padding:5px 0;border:0}.fb button{width:42px;height:42px;padding:0;border:1px solid transparent;background:transparent;border-radius:8px;cursor:pointer;display:grid;place-items:center;color:var(--muted);transition:transform .14s ease,color .14s ease,background .14s ease}.fb button svg{width:21px;height:21px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}@@ -370,8 +377,7 @@ body[data-density="dense"] .card .meta .t{-webkit-line-clamp:1;white-space:nowra.fb .seen:hover,.fb .seen[aria-pressed="true"]{color:var(--keep);background:color-mix(in srgb,var(--keep) 12%,transparent)}.fb .dispose:hover,.fb .dispose[aria-pressed="true"]{color:var(--meter);background:color-mix(in srgb,var(--meter) 12%,transparent)}.fb .later:hover,.fb .later[aria-pressed="true"]{color:var(--loupe);background:color-mix(in srgb,var(--loupe) 12%,transparent)}-.preference{border-top:1px solid var(--line-soft);padding:12px 0 0;margin:4px 0 8px;- background:color-mix(in srgb,var(--surface) 78%,transparent)}+.preference{border:0;padding:8px 0 0;margin:2px 0 8px;background:transparent}.preference textarea{display:block;width:100%;min-height:62px;resize:vertical;padding:8px 9px;color:var(--ink);background:var(--ground);border:1px solid var(--line);border-radius:5px;line-height:1.5;font-size:14px}@@ -396,7 +402,8 @@ body[data-density="dense"] .card .meta .t{-webkit-line-clamp:1;white-space:nowra/* 常驻 72 px 窄图标条。外部实现证据和有意差异登记在 docs/HANDOFF.md。 */.edge{position:fixed;top:0;bottom:0;left:0;width:var(--railW);z-index:92;padding-top:14px;- background:var(--surface);+ background:linear-gradient(180deg,var(--frost-light),var(--frost-panel));+ backdrop-filter:saturate(1.8) blur(20px);-webkit-backdrop-filter:saturate(1.8) blur(20px);border-right:1px solid var(--line-soft);display:flex;flex-direction:column;align-items:center;gap:4px;padding:10px 0}.edge button{width:52px;height:52px;border-radius:8px;background:none;border:0;cursor:pointer;@@ -409,7 +416,8 @@ body[data-density="dense"] .card .meta .t{-webkit-line-clamp:1;white-space:nowrabody{padding-left:var(--railW)}@media (max-width:760px){body{padding-left:0}.edge{display:none}}.drawer{position:fixed;top:0;bottom:0;left:0;width:360px;z-index:97;- background:var(--surface);+ background:linear-gradient(180deg,var(--frost-light),var(--frost-panel));+ backdrop-filter:saturate(1.8) blur(20px);-webkit-backdrop-filter:saturate(1.8) blur(20px);border-right:1px solid var(--line);padding:16px 12px 60px;overflow-y:auto;transform:translateX(-100%);transition:transform .2s cubic-bezier(.3,.8,.3,1)}.drawer.open{transform:none;box-shadow:18px 0 60px -24px #000}@@ -441,8 +449,8 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位.chip img,.chip>svg{width:14px;height:14px;border-radius:3px;object-fit:contain;flex:none}.source-icon{display:block!important;width:16px!important;height:16px!important;min-width:16px;opacity:1!important;filter:none!important;object-fit:contain}.chip>svg{stroke:currentColor;fill:none;stroke-width:1.7}-.chip{display:inline-flex;align-items:center;gap:6px;padding:3px 9px;border:1px solid var(--line);- border-radius:3px;background:transparent;cursor:pointer;font-size:12px}+.chip{display:inline-flex;align-items:center;gap:6px;padding:var(--tag-pad-y) var(--tag-pad-x);border:1px solid var(--line);+ border-radius:var(--tag-radius);background:transparent;cursor:pointer;font-size:12px}.chip:hover{border-color:var(--tungsten)}.chip[aria-pressed="true"]{background:var(--tungsten-soft);border-color:var(--tungsten)}/* 不同类别保留语义色,内容卡片本身维持中性。 */@@ -630,6 +638,9 @@ const $=s=>document.querySelector(s);const icon=(name,cls='')=>`<svg${cls?` class="${cls}"`:''} viewBox="0 0 24 24" aria-hidden="true"><use href="#i-${name}"/></svg>`;const api=(p,o)=>fetch(p,Object.assign({headers:{'Content-Type':'application/json'}},o||{})).then(r=>r.json());const route=(path,replace=false)=>history[replace?'replaceState':'pushState']({},'',path);+const ENTITY_ROUTES={performer:'performers',studio:'studios',creator:'creators',series:'series'};+const ROUTE_ENTITIES={performers:'performer',studios:'studio',creators:'creator',series:'series'};+const entityPath=(kind,name)=>`/${ENTITY_ROUTES[kind]||kind}/${encodeURIComponent(name)}`;const esc=s=>String(s??'').replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));const fmtDur=s=>{if(!s)return'—';s=Math.round(s);const h=s/3600|0,m=(s%3600)/60|0,x=s%60;return h?`${h}:${String(m).padStart(2,'0')}:${String(x).padStart(2,'0')}`:`${m}:${String(x).padStart(2,'0')}`};@@ -658,6 +669,14 @@ const REP={}; // 创作者/厂牌 → 代表作 id,用来做圆头像(裁let offset=0,total=0,facets=null,current=null;const CACHE={};const cache=items=>{items.forEach(x=>CACHE[x.id]=x);return items};+function disposeStage(push=false){+ const stage=$('#stage');+ stage.querySelectorAll('video').forEach(video=>{+ if(video._hop)clearInterval(video._hop);+ video.pause();video.removeAttribute('src');video.load();video.remove()});+ stage.innerHTML='';stage.hidden=true;document.body.classList.remove('detail-open');current=null;+ if(push)route('/');+}const selected=new Set();function paintSelection(){document.querySelectorAll('.card[data-id]').forEach(card=>card.classList.toggle('selected',selected.has(+card.dataset.id)));@@ -955,10 +974,11 @@ function renderCombo(){/* ── 统计与管理 ── */async function openStats(push=true){if(push)route('/stats');+ disposeStage(false);const d=await api('/api/stats');$('#stats').hidden=false; $('#index').hidden=true; $('#grid').innerHTML='';$('#count').textContent=''; $('#loadSentinel').hidden=true; $('#shortsSec').hidden=true;- $('#stage').hidden=true; $('#tiers').style.display='none'; $('#tagbar').style.display='none';+ $('#tiers').style.display='none'; $('#tagbar').style.display='none';const a=d.attribution, cs=d.consumption;const pct=(x,y)=>y?Math.round(x/y*100):0;const gb=b=>b>=1099511627776?(b/1099511627776).toFixed(2)+' TB':(b/1073741824).toFixed(1)+' GB';@@ -1020,9 +1040,10 @@ function closeStats(push=true){if(push)route('/');$('#stats').hidden=true;/* ── 全部艺人 / 创作者 / 标签索引页 ── */async function openIndex(kind,q,push=true){if(push)route('/'+kind+(q?'?q='+encodeURIComponent(q):''),!!q);+ disposeStage(false);const d=await api('/api/index?kind='+kind+(q?'&q='+encodeURIComponent(q):''));$('#index').hidden=false; $('#grid').innerHTML=''; $('#count').textContent='';- $('#loadSentinel').hidden=true; $('#shortsSec').hidden=true; $('#stage').hidden=true;+ $('#loadSentinel').hidden=true; $('#shortsSec').hidden=true;const people=kind==='creators'||kind==='performers';const entityKind=kind==='performers'?'performer':'creator';const title=kind==='performers'?'全部艺人':(kind==='creators'?'全部创作者':'全部标签');@@ -1049,13 +1070,14 @@ async function openIndex(kind,q,push=true){}async function openEntity(kind,name,push=true){- if(push)route(`/entity/${encodeURIComponent(kind)}/${encodeURIComponent(name)}`);+ if(push)route(entityPath(kind,name));+ disposeStage(false);const d=await api(`/api/entity?kind=${encodeURIComponent(kind)}&name=${encodeURIComponent(name)}`);if(d.error)return;const p=new URLSearchParams();p.set(kind,name);p.set('limit','120');p.set('sort','new');const items=await api('/api/items?'+p);cache(items.items);$('#index').hidden=false;$('#grid').innerHTML='';$('#count').textContent='';- $('#loadSentinel').hidden=true;$('#shortsSec').hidden=true;$('#stage').hidden=true;+ $('#loadSentinel').hidden=true;$('#shortsSec').hidden=true;const labels={performer:'女优',studio:'厂牌',creator:'创作者',series:'系列'};const image=d.id?`<img src="/entity-image?kind=${kind}&id=${d.id}" alt="${esc(d.canonical_name)}"onerror="${d.representative_asset_id?`this.onerror=null;this.src='/avatar?id=${d.representative_asset_id}'`:`this.remove()`}">`:'';@@ -1200,6 +1222,7 @@ async function loadShorts(){/* ── 就地展开播放 ── */async function openItem(id,push=true){+ disposeStage(false);if(push)route('/item/'+id);const it=await api('/api/item?id='+id); if(it.error)return;current=it; CACHE[it.id]=it;@@ -1222,7 +1245,7 @@ async function openItem(id,push=true){: k==='series'?icon('tags'):`<span>${esc(n.slice(0,1))}</span>`;return `<div class="identityrow"><button class="identitymark ${k==='studio'?'logo ':''}entitylink" data-entity-kind="${k}" data-entity-name="${esc(n)}" title="打开${l}页">${visual}</button><span class="ilabel">${l}</span><button class="entitylink" data-entity-kind="${k}" data-entity-name="${esc(n)}">${esc(n)}</button></div>`;}).join('');- $('#stage').hidden=false; delete $('#stage').dataset.c;+ $('#stage').hidden=false;document.body.classList.add('detail-open');delete $('#stage').dataset.c;$('#stage').innerHTML=`<div class="sgrid"><div class="vwrap"><button class="closestage" id="closeStage">收起 <kbd>Esc</kbd></button>${gated?`<div class="gate" id="gate">@@ -1262,7 +1285,7 @@ async function openItem(id,push=true){</div></div><div class="next"><h3>接着看 · 口味接近</h3><div class="nrow" id="nrow">载入中…</div></div>`;- $('#closeStage').onclick=()=>{const v=$('#vid');v&&v.pause();$('#stage').hidden=true;route('/')};+ $('#closeStage').onclick=()=>disposeStage(true);const g=$('#gate'); if(g)g.onclick=()=>{const v=$('#vid');v.src='/stream?id='+it.id;v.hidden=false;g.remove();v.play()};$('#stage').querySelectorAll('[data-kind]').forEach(b=>b.onclick=async()=>{@@ -1273,7 +1296,7 @@ async function openItem(id,push=true){$('#stage').querySelector('.dispose').setAttribute('aria-pressed',r.disposal==='pending');$('#oCount').textContent=r.o_count||0});$('#stage').querySelectorAll('.stags .tg').forEach(s=>s.onclick=()=>{- state.tag=s.dataset.tag;buildBars();load(true);window.scrollTo({top:0,behavior:'smooth'})});+ state.tag=s.dataset.tag;disposeStage(false);buildBars();load(true);window.scrollTo({top:0,behavior:'smooth'})});$('#stage').querySelectorAll('[data-entity-kind]').forEach(b=>b.onclick=()=>openEntity(b.dataset.entityKind,b.dataset.entityName));$('#stageLater').onclick=async()=>{const r=await api('/api/watch-later',{method:'POST',@@ -1435,7 +1458,7 @@ $('#searchBtn').onclick=()=>{const s=$('.search');s.classList.toggle('open');$('#q').addEventListener('blur',()=>{if(!$('#q').value)$('.search').classList.remove('open')});$('#brandHome').onclick=e=>{e.preventDefault();state={loc:state.loc,creator:'',studio:'',tag:'',len:'',dur_min:'',dur_max:'',orient:'',state:'',sort:'daily',seed:String((Date.now()^(Math.random()*1e9|0))%99991),q:'',thumb:'1'};- route('/');$('#q').value='';$('#stage').hidden=true;buildBars();load(true);window.scrollTo({top:0,behavior:'smooth'})};+ route('/');$('#q').value='';disposeStage(false);buildBars();load(true);window.scrollTo({top:0,behavior:'smooth'})};$('#tokClose').onclick=()=>{route('/');$('#tok').hidden=true;$('#tokTrack').querySelectorAll('video').forEach(v=>{v.pause();v.removeAttribute('src');v.load();if(v.id!=='tokVid')v.remove()});const v=$('#tokVid');if(v){v.style.transform=''}tokSwitching=false;document.body.style.overflow=''};@@ -1472,7 +1495,7 @@ async function refreshAll(){if(!$('#stats').hidden){await openStats();return} // 统计页只刷统计if(!$('#index').hidden){return}state.sort='seed'; state.seed=String(Date.now()%99991);- $('#stage').hidden=true;+ disposeStage(false);await load(true);window.scrollTo({top:0,behavior:'smooth'});}@@ -1505,11 +1528,12 @@ function wireAllDrag(){['#tagbar','#srow','#nrow'].forEach(s=>wireDrag($(s)));async function restoreRoute(){const path=decodeURIComponent(location.pathname),parts=path.split('/').filter(Boolean);if(parts[0]==='item'&&/^\d+$/.test(parts[1]||'')){await openItem(+parts[1],false);return}- if(parts[0]==='entity'&&parts.length>=3){await openEntity(parts[1],parts.slice(2).join('/'),false);return}- if(path==='/performers'||path==='/tags'){await openIndex(path.slice(1),new URLSearchParams(location.search).get('q')||'',false);return}+ const entityKind=ROUTE_ENTITIES[parts[0]];+ if(entityKind&&parts.length>=2){await openEntity(entityKind,parts.slice(1).join('/'),false);return}+ if(path==='/performers'||path==='/creators'||path==='/tags'){await openIndex(path.slice(1),new URLSearchParams(location.search).get('q')||'',false);return}if(path==='/stats'){await openStats(false);return}if(path==='/immerse'){await openTok(undefined,false);return}- $('#stats').hidden=true;$('#index').hidden=true;$('#stage').hidden=true;+ $('#stats').hidden=true;$('#index').hidden=true;disposeStage(false);}window.addEventListener('popstate',restoreRoute);buildEdge();