feat(toolchain): §25 Gitea @mention end-to-end integration #45
Reference in New Issue
Block a user
Delete Branch "feat/25-gitea-mention-toolchain"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
设计文档
改动
关键设计决策
❌ 必须修:
M1. [src/api/mention_utils.py:infer_intent] 意图推断关键词优先级 bug —
help_keywords包含"帮忙",会在collab_keywords(含"请帮忙")之前匹配。实测验证:"请帮忙澄清需求" → 被分类为 help(错误),应为 collaborate。
→ 修改方向:将 collab 检查移到 help 之前,或从 help_keywords 中移除"帮忙"(已被 assign 的"帮忙做"覆盖同类场景)。
→ 原因:"请帮忙"/"请协助"是协作请求的明确信号,不应被通用的"帮忙"抢走。
M2. [toolchain_routes.py:_handle_pr_closed] PR #44 self-kill 修复代码混入此 PR — PR #44(auto-deploy self-kill)仍处于 open 状态(尚未合并),但其代码出现在本 PR diff 中,说明 feat/25 分支基于 PR #44 的分支创建。
→ 修改方向:将 PR #44 单独合并后,rebase 此 PR 到最新 main。或从本 PR 移除 _handle_pr_closed 的 self-kill 改动。
→ 原因:1) 违反单一职责,增加 review 负担;2) PR #44 的 self-kill 代码尚有 M1/M2 必修问题未修(Review #76)。
M3. [全 PR] 无单元测试 — 设计文档 §25.7 定义了 15 个单元测试用例,但 PR 无任何测试文件。
mention_utils.py是新模块,extract_mentions、infer_intent、should_suppress_mention均无测试覆盖。→ 修改方向:新增
tests/unit/test_mention_utils.py,至少覆盖 §25.7 列出的核心用例(精确匹配、别名、前缀模糊、去重、排除自己、意图推断)。→ 原因:新功能无测试 = 无法验证正确性,尤其 infer_intent 已证实有 bug。
⚠️ 建议改:
S1. [toolchain_routes.py:_handle_issues]
_handle_issues中出现两个独立的if action == "opened"块(原有 assigned 处理 + 新增 @mention 处理)。建议合并为同一个 opened 分支内,减少代码分散。S2. [toolchain_routes.py:_handle_pull_request_review] S5 @mention 代码在 COMMENTED 和非 COMMENTED 两个分支各重复一份(~20行)。可提取为辅助函数减少重复。
S3. [toolchain_routes.py:_handle_pr_closed]
import re在 self_restart 条件块内部(约 L718),但re已在文件顶部导入。冗余 import 应删除。(如果按 M2 rebase 后此代码消失则自动修复)注:风险级别从 standard 升级为 high,因为 toolchain_routes.py 匹配 */router 高风险规则。
New files: - src/api/mention_utils.py: extract_mentions(), infer_intent(), _build_response_guidance(), AGENT_ALIAS mapping - templates/toolchain/mention.md: @mention notification template with context API + response guidance by intent type Modified: - src/api/toolchain_routes.py: S1-S5 handler changes - S1: Issue body @mention on opened - S2+S4: _handle_issue_comment control flow refactored (guard clause → positive if, CI + @mention independent paths) - S3: PR body @mention on opened - S5: Review body @mention on submitted - New _send_mention_mails() with auto-flow suppression - src/daemon/toolchain_templates.py: register mention template Design: docs/design/25-gitea-mention-toolchain.md (v2.0) Tests: 405 passed, 3 skippedf286d9acd0toe7f28cd36e✅ APPROVED
第一轮 M1-M3、S1-S3 全部修复确认:
866060e)CI: success ✅
⚠️ 一个小建议(不阻塞):
S1. [docs/design/25-gitea-mention-toolchain.md §25.3.1] 设计文档 infer_intent 伪代码 help_keywords 仍含"帮忙",与实际代码不一致。建议同步更新文档伪代码。