 CodexandClaude Opus 4.7
|
fb82213d53
|
refactor(underlying): 抽 _get_screenshot_direct 到 underlying_operations_pkg/screenshot_direct (2416 → 1930)
497 行的 ADB 截图实现(含 exec-out 主路径 + 多重兜底 + watchdog)整段抽到
underlying_operations_pkg/screenshot_direct.capture_screenshot_direct,
原方法保留 9 行 thin shim:
def _get_screenshot_direct(self, device_id, path="pic"):
from douyin.core.underlying_operations_pkg.screenshot_direct import (
capture_screenshot_direct,
)
return capture_screenshot_direct(self, device_id, path)
净减 486 行。函数体过深的两层嵌套截图逻辑现在独立成模块,方便单独测试与改进。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 22:55:34 +08:00 |
|
 CodexandClaude Opus 4.7
|
ffd048ffa5
|
refactor(fudai): 抽 run_once_basic 0.1 高价值预约检查到 helper (2079 → 1541)
新增 5 个 helper 到 run_once_basic_helpers.py:
- handle_reservation_check 0.1 预约检查主入口
- _maybe_clear_reservations_on_first_run 首次运行清空队列 + 状态文件
- _log_reservation_check_trigger 调试日志:检查触发条件
- _run_reservation_attend_window 队列满处理 / 抢占逻辑
- _log_reservation_attend_check 调试日志:第一个预约信息
净减 538 行重复嵌套样板。新增 7 个单元测试覆盖:
- 高价值未启用 / 队列空 → return False
- 首次运行清空队列
- 正常路径调 process_reservation_attend_window
- 队列满 → return True
- needswitch=False 走单间模式 + cleanup
- 等待开奖标志不阻断流程
至此 run_once_basic 总长 612 → 88 行(-86%),douyin_fudai.py
累计 4121 → 1541(-2580 行 / -63%),不再是项目最大文件。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 22:45:51 +08:00 |
|
 CodexandClaude Opus 4.7
|
61cdf7b445
|
refactor(fudai): 抽 _handle_in_fudai_detail 步骤1 第二次打开分支 (2216 → 2079)
新增 handle_second_open_branch helper:
- 取 _last_fudai_detail_tuple;缺失/无效则重新读取(兜底)
- 有效缓存:从 countdown_tuple 提取 future_ts/原始秒数 + 设到 self
- 调 attend_choujiang:成功清标志 / 失败累加计数 / 异常 fall through
顺手修了一个 latent bug:first-open 抽出后 caller 还在用 step3_start /
skip / skip_reason 这些已不在作用域里的变量。改成从 self._last_fudai_detail_tuple
重新取 detail,去掉无意义的 step3_elapsed 日志,step4 的 skip 参数
直接传 (False, "") —— skip 已在 first-open 内部处理完。
净减 146 行嵌套样板。新增 6 个 second-open 单元测试覆盖:
- 缓存缺失重读 + fall through
- 短 tuple 触发重读
- attend 成功清标志清失败计数
- attend 失败累加计数
- attend 异常 fall through
- 缓存有效时正确设置 _current_fudai_future_ts
至此 _handle_in_fudai_detail 总长 506 → 215 行(-58%),
douyin_fudai.py 累计 4121 → 2079(-2042 行 / -50%)。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 22:18:33 +08:00 |
|
 CodexandClaude Opus 4.7
|
ca953cb4ba
|
refactor(fudai): 抽 _handle_in_fudai_detail 步骤2+3 第一次打开分支 (2568 → 2216)
新增 5 个 helper 到 handle_detail_helpers.py:
- handle_first_open_branch 第一次打开主入口
- _validate_first_open_detail 数据验证失败处理
- _check_skip_and_handle 筛选检查 + 高价值预约 + 切房
- _try_high_value_reservation 高价值倒计时阈值判断(return/continue/still_skip)
- _handle_skip_filter 普通筛选不通过:关详情 + 切房
- _fallback_swipe_up swipe_up_to_next_live 不存在时的兜底
净减 354 行嵌套样板代码。新增 8 个单元测试覆盖:
- detail 无效 / 短 tuple
- 数据验证失败
- 筛选通过保存数据
- 普通筛选不通过 + needswitch true/false
- 高价值阈值内立即参与
- 高价值阈值外记预约
至此 _handle_in_fudai_detail 总长 1010 → 506 行(-50%),
douyin_fudai.py 累计 4121 → 2216(-1905 行 / -46%)。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 22:00:24 +08:00 |
|
 CodexandClaude Opus 4.7
