feat(backend): 同步 ZZZ backend 演进(open_game + click/input/screen_area CRUD,7→11 tool)#605
feat(backend): 同步 ZZZ backend 演进(open_game + click/input/screen_area CRUD,7→11 tool)#605DoctorReid wants to merge 41 commits into
Conversation
Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- one_dragon: 新增 context_notify_event.py 等,对齐 ZZZ 框架层 - one_dragon_qt: 新增 app_notify_setting_interface/flyout、fast_scroll_area,移除 notify_dialog - onnxocr: 新增 inference_engine.py,含 PaddleOCR v6 代码支持 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- 新增 docs/develop/one_dragon/common-package-sync.md:common 三包性质、整包镜像同步法、模型下载机制 - AGENTS.md 架构落点:说明三个 common 包是游戏无关的公共框架 - AGENTS.md 硬约束:模型走运行时下载、不进 git、勿 git add Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
完成 sr_od 业务代码向 application/ 架构的统一:
- app/div_uni → application/div_uni(5 文件)
- app/treasures_lightward → application/treasures_lightward(18 文件)
- 删除 app/sr_application_launcher.py(转发 stub,application/ 已有真实实现)+ 空 app/__init__.py
- 导入路径 sr_od.app.{div_uni,treasures_lightward} → sr_od.application.*
- 清理空 app/ 目录
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- schemas: OcrText/AnalyzeScreenResult/WindowStatus(照搬)
- backend_context: SrBackendContext 收敛层(check_window/capture/analyze/enter_game)
- mcp/app: FastMCP 4 tool(check_game_window/capture_game_screen/analyze_screen/open_and_enter_game)
- http/routes: /game/{window,capture,analyze,enter} 4 端点
- entry/server: uvicorn 入口,端口 24001
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- sr_od_daemon.py: 管理 server daemon,端口 24000,4 个管理 tool(start/stop/restart/status) - start_daemon.ps1: 启 daemon(默认 24000) - create_startup_shortcut.ps1: 开机自启快捷方式 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
照搬 ZZZ docs/develop/zzz/backend(README/architecture/mcp/http/entry/remote-ssh), 命名/端口/文案替换为 sr_od / 24001·24000 / 星穹铁道;ai_coding.md 的 MCP 小节 由「尚未实现」更新为「已实现」并接入启动命令与文档链接。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
从 MCP backend 照搬实战提炼:token 形式多样(包名/模块文件名/类名/文案/路径/端口), 单一 sed/grep pattern 覆盖不全。补完整清单 + sed 顺序 + 验证纪律(grep pattern 须含 zzz/ 路径形式、pyright 兜底、.md 单独通读)。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
SrLauncher(RuntimeLauncher): _do_run_gui→sr_full_app.main、 _do_run_onedragon→sr_application_launcher.main;文案星穹铁道。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
…fest,照搬 ZZZ generate 扫 src/ 生成依赖清单,EXCLUDE_SRCPATHS=sr_od/backend(backend dev-only 不进发布 bundle);hook_path_inject 为 runtime_hook,注入 exe 旁 src/ 到 sys.path。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
入口 src/sr_od/win_exe/runtime_launcher.py;KEEP_TREES=one_dragon.launcher/version; collect_submodules 收集源码包后 excludes 业务(runtime 只含依赖+Python,源码外部加载)。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
build_full 一键打 3 exe + 拼 .runtime + 拷 config/assets/pyproject + 打 zip; 去掉不存在的 uv.toml 行;project.yml 加 manifest_path 启用 runtime 兼容性闸门。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
照搬 ZZZ docs/develop/one_dragon/runtime_launcher.md,命名替换(zzz_od→sr_od、 ZLauncher→SrLauncher、绝区零→星穹铁道、app.py→sr_full_app.py);CI/产物段 适配 SR 现状(无 CI、build_full.bat 产物 StarRailOneDragon*.zip、完整包不含 src)。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- skills/sr-od-dev-{deciding-a-fix,pr-finishing,skill-guide}/(SKILL.md + design.md),从 ZZZ 同步并按 token 清单适配(CodeRabbit 内容保留)
- ai_coding.md:加「推荐安装 superpowers」节、symlink→junction(mklink /J 免管理员)、skill 表更新
- quickstart.md:新建,从 ZZZ 适配(sr_full_app.py / 端口 24001 / sr_od backend / sr-od-test)
- entry_files.md:补 path-scoped rule 说明段(非 always-on 规范在 AGENTS.md 提及并指向 docs)
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- README.md:方向A 补 superpowers+skills/ 方法论;方向B「暂未实施」→「已落地」(SrBackendContext / 4 tool / 端口 24001 / sr_od/backend);A-2/B-1 状态表更新;entry-files 表加 skills/ 行 - settings_scope.md:坑1 例子改 sr_od;表格行「无项目自有 MCP」→ 3 个 mcp__*(context7/sr_od/sr_od_daemon);整体归口补 server 定义落点 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- ZZZ 397b5b22 新增的 one_dragon/base/screen/screen_match.py(ScreenMatch dataclass + find_screen_matches) - SR 的 one_dragon 其余部分已与 ZZZ 对齐,本次实质新增仅此一文件 - 验证:文件数 205、pyright 0 error、GUI 启动 OK、sr_od 零失配 - 解锁 Phase B:sr_od/backend analyze 画面匹配增强 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- schemas: + RunStatusResult、AnalyzeScreenResult +screens(import ScreenMatch) - backend_context: + RunSlot 单跑道(start_run/query_status/stop)+ close_game + analyze 增强画面匹配 - mcp/app: 7 tool 工厂模式(+ get_run_status/stop_run/close_game,enter 加 block) - http/routes: 7 端点(+ status/stop/close,enter 改 start_run) - entry: docstring 勘误 4→7 tool 照搬 ZZZ backend 演进,token 清单适配(enter_game 单→复、sr_od_mcp 等) Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- README/architecture/mcp/http/entry 更新为运行态版本(7 tool、7 端点、start_run/query_status/stop、close_game) - 新增 design-principles.md(backend 设计原则 P1-P12) - 适配 async-operation 设计 spec(docs/superpowers/specs/,gitignore 不入库) - 通读勘误:README tool 数 4→7;architecture ZPcController→SrPcController;删 SR 不存在的 one_dragon_architecture.md 链接 照搬 ZZZ backend 文档,token 清单适配(sr_od 路径、端口 24001 等) Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
…te-design) final review 发现:B3 sed 集(代码文件)未覆盖 spec 文件名 token, backend_context.py:64 仍指向 ZZZ 的 2026-07-02 spec(SR 已适配为 2026-07-05)。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
…匹配 + 7 tool/7 端点 + docs) - common: 带进 screen_match.py(analyze 画面匹配依赖) - backend: RunSlot 运行态管理(start_run/query_status/stop)+ close_game + analyze 增强 - mcp: 7 tool(+ get_run_status/stop_run/close_game,enter 加 block) - http: 7 端点(+ status/stop/close,enter 改 start_run) - docs: 运行态文档 + design-principles + adapted spec - tests: 74 用例(sr-od-test) 照搬 ZZZ backend 演进,token 清单适配 SR。final opus review clean。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
MCP backend 照搬轮靠通读/final review 抓到 5 类 sed+grep 都漏的 token: - 端口 sed 须用裸形式(不带反引号) - 小写前缀 zzz_backend_run(thread_name_prefix) - Z 前缀业务子类 ZPcController - 英文游戏名字面量 ZenlessZoneZero - 端口片段 :2300(findstr) - spec 文件名引用 §5.2 残留 grep pattern 同步补 Zenless|ZPc|zzz_backend|:2300。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- build_full.bat: copy 前先 mkdir config 目录(原 copy 到不存在的 config/ 会失败,包里缺 config/project.yml;ZZZ 也有此 bug) - common-package-sync.md: 表格内转义 |(markdown 列解析,markdownlint MD056) - backend_context: SrBackendContext.shutdown() 关闭 RunSlot._executor(原漏关致线程泄漏;加 RunSlot.shutdown() 封装) - sr_od_daemon: 主 server 进程检测改精确 argv 匹配(-m sr_od.backend.entry.server),避免子串误匹配;与同文件 --port 解析风格一致 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
…en_area CRUD,7→11 tool) - common: screen_info +upsert_area/remove_area_by_name(screen_area 工具依赖) - backend_context: + click_game/input_text/upsert_screen_area/delete_screen_area 切片 + analyze 按截图文件/图名解析;重提 RunSlot executor shutdown(ZZZ 仍未修,SR 保留) - mcp/app: open_and_enter_game → open_game(enter) + click_game + input_text + upsert/delete_screen_area(11 tool) - http/routes: ZZZ 未新增端点(新工具仅 MCP 暴露),diff 后确认 SR 现状已正确,no-op - entry/server: docstring 工具数 7→11 照搬 ZZZ backend 最新(2d73af97 / 7b102f38 / 80bf5bd3 / 9972ba18 / 53bc2823 共 5 commit),token 清单适配。 残留 grep 全 CLEAN;pyright 0 error;assembly ok;50 passed/5 failed(fail 均为 open_and_enter_game→open_game 签名变更,测试更新留待后续)。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
…input/screen_area CRUD) - mcp.md: 工具表更新(open_and_enter_game → open_game(enter) + click_game + input_text);ZZZ doc 漏列 upsert/delete_screen_area,SR 补上(11 tool) - 其余 backend doc 随 ZZZ 最新同步(token 适配) 照搬 ZZZ backend 文档(8087f220 等)。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
Walkthrough本次 PR 新增 Changes后端服务与 MCP 适配
运行时与模型执行
通知与 Qt 界面
规范、配置与基础工具
Estimated code review effort: 5 (Critical) | ~120 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
- PR 时 checkout sr-od-test @ github.head_ref(同名分支优先,fallback main,continue-on-error 兜底) - PR 跑 pytest -m 'not requires_secrets',main 跑全集 - 配 sr-od-test 同名分支 PR(OneDragon-Anything/sr-od-test#1),CI 能跑到配对测试 - 注意:本 PR 自身不会触发该 workflow(GitHub pull_request 用 base 分支版本);合并到 main 后后续 PR 生效 照搬 ZZZ test-check.yml,zzz-od-test→sr-od-test 适配。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- 移除 -m 'not requires_secrets' 过滤(SR 测试仓无通知测试) - 移除 PUSH_* env 块(SR 未配这些 secret,死重) - 合并 PR/main 分支为单条 pytest sr-od-test/ Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
There was a problem hiding this comment.
Actionable comments posted: 19
🧹 Nitpick comments (5)
.github/workflows/test-check.yml (1)
18-21: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win通过管道执行未锁版本的远程安装脚本。
Invoke-WebRequest ... | Invoke-Expression直接执行 astral.sh 提供的最新安装脚本,未锁定版本/哈希,若上游被篡改会直接在 CI 中执行任意代码。可考虑固定到具体版本的安装脚本 URL,或改用官方astral-sh/setup-uvAction(内置版本锁定与缓存)。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/test-check.yml around lines 18 - 21, The Install uv step in the workflow is piping a remote install script directly into Invoke-Expression, so replace that unsafe pattern with a pinned, verifiable installation approach. Update the "Install uv" step to use a fixed-version script URL or, preferably, the official astral-sh/setup-uv Action so the workflow relies on version-locked installation and caching. Keep the change scoped to the workflow job that runs this step..github/dev.md (1)
5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPython 补丁版本与 CI 不一致。
此处写死
Python 3.11.9,但.github/workflows/test-check.yml中 CI 使用--python=3.11.12。建议统一版本描述(或只标注3.11.x/3.11,与 AGENTS.md 保持一致),避免开发者本地环境与 CI 环境的补丁版本产生分歧。📝 建议修改
-- Python 3.11.9;包管理用 uv。 +- Python 3.11(与 CI 保持一致,具体补丁版本见 workflow);包管理用 uv。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/dev.md at line 5, The Python version note in the docs is pinned to 3.11.9 while CI uses 3.11.12, so align the version text in the dev guide with the workflow and AGENTS.md. Update the wording in the document section that mentions Python and uv to use a consistent 3.11.x/3.11 reference or the CI patch version, so developers follow the same environment as the test-check setup.docs/develop/harness/README.md (1)
38-38: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win文档描述的 MCP 工具数量/阶段可能与本 PR 的实际实现脱节。
本文件多处(如 Line 38 "4 个感知 / 操作 tool",Line 65 B-1 状态,Line 66 B-2 "⏳ 规划")描述当前只落地 4 个感知/操作类 MCP 工具、原子操作工具(B-2)仍待规划。但根据 PR 描述,同一 PR 已将 MCP 工具从 7 个扩展到 11 个,新增了
click_game、input_text、upsert_screen_area、delete_screen_area等原子操作与屏幕区域管理能力,这些能力看起来正对应 B-2 阶段的内容。请确认此文档是否需要同步更新工具数量与路线图状态,避免刚引入就与代码现状不一致。Based on learnings, 修改代码后应同步更新对应的docs/develop/文档。Also applies to: 59-70
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/develop/harness/README.md` at line 38, Update the harness README to match the current MCP implementation: the “4 个感知 / 操作 tool” wording and the B-1/B-2 roadmap in the sections around the MCP tool overview should be revised to reflect that `SrBackendContext` now exposes 11 tools, including the new atomic operation and screen-area management capabilities such as `click_game`, `input_text`, `upsert_screen_area`, and `delete_screen_area`. Keep the tool-stage descriptions aligned with the actual state of the backend and ensure the route/map text in the README is synchronized with the symbols introduced in the PR.Source: Learnings
src/one_dragon/base/operation/operation_notify.py (1)
62-99: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win热路径中重复构造
notify_config,建议本地缓存引用。
operation.ctx.notify_config是一个属性,每次访问都会重新构造NotifyConfig(进而触发YamlConfig加载)。send_node_notify单次调用中最多访问该属性 4 次(Line 244、249、345、352),send_application_notify通过_get_lifecycle_mode/_get_detail_mode(各自内部又访问两次)合计可达 4-6 次。由于send_node_notify会在每个节点结束时高频调用,重复构造可能带来不必要的 I/O/对象开销。建议在函数入口处缓存一次
notify_config引用后复用,例如:⚡ 建议的优化方向(示意)
app_id, app_name = _get_app_info(operation) + notify_config = operation.ctx.notify_config detail_mode = ( NotifyDetailMode.ALL.value.value if app_id is None - else operation.ctx.notify_config.get_app_detail_mode(app_id) + else notify_config.get_app_detail_mode(app_id) ) app_lifecycle_mode = ( NotifyLifecycleMode.FINISH_ONLY.value.value if app_id is None - else operation.ctx.notify_config.get_app_lifecycle_mode(app_id) + else notify_config.get_app_lifecycle_mode(app_id) )由于
src/one_dragon/属于从 ZZZ 上游整包同步的公共框架代码,本地补丁在下次同步时可能被覆盖,若确认此问题成立,建议优先在上游 ZZZ 项目修复后再同步回来。Also applies to: 237-265, 340-352
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/one_dragon/base/operation/operation_notify.py` around lines 62 - 99, send_application_notify and send_node_notify are repeatedly accessing operation.ctx.notify_config, which can reconstruct NotifyConfig and trigger extra YamlConfig loading on hot paths. Cache the notify_config once at the start of these functions (and reuse it in _get_lifecycle_mode / _get_detail_mode or inline their calls) so lifecycle/detail mode lookups use the same local reference instead of re-fetching the property multiple times. Use the existing symbols send_application_notify, send_node_notify, _get_lifecycle_mode, and _get_detail_mode to keep the change localized and avoid repeated property access.Source: Learnings
pyproject.toml (1)
54-72: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win建议将
RUF002加入忽略列表,与中文注释规范保持一致。
ignore只包含RUF001、RUF003,未包含RUF002(docstring 中全角标点歧义)。由于路径指导要求注释与 docstring 必须使用中文,中文语境下全角逗号/括号非常普遍,会产生大量噪音警告(本次静态分析已在多个文件中命中),建议一并忽略。♻️ 建议修改
-ignore = ["RUF001", "RUF003"] +ignore = ["RUF001", "RUF002", "RUF003"]As per path instructions, "注释与 docstring 必须使用中文,并保持现有项目风格。"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pyproject.toml` around lines 54 - 72, The Ruff lint configuration is missing the `RUF002` rule in the ignore list, which will keep producing noisy warnings for Chinese docstrings and comments. Update the `[tool.ruff.lint]` settings in the `ignore` entry alongside `RUF001` and `RUF003` so `RUF002` is also ignored, keeping the existing project style intact.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/test-check.yml:
- Around line 13-16: The actions/checkout step currently relies on the default
credential persistence, which leaves git credentials available to later steps.
Update each checkout usage in this workflow, including the Checkout code step
and the other two checkout calls referenced in the job, to explicitly disable
credential persistence with persist-credentials set to false. Use the
actions/checkout configuration blocks to locate and apply the change
consistently across all checkout steps.
- Around line 9-11: Explicitly add a permissions block to the test-check job so
it follows least-privilege instead of inheriting repository defaults. Update the
job definition under test-check in the workflow to declare only the minimum
required scope, using contents: read unless a specific step in this job needs
more. This change should be made in the job configuration for test-check so the
workflow’s permissions are clear and constrained.
In `@deploy/build_full.bat`:
- Around line 17-32: Several `copy` steps in `build_full.bat` can prompt for
overwrite confirmation on reruns, which can hang unattended builds. Update the
`copy` commands used for `OneDragon-Installer.exe`, `OneDragon-Launcher.exe`,
`OneDragon-RuntimeLauncher.exe`, `project.yml`, and `pyproject.toml` to use
non-interactive overwrite behavior, or clear `TARGET_DIR` before the packaging
steps. Keep the existing `xcopy` calls for directories, and make the change in
the same build flow around the `TARGET_DIR`/`DIST_DIR` copy sequence.
In `@deploy/module_manifest.py`:
- Line 66: The manifest still contains legacy sr.* imports that will fail under
the current package layout; update the import entries in the manifest generation
logic to use sr_od.* instead of sr.app.*, sr.context.*, sr.operation.*, and
sr.treasures_lightward.*. Keep valid imports like from unittest import result
unchanged, and adjust the affected manifest-building code in module_manifest.py
so all referenced modules match the current package structure.
In `@docs/develop/one_dragon/common-package-sync.md`:
- Around line 39-44: The validation section currently limits linting to only
sr_od files, which can miss syntax or import issues introduced in the synced
public packages. Update the verification steps in the common-package sync guide
so the post-sync checks also cover the synchronized one_dragon, one_dragon_qt,
and onnxocr content with a minimal validation pass, while still keeping
sr_od-specific checks separate where appropriate.
In `@docs/develop/one_dragon/runtime_launcher.md`:
- Around line 93-95: The wording in the runtime launcher docs is too broad
because it says SR has “no CI,” which is no longer accurate after the new test
CI was added. Update the related bullet in the documentation to use the correct
scope, and make sure the description around generate_module_manifest.py and
build_full.bat clearly says there is no automated packaging/release CI rather
than no CI at all.
In `@docs/develop/setup/ai_coding.md`:
- Around line 144-146: The fenced block in the documentation snippet is missing
a language identifier, causing markdownlint MD040 to fire. Update the fenced
block around the Co-Authored-By footer in the setup guide by adding an
appropriate language tag such as text or gitcommit, and keep the content
unchanged so the markdown remains valid and lint-friendly.
In `@docs/develop/setup/claude-code/commit-trailer.md`:
- Around line 107-111: The early exit in the commit trailer update flow is too
broad: in the trailer handling logic, do not return just because a Claude Code
co-author trailer already exists, since that prevents --amend from refreshing
the model-specific trailer. Update the behavior in the trailer-writing step to
detect and replace or refresh the existing model trailer while preserving the
Claude Code trailer, and keep the logic centered around the trailer
insertion/rewriting path that uses git interpret-trailers.
In `@docs/develop/sr_od/backend/architecture.md`:
- Around line 17-30: Update the architecture doc’s tool/method inventory to
match the actual backend symbols. In the `mcp/app.py` section, replace the
outdated “7 个 `@mcp.tool`” count with the current 11 tools and keep the list
aligned with `create_mcp_server`; in `backend_context.py`, extend the method
list beyond `close_game` to include the existing `click_game`, `input_text`,
`upsert_screen_area`, and `delete_screen_area`. Make sure the counts and names
stay consistent with the current implementation.
In `@docs/develop/sr_od/backend/design-principles.md`:
- Around line 20-25: Update the “读源码 / Read / Grep / Glob” example in
design-principles.md because it still references the old OpenAndEnterGame entry
name; replace it with the current finer-grained tool name(s) used in this
codebase or rephrase the example as a generic “进游戏链路” description so readers are
not directed to a stale API. Use the existing table entry and surrounding
guidance to keep the wording aligned with the current tool surface.
In `@docs/develop/sr_od/backend/remote-ssh.md`:
- Around line 22-24: The daemon port numbers are inconsistent between the
startup command and the MCP client registration example, so unify them to a
single port throughout this section. Update the start_daemon.ps1 default port
reference, the example MCP URL, and any related wording so they all match the
same daemon port, keeping the remote-ssh.md guidance consistent for readers.
- Around line 13-18: Update the topology diagram fenced block in the remote SSH
markdown doc to include a language tag, using the existing diagram section so it
is marked as text instead of a bare fence. Keep the content unchanged and adjust
the opening fence in the diagram block to use text, which will satisfy
markdownlint MD040.
In `@skills/sr-od-dev-deciding-a-fix/SKILL.md`:
- Around line 32-40: In the Quick Reference table within SKILL.md, add the
missing blank line separation before and after the markdown table so it complies
with markdownlint MD058. Keep the table content unchanged and adjust the
surrounding spacing around the Quick Reference section to remove the lint
warning.
In `@skills/sr-od-dev-pr-finishing/SKILL.md`:
- Around line 21-24: The fenced shell command blocks in SKILL.md are missing the
bash language tag, causing markdownlint MD040. Update both command blocks around
the gh api graphql examples (including the later block referenced by the
comment) to use bash-labeled fences so they render and lint correctly.
In `@src/one_dragon_qt/widgets/horizontal_setting_card_group.py`:
- Around line 32-36: The add_card method in HorizontalSettingCardGroup is making
each card participate in horizontal stretch by using a nonzero stretch factor,
which causes cards to expand instead of keeping their natural width. Update
add_card so the card is added to h_layout with a stretch of 0 while keeping the
existing alignment, and leave the placeholder/spacer logic to absorb extra
space.
In `@src/one_dragon/base/screen/screen_info.py`:
- Around line 96-110: `upsert_area` in `ScreenInfo` is not propagating the
screen-level `pc_alt`, so inserted or replaced `ScreenArea` entries can drift
from the `ScreenInfo.__init__` YAML normalization. Update `upsert_area` to
ensure any incoming `ScreenArea` is aligned with `self.pc_alt` before storing
it, both in the replace path and the append path, so downstream logic that reads
`area.pc_alt` always sees the current screen configuration.
In `@src/onnxocr/logger.py`:
- Around line 23-41: _LoggerShim in logger.py is dropping logging kwargs such as
exc_info because info/debug/warning/error only format the message and never
forward the remaining keyword arguments to od_log. Update the upstream
implementation of _LoggerShim so these methods preserve and pass through logging
kwargs while still supporting message formatting, then sync the fix back into
this shared package rather than patching it locally in the SR repo.
In `@src/sr_od/backend/backend_context.py`:
- Around line 375-389: The analyze() OCR/matching path is not serialized and can
race with background operations, causing DirectML session contention and cache
corruption. Update backend_context.analyze() so the calls to
OcrService.get_ocr_result_list() and find_screen_matches() run through the same
GPU execution guard used elsewhere, or add a shared lock inside
OcrService/OnnxOcrMatcher to protect _cache, _cache_list, and self._model.ocr()
from concurrent access, keeping the current write_back behavior unchanged.
In `@tools/mcp/daemon/sr_od_daemon.py`:
- Around line 90-121: `start_sr_od_mcp_server` has a TOCTOU race between
`find_sr_od_mcp_server_process()`, `is_port_in_use(port)`, and the
`subprocess.Popen` launch, so concurrent calls can both pass the checks and
start duplicate servers. Add a mutual-exclusion guard around the entire
check-and-start flow (for example a process-wide lock or other startup
serialization in `sr_od_daemon.py`) so only one caller can evaluate
`existing_proc`/port state and invoke `Popen` at a time. Keep the existing
`process.poll()` and logging behavior, but ensure the lock covers the full
critical section from the initial checks through process creation.
---
Nitpick comments:
In @.github/dev.md:
- Line 5: The Python version note in the docs is pinned to 3.11.9 while CI uses
3.11.12, so align the version text in the dev guide with the workflow and
AGENTS.md. Update the wording in the document section that mentions Python and
uv to use a consistent 3.11.x/3.11 reference or the CI patch version, so
developers follow the same environment as the test-check setup.
In @.github/workflows/test-check.yml:
- Around line 18-21: The Install uv step in the workflow is piping a remote
install script directly into Invoke-Expression, so replace that unsafe pattern
with a pinned, verifiable installation approach. Update the "Install uv" step to
use a fixed-version script URL or, preferably, the official astral-sh/setup-uv
Action so the workflow relies on version-locked installation and caching. Keep
the change scoped to the workflow job that runs this step.
In `@docs/develop/harness/README.md`:
- Line 38: Update the harness README to match the current MCP implementation:
the “4 个感知 / 操作 tool” wording and the B-1/B-2 roadmap in the sections around the
MCP tool overview should be revised to reflect that `SrBackendContext` now
exposes 11 tools, including the new atomic operation and screen-area management
capabilities such as `click_game`, `input_text`, `upsert_screen_area`, and
`delete_screen_area`. Keep the tool-stage descriptions aligned with the actual
state of the backend and ensure the route/map text in the README is synchronized
with the symbols introduced in the PR.
In `@pyproject.toml`:
- Around line 54-72: The Ruff lint configuration is missing the `RUF002` rule in
the ignore list, which will keep producing noisy warnings for Chinese docstrings
and comments. Update the `[tool.ruff.lint]` settings in the `ignore` entry
alongside `RUF001` and `RUF003` so `RUF002` is also ignored, keeping the
existing project style intact.
In `@src/one_dragon/base/operation/operation_notify.py`:
- Around line 62-99: send_application_notify and send_node_notify are repeatedly
accessing operation.ctx.notify_config, which can reconstruct NotifyConfig and
trigger extra YamlConfig loading on hot paths. Cache the notify_config once at
the start of these functions (and reuse it in _get_lifecycle_mode /
_get_detail_mode or inline their calls) so lifecycle/detail mode lookups use the
same local reference instead of re-fetching the property multiple times. Use the
existing symbols send_application_notify, send_node_notify, _get_lifecycle_mode,
and _get_detail_mode to keep the change localized and avoid repeated property
access.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 705a9881-22af-4869-8a96-7022dee5409b
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (143)
.claude/CLAUDE.md.github/dev.md.github/workflows/test-check.yml.gitignoreAGENTS.mdconfig/project.ymldeploy/OneDragon-RuntimeLauncher.specdeploy/build_full.batdeploy/generate_module_manifest.pydeploy/hook_path_inject.pydeploy/module_manifest.pydocs/develop/harness/README.mddocs/develop/harness/ai_tool_rules.mddocs/develop/harness/context_layering.mddocs/develop/harness/entry_files.mddocs/develop/harness/settings_scope.mddocs/develop/one_dragon/common-package-sync.mddocs/develop/one_dragon/runtime_launcher.mddocs/develop/setup/ai_coding.mddocs/develop/setup/claude-code/commit-trailer.mddocs/develop/setup/quickstart.mddocs/develop/sr_od/backend/README.mddocs/develop/sr_od/backend/architecture.mddocs/develop/sr_od/backend/design-principles.mddocs/develop/sr_od/backend/entry.mddocs/develop/sr_od/backend/http.mddocs/develop/sr_od/backend/mcp.mddocs/develop/sr_od/backend/remote-ssh.mdpyproject.tomlskills/sr-od-dev-deciding-a-fix/SKILL.mdskills/sr-od-dev-deciding-a-fix/design.mdskills/sr-od-dev-pr-finishing/SKILL.mdskills/sr-od-dev-pr-finishing/design.mdskills/sr-od-dev-skill-guide/SKILL.mdskills/sr-od-dev-skill-guide/design.mdsrc/one_dragon/base/conditional_operation/state_handler.pysrc/one_dragon/base/config/basic_model_config.pysrc/one_dragon/base/config/game_account_config.pysrc/one_dragon/base/config/notify_config.pysrc/one_dragon/base/config/yaml_operator.pysrc/one_dragon/base/controller/pc_controller_base.pysrc/one_dragon/base/matcher/ocr/onnx_ocr_matcher.pysrc/one_dragon/base/operation/application/application_factory_manager.pysrc/one_dragon/base/operation/application_base.pysrc/one_dragon/base/operation/context_event_bus.pysrc/one_dragon/base/operation/context_notify_event.pysrc/one_dragon/base/operation/notify_pool.pysrc/one_dragon/base/operation/one_dragon_app.pysrc/one_dragon/base/operation/one_dragon_context.pysrc/one_dragon/base/operation/operation_notify.pysrc/one_dragon/base/screen/screen_info.pysrc/one_dragon/base/screen/screen_loader.pysrc/one_dragon/base/screen/screen_match.pysrc/one_dragon/base/screen/screen_utils.pysrc/one_dragon/base/screen/template_info.pysrc/one_dragon/base/screen/template_loader.pysrc/one_dragon/devtools/python_launcher.pysrc/one_dragon/envs/env_config.pysrc/one_dragon/envs/git_service.pysrc/one_dragon/launcher/runtime_launcher.pysrc/one_dragon/utils/app_utils.pysrc/one_dragon/utils/cv2_utils.pysrc/one_dragon/utils/gpu_executor.pysrc/one_dragon/utils/http_utils.pysrc/one_dragon/utils/log_utils.pysrc/one_dragon/yolo/onnx_model_loader.pysrc/one_dragon/yolo/yolov8_onnx_cls.pysrc/one_dragon/yolo/yolov8_onnx_det.pysrc/one_dragon_qt/demo/draggable_list_demo.pysrc/one_dragon_qt/services/app_setting/app_setting_manager.pysrc/one_dragon_qt/view/app_run_interface.pysrc/one_dragon_qt/view/code_interface.pysrc/one_dragon_qt/view/devtools/devtools_image_analysis_interface.pysrc/one_dragon_qt/view/devtools/devtools_screen_manage_interface.pysrc/one_dragon_qt/view/devtools/devtools_template_helper_interface.pysrc/one_dragon_qt/view/one_dragon/one_dragon_run_interface.pysrc/one_dragon_qt/view/setting/app_notify_setting_interface.pysrc/one_dragon_qt/view/setting/resource_download_interface.pysrc/one_dragon_qt/view/setting/setting_env_interface.pysrc/one_dragon_qt/view/setting/setting_instance_interface.pysrc/one_dragon_qt/view/setting/setting_push_interface.pysrc/one_dragon_qt/widgets/app_run_list.pysrc/one_dragon_qt/widgets/app_setting/app_notify_setting_flyout.pysrc/one_dragon_qt/widgets/color_channel_dialog.pysrc/one_dragon_qt/widgets/fast_scroll_area.pysrc/one_dragon_qt/widgets/horizontal_setting_card_group.pysrc/one_dragon_qt/widgets/install_card/code_install_card.pysrc/one_dragon_qt/widgets/notify_dialog.pysrc/one_dragon_qt/widgets/scroll_credits.pysrc/one_dragon_qt/widgets/setting_card/app_run_card.pysrc/one_dragon_qt/widgets/setting_card/password_switch_setting_card.pysrc/one_dragon_qt/widgets/vertical_scroll_interface.pysrc/one_dragon_qt/windows/main_app_window_base.pysrc/onnxocr/inference_engine.pysrc/onnxocr/logger.pysrc/onnxocr/onnx_paddleocr.pysrc/onnxocr/operators.pysrc/onnxocr/predict_base.pysrc/onnxocr/predict_cls.pysrc/onnxocr/predict_det.pysrc/onnxocr/predict_rec.pysrc/onnxocr/predict_system.pysrc/onnxocr/readme.mdsrc/onnxocr/utils.pysrc/sr_od/app/sr_application_launcher.pysrc/sr_od/application/div_uni/__init__.pysrc/sr_od/application/div_uni/operations/__init__.pysrc/sr_od/application/div_uni/operations/choose_oe_file.pysrc/sr_od/application/div_uni/operations/choose_oe_support.pysrc/sr_od/application/div_uni/operations/ornamenet_extraction.pysrc/sr_od/application/trailblaze_power/trailblaze_power_app.pysrc/sr_od/application/treasures_lightward/__init__.pysrc/sr_od/application/treasures_lightward/op/__init__.pysrc/sr_od/application/treasures_lightward/op/challenge_mission.pysrc/sr_od/application/treasures_lightward/op/check_max_unlock_mission.pysrc/sr_od/application/treasures_lightward/op/check_mission_star.pysrc/sr_od/application/treasures_lightward/op/check_star.pysrc/sr_od/application/treasures_lightward/op/choose_character.pysrc/sr_od/application/treasures_lightward/op/forgotten_hall/__init__.pysrc/sr_od/application/treasures_lightward/op/forgotten_hall/choose_mission.pysrc/sr_od/application/treasures_lightward/op/forgotten_hall/choose_team_in_fh.pysrc/sr_od/application/treasures_lightward/op/forgotten_hall/get_reward_in_fh.pysrc/sr_od/application/treasures_lightward/op/tl_battle.pysrc/sr_od/application/treasures_lightward/op/tl_wait.pysrc/sr_od/application/treasures_lightward/treasures_lightward_app.pysrc/sr_od/application/treasures_lightward/treasures_lightward_config.pysrc/sr_od/application/treasures_lightward/treasures_lightward_const.pysrc/sr_od/application/treasures_lightward/treasures_lightward_record.pysrc/sr_od/application/treasures_lightward/treasures_lightward_team_module.pysrc/sr_od/backend/__init__.pysrc/sr_od/backend/backend_context.pysrc/sr_od/backend/entry/__init__.pysrc/sr_od/backend/entry/server.pysrc/sr_od/backend/http/__init__.pysrc/sr_od/backend/http/routes.pysrc/sr_od/backend/mcp/__init__.pysrc/sr_od/backend/mcp/app.pysrc/sr_od/backend/schemas.pysrc/sr_od/win_exe/__init__.pysrc/sr_od/win_exe/runtime_launcher.pytools/mcp/daemon/create_startup_shortcut.ps1tools/mcp/daemon/sr_od_daemon.pytools/mcp/daemon/start_daemon.ps1
💤 Files with no reviewable changes (3)
- src/one_dragon/base/conditional_operation/state_handler.py
- src/sr_od/app/sr_application_launcher.py
- src/one_dragon_qt/widgets/notify_dialog.py
…est-check CI test-check 报 ModuleNotFoundError: No module named 'one_dragon'/sr_od (src-layout + package=false,pytest 默认不加 src/ 到 sys.path)。 照搬 ZZZ pyproject 的 pytest pythonpath 配置,pytest 自动加 src/。 顺带省掉本地手动 PYTHONPATH=src。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- test-check.yml: 加 permissions: contents: read(最小权限)+ persist-credentials: false(3 个 checkout,防 artipacked 凭据残留) - build_full.bat: copy 加 /Y(防 rerun 时交互式覆盖确认挂起无人值守构建) CodeRabbit #605 review 处理(MAJOR 2 个 push back:module_manifest 是兼容性门禁数据非执行 / backend_context analyze 照搬 ZZZ 上游问题)。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
…I 措辞 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
cal_pos/sim_uni 集成测试 init_for_world_patrol 加载 YOLO 模型;loader 默认走 ghfast.top 代理在 CI 下载失败 → 切 backup(None) → os.path.join 崩。 CI 直连 github release 预下载 yolov8n-640-simuni-0601 到 loader 期望目录 (world_patrol + sim_uni),check_model_exists 通过不触发下载。 (OCR 用另一套 ZipDownloader,CI 里已能下;仅 YOLO 的 urllib+代理路径有此问题。) Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.github/workflows/test-check.yml (2)
64-66: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win下载步骤缺少重试机制,网络抖动可能导致 CI 间歇性失败。
Invoke-WebRequest未配置重试参数,一次瞬时网络问题就会使整个 job 失败,需要重跑整个 CI。🔁 建议增加重试参数
- Invoke-WebRequest -Uri $url -OutFile $tmp + Invoke-WebRequest -Uri $url -OutFile $tmp -MaximumRetryCount 3 -RetryIntervalSec 5🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/test-check.yml around lines 64 - 66, The download step in the workflow lacks retry handling, so a transient network failure can break the job. Update the PowerShell step that uses Invoke-WebRequest to add retry logic (for example, retry the download a few times with a short delay) around the $url and $tmp download block so the CI can recover from intermittent failures without rerunning the whole workflow.
64-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win模型版本号在 URL 与目标目录名中重复硬编码,建议提取为变量。
yolov8n-640-simuni-0601同时出现在下载 URL(Line 64)和解压目标目录名(Line 68)。未来升级模型版本时若只改了其中一处,check_model_exists可能因目录名不匹配而误判模型不存在,导致该预下载步骤形同虚设且难以排查。♻️ 建议提取为变量
+ $modelVersion = "yolov8n-640-simuni-0601" - $url = "https://github.com/OneDragon-Anything/OneDragon-YOLO/releases/download/sr_model/yolov8n-640-simuni-0601.zip" + $url = "https://github.com/OneDragon-Anything/OneDragon-YOLO/releases/download/sr_model/$modelVersion.zip" $tmp = "$env:TEMP\yolo.zip" foreach ($cat in @("world_patrol", "sim_uni")) { - $dst = "assets\models\$cat\yolov8n-640-simuni-0601" + $dst = "assets\models\$cat\$modelVersion" New-Item -ItemType Directory -Force -Path $dst | Out-Null Expand-Archive -Path $tmp -DestinationPath $dst -Force }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/test-check.yml around lines 64 - 68, The model version string is duplicated in both the download URL and the destination directory path, which can drift out of sync. Update the workflow block that builds the URL and the $dst path to use a single shared variable for the model version in this PowerShell step, so changes to the version only need to be made once and remain consistent for check_model_exists.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.github/workflows/test-check.yml:
- Around line 64-66: The download step in the workflow lacks retry handling, so
a transient network failure can break the job. Update the PowerShell step that
uses Invoke-WebRequest to add retry logic (for example, retry the download a few
times with a short delay) around the $url and $tmp download block so the CI can
recover from intermittent failures without rerunning the whole workflow.
- Around line 64-68: The model version string is duplicated in both the download
URL and the destination directory path, which can drift out of sync. Update the
workflow block that builds the URL and the $dst path to use a single shared
variable for the model version in this PowerShell step, so changes to the
version only need to be made once and remain consistent for check_model_exists.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c328489a-2cdf-408e-b35d-c6531daa73bd
📒 Files selected for processing (1)
.github/workflows/test-check.yml
…ackend_context - _save_screenshot 从 mcp/app 提到 backend_context(MCP/HTTP 共享,去重) - analyze 现在落盘截图 + AnalyzeScreenResult +screenshot_path 字段 - mcp/app + http/routes 用共享 _save_screenshot - 重提 RunSlot executor shutdown + spec 路径(照搬覆盖后加回) 照搬 ZZZ backend(补 sync2 遗漏的 analyze-screenshot 重构)。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- application_run_context +last_application_result(backend run-slot 固化终态用)
- + application_factory、push_service、devtools/python_launcher、
envs/python_service、utils/{cmd,cv2,os}、setting 接口、predict_det 等内容更新
- sr_od 无需适配:GUI 启动无 traceback、pyright 0 error
- application_factory_manager/one_dragon_context/screen_match 经 token 适配后
内容与 HEAD 一致(仅 CRLF),无内容变更
照搬 ZZZ common(#2460),验证 GUI 启动 + pyright 干净。
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- operation_registry: operation 反射扫描/解析/args 校验(_SCAN_ROOTS 适配 sr_od.operations,无 hollow_zero) - mcp/service_app: run_one_dragon / list_operations / describe_operation / run_operation 工具 - mcp/prompts: MCP prompt 工具(check_status_guide 等) - http/service_routes: HTTP 应用运行端点 + /health - backend_context/mcp.app/http.routes/schemas/entry: 配套(schemas +OperationInfo 等) - GUI: devtools/mcp_service_interface(MCP server 管理页)+ app_devtools_interface - psutil: 必需依赖 - 重提 RunSlot executor shutdown + spec 路径 照搬 ZZZ #2460,token 适配 + operation_registry 扫描根适配 SR。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- README/architecture/entry/http/mcp 同步 #2460(MCP 应用运行能力、operation_registry、service_app/prompts/service_routes、/health) - architecture scan_operations 描述适配 SR(sr_od.operations,无 hollow_zero) - module_manifest regenerate(166 imports,+新 backend 模块) 照搬 ZZZ backend 文档(#2460),token 适配。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/sr_od/backend/backend_context.py (1)
318-325: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift关闭 backend 前先停止并等待活动运行退出。
RunSlot.shutdown()仅执行shutdown(wait=False),不会取消已运行的线程;随后 Line 837 会清理SrContext资源,而 Operation 仍可能继续访问控制器、OCR 或配置,且非 daemon 的线程池线程还可能阻止进程退出。请先发送stop_running(),等待当前 future 结束,再执行after_app_shutdown()。Based on learnings,
src/sr_od/backend必须与上游 ZZZ 保持一致;请先在 ZZZ 修复后同步回 SR,避免 backend drift。Also applies to: 829-837
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/sr_od/backend/backend_context.py` around lines 318 - 325, 先在上游 ZZZ 修复对应 backend 关闭流程,再将该修复同步到 SR,避免分叉;更新 RunSlot.shutdown() 及 backend 关闭路径,使其先调用 stop_running() 并等待活动 future 完成,再调用 after_app_shutdown() 清理 SrContext 资源,最后关闭线程池。Source: Learnings
🧹 Nitpick comments (2)
src/sr_od/backend/mcp/service_app.py (1)
155-156: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win为
op_factory补上类型注解
def op_factory(ctx)仍然缺少参数和返回值标注,和项目的强制类型注解要求不一致。这里直接标成ctx: SrContext、返回Operation,并去掉# noqa: ANN202;SrContext和Operation可在TYPE_CHECKING下分别从sr_od.context.sr_context、one_dragon.base.operation.operation导入。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/sr_od/backend/mcp/service_app.py` around lines 155 - 156, 为 op_factory 补充完整类型注解,将 ctx 标注为 SrContext、返回值标注为 Operation,并移除 # noqa: ANN202;在 TYPE_CHECKING 块中分别导入 sr_od.context.sr_context.SrContext 和 one_dragon.base.operation.operation.Operation。Source: Coding guidelines
src/sr_od/backend/http/service_routes.py (1)
175-176: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win补齐新函数和 Qt 类成员的类型注解。
src/sr_od/backend/http/service_routes.py#L175-L176: 为op_factory标注SrContext参数和Operation返回类型,类型专用导入放入TYPE_CHECKING。src/sr_od/gui/interface/devtools/mcp_service_interface.py#L217-L222: 为finishedSignal 补充类型。src/sr_od/gui/interface/devtools/mcp_service_interface.py#L264-L270: 为两个QTimer成员补充类型。src/sr_od/gui/interface/devtools/mcp_service_interface.py#L278-L323: 为新增 card、button 和 message-box 成员补充类型。As per coding guidelines,
**/*.py: 所有函数签名和类成员变量都必须有类型注解。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/sr_od/backend/http/service_routes.py` around lines 175 - 176, 为 src/sr_od/backend/http/service_routes.py:175-176 的 op_factory 补充 SrContext 参数和 Operation 返回类型,并将仅用于类型检查的导入放入 TYPE_CHECKING。为 src/sr_od/gui/interface/devtools/mcp_service_interface.py:217-222 的 finished Signal、264-270 的两个 QTimer 成员,以及 278-323 新增的 card、button 和 message-box 成员补充准确类型注解,确保所有函数签名和类成员变量符合类型注解要求。Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/sr_od/backend/backend_context.py`:
- Around line 741-768: 调整 run_standalone_app 与 _start 的默认应用解析时机:显式传入的 app_id
继续立即使用,但未传入时不要在刷新前读取 active_app_id。将默认独立应用的解析移入 refresh_config
执行完成后的槽线程流程,确保使用刷新后的 _ctx.standalone_app_config.active_app_id;无可用应用时仍抛出
BackendNotReadyError。
- Around line 350-355: Update the screenshot-writing flow around cv2.imwrite in
the backend context to encode the BGR image with cv2.imencode and write the
encoded ndarray using tofile, preserving the existing screenshot path and
raising an explicit RuntimeError when encoding or writing fails.
In `@src/sr_od/backend/operation_registry.py`:
- Around line 239-272: 在 validate_args() 中增加未知参数校验:先根据 cls.__init__ 的参数定义排除
self、ctx 及可变参数后,拒绝 args 中未声明的键并返回明确的参数错误。保留现有必填参数、类型和 JSON 可序列化校验逻辑,确保 cls(ctx,
**args) 执行前即可发现拼写错误或额外参数。
- Around line 196-236: 更新 resolve_op_class,使 op_id 只能匹配扫描阶段基于 _SCAN_ROOTS 生成的可运行
Operation 白名单;在 import_module 前拒绝不在白名单中的模块或类,并复用扫描阶段对 Application、抽象类及 *Base
的过滤结果。保留现有格式、定义模块和 Operation 子类校验,避免通过 HTTP/MCP 解析任意未公开内部类。
- Around line 98-120: Update _annotation_json_serializable’s Union handling to
ignore NoneType branches before evaluating serializability, and require every
remaining branch to be JSON-serializable so CustomType | None is rejected while
valid scalar unions remain accepted.
In `@src/sr_od/gui/interface/devtools/mcp_service_interface.py`:
- Around line 82-91: 更新 _find_server_process() 以接收当前端口,严格匹配完整的 “-m
sr_od.backend.entry.server --port <端口>” 参数,并仅返回 cwd 与 _project_root() 一致的进程;同时将
_stop_server() 改为接收 port,并在所有调用处传入当前端口,确保停止操作只针对当前项目和端口的 server。
---
Outside diff comments:
In `@src/sr_od/backend/backend_context.py`:
- Around line 318-325: 先在上游 ZZZ 修复对应 backend 关闭流程,再将该修复同步到 SR,避免分叉;更新
RunSlot.shutdown() 及 backend 关闭路径,使其先调用 stop_running() 并等待活动 future 完成,再调用
after_app_shutdown() 清理 SrContext 资源,最后关闭线程池。
---
Nitpick comments:
In `@src/sr_od/backend/http/service_routes.py`:
- Around line 175-176: 为 src/sr_od/backend/http/service_routes.py:175-176 的
op_factory 补充 SrContext 参数和 Operation 返回类型,并将仅用于类型检查的导入放入 TYPE_CHECKING。为
src/sr_od/gui/interface/devtools/mcp_service_interface.py:217-222 的 finished
Signal、264-270 的两个 QTimer 成员,以及 278-323 新增的 card、button 和 message-box
成员补充准确类型注解,确保所有函数签名和类成员变量符合类型注解要求。
In `@src/sr_od/backend/mcp/service_app.py`:
- Around line 155-156: 为 op_factory 补充完整类型注解,将 ctx 标注为 SrContext、返回值标注为
Operation,并移除 # noqa: ANN202;在 TYPE_CHECKING 块中分别导入
sr_od.context.sr_context.SrContext 和
one_dragon.base.operation.operation.Operation。
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5e3a428e-f0d3-425d-8df6-33644f2adc79
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (31)
.github/workflows/test-check.ymldeploy/module_manifest.pydocs/develop/sr_od/backend/README.mddocs/develop/sr_od/backend/architecture.mddocs/develop/sr_od/backend/entry.mddocs/develop/sr_od/backend/http.mddocs/develop/sr_od/backend/mcp.mdpyproject.tomlsrc/one_dragon/base/operation/application/application_factory.pysrc/one_dragon/base/operation/application/application_run_context.pysrc/one_dragon/base/push/push_service.pysrc/one_dragon/devtools/python_launcher.pysrc/one_dragon/envs/python_service.pysrc/one_dragon/utils/cmd_utils.pysrc/one_dragon/utils/cv2_utils.pysrc/one_dragon/utils/os_utils.pysrc/one_dragon_qt/view/setting/setting_custom_interface.pysrc/one_dragon_qt/view/setting/setting_env_interface.pysrc/one_dragon_qt/view/setting/setting_push_interface.pysrc/onnxocr/predict_det.pysrc/sr_od/backend/backend_context.pysrc/sr_od/backend/entry/server.pysrc/sr_od/backend/http/routes.pysrc/sr_od/backend/http/service_routes.pysrc/sr_od/backend/mcp/app.pysrc/sr_od/backend/mcp/prompts.pysrc/sr_od/backend/mcp/service_app.pysrc/sr_od/backend/operation_registry.pysrc/sr_od/backend/schemas.pysrc/sr_od/gui/interface/devtools/mcp_service_interface.pysrc/sr_od/gui/interface/devtools/sr_devtools_interface.py
💤 Files with no reviewable changes (1)
- src/one_dragon_qt/view/setting/setting_push_interface.py
✅ Files skipped from review due to trivial changes (4)
- deploy/module_manifest.py
- docs/develop/sr_od/backend/mcp.md
- docs/develop/sr_od/backend/http.md
- docs/develop/sr_od/backend/README.md
🚧 Files skipped from review as they are similar to previous changes (3)
- pyproject.toml
- src/onnxocr/predict_det.py
- .github/workflows/test-check.yml
✅ Action performedReviews resumed. |
- python_launcher/python_service: 启动器同步运行环境文案(582d9984) - setting_instance_interface: 删除账号前二级确认框(a3365dc4) - .devin/wiki.json: Deep Wiki 生成配置(3c6309c9,zzz→sr 适配) 照搬 ZZZ common + 工具配置,token 适配。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- backend_context: + 画面建档方法 - mcp/app: MCP tool 规范化(output schema/annotation 等,+176) - prompts/service_app: 配套 - docs: + mcp-implementation.md、chrome-devtools-mcp.md;README/design-principles/mcp 更新 - 重提 RunSlot executor shutdown + spec 路径 照搬 ZZZ 7277d040,token 适配 sr_od。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/sr_od/backend/backend_context.py (1)
797-804: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift在刷新实例配置后再解析默认独立应用。
从当前缓存读取
active_app_id时,真正的_refresh_runtime_config()尚未在槽线程中执行。如果 GUI 刚刚切换了实例或独立应用,此时获取的app_id仍是旧值,导致最终运行错误的应用。建议将默认独立应用的解析移入
_refresh_runtime_config执行完成后的槽线程流程中,或者让单跑道_start支持延迟解析,以确保始终读取到刷新后的最新配置。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/sr_od/backend/backend_context.py` around lines 797 - 804, Update run_standalone_app so the default standalone application ID is resolved only after _refresh_runtime_config completes in the slot-thread flow, rather than reading _ctx.standalone_app_config.active_app_id immediately. Preserve explicit app_id behavior, and ensure missing refreshed IDs still raise BackendNotReadyError before invoking _start_app.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.devin/wiki.json:
- Around line 12-271: 全面校正 `.devin/wiki.json` 中残留的 ZZZ 术语与引用,确保 Wiki 只描述星穹铁道项目。将
`ZzzBackendContext`、`ZContext`、`zzz_context.py`、`zzz_pc_controller.py` 及相关
`docs/develop/zzz` 引用替换为仓库实际使用的 SR
对应符号和路径,并同步修正“零号空洞”等玩法及其业务目录;涉及内置应用、后端、上下文、控制器和开发文档条目时,应以当前源码与真实文档为准,分别映射到差分宇宙、模拟宇宙、忘却之庭、每日实训、委托等实际功能,避免保留或臆造
ZZZ 内容。
---
Duplicate comments:
In `@src/sr_od/backend/backend_context.py`:
- Around line 797-804: Update run_standalone_app so the default standalone
application ID is resolved only after _refresh_runtime_config completes in the
slot-thread flow, rather than reading _ctx.standalone_app_config.active_app_id
immediately. Preserve explicit app_id behavior, and ensure missing refreshed IDs
still raise BackendNotReadyError before invoking _start_app.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 04539832-d603-4f34-92cf-957107d4a5bf
📒 Files selected for processing (13)
.devin/wiki.jsondocs/develop/setup/chrome-devtools-mcp.mddocs/develop/sr_od/backend/README.mddocs/develop/sr_od/backend/design-principles.mddocs/develop/sr_od/backend/mcp-implementation.mddocs/develop/sr_od/backend/mcp.mdsrc/one_dragon/devtools/python_launcher.pysrc/one_dragon/envs/python_service.pysrc/one_dragon_qt/view/setting/setting_instance_interface.pysrc/sr_od/backend/backend_context.pysrc/sr_od/backend/mcp/app.pysrc/sr_od/backend/mcp/prompts.pysrc/sr_od/backend/mcp/service_app.py
🚧 Files skipped from review as they are similar to previous changes (3)
- docs/develop/sr_od/backend/mcp.md
- src/sr_od/backend/mcp/service_app.py
- docs/develop/sr_od/backend/README.md
CodeRabbit 指出 wiki.json 残留大量 ZZZ 内容(ZContext/ZzzBackendContext/hollow_zero/ auto_battle/恶名狩猎/式舆防卫战 等 SR 无的玩法与模块)。该文件是 Deep Wiki 的 repo 结构描述,内容深度 ZZZ 专属,token sed 改不全结构内容。保留会误导 Deep Wiki 基于错误描述生成文档。本次移除,需 SR 专属重写(按 SR 实际 app/context/docs)。 Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
概述
同步 ZZZ(绝区零一条龙)backend 最新演进到 SR。
open_and_enter_game被更细粒度工具取代,7 → 11 tool。照搬 ZZZ 已验证实现 + token 清单(common-package-sync.md§5)适配。承接已关闭的 #604(其 review 修复c4743d81未进 main,本 PR 一并带入)。工具变化(7 → 11)
open_game(enter=True, block=True)open_and_enter_game;enter=False只打开不登录(分步驱动登录)click_game(x, y, press_time=0)input_text(text, use_clipboard=None)game_config.type_input_way,可覆盖),返回脱敏文本upsert_screen_area(...)delete_screen_area(screen_name, area_name)保留:
check_game_window/capture_game_screen/analyze_screen(+screenshot 参)/close_game/get_run_status/stop_run。改动
screen_info.py:+upsert_area/remove_area_by_name(screen_area 工具依赖,one_dragon公共框架)backend_context.py:+ click_game / input_text / upsert_screen_area / delete_screen_area 切片 + analyze 按截图文件/图名解析;重提 RunSlot executor shutdown(ZZZ 仍未修,照搬会丢失,SR 保留修复)open_and_enter_game→open_game+ 4 新工具c4743d81):build_full.bat config 目录、common-sync 表格\|、daemon 精确 argv 匹配、backend_context executor shutdown —— 本 PR 带入 main验证
be58691:test_mcp_app 更新 + 5 新测试含 test_click_game/input_text/run_slot/close_game + conftest)ZPcController→SrPcController、spec 路径2026-07-05、裸端口等 token 缺口)RunSlot.shutdown就位照搬 ZZZ commit
2d73af97(open_game+click+input MCP) ·80bf5bd3(input_text 切片) ·7b102f38(click_game 切片) ·9972ba18(screen_info area CRUD) ·53bc2823(analyze 按截图解析) ·8087f220(mcp doc 7→9)端口
主 server 24001、daemon 24000(避与 ZZZ 同机冲突)。
🤖 Generated with Claude Code
Summary by CodeRabbit
/game/*)能力:支持一条龙与独立应用运行、任务状态查询,并提供常驻远程管理(启动/停止/重启)。