Skip to content

Refactor: 恢复信用点商店的GO逻辑#1548

Merged
MistEO merged 53 commits intov2from
refactor/Creditshopping
Mar 23, 2026
Merged

Refactor: 恢复信用点商店的GO逻辑#1548
MistEO merged 53 commits intov2from
refactor/Creditshopping

Conversation

@overflow65537
Copy link
Copy Markdown
Member

@overflow65537 overflow65537 commented Mar 23, 2026

低代码版目前的问题:

运行速度过慢

低代码版需要多次识别(一个物品进行识别16次OCR,如果是白名单,折扣购买和黑名单购买,那则需要48次)
即使经过优化也和GO逻辑中的一次识别有巨大差距

严重逻辑错误

低代码中的识别物品是or逻辑,会导致物品选择的优先级会使用代码的顺序,而非是折扣力度

Summary by Sourcery

恢复并集成基于 Go 的积分商城处理逻辑,用其替换低代码实现,以获得更快速、基于配置驱动的处理流水线。

新功能:

  • 引入一个 Go 编写的积分购物模块,从流水线元数据中解析商品白名单/黑名单配置,并应用 OCR 匹配覆盖规则。
  • 添加自定义识别组件,在购买商品之前强制执行可配置的预留积分阈值。

增强改进:

  • 将新的积分购物 Go 模块接入到代理服务注册、任务定义以及每日任务预设中,以使用恢复后的逻辑。
  • 更新积分购物流程相关的本地化、流水线和任务资源,使其与新的基于 Go 的行为保持一致。
Original summary in English

Summary by Sourcery

Restore and integrate the Go-based credit shop handling, replacing the low-code implementation with a faster, configuration-driven pipeline.

New Features:

  • Introduce a Go credit shopping module that parses item whitelist/blacklist configuration from pipeline metadata and applies OCR matching overrides.
  • Add a custom recognition component to enforce a configurable reserve credit threshold before purchasing items.

Enhancements:

  • Wire the new credit shopping Go module into the agent service registration, task definitions, and daily task presets to use the restored logic.
  • Update localization, pipelines, and task assets for the credit shopping flow to align with the new Go-based behavior.
Original summary in English

Summary by Sourcery

恢复并集成基于 Go 的积分商城处理逻辑,用其替换低代码实现,以获得更快速、基于配置驱动的处理流水线。

新功能:

  • 引入一个 Go 编写的积分购物模块,从流水线元数据中解析商品白名单/黑名单配置,并应用 OCR 匹配覆盖规则。
  • 添加自定义识别组件,在购买商品之前强制执行可配置的预留积分阈值。

增强改进:

  • 将新的积分购物 Go 模块接入到代理服务注册、任务定义以及每日任务预设中,以使用恢复后的逻辑。
  • 更新积分购物流程相关的本地化、流水线和任务资源,使其与新的基于 Go 的行为保持一致。
Original summary in English

Summary by Sourcery

Restore and integrate the Go-based credit shop handling, replacing the low-code implementation with a faster, configuration-driven pipeline.

New Features:

  • Introduce a Go credit shopping module that parses item whitelist/blacklist configuration from pipeline metadata and applies OCR matching overrides.
  • Add a custom recognition component to enforce a configurable reserve credit threshold before purchasing items.

Enhancements:

  • Wire the new credit shopping Go module into the agent service registration, task definitions, and daily task presets to use the restored logic.
  • Update localization, pipelines, and task assets for the credit shopping flow to align with the new Go-based behavior.

