docs: update README/CLAUDE.md for package layout; add Tier 1 spec and plan

Rewrite run commands to python -m inbound_verify.* (and console_script aliases); add pip install -e . to env prep; refresh the directory tree. Also commit the design spec and Tier 1 implementation plan under docs/superpowers/.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-07-23 12:21:45 +08:00
parent 7065b88269
commit a07b9b435b
4 changed files with 926 additions and 48 deletions

View File

@@ -32,20 +32,30 @@
```
InboundVerify/
├── main_router.py # 主入口 / 调度层(菜单、启动浏览器与安能、就绪轮询、登录检测
├── site_shunxin.py # 顺心站点模块(流程 + 重置 + 重试,自洽)
├── site_baishi.py # 百世站点模块
├── site_zto.py # 中通站点模块
├── site_yunda.py # 韵达站点模块(含自动登录
├── site_anneng.py # 安能站点模块Electron + CDP 驱动)
├── expected_undelivered.py # 全站点应到未到离线比对,输出 output/应到未到数据.xlsx
├── paths.py # 统一路径锚点(以本目录为基准,不依赖 cwd
├── pyproject.toml # 打包 + 依赖 + console_scriptsinbound-verify 等
├── inbound_verify/ # 源码包
│ ├── paths.py # 统一路径锚点(以项目目录为基准,不依赖 cwd
│ ├── runtime.py # 两种模式共享核心(启动 / 就绪 / 任务派发 / 心跳)
├── state_store.py # SQLite 状态持久化state/state.db
│ ├── expected_undelivered.py# 全站点应到未到离线比对,输出 output/应到未到数据.xlsx
│ ├── store.py # DB CLI 入口createdb|init|ingest|all
│ ├── sites/ # 各站点模块(流程 + 重置 + 重试,自洽
│ │ ├── shunxin.py # 顺心(含双账号)
│ │ ├── baishi.py # 百世
│ │ ├── zto.py # 中通
│ │ ├── yunda.py # 韵达(含自动登录)
│ │ └── anneng.py # 安能Electron + CDP 驱动)
│ └── cli/ # 命令行入口
│ ├── router.py # 交互菜单(调度层:启动 / 就绪轮询 / 登录检测 / 菜单分发)
│ └── server.py # FastAPI 服务模式(常驻 + HTTP 触发)
├── config.example.yaml # 配置模板
├── config.yaml # 真实配置(自行创建,已被 .gitignore 忽略)
├── requirements.txt
├── downloads/ # 各站点下载的原始数据
├── output/ # 比对报表输出
── docs/ # 说明文档
├── config.yaml # 真实配置(自行创建,已被 .gitignore 忽略)
├── schema.sql # 数据库表结构store.py createdb / init 使用)
├── requirements.txt # pyproject 依赖的静态镜像
├── downloads/ # 各站点下载的原始数据
── output/ # 比对报表输出
├── state/ # 运行状态持久化state.db
└── docs/ # 说明文档
```
---
@@ -63,10 +73,13 @@ python -m venv .venv
# 2. 安装依赖(含安能 CDP 驱动所需的 websocket-client
pip install -r requirements.txt
# 3. 安装 Playwright 浏览器内核(网页站点用
# 3. 以可编辑模式安装本包(注册 inbound-verify 等命令
pip install -e .
# 4. 安装 Playwright 浏览器内核(网页站点用)
playwright install chromium
# 4. 由模板创建本地配置并填入真实凭据
# 5. 由模板创建本地配置并填入真实凭据
cp config.example.yaml config.yaml
```
@@ -96,7 +109,10 @@ cp config.example.yaml config.yaml
## 五、运行
```bash
python main_router.py
# 交互菜单(任选其一)
python -m inbound_verify.cli.router
# 或装包后直接用命令:
inbound-verify
```
程序会:
@@ -126,10 +142,10 @@ python main_router.py
**分层原则:路由层只调度,站点模块自洽。**
- **`main_router.py`(调度层)**:负责启动浏览器 / 安能、就绪轮询、登录检测、
- **`inbound_verify.cli.router`(调度层)**:负责启动浏览器 / 安能、就绪轮询、登录检测、
菜单分发。**不关心**"任务能否完成、失败怎么办"——只调
`site_xxx.xxx_download(page)` 然后等结果。
- **各 `site_xxx.py`(站点模块)**:每个模块对外只暴露一个"把任务做了"的入口
`inbound_verify.sites.xxx_download(page)` 然后等结果。
- **各 `inbound_verify.sites.*`(站点模块)**:每个模块对外只暴露一个"把任务做了"的入口
`xxx_download(...)`,内部自行处理一切:
- `HOME_URL`:站点首页 URL也供路由层 `SITES_CONFIG` 引用,单一来源);
- `xxx_reset(...)`:异常兜底的重置(网页 = 跳首页 URL安能 = 关业务 tab + 收菜单);
@@ -162,4 +178,4 @@ python main_router.py
- 首次运行需手动登录各站点(程序会停在就绪轮询,直到检测到所有站点进入工作台);
- 安能为单实例 Electron 应用:启动前请先关闭已打开的安能窗口;
- 所有下载/输出路径以项目目录为基准(见 `paths.py`),与从哪个目录启动无关。
- 所有下载/输出路径以项目目录为基准(见 `inbound_verify.paths`),与从哪个目录启动无关。