1- # AGENTS.md - AI 开发规范
1+ # AGENTS.md - AI Development Guidelines
22
3- 本文档定义了 AI 助手在开发 rc 项目时必须遵循的规范和约束。
3+ This document defines the standards and constraints that AI assistants must follow when developing the rc project.
44
5- ## 语言规范
5+ ## Language Requirements
66
7- ** 重要 ** :除了与 AI 助手的对话可以使用中文外,所有其他内容必须使用英文:
7+ ** Important ** : All content must be in English, except for conversations with AI assistants which may use Chinese:
88
9- - Code comments (代码注释)
10- - Commit messages (提交消息)
11- - PR titles and descriptions (PR 标题和描述)
12- - Documentation in code (代码文档)
13- - Error messages in code (代码中的错误消息)
14- - Log messages (日志消息)
15- - Variable and function names (变量和函数名)
9+ - Code comments
10+ - Commit messages
11+ - PR titles and descriptions
12+ - Documentation in code
13+ - Error messages in code
14+ - Log messages
15+ - Variable and function names
1616
17- ## 工作流程
17+ ## Workflow
1818
19- ### 1. 开始前
19+ ### 1. Before Starting
2020
21- 1 . 读取 ` IMPLEMENTATION_PLAN.md ` 确认当前阶段
22- 2 . 检查当前阶段的状态是否为 "进行中 "
23- 3 . 理解当前阶段的目标和验收标准
21+ 1 . Read ` IMPLEMENTATION_PLAN.md ` to confirm the current phase
22+ 2 . Check if the current phase status is "In Progress "
23+ 3 . Understand the goals and acceptance criteria for the current phase
2424
25- ### 2. 修改前
25+ ### 2. Before Modifying
2626
27- 1 . 检查目标文件是否为受保护文件
28- 2 . 如果是受保护文件,必须遵循 Breaking Change 流程
29- 3 . 阅读相关的现有代码,理解模式和约定
27+ 1 . Check if the target file is a protected file
28+ 2 . If it's a protected file, follow the Breaking Change process
29+ 3 . Read related existing code to understand patterns and conventions
3030
31- ### 3. 实现时
31+ ### 3. During Implementation
3232
33- 1 . 先写测试(红灯)
34- 2 . 实现最少代码通过测试(绿灯)
35- 3 . 重构清理代码
36- 4 . 确保所有测试通过
33+ 1 . Write tests first (red)
34+ 2 . Implement minimum code to pass tests (green)
35+ 3 . Refactor and clean up code
36+ 4 . Ensure all tests pass
3737
38- ### 4. 完成后
38+ ### 4. After Completion
3939
40- ** ⚠️ 重要:每次提交前必须通过所有检查! **
40+ ** ⚠️ Important: All checks must pass before each commit! **
4141
42- 1 . 运行 ` cargo fmt --all ` - 代码格式化
43- 2 . 运行 ` cargo clippy --workspace -- -D warnings ` - 静态检查, ** 必须零警告 **
44- 3 . 运行 ` cargo test --workspace ` - 单元测试, ** 必须全部通过 **
45- 4 . 更新 ` IMPLEMENTATION_PLAN.md ` 状态
46- 5 . ** 只有上述检查全部通过后,才能创建 git commit**
42+ 1 . Run ` cargo fmt --all ` - Code formatting
43+ 2 . Run ` cargo clippy --workspace -- -D warnings ` - Static analysis, ** must have zero warnings **
44+ 3 . Run ` cargo test --workspace ` - Unit tests, ** must all pass **
45+ 4 . Update ` IMPLEMENTATION_PLAN.md ` status
46+ 5 . ** Only create a git commit after all above checks pass **
4747 - Commit message format: ` feat(phase-N): <description> `
4848 - Example: ` feat(phase-1): implement alias commands and core infrastructure `
4949
50- ** 禁止在检查未通过的情况下提交代码! **
50+ ** Do not commit code when checks have not passed! **
5151
5252---
5353
54- ## 受保护文件
54+ ## Protected Files
5555
56- 以下文件的修改需要 Breaking Change 流程:
56+ The following files require the Breaking Change process for modifications:
5757
58- | 文件 | 说明 |
59- | ------| ------|
60- | ` docs/SPEC.md ` | CLI 行为合同 |
61- | ` schemas/output_v1.json ` | JSON 输出 schema |
62- | ` crates/cli/src/exit_code.rs ` | 退出码定义 |
63- | ` crates/core/src/config.rs ` | 配置 schema_version 相关 |
58+ | File | Description |
59+ | ------| ------------- |
60+ | ` docs/SPEC.md ` | CLI behavior contract |
61+ | ` schemas/output_v1.json ` | JSON output schema |
62+ | ` crates/cli/src/exit_code.rs ` | Exit code definitions |
63+ | ` crates/core/src/config.rs ` | Config schema_version related |
6464
65- ### Breaking Change 流程
65+ ### Breaking Change Process
6666
67- 修改受保护文件必须同时:
67+ Modifying protected files requires:
6868
69- 1 . ** 更新版本号 **
70- - 配置变更: bump ` schema_version `
71- - 输出变更:创建新的 ` output_v2.json ` schema
69+ 1 . ** Update version number **
70+ - Config changes: bump ` schema_version `
71+ - Output changes: create new ` output_v2.json ` schema
7272
73- 2 . ** 提供迁移方案 **
74- - 配置迁移:添加 ` migrations/v{N}_to_v{N+1}.rs `
75- - 文档更新:更新 SPEC.md 相关章节
73+ 2 . ** Provide migration path **
74+ - Config migration: add ` migrations/v{N}_to_v{N+1}.rs `
75+ - Documentation update: update relevant SPEC.md sections
7676
77- 3 . ** 更新 CHANGELOG**
78- - 在 CHANGELOG.md 中添加 BREAKING CHANGE 条目
77+ 3 . ** Update CHANGELOG**
78+ - Add BREAKING CHANGE entry in CHANGELOG.md
7979
80- 4 . ** PR 标记 **
81- - 在 PR 标题或描述中包含 ` BREAKING `
80+ 4 . ** PR marking **
81+ - Include ` BREAKING ` in PR title or description
8282
8383---
8484
85- ## 绝对禁止
85+ ## Absolute Prohibitions
8686
87- ### 代码层面
87+ ### Code Level
8888
89- 1 . ** 在 ` cli ` crate 中直接 ` use aws_sdk_s3 ` **
90- - 必须通过 ` core ` 的 trait 抽象访问 S3 功能
91- - 违反:破坏依赖边界
89+ 1 . ** Using ` use aws_sdk_s3 ` directly in ` cli ` crate **
90+ - Must access S3 functionality through ` core ` trait abstractions
91+ - Violation: breaks dependency boundaries
9292
93- 2 . ** 使用 ` .unwrap() ` ** (测试代码除外)
94- - 必须使用 ` ? ` 或 ` expect("reason") `
95- - 违反:可能导致 panic
93+ 2 . ** Using ` .unwrap() ` ** (except in test code)
94+ - Must use ` ? ` or ` expect("reason") `
95+ - Violation: may cause panic
9696
97- 3 . ** 使用 ` unsafe ` 代码 **
98- - 无例外
99- - 违反:安全风险
97+ 3 . ** Using ` unsafe ` code **
98+ - No exceptions
99+ - Violation: security risk
100100
101- 4 . ** 在日志/错误中打印凭证信息 **
102- - 包括: access_key, secret_key, Authorization 头
103- - 违反:安全风险
101+ 4 . ** Printing credentials in logs/errors **
102+ - Includes: access_key, secret_key, Authorization headers
103+ - Violation: security risk
104104
105- ### 流程层面
105+ ### Process Level
106106
107- 5 . ** 修改受保护文件而不走 Breaking Change 流程 **
108- - 违反:破坏向后兼容性
107+ 5 . ** Modifying protected files without following Breaking Change process **
108+ - Violation: breaks backward compatibility
109109
110- 6 . ** 删除或禁用测试来"修复 " CI**
111- - 必须修复测试失败的根本原因
112- - 违反:降低代码质量
110+ 6 . ** Deleting or disabling tests to "fix " CI**
111+ - Must fix the root cause of test failures
112+ - Violation: reduces code quality
113113
114- 7 . ** 跨层重构未经 ADR**
115- - 例如:把 s3 逻辑移到 cli
116- - 需要在 ` docs/ADR/ ` 中记录决策
114+ 7 . ** Cross-layer refactoring without ADR**
115+ - Example: moving s3 logic to cli
116+ - Requires recording decision in ` docs/ADR/ `
117117
118- 8 . ** 使用 ` --no-verify ` 绕过 commit hooks**
119- - 无例外
118+ 8 . ** Using ` --no-verify ` to bypass commit hooks**
119+ - No exceptions
120120
121121---
122122
123- ## 代码风格
123+ ## Code Style
124124
125- ### 错误处理
125+ ### Error Handling
126126
127127``` rust
128128// Recommended: Use thiserror to define error types
@@ -155,7 +155,7 @@ fn ok() {
155155}
156156```
157157
158- ### 异步代码
158+ ### Async Code
159159
160160``` rust
161161// Recommended: Use tokio
@@ -172,7 +172,7 @@ fn bad() {
172172}
173173```
174174
175- ### 日志
175+ ### Logging
176176
177177``` rust
178178use tracing :: {debug, info, warn, error};
@@ -188,7 +188,7 @@ error!("Auth failed: key={}", secret_key); // ❌ Absolutely forbidden
188188error! (" Auth failed: endpoint={}" , endpoint ); // ✓ Non-sensitive info is OK
189189```
190190
191- ### 注释
191+ ### Comments
192192
193193``` rust
194194// Recommended: Comments explain WHY, not just WHAT
@@ -204,9 +204,9 @@ counter += 1; // ❌ This comment adds no value
204204
205205---
206206
207- ## 命令实现模板
207+ ## Command Implementation Template
208208
209- 新命令必须遵循此模板:
209+ New commands must follow this template:
210210
211211``` rust
212212// crates/cli/src/commands/example.rs
@@ -273,13 +273,13 @@ mod tests {
273273
274274## PR Checklist
275275
276- ** ⚠️ 每次提交前必须确认以下所有检查项通过: **
276+ ** ⚠️ All checklist items must pass before each commit: **
277277
278278Before submitting a PR, confirm all of the following:
279279
280- - [ ] ` cargo fmt --all --check ` passes (** 必须 ** )
281- - [ ] ` cargo clippy --workspace -- -D warnings ` passes (** 必须,零警告 ** )
282- - [ ] ` cargo test --workspace ` passes (** 必须,全部通过 ** )
280+ - [ ] ` cargo fmt --all --check ` passes (** required ** )
281+ - [ ] ` cargo clippy --workspace -- -D warnings ` passes (** required, zero warnings ** )
282+ - [ ] ` cargo test --workspace ` passes (** required, all must pass ** )
283283- [ ] No changes to CLI/JSON/config contracts (or followed Breaking Change process)
284284- [ ] New behaviors have unit tests
285285- [ ] Each new command has at least 2 exit code test scenarios
@@ -289,11 +289,11 @@ Before submitting a PR, confirm all of the following:
289289- [ ] Updated IMPLEMENTATION_PLAN.md status (if applicable)
290290- [ ] Commit message and PR description are in English
291291
292- ** 禁止跳过检查直接提交! CI 失败的代码不应被合并。 **
292+ ** Do not skip checks and commit directly! Code that fails CI should not be merged. **
293293
294294---
295295
296- ## 依赖边界 ( Dependency Boundaries)
296+ ## Dependency Boundaries
297297
298298```
299299┌─────────────────────────────────────────────────────────┐
@@ -324,7 +324,7 @@ Before submitting a PR, confirm all of the following:
324324
325325---
326326
327- ## 常见错误及修复 ( Common Errors and Fixes)
327+ ## Common Errors and Fixes
328328
329329### Compilation Errors
330330
@@ -344,7 +344,7 @@ Before submitting a PR, confirm all of the following:
344344
345345---
346346
347- ## 阶段工作指南 ( Phase Work Guidelines)
347+ ## Phase Work Guidelines
348348
349349### Phase 0: Project Initialization
350350- Create workspace structure
@@ -370,4 +370,3 @@ Each completed phase should have a commit:
370370- Format: ` feat(phase-N): <brief description> `
371371- Example: ` feat(phase-0): initialize project structure and CI `
372372- Example: ` feat(phase-1): implement core infrastructure and alias commands `
373-
0 commit comments