overflow65537 and others added 30 commits March 9, 2026 20:17
… Added parameters for `refresh_image` and `getimg` in the action's JSON schema and updated the OCR logic to conditionally capture a new screenshot based on these parameters. Updated documentation to reflect these changes.
… parameter structure by removing redundant fields and improved error handling. Updated ROI values in the JSON configuration for CreditShopping actions to reflect new naming conventions.
…ion functions for ROI, ROIOffset, and Expected parameters to streamline input validation and ensure default values are set correctly. Updated OCR function call to utilize these new normalization methods.
…tailed logs for parameter normalization and OCR attempts, including fallback mechanisms for error scenarios. Improved context validation to ensure robustness during OCR execution.
…on results. Removed redundant parameters and updated logging to reflect the new structure. Adjusted JSON configurations for CreditShopping actions to align with the simplified parameter model. Updated documentation to clarify changes in action behavior and parameter usage.
…ognition parameters. Enhanced error handling and logging for context validation and OCR execution. Updated documentation to reflect changes in parameter requirements and action behavior.
…meters in JSON configuration. Removed redundant override logic and enhanced the OCR execution process. Updated action parameters to include detailed recognition settings for improved accuracy in CreditShopping actions.
…plified the override structure by directly using recognition configurations and added compatibility for nested recognition formats. Updated documentation to clarify parameter expectations.
…s. Deleted associated files and references in the pipeline JSON, streamlining the codebase. Updated documentation to reflect the removal of this action and its parameters.
…ctionality into CreditShopping pipeline JSON configurations for item recognition. Update action parameters to utilize OCR results for enhanced user feedback.
… OCR functionality into CreditShopping pipeline JSON configurations for item recognition. Update action parameters to utilize OCR results for enhanced user feedback."

This reverts commit 761cf37.
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: overflow65537 <[email protected]>
Co-authored-by: overflow65537 <[email protected]>
@Daydreamer114 Daydreamer114 changed the title Refactor:恢复信用点商店的GO逻辑 Refactor: 恢复信用点商店的GO逻辑 Mar 23, 2026
@overflow65537 overflow65537 linked an issue Mar 23, 2026 that may be closed by this pull request
@overflow65537 overflow65537 marked this pull request as ready for review March 23, 2026 14:43
Copilot AI review requested due to automatic review settings March 23, 2026 14:43
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好——我这边有一些整体性的反馈:

  • 那些硬编码的节点和流水线名称(例如 "BuyFirstOCR", "BuyFirstOCR_CanNotAfford", "BlacklistOCR", "CreditShoppingReserveCreditOCRInternal")以及默认的预留阈值 300,如果能在包里定义为具名常量,会更易维护,也更不容易出错。
  • reserveCreditRecognition.Run 中,所有解析/识别失败(parseReserveCreditThreshold, RunRecognition, extractReserveCredit)都会让识别返回 (nil, false);建议区分配置错误(例如错误的 JSON)与短暂的 OCR 问题,要么回退到一个安全的默认值,要么以更清晰的失败模式暴露出来,避免配置错误悄悄地让预留逻辑失效。
给 AI 代理的提示词
Please address the comments from this code review:

## Overall Comments
- The hard-coded node and pipeline names (e.g. "BuyFirstOCR", "BuyFirstOCR_CanNotAfford", "BlacklistOCR", "CreditShoppingReserveCreditOCRInternal") and the default reserve threshold `300` would be easier to maintain and less error‑prone if defined as named constants in the package.
- In `reserveCreditRecognition.Run`, all parse/recognition failures (`parseReserveCreditThreshold`, `RunRecognition`, `extractReserveCredit`) cause the recognition to return `(nil, false)`; consider distinguishing configuration errors (e.g. bad JSON) from transient OCR issues and either falling back to a safe default or surfacing a clearer failure mode so misconfiguration doesn’t silently disable the reserve logic.

Sourcery 对开源项目是免费的——如果你觉得我们的评审对你有帮助,欢迎分享 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进之后的评审。
Original comment in English

Hey - I've left some high level feedback:

  • The hard-coded node and pipeline names (e.g. "BuyFirstOCR", "BuyFirstOCR_CanNotAfford", "BlacklistOCR", "CreditShoppingReserveCreditOCRInternal") and the default reserve threshold 300 would be easier to maintain and less error‑prone if defined as named constants in the package.
  • In reserveCreditRecognition.Run, all parse/recognition failures (parseReserveCreditThreshold, RunRecognition, extractReserveCredit) cause the recognition to return (nil, false); consider distinguishing configuration errors (e.g. bad JSON) from transient OCR issues and either falling back to a safe default or surfacing a clearer failure mode so misconfiguration doesn’t silently disable the reserve logic.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The hard-coded node and pipeline names (e.g. "BuyFirstOCR", "BuyFirstOCR_CanNotAfford", "BlacklistOCR", "CreditShoppingReserveCreditOCRInternal") and the default reserve threshold `300` would be easier to maintain and less error‑prone if defined as named constants in the package.