|
aeb51f73c7
|
chore(fudai): 清理 _handle_in_fudai_detail 死代码 + 4 处重复 cleanup
- 1 处 dead code:is_second_open 重复赋值(同一变量连读两次)
- 4 处内联"清除任务数量标志 + 嵌套 try"块用 _hd_helpers._clear_task_count_flag 替换
净减 50 行重复样板,2614 → 2568 行。
全套 1172 个测试通过。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 21:35:38 +08:00 |
|
 CodexandClaude Opus 4.7
|
0540610c75
|
refactor(fudai): 抽 _handle_in_fudai_detail last_status 检查到 helper (2872 → 2614)
新增 3 个 helper:
- check_last_status_branch:根据 _last_fudai_detail_status 路由 4 个状态
(coupon_popup / watch_task / validation_failed / error)
- _clear_task_count_flag:清除 _fudai_detail_task_count_from_stage(多分支共用)
- _handle_error_status:error + reason=task_count_zero 时连续 3 次切直播间
净减 260 行重复样板代码。新增 9 个单元测试覆盖:
- 4 种已知 status 各自分支
- 未知/空 status 不触发
- task_count_zero 第 1 次仅累计、第 3 次强制切房 / needswitch=False 不切
至此 _handle_in_fudai_detail 总长 1010 → 752 行,
douyin_fudai.py 累计 4121 → 2614(-1507 行 / -37%)。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 21:23:26 +08:00 |
|
 CodexandClaude Opus 4.7
|
7b6dec820b
|
refactor(fudai): 抽 _handle_in_fudai_detail 步骤3末尾两个小段 (2926 → 2872)
新增 2 个 helper:
- check_invalid_detail_fallback:兜底检查(content="" + value=0 → 视为无效详情)
- prepare_for_attend:记 attend_before_ts + 提取 future_ts + 重置 _detail_closed_by_attend
净减 54 行重复样板代码。新增 9 个单元测试覆盖:
- 空内容+0价值识别为无效
- 正常内容不触发兜底
- detail tuple 短或非 tuple 不抛
- prepare_for_attend 正确返回 attend_before_ts 和写入 future_ts
至此 _handle_in_fudai_detail 总长 1872 → 1010 行(-862 行 / -46%),
douyin_fudai.py 4121 → 2872(累计 -1249 行 / -30%)。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 21:16:06 +08:00 |
|
 CodexandClaude Opus 4.7
|
8a975f2bf6
|
refactor(fudai): 抽 _handle_in_fudai_detail 步骤4 到 handle_detail_helpers (3174 → 2926)
新增 3 个 helper:
- step4_make_join_decision:参与决策入口(detail=None 短路 + 调 basic_join_decision)
- _handle_reservation_completion:参与成功是预约福袋时的锁定期处理 + 队列清理
- _close_detail_after_attend:根据 _detail_closed_by_attend 决定是否点 click_back
净减 251 行重复代码。新增 7 个 step4 单元测试覆盖:
- detail=None 短路
- join_decision 失败不设标志
- countdown 有效设标志 + 关详情
- attend 已关详情时跳过 click_back
- 预约福袋无其他预约 → 清锁定期
- 预约福袋有其他预约 → 设保护期
- countdown 已过期不设标志
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 21:09:24 +08:00 |
|
 CodexandClaude Opus 4.7
|
cea3aced73
|
feat(web_gui): WebUI 启动时自动重连上次 WiFi 设备 + 智能匹配
新增 /api/wifi/auto-reconnect 端点,把桌面 GUI 的 _try_reconnect_last_wifi
逻辑搬到服务端:先 verify_adb_target 上次的 target → 失败则 discover_adb_devices
扫描 + pick_best_match 智能匹配。返回结构化 JSON 让前端渲染:
action: noop | already_online | reconnected | matched | failed
target / model / message / devices
webui/app.js DOMContentLoaded 末尾调用 tryAutoReconnectLastWifi(),
不阻塞页面加载。命中后自动刷新设备下拉并选中。
至此桌面 GUI 和 WebUI 在 WiFi 重连体验上完全对齐:换网段也能找回手机。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 20:53:23 +08:00 |
|
 CodexandClaude Opus 4.7
|
5966f461c3
|
feat(wifi_adb): 启动重连失败时自动扫描子网 + 智能匹配
新增 pick_best_match(devs, last) 纯函数,按优先级匹配上次设备:
1. target 完全一致(IP 没换)
2. 同 model + 同 port(换 IP 但同一台手机)—— 多台同型号时返回 None 让用户选
3. 同主机段 + 同 port(弱兜底,仅唯一时返回)
4. 唯一一台 connected(扫到就一台时认定)
GUI _try_reconnect_last_wifi 流程升级:
- verify_adb_target 失败(不可达)→ 自动 discover_adb_devices 扫子网
- pick_best_match 命中 → 选中 + 更新 last_wifi_target
- 命中且 IP 已变 → 日志写"上次目标 X 已变 → 智能匹配到 Y(已更新记忆)"
- 没命中 → 列出候选 + 提示点'扫描 WiFi'手选
实际场景:换 WiFi 网段(家里 → 公司 / 192.168.1 → 192.168.5)后
GUI 启动时自动找回同一台手机,无需任何手动操作。
新增 15 个 pick_best_match 单元测试覆盖所有规则 + 边界。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 20:46:23 +08:00 |
|
 CodexandClaude Opus 4.7
