Files
cmshoppe/docs/current-state.md
T
chengma 3832697fc4 docs: 补强 V1 数据与测试设计
- 扩展 SQLite schema:新增 batches、Excel 行定位、stage/status、时间戳和重试字段

- 明确 SQLite worker 并发规则:独立 connection、WAL、busy_timeout、短事务

- 调整 AI 接入顺序:先做模型清单后端,再接真实 ai.py,设置页复用后端

- 补充 unittest 测试基座要求和分层验证策略

- 敏感信息改为本地明文保存,配合 gitignore、UI 打码和日志脱敏
2026-06-26 16:27:33 +08:00

90 lines
5.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 当前实现状态
> 本文是可覆盖的当前快照,记录代码与任务看板的现实状态。
> 历史执行流水追加到 [`../progress.md`](../progress.md),不在本文重复完整日志。
## 当前快照
- 日期:2026-06-26
- 阶段:V0 单账号 CDP 流程已验证;V1 多账号管理 + 5 Tab GUI + Excel/AI 流水线为既定设计,尚未开始编码。
- 技术栈:Python 3.10+,自研 CDP(websocket-client + requests),SQLite(sqlite3)+ `config.json` + openpyxl + AI(服务商待定),GUI PySide6 5 Tab(已定)。
- 生产代码:尚无 `appconfig/db/excel/config/chrome/editor/gui/workers`;现有为验证脚本 + `cdp.py`。
- 测试:当前以 `py_compile` + 在测试商品上手动跑 `prototypes/demo.py` 为主;T-006 将补 `unittest` 自动化测试基座。
- 数据:无 `config.json`、`cmshopee.db`、`chrome_user_data_dir/`(待 Phase 0/1 建立)。
## 既定设计要点(文档已定)
- GUI:**PySide6 5 Tab 流水线**,顺序 ① 导入采集 → ② AI生成 → ③ 更新shopee → ④ 账号管理 → ⑤ 设置;后台任务用 worker/QThread/signal。
- 流水线阶段:imported → collected(采集旧标题/旧封面+下载+回写)→ generated(AI 提示词生成新标题/新封面)→ applied(③ 弹窗批量确认后改 Shopee 并提交)。**无 confirmed、无常驻提交开关。**
- 存储:`config.json`(应用设置)+ `config/ai_models.json`(AI 模型清单与本地明文 Key)+ SQLite `cmshopee.db`(账号/任务/各阶段结果)+ openpyxl(Excel)+ 本地 `images/`(旧/新封面)。
- 多账号隔离:每账号独立 user-data-dir(非 profile)。
- 账号↔任务绑定:以 Excel“别名”列为权威;未匹配略过,结束弹窗汇总。
- 执行:多账号串行、单条失败继续;③ 点击「开始更新」后弹窗确认当前筛选范围和任务数量,确认后逐条点「更新」提交线上。
- AI:服务商待定;生成内容直接用于更新,本地留档+回写 Excel 供追溯。
- 登录:人工登录 + 程序检测,不自动登录;首次未配账号/未登录时 ① ③ 禁用并引导去④。
## 当前目录要点
| 路径 | 状态 | 说明 |
| --- | --- | --- |
| `docs/` | 已有 | 本 harness coding 文档集合 |
| `cdp.py` | 已有 | CDP 底座:连接/找 tab/开 tab/执行 JS/拖拽(正式模块,留根目录) |
| `prototypes/` | 已有 | 已验证原型/探查脚本(demo/set_title/set_cover/get_title/cookies/inspect_images/grab/1.py),逻辑待并入 `editor.py` 后清理;见 `prototypes/README.md` |
| `chrome-remote-debug-lan.md` | 已有 | WSL→Windows CDP 转发排查记录 |
| `appconfig.py` / `db.py` / `excel.py` / `config.py` / `chrome.py` / `editor.py` / `gui.py` / `workers.py` | 待建 | Phase 0-3 产出 |
| `config.json` / `cmshopee.db` / `chrome_user_data_dir/` | 待建 | 含配置/业务/凭证,须 gitignore |
## 已验证能力(单账号)
- CDP 连接 Chrome、遍历 tab、读取 shopee.tw Cookie。
- 找到/新建商品详情页 tab,等编辑器就绪。
- 改标题:原生 setter + 派发事件,`value` 与 `modelvalue` 双等于新值。
- 换封面:`setFileInputFiles` 上传(`.shopee-image-manager__upload input[type=file]`)→ 等 CDN 链接 → `Input.dispatchMouseEvent` 拖到第一位(落点 `first.left - 0.30*w`)。
- 「更新」按钮:可点才点,禁用态识别;③ 未批量确认前不提交。
## 任务看板状态
任务状态以 [`06-tasks.md`](06-tasks.md) 为准,历史记录见 [`../progress.md`](../progress.md)。
- 已完成:无(任务均为 TODO;单账号能力以脚本形式存在,待 T-001 模块化)。
- 正在进行:无。
- 下一个可领取任务:Phase 0 的 **T-001(`editor.py` 含采集)/ T-002(`appconfig.py`+`config.json`)/ T-003(`db.py`+SQLite)**——三者无相互依赖,可任选其一起步;AI 真实接入前先做 T-005。
## 当前可运行内容
```bash
# 语法检查
python -m py_compile *.py
# 单元测试(T-006 后)
python -m unittest discover -s tests
# 单账号闭环(不提交线上)
python prototypes/demo.py # 分步(需根目录 cdp.py 可导入)
set AUTO=1 && python prototypes/demo.py # 自动(cmd)
# 真实提交(谨慎)
set UPDATE=1 && python prototypes/demo.py
```
前置条件:
- Chrome 已用某 user-data-dir 带 `--remote-debugging-port` + `--remote-allow-origins=*` 启动并登录 Shopee。
- 已 `pip install websocket-client requests`。
- PySide6 当前环境已可导入(验证版本 6.5.3);GUI 实现固定使用 PySide6。
- 默认连 `127.0.0.1:9222`(开发期可用 `CDP_HOST` 指向 WSL 转发的 `192.168.0.224:9333`)。
## 开始编码前检查
1. 读仓库级 `AGENTS.md` / `CLAUDE.md`(如有)。
2. 读 `docs/00-ai-start-here.md`。
3. 读 `docs/05-coding-rules.md` 与 `docs/04-architecture.md` 第七节。
4. 在 `docs/06-tasks.md` 取第一个 `TODO` 且依赖 `DONE` 的任务。
5. 将该任务状态改为 `DOING`。
## 维护规则
- 新建 `config/chrome/editor/gui/workers` 或改 CDP 选择器后,更新本文与 `04-architecture.md`。
- 任务状态变化同步 [`06-tasks.md`](06-tasks.md);执行记录追加 [`../progress.md`](../progress.md)。
- 本文只保留当前快照,不保留完整历史。