Skip to content

feat: 添加重置节点命中计数的通用Custom 自定义动作,并添加对应文档和示例#1063

Merged
MistEO merged 3 commits intoMaaEnd:mainfrom
ocsin1:feat/ClearHitCount
Mar 7, 2026
Merged

feat: 添加重置节点命中计数的通用Custom 自定义动作,并添加对应文档和示例#1063
MistEO merged 3 commits intoMaaEnd:mainfrom
ocsin1:feat/ClearHitCount

Conversation

@ocsin1
Copy link
Contributor

@ocsin1 ocsin1 commented Mar 7, 2026

变更内容

新增功能

  • 新增 ClearHitCount 自定义动作,用于清除指定节点的命中计数
  • 支持批量清除多个节点的命中计数
  • 提供 strict 参数控制清除失败时的行为

Summary by Sourcery

添加一个新的 ClearHitCount 自定义动作,用于重置节点命中次数,并通过示例文档说明其用法。

新功能:

  • 引入 ClearHitCount 自定义动作,用于清除一个或多个指定节点的命中次数,并支持可选的严格失败处理。

增强:

  • 在 Go 服务中注册 ClearHitCount 自定义动作,以便可以通过 Custom 机制调用。

文档:

  • 在英文和中文开发者指南中记录 ClearHitCount 自定义动作的相关内容,包括参数、行为和注意事项。
  • 新增一个流水线 JSON 示例,演示如何使用 ClearHitCount 自定义动作。
Original summary in English

Summary by Sourcery

Add a new ClearHitCount custom action to reset node hit counts and document its usage with examples.

New Features:

  • Introduce the ClearHitCount custom action to clear hit counts for one or more specified nodes with optional strict failure handling.

Enhancements:

  • Register the ClearHitCount custom action in the Go service so it can be invoked via the Custom mechanism.

Documentation:

  • Document the ClearHitCount custom action in both English and Chinese developer guides, including parameters, behavior, and notes.
  • Add a pipeline JSON example demonstrating how to use the ClearHitCount custom action.

新特性:

  • 新增 ClearHitCount 自定义动作,可在可选的严格失败处理模式下,清除一个或多个指定节点的命中计数。

功能增强:

  • 在 Go 服务中注册新的 ClearHitCount 自定义动作,使其可以通过 Custom 机制被调用。

文档:

  • 在英文和中文开发者指南中记录 ClearHitCount 自定义动作的相关内容,包括参数、行为及使用注意事项。
  • 新增一个流水线(pipeline)JSON 示例,展示如何使用 ClearHitCount 自定义动作。
Original summary in English

Summary by Sourcery

添加一个新的 ClearHitCount 自定义动作,用于重置节点命中次数,并通过示例文档说明其用法。

新功能:

  • 引入 ClearHitCount 自定义动作,用于清除一个或多个指定节点的命中次数,并支持可选的严格失败处理。

增强:

  • 在 Go 服务中注册 ClearHitCount 自定义动作,以便可以通过 Custom 机制调用。

文档:

  • 在英文和中文开发者指南中记录 ClearHitCount 自定义动作的相关内容,包括参数、行为和注意事项。
  • 新增一个流水线 JSON 示例,演示如何使用 ClearHitCount 自定义动作。
Original summary in English

Summary by Sourcery

Add a new ClearHitCount custom action to reset node hit counts and document its usage with examples.

New Features:

  • Introduce the ClearHitCount custom action to clear hit counts for one or more specified nodes with optional strict failure handling.

Enhancements:

  • Register the ClearHitCount custom action in the Go service so it can be invoked via the Custom mechanism.

Documentation:

  • Document the ClearHitCount custom action in both English and Chinese developer guides, including parameters, behavior, and notes.
  • Add a pipeline JSON example demonstrating how to use the ClearHitCount custom action.

Copy link
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.

Hey - 我发现了 1 个问题,并给出了一些整体层面的反馈:

  • ClearHitCountAction.Run 中,对空节点名的检查仅使用 nodeName == "";建议在检查前先去除空白字符(trim),这样像 " " 这样的名称也会被视为无效。
  • 当部分节点清除失败但 strictfalse 时,该 action 仍然会记录错误日志;如果在此模式下预期会出现部分失败,建议将这些日志级别从 error 降级为 warning 或 info,以减少正常运行时的噪音。