|
3d91764f56
|
feat(webui): WebUI 加"扫描 WiFi"按钮,对齐桌面 GUI
- index.html:WiFi ADB 操作行加"扫描 WiFi"按钮 + 扫描结果区域
- app.js:wifiScan() 调 /api/wifi/scan
- 单个 connected:自动填回 IP,刷新设备
- 多个候选:渲染列表,点击就填回 IP
- unauthorized:提示需手机端授权
- 单击列表项 → 填 wifi_ip 输入框 + 刷新设备下拉
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 20:40:54 +08:00 |
|
 CodexandClaude Opus 4.7
|
8c3a162deb
|
feat(web_gui): WebGUI 对齐桌面 GUI 的 WiFi 扫描和 last_wifi_target 能力
新增 4 个端点:
- POST /api/wifi/scan 扫描局域网 ADB 设备
- GET /api/wifi/last 查询上次连接记录
- POST /api/wifi/last 同上(POST 方便 fetch)
- POST /api/wifi/last/clear 清除记录
同步 connect / disconnect 路径行为:
- /api/wifi/connect 成功后写入 last_wifi_target(取设备型号)
- /api/wifi/disconnect 如果断的就是上次记住的设备 → 自动清除记录
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 20:33:22 +08:00 |
|
 CodexandClaude Opus 4.7
|
b3a41db029
|
feat(wifi_adb): WiFi-ADB 设置对话框三个连接路径都记 last_wifi_target
补齐之前 main commit a71f6fa 漏的几处:
- "连接"按钮:成功后保存 ip:port + 设备型号到 last_wifi_target
- "自动连接"按钮:从 USB → WiFi 切换成功后保存
- "断开连接"按钮:如果断开的就是上次记住的 IP,清掉记录避免下次启动徒劳重试
行为现在统一:所有"连上一台 WiFi 设备"的入口都会更新记忆,所有"主动断开"
的入口都会清除记忆。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 20:21:24 +08:00 |
|
 CodexandClaude Opus 4.7
|
a71f6faed0
|
feat(wifi_adb): 记住上次成功的 WiFi 设备,GUI 启动时自动重连
新增 gui/gui_core_pkg/config.py 三个 helper:
- get_last_wifi_target / set_last_wifi_target / clear_last_wifi_target
配置以 last_wifi_target = {target, model, saved_at} 形式存在 config.json 顶层。
GUI 行为:
- "扫描 WiFi" 选中或自动连上一台 connected 设备 → 写入 last_wifi_target
- WiFi 选择对话框"使用选中"也写入
- 主窗口启动后延迟 300ms 后台尝试 verify_adb_target(last.target)
- 已有设备:不打扰
- 重连成功:自动设为当前设备
- unauthorized:提示需手机端授权
- 不可达:提示换网了,引导点'扫描 WiFi'
新增 12 个 last_wifi_target 单元测试覆盖读写/清除/损坏值/缺文件等场景。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 20:16:37 +08:00 |
|
 CodexandClaude Opus 4.7
|
db7a78876b
|
feat(gui): 主窗口加"扫描 WiFi"一键按钮
主窗口设备行的"刷新设备"按钮旁加"扫描 WiFi"按钮。后台线程扫描局域网,
按结果数智能处理:
- 0 个发现 → 日志提示
- 1 个 connected → 自动设为当前设备
- N 个 unauthorized → 提示需手机端授权
- 多个候选 → 弹简化版列表对话框让用户选
省去打开 WiFi-ADB 设置对话框的步骤,常见单机场景一键完成。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 20:09:01 +08:00 |
|
 CodexandClaude Opus 4.7
