universal-dev-standards 6.14.0-beta.3 → 6.14.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled/ai/standards/ai-response-navigation.ai.yaml +43 -3
- package/bundled/ai/standards/checkin-standards.ai.yaml +25 -6
- package/bundled/ai/standards/pipeline-security-gates.ai.yaml +5 -1
- package/bundled/core/ai-response-navigation.md +128 -12
- package/bundled/extensions/frameworks/fat-free-patterns.md +937 -0
- package/bundled/extensions/languages/csharp-style.md +464 -0
- package/bundled/extensions/languages/php/fat-free-patterns.md +915 -0
- package/bundled/extensions/languages/php/php-style.md +693 -0
- package/bundled/extensions/languages/php-style.md +700 -0
- package/bundled/extensions/locales/zh-cn.md +717 -0
- package/bundled/extensions/locales/zh-tw.md +717 -0
- package/bundled/locales/COVERAGE.md +5 -4
- package/bundled/locales/zh-CN/CHANGELOG.md +27 -3
- package/bundled/locales/zh-CN/README.md +2 -2
- package/bundled/locales/zh-CN/SECURITY.md +1 -1
- package/bundled/locales/zh-CN/core/ai-response-navigation.md +110 -12
- package/bundled/locales/zh-CN/skills/README.md +1 -0
- package/bundled/locales/zh-CN/skills/comprehension-ladder/SKILL.md +289 -0
- package/bundled/locales/zh-CN/skills/comprehension-ladder/eval-cases.md +261 -0
- package/bundled/locales/zh-TW/CHANGELOG.md +27 -3
- package/bundled/locales/zh-TW/README.md +2 -2
- package/bundled/locales/zh-TW/SECURITY.md +1 -1
- package/bundled/locales/zh-TW/core/ai-response-navigation.md +110 -12
- package/bundled/locales/zh-TW/skills/README.md +1 -0
- package/bundled/locales/zh-TW/skills/comprehension-ladder/SKILL.md +289 -0
- package/bundled/locales/zh-TW/skills/comprehension-ladder/eval-cases.md +261 -0
- package/bundled/skills/README.md +1 -0
- package/bundled/skills/comprehension-ladder/SKILL.md +283 -0
- package/bundled/skills/comprehension-ladder/eval-cases.md +255 -0
- package/package.json +2 -2
- package/src/commands/init.js +29 -9
- package/src/commands/update.js +3 -2
- package/src/installers/standards-installer.js +16 -23
- package/src/reconciler/plan-executor.js +10 -11
- package/src/uninstallers/hook-uninstaller.js +5 -3
- package/src/utils/copier.js +57 -0
- package/src/utils/git-hooks.js +8 -4
- package/src/utils/locale.js +19 -0
- package/standards-registry.json +21 -7
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
# Simplified Chinese (Mainland China) Locale Standard
|
|
2
|
+
# 简体中文(中国大陆)地区规范
|
|
3
|
+
|
|
4
|
+
**Version**: 1.0.0
|
|
5
|
+
**Last Updated**: 2026-10-05
|
|
6
|
+
**Applicability**: Projects with Simplified Chinese documentation or mainland China teams
|
|
7
|
+
**适用范围**: 使用简体中文文档或中国大陆团队的项目
|
|
8
|
+
**Derived from**: `extensions/locales/zh-tw.md` v1.2.0 (re-written with mainland terminology, not a character-for-character conversion)
|
|
9
|
+
**来源**: 由 `extensions/locales/zh-tw.md` v1.2.0 改写(采用大陆通行术语,并非逐字转换)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Purpose | 目的
|
|
14
|
+
|
|
15
|
+
This standard defines language usage guidelines for projects with Simplified Chinese documentation, ensuring consistency between Chinese content and English code.
|
|
16
|
+
|
|
17
|
+
本标准定义使用简体中文文档的项目的语言使用准则,确保中文内容与英文代码之间的一致性。
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Core Principle | 核心原则
|
|
22
|
+
|
|
23
|
+
**Chinese for Communication, English for Code**
|
|
24
|
+
**中文用于沟通,英文用于代码**
|
|
25
|
+
|
|
26
|
+
- ✅ Documentation, comments, and commit messages: Simplified Chinese
|
|
27
|
+
- ✅ Code (variables, functions, classes): English
|
|
28
|
+
- ✅ Log messages: English (for international teams and tooling compatibility)
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Language Usage Matrix | 语言使用矩阵
|
|
33
|
+
|
|
34
|
+
| Content Type | Language | Rationale | 示例 |
|
|
35
|
+
|--------------|----------|-----------|------|
|
|
36
|
+
| **Code** |
|
|
37
|
+
| Variable names | English | Universal readability | `userName` ✅<br>`用户名称` ❌ |
|
|
38
|
+
| Function names | English | Universal readability | `authenticateUser()` ✅<br>`认证用户()` ❌ |
|
|
39
|
+
| Class names | English | Universal readability | `UserService` ✅<br>`用户服务` ❌ |
|
|
40
|
+
| **Documentation** |
|
|
41
|
+
| README.md | 简体中文 | Team communication | ✅ |
|
|
42
|
+
| API documentation | 简体中文 | User-facing docs | ✅ |
|
|
43
|
+
| Architecture docs | 简体中文 | Design communication | ✅ |
|
|
44
|
+
| **Code Comments** |
|
|
45
|
+
| Inline comments | 简体中文 | Explain intent to team | `// 验证用户权限` ✅ |
|
|
46
|
+
| Doc comments | 简体中文 | API documentation | `/// <summary>验证用户</summary>` ✅ |
|
|
47
|
+
| **Commit Messages** |
|
|
48
|
+
| Type | 简体中文 | Team preference | `新增`, `修复`, `重构` ✅ |
|
|
49
|
+
| Subject | 简体中文 | Clear communication | `实现 OAuth2 登录` ✅ |
|
|
50
|
+
| Body | 简体中文 | Detailed explanation | ✅ |
|
|
51
|
+
| **Logging** |
|
|
52
|
+
| Log messages | English | Tool compatibility | `logger.info("User authenticated")` ✅ |
|
|
53
|
+
| Error messages | English | Searchability | `throw new Error("Invalid credentials")` ✅ |
|
|
54
|
+
| **Configuration** |
|
|
55
|
+
| Config keys | English | Standard practice | `maxRetryCount` ✅ |
|
|
56
|
+
| Config comments | 简体中文 | Explain to team | `# 最大重试次数` ✅ |
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Certainty Tags (Chinese) | 确定性标签(中文)
|
|
61
|
+
|
|
62
|
+
When using AI assistants with Simplified Chinese documentation, use these Chinese equivalents of the certainty tags defined in `core/anti-hallucination.md`:
|
|
63
|
+
|
|
64
|
+
与 AI 助手协作时,使用以下中文确定性标签(对应 `core/anti-hallucination.md` 定义):
|
|
65
|
+
|
|
66
|
+
### Tag Mapping | 标签对照
|
|
67
|
+
|
|
68
|
+
| English Tag | 中文标签 | Usage | 使用时机 |
|
|
69
|
+
|-------------|---------|-------|----------|
|
|
70
|
+
| `[Confirmed]` | `[已确认]` | Direct evidence from code/docs | 直接来自代码/文档的证据 |
|
|
71
|
+
| `[Inferred]` | `[推断]` | Logical deduction from evidence | 基于现有证据的逻辑推断 |
|
|
72
|
+
| `[Assumption]` | `[假设]` | Based on common patterns | 基于常见模式(需验证)|
|
|
73
|
+
| `[Unknown]` | `[未知]` | Information not available | 信息不可得 |
|
|
74
|
+
| `[Need Confirmation]` | `[待确认]` | Requires user clarification | 需要用户澄清 |
|
|
75
|
+
|
|
76
|
+
### Usage Examples | 使用示例
|
|
77
|
+
|
|
78
|
+
**In Technical Documents | 技术文档中**:
|
|
79
|
+
```markdown
|
|
80
|
+
## 系统架构分析
|
|
81
|
+
|
|
82
|
+
`[已确认]` 系统使用 ASP.NET Core 8.0 框架 [Source: Code] Program.cs:1
|
|
83
|
+
`[已确认]` 数据库采用 SQL Server [Source: Code] appsettings.json:12
|
|
84
|
+
`[推断]` 基于 Repository Pattern 的使用,系统可能采用 DDD 架构
|
|
85
|
+
`[假设]` 缓存机制可能使用 Redis(需确认配置文件)
|
|
86
|
+
`[待确认]` 是否需要支持多租户架构?
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**In Design Documents | 设计文档中**:
|
|
90
|
+
```markdown
|
|
91
|
+
## 设计决策
|
|
92
|
+
|
|
93
|
+
### D1: 数据库选择
|
|
94
|
+
|
|
95
|
+
**决策**:使用 PostgreSQL
|
|
96
|
+
|
|
97
|
+
**理由**:
|
|
98
|
+
- `[已确认]` 团队已有 PostgreSQL 运维经验 (用户确认)
|
|
99
|
+
- `[已确认]` 现有授权可用 (用户确认)
|
|
100
|
+
- `[推断]` JSON 字段支持有助于灵活的数据存储
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**In Code Review | 代码审查中**:
|
|
104
|
+
```markdown
|
|
105
|
+
## 审查意见
|
|
106
|
+
|
|
107
|
+
`[已确认]` src/Services/AuthService.cs:45 - 密码验证缺少防暴力破解机制
|
|
108
|
+
`[推断]` 此处可能需要加入 Rate Limiting
|
|
109
|
+
`[待确认]` 是否已有其他层级的防护措施?
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Best Practices | 最佳实践
|
|
113
|
+
|
|
114
|
+
1. **Consistency | 一致性**
|
|
115
|
+
- 在同一份文档中使用同一种语言的标签(全用中文或全用英文)
|
|
116
|
+
- 团队应在 `CONTRIBUTING.md` 中明确选择使用的语言
|
|
117
|
+
|
|
118
|
+
2. **Source Citation | 来源引用**
|
|
119
|
+
- 中文标签同样需要附上来源引用
|
|
120
|
+
- 格式:`[已确认]` 陈述 [Source: Code] 文件路径:行号
|
|
121
|
+
|
|
122
|
+
3. **Team Agreement | 团队共识**
|
|
123
|
+
- 在项目开始时决定使用中文或英文标签
|
|
124
|
+
- 记录于 `CONTRIBUTING.md` 或 `.standards/` 目录
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Code Naming Conventions | 代码命名约定
|
|
129
|
+
|
|
130
|
+
### ✅ Correct Examples | 正确示例
|
|
131
|
+
|
|
132
|
+
```csharp
|
|
133
|
+
// Class names: English, PascalCase
|
|
134
|
+
public class UserAuthenticationService
|
|
135
|
+
{
|
|
136
|
+
// Private fields: English, _camelCase
|
|
137
|
+
private readonly IUserRepository _userRepository;
|
|
138
|
+
|
|
139
|
+
// Methods: English, PascalCase
|
|
140
|
+
/// <summary>
|
|
141
|
+
/// 验证用户登录凭证
|
|
142
|
+
/// </summary>
|
|
143
|
+
/// <param name="username">用户账号</param>
|
|
144
|
+
/// <param name="password">用户密码</param>
|
|
145
|
+
/// <returns>验证成功返回 JWT token,失败返回 null</returns>
|
|
146
|
+
public async Task<string?> AuthenticateAsync(string username, string password)
|
|
147
|
+
{
|
|
148
|
+
// 检查参数有效性
|
|
149
|
+
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
|
|
150
|
+
{
|
|
151
|
+
throw new ArgumentException("用户账号与密码不能为空");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 从数据库查询用户
|
|
155
|
+
var user = await _userRepository.GetByUsernameAsync(username);
|
|
156
|
+
|
|
157
|
+
// 验证密码
|
|
158
|
+
if (user == null || !VerifyPassword(user.PasswordHash, password))
|
|
159
|
+
{
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 生成 JWT token
|
|
164
|
+
return GenerateJwtToken(user);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Key Points | 重点**:
|
|
170
|
+
- ✅ Class name: `UserAuthenticationService` (English)
|
|
171
|
+
- ✅ Method name: `AuthenticateAsync` (English)
|
|
172
|
+
- ✅ Parameters: `username`, `password` (English)
|
|
173
|
+
- ✅ Variables: `user`, `passwordHash` (English)
|
|
174
|
+
- ✅ Comments: 简体中文
|
|
175
|
+
- ✅ XML documentation: 简体中文
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
### ❌ Incorrect Examples | 错误示例
|
|
180
|
+
|
|
181
|
+
```csharp
|
|
182
|
+
// ❌ WRONG: Using Chinese or Pinyin for code names
|
|
183
|
+
public class 用户认证服务 // ❌ Class name in Chinese
|
|
184
|
+
{
|
|
185
|
+
private readonly IUserRepository _yongHuCangKu; // ❌ Pinyin variable name
|
|
186
|
+
|
|
187
|
+
// ❌ Method name in Chinese
|
|
188
|
+
public async Task<string?> 认证用户Async(string yhm, string mm)
|
|
189
|
+
{
|
|
190
|
+
// ❌ Abbreviated Pinyin parameters (yhm = 用户名, mm = 密码)
|
|
191
|
+
var user = await _yongHuCangKu.GetByUsernameAsync(yhm);
|
|
192
|
+
return GenerateJwtToken(user);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Problems | 问题**:
|
|
198
|
+
- ❌ Chinese characters in class/method names break IDE features
|
|
199
|
+
- ❌ Pinyin is hard to understand for non-Chinese speakers
|
|
200
|
+
- ❌ Abbreviated pinyin (yhm, mm) is unclear even for Chinese speakers
|
|
201
|
+
- ❌ Inconsistent with global coding standards
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Documentation Language Guidelines | 文档语言准则
|
|
206
|
+
|
|
207
|
+
### README.md | 项目自述
|
|
208
|
+
|
|
209
|
+
**Use Simplified Chinese** for README.md in mainland China-based projects:
|
|
210
|
+
|
|
211
|
+
```markdown
|
|
212
|
+
# 项目名称 (YourProject)
|
|
213
|
+
|
|
214
|
+
## 项目简介
|
|
215
|
+
|
|
216
|
+
本项目是一个基于 ASP.NET Core 8.0 的 SMS/MMS 消息审核系统...
|
|
217
|
+
|
|
218
|
+
## 技术栈
|
|
219
|
+
|
|
220
|
+
- **.NET 8.0** - ASP.NET Core Web API
|
|
221
|
+
- **Quartz.NET** - 后台任务调度
|
|
222
|
+
- **SQL Server** - 主要数据库
|
|
223
|
+
|
|
224
|
+
## 构建与运行
|
|
225
|
+
|
|
226
|
+
### 构建项目
|
|
227
|
+
```bash
|
|
228
|
+
dotnet build
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 运行应用程序
|
|
232
|
+
```bash
|
|
233
|
+
dotnet run
|
|
234
|
+
```
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**For international projects**, consider bilingual README:
|
|
238
|
+
|
|
239
|
+
```markdown
|
|
240
|
+
# Message Review Center | 消息审核中心
|
|
241
|
+
|
|
242
|
+
[English](#english) | [简体中文](#简体中文)
|
|
243
|
+
|
|
244
|
+
## <a name="english"></a>English
|
|
245
|
+
|
|
246
|
+
This is an ASP.NET Core 8.0 SMS/MMS message review system...
|
|
247
|
+
|
|
248
|
+
## <a name="简体中文"></a>简体中文
|
|
249
|
+
|
|
250
|
+
本项目是一个基于 ASP.NET Core 8.0 的 SMS/MMS 消息审核系统...
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
### API Documentation | API 文档
|
|
256
|
+
|
|
257
|
+
**Use Simplified Chinese** for user-facing API documentation:
|
|
258
|
+
|
|
259
|
+
```markdown
|
|
260
|
+
## 用户认证 API
|
|
261
|
+
|
|
262
|
+
### POST /Auth/GoogleLogin
|
|
263
|
+
|
|
264
|
+
通过 Google OAuth2 登录并获取访问令牌。
|
|
265
|
+
|
|
266
|
+
#### 请求参数
|
|
267
|
+
|
|
268
|
+
| 参数名称 | 类型 | 必填 | 说明 |
|
|
269
|
+
|---------|------|------|------|
|
|
270
|
+
| `idToken` | string | 是 | Google ID Token |
|
|
271
|
+
|
|
272
|
+
#### 响应格式
|
|
273
|
+
|
|
274
|
+
```json
|
|
275
|
+
{
|
|
276
|
+
"accessToken": "eyJhbGc...",
|
|
277
|
+
"refreshToken": "dGhpc2...",
|
|
278
|
+
"expiresIn": 3600
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
#### 错误码
|
|
283
|
+
|
|
284
|
+
| 代码 | 说明 |
|
|
285
|
+
|------|------|
|
|
286
|
+
| 400 | 无效的 Google ID Token |
|
|
287
|
+
| 401 | 用户未授权 |
|
|
288
|
+
| 500 | 服务器内部错误 |
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
### Code Comments | 代码注释
|
|
294
|
+
|
|
295
|
+
**Use Simplified Chinese** for all code comments:
|
|
296
|
+
|
|
297
|
+
```csharp
|
|
298
|
+
/// <summary>
|
|
299
|
+
/// 用户服务类,处理用户相关业务逻辑
|
|
300
|
+
/// </summary>
|
|
301
|
+
public class UserService
|
|
302
|
+
{
|
|
303
|
+
/// <summary>
|
|
304
|
+
/// 根据用户 ID 获取用户数据
|
|
305
|
+
/// </summary>
|
|
306
|
+
/// <param name="userId">用户 ID</param>
|
|
307
|
+
/// <param name="cancellationToken">取消令牌</param>
|
|
308
|
+
/// <returns>用户数据,找不到则返回 null</returns>
|
|
309
|
+
/// <exception cref="ArgumentException">当 userId 小于等于 0 时抛出</exception>
|
|
310
|
+
public async Task<User?> GetUserByIdAsync(
|
|
311
|
+
int userId,
|
|
312
|
+
CancellationToken cancellationToken = default)
|
|
313
|
+
{
|
|
314
|
+
// 验证参数
|
|
315
|
+
if (userId <= 0)
|
|
316
|
+
{
|
|
317
|
+
throw new ArgumentException("用户 ID 必须大于 0", nameof(userId));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// 从缓存读取
|
|
321
|
+
var cachedUser = await _cache.GetAsync<User>($"user:{userId}");
|
|
322
|
+
if (cachedUser != null)
|
|
323
|
+
{
|
|
324
|
+
return cachedUser;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// 从数据库查询
|
|
328
|
+
var user = await _repository.GetByIdAsync(userId, cancellationToken);
|
|
329
|
+
|
|
330
|
+
// 写入缓存
|
|
331
|
+
if (user != null)
|
|
332
|
+
{
|
|
333
|
+
await _cache.SetAsync($"user:{userId}", user, TimeSpan.FromMinutes(10));
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return user;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Key Points | 重点**:
|
|
342
|
+
- ✅ XML documentation (/// <summary>) in Simplified Chinese
|
|
343
|
+
- ✅ Inline comments (// ...) in Simplified Chinese
|
|
344
|
+
- ✅ Parameter/exception descriptions in Simplified Chinese
|
|
345
|
+
- ✅ Code (class/method/variable names) in English
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Output Language | 产出语言
|
|
350
|
+
|
|
351
|
+
### Commit Types in Simplified Chinese | 简体中文 Commit 类型
|
|
352
|
+
|
|
353
|
+
Use Simplified Chinese types for mainland China-based teams:
|
|
354
|
+
|
|
355
|
+
| 简体中文类型 | 英文对应 | 说明 |
|
|
356
|
+
|------------|---------|------|
|
|
357
|
+
| `新增` | feat | 新功能 |
|
|
358
|
+
| `修复` | fix | Bug 修复 |
|
|
359
|
+
| `重构` | refactor | 代码重构 |
|
|
360
|
+
| `文档` | docs | 文档更新 |
|
|
361
|
+
| `测试` | test | 测试相关 |
|
|
362
|
+
| `样式` | style | 代码格式 |
|
|
363
|
+
| `性能` | perf | 性能优化 |
|
|
364
|
+
| `构建` | build | 构建系统 |
|
|
365
|
+
| `集成` | ci | CI/CD 变更 |
|
|
366
|
+
| `维护` | chore | 维护任务 |
|
|
367
|
+
| `回退` | revert | 回退提交 |
|
|
368
|
+
| `安全` | security | 安全漏洞修复 |
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
### Commit Message Examples | Commit 消息示例
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
新增(认证): 实现 OAuth2 Google 登录功能
|
|
376
|
+
|
|
377
|
+
- 新增 GoogleAuthService 处理 Google OAuth2 流程
|
|
378
|
+
- 集成 JWT token 生成逻辑
|
|
379
|
+
- 更新用户模型以支持外部账号 ID
|
|
380
|
+
|
|
381
|
+
技术细节:
|
|
382
|
+
- 使用 Google.Apis.Auth NuGet 包验证 ID Token
|
|
383
|
+
- Token 有效期设置为 1 小时
|
|
384
|
+
- Refresh token 有效期为 30 天
|
|
385
|
+
|
|
386
|
+
Closes #123
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
```
|
|
390
|
+
修复(API): 解决并发更新用户数据时的竞态条件
|
|
391
|
+
|
|
392
|
+
问题原因:
|
|
393
|
+
- 两个同时发出的 PUT /users/:id 请求会互相覆盖
|
|
394
|
+
- 缺少乐观锁或事务隔离机制
|
|
395
|
+
- 最后写入胜出,造成数据丢失
|
|
396
|
+
|
|
397
|
+
修复方式:
|
|
398
|
+
- 在 User 模型新增 version 字段
|
|
399
|
+
- 实现乐观锁检查
|
|
400
|
+
- 版本不一致时返回 409 Conflict
|
|
401
|
+
- 更新 API 文档说明重试机制
|
|
402
|
+
|
|
403
|
+
测试:
|
|
404
|
+
- 新增并发更新测试场景
|
|
405
|
+
- 压力测试验证 (100 个并发请求)
|
|
406
|
+
|
|
407
|
+
Fixes #456
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
```
|
|
411
|
+
重构(数据库): 提取连接池管理为独立模块
|
|
412
|
+
|
|
413
|
+
重构原因:
|
|
414
|
+
- 连接池逻辑分散在多个 Repository 中
|
|
415
|
+
- 难以统一调整连接池设置
|
|
416
|
+
- 无法集中监控连接状态
|
|
417
|
+
|
|
418
|
+
变更内容:
|
|
419
|
+
- 新增 DatabaseConnectionPool 类
|
|
420
|
+
- 集中管理所有数据库连接
|
|
421
|
+
- 提供连接状态监控接口
|
|
422
|
+
- 更新所有 Repository 使用新的连接池
|
|
423
|
+
|
|
424
|
+
影响范围:
|
|
425
|
+
- 所有 Repository 类已更新
|
|
426
|
+
- 单元测试已更新为使用 Mock ConnectionPool
|
|
427
|
+
- 无功能性变更,测试全部通过
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## Logging Language | 日志语言
|
|
433
|
+
|
|
434
|
+
**Use English for log messages** to ensure compatibility with international teams and log analysis tools:
|
|
435
|
+
|
|
436
|
+
```csharp
|
|
437
|
+
// ✅ CORRECT: English log messages
|
|
438
|
+
_logger.LogInformation("User {UserId} authenticated successfully", userId);
|
|
439
|
+
_logger.LogWarning("Failed login attempt for user {Username}", username);
|
|
440
|
+
_logger.LogError(ex, "Database connection failed for host {Host}", dbHost);
|
|
441
|
+
|
|
442
|
+
// ❌ WRONG: Chinese log messages
|
|
443
|
+
_logger.LogInformation("用户 {UserId} 认证成功", userId); // Harder to search/analyze
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
**Rationale | 理由**:
|
|
447
|
+
- ✅ Easier to search in log aggregation tools (Splunk, ELK, etc.)
|
|
448
|
+
- ✅ Compatible with international support teams
|
|
449
|
+
- ✅ Standardized error patterns for alerting
|
|
450
|
+
|
|
451
|
+
**Exception**: User-facing error messages can be Chinese:
|
|
452
|
+
|
|
453
|
+
```csharp
|
|
454
|
+
// User-facing error messages: Simplified Chinese
|
|
455
|
+
throw new ValidationException("用户账号格式不正确");
|
|
456
|
+
|
|
457
|
+
// But log the error in English
|
|
458
|
+
_logger.LogWarning("Invalid username format for input: {Input}", username);
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
## Configuration Files | 配置文件
|
|
464
|
+
|
|
465
|
+
### Configuration Keys: English | 配置键: 英文
|
|
466
|
+
|
|
467
|
+
```json
|
|
468
|
+
{
|
|
469
|
+
"ConnectionStrings": {
|
|
470
|
+
"DefaultConnection": "Server=localhost;Database=MyDb;..."
|
|
471
|
+
},
|
|
472
|
+
"JwtSettings": {
|
|
473
|
+
"Issuer": "YourProject",
|
|
474
|
+
"ExpirationMinutes": 60
|
|
475
|
+
},
|
|
476
|
+
"AppSettings": {
|
|
477
|
+
"MaxRetryCount": 3,
|
|
478
|
+
"TimeoutSeconds": 30
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
**Do NOT use Chinese keys**:
|
|
484
|
+
```json
|
|
485
|
+
{
|
|
486
|
+
"连接字符串": { // ❌ WRONG
|
|
487
|
+
"默认连接": "..."
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
### Configuration Comments: Simplified Chinese | 配置注释: 简体中文
|
|
493
|
+
|
|
494
|
+
```json
|
|
495
|
+
{
|
|
496
|
+
// JWT 相关配置
|
|
497
|
+
"JwtSettings": {
|
|
498
|
+
// JWT 签发者名称
|
|
499
|
+
"Issuer": "YourProject",
|
|
500
|
+
// Token 有效期限(分钟)
|
|
501
|
+
"ExpirationMinutes": 60,
|
|
502
|
+
// 签名密钥路径
|
|
503
|
+
"PrivateKeyPath": "keys/es256key.pem"
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
Or use separate documentation:
|
|
509
|
+
|
|
510
|
+
```markdown
|
|
511
|
+
## 配置文件说明 (appsettings.json)
|
|
512
|
+
|
|
513
|
+
### JwtSettings
|
|
514
|
+
|
|
515
|
+
| 配置键 | 类型 | 说明 | 默认值 |
|
|
516
|
+
|--------|------|------|--------|
|
|
517
|
+
| `Issuer` | string | JWT 签发者名称 | YourProject |
|
|
518
|
+
| `ExpirationMinutes` | int | Token 有效期限(分钟)| 60 |
|
|
519
|
+
| `PrivateKeyPath` | string | ECDSA 私钥文件路径 | keys/es256key.pem |
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
## Error Messages | 错误消息
|
|
525
|
+
|
|
526
|
+
### System Errors: English | 系统错误: 英文
|
|
527
|
+
|
|
528
|
+
```csharp
|
|
529
|
+
// ✅ Internal errors, exceptions: English
|
|
530
|
+
throw new InvalidOperationException("Cannot process payment in pending state");
|
|
531
|
+
throw new ArgumentNullException(nameof(userId), "User ID cannot be null");
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### User-Facing Errors: Simplified Chinese | 用户错误: 简体中文
|
|
535
|
+
|
|
536
|
+
```csharp
|
|
537
|
+
// ✅ User-facing error messages: Simplified Chinese
|
|
538
|
+
public class ErrorResponse
|
|
539
|
+
{
|
|
540
|
+
public string Code { get; set; } // "INVALID_CREDENTIALS"
|
|
541
|
+
public string Message { get; set; } // "用户账号或密码错误"
|
|
542
|
+
public string Details { get; set; } // "请确认账号与密码后重试"
|
|
543
|
+
}
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
**API Error Response Example**:
|
|
547
|
+
```json
|
|
548
|
+
{
|
|
549
|
+
"error": {
|
|
550
|
+
"code": "INVALID_CREDENTIALS",
|
|
551
|
+
"message": "用户账号或密码错误",
|
|
552
|
+
"details": "请确认您的账号与密码是否正确,密码区分大小写"
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
## Testing Documentation | 测试文档
|
|
560
|
+
|
|
561
|
+
### Test Method Names: English | 测试方法名称: 英文
|
|
562
|
+
|
|
563
|
+
```csharp
|
|
564
|
+
// ✅ CORRECT: English test method names
|
|
565
|
+
[Fact]
|
|
566
|
+
public async Task AuthenticateAsync_WithValidCredentials_ReturnsToken()
|
|
567
|
+
{
|
|
568
|
+
// Arrange
|
|
569
|
+
var service = new AuthenticationService(_mockRepository.Object);
|
|
570
|
+
|
|
571
|
+
// Act
|
|
572
|
+
var token = await service.AuthenticateAsync("testuser", "password123");
|
|
573
|
+
|
|
574
|
+
// Assert
|
|
575
|
+
Assert.NotNull(token);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// ❌ WRONG: Chinese test method names
|
|
579
|
+
[Fact]
|
|
580
|
+
public async Task 验证_使用有效凭证_返回Token() // ❌
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
### Test Comments: Simplified Chinese | 测试注释: 简体中文
|
|
584
|
+
|
|
585
|
+
```csharp
|
|
586
|
+
[Fact]
|
|
587
|
+
public async Task AuthenticateAsync_WithInvalidPassword_ReturnsNull()
|
|
588
|
+
{
|
|
589
|
+
// Arrange - 准备测试数据
|
|
590
|
+
var mockRepo = new Mock<IUserRepository>();
|
|
591
|
+
mockRepo.Setup(r => r.GetByUsernameAsync("testuser"))
|
|
592
|
+
.ReturnsAsync(new User { PasswordHash = "hashed_password" });
|
|
593
|
+
|
|
594
|
+
var service = new AuthenticationService(mockRepo.Object);
|
|
595
|
+
|
|
596
|
+
// Act - 执行测试
|
|
597
|
+
var result = await service.AuthenticateAsync("testuser", "wrong_password");
|
|
598
|
+
|
|
599
|
+
// Assert - 验证结果
|
|
600
|
+
Assert.Null(result); // 密码错误应返回 null
|
|
601
|
+
}
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
---
|
|
605
|
+
|
|
606
|
+
## Typography Standards | 排版标准
|
|
607
|
+
|
|
608
|
+
### Chinese-English Mixed Text | 中英混合文字
|
|
609
|
+
|
|
610
|
+
**Add spaces between Chinese and English**:
|
|
611
|
+
|
|
612
|
+
```markdown
|
|
613
|
+
✅ CORRECT:
|
|
614
|
+
本项目使用 ASP.NET Core 8.0 开发,采用 Clean Architecture 设计模式。
|
|
615
|
+
|
|
616
|
+
❌ WRONG:
|
|
617
|
+
本项目使用ASP.NET Core 8.0开发,采用Clean Architecture设计模式。
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
### Punctuation | 标点符号
|
|
621
|
+
|
|
622
|
+
**Use Chinese punctuation in Chinese text**:
|
|
623
|
+
|
|
624
|
+
```markdown
|
|
625
|
+
✅ CORRECT:
|
|
626
|
+
项目包含:认证模块、API 层、数据库层。
|
|
627
|
+
|
|
628
|
+
❌ WRONG:
|
|
629
|
+
项目包含:认证模块,API层,数据库层.
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
**Use English punctuation in code and English text**:
|
|
633
|
+
|
|
634
|
+
```csharp
|
|
635
|
+
// ✅ CORRECT: English punctuation in comments
|
|
636
|
+
// This method validates user credentials, checks permissions, and generates JWT token.
|
|
637
|
+
|
|
638
|
+
// ❌ WRONG: Chinese punctuation in English comments
|
|
639
|
+
// This method validates user credentials,checks permissions,and generates JWT token。
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
### Numbers | 数字
|
|
643
|
+
|
|
644
|
+
**Use Arabic numerals**:
|
|
645
|
+
|
|
646
|
+
```markdown
|
|
647
|
+
✅ CORRECT:
|
|
648
|
+
项目包含 15 个 API 端点、8 个数据模型、120 个单元测试。
|
|
649
|
+
|
|
650
|
+
❌ WRONG:
|
|
651
|
+
项目包含十五个 API 端点、八个数据模型、一百二十个单元测试。
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
---
|
|
655
|
+
|
|
656
|
+
## Terminology Consistency | 术语一致性
|
|
657
|
+
|
|
658
|
+
Maintain a **terminology glossary** for consistent Chinese translations:
|
|
659
|
+
|
|
660
|
+
### Common Software Terms | 常见软件术语
|
|
661
|
+
|
|
662
|
+
| English | 简体中文 | Notes |
|
|
663
|
+
|---------|---------|-------|
|
|
664
|
+
| Authentication | 认证 | Use one term throughout; do not mix with "身份验证" |
|
|
665
|
+
| Authorization | 授权 | |
|
|
666
|
+
| Repository | 仓储 | In code pattern context; a Git repository is "仓库" |
|
|
667
|
+
| Service | 服务 | |
|
|
668
|
+
| Controller | 控制器 | |
|
|
669
|
+
| Middleware | 中间件 | |
|
|
670
|
+
| Dependency Injection | 依赖注入 | |
|
|
671
|
+
| Unit Test | 单元测试 | |
|
|
672
|
+
| Integration Test | 集成测试 | |
|
|
673
|
+
| Code Review | 代码审查 | |
|
|
674
|
+
| Pull Request | Pull Request | Keep English term |
|
|
675
|
+
| Commit | Commit | Keep English term, or "提交" |
|
|
676
|
+
| Branch | 分支 | |
|
|
677
|
+
| Merge | 合并 | |
|
|
678
|
+
| Refactor | 重构 | |
|
|
679
|
+
| Bug | Bug | Keep English term or "错误" |
|
|
680
|
+
| Feature | 功能 | |
|
|
681
|
+
| Performance | 性能 | NOT "效能" |
|
|
682
|
+
| Database | 数据库 | |
|
|
683
|
+
| Cache | 缓存 | |
|
|
684
|
+
| API | API | Keep English |
|
|
685
|
+
| SDK | SDK | Keep English |
|
|
686
|
+
| Framework | 框架 | |
|
|
687
|
+
| Changelog | 变更日志 | |
|
|
688
|
+
| Release Notes | 发布说明 | |
|
|
689
|
+
| Breaking Change | 破坏性变更 | |
|
|
690
|
+
| Deprecate | 弃用 | |
|
|
691
|
+
| Semantic Versioning | 语义化版本 | |
|
|
692
|
+
|
|
693
|
+
**Project-Specific Customization**: Create `docs/terminology.md` for your project.
|
|
694
|
+
|
|
695
|
+
---
|
|
696
|
+
|
|
697
|
+
## Version History | 版本历史
|
|
698
|
+
|
|
699
|
+
| Version | Date | Changes |
|
|
700
|
+
|---------|------|--------|
|
|
701
|
+
| 1.0.0 | 2026-10-05 | Initial Simplified Chinese standard, derived from zh-tw.md v1.2.0 with mainland terminology (the zh-CN locale was declared by the installer but the file was missing, so `uds init --locale zh-cn` failed) 首个简体中文规范,由 zh-tw.md v1.2.0 改写并采用大陆通行术语(安装程序已声明 zh-CN 语系但缺少此文件,导致 `uds init --locale zh-cn` 失败) |
|
|
702
|
+
|
|
703
|
+
---
|
|
704
|
+
|
|
705
|
+
## References | 参考资料
|
|
706
|
+
|
|
707
|
+
- [Chinese Copywriting Guidelines](https://github.com/sparanoid/chinese-copywriting-guidelines)
|
|
708
|
+
- [中文技术文档写作规范](https://github.com/yikeke/zh-style-guide)
|
|
709
|
+
- [Anti-Hallucination Standards](../../core/anti-hallucination.md)
|
|
710
|
+
|
|
711
|
+
---
|
|
712
|
+
|
|
713
|
+
## License | 授权
|
|
714
|
+
|
|
715
|
+
This standard is released under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
|
|
716
|
+
|
|
717
|
+
本标准以 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 授权发布。
|