docs(agents): 添加AI代理编码行为规范文档

- 定义了环境能力清单和工具选择规则
- 规定了XML文档注释、内联注释和架构级注释要求
- 明确了代码风格包括命名约定、格式化和C#惯例
- 设立了测试覆盖范围、组织结构和验证命令标准
- 制定了安全规则防止输入验证和敏感数据泄露
- 规范了代码文档、任务跟踪和仓库文档更新流程
- 建立了审查标准确保代码质量和完整性
This commit is contained in:
GeWuYou 2026-04-09 19:23:17 +08:00
parent 16686a0d97
commit f9f608ad64

View File

@ -10,6 +10,10 @@ All AI agents and contributors must follow these rules when writing, reviewing,
- Use `@.ai/environment/tools.raw.yaml` only when you need the full collected facts behind the AI-facing hints.
- Prefer the project-relevant tools listed there instead of assuming every installed system tool is fair game.
- If the real environment differs from the inventory, use the project-relevant installed tool and report the mismatch.
- When working in WSL against this repository's Windows-backed worktree, prefer Windows Git from WSL (for example
`git.exe`) instead of the Linux `git` binary.
- If a Git command in WSL fails with a worktree-style “not a git repository” path translation error, rerun it with the
Windows Git executable and treat that as the repository-default Git path for the rest of the task.
## Commenting Rules (MUST)
@ -114,6 +118,15 @@ All generated or modified code MUST include clear and meaningful comments where
### Analyzer and Validation Expectations
- The repository uses `Meziantou.Analyzer`; treat analyzer feedback as part of the coding standard.
- Treat SonarQube maintainability rules as part of the coding standard as well, especially cognitive complexity and
oversized parameter list findings.
- When a method approaches analyzer complexity limits, prefer extracting named helper methods by semantic phase
(parsing, normalization, validation, diagnostics) instead of silencing the warning or doing cosmetic reshuffles.
- When a constructor or method exceeds parameter count limits, choose the refactor that matches the shape of the API:
use domain-specific value objects or parameter objects for naturally grouped data, and prefer named factory methods
when the call site is really selecting between different creation modes.
- Do not add suppressions for complexity or parameter-count findings unless the constraint is externally imposed and the
reason is documented in code comments.
- Naming must remain compatible with `scripts/validate-csharp-naming.sh`.
## Testing Requirements