|
e89393693b
|
feat(wifi_adb): 加局域网 ADB 设备扫描发现
新增 gui/gui_core_pkg/wifi_adb_scan.py(356 行):
- get_local_subnet:从本机 WLAN 出口 IP 推 /24 子网
- parse_subnet_spec:解析 192.168.5.0/24 / 192.168.5.1-100 / 192.168.5.5 / 逗号组合
- probe_adb_port:并发 TCP 探测(默认 0.3s 超时,64 线程并发)
- verify_adb_target:对每个开放端口的 IP 调 adb connect 区分 connected / unauthorized / failed
- discover_adb_devices:主入口,端到端只需 1.5 秒扫完 /24
GUI(gui/gui_app.py)"扫描局域网"按钮加在 WiFi 设备操作区:
- 自动推子网(默认)+ 手动输入支持 CIDR / 范围 / 单 IP / 逗号
- 后台线程扫描,进度条 + 阶段提示
- 列表展示 IP / 状态 / 设备型号 / adb connect 输出,列表中手动选
- 选中已 connected 的设备 → 回填 IP 到主对话框
- unauthorized 设备明确提示需手机端授权
新增 25 个 wifi_adb_scan 单元测试。真机端到端验证通过:1.5s 扫完
192.168.5.0/24 子网,发现 192.168.5.2:5555(PEPM00)connected。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 19:59:19 +08:00 |
|
 CodexandClaude Opus 4.7
|
23d370ae22
|
fix(wifi_adb): 修 3 处导致 WiFi-ADB 自动连接失败的解析 bug
1) get_device_ip 把 ip route 输出里的网段当 IP 返回
原代码看到 "192.168.5.0/24 ... src 192.168.5.2" 时,扫到的第一个含 3 个点的字段是
"192.168.5.0/24",结果用 0/24 当 IP 调 adb connect 必然失败。
改成显式从 "src <ip>" 取,并优先 wlan 接口;加 ip addr show / ifconfig 兜底。
2) auto_connect_wifi_adb 顺序错误
原代码先 tcpip 5555(让设备 adbd 重启、USB 链路断开)再 get_device_ip(需要 USB),
USB 已断必然取不到 IP。改成先 get_device_ip 再 enable_wifi_adb 再 connect。
3) connect_wifi_adb 把"未授权 / 连接被拒"当成功
adb connect 在 unauthorized / cannot connect / failed to authenticate 等场景下
returncode 也是 0;以前只看 returncode + "connected" 子串,未授权也判成功。
改成显式列出失败关键词,并对未授权给清晰的中文提示。
新增 20 个 wifi_adb 单元测试覆盖 3 处回归场景。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 19:32:04 +08:00 |
|
 CodexandClaude Opus 4.7
|
a92cec4ff9
|
refactor(recovery): 抽 3 处桌面自救重复逻辑到 douyin/core/recovery 共享模块
新增 douyin/core/recovery.py(113 行):
- is_douyin_foreground(top_pkg): 统一判断前台是否抖音相关包
- recover_to_douyin(analyser, log=...): 桌面自救主入口(先 launch_package,失败回退点击)
- fallback_click_recovery(analyser, log=...): 旧的点击坐标自救兜底
3 处调用点收敛:
- fudai_modules/run_once_basic_helpers.handle_desktop_recovery:80 行 → 18 行
- douyin/other/douyin_yanghao.py: 3 段重复块(原 ~80 行 each)→ 单行调用
总计净减 -269 行重复代码。新增 13 个 recovery 单元测试 + 修测试 mock。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 19:20:29 +08:00 |
|
 CodexandClaude Opus 4.7
|
4c1d95d4b5
|
feat(recovery): 桌面自救改用包名启动抖音,点击坐标降为兜底
当检测到不在抖音前台时,原先点击桌面图标 + 直播 + 进入直播间 3 步坐标的方式
依赖图标位置和分辨率,不同设备/桌面常常失败。改为优先调用 ADB 包名启动:
- underlying_operations 新增 launch_package(device_id, pkg):
monkey -p <pkg> -c android.intent.category.LAUNCHER 1(主路径)
失败回退到 am start -n <pkg>/<MainActivity>(多个常见 activity 兜底)
默认按 com.ss.android.ugc.aweme / .lite / TikTok 顺序尝试
- 新增 is_douyin_foreground 便捷方法
- 改造 3 处自救点:
fudai_modules/run_once_basic_helpers.py:handle_desktop_recovery
douyin/other/douyin_yanghao.py(养号循环 + _yanghao_check_and_recover_from_desktop ×2)
包名启动失败时仍走旧的点击逻辑作为兜底,向后兼容
新增 12 个单元测试覆盖 launch_package 主路径/兜底/失败和自救新行为。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 19:08:09 +08:00 |
|
 CodexandClaude Opus 4.7
|
3aca02fae4
|
refactor(fudai): 抽 run_once_basic 2 段独立逻辑到 run_once_basic_helpers (3233 → 3174)
新增 2 个 helper:
- handle_just_recorded_reservation:刚记录预约后强制切换直播间
- handle_skip_stage_diagnosis:0.5 跳过阶段检测分支
新增 5 个单元测试。行为保持不变。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 18:37:18 +08:00 |
|
 CodexandClaude Opus 4.7
