Commit Graph
3 Commits
Author SHA1 Message Date
CodexandClaude Opus 4.7 a864f6e23a refactor(fudai): 抽 __init__ 配置默认值到 init_helpers (1559 → 1323)
fudai_analyse.__init__ L119-354 是 236 行配置字段默认值 + 运行时状态初始化:
- ~80 个 self.X = <default_value> 配置字段
- 30+ 个运行时状态字段
- _reservations_state_path 解析 + room_pos_map 旧文件清理

抽到 douyin/core/fudai_modules/init_helpers.py:
- apply_fudai_defaults(self): 主入口
- _apply_yanghao_defaults(self): 推荐页养号子段
- _resolve_reservations_state_path(self): 解析路径,path_config 失败时
  兜底用 ".." 回退(不再用 dirname(__file__) + "state")
- _cleanup_old_room_pos_map_files(self): 清理上次运行的 JSON/CSV/MD 导出

__init__ 中保留:
- L57-117 设备/分辨率/operation/日志系统初始化(依赖较深,难抽)
- L356-357 self.load_config()

行为完全保留:所有字段值、解析顺序、异常兜底全部不变。
test_runtime_path_anchors.test_reservations_state_path_uses_path_config 已更新
为同时检查 douyin_fudai.py 和 init_helpers.py。

1361 passed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 03:13:46 +08:00
CodexandClaude Opus 4.7 e46497ea80 refactor(underlying): 抽 cut_pic 图片裁剪到 image_ops (1574 → 1327)
underlying_operations.cut_pic L474-721 是 248 行图片裁剪管道:
- 默认/命名两个分支共享重试 3 次的截图加载验证
- 默认分支裁出 cut.png 或 ocr/<name>.png;命名分支裁出 pic/<target>/<name>.png
- 写入 _ocr_coords_cache 供 analyse_pic_word 调试图像引用
- SAVE_CUT_PIC_DEBUG_IMAGES=1 时保存 cut_pic 调试图

抽到 underlying_operations_pkg/image_ops.py:
- cut_pic(self, left_up, right_down, target, name) -> bool
- _ensure_parent_dir / _validate_coords / _save_cut_debug_images 内部 helper

主类方法替换为 4 行委托。

更新两个旧的源码断言测试以适配抽离:
- test_cut_pic_path:从 inspect.getsource(op.cut_pic) 改为读 image_ops.py 文件源码
- test_runtime_path_anchors:把 path_config.get_pic_dir() 检查范围从单一文件
  扩展到 underlying_operations.py + image_ops.py + ocr_pipeline.py 三处

1361 passed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 02:43:36 +08:00
CodexandClaude Opus 4.7 07eee6da52 fix(paths): 修同类型 5 处路径推导 bug + 加回归测试
cut_pic 路径 bug 之后再做地毯式排查,发现 5 处类似潜在 bug:
fallback 分支用 dirname(__file__) 推根级目录,path_config 不可用时
会指向错误位置(推到 douyin/core/pic 等子目录而非项目根 pic/)。

修复:
- underlying_operations.py: screenshot_calls.jsonl 路径 + OCR category 目录
  改用 path_config.get_logs_dir() / get_pic_dir()
- douyin_fudai.py: 2 处 actions.log 兜底路径
  优先 path_config.get_actions_log_path(),兜底加 ".." 回到项目根
- fudai_detail_room_title.py: 截图复用 fallback 路径加 ".." 回退
- fudai_detail_orchestrator_pkg/read_once.py: 同上 2 处 fallback

新增 11 个回归测试覆盖:
- 关键文件不再用单步 dirname/__file__/pic 写法
- path_config 仍把所有路径锚到 PROJECT_ROOT
- 兜底分支必须含 ".." 表示回退

注:douyin_fudai.py:299 的 reservations.json 因 dirname 恰好等于
PROJECT_ROOT/douyin/core,跟 path_config.get_reservations_path() 一致,
不是 bug,未改动。

1226 passed (+11 新增)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 01:21:27 +08:00