给 AI Agent 的提示词
Please address the comments from this code review:

## Overall Comments
- In `ClearHitCountAction.Run`, empty node names are only checked by `nodeName == ""`; consider trimming whitespace so names like `"  "` are also treated as invalid.
- When some nodes fail to clear but `strict` is `false`, the action still logs errors; if partial failure is expected in this mode, consider downgrading those logs to warning or info to reduce noise in normal operation.

## Individual Comments

### Comment 1
<location path="docs/zh_cn/developers/custom-action.md" line_range="64" />
<code_context>
+- **注意事项**
+    - 节点按 `nodes` 数组顺序依次清除计数,某个节点清除失败不影响其他节点的清除。
+    - 节点名称必须与 Pipeline 中定义的节点名称完全一致。
+    - 节点不存在或从未被执行过时,清除操作会失败。
+    -`strict: false` 时,即使部分节点清除失败,action 也会返回成功,适用于清理可能不存在的可选节点。
+    -`strict: true` 时,任一节点清除失败都会导致 action 返回失败,适用于关键节点的计数清理。
</code_context>
<issue_to_address>
**question:** Clarify whether the Chinese description should match the English condition (“recognized successfully” vs “executed”).

The English text says “Clearing a node will fail if the node does not exist or has never been recognized successfully,” while the Chinese reads “节点不存在或从未被执行过时,清除操作会失败.” These differ (“recognized successfully” vs “executed”). Please confirm the intended behavior and update one language so they describe the same condition.
</issue_to_address>

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

Hey - I've found 1 issue, and left some high level feedback:

  • In ClearHitCountAction.Run, empty node names are only checked by nodeName == ""; consider trimming whitespace so names like " " are also treated as invalid.
  • When some nodes fail to clear but strict is false, the action still logs errors; if partial failure is expected in this mode, consider downgrading those logs to warning or info to reduce noise in normal operation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `ClearHitCountAction.Run`, empty node names are only checked by `nodeName == ""`; consider trimming whitespace so names like `"  "` are also treated as invalid.
- When some nodes fail to clear but `strict` is `false`, the action still logs errors; if partial failure is expected in this mode, consider downgrading those logs to warning or info to reduce noise in normal operation.

## Individual Comments

### Comment 1
<location path="docs/zh_cn/developers/custom-action.md" line_range="64" />
<code_context>
+- **注意事项**
+    - 节点按 `nodes` 数组顺序依次清除计数,某个节点清除失败不影响其他节点的清除。
+    - 节点名称必须与 Pipeline 中定义的节点名称完全一致。
+    - 节点不存在或从未被执行过时,清除操作会失败。
+    -`strict: false` 时,即使部分节点清除失败,action 也会返回成功,适用于清理可能不存在的可选节点。
+    -`strict: true` 时,任一节点清除失败都会导致 action 返回失败,适用于关键节点的计数清理。
</code_context>
<issue_to_address>
**question:** Clarify whether the Chinese description should match the English condition (“recognized successfully” vs “executed”).

The English text says “Clearing a node will fail if the node does not exist or has never been recognized successfully,” while the Chinese reads “节点不存在或从未被执行过时,清除操作会失败.” These differ (“recognized successfully” vs “executed”). Please confirm the intended behavior and update one language so they describe the same condition.
</issue_to_address>

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.

@ocsin1 ocsin1 marked this pull request as draft March 7, 2026 05:18
ocsin1 added 2 commits March 7, 2026 13:20
- strict 模式下失败记录 error 级别日志
- 非 strict 模式下失败记录 warning 级别日志
- 减少非严格模式下的日志噪音
- 中英文文档统一使用'从未被执行过'(never been executed)
- 更准确描述节点状态,避免技术实现细节带来的混淆
- 从用户角度理解节点执行流程
@ocsin1 ocsin1 marked this pull request as ready for review March 7, 2026 05:25
Copy link
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.

Hey - 我已经审查了你的更改,看起来很棒!


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

Hey - I've reviewed your changes and they look great!


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.

@MistEO MistEO merged commit d194d34 into MaaEnd:main Mar 7, 2026
17 checks passed
@ocsin1 ocsin1 deleted the feat/ClearHitCount branch March 7, 2026 06:38
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.

2 participants