Skip to content

feat: add loop-times support for copilot#501

Merged
wangl-cc merged 3 commits intomainfrom
codex/add-copilot-loop-times
Mar 21, 2026
Merged

feat: add loop-times support for copilot#501
wangl-cc merged 3 commits intomainfrom
codex/add-copilot-loop-times

Conversation

@wangl-cc
Copy link
Copy Markdown
Member

@wangl-cc wangl-cc commented Mar 11, 2026

Fixes #500

Summary

  • add the loop-times option to CopilotParams and merge it with overlay defaults for single-stage copilot runs
  • warn when loop_times is provided for copilot_list mode and keep that field out of multi-stage task parameters
  • reject invalid raid modes before formation prompts and cover the new loop-times behavior with tests

Testing

  • cargo +nightly fmt --all
  • cargo clippy
  • cargo test -p maa-cli
  • cargo x test --no-clippy
  • cargo x test

Summary by Sourcery

为 copilot 运行添加可配置的循环次数(loop-times)支持,并收紧 copilot 预设的 raid 模式校验。

New Features:

  • 为 copilot 单阶段运行引入 loop-times CLI 选项,并将其传递到任务参数中,支持默认值和通过 CLI 覆盖。

Enhancements:

  • 在构建 copilot 参数的早期阶段校验 raid 模式,并将后续出现的无效分支视为不可达,以防止出现不一致的配置。

Tests:

  • 扩展 copilot CLI 测试,用于覆盖 loop-times 的默认值、CLI 覆盖,以及在指定多个 copilot 任务时的行为,包括在列表模式(list mode)下忽略 loop-times 的情况。
Original summary in English

Summary by Sourcery

Add configurable loop-times support to copilot runs and tighten raid mode validation for copilot presets.

New Features:

  • Introduce a loop-times CLI option for copilot single-stage runs and propagate it into task parameters, supporting default values and CLI overrides.

Enhancements:

  • Validate raid mode early in copilot parameter construction and treat later invalid branches as unreachable to prevent inconsistent configurations.

Tests:

  • Extend copilot CLI tests to cover loop-times defaults, CLI overrides, and the behavior when multiple copilot tasks are specified, including ignoring loop-times in list mode.

Copy link
Copy Markdown

@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.

Hey - 我在这里给出了一些高层次的反馈:

  • 建议对 loop_times 做校验(例如,强制其为正数且非零,或者使用无符号类型),以避免明显无效的循环次数进入核心逻辑。
  • unreachable!("invalid raid mode must be rejected before stage resolution") 依赖于之前的校验永远不退化;你可能希望在这里保留一个更防御性的 bail!,这样未来修改导致出现的意料之外的值可以以对用户可见的错误形式暴露,而不是触发 panic。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- Consider validating `loop_times` (e.g., enforcing it is positive and non-zero or using an unsigned type) to avoid passing obviously invalid loop counts through to the core logic.
- The `unreachable!("invalid raid mode must be rejected before stage resolution")` depends on the earlier validation never regressing; you may want to keep a defensive `bail!` here instead so that unexpected values from future changes are surfaced as user-facing errors rather than panics.

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

Hey - I've left some high level feedback:

  • Consider validating loop_times (e.g., enforcing it is positive and non-zero or using an unsigned type) to avoid passing obviously invalid loop counts through to the core logic.
  • The unreachable!("invalid raid mode must be rejected before stage resolution") depends on the earlier validation never regressing; you may want to keep a defensive bail! here instead so that unexpected values from future changes are surfaced as user-facing errors rather than panics.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider validating `loop_times` (e.g., enforcing it is positive and non-zero or using an unsigned type) to avoid passing obviously invalid loop counts through to the core logic.
- The `unreachable!("invalid raid mode must be rejected before stage resolution")` depends on the earlier validation never regressing; you may want to keep a defensive `bail!` here instead so that unexpected values from future changes are surfaced as user-facing errors rather than panics.

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.44%. Comparing base (38c95be) to head (3f66f38).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/maa-cli/src/run/preset/copilot.rs 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #501      +/-   ##
==========================================
+ Coverage   70.39%   70.44%   +0.04%     
==========================================
  Files          61       61              
  Lines        5834     5847      +13     
  Branches     5834     5847      +13     
==========================================
+ Hits         4107     4119      +12     
- Misses       1411     1412       +1     
  Partials      316      316              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wangl-cc wangl-cc force-pushed the codex/add-copilot-loop-times branch from 1396536 to 014dc1a Compare March 21, 2026 03:59
@wangl-cc wangl-cc force-pushed the codex/add-copilot-loop-times branch from 014dc1a to db7b2df Compare March 21, 2026 04:13
@wangl-cc wangl-cc merged commit 39794fe into main Mar 21, 2026
20 checks passed
@wangl-cc wangl-cc deleted the codex/add-copilot-loop-times branch March 21, 2026 04:35
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.

Feature request: 允许运行自动作战多次

1 participant