Skip to content

fix: add default value for missing skill in CopilotOperator#496

Merged
wangl-cc merged 1 commit intoMaaAssistantArknights:mainfrom
travellerse:fix/copilot_skill_fix
Mar 21, 2026
Merged

fix: add default value for missing skill in CopilotOperator#496
wangl-cc merged 1 commit intoMaaAssistantArknights:mainfrom
travellerse:fix/copilot_skill_fix

Conversation

@travellerse
Copy link
Copy Markdown
Contributor

@travellerse travellerse commented Mar 1, 2026

前几天就遇到这个问题了,既然有人发issue了,就先开个pr

参照wpf那边的逻辑,从resource/battle_data.json中读取干员的rarity,并根据此对作业里的skill进行解析,暂时不考虑术兔这种5星却拥有3技能的情况

skill标准化处理之后单开个issue

fix #495

适配上游最近更改的MaaAssistantArknights/MaaAssistantArknights#15898,将skill默认值改为0

❯ maa-dev copilot --formation --ignore-requirements maa://85640
   Compiling maa-cli v0.7.1 (/home/trave/code/MaaAssistantArknights/src/maa-cli/crates/maa-cli)
    Finished `release` profile [optimized] target(s) in 9.86s
     Running `code/MaaAssistantArknights/src/maa-cli/target/release/maa copilot --formation --ignore-requirements 'maa://85640'`
