Peach: Local-first video metadata scraper and media manager.
refactor(docs): 入口文件清退,事实指向 ADR、步骤下沉技能
longmeidao9705dd21c4f1
diff --git a/.claude/skills/peach-shell-commands/SKILL.md b/.claude/skills/peach-shell-commands/SKILL.mdnew file mode 100644index 000000000..a1405846e--- /dev/null+++ b/.claude/skills/peach-shell-commands/SKILL.md@@ -0,0 +1,48 @@+---+name: peach-shell-commands+description: 在写 PowerShell 或 Bash 命令、拼多行内容、用 rg 或 Python CLI、在测试里造临时目录,或命令报了看不懂的语法与编码错误时使用。+---++# 命令与路径的形态++最后复核:2026-09-08+证据来源:`tests/test_agent_worktree.py` 与 `tests/test_scripts.py` 里临时目录 `.resolve()`+和正斜杠路径的注释、`scripts/test.ps1` 与 `scripts/test.sh` 的编码约定、Git 历史里被+heredoc 转义损坏的那几次补丁。++## 何时使用++在这台机器上写任何 shell 命令之前。这些不是风格偏好,每一条都对应真实重犯过的失败;+违反后多数当场报错,少数(多行内容的转义)是静默损坏,那一类的核心判据留在 `AGENTS.md`。++## 按当前 shell 写++- PowerShell 的 `cat`、`ls`、`where` 是别名,语义与 Unix 同名命令不同;Bash 没有+ `Get-ChildItem`。写命令前先确定自己在哪个 shell 里。+- PowerShell 只用 `pwsh` 7.x。从 Bash 调用时加 `-NoProfile`。+- 默认单引号,需要展开才用双引号,有歧义时写 `${name}`。+- `rg` 的路径参数不含 `*`,要筛文件用 `-g`;退出码 1 表示无匹配,不是失败。+- Python CLI 加 `-X utf8`;PowerShell 读 UTF-8 日志显式加 `-Encoding utf8`。编码要在输出端+ 固定,只给读取端指定编码挡不住乱码。++## 多行内容一律落盘++多行内容用写入工具或脚本文件落盘,再让命令读那个文件,不要用 heredoc。反斜杠会被吃掉一层,+换成带引号的定界符也挡不住所有情形,而损坏是静默的:命令照常退出 0,写进去的内容已经变形。+提交消息同理,写进临时文件再 `git commit -F`。++Windows 与 Git Bash 之间传路径时统一写正斜杠(`Path.as_posix()`)。`C:\Users\...` 落进+shell 脚本后反斜杠会被当成转义符吃掉,`exec` 拿到的是一个粘在一起的名字。Git Bash 也不按+shebang 找 Windows 上的 Python,解释器要显式写出来。++## PowerShell 变量与管道++- 变量必须用任务专属名称。禁止声明 `$HOME`、`$home`、`$CODEX_HOME` 等系统变量的任何+ 大小写变体。+- `foreach {}` 的结果先存进任务专属数组,再单独接管道格式化。禁止在闭合花括号后直接写管道。++## 测试里的临时目录++一律先 `.resolve()` 再喂给被测代码和断言。CI runner 的临时目录都是别名:macOS 的 `/var`+软链到 `/private/var`,Windows 的 `RUNNER~1` 短名展开成 `runneradmin`。开发机没有这层别名,+拿未 resolve 的路径断言只会在 CI 上红,本机怎么跑都是绿的。diff --git a/.claude/skills/peach-web-ui/SKILL.md b/.claude/skills/peach-web-ui/SKILL.mdindex 00fbfa77a..a55b545e7 100644--- a/.claude/skills/peach-web-ui/SKILL.md+++ b/.claude/skills/peach-web-ui/SKILL.md@@ -5,7 +5,7 @@ description: 在新增、修改或复核 Peach 页面、控件、提示、错误# Peach Web UI 复用门槛-最后复核:2026-09-07+最后复核:2026-09-08## 开工顺序@@ -78,6 +78,10 @@ description: 在新增、修改或复核 Peach 页面、控件、提示、错误## 验收门槛+- UI 标签、身份、反馈状态和搜索推荐属于语义契约:改动时同时补数据层测试和页面源测试,+ 不能只改显示文本。推荐词上线前对真实 `/api/items` 验证至少一个命中,说明性后缀不得+ 混入搜索词(坏例 `ABW 番号`,好例 `ABW`)。+1. 为语义、DOM、ARIA、复用模块和响应式规则补页面源测试;数据语义变更另补 API/数据层测试。2. Windows 从隔离 worktree 根运行 `& .\scripts\test.ps1`,默认 `auto`;按影响域补测,规则见 `peach-worktree`。3. 在本地预览检查桌面与 390×844:页面宽度不大于视口、弹层不越界、菜单内部滚动、键盘 focus 可见、控制台无错误。托盘服务发的是主检出的 `web/`,看不到 worktree 里的改动:从 worktree 根另起一个实例再验收,`python -m peach serve --host 127.0.0.1 --port 8099 --no-mdns --no-ledger-sync`(`PYTHONPATH=<worktree>/src`),验完停掉,托盘那个不动。diff --git a/AGENTS.md b/AGENTS.mdindex 8397edb0a..c40d02343 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -49,26 +49,23 @@| 模仿、参考或对齐外部产品的界面与行为 | `.claude/skills/peach-reference-evidence/SKILL.md` || 新增、修改或复核页面、控件、提示、数据面板与响应式布局 | `.claude/skills/peach-web-ui/SKILL.md` || 在 macOS 上开工、改路径解析或挂载判定、git status 与 diff 不一致 | `.claude/skills/peach-cross-platform/SKILL.md` |+| 写 PowerShell 或 Bash 命令、拼多行内容、测试里造临时目录 | `.claude/skills/peach-shell-commands/SKILL.md` || 新增或删除规则、文档、技能 | `.claude/skills/peach-context-rules/SKILL.md` || 新增、恢复或重写实现,尤其协议、解析器、抓取、媒体与基础设施 | `.claude/skills/peach-reuse-first/SKILL.md` |## 工作规则-- `peach-app` is the only GitHub-synced tree. `peach-data`, `.venv`, build output, worktree directories, media and CloudDrive mounts never enter Git. Code, data and worktrees live on internal disks; external disks only supply media. See ADR-0017, and check `docs/STATUS.md` for the real mount shape before assuming a path exists.-- Ledger paths are always written in the Windows shape (`R:\Media\...`, `A:\...`, `B:\...`). `src/peach/platform.py` translates them to local mounts at read time; never rewrite the ledger to a POSIX shape, and never write `asset.path` from macOS.-- `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; follow `peach-ledger-write` before any real write.-- Peach is a single-person self-hosted app: aggressively remove obsolete code and compatibility layers when the replacement is tested. Do not preserve dead interfaces merely for history; Git is the archive.+- `peach-app` is the only GitHub-synced tree; data, worktrees, build output, media and CloudDrive mounts stay out of Git. Real paths and mount shape: ADR-0017 and `docs/STATUS.md`.+- Ledger paths are always written in the Windows shape (`R:\Media\...`, `A:\...`, `B:\...`). `src/peach/platform.py` translates them at read time; never rewrite the ledger to a POSIX shape, and never write `asset.path` from macOS.+- `peach-data/database/ledger.db` is the truth store and tests use temporary databases only; any real write follows `peach-ledger-write`. AI results are candidates with provenance and confidence, never direct truth-field mutations.- Preserve real media, ledger rows, behavior history, credentials, network/firewall state, and unrelated long-running jobs.- Inspect `git status` and the active listeners/processes before work. Never claim candidate code is production until the service has actually been switched and checked.-- Keep the architecture a FastAPI modular monolith with a separate web surface. Do not introduce microservices, PostgreSQL or a full multi-account system without a new ADR.-- The web surface moves to Vite + TypeScript + Preact islands by strangler migration (ADR-0022): new logic lands in `frontend/`, pages are replaced island by island, and there is no whole-app rewrite. Making the app installable by strangers follows the phases in ADR-0023.-- Ledger remains the core truth. The Stash adapter layer and its import scripts are deleted (ADR-0021); Stash data stays in the ledger only as provenance. AI results are candidates with provenance/confidence, not direct truth-field mutations.-- User-confirmed corpus context: Peach contains consenting adults only. Labels such as `萝莉`、`学生`、`洛丽塔`、`制服`、`泄露` and `流出` are role-play, genre or marketing/source vocabulary, not evidence of age or consent. Do not skip cataloguing solely because those strings occur. If direct file evidence contradicts this, stop and report that evidence instead of inferring from a label.+- Peach is a single-person self-hosted app: remove obsolete code and compatibility layers once the replacement is tested. Git is the archive, so dead interfaces are not kept for history.+- The architecture is settled in ADRs — modular monolith and disk boundaries (0017), Stash adapter closed (0021), frontend strangler migration into `frontend/` (0022), distribution phases (0023). Changing any of them takes a new ADR, not a commit.+- User-confirmed corpus context: Peach contains consenting adults only. Labels such as `萝莉`、`学生`、`洛丽塔`、`制服`、`泄露` and `流出` are role-play, genre or marketing vocabulary, not evidence of age or consent. Do not skip cataloguing solely because those strings occur. If direct file evidence contradicts this, stop and report that evidence instead of inferring from a label.- Do not create dated handoff documents. Update `docs/STATUS.md` for runtime facts, `docs/PRODUCT_BACKLOG.md` for open work and `docs/HANDOFF.md` for durable knowledge in the same change.-- 新增、恢复或重写实现前必须按 `peach-reuse-first` 依次检查当前树、`docs/REUSE.md`、Git 历史和成熟外部实现,并用真实输入做最小 POC;只有外部方案不满足已验证约束时才自研,并把例外写回复用清单。旧文件名不存在不等于能力缺失。-- When the user says to imitate, reference or align with another product, obtain current reproducible evidence first and register it per `peach-reference-evidence`. If evidence is unavailable, write `未取得`; do not ship a guessed approximation as a faithful reproduction.-- Never require the user to relay implementation details between agents. Put current facts in `docs/STATUS.md`, durable rules in `docs/HANDOFF.md`/`docs/REUSE.md`, procedures in a skill, and architecture decisions in an ADR.-- 复用既有入口与协议,不自研已有替代(含智能体用量与配额视图):清单与例外见 `docs/REUSE.md`。截图与视觉验收的画面保护判据见 `docs/HANDOFF.md`。+- Never require the user to relay implementation details between agents: facts go to `docs/STATUS.md`, durable rules to `docs/HANDOFF.md`/`docs/REUSE.md`, procedures to a skill, decisions to an ADR.+- 复用优先:新增、恢复或重写实现按 `peach-reuse-first` 依次查当前树、`docs/REUSE.md`、Git 历史与成熟外部实现,旧文件名不存在不等于能力缺失;对齐外部产品先按 `peach-reference-evidence` 取到可复现证据,取不到写 `未取得`,不拿猜测冒充复现。## 门槛(由脚本、测试或 hook 拒绝,不是提醒)@@ -82,9 +79,6 @@## 常犯错误(没有自动拦截,都是真实重犯过的)-- 命令按当前 shell 编写:PowerShell 的 `cat`、`ls`、`where` 是别名,Bash 没有 `Get-ChildItem`。PowerShell 只用 `pwsh` 7.x,从 Bash 调用加 `-NoProfile`。默认单引号,需展开用双引号,歧义用 `${name}`。`rg` 路径不含 `*`,用 `-g` 筛选;退出码 1 表示无匹配。Python CLI 加 `-X utf8`,读 UTF-8 日志加 `-Encoding utf8`。多行内容用写入工具或脚本落盘,不用 heredoc,防止转义损坏。-- PowerShell 变量必须使用任务专属名称;禁止声明 `$HOME`、`$home`、`$CODEX_HOME` 等系统变量的任何大小写变体。`foreach {}` 的结果先存入任务专属数组,再单独接管道格式化,禁止在闭合花括号后直接写管道。+- 多行内容一律用写入工具或脚本落盘再让命令读,不用 heredoc:反斜杠会被吃掉一层,加引号定界符也挡不住,而损坏是静默的——命令照样退出 0,写进去的内容已经变形。其余 shell、PowerShell 与 CI 路径别名的坑见 `peach-shell-commands`。- HTTPS 结论必须使用项目 CA 做严格校验;Schannel、浏览器或取证入口失败时,立即报告原始错误和未取得的验收面,不能改用 HTTP 成功来声称 HTTPS 已通过。-- UI 标签、身份、反馈状态和搜索推荐属于语义契约。修改时必须同时增加数据层测试和页面源测试,不能只改显示文本;推荐词上线前必须对真实 `/api/items` 验证至少一个命中,说明性后缀不得混入搜索词。-- 测试里的临时目录一律先 `.resolve()` 再喂给被测代码和断言。CI runner 的临时目录都是别名(macOS `/var` 软链到 `/private/var`,Windows `RUNNER~1` 短名展开成 `runneradmin`),开发机没有这层别名,拿未 resolve 的路径断言只会在 CI 上红。- 本仓库最常见的缺陷是「只改了自己测试的那条路径」。收尾前按 `peach-surfaces` 逐项说明每个表面适用还是不适用,不要跳过不适用的项。diff --git a/docs/adr/0015-agent-context-layering.md b/docs/adr/0015-agent-context-layering.mdindex 22fadfe2a..d47b12e59 100644--- a/docs/adr/0015-agent-context-layering.md+++ b/docs/adr/0015-agent-context-layering.md@@ -141,6 +141,13 @@`AGENTS.md` 预算从 70 行放宽到 90 行,多出来的额度专用于术语表与覆盖声明这两件常驻构件;其余新增内容仍应落到技能或 `docs/`。+2026-09-08 复核清退 `AGENTS.md`:工作规则里四条已由 ADR-0017/0021/0022/0023 承载的事实+并成一行指针,常犯错误里的 shell 语法、PowerShell 变量命名与 CI 临时目录别名下沉到新技能+`peach-shell-commands`,UI 语义契约下沉 `peach-web-ui`。留在入口的判准是判据 1:违反会+损坏真实数据或产出假结论。下沉的那几条违反后是命令当场报错或 CI 变红,代价是一次重试,+不是假结论;唯一例外是多行内容的转义损坏(静默),它的核心判据留在入口。文件从 12.2 KB+降到 10.0 KB,字节预算同步降为 11 KB、行数降为 88。+2026-08-27 复核已清退 `docs/HANDOFF.md` 中会变化的外部测量、旧测试数字、模型能力说明,以及已由技能、测试或 `docs/STATUS.md` 承担的重复事实;长期文档从 259 行降到 157 行,预算同步降为180 行。运行态仍以 `docs/STATUS.md` 为单一真相位置。diff --git a/scripts/check_context_budget.py b/scripts/check_context_budget.pyindex 190f44bd3..540947f1a 100644--- a/scripts/check_context_budget.py+++ b/scripts/check_context_budget.py@@ -36,6 +36,7 @@ BUDGET_CHANGES = {"AGENTS.md": [(70, "2026-08-17", "初始值"),(90, "2026-08-17", "术语表与覆盖声明是每个任务都要成立的常驻构件,下沉到技能即失效"),+ (88, "2026-09-08", "工作规则的事实条目并进 ADR 指针,常犯错误里的 shell 与路径下沉技能"),],"docs/HANDOFF.md": [(260, "2026-08-17", "初始值"),@@ -57,7 +58,14 @@ MAX_EVER_BYTES = {# 字节预算的变更记录,语义与 BUDGET_CHANGES 完全一致:只能降,上调要写明理由。BYTE_BUDGET_CHANGES = {- "AGENTS.md": [(12 * 1024, "2026-09-03", "初始值")],+ "AGENTS.md": [+ (12 * 1024, "2026-09-03", "初始值"),+ # 清退腾出来的余量留着不动,等于把位置空出来让散文回填——这个文件就是这么长到+ # 12 KB 的,ADR-0015 自己记着那个反例(涨到 82 行后预算在同一批里从 70 改成 90)。+ # 留 1 KB 是有用处的:真出现一条判据 1 的规则要能当场写进来,不必先走一次上调。+ # 一行 130~150 字节,1 KB 约等于 7 行。这个数不是测出来的最优值,它只是闸门。+ (11 * 1024, "2026-09-08", "清退后 10.0 KB,留 1 KB 给判据 1 的新规则,其余余量收回"),+ ],"docs/HANDOFF.md": [(24 * 1024, "2026-09-03", "初始值")],"docs/STATUS.md": [(12 * 1024, "2026-09-03", "初始值"),