|
695a84d8b5
|
refactor(fudai): 抽 _handle_in_fudai_detail 入口检查到 handle_detail_helpers (3294 → 3233)
抽出 2 个独立函数到 fudai_modules/handle_detail_helpers.py:
- log_entry_flags:进入方法时记录关键 flags
- handle_consecutive_failures_check:连续参与失败次数检查
新增 5 个单元测试覆盖阈值、needswitch 分支。行为保持不变。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 18:31:43 +08:00 |
|
 CodexandClaude Opus 4.7
|
5802586b20
|
refactor(fudai): 拆 run_once_basic 6 段独立逻辑到 run_once_basic_helpers (4121 → 3294)
抽出 6 个独立函数到 fudai_modules/run_once_basic_helpers.py:
- handle_waiting_for_lottery_result:等待开奖期间持续 OCR 检测
- handle_no_attend_timeout:30 分钟未参与回到推荐页
- handle_desktop_recovery:桌面检测自救
- screenshot_and_diagnose:截图 + 阶段诊断
- handle_high_value_room_revisit:高价值房间重访
- dispatch_stage_branch:弹窗/详情/直播间/推荐页/开奖结果分发
新增 15 个单元测试覆盖各分支。run_once_basic 体积大幅瘦身但行为保持不变。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-22 18:22:17 +08:00 |
|
 CodexandClaude Opus 4.5
|
66eb05e6b1
|
补 reservation_logic.cleanup_validate 子模块单元测试(+10 用例)
- validate_back_to_reservation / cleanup_expired_reservations 函数签名验证
- reservation_logic 全部 6 个子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-22 01:22:56 +08:00 |
|
 CodexandClaude Opus 4.5
|
5a40b49727
|
补 douyin_yanghao_pkg 剩余子模块单元测试(+7 用例)
- _scaled_click / _do_comment 函数签名验证
- douyin_yanghao_pkg 全部 3 个子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:48:38 +08:00 |
|
 CodexandClaude Opus 4.5
|
266c7f2932
|
补 underlying_operations_pkg 剩余子模块单元测试(+14 用例)
- analyse_pic_digits / _swipe_with_sendevent_improved 函数签名验证
- underlying_operations_pkg 全部 10 个子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:45:46 +08:00 |
|
 CodexandClaude Opus 4.5
|
59ac6a3abc
|
补 flow_control_pkg + orchestrator_pkg 子模块单元测试(+12 用例)
- find_and_open_fudai_detail 函数签名验证
- read_fudai_detail_once / read_fudai_detail_with_retries 函数签名验证
- flow_control_pkg / orchestrator_pkg 子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:42:58 +08:00 |
|
 CodexandClaude Opus 4.5
|
df628c11dd
|
补 douyin_fudai_finder_pkg 子模块单元测试(+15 用例)
- FudaiClickExecutor / FudaiDetailVerifier / FudaiImageAcquirer 类存在性验证
- check_have_fudai_with_ready_screenshot_optimized 函数签名验证
- douyin_fudai_finder_pkg 子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:38:43 +08:00 |
|
 CodexandClaude Opus 4.5
|
6996c7813e
|
补 screenshot_manager 子模块单元测试(+17 用例)
- _sanitize_filename_part 纯函数测试(无效字符/中文/路径)
- save_files / save_image 函数签名验证
- screenshot_manager 子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:28:26 +08:00 |
|
 CodexandClaude Opus 4.5
|
0efcfff545
|
补 reservation/core + fudai_modules 模块单元测试(+21 用例)
- format_reservation_context / validate_reservation_item 纯函数测试
- fudai_modules Mixin 类存在性验证
- reservation/core 包导入测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:24:15 +08:00 |
|
 CodexandClaude Opus 4.5
|
b0eccc5171
|
补 bin 模块单元测试(+19 用例)
- format_size / get_log_base_names 纯函数测试
- parse_args 命令行参数解析测试
- manage_logs / run_cli 函数签名验证
- bin 子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:21:03 +08:00 |
|
 CodexandClaude Opus 4.5
|
e8bf904fc6
|
补 douyin/stage 模块单元测试(+23 用例)
- diagnose_stage_from_current_screen 函数签名验证
- StageHandler 类方法检查
- stage_handler_pkg shim 与子模块导出一致性验证
- stage 子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:17:54 +08:00 |
|
 CodexandClaude Opus 4.5
|
8d98143df1
|
补 douyin/core 模块单元测试(+24 用例)
- io_utils 纯函数测试(_verify_png_integrity/_ensure_parent_dir/_safe_replace_file)
- path_config 路径配置函数测试
- version 版本信息格式验证
- flow_control shim 与子模块导出一致性验证
- core 子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:15:34 +08:00 |
|
 CodexandClaude Opus 4.5