[2026-03-03 22:14:10 INFO ] Updating hot update files...
[2026-03-03 22:14:10 INFO ] Hot update completed successfully
[2026-03-03 22:14:11 INFO ] Connected
[2026-03-03 22:14:11 INFO ] FastestWayToScreencap RawByNc 139
[2026-03-03 22:14:11 INFO ] Copilot Start
[2026-03-03 22:14:15 INFO ] BattleFormation 艾雅法拉, U-Official, 阻挡
[2026-03-03 22:14:39 INFO ] BattleFormationSelected 蛇屠箱
[2026-03-03 22:14:45 INFO ] BattleFormationSelected U-Official
[2026-03-03 22:14:48 INFO ] BattleFormationSelected 艾雅法拉
[2026-03-03 22:14:50 INFO ] MissionStart
[2026-03-03 22:15:02 INFO ] CurrentSteps Deploy 艾雅法拉
[2026-03-03 22:15:04 INFO ] CurrentSteps Deploy U-Official
[2026-03-03 22:15:17 INFO ] CurrentSteps SkillUsage 艾雅法拉
[2026-03-03 22:15:17 INFO ] CurrentSteps Deploy 阻挡
[2026-03-03 22:15:28 INFO ] CurrentSteps SwitchSpeed 
[2026-03-03 22:15:28 INFO ] CurrentSteps SkillDaemon 
[2026-03-03 22:16:04 INFO ] Copilot Completed
[2026-03-03 22:16:04 INFO ] AllTasksCompleted
Summary
----------------------------------------
[Copilot] 22:14:11 - 22:16:04 (1m 52s) Completed

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.52%. Comparing base (115f10a) to head (68ee02b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #496   +/-   ##
=======================================
  Coverage   70.52%   70.52%           
=======================================
  Files          61       61           
  Lines        5842     5842           
  Branches     5842     5842           
=======================================
  Hits         4120     4120           
  Misses       1406     1406           
  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.

@travellerse travellerse force-pushed the fix/copilot_skill_fix branch from 13d6dfb to 04edeeb Compare March 1, 2026 12:41
@travellerse travellerse marked this pull request as ready for review March 2, 2026 05:38
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 - 我在这里提供了一些高层次的反馈:

  • 在 copilot 文件解析循环中,你现在忽略了 resolve_copilot_uris 返回的内存中的 JSON 值,而是总是从 file 重新读取,这可能会破坏基于 URI 或内联的 copilot 定义;建议保留并规范化已经解析好的值,而不是直接丢弃它。
  • load_skill_support_map 目前会把所有在 battle_data.json 中缺失的干员视为稀有度 -1,并因此强制将技能 1–3 设为 0;如果这并不是严格想要的行为,你可能需要区分“未知干员”和“已知低稀有度干员”,这样未知名字就可以保留其已有的技能配置。
  • is_skill_supported 对于任何超出 1–3 的技能编号都会返回 true,这会在无提示的情况下把意外的技能下标当作受支持的;如果你期望技能编号严格为 0–3,那么可能应该显式拒绝或规范化这些超出范围的值。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- In the copilot file resolution loop you now ignore the in‑memory JSON value from `resolve_copilot_uris` and always re‑read from `file`, which may break URI/inlined copilot definitions; consider preserving and normalizing the already-parsed value instead of discarding it.
- `load_skill_support_map` currently treats any operator missing from `battle_data.json` as having rarity -1 and thus forces skills 1–3 to 0; if that’s not strictly desired, you may want to distinguish between unknown and known-low-rarity operators so that unknown names keep their configured skills.
- `is_skill_supported` returns `true` for any skill number outside 1–3, which silently treats unexpected skill indices as supported; if you expect skills to be strictly 0–3 you might instead reject or normalize out-of-range values explicitly.

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

Hey - I've left some high level feedback:

  • In the copilot file resolution loop you now ignore the in‑memory JSON value from resolve_copilot_uris and always re‑read from file, which may break URI/inlined copilot definitions; consider preserving and normalizing the already-parsed value instead of discarding it.
  • load_skill_support_map currently treats any operator missing from battle_data.json as having rarity -1 and thus forces skills 1–3 to 0; if that’s not strictly desired, you may want to distinguish between unknown and known-low-rarity operators so that unknown names keep their configured skills.
  • is_skill_supported returns true for any skill number outside 1–3, which silently treats unexpected skill indices as supported; if you expect skills to be strictly 0–3 you might instead reject or normalize out-of-range values explicitly.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the copilot file resolution loop you now ignore the in‑memory JSON value from `resolve_copilot_uris` and always re‑read from `file`, which may break URI/inlined copilot definitions; consider preserving and normalizing the already-parsed value instead of discarding it.
- `load_skill_support_map` currently treats any operator missing from `battle_data.json` as having rarity -1 and thus forces skills 1–3 to 0; if that’s not strictly desired, you may want to distinguish between unknown and known-low-rarity operators so that unknown names keep their configured skills.
- `is_skill_supported` returns `true` for any skill number outside 1–3, which silently treats unexpected skill indices as supported; if you expect skills to be strictly 0–3 you might instead reject or normalize out-of-range values explicitly.

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.

@travellerse travellerse force-pushed the fix/copilot_skill_fix branch 2 times, most recently from 36a0912 to 1902409 Compare March 3, 2026 14:09
@wangl-cc
Copy link
Copy Markdown
Member

wangl-cc commented Mar 21, 2026

我最近比较忙,一直没顾上看这边。感谢你的贡献和补充 WPF 的思路。如果只是修复 #495 的问题,其实目前不需要这么复杂的改动,直接给 CopilotOperator 的 skill 设置默认值即可。

当前这个 PR 还引入了基于 battle_data.json 的 skill 标准化处理。我不太清楚 WPF 的具体实现方式,让 Codex 帮忙看了一下,它提到 WPF 会处理多语言的干员名称,在当前 PR 中这可能导致回归,非中文干员名可能会被强行将 skill 设为 0。虽然不确定作业站是否真有非中文作业,但这在理论上确实存在回归风险。

如果你愿意继续推进当前这个方向,我建议至少先把 #495 的最小修复独立出来,这样后续标准化部分可以单独讨论。

@travellerse travellerse force-pushed the fix/copilot_skill_fix branch from 1902409 to 68ee02b Compare March 21, 2026 08:04
@travellerse travellerse changed the title fix(copilot): normalize copilot skills with battle data and align behavior with WPF GUI fix: add default value for missing skill in CopilotOperator Mar 21, 2026
@wangl-cc
Copy link
Copy Markdown
Member

LGTM!感谢贡献。

@wangl-cc wangl-cc merged commit 6b3086a into MaaAssistantArknights:main Mar 21, 2026
20 checks passed
@travellerse travellerse deleted the fix/copilot_skill_fix branch March 21, 2026 10:32
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.

copilot.rs 没有考虑无技能干员(如u酱)的作业

2 participants