- In `reserveCreditRecognition.Run`, all parse/recognition failures (`parseReserveCreditThreshold`, `RunRecognition`, `extractReserveCredit`) cause the recognition to return `(nil, false)`; consider distinguishing configuration errors (e.g. bad JSON) from transient OCR issues and either falling back to a safe default or surfacing a clearer failure mode so misconfiguration doesn’t silently disable the reserve logic.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 旨在恢复并优化基于 Go 的信用点商店处理逻辑,通过自定义 Action/Recognition 动态下发 OCR 匹配参数,替代当前低代码实现的性能与优先级问题。

Changes:

  • 在 Go 侧新增 CreditShoppingParseParams 自定义动作与 CreditShoppingReserveRecognition 自定义识别,并注册到 agent。
  • 重构信用商店相关 pipeline:将大量按物品拆分的 OCR 节点改为通过 attach 关键字聚合生成正则 expected,并新增“保留信用点阈值”输入项。
  • 更新信用商店相关资源与多语言文案,并同步 MaaEnd 测试集子模块版本。

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tests/MaaEndTestset 更新测试集子模块版本以覆盖新信用商店行为
assets/tasks/preset/QuickDaily.json 预设中将 CreditShoppingReserve 从开关改为阈值输入结构
assets/tasks/preset/DailyFull.json 同上,更新全量日常预设的 CreditShoppingReserve 配置
assets/tasks/CreditShopping.json 重构选项结构(attach 关键字、Reserve 输入项、Force 新增 Exit 等)与默认值
assets/resource/pipeline/CreditShopping/Shopping.json 接入自定义动作/识别;调整购物流程节点顺序;新增 ReserveCredit 自定义识别节点
assets/resource/pipeline/CreditShopping/Reflash.json 刷新按钮 OCR 期望文本从正则改为固定英文
assets/resource/pipeline/CreditShopping/ItemFocus.json 删除按物品拆分的 OCR 节点文件(改由 attach + Go 覆盖生成 expected)
assets/resource/pipeline/CreditShopping/Item.json 重构可买/不可买识别与 BuyFirst/Blacklist OCR 逻辑(expected 作为占位待 Go 覆盖)
assets/resource/pipeline/CreditShopping/ClaimCredit.json 领取信用按钮 OCR 期望文本从正则改为固定英文
assets/resource/pipeline/CreditShopping/BuyItemFocus.json 补充/调整购买确认页的各物品 OCR 识别节点与 focus 文案键
assets/resource/pipeline/CreditShopping/BuyItem.json 调整购买确认页识别 ROI/expected;更新 next 列表
assets/misc/locales/zh_tw.json 新增/调整信用商店相关选项与物品文案(含 Reserve 阈值输入项)
assets/misc/locales/zh_cn.json 同上(简中)
assets/misc/locales/ko_kr.json 同上(韩语)
assets/misc/locales/ja_jp.json 同上(日语)
assets/misc/locales/en_us.json 同上(英文)
agent/go-service/register.go 在 Go 服务中注册 creditshopping 组件
agent/go-service/creditshopping/reserve_recognition.go 新增“信用点低于阈值”自定义识别实现
agent/go-service/creditshopping/register.go 注册自定义 Action/Recognition 到 agent server
agent/go-service/creditshopping/creditshopping.go 新增参数解析自定义动作:从节点 attach 聚合关键词并 OverridePipeline 生成 expected

@MistEO MistEO merged commit ede5c03 into v2 Mar 23, 2026
17 checks passed
@MistEO MistEO deleted the refactor/Creditshopping branch March 23, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

信用点购物,协议圆盘组购买失败 信用点购物不会买部分折扣物品 信用商店执行刷新时检测信用点余额

4 participants