|
b5a15ecea4
|
补 douyin/other 模块单元测试(+28 用例)
- _normalize_room_title 纯函数测试(空格/数字/中文)
- high_value_room / popups / lottery 函数签名验证
- yanghao shim 与子模块导出一致性验证
- other 子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:12:54 +08:00 |
|
 CodexandClaude Opus 4.5
|
73008a9763
|
补 douyin/reservation 模块单元测试(+23 用例)
- _compact_text 纯函数测试(空格/中文/边界值)
- match_reservation / validate_back_to_reservation 函数签名验证
- reservation_handler shim 与子模块导出一致性验证
- reservation 子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:09:35 +08:00 |
|
 CodexandClaude Opus 4.5
|
5309aa0198
|
补 douyin/fudai 模块单元测试(+20 用例)
- is_abnormal_time_value 纯函数测试(边界值/异常值)
- validate_fudai_detail 函数签名验证
- fudai_detail shim 与子模块导出一致性验证
- fudai/core 子模块存在性测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:07:15 +08:00 |
|
 CodexandClaude Opus 4.5
|
85d7bb2525
|
补 douyin/detection/pixel 模块单元测试(+14 用例)
- pixel/popups 弹窗检测函数签名验证
- pixel/buttons 按钮检测函数签名验证
- pixel/stage 阶段检测函数签名验证
- shim 与子模块导出一致性验证
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:03:35 +08:00 |
|
 CodexandClaude Opus 4.5
|
3269d3adf6
|
补 gui/components 模块单元测试(+22 用例)
- log_color_config 纯函数测试(get_operation_type/get_color_config)
- mapping_utils 纯函数测试(_format_timestamp)
- gui/components 子模块存在性验证
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 22:00:02 +08:00 |
|
 CodexandClaude Opus 4.5
|
7ef5bc3e07
|
补 douyin/logging 模块单元测试(+30 用例)
- log_formatter 纯函数测试(format_debug_log/action_log/error_log 等)
- PerformanceTracker 类测试
- logging 子模块存在性验证
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 21:56:43 +08:00 |
|
 CodexandClaude Opus 4.5
|
2c8879be7a
|
补 douyin/fudai/core 模块单元测试(+14 用例)
- validate_coords 纯函数测试(边界/修正/无效坐标)
- safe_image_load 函数测试
- fudai/core 子模块存在性验证
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 21:53:47 +08:00 |
|
 CodexandClaude Opus 4.5
|
6ecedbbde1
|
补 douyin/handlers 模块单元测试(+13 用例)
- _adb_path 纯函数测试(环境变量、引号处理、operation 对象)
- SwipeHandler / PopupHandler / ScreenshotHandler 类存在性验证
- swipe_ops 函数签名检查
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 21:50:02 +08:00 |
|
 CodexandClaude Opus 4.5
|
cdf8be0ded
|
补 operations 模块单元测试(+18 用例)
- OCR 缓存机制测试(cache_get/put/clear/stats)
- _img_fingerprint 哈希函数测试
- screenshot_operations / screenshot_service 类存在性验证
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 21:42:39 +08:00 |
|
 CodexandClaude Opus 4.5
|
a6dee879e7
|
补 tools/dev/bump_version.py 单元测试(+10 用例)
- parse_semver 纯函数测试(含边界/异常)
- compute_next 版本号递增测试
- 集成测试:连续 bump 验证
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 21:37:19 +08:00 |
|
 CodexandClaude Opus 4.5
|
9f7e8da57a
|
补 reservation_handler_pkg / stage_handler_pkg 单元测试(+12 用例)
- 验证 shim 与 pkg 导出一致性
- Handler 类方法签名检查
- 子模块导入测试
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-05-21 21:25:50 +08:00 |
|
 CodexandClaude Opus 4.7
