提供了一种自动合成以太电池和高保真母盘的实现#4
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 56 minutes and 15 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough新增一个完整的自动合成插件实现,包括主应用程序、工厂类、配置管理、UI设置和两个合成操作流程(高保真母盘和以太电池),配合屏幕交互配置定义。 Changes
Sequence Diagram(s)sequenceDiagram
participant App as AutoSyntheticApp
participant Config as AutoSyntheticConfig
participant CheckCfg as check_config节点
participant HifiOp as HifiMasterSynthesisOp
participant BatteryOp as EtherBatterySynthesisOp
participant Final as final_return节点
participant World as BackToNormalWorld
App->>Config: 加载配置(母盘、电池开关)
App->>CheckCfg: execute()
CheckCfg->>CheckCfg: 根据config构建任务队列
alt 有任务
CheckCfg->>CheckCfg: 返回第一个任务状态
alt 母盘合成
CheckCfg->>HifiOp: 转移至hifi_master节点
HifiOp->>HifiOp: 执行母盘合成流程
HifiOp-->>CheckCfg: 成功→增加任务索引
end
alt 以太电池合成
CheckCfg->>BatteryOp: 转移至source_ether_battery节点
BatteryOp->>Config: 读取合成数量配置
BatteryOp->>BatteryOp: 执行电池合成流程
BatteryOp-->>CheckCfg: 成功→增加任务索引
end
CheckCfg->>Final: 任务全部完成→转移
else 无任务
CheckCfg->>Final: 直接转移至完成节点
end
Final->>World: 执行BackToNormalWorld
World-->>App: 返回最终结果
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 13
🧹 Nitpick comments (3)
plugins/auto_synthetic/auto_synthetic_app.py (1)
23-23: 请补齐类型注解:operation_class与__debug返回类型。这两处目前未满足“函数/方法必须有类型注解”的规则。
As per coding guidelines
所有函数和方法必须有类型注解.Also applies to: 105-105
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/auto_synthetic_app.py` at line 23, The method signatures in auto_synthetic_app.py lack type annotations: add a type for the operation_class parameter in __init__ (e.g. operation_class: Type[BaseOperation] or operation_class: Any if no base type is available) and add an explicit return annotation for __debug (e.g. def __debug(self) -> bool). Also import typing.Type or typing.Any as needed and update the other occurrence referenced (the __debug definition around line 105) to match the same return type annotation.plugins/auto_synthetic/auto_synthetic_run_record.py (1)
8-8: 运行记录 app_id 建议避免硬编码。这里直接写死
'auto_synthetic',与常量源分离;后续若APP_ID调整会产生隐性不一致。建议改为引用常量。建议修改
+from zzz_od.plugins.auto_synthetic.auto_synthetic_const import APP_ID + class AutoSyntheticRunRecord(AppRunRecord): def __init__(self, instance_idx: int | None = None, game_refresh_hour_offset: int = 0) -> None: AppRunRecord.__init__( self, - 'auto_synthetic', + APP_ID, instance_idx=instance_idx, game_refresh_hour_offset=game_refresh_hour_offset )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/auto_synthetic_run_record.py` at line 8, The list currently contains a hardcoded app id string 'auto_synthetic'; change this to reference the canonical constant (e.g., APP_ID) instead of a literal. Import the APP_ID constant from the module that defines application constants (for example the plugin's constants module) and replace the literal in the list with that symbol so code in auto_synthetic_run_record.py uses APP_ID consistently (update any surrounding code that builds or exports this list to use the imported APP_ID).plugins/auto_synthetic/auto_synthetic_setting_flyout.py (1)
15-15:_setup_ui的参数需要补齐类型注解。
layout当前缺少类型注解,不满足仓库的函数/方法注解要求。As per coding guidelines
所有函数和方法必须有类型注解.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/auto_synthetic_setting_flyout.py` at line 15, The _setup_ui method is missing a type annotation for its layout parameter; update the method signature def _setup_ui(self, layout) -> None: to include a concrete type (e.g., use typing.Any as a safe default) like def _setup_ui(self, layout: Any) -> None:, add the corresponding import from typing (import Any) at the top of the module, and if this overrides or implements a base/abstract method ensure the annotation matches the declared signature for _setup_ui in related classes/interfaces.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@plugins/auto_synthetic/auto_synthetic_app_factory.py`:
- Around line 9-13: Replace the relative imports in this factory module with
absolute package imports using the zzz_od.plugins.auto_synthetic path: import
auto_synthetic_const, AutoSyntheticApp, AutoSyntheticConfig, and
AutoSyntheticRunRecord from zzz_od.plugins.auto_synthetic (e.g. from
zzz_od.plugins.auto_synthetic import auto_synthetic_const and from
zzz_od.plugins.auto_synthetic.auto_synthetic_app import AutoSyntheticApp, etc.),
ensuring all four symbols (auto_synthetic_const, AutoSyntheticApp,
AutoSyntheticConfig, AutoSyntheticRunRecord) are imported via absolute imports
to comply with the import guideline.
In `@plugins/auto_synthetic/auto_synthetic_app_setting.py`:
- Line 5: Replace the relative import of APP_ID from auto_synthetic_const with
an absolute import using the repository plugin namespace; locate the statement
referencing APP_ID (from .auto_synthetic_const import APP_ID) in
auto_synthetic_app_setting and change it to import APP_ID from
zzz_od.plugins.auto_synthetic.auto_synthetic_const, and do the same for the
other occurrence that uses a relative import (the similar import at the other
spot referenced in the review).
In `@plugins/auto_synthetic/auto_synthetic_app.py`:
- Around line 11-13:
当前模块使用了相对导入(auto_synthetic_const、EtherBatterySynthesisOp、HifiMasterSynthesisOp);按仓库规范将这些改为绝对导入,替换
from . import auto_synthetic_const 和 from .operations... 导入为以
zzz_od.plugins.auto_synthetic 开头的绝对路径(例如引用
auto_synthetic_const、operations.ether_battery_synthesis_op.EtherBatterySynthesisOp、operations.hifi_master_synthesis_op.HifiMasterSynthesisOp),保持名称不变并确保导入路径与包结构一致。
- Around line 88-95: The loop always returns self.round_success(status='全部完成')
regardless of op.execute() outcome, causing failures to be reported as success;
wrap the call to op.execute() (in the block that sets task.result and advances
self.current_task_index) in a try/except or check the returned result status,
set task.result and task.status ('success'/'failed') accordingly, and if a
failure or exception occurs immediately return self.round_failure(...) with a
descriptive status (and possibly include error details), otherwise continue
incrementing self.current_task_index and only call self.round_success(...) after
all tasks truly succeed.
In `@plugins/auto_synthetic/auto_synthetic_config.py`:
- Around line 46-50: The property source_ether_battery_auto_synthetic_quantity
currently returns a ConfigItem object instead of a string which breaks enum
construction in get_battery_click_count; change its default to
SourceEtherBatteryAutoSyntheticQuantity.ALL.value.value and keep the property
return type as str so it always returns the raw string value, then update
get_battery_click_count to safely map the string to the enum (use try:
SourceEtherBatteryAutoSyntheticQuantity(self.source_ether_battery_auto_synthetic_quantity)
except ValueError: fallback to SourceEtherBatteryAutoSyntheticQuantity.ALL) so
invalid values don’t raise and cause the method to return 0.
In `@plugins/auto_synthetic/auto_synthetic_setting_flyout.py`:
- Around line 9-10: Replace the relative imports in
auto_synthetic_setting_flyout.py with absolute imports: instead of "from .
import auto_synthetic_const" and "from .auto_synthetic_config import
SourceEtherBatteryAutoSyntheticQuantity, AutoSyntheticConfig", import the
symbols from the package root (e.g. use "from zzz_od.plugins.auto_synthetic
import auto_synthetic_const" and "from
zzz_od.plugins.auto_synthetic.auto_synthetic_config import
SourceEtherBatteryAutoSyntheticQuantity, AutoSyntheticConfig") so the module
follows the repository's absolute-import convention.
In `@plugins/auto_synthetic/operations/ether_battery_synthesis_op.py`:
- Around line 137-147: The failure branch "未找到数量增加按钮" is unreachable because
_click_increase_button(number) always returns True; either implement real
existence/click-failure detection in _click_increase_button (e.g., verify the
button exists before clicking, check click result/response, return False on any
failure, and surface that to the caller) or remove the caller's conditional that
returns round_retry when _click_increase_button is False; update or remove
references to EtherBatteryCoordinate.BTN_INCREASE and ensure
ctx.controller.click uses a validated target and error handling so
_click_increase_button accurately reflects success/failure.
- Around line 15-20: Replace all relative imports in this module with absolute
package imports: change occurrences like "from .common_areas import
EtherBatteryCoordinate" and "from ..auto_synthetic_config import
AutoSyntheticConfig" (and any other "from ...." or "from ....." around lines
~15-20 and ~190-193) to their absolute equivalents (e.g., import from the full
package path starting with plugins.auto_synthetic...), updating the references
EtherBatteryCoordinate and AutoSyntheticConfig accordingly so the module uses
absolute imports throughout.
- Around line 180-183: The back() method ignores the result of
self.round_by_click_area("画面-通用", "返回") and always returns round_success, so
clicking may fail silently; update back to capture the
boolean/OperationRoundResult from round_by_click_area (or its success flag), and
only return self.round_success(wait=1) when the click succeeded—otherwise return
an appropriate failure result (e.g., self.round_failure(...) or propagate the
error) so the flow does not proceed on a failed click; reference the back method
and the round_by_click_area/round_success/round_failure helpers when making this
change.
- Around line 187-190: Both goto_world and __debug are missing return type
annotations; add explicit types: annotate goto_world with the same return type
as round_by_find_and_click_area (e.g., -> bool or the exact type from
round_by_find_and_click_area) and annotate __debug as a no-return helper (->
None) or the appropriate type if it returns something; update the function
signatures for goto_world and __debug to include these return type annotations
and import typing.Any if the exact type is unknown.
In `@plugins/auto_synthetic/operations/hifi_master_synthesis_op.py`:
- Around line 23-24: Add explicit return type annotations to the two methods
missing them: annotate the constructor method __init__(self, ctx: ZContext) with
-> None and annotate the private method __debug(...) with -> None (or the
correct non-None return type if it actually returns a value). Update the
function signatures for __init__ and __debug in the HifiMasterSynthesisOp class
to include these return type annotations to comply with the project rule that
all functions and methods must have type hints.
- Around line 122-125: In return_to_world, the click result from
round_by_click_area("画面-通用", "返回") is ignored; change it to capture the result
(e.g., success = self.round_by_click_area(...)), validate that it succeeded, and
only call and return self.round_success(wait=1) when success is truthy; if the
click failed, return an appropriate failure result (e.g.,
self.round_failed(...)) or trigger a retry/cleanup so the operation doesn't
report success on a failed "返回" click.
- Line 14: 当前在 plugins/auto_synthetic/operations/hifi_master_synthesis_op.py 中对
HifiMasterCoordinate 使用了相对导入(from .common_areas import
HifiMasterCoordinate);请改为插件的绝对模块导入,例如从插件包根模块导入 common_areas 中的
HifiMasterCoordinate(替换相对导入为绝对导入模块路径并保留符号
HifiMasterCoordinate),以遵守导入规范并避免路径不一致问题。
---
Nitpick comments:
In `@plugins/auto_synthetic/auto_synthetic_app.py`:
- Line 23: The method signatures in auto_synthetic_app.py lack type annotations:
add a type for the operation_class parameter in __init__ (e.g. operation_class:
Type[BaseOperation] or operation_class: Any if no base type is available) and
add an explicit return annotation for __debug (e.g. def __debug(self) -> bool).
Also import typing.Type or typing.Any as needed and update the other occurrence
referenced (the __debug definition around line 105) to match the same return
type annotation.
In `@plugins/auto_synthetic/auto_synthetic_run_record.py`:
- Line 8: The list currently contains a hardcoded app id string
'auto_synthetic'; change this to reference the canonical constant (e.g., APP_ID)
instead of a literal. Import the APP_ID constant from the module that defines
application constants (for example the plugin's constants module) and replace
the literal in the list with that symbol so code in auto_synthetic_run_record.py
uses APP_ID consistently (update any surrounding code that builds or exports
this list to use the imported APP_ID).
In `@plugins/auto_synthetic/auto_synthetic_setting_flyout.py`:
- Line 15: The _setup_ui method is missing a type annotation for its layout
parameter; update the method signature def _setup_ui(self, layout) -> None: to
include a concrete type (e.g., use typing.Any as a safe default) like def
_setup_ui(self, layout: Any) -> None:, add the corresponding import from typing
(import Any) at the top of the module, and if this overrides or implements a
base/abstract method ensure the annotation matches the declared signature for
_setup_ui in related classes/interfaces.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d2862b53-6974-439b-9d3e-04adb3f2931c
📒 Files selected for processing (12)
plugins/auto_synthetic/__init__.pyplugins/auto_synthetic/auto_synthetic_app.pyplugins/auto_synthetic/auto_synthetic_app_factory.pyplugins/auto_synthetic/auto_synthetic_app_setting.pyplugins/auto_synthetic/auto_synthetic_config.pyplugins/auto_synthetic/auto_synthetic_const.pyplugins/auto_synthetic/auto_synthetic_run_record.pyplugins/auto_synthetic/auto_synthetic_setting_flyout.pyplugins/auto_synthetic/operations/__init__.pyplugins/auto_synthetic/operations/common_areas.pyplugins/auto_synthetic/operations/ether_battery_synthesis_op.pyplugins/auto_synthetic/operations/hifi_master_synthesis_op.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
plugins/**/*.py
⚙️ CodeRabbit configuration file
plugins/**/*.py: ## 项目背景
这是 ZZZ-OneDragon (绝区零一条龙) 的插件仓库。
插件会被安装到主仓库的zzz_od/plugins/目录下运行。代码规范 (Coding Standards)
- Python 版本: 3.11+
- 使用现代类型注解:
list[str]而非List[str],X | None而非Optional[X]- 所有函数和方法必须有类型注解
- 路径处理优先使用
pathlib- 字符串格式化使用 f-string
- 避免不必要的 try-catch
插件开发规范
文件命名
- 工厂文件必须以
_factory.py结尾- 常量文件必须以
_const.py结尾必需常量 (xxx_const.py)
APP_ID: 插件唯一标识APP_NAME: 插件显示名称DEFAULT_GROUP: 是否出现在一条龙列表推荐元数据 (xxx_const.py)
PLUGIN_AUTHOR: 作者名PLUGIN_HOMEPAGE: 项目主页PLUGIN_VERSION: 版本号PLUGIN_DESCRIPTION: 描述导入规范 (重要!)
✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const
❌ 错误:from . import my_plugin_const(禁止相对导入)审查指南
环境假设
- 目标平台: 1080p 分辨率 + PC
- 允许硬编码像素坐标 (基于 1080p)
- 允许硬编码键盘按键 (如 '`', 'esc')
审查重点 (只关注这些)
- 严重的逻辑错误
- 死循环
- 潜在的运行时崩溃 (Runtime Error)
- 资源泄漏 (如未关闭的文件句柄)
忽略/不要建议
- 缩进、空行、空格等格式问题 (由 Ruff 处理)
- 简单逻辑中的 Magic Number
- 分辨率适配或控制器类型检查
- 过度工程化的"最佳实践"
- 非必要的抽象
Files:
plugins/auto_synthetic/auto_synthetic_app_setting.pyplugins/auto_synthetic/auto_synthetic_run_record.pyplugins/auto_synthetic/auto_synthetic_const.pyplugins/auto_synthetic/auto_synthetic_app_factory.pyplugins/auto_synthetic/auto_synthetic_setting_flyout.pyplugins/auto_synthetic/auto_synthetic_config.pyplugins/auto_synthetic/operations/common_areas.pyplugins/auto_synthetic/operations/hifi_master_synthesis_op.pyplugins/auto_synthetic/operations/ether_battery_synthesis_op.pyplugins/auto_synthetic/auto_synthetic_app.py
🪛 Ruff (0.15.9)
plugins/auto_synthetic/auto_synthetic_app_setting.py
[warning] 14-14: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
plugins/auto_synthetic/operations/ether_battery_synthesis_op.py
[warning] 53-53: String contains ambiguous : (FULLWIDTH COLON). Did you mean : (COLON)?
(RUF001)
[warning] 65-65: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 84-84: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 85-85: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 85-85: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 122-122: String contains ambiguous : (FULLWIDTH COLON). Did you mean : (COLON)?
(RUF001)
[warning] 130-130: String contains ambiguous : (FULLWIDTH COLON). Did you mean : (COLON)?
(RUF001)
plugins/auto_synthetic/auto_synthetic_app.py
[warning] 52-52: Docstring contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF002)
🔇 Additional comments (2)
plugins/auto_synthetic/operations/common_areas.py (1)
4-21: 坐标枚举拆分清晰,可维护性良好。两个场景的区域坐标集中定义,便于后续识别逻辑复用与维护。
plugins/auto_synthetic/auto_synthetic_const.py (1)
1-9: 常量文件结构完整,符合插件元数据约定。
APP_ID / APP_NAME / DEFAULT_GROUP以及推荐元数据均已提供,落地良好。
| from . import auto_synthetic_const | ||
| from .auto_synthetic_app import AutoSyntheticApp | ||
| from .auto_synthetic_config import AutoSyntheticConfig | ||
| from .auto_synthetic_run_record import AutoSyntheticRunRecord | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
工厂模块建议统一为绝对导入。
当前相对导入与插件导入规范不一致,建议改为 zzz_od.plugins.auto_synthetic 绝对路径导入。
As per coding guidelines 导入规范 (重要!): ✅ 正确: from zzz_od.plugins.my_plugin import my_plugin_const / ❌ 错误: from . import my_plugin_const (禁止相对导入).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/auto_synthetic/auto_synthetic_app_factory.py` around lines 9 - 13,
Replace the relative imports in this factory module with absolute package
imports using the zzz_od.plugins.auto_synthetic path: import
auto_synthetic_const, AutoSyntheticApp, AutoSyntheticConfig, and
AutoSyntheticRunRecord from zzz_od.plugins.auto_synthetic (e.g. from
zzz_od.plugins.auto_synthetic import auto_synthetic_const and from
zzz_od.plugins.auto_synthetic.auto_synthetic_app import AutoSyntheticApp, etc.),
ensuring all four symbols (auto_synthetic_const, AutoSyntheticApp,
AutoSyntheticConfig, AutoSyntheticRunRecord) are imported via absolute imports
to comply with the import guideline.
| AppSettingProvider, | ||
| SettingType, | ||
| ) | ||
| from .auto_synthetic_const import APP_ID |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
请改为绝对导入,避免相对导入在插件运行上下文中的不确定性。
当前相对导入不符合仓库插件导入约束,建议统一改为 from zzz_od.plugins.auto_synthetic ... 形式。
As per coding guidelines 导入规范 (重要!): ✅ 正确: from zzz_od.plugins.my_plugin import my_plugin_const / ❌ 错误: from . import my_plugin_const (禁止相对导入).
Also applies to: 14-14
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/auto_synthetic/auto_synthetic_app_setting.py` at line 5, Replace the
relative import of APP_ID from auto_synthetic_const with an absolute import
using the repository plugin namespace; locate the statement referencing APP_ID
(from .auto_synthetic_const import APP_ID) in auto_synthetic_app_setting and
change it to import APP_ID from
zzz_od.plugins.auto_synthetic.auto_synthetic_const, and do the same for the
other occurrence that uses a relative import (the similar import at the other
spot referenced in the review).
| from . import auto_synthetic_const | ||
| from .operations.ether_battery_synthesis_op import EtherBatterySynthesisOp | ||
| from .operations.hifi_master_synthesis_op import HifiMasterSynthesisOp |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
应用主模块也需要改为绝对导入。
相对导入与仓库插件导入规范不一致,建议统一改为 zzz_od.plugins.auto_synthetic...。
As per coding guidelines 导入规范 (重要!): ✅ 正确: from zzz_od.plugins.my_plugin import my_plugin_const / ❌ 错误: from . import my_plugin_const (禁止相对导入).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/auto_synthetic/auto_synthetic_app.py` around lines 11 - 13,
当前模块使用了相对导入(auto_synthetic_const、EtherBatterySynthesisOp、HifiMasterSynthesisOp);按仓库规范将这些改为绝对导入,替换
from . import auto_synthetic_const 和 from .operations... 导入为以
zzz_od.plugins.auto_synthetic 开头的绝对路径(例如引用
auto_synthetic_const、operations.ether_battery_synthesis_op.EtherBatterySynthesisOp、operations.hifi_master_synthesis_op.HifiMasterSynthesisOp),保持名称不变并确保导入路径与包结构一致。
| result = op.execute() | ||
| task.result = result | ||
|
|
||
| # 移动到下一个任务 | ||
| self.current_task_index += 1 | ||
|
|
||
| # 所有任务执行完毕 | ||
| return self.round_success(status='全部完成') |
There was a problem hiding this comment.
任务执行结果未参与流程分支,失败会被误报为“全部完成”。
当前循环里无论 op.execute() 成功或失败,最后都直接 round_success(status='全部完成')。这会掩盖实际失败结果并影响后续调度与统计。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/auto_synthetic/auto_synthetic_app.py` around lines 88 - 95, The loop
always returns self.round_success(status='全部完成') regardless of op.execute()
outcome, causing failures to be reported as success; wrap the call to
op.execute() (in the block that sets task.result and advances
self.current_task_index) in a try/except or check the returned result status,
set task.result and task.status ('success'/'failed') accordingly, and if a
failure or exception occurs immediately return self.round_failure(...) with a
descriptive status (and possibly include error details), otherwise continue
incrementing self.current_task_index and only call self.round_success(...) after
all tasks truly succeed.
| def source_ether_battery_auto_synthetic_quantity(self) -> str: | ||
| return self.get( | ||
| 'source_ether_battery_auto_synthetic_quantity', | ||
| SourceEtherBatteryAutoSyntheticQuantity.ALL.value | ||
| ) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 只读验证:确认 ConfigItem 结构、同仓库同类枚举写法、以及当前字段实际存储形态
set -euo pipefail
echo "== ConfigItem 定义 =="
fd -i "config_item.py" | xargs -r rg -n "class ConfigItem|def __init__|value"
echo
echo "== 全仓库: Enum 成员使用 ConfigItem 的模式 =="
rg -n "Enum\\):|=\\s*ConfigItem\\(" -C2 --type=py
echo
echo "== 全仓库: 这类配置字段如何落盘/读取(是否为字符串) =="
rg -n "source_ether_battery_auto_synthetic_quantity|get_battery_click_count|get\\(|update\\(" -C2 --type=pyRepository: Usagi-wusaqi/zzz-onedragon-plugins
Length of output: 11028
🏁 Script executed:
# 查找 ConfigItem 的导入来源
rg -n "from|import.*ConfigItem" plugins/auto_synthetic/ -B2
# 查看完整的 auto_synthetic_config.py 文件
cat -n plugins/auto_synthetic/auto_synthetic_config.py | head -80
# 查找 ComboBoxSettingCard 和 adapter 的定义
rg -n "class ComboBoxSettingCard|get_prop_adapter|class.*Adapter" --type=py -A5Repository: Usagi-wusaqi/zzz-onedragon-plugins
Length of output: 24220
🏁 Script executed:
# 检查 ApplicationConfig 基类的 get() 方法
rg -n "class ApplicationConfig|def get\(" --type=py -A5 | head -60
# 检查 ComboBoxSettingCard 如何处理 enum 值
rg -n "class ComboBoxSettingCard|options_enum" --type=py -A10 | head -80
# 查找 adapter 如何处理值的转换
rg -n "get_prop_adapter|class.*Adapter|def get\(" --type=py -A5 | head -100Repository: Usagi-wusaqi/zzz-onedragon-plugins
Length of output: 3139
🏁 Script executed:
# 确认枚举构造的参数机制
rg -n "SourceEtherBatteryAutoSyntheticQuantity\(" plugins/auto_synthetic/ -B2 -A2
# 确认 setter 和 getter 的值流向
rg -n "source_ether_battery_auto_synthetic_quantity" plugins/auto_synthetic/ -B1 -A1Repository: Usagi-wusaqi/zzz-onedragon-plugins
Length of output: 3466
枚举成员值类型与 Enum 构造参数不匹配,get_battery_click_count() 会因异常始终返回 0。
这里的问题在于:
- 枚举成员值都是
ConfigItem对象(Line 7-11),访问字符串值需要.value.value(参考 Line 22) - 属性声明返回
str(Line 46),但默认值为SourceEtherBatteryAutoSyntheticQuantity.ALL.value,这是一个ConfigItem对象,不是字符串 - 在
get_battery_click_count()中直接用SourceEtherBatteryAutoSyntheticQuantity(self.source_ether_battery_auto_synthetic_quantity)构造枚举,期望参数为字符串,但枚举成员值是ConfigItem,构造会失败 - 异常被捕获后返回硬编码 0,导致合成点击次数始终为 0
需修复:
- 默认值改为
SourceEtherBatteryAutoSyntheticQuantity.ALL.value.value(获取字符串值) - 重写枚举查找逻辑,正确处理字符串到枚举的映射:
修复方案
`@property`
def source_ether_battery_auto_synthetic_quantity(self) -> str:
return self.get(
'source_ether_battery_auto_synthetic_quantity',
- SourceEtherBatteryAutoSyntheticQuantity.ALL.value
+ SourceEtherBatteryAutoSyntheticQuantity.ALL.value.value
)
def get_battery_click_count(self, max_available: int) -> int:
"""获取电池合成需要点击的次数"""
- try:
- quantity = SourceEtherBatteryAutoSyntheticQuantity(
- self.source_ether_battery_auto_synthetic_quantity
- )
- return quantity.get_click_count(max_available - 1)
- except ValueError:
- return 0
+ raw = self.source_ether_battery_auto_synthetic_quantity
+ for quantity in SourceEtherBatteryAutoSyntheticQuantity:
+ if quantity.value.value == raw:
+ return quantity.get_click_count(max(0, max_available - 1))
+ return 0🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/auto_synthetic/auto_synthetic_config.py` around lines 46 - 50, The
property source_ether_battery_auto_synthetic_quantity currently returns a
ConfigItem object instead of a string which breaks enum construction in
get_battery_click_count; change its default to
SourceEtherBatteryAutoSyntheticQuantity.ALL.value.value and keep the property
return type as str so it always returns the raw string value, then update
get_battery_click_count to safely map the string to the enum (use try:
SourceEtherBatteryAutoSyntheticQuantity(self.source_ether_battery_auto_synthetic_quantity)
except ValueError: fallback to SourceEtherBatteryAutoSyntheticQuantity.ALL) so
invalid values don’t raise and cause the method to return 0.
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (7)
plugins/auto_synthetic/operations/hifi_master_synthesis_op.py (2)
23-24:⚠️ Potential issue | 🟠 Major补全
__init__的返回类型注解。Line 23 这里还缺
-> None,和仓库强制类型注解规则不一致。建议修改
- def __init__(self, ctx: ZContext): + def __init__(self, ctx: ZContext) -> None:As per coding guidelines「所有函数和方法必须有类型注解」。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/operations/hifi_master_synthesis_op.py` around lines 23 - 24, The __init__ method is missing a return type annotation; update the signature of __init__(self, ctx: ZContext) in the class that calls ZOperation.__init__(..., op_name='母盘合成') to include "-> None" so it becomes def __init__(self, ctx: ZContext) -> None:, keeping the existing call to ZOperation.__init__ unchanged.
14-14:⚠️ Potential issue | 🟠 Major请改为插件绝对导入。
这里仍在使用相对导入;插件安装到主仓库后应统一改成
zzz_od.plugins.auto_synthetic...,避免包路径解析不一致。建议修改
-from .common_areas import HifiMasterCoordinate +from zzz_od.plugins.auto_synthetic.operations.common_areas import HifiMasterCoordinateAs per coding guidelines「导入规范 (重要!): ✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const/ ❌ 错误:from . import my_plugin_const(禁止相对导入)」。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/operations/hifi_master_synthesis_op.py` at line 14, 当前文件使用了相对导入 "from .common_areas import HifiMasterCoordinate";请改成插件的绝对导入,例如将该导入替换为 "from zzz_od.plugins.auto_synthetic.common_areas import HifiMasterCoordinate"(并检查同一模块中是否还有其他相对导入一并替换),以符合导入规范并避免包路径解析不一致。plugins/auto_synthetic/operations/ether_battery_synthesis_op.py (3)
15-19:⚠️ Potential issue | 🟠 Major请统一改为绝对导入。
当前文件的运行时导入、
TYPE_CHECKING导入和__debug()里的导入都还是相对路径,和插件导入规范不一致。建议修改
-from .common_areas import EtherBatteryCoordinate +from zzz_od.plugins.auto_synthetic.operations.common_areas import EtherBatteryCoordinate if TYPE_CHECKING: from zzz_od.context.zzz_context import ZContext - from ..auto_synthetic_config import AutoSyntheticConfig + from zzz_od.plugins.auto_synthetic.auto_synthetic_config import AutoSyntheticConfig @@ def __debug() -> None: from zzz_od.context.zzz_context import ZContext - from ..auto_synthetic_config import AutoSyntheticConfig + from zzz_od.plugins.auto_synthetic.auto_synthetic_config import AutoSyntheticConfigAs per coding guidelines「导入规范 (重要!): ✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const/ ❌ 错误:from . import my_plugin_const(禁止相对导入)」。Also applies to: 192-194
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/operations/ether_battery_synthesis_op.py` around lines 15 - 19, 当前文件使用了相对导入(例如 from .common_areas import EtherBatteryCoordinate 以及 TYPE_CHECKING 中的相对路径和 __debug() 内部导入),请把所有相对导入改为插件规范要求的绝对导入:替换 EtherBatteryCoordinate 的导入为绝对路径(例如 from zzz_od.plugins.auto_synthetic.common_areas import EtherBatteryCoordinate),并同样修改 TYPE_CHECKING 中的 ZContext / AutoSyntheticConfig 引入以及 __debug() 里的任何导入,确保运行时导入、类型检查导入和调试分支均使用绝对导入且引用正确的模块名(保留原有符号名 EtherBatteryCoordinate、ZContext、AutoSyntheticConfig 不变)。
189-190:⚠️ Potential issue | 🟠 Major补全
goto_world的返回类型注解。Line 189 这里仍缺
-> OperationRoundResult,和仓库强制类型注解规则不一致。建议修改
- def goto_world(self): + def goto_world(self) -> OperationRoundResult:As per coding guidelines「所有函数和方法必须有类型注解」。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/operations/ether_battery_synthesis_op.py` around lines 189 - 190, The method goto_world is missing a return type annotation; update its signature to declare a return type of OperationRoundResult (e.g., def goto_world(self) -> OperationRoundResult:) so it follows the repo's type-annotation rule; ensure the annotated method still returns the result of calling round_by_find_and_click_area(self.last_screenshot, '画面-通用', '左上角-街区') and import or reference OperationRoundResult if needed.
137-147:⚠️ Potential issue | 🟠 Major
未找到数量增加按钮分支当前不可达。Line 137 依赖
_click_increase_button()返回False,但 Line 142-147 永远返回True。现在即使增加按钮没点到,流程也会继续执行,失败状态永远不会出现。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/operations/ether_battery_synthesis_op.py` around lines 137 - 147, The branch checking `_click_increase_button()` is unreachable because `_click_increase_button` always returns True; change `_click_increase_button(number: int) -> bool` to detect whether the increase button exists/was actually clicked (e.g., use self.ctx.controller.find/exists on EtherBatteryCoordinate.BTN_INCREASE or verify a post-click state) and return False if not found or click failed, and keep the caller logic that calls `round_retry(status='未找到数量增加按钮', wait=1)` when `_click_increase_button` returns False so the failure branch can be triggered (update references: `_click_increase_button`, `EtherBatteryCoordinate.BTN_INCREASE`, `self.ctx.controller.click`, `round_retry`, `round_success`).plugins/auto_synthetic/auto_synthetic_app.py (2)
88-95:⚠️ Potential issue | 🟠 Major任务失败会被误报为“全部完成”。
Line 88 的执行结果只被保存到了
task.result,Line 95 仍无条件返回成功。任一子任务失败时,这里会继续推进current_task_index,最后还会进入final_return,把整次执行记成成功。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/auto_synthetic_app.py` around lines 88 - 95, The loop unconditionally advances current_task_index and ultimately returns self.round_success even if a subtask failed; modify the block around op.execute() so that you (1) catch exceptions from op.execute() and mark the corresponding task (task.result/task.status) as failed, do NOT increment self.current_task_index, and immediately return a failure response via a new or existing method (e.g. self.round_failed or self.round_failure) with a descriptive status; (2) if op.execute() returns a result object that indicates failure, detect that failure, set task.result/task.status accordingly, and return failure instead of continuing; ensure the success return at the end (self.round_success) is only reached when every task completed successfully, referencing task.result, current_task_index, and round_success/round_failed to locate the change.
11-17:⚠️ Potential issue | 🟠 Major请统一改为绝对导入。
当前运行时导入和
TYPE_CHECKING导入都还是相对路径,安装到主仓库后容易出现插件包路径不一致。建议修改
-from . import auto_synthetic_const -from .operations.ether_battery_synthesis_op import EtherBatterySynthesisOp -from .operations.hifi_master_synthesis_op import HifiMasterSynthesisOp +from zzz_od.plugins.auto_synthetic import auto_synthetic_const +from zzz_od.plugins.auto_synthetic.operations.ether_battery_synthesis_op import EtherBatterySynthesisOp +from zzz_od.plugins.auto_synthetic.operations.hifi_master_synthesis_op import HifiMasterSynthesisOp if TYPE_CHECKING: from zzz_od.context.zzz_context import ZContext - from .auto_synthetic_config import AutoSyntheticConfig + from zzz_od.plugins.auto_synthetic.auto_synthetic_config import AutoSyntheticConfigAs per coding guidelines「导入规范 (重要!): ✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const/ ❌ 错误:from . import my_plugin_const(禁止相对导入)」。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/auto_synthetic_app.py` around lines 11 - 17, Replace all relative imports in this module with absolute imports so the plugin works when installed: change the imports of auto_synthetic_const, EtherBatterySynthesisOp, and HifiMasterSynthesisOp to use the package absolute path instead of leading dots (refer to symbol names auto_synthetic_const, EtherBatterySynthesisOp, HifiMasterSynthesisOp), and also switch the TYPE_CHECKING imports to absolute paths for ZContext and AutoSyntheticConfig so they import from the full package module names rather than relative modules.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@plugins/auto_synthetic/auto_synthetic_app.py`:
- Line 23: 在 Task.__init__ 中给参数 operation_class 补充类型注解为 type[ZOperation]:将 def
__init__(self, name: str, operation_class, enabled: bool = True) -> None 改为使用
operation_class: type[ZOperation],并在文件顶部确保已导入 ZOperation(或使用其完整引用名)以消除未定义引用;保持
enabled 和 name 的现有注解不变以满足“所有函数和方法必须有类型注解”的规范。
In `@plugins/auto_synthetic/operations/ether_battery_synthesis_op.py`:
- Around line 86-100: The code treats any round_by_ocr() miss as "储值电卡数量不足",
which misclassifies OCR/UI issues; update the logic in
ether_battery_synthesis_op.py around round_by_ocr, round_success and
max_synthetic_quantity_from_battery_charge so that an OCR miss triggers a
recovery flow (e.g., retry round_by_ocr a couple times with short delays,
optionally fall back to a template match on IMG_PREPAID_CARD or verify UI
loaded) instead of immediately returning '储值电卡数量不足'; only return '储值电卡数量不足' when
you have confirmed the stored-card quantity check
(max_synthetic_quantity_from_battery_charge < 1) fails, return a distinct status
(or retry/abort) for OCR/UI non-detections, and keep the
click(Rect(*EtherBatteryCoordinate.IMG_PREPAID_CARD.value).center) and
round_success('可合成') path unchanged when round_by_ocr succeeds.
---
Duplicate comments:
In `@plugins/auto_synthetic/auto_synthetic_app.py`:
- Around line 88-95: The loop unconditionally advances current_task_index and
ultimately returns self.round_success even if a subtask failed; modify the block
around op.execute() so that you (1) catch exceptions from op.execute() and mark
the corresponding task (task.result/task.status) as failed, do NOT increment
self.current_task_index, and immediately return a failure response via a new or
existing method (e.g. self.round_failed or self.round_failure) with a
descriptive status; (2) if op.execute() returns a result object that indicates
failure, detect that failure, set task.result/task.status accordingly, and
return failure instead of continuing; ensure the success return at the end
(self.round_success) is only reached when every task completed successfully,
referencing task.result, current_task_index, and round_success/round_failed to
locate the change.
- Around line 11-17: Replace all relative imports in this module with absolute
imports so the plugin works when installed: change the imports of
auto_synthetic_const, EtherBatterySynthesisOp, and HifiMasterSynthesisOp to use
the package absolute path instead of leading dots (refer to symbol names
auto_synthetic_const, EtherBatterySynthesisOp, HifiMasterSynthesisOp), and also
switch the TYPE_CHECKING imports to absolute paths for ZContext and
AutoSyntheticConfig so they import from the full package module names rather
than relative modules.
In `@plugins/auto_synthetic/operations/ether_battery_synthesis_op.py`:
- Around line 15-19: 当前文件使用了相对导入(例如 from .common_areas import
EtherBatteryCoordinate 以及 TYPE_CHECKING 中的相对路径和 __debug()
内部导入),请把所有相对导入改为插件规范要求的绝对导入:替换 EtherBatteryCoordinate 的导入为绝对路径(例如 from
zzz_od.plugins.auto_synthetic.common_areas import EtherBatteryCoordinate),并同样修改
TYPE_CHECKING 中的 ZContext / AutoSyntheticConfig 引入以及 __debug()
里的任何导入,确保运行时导入、类型检查导入和调试分支均使用绝对导入且引用正确的模块名(保留原有符号名
EtherBatteryCoordinate、ZContext、AutoSyntheticConfig 不变)。
- Around line 189-190: The method goto_world is missing a return type
annotation; update its signature to declare a return type of
OperationRoundResult (e.g., def goto_world(self) -> OperationRoundResult:) so it
follows the repo's type-annotation rule; ensure the annotated method still
returns the result of calling round_by_find_and_click_area(self.last_screenshot,
'画面-通用', '左上角-街区') and import or reference OperationRoundResult if needed.
- Around line 137-147: The branch checking `_click_increase_button()` is
unreachable because `_click_increase_button` always returns True; change
`_click_increase_button(number: int) -> bool` to detect whether the increase
button exists/was actually clicked (e.g., use self.ctx.controller.find/exists on
EtherBatteryCoordinate.BTN_INCREASE or verify a post-click state) and return
False if not found or click failed, and keep the caller logic that calls
`round_retry(status='未找到数量增加按钮', wait=1)` when `_click_increase_button` returns
False so the failure branch can be triggered (update references:
`_click_increase_button`, `EtherBatteryCoordinate.BTN_INCREASE`,
`self.ctx.controller.click`, `round_retry`, `round_success`).
In `@plugins/auto_synthetic/operations/hifi_master_synthesis_op.py`:
- Around line 23-24: The __init__ method is missing a return type annotation;
update the signature of __init__(self, ctx: ZContext) in the class that calls
ZOperation.__init__(..., op_name='母盘合成') to include "-> None" so it becomes def
__init__(self, ctx: ZContext) -> None:, keeping the existing call to
ZOperation.__init__ unchanged.
- Line 14: 当前文件使用了相对导入 "from .common_areas import
HifiMasterCoordinate";请改成插件的绝对导入,例如将该导入替换为 "from
zzz_od.plugins.auto_synthetic.common_areas import
HifiMasterCoordinate"(并检查同一模块中是否还有其他相对导入一并替换),以符合导入规范并避免包路径解析不一致。
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8d4566b1-3c16-430a-bc88-c72d7fff0123
📒 Files selected for processing (4)
plugins/auto_synthetic/auto_synthetic_app.pyplugins/auto_synthetic/auto_synthetic_config.pyplugins/auto_synthetic/operations/ether_battery_synthesis_op.pyplugins/auto_synthetic/operations/hifi_master_synthesis_op.py
🚧 Files skipped from review as they are similar to previous changes (1)
- plugins/auto_synthetic/auto_synthetic_config.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
plugins/**/*.py
⚙️ CodeRabbit configuration file
plugins/**/*.py: ## 项目背景
这是 ZZZ-OneDragon (绝区零一条龙) 的插件仓库。
插件会被安装到主仓库的zzz_od/plugins/目录下运行。代码规范 (Coding Standards)
- Python 版本: 3.11+
- 使用现代类型注解:
list[str]而非List[str],X | None而非Optional[X]- 所有函数和方法必须有类型注解
- 路径处理优先使用
pathlib- 字符串格式化使用 f-string
- 避免不必要的 try-catch
插件开发规范
文件命名
- 工厂文件必须以
_factory.py结尾- 常量文件必须以
_const.py结尾必需常量 (xxx_const.py)
APP_ID: 插件唯一标识APP_NAME: 插件显示名称DEFAULT_GROUP: 是否出现在一条龙列表推荐元数据 (xxx_const.py)
PLUGIN_AUTHOR: 作者名PLUGIN_HOMEPAGE: 项目主页PLUGIN_VERSION: 版本号PLUGIN_DESCRIPTION: 描述导入规范 (重要!)
✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const
❌ 错误:from . import my_plugin_const(禁止相对导入)审查指南
环境假设
- 目标平台: 1080p 分辨率 + PC
- 允许硬编码像素坐标 (基于 1080p)
- 允许硬编码键盘按键 (如 '`', 'esc')
审查重点 (只关注这些)
- 严重的逻辑错误
- 死循环
- 潜在的运行时崩溃 (Runtime Error)
- 资源泄漏 (如未关闭的文件句柄)
忽略/不要建议
- 缩进、空行、空格等格式问题 (由 Ruff 处理)
- 简单逻辑中的 Magic Number
- 分辨率适配或控制器类型检查
- 过度工程化的"最佳实践"
- 非必要的抽象
Files:
plugins/auto_synthetic/auto_synthetic_app.pyplugins/auto_synthetic/operations/hifi_master_synthesis_op.pyplugins/auto_synthetic/operations/ether_battery_synthesis_op.py
🪛 Ruff (0.15.9)
plugins/auto_synthetic/auto_synthetic_app.py
[warning] 52-52: Docstring contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF002)
plugins/auto_synthetic/operations/ether_battery_synthesis_op.py
[warning] 53-53: String contains ambiguous : (FULLWIDTH COLON). Did you mean : (COLON)?
(RUF001)
[warning] 65-65: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 84-84: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 85-85: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 85-85: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 122-122: String contains ambiguous : (FULLWIDTH COLON). Did you mean : (COLON)?
(RUF001)
[warning] 130-130: String contains ambiguous : (FULLWIDTH COLON). Did you mean : (COLON)?
(RUF001)
| class Task: | ||
| """任务类""" | ||
|
|
||
| def __init__(self, name: str, operation_class, enabled: bool = True) -> None: |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n plugins/auto_synthetic/auto_synthetic_app.py | head -50Repository: Usagi-wusaqi/zzz-onedragon-plugins
Length of output: 2166
🏁 Script executed:
# 搜索 ZOperation 定义
rg "class ZOperation" --type pyRepository: Usagi-wusaqi/zzz-onedragon-plugins
Length of output: 60
🏁 Script executed:
# 查看 operation_class 在文件中的使用
rg "operation_class" plugins/auto_synthetic/auto_synthetic_app.py -A 2 -B 2Repository: Usagi-wusaqi/zzz-onedragon-plugins
Length of output: 862
🏁 Script executed:
# 查看整个 __init__ 方法的实现
ast-grep --pattern $'def __init__($_, operation_class, $_) {
$$$
}'Repository: Usagi-wusaqi/zzz-onedragon-plugins
Length of output: 60
🏁 Script executed:
cat plugins/auto_synthetic/operations/hifi_master_synthesis_op.py | head -30Repository: Usagi-wusaqi/zzz-onedragon-plugins
Length of output: 1162
🏁 Script executed:
cat plugins/auto_synthetic/operations/ether_battery_synthesis_op.py | head -30Repository: Usagi-wusaqi/zzz-onedragon-plugins
Length of output: 1289
🏁 Script executed:
# Search for operation base classes
rg "from one_dragon" plugins/auto_synthetic/operations/ | head -10Repository: Usagi-wusaqi/zzz-onedragon-plugins
Length of output: 1353
补全 Task.__init__ 的参数类型注解。
operation_class 参数缺少类型注解,应补充为 type[ZOperation],以符合编码规范「所有函数和方法必须有类型注解」的要求。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/auto_synthetic/auto_synthetic_app.py` at line 23, 在 Task.__init__
中给参数 operation_class 补充类型注解为 type[ZOperation]:将 def __init__(self, name: str,
operation_class, enabled: bool = True) -> None 改为使用 operation_class:
type[ZOperation],并在文件顶部确保已导入 ZOperation(或使用其完整引用名)以消除未定义引用;保持 enabled 和 name
的现有注解不变以满足“所有函数和方法必须有类型注解”的规范。
| result = self.round_by_ocr( | ||
| self.last_screenshot, | ||
| "以太电池", | ||
| area=ScreenArea(pc_rect=Rect(*EtherBatteryCoordinate.TEXT_ETHER_BATTERY.value)) | ||
| ) | ||
| if result.is_success: | ||
| time.sleep(0.5) | ||
| self.ctx.controller.click(Rect(*EtherBatteryCoordinate.IMG_PREPAID_CARD.value).center) | ||
| return self.round_success(status='可合成') | ||
| else: | ||
| # 移除了模板匹配电池图片的逻辑 | ||
| if self.max_synthetic_quantity_from_battery_charge < 1: | ||
| return self.round_success(status='电量不足') | ||
| else: | ||
| return self.round_success(status='储值电卡数量不足') |
There was a problem hiding this comment.
不要把 OCR 未命中直接当成“储值电卡数量不足”。
这里一旦 round_by_ocr() 没识别到 以太电池,就直接返回成功状态 储值电卡数量不足。UI 未加载、OCR 波动或坐标漂移时都会被提前判成“材料不足”,整条合成流程会被直接跳过。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/auto_synthetic/operations/ether_battery_synthesis_op.py` around lines
86 - 100, The code treats any round_by_ocr() miss as "储值电卡数量不足", which
misclassifies OCR/UI issues; update the logic in ether_battery_synthesis_op.py
around round_by_ocr, round_success and
max_synthetic_quantity_from_battery_charge so that an OCR miss triggers a
recovery flow (e.g., retry round_by_ocr a couple times with short delays,
optionally fall back to a template match on IMG_PREPAID_CARD or verify UI
loaded) instead of immediately returning '储值电卡数量不足'; only return '储值电卡数量不足' when
you have confirmed the stored-card quantity check
(max_synthetic_quantity_from_battery_charge < 1) fails, return a distinct status
(or retry/abort) for OCR/UI non-detections, and keep the
click(Rect(*EtherBatteryCoordinate.IMG_PREPAID_CARD.value).center) and
round_success('可合成') path unchanged when round_by_ocr succeeds.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
plugins/auto_synthetic/auto_synthetic_app.py (1)
11-13:⚠️ Potential issue | 🟡 Minor相对导入还没清干净。
这里的运行时导入和
TYPE_CHECKING导入都还是.开头,插件装入主仓库后建议统一改成zzz_od.plugins.auto_synthetic...的绝对路径,避免继续偏离仓库约定。🔧 建议修改
-from . import auto_synthetic_const -from .operations.ether_battery_synthesis_op import EtherBatterySynthesisOp -from .operations.hifi_master_synthesis_op import HifiMasterSynthesisOp +from zzz_od.plugins.auto_synthetic import auto_synthetic_const +from zzz_od.plugins.auto_synthetic.operations.ether_battery_synthesis_op import EtherBatterySynthesisOp +from zzz_od.plugins.auto_synthetic.operations.hifi_master_synthesis_op import HifiMasterSynthesisOp if TYPE_CHECKING: from zzz_od.context.zzz_context import ZContext - from .auto_synthetic_config import AutoSyntheticConfig + from zzz_od.plugins.auto_synthetic.auto_synthetic_config import AutoSyntheticConfigAs per coding guidelines
导入规范 (重要!): ✅ 正确: from zzz_od.plugins.my_plugin import my_plugin_const / ❌ 错误: from . import my_plugin_const (禁止相对导入).Also applies to: 17-17
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/auto_synthetic_app.py` around lines 11 - 13, Replace the relative imports in auto_synthetic_app.py with absolute imports following the repository convention: change "from . import auto_synthetic_const" to "from zzz_od.plugins.auto_synthetic import auto_synthetic_const" and update the operation imports "from .operations.ether_battery_synthesis_op import EtherBatterySynthesisOp" and "from .operations.hifi_master_synthesis_op import HifiMasterSynthesisOp" to "from zzz_od.plugins.auto_synthetic.operations.ether_battery_synthesis_op import EtherBatterySynthesisOp" and "from zzz_od.plugins.auto_synthetic.operations.hifi_master_synthesis_op import HifiMasterSynthesisOp" respectively; also scan for any other relative imports (including TYPE_CHECKING blocks) in this module and replace them with the corresponding zzz_od.plugins.auto_synthetic absolute paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@plugins/auto_synthetic/auto_synthetic_app.py`:
- Line 38: The code uses two different attribute names for the task index
(current_task_index vs _current_task_index), causing an AttributeError when
_get_next_task_status() reads _current_task_index while __init__() and
check_config() set current_task_index; unify the attribute name across the class
(choose one consistent identifier, e.g., _current_task_index or
current_task_index) and update all references in __init__, check_config(),
_get_next_task_status(), and any increment logic so reads and writes target the
same attribute.
---
Duplicate comments:
In `@plugins/auto_synthetic/auto_synthetic_app.py`:
- Around line 11-13: Replace the relative imports in auto_synthetic_app.py with
absolute imports following the repository convention: change "from . import
auto_synthetic_const" to "from zzz_od.plugins.auto_synthetic import
auto_synthetic_const" and update the operation imports "from
.operations.ether_battery_synthesis_op import EtherBatterySynthesisOp" and "from
.operations.hifi_master_synthesis_op import HifiMasterSynthesisOp" to "from
zzz_od.plugins.auto_synthetic.operations.ether_battery_synthesis_op import
EtherBatterySynthesisOp" and "from
zzz_od.plugins.auto_synthetic.operations.hifi_master_synthesis_op import
HifiMasterSynthesisOp" respectively; also scan for any other relative imports
(including TYPE_CHECKING blocks) in this module and replace them with the
corresponding zzz_od.plugins.auto_synthetic absolute paths.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7e951cdb-6613-4ea6-834f-c5722cf01ce1
📒 Files selected for processing (1)
plugins/auto_synthetic/auto_synthetic_app.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
plugins/**/*.py
⚙️ CodeRabbit configuration file
plugins/**/*.py: ## 项目背景
这是 ZZZ-OneDragon (绝区零一条龙) 的插件仓库。
插件会被安装到主仓库的zzz_od/plugins/目录下运行。代码规范 (Coding Standards)
- Python 版本: 3.11+
- 使用现代类型注解:
list[str]而非List[str],X | None而非Optional[X]- 所有函数和方法必须有类型注解
- 路径处理优先使用
pathlib- 字符串格式化使用 f-string
- 避免不必要的 try-catch
插件开发规范
文件命名
- 工厂文件必须以
_factory.py结尾- 常量文件必须以
_const.py结尾必需常量 (xxx_const.py)
APP_ID: 插件唯一标识APP_NAME: 插件显示名称DEFAULT_GROUP: 是否出现在一条龙列表推荐元数据 (xxx_const.py)
PLUGIN_AUTHOR: 作者名PLUGIN_HOMEPAGE: 项目主页PLUGIN_VERSION: 版本号PLUGIN_DESCRIPTION: 描述导入规范 (重要!)
✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const
❌ 错误:from . import my_plugin_const(禁止相对导入)审查指南
环境假设
- 目标平台: 1080p 分辨率 + PC
- 允许硬编码像素坐标 (基于 1080p)
- 允许硬编码键盘按键 (如 '`', 'esc')
审查重点 (只关注这些)
- 严重的逻辑错误
- 死循环
- 潜在的运行时崩溃 (Runtime Error)
- 资源泄漏 (如未关闭的文件句柄)
忽略/不要建议
- 缩进、空行、空格等格式问题 (由 Ruff 处理)
- 简单逻辑中的 Magic Number
- 分辨率适配或控制器类型检查
- 过度工程化的"最佳实践"
- 非必要的抽象
Files:
plugins/auto_synthetic/auto_synthetic_app.py
🪛 Ruff (0.15.9)
plugins/auto_synthetic/auto_synthetic_app.py
[warning] 42-42: Docstring contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF002)
There was a problem hiding this comment.
♻️ Duplicate comments (1)
plugins/auto_synthetic/auto_synthetic_app.py (1)
37-64:⚠️ Potential issue | 🔴 Critical关键崩溃:任务索引属性名不一致仍未修复。
Line 38、53 写入的是
self.current_task_index,而 Line 59、62 读取的是self._current_task_index(带下划线);Line 76、91 又写回self.current_task_index。只要任务队列非空,check_config末尾调用_get_next_task_status()立刻触发AttributeError,整个应用无法启动。之前评审已指出,此处仍未统一。🐛 建议修改
- if self._current_task_index >= len(self._task_queue): + if self.current_task_index >= len(self._task_queue): return self.round_success(status='全部完成') - current_task = self._task_queue[self._current_task_index] + current_task = self._task_queue[self.current_task_index]As per coding guidelines「审查重点 (只关注这些): 严重的逻辑错误 / 潜在的运行时崩溃 (Runtime Error)」。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_synthetic/auto_synthetic_app.py` around lines 37 - 64, The code uses two different attribute names for the task index (self.current_task_index vs self._current_task_index) causing an AttributeError in _get_next_task_status; unify the attribute name across the class (choose either current_task_index or _current_task_index) and update all references in check_config and _get_next_task_status (and any other methods that touch the task index) to use the same symbol (e.g., update _get_next_task_status to read self.current_task_index or update assignments in check_config to set self._current_task_index), ensuring initialization, reads, and writes are consistent with the chosen name.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@plugins/auto_synthetic/auto_synthetic_app.py`:
- Around line 37-64: The code uses two different attribute names for the task
index (self.current_task_index vs self._current_task_index) causing an
AttributeError in _get_next_task_status; unify the attribute name across the
class (choose either current_task_index or _current_task_index) and update all
references in check_config and _get_next_task_status (and any other methods that
touch the task index) to use the same symbol (e.g., update _get_next_task_status
to read self.current_task_index or update assignments in check_config to set
self._current_task_index), ensuring initialization, reads, and writes are
consistent with the chosen name.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 94e387ec-1112-440c-bac5-a445a52e30d5
📒 Files selected for processing (6)
plugins/auto_synthetic/auto_synthetic_app.pyplugins/auto_synthetic/operations/ether_battery_synthesis_op.pyplugins/auto_synthetic/operations/hifi_master_synthesis_op.pyplugins/auto_synthetic/screen_info/manage_item.ymlplugins/auto_synthetic/screen_info/storage_materials_tools.ymlplugins/auto_synthetic/screen_info/video_shop.yml
✅ Files skipped from review due to trivial changes (3)
- plugins/auto_synthetic/screen_info/video_shop.yml
- plugins/auto_synthetic/screen_info/storage_materials_tools.yml
- plugins/auto_synthetic/screen_info/manage_item.yml
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
plugins/**/*.py
⚙️ CodeRabbit configuration file
plugins/**/*.py: ## 项目背景
这是 ZZZ-OneDragon (绝区零一条龙) 的插件仓库。
插件会被安装到主仓库的zzz_od/plugins/目录下运行。代码规范 (Coding Standards)
- Python 版本: 3.11+
- 使用现代类型注解:
list[str]而非List[str],X | None而非Optional[X]- 所有函数和方法必须有类型注解
- 路径处理优先使用
pathlib- 字符串格式化使用 f-string
- 避免不必要的 try-catch
插件开发规范
文件命名
- 工厂文件必须以
_factory.py结尾- 常量文件必须以
_const.py结尾必需常量 (xxx_const.py)
APP_ID: 插件唯一标识APP_NAME: 插件显示名称DEFAULT_GROUP: 是否出现在一条龙列表推荐元数据 (xxx_const.py)
PLUGIN_AUTHOR: 作者名PLUGIN_HOMEPAGE: 项目主页PLUGIN_VERSION: 版本号PLUGIN_DESCRIPTION: 描述导入规范 (重要!)
✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const
❌ 错误:from . import my_plugin_const(禁止相对导入)审查指南
环境假设
- 目标平台: 1080p 分辨率 + PC
- 允许硬编码像素坐标 (基于 1080p)
- 允许硬编码键盘按键 (如 '`', 'esc')
审查重点 (只关注这些)
- 严重的逻辑错误
- 死循环
- 潜在的运行时崩溃 (Runtime Error)
- 资源泄漏 (如未关闭的文件句柄)
忽略/不要建议
- 缩进、空行、空格等格式问题 (由 Ruff 处理)
- 简单逻辑中的 Magic Number
- 分辨率适配或控制器类型检查
- 过度工程化的"最佳实践"
- 非必要的抽象
Files:
plugins/auto_synthetic/operations/hifi_master_synthesis_op.pyplugins/auto_synthetic/auto_synthetic_app.pyplugins/auto_synthetic/operations/ether_battery_synthesis_op.py
🪛 GitHub Actions: Lint Check
plugins/auto_synthetic/auto_synthetic_app.py
[error] 1-1: Ruff check failed: I001 Import block is un-sorted or un-formatted
🪛 GitHub Check: lint
plugins/auto_synthetic/auto_synthetic_app.py
[failure] 118-118: ruff (W292)
plugins/auto_synthetic/auto_synthetic_app.py:118:14: W292 No newline at end of file
help: Add trailing newline
[failure] 16-17: ruff (I001)
plugins/auto_synthetic/auto_synthetic_app.py:16:5: I001 Import block is un-sorted or un-formatted
help: Organize imports
[failure] 1-13: ruff (I001)
plugins/auto_synthetic/auto_synthetic_app.py:1:1: I001 Import block is un-sorted or un-formatted
help: Organize imports
🪛 Ruff (0.15.10)
plugins/auto_synthetic/auto_synthetic_app.py
[warning] 42-42: Docstring contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF002)
plugins/auto_synthetic/operations/ether_battery_synthesis_op.py
[warning] 50-50: String contains ambiguous : (FULLWIDTH COLON). Did you mean : (COLON)?
(RUF001)
[warning] 62-62: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 77-77: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 78-78: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 78-78: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
[warning] 110-110: String contains ambiguous : (FULLWIDTH COLON). Did you mean : (COLON)?
(RUF001)
[warning] 118-118: String contains ambiguous : (FULLWIDTH COLON). Did you mean : (COLON)?
(RUF001)
🔇 Additional comments (5)
plugins/auto_synthetic/operations/ether_battery_synthesis_op.py (3)
14-16: 相对导入仍未修复。Line 16 的
from ..auto_synthetic_config import AutoSyntheticConfig及 Line 180 的同名导入仍为相对导入,违反插件导入规范。请改为from zzz_od.plugins.auto_synthetic.auto_synthetic_config import AutoSyntheticConfig。As per coding guidelines「导入规范 (重要!): ❌ 错误:
from . import my_plugin_const(禁止相对导入)」。
86-90: OCR 未命中仍被直接判为“储值电卡数量不足”。之前评论指出的误判问题未解决:
round_by_ocr未识别到“以太电池”时(UI 未加载/OCR 波动/坐标漂移)直接返回成功状态储值电卡数量不足,会跳过整条合成流程。建议增加重试或模板回退再判定。
125-135:_click_increase_button仍恒返回 True,未找到数量增加按钮分支不可达。Line 132-135 无失败检测,Line 125 的失败分支永远进不去。建议在
round_by_click_area返回值上做判断并向上传递,或移除该误导性失败分支。plugins/auto_synthetic/auto_synthetic_app.py (1)
11-17: 相对导入仍未修复。Line 11-13 的
from . import auto_synthetic_const、from .operations.ether_battery_synthesis_op ...、from .operations.hifi_master_synthesis_op ...,以及 Line 17 TYPE_CHECKING 块的from .auto_synthetic_config均为相对导入,违反插件规范,也会触发 Ruff I001 报错。请统一改为zzz_od.plugins.auto_synthetic...绝对路径。As per coding guidelines「导入规范 (重要!): ❌ 错误:
from . import my_plugin_const(禁止相对导入)」。plugins/auto_synthetic/operations/hifi_master_synthesis_op.py (1)
1-115: LGTM!之前评审提出的相对导入(
common_areas已在本文件删除)、__init__/__debug返回类型注解、return_to_world点击结果未校验等问题均已修复。
Summary by CodeRabbit