fix: prevent #N auto-reference conversion in GitHub comments#175
Conversation
Two-layer defense against #N patterns being auto-converted to issue/PR references by GitHub: 1. Prompt layer: Add explicit instructions to all action prompts, reviewer personas, coordinator prompt, and language instructions telling the agent never to use #N format for numbering items. 2. Code layer: Add escapeHashReferences() post-processing in platform.ts that inserts a zero-width space between # and digits in agent output before posting as PR comments. Closes #173
|
我已读取所有变更文件和 PR body。Issue #173 的内容已在 PR body 中完整描述(webfetch 直接拉取该 issue 返回 404,但 PR body 包含了完整的 issue 描述和方案说明)。 分析Issue 规范(来自 PR body):
实现验证:
集成完整性:
PR body 中列出的所有文件、所有防御层级、所有集成路径均已实现,无缺失。 结论无遗漏 PR 完整实现了 issue #173 所要求的两层防御方案:所有 12 个 prompt/persona/语言指令文件均加入了 "不要使用 #N 格式" 指令; |
|
可合并 本 PR 通过 prompt 指令 + 阻塞项:无 建议项:
📋 各 Reviewer 详细审查结果quality可合并 阻塞项:无 建议项:
security安全无虞 本 PR 主要为评论输出增加 阻塞项:无 建议项:
performance性能良好 本 PR 的所有改动均不涉及性能敏感路径。核心新增逻辑仅在 主要改动性能分析:
潜在微观开销:
阻塞项:无 architecture架构有疑虑 本 PR 通过两层防御解决 GitHub 自动将 阻塞项:无 建议项:
|
- Widen escapeHashReferences regex to cover more contexts: parentheses, brackets, angle brackets, colons, and Chinese punctuation (:,、) - Skip code blocks (triple backtick fences) during escaping - Insert zero-width space between # and digits (not after) for correct GitHub reference breaking - Extract buildLangInstruction() in reviewers.ts for readability - Add architectural comment clarifying platform layer is authoritative - Use neutral notation in source comments (#<num> -> hash-number) - Unify Chinese/English instruction text between Python and TS - Add 14 unit tests for escapeHashReferences covering line start, after punctuation, Chinese punctuation, code block exclusion, and headings Addresses suggestions from PR #175 multi-review.

Summary
Closes #173
Agent 在输出中使用
#1、#2格式时,GitHub 会自动将其转换为 issue/PR 引用链接,导致语义被改变。方案:两层防御
1. Prompt 层(预防)
在所有 action 的默认 prompt、reviewer persona、coordinator prompt、语言指令中添加明确指令,告诉 agent 不要使用
#N格式编号。涉及文件:
review/action.ymlarchitect-review/action.ymlfeature-missing/action.ymlspec-coverage/action.ymlmulti-review/reviewers/*.yaml(quality, security, performance, architecture)multi-review/src/orchestrator.ts(DEFAULT_COORDINATOR_PROMPT)github-run-opencode/run-github-opencode.py(语言指令追加)multi-review/src/reviewers.ts(语言指令追加)2. Code 层(兜底)
在
multi-review/src/platform.ts的postPRComment()中添加escapeHashReferences()后处理函数,在发布 PR 评论前自动将#N中的#和数字之间插入零宽空格(zero-width space),阻止 GitHub 的自动引用转换。Testing
npx tsc --noEmit)