|
6bdf7b2527
|
补 5 个剩余子包的综合测试(test_remaining_pkgs.py +20 用例)
覆盖 5 个之前没专门测试的拆分子包,每个写"API 兼容 + 不抛异常"级别的测试
(业务函数依赖大量 analyser 状态 + 真实截图,深度业务测试留给端到端):
- detection_pkg
+ _ensure_detection_cache 创建 _detection_cache 与 _detection_cache_ttl
+ _ensure_detection_cache 多次调用幂等(不覆盖既有 cache)
+ 4 个对外 API callable
- fudai_detail_orchestrator_pkg
+ read_fudai_detail_once / _with_retries 可调用
+ 兼容 shim 与子包指向同一函数对象
- logging_wrapper_pkg.misc
+ log_step_time / log_error_with_context / log_performance_step /
log_debug_info 不抛异常
+ get_performance_stats 返回 dict
- flow_control_pkg
+ 4 个对外 API callable
+ 兼容 shim 与子包指向同一函数对象
- detect_by_template (module-level)
+ 签名 (analyser, rx, pic, region) 正确
+ FudaiDetector.detect_by_template 类方法仍可调用(forwarding)
- underlying_operations_pkg 第二轮新增
+ save_reward_pic / set_clipboard_text / _swipe_with_sendevent_improved /
select_device / analyse_pic_digits 可调用
+ set_clipboard_text 空文本短路返回 False(不调用 ADB)
回归:
- 全套 627 → 647(+20 用例)
- 全部 647 passed in 19s
- compileall exit 0
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 21:04:14 +08:00 |
|
 CodexandClaude Opus 4.7
|
af8145b8a8
|
补 fudai_filter_pkg / logging_pkg 单元测试 + 修 monitor 缺 datetime import
新增测试:
- test_fudai_filter_pkg (24)
覆盖 helpers / should_skip / join_decision 三个子模块
含 _is_short_countdown_text / is_watch_task_fudai / check_contain
+ should_skip_fudai_by_config 5 个业务场景断言(高价值通过 / 观看任务跳过 /
低价值跳过 / 黑名单跳过 / 单间模式必参)
- test_logging_pkg (22)
覆盖 _common 全局状态 + handlers 类构造 + cleanup 纯函数边界 + monitor
类构造 + config 全部对外 API(get_logger 缓存 / get_caller_info /
format_exception_info / LogContext / log_function_call 装饰器)
修复 1 个真实回归 bug:
- douyin/logging/douyin_logging_pkg/monitor.py 缺 from datetime import datetime
(原文件用的是 from datetime import datetime, timedelta;拆分时只写了
import 模块导致 datetime.now() 抛 NameError)
修复后 LogRotationMonitor 可正常构造
回归:
- 全套 581 → 627 (+46 用例)
- 全部 627 passed in 22s
- compileall exit 0
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 21:01:15 +08:00 |
|
 CodexandClaude Opus 4.7
|
e417acfb7c
|
为 10 个已拆出的子包补单元测试(+226 用例)
新增 tests/ 下 10 个测试文件,把已拆出的子包从"被外部测试间接覆盖"提升到
"独立可测":
- test_web_gui_pkg (52)
覆盖 logger / ansi / adb_compat / nested / stats_helpers
含 _wg_log/_LOGGER 日志、ANSI 清理、点号路径、_parse_countdown_seconds 等
- test_underlying_operations_pkg (35)
覆盖 adb_helpers / bounds / countdown / ocr_content / pic_path
含 _adb_path 环境变量覆盖、check_countdown 多种格式、OCR 字符纠错
- test_reservation_logic_helpers (21)
覆盖 helpers.py 5 个纯函数(_now_ts / _normalize_room_title /
_calculate_string_similarity / _extract_content_core /
_sort_reservations_inplace 排序稳定性)
- test_screenshot_manager_pkg (47)
覆盖 paths.get_category_for_picname(5 类关键词分类)+
get_latest_attempt_path / get_last_success_path(按 operation_type 路径推断)
+ 异步计数器
- test_gui_core_pkg (13)
覆盖 RunParams dataclass 28 字段构造 + adb 函数 + read_config / write_config
roundtrip
- test_fudai_core_pkg (17)
覆盖 _FudaiOcrExecutorState 单例 + _get_fudai_ocr_executor 缓存复用 + 11
个 thin_wrappers 与原实现等价行为
- test_handler_shells (8)
覆盖 ReservationHandler / StageHandler / LoggingWrapper 三个薄壳类的
staticmethod forwarding 完整性
- test_yanghao_pkg (14)
覆盖 _yanghao_log(_log_kv 优先 + logger fallback + broken analyser
兜底 + 未知 level 不抛)+ yanghao_get_recommend_seconds 默认值
- test_pixel_common (6)
覆盖 _safe_open_screenshot_rgb 用 tmp_path 构造合法/损坏/截断/RGBA PNG
- test_fudai_finder_pkg (13)
覆盖 5 个类(FudaiImageAcquirer / FudaiDetector / FudaiClickExecutor /
FudaiDetailVerifier / FudaiFinder)实例化与组合关系,verify
detect_by_template 类方法签名仍兼容(拆出后)
回归:
- 全套测试 355 → 581(+226 用例)
- 全部 581 passed / 1 skipped in 27s
- 新拆出的 12 个子包现在都有专门的单元测试覆盖
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 20:54:35 +08:00 |
|
 CodexandClaude Opus 4.7
|
2d928c3856
|
FudaiDetector.detect_by_template 拆出(957→655,瘦身 302 行)
把 douyin/fudai/douyin_fudai_finder_pkg/detector.py 的 FudaiDetector.detect_by_template
(306 行 / 4 个 self.X)搬到独立子模块 detect_by_template.py(321 行)。
策略:
- self.analyser → analyser(参数)
- self.rx → rx(参数)
- 类方法保留为 1 行 forwarding:
def detect_by_template(self, pic, region):
return _impl(self.analyser, self.rx, pic, region)
- detector.py 内顶部 import detect_by_template 模块的实现
回归:
- 2 个文件 compileall 通过
- pytest 355 passed / 1 skipped
- FudaiFinder() 实例化正常,FudaiDetector.detect_by_template 类方法仍可访问
- module-level detect_by_template 可独立调用
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 20:31:27 +08:00 |
|
 CodexandClaude Opus 4.7
|
57d99f3459
|
拆分 douyin_fudai_core (2205 → 2124 + 3 个子模块)
把 douyin/fudai/douyin_fudai_core.py 中工具/兼容部分搬到
douyin/fudai/douyin_fudai_core_pkg/ 子包:
- ocr_executor (46) _FudaiOcrExecutorState 类 + _fudai_ocr_executor_state
全局实例 + _get_fudai_ocr_executor 池复用函数
- thin_wrappers (65) 11 个 [兼容] 薄壳 forwarding 函数
(attend_choujiang / check_lucky_draw_result /
is_watch_task_fudai / should_skip_fudai_by_config /
basic_join_decision 等)
巨型 get_fudai_contain (2062 行) 留在原文件。原文件从子包 import 后
re-export,外部全部不需修改:
- should_skip_fudai_by_config 24 处外部引用
- attend_choujiang 15 处 / is_watch_task_fudai 13 处 / basic_join_decision 13 处
- 其他 1-10 处
回归:
- 4 个新/改文件 compileall 通过
- pytest 355 passed / 1 skipped(其中 2 个新 _is_short_countdown_text 测试也通过)
- attend_choujiang shim ⇄ pkg 同一对象
- should_skip_fudai_by_config(高价值) 返回 (False, 'ok')
- _fudai_ocr_executor_state.workers = 0 全局实例正常
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 20:25:34 +08:00 |
|
 CodexandClaude Opus 4.7
|
a337b4b93d
|
underlying_operations 第三轮拆分(2434 → 2351,再瘦身 83 行)
新增 2 个子模块:
- device_select (新, 73) select_device 设备选择交互(无 self.X)
- ocr_digits (新, 49) analyse_pic_digits 数字 OCR 识别
(保留 analyser 参数以调 analyser.analyse_pic_word)
策略:
- select_device 的 self.X 全是 _adb_path / _adb_args,已经是 module-level,
搬出后改用 from .adb_helpers import _adb_path, _adb_args 即可。
- analyse_pic_digits 用 self.analyse_pic_word(递归调用类内大方法)。
搬到 module-level 后第一参数从 self 改名 analyser,类内 forwarding
传 self 即可,外部 op.analyse_pic_digits(picname) 完全兼容。
回归:
- 4 个新/改文件 compileall 通过
- pytest 353 passed / 1 skipped
- underlying_operations.select_device / analyse_pic_digits 类方法和 module-level
函数都可访问
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 20:12:40 +08:00 |
|
 CodexandClaude Opus 4.7
|
57eacb3219
|
underlying_operations 第二轮拆分(2582 → 2434,再瘦身 148 行)
新增 3 个子模块 + 1 个函数搬到已有子模块:
- adb_helpers (38) 新增 _adb_args(构造 adb -s 命令行)
- reward_pic (新, 73) save_reward_pic(中奖截图保存)
- swipe_sendevent (新, 47) _swipe_with_sendevent_improved(sendevent 滑动)
- clipboard (新, 75) set_clipboard_text(设备剪贴板设置)
策略:4 个方法的 self.X 引用都是 self._adb_path / self._adb_args 这种
"无状态工具方法",可以替换为 module-level 函数调用。类内方法保留为
1 行 forwarding 调用 _impl_X。
外部调用全部不需修改:
- save_reward_pic 4 处外部 self.save_reward_pic 仍工作
- _adb_args / _swipe_with_sendevent_improved / set_clipboard_text 0 外部引用
回归:
- 5 个新/改文件 compileall 通过
- pytest 353 passed / 1 skipped
- 类的 _adb_args / save_reward_pic / set_clipboard_text /
_swipe_with_sendevent_improved 4 个 forwarding 全部正确
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-05-21 20:07:23 +08:00 |
|