universal-dev-standards 6.14.0-beta.2 → 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/open-work-tracking.ai.yaml +4 -1
- package/bundled/ai/standards/pipeline-security-gates.ai.yaml +5 -1
- package/bundled/core/ai-response-navigation.md +128 -12
- package/bundled/core/open-work-tracking.md +1 -1
- 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 +44 -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 +44 -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/core/open-work-tracking.md +3 -3
- 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/check.js +9 -0
- package/src/commands/init.js +100 -27
- package/src/commands/uninstall.js +144 -30
- package/src/commands/update.js +62 -3
- package/src/core/install-records.js +191 -0
- package/src/i18n/messages.js +39 -6
- package/src/installers/hooks-installer.js +61 -30
- package/src/installers/integration-installer.js +5 -1
- package/src/installers/standards-installer.js +16 -23
- package/src/reconciler/plan-executor.js +10 -11
- package/src/uninstallers/hook-uninstaller.js +219 -33
- package/src/uninstallers/integration-uninstaller.js +35 -5
- package/src/utils/copier.js +57 -0
- package/src/utils/git-hooks.js +139 -7
- package/src/utils/hasher.js +36 -0
- package/src/utils/integration-generator.js +16 -6
- package/src/utils/legacy-hook-migration.js +112 -0
- package/src/utils/locale.js +19 -0
- package/src/utils/open-work-tracking.mjs +124 -23
- package/standards-registry.json +21 -7
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
# Traditional Chinese (Taiwan) Locale Standard
|
|
2
|
+
# 繁體中文(台灣)地區規範
|
|
3
|
+
|
|
4
|
+
**Version**: 1.2.0
|
|
5
|
+
**Last Updated**: 2025-12-12
|
|
6
|
+
**Applicability**: Projects with Traditional Chinese documentation or Taiwanese teams
|
|
7
|
+
**適用範圍**: 使用繁體中文文件或台灣團隊的專案
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Purpose | 目的
|
|
12
|
+
|
|
13
|
+
This standard defines language usage guidelines for projects with Traditional Chinese documentation, ensuring consistency between Chinese content and English code.
|
|
14
|
+
|
|
15
|
+
本標準定義使用繁體中文文件的專案語言使用準則,確保中文內容與英文程式碼之間的一致性。
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Core Principle | 核心原則
|
|
20
|
+
|
|
21
|
+
**Chinese for Communication, English for Code**
|
|
22
|
+
**中文用於溝通,英文用於程式碼**
|
|
23
|
+
|
|
24
|
+
- ✅ Documentation, comments, and commit messages: Traditional Chinese
|
|
25
|
+
- ✅ Code (variables, functions, classes): English
|
|
26
|
+
- ✅ Log messages: English (for international teams and tooling compatibility)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Language Usage Matrix | 語言使用矩陣
|
|
31
|
+
|
|
32
|
+
| Content Type | Language | Rationale | 範例 |
|
|
33
|
+
|--------------|----------|-----------|------|
|
|
34
|
+
| **Code** |
|
|
35
|
+
| Variable names | English | Universal readability | `userName` ✅<br>`使用者名稱` ❌ |
|
|
36
|
+
| Function names | English | Universal readability | `authenticateUser()` ✅<br>`認證使用者()` ❌ |
|
|
37
|
+
| Class names | English | Universal readability | `UserService` ✅<br>`使用者服務` ❌ |
|
|
38
|
+
| **Documentation** |
|
|
39
|
+
| README.md | 繁體中文 | Team communication | ✅ |
|
|
40
|
+
| API documentation | 繁體中文 | User-facing docs | ✅ |
|
|
41
|
+
| Architecture docs | 繁體中文 | Design communication | ✅ |
|
|
42
|
+
| **Code Comments** |
|
|
43
|
+
| Inline comments | 繁體中文 | Explain intent to team | `// 驗證使用者權限` ✅ |
|
|
44
|
+
| Doc comments | 繁體中文 | API documentation | `/// <summary>驗證使用者</summary>` ✅ |
|
|
45
|
+
| **Commit Messages** |
|
|
46
|
+
| Type | 繁體中文 | Team preference | `新增`, `修正`, `重構` ✅ |
|
|
47
|
+
| Subject | 繁體中文 | Clear communication | `實作 OAuth2 登入` ✅ |
|
|
48
|
+
| Body | 繁體中文 | Detailed explanation | ✅ |
|
|
49
|
+
| **Logging** |
|
|
50
|
+
| Log messages | English | Tool compatibility | `logger.info("User authenticated")` ✅ |
|
|
51
|
+
| Error messages | English | Searchability | `throw new Error("Invalid credentials")` ✅ |
|
|
52
|
+
| **Configuration** |
|
|
53
|
+
| Config keys | English | Standard practice | `maxRetryCount` ✅ |
|
|
54
|
+
| Config comments | 繁體中文 | Explain to team | `# 最大重試次數` ✅ |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Certainty Tags (Chinese) | 確定性標籤(中文)
|
|
59
|
+
|
|
60
|
+
When using AI assistants with Traditional Chinese documentation, use these Chinese equivalents of the certainty tags defined in `core/anti-hallucination.md`:
|
|
61
|
+
|
|
62
|
+
與 AI 助手協作時,使用以下中文確定性標籤(對應 `core/anti-hallucination.md` 定義):
|
|
63
|
+
|
|
64
|
+
### Tag Mapping | 標籤對照
|
|
65
|
+
|
|
66
|
+
| English Tag | 中文標籤 | Usage | 使用時機 |
|
|
67
|
+
|-------------|---------|-------|----------|
|
|
68
|
+
| `[Confirmed]` | `[已確認]` | Direct evidence from code/docs | 直接來自程式碼/文件的證據 |
|
|
69
|
+
| `[Inferred]` | `[推論]` | Logical deduction from evidence | 基於現有證據的邏輯推論 |
|
|
70
|
+
| `[Assumption]` | `[假設]` | Based on common patterns | 基於常見模式(需驗證)|
|
|
71
|
+
| `[Unknown]` | `[未知]` | Information not available | 資訊不可得 |
|
|
72
|
+
| `[Need Confirmation]` | `[待確認]` | Requires user clarification | 需要使用者澄清 |
|
|
73
|
+
|
|
74
|
+
### Usage Examples | 使用範例
|
|
75
|
+
|
|
76
|
+
**In Technical Documents | 技術文件中**:
|
|
77
|
+
```markdown
|
|
78
|
+
## 系統架構分析
|
|
79
|
+
|
|
80
|
+
`[已確認]` 系統使用 ASP.NET Core 8.0 框架 [Source: Code] Program.cs:1
|
|
81
|
+
`[已確認]` 資料庫採用 SQL Server [Source: Code] appsettings.json:12
|
|
82
|
+
`[推論]` 基於 Repository Pattern 的使用,系統可能採用 DDD 架構
|
|
83
|
+
`[假設]` 快取機制可能使用 Redis(需確認設定檔)
|
|
84
|
+
`[待確認]` 是否需要支援多租戶架構?
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**In Design Documents | 設計文件中**:
|
|
88
|
+
```markdown
|
|
89
|
+
## 設計決策
|
|
90
|
+
|
|
91
|
+
### D1: 資料庫選擇
|
|
92
|
+
|
|
93
|
+
**決策**:使用 PostgreSQL
|
|
94
|
+
|
|
95
|
+
**理由**:
|
|
96
|
+
- `[已確認]` 團隊已有 PostgreSQL 維運經驗 (使用者確認)
|
|
97
|
+
- `[已確認]` 現有授權可用 (使用者確認)
|
|
98
|
+
- `[推論]` JSON 欄位支援有助於彈性資料儲存
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**In Code Review | 程式碼審查中**:
|
|
102
|
+
```markdown
|
|
103
|
+
## 審查意見
|
|
104
|
+
|
|
105
|
+
`[已確認]` src/Services/AuthService.cs:45 - 密碼驗證缺少防暴力破解機制
|
|
106
|
+
`[推論]` 此處可能需要加入 Rate Limiting
|
|
107
|
+
`[待確認]` 是否已有其他層級的防護措施?
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Best Practices | 最佳實踐
|
|
111
|
+
|
|
112
|
+
1. **Consistency | 一致性**
|
|
113
|
+
- 在同一份文件中使用同一語言的標籤(全用中文或全用英文)
|
|
114
|
+
- 團隊應在 `CONTRIBUTING.md` 中明確選擇使用的語言
|
|
115
|
+
|
|
116
|
+
2. **Source Citation | 來源引用**
|
|
117
|
+
- 中文標籤同樣需要附上來源引用
|
|
118
|
+
- 格式:`[已確認]` 陳述 [Source: Code] 檔案路徑:行號
|
|
119
|
+
|
|
120
|
+
3. **Team Agreement | 團隊共識**
|
|
121
|
+
- 在專案開始時決定使用中文或英文標籤
|
|
122
|
+
- 記錄於 `CONTRIBUTING.md` 或 `.standards/` 目錄
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Code Naming Conventions | 程式碼命名慣例
|
|
127
|
+
|
|
128
|
+
### ✅ Correct Examples | 正確範例
|
|
129
|
+
|
|
130
|
+
```csharp
|
|
131
|
+
// Class names: English, PascalCase
|
|
132
|
+
public class UserAuthenticationService
|
|
133
|
+
{
|
|
134
|
+
// Private fields: English, _camelCase
|
|
135
|
+
private readonly IUserRepository _userRepository;
|
|
136
|
+
|
|
137
|
+
// Methods: English, PascalCase
|
|
138
|
+
/// <summary>
|
|
139
|
+
/// 驗證使用者登入憑證
|
|
140
|
+
/// </summary>
|
|
141
|
+
/// <param name="username">使用者帳號</param>
|
|
142
|
+
/// <param name="password">使用者密碼</param>
|
|
143
|
+
/// <returns>驗證成功返回 JWT token,失敗返回 null</returns>
|
|
144
|
+
public async Task<string?> AuthenticateAsync(string username, string password)
|
|
145
|
+
{
|
|
146
|
+
// 檢查參數有效性
|
|
147
|
+
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
|
|
148
|
+
{
|
|
149
|
+
throw new ArgumentException("使用者帳號與密碼不可為空");
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 從資料庫查詢使用者
|
|
153
|
+
var user = await _userRepository.GetByUsernameAsync(username);
|
|
154
|
+
|
|
155
|
+
// 驗證密碼
|
|
156
|
+
if (user == null || !VerifyPassword(user.PasswordHash, password))
|
|
157
|
+
{
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 產生 JWT token
|
|
162
|
+
return GenerateJwtToken(user);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Key Points | 重點**:
|
|
168
|
+
- ✅ Class name: `UserAuthenticationService` (English)
|
|
169
|
+
- ✅ Method name: `AuthenticateAsync` (English)
|
|
170
|
+
- ✅ Parameters: `username`, `password` (English)
|
|
171
|
+
- ✅ Variables: `user`, `passwordHash` (English)
|
|
172
|
+
- ✅ Comments: 繁體中文
|
|
173
|
+
- ✅ XML documentation: 繁體中文
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
### ❌ Incorrect Examples | 錯誤範例
|
|
178
|
+
|
|
179
|
+
```csharp
|
|
180
|
+
// ❌ WRONG: Using Chinese or Pinyin for code names
|
|
181
|
+
public class 使用者認證服務 // ❌ Class name in Chinese
|
|
182
|
+
{
|
|
183
|
+
private readonly IUserRepository _yongHuCangKu; // ❌ Pinyin variable name
|
|
184
|
+
|
|
185
|
+
// ❌ Method name in Chinese
|
|
186
|
+
public async Task<string?> 認證使用者Async(string yhm, string mm)
|
|
187
|
+
{
|
|
188
|
+
// ❌ Abbreviated Pinyin parameters (yhm = 用戶名, mm = 密碼)
|
|
189
|
+
var user = await _yongHuCangKu.GetByUsernameAsync(yhm);
|
|
190
|
+
return GenerateJwtToken(user);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Problems | 問題**:
|
|
196
|
+
- ❌ Chinese characters in class/method names break IDE features
|
|
197
|
+
- ❌ Pinyin is hard to understand for non-Chinese speakers
|
|
198
|
+
- ❌ Abbreviated pinyin (yhm, mm) is unclear even for Chinese speakers
|
|
199
|
+
- ❌ Inconsistent with global coding standards
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Documentation Language Guidelines | 文件語言準則
|
|
204
|
+
|
|
205
|
+
### README.md | 專案自述
|
|
206
|
+
|
|
207
|
+
**Use Traditional Chinese** for README.md in Taiwan-based projects:
|
|
208
|
+
|
|
209
|
+
```markdown
|
|
210
|
+
# 專案名稱 (YourProject)
|
|
211
|
+
|
|
212
|
+
## 專案簡介
|
|
213
|
+
|
|
214
|
+
本專案是一個基於 ASP.NET Core 8.0 的 SMS/MMS 訊息審核系統...
|
|
215
|
+
|
|
216
|
+
## 技術棧
|
|
217
|
+
|
|
218
|
+
- **.NET 8.0** - ASP.NET Core Web API
|
|
219
|
+
- **Quartz.NET** - 背景工作排程
|
|
220
|
+
- **SQL Server** - 主要資料庫
|
|
221
|
+
|
|
222
|
+
## 建置與執行
|
|
223
|
+
|
|
224
|
+
### 建置專案
|
|
225
|
+
```bash
|
|
226
|
+
dotnet build
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### 執行應用程式
|
|
230
|
+
```bash
|
|
231
|
+
dotnet run
|
|
232
|
+
```
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**For international projects**, consider bilingual README:
|
|
236
|
+
|
|
237
|
+
```markdown
|
|
238
|
+
# Message Review Center | 訊息審核中心
|
|
239
|
+
|
|
240
|
+
[English](#english) | [繁體中文](#繁體中文)
|
|
241
|
+
|
|
242
|
+
## <a name="english"></a>English
|
|
243
|
+
|
|
244
|
+
This is an ASP.NET Core 8.0 SMS/MMS message review system...
|
|
245
|
+
|
|
246
|
+
## <a name="繁體中文"></a>繁體中文
|
|
247
|
+
|
|
248
|
+
本專案是一個基於 ASP.NET Core 8.0 的 SMS/MMS 訊息審核系統...
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### API Documentation | API 文件
|
|
254
|
+
|
|
255
|
+
**Use Traditional Chinese** for user-facing API documentation:
|
|
256
|
+
|
|
257
|
+
```markdown
|
|
258
|
+
## 使用者認證 API
|
|
259
|
+
|
|
260
|
+
### POST /Auth/GoogleLogin
|
|
261
|
+
|
|
262
|
+
透過 Google OAuth2 登入並取得存取令牌。
|
|
263
|
+
|
|
264
|
+
#### 請求參數
|
|
265
|
+
|
|
266
|
+
| 參數名稱 | 類型 | 必填 | 說明 |
|
|
267
|
+
|---------|------|------|------|
|
|
268
|
+
| `idToken` | string | 是 | Google ID Token |
|
|
269
|
+
|
|
270
|
+
#### 回應格式
|
|
271
|
+
|
|
272
|
+
```json
|
|
273
|
+
{
|
|
274
|
+
"accessToken": "eyJhbGc...",
|
|
275
|
+
"refreshToken": "dGhpc2...",
|
|
276
|
+
"expiresIn": 3600
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
#### 錯誤代碼
|
|
281
|
+
|
|
282
|
+
| 代碼 | 說明 |
|
|
283
|
+
|------|------|
|
|
284
|
+
| 400 | 無效的 Google ID Token |
|
|
285
|
+
| 401 | 使用者未授權 |
|
|
286
|
+
| 500 | 伺服器內部錯誤 |
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
### Code Comments | 程式碼註解
|
|
292
|
+
|
|
293
|
+
**Use Traditional Chinese** for all code comments:
|
|
294
|
+
|
|
295
|
+
```csharp
|
|
296
|
+
/// <summary>
|
|
297
|
+
/// 使用者服務類別,處理使用者相關業務邏輯
|
|
298
|
+
/// </summary>
|
|
299
|
+
public class UserService
|
|
300
|
+
{
|
|
301
|
+
/// <summary>
|
|
302
|
+
/// 根據使用者 ID 取得使用者資料
|
|
303
|
+
/// </summary>
|
|
304
|
+
/// <param name="userId">使用者 ID</param>
|
|
305
|
+
/// <param name="cancellationToken">取消令牌</param>
|
|
306
|
+
/// <returns>使用者資料,找不到則返回 null</returns>
|
|
307
|
+
/// <exception cref="ArgumentException">當 userId 小於等於 0 時拋出</exception>
|
|
308
|
+
public async Task<User?> GetUserByIdAsync(
|
|
309
|
+
int userId,
|
|
310
|
+
CancellationToken cancellationToken = default)
|
|
311
|
+
{
|
|
312
|
+
// 驗證參數
|
|
313
|
+
if (userId <= 0)
|
|
314
|
+
{
|
|
315
|
+
throw new ArgumentException("使用者 ID 必須大於 0", nameof(userId));
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// 從快取讀取
|
|
319
|
+
var cachedUser = await _cache.GetAsync<User>($"user:{userId}");
|
|
320
|
+
if (cachedUser != null)
|
|
321
|
+
{
|
|
322
|
+
return cachedUser;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// 從資料庫查詢
|
|
326
|
+
var user = await _repository.GetByIdAsync(userId, cancellationToken);
|
|
327
|
+
|
|
328
|
+
// 寫入快取
|
|
329
|
+
if (user != null)
|
|
330
|
+
{
|
|
331
|
+
await _cache.SetAsync($"user:{userId}", user, TimeSpan.FromMinutes(10));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return user;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**Key Points | 重點**:
|
|
340
|
+
- ✅ XML documentation (/// <summary>) in Traditional Chinese
|
|
341
|
+
- ✅ Inline comments (// ...) in Traditional Chinese
|
|
342
|
+
- ✅ Parameter/exception descriptions in Traditional Chinese
|
|
343
|
+
- ✅ Code (class/method/variable names) in English
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
## Output Language | 產出語言
|
|
348
|
+
|
|
349
|
+
### Commit Types in Traditional Chinese | 繁體中文 Commit 類型
|
|
350
|
+
|
|
351
|
+
Use Traditional Chinese types for Taiwan-based teams:
|
|
352
|
+
|
|
353
|
+
| 繁體中文類型 | 英文對應 | 說明 |
|
|
354
|
+
|------------|---------|------|
|
|
355
|
+
| `新增` | feat | 新功能 |
|
|
356
|
+
| `修正` | fix | Bug 修復 |
|
|
357
|
+
| `重構` | refactor | 程式碼重構 |
|
|
358
|
+
| `文件` | docs | 文件更新 |
|
|
359
|
+
| `測試` | test | 測試相關 |
|
|
360
|
+
| `樣式` | style | 程式碼格式 |
|
|
361
|
+
| `效能` | perf | 效能優化 |
|
|
362
|
+
| `建置` | build | 建置系統 |
|
|
363
|
+
| `整合` | ci | CI/CD 變更 |
|
|
364
|
+
| `維護` | chore | 維護任務 |
|
|
365
|
+
| `回退` | revert | 回退提交 |
|
|
366
|
+
| `安全` | security | 安全漏洞修復 |
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
### Commit Message Examples | Commit 訊息範例
|
|
371
|
+
|
|
372
|
+
```
|
|
373
|
+
新增(認證): 實作 OAuth2 Google 登入功能
|
|
374
|
+
|
|
375
|
+
- 新增 GoogleAuthService 處理 Google OAuth2 流程
|
|
376
|
+
- 整合 JWT token 產生邏輯
|
|
377
|
+
- 更新使用者模型支援外部帳號 ID
|
|
378
|
+
|
|
379
|
+
技術細節:
|
|
380
|
+
- 使用 Google.Apis.Auth NuGet 套件驗證 ID Token
|
|
381
|
+
- Token 有效期設定為 1 小時
|
|
382
|
+
- Refresh token 有效期為 30 天
|
|
383
|
+
|
|
384
|
+
Closes #123
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
```
|
|
388
|
+
修正(API): 解決並發更新使用者資料時的競爭條件
|
|
389
|
+
|
|
390
|
+
問題原因:
|
|
391
|
+
- 兩個同時發出的 PUT /users/:id 請求會互相覆蓋
|
|
392
|
+
- 缺少樂觀鎖定或交易隔離機制
|
|
393
|
+
- 最後寫入勝出,造成資料遺失
|
|
394
|
+
|
|
395
|
+
修正方式:
|
|
396
|
+
- 在 User 模型新增 version 欄位
|
|
397
|
+
- 實作樂觀鎖定檢查
|
|
398
|
+
- 版本不符時返回 409 Conflict
|
|
399
|
+
- 更新 API 文件說明重試機制
|
|
400
|
+
|
|
401
|
+
測試:
|
|
402
|
+
- 新增並發更新測試場景
|
|
403
|
+
- 負載測試驗證 (100 個並發請求)
|
|
404
|
+
|
|
405
|
+
Fixes #456
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
```
|
|
409
|
+
重構(資料庫): 提取連線池管理為獨立模組
|
|
410
|
+
|
|
411
|
+
重構原因:
|
|
412
|
+
- 連線池邏輯散落在多個 Repository 中
|
|
413
|
+
- 難以統一調整連線池設定
|
|
414
|
+
- 無法集中監控連線狀態
|
|
415
|
+
|
|
416
|
+
變更內容:
|
|
417
|
+
- 新增 DatabaseConnectionPool 類別
|
|
418
|
+
- 集中管理所有資料庫連線
|
|
419
|
+
- 提供連線狀態監控介面
|
|
420
|
+
- 更新所有 Repository 使用新的連線池
|
|
421
|
+
|
|
422
|
+
影響範圍:
|
|
423
|
+
- 所有 Repository 類別已更新
|
|
424
|
+
- 單元測試已更新使用 Mock ConnectionPool
|
|
425
|
+
- 無功能性變更,測試全數通過
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
## Logging Language | 日誌語言
|
|
431
|
+
|
|
432
|
+
**Use English for log messages** to ensure compatibility with international teams and log analysis tools:
|
|
433
|
+
|
|
434
|
+
```csharp
|
|
435
|
+
// ✅ CORRECT: English log messages
|
|
436
|
+
_logger.LogInformation("User {UserId} authenticated successfully", userId);
|
|
437
|
+
_logger.LogWarning("Failed login attempt for user {Username}", username);
|
|
438
|
+
_logger.LogError(ex, "Database connection failed for host {Host}", dbHost);
|
|
439
|
+
|
|
440
|
+
// ❌ WRONG: Chinese log messages
|
|
441
|
+
_logger.LogInformation("使用者 {UserId} 認證成功", userId); // Harder to search/analyze
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
**Rationale | 理由**:
|
|
445
|
+
- ✅ Easier to search in log aggregation tools (Splunk, ELK, etc.)
|
|
446
|
+
- ✅ Compatible with international support teams
|
|
447
|
+
- ✅ Standardized error patterns for alerting
|
|
448
|
+
|
|
449
|
+
**Exception**: User-facing error messages can be Chinese:
|
|
450
|
+
|
|
451
|
+
```csharp
|
|
452
|
+
// User-facing error messages: Traditional Chinese
|
|
453
|
+
throw new ValidationException("使用者帳號格式不正確");
|
|
454
|
+
|
|
455
|
+
// But log the error in English
|
|
456
|
+
_logger.LogWarning("Invalid username format for input: {Input}", username);
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
---
|
|
460
|
+
|
|
461
|
+
## Configuration Files | 設定檔
|
|
462
|
+
|
|
463
|
+
### Configuration Keys: English | 設定鍵: 英文
|
|
464
|
+
|
|
465
|
+
```json
|
|
466
|
+
{
|
|
467
|
+
"ConnectionStrings": {
|
|
468
|
+
"DefaultConnection": "Server=localhost;Database=MyDb;..."
|
|
469
|
+
},
|
|
470
|
+
"JwtSettings": {
|
|
471
|
+
"Issuer": "YourProject",
|
|
472
|
+
"ExpirationMinutes": 60
|
|
473
|
+
},
|
|
474
|
+
"AppSettings": {
|
|
475
|
+
"MaxRetryCount": 3,
|
|
476
|
+
"TimeoutSeconds": 30
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
**Do NOT use Chinese keys**:
|
|
482
|
+
```json
|
|
483
|
+
{
|
|
484
|
+
"連線字串": { // ❌ WRONG
|
|
485
|
+
"預設連線": "..."
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Configuration Comments: Traditional Chinese | 設定註解: 繁體中文
|
|
491
|
+
|
|
492
|
+
```json
|
|
493
|
+
{
|
|
494
|
+
// JWT 相關設定
|
|
495
|
+
"JwtSettings": {
|
|
496
|
+
// JWT 發行者名稱
|
|
497
|
+
"Issuer": "YourProject",
|
|
498
|
+
// Token 有效期限(分鐘)
|
|
499
|
+
"ExpirationMinutes": 60,
|
|
500
|
+
// 簽署金鑰路徑
|
|
501
|
+
"PrivateKeyPath": "keys/es256key.pem"
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
Or use separate documentation:
|
|
507
|
+
|
|
508
|
+
```markdown
|
|
509
|
+
## 設定檔說明 (appsettings.json)
|
|
510
|
+
|
|
511
|
+
### JwtSettings
|
|
512
|
+
|
|
513
|
+
| 設定鍵 | 類型 | 說明 | 預設值 |
|
|
514
|
+
|--------|------|------|--------|
|
|
515
|
+
| `Issuer` | string | JWT 發行者名稱 | YourProject |
|
|
516
|
+
| `ExpirationMinutes` | int | Token 有效期限(分鐘)| 60 |
|
|
517
|
+
| `PrivateKeyPath` | string | ECDSA 私鑰檔案路徑 | keys/es256key.pem |
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
## Error Messages | 錯誤訊息
|
|
523
|
+
|
|
524
|
+
### System Errors: English | 系統錯誤: 英文
|
|
525
|
+
|
|
526
|
+
```csharp
|
|
527
|
+
// ✅ Internal errors, exceptions: English
|
|
528
|
+
throw new InvalidOperationException("Cannot process payment in pending state");
|
|
529
|
+
throw new ArgumentNullException(nameof(userId), "User ID cannot be null");
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
### User-Facing Errors: Traditional Chinese | 使用者錯誤: 繁體中文
|
|
533
|
+
|
|
534
|
+
```csharp
|
|
535
|
+
// ✅ User-facing error messages: Traditional Chinese
|
|
536
|
+
public class ErrorResponse
|
|
537
|
+
{
|
|
538
|
+
public string Code { get; set; } // "INVALID_CREDENTIALS"
|
|
539
|
+
public string Message { get; set; } // "使用者帳號或密碼錯誤"
|
|
540
|
+
public string Details { get; set; } // "請確認帳號與密碼後重試"
|
|
541
|
+
}
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
**API Error Response Example**:
|
|
545
|
+
```json
|
|
546
|
+
{
|
|
547
|
+
"error": {
|
|
548
|
+
"code": "INVALID_CREDENTIALS",
|
|
549
|
+
"message": "使用者帳號或密碼錯誤",
|
|
550
|
+
"details": "請確認您的帳號與密碼是否正確,密碼區分大小寫"
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
557
|
+
## Testing Documentation | 測試文件
|
|
558
|
+
|
|
559
|
+
### Test Method Names: English | 測試方法名稱: 英文
|
|
560
|
+
|
|
561
|
+
```csharp
|
|
562
|
+
// ✅ CORRECT: English test method names
|
|
563
|
+
[Fact]
|
|
564
|
+
public async Task AuthenticateAsync_WithValidCredentials_ReturnsToken()
|
|
565
|
+
{
|
|
566
|
+
// Arrange
|
|
567
|
+
var service = new AuthenticationService(_mockRepository.Object);
|
|
568
|
+
|
|
569
|
+
// Act
|
|
570
|
+
var token = await service.AuthenticateAsync("testuser", "password123");
|
|
571
|
+
|
|
572
|
+
// Assert
|
|
573
|
+
Assert.NotNull(token);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// ❌ WRONG: Chinese test method names
|
|
577
|
+
[Fact]
|
|
578
|
+
public async Task 驗證_使用有效憑證_返回Token() // ❌
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### Test Comments: Traditional Chinese | 測試註解: 繁體中文
|
|
582
|
+
|
|
583
|
+
```csharp
|
|
584
|
+
[Fact]
|
|
585
|
+
public async Task AuthenticateAsync_WithInvalidPassword_ReturnsNull()
|
|
586
|
+
{
|
|
587
|
+
// Arrange - 準備測試資料
|
|
588
|
+
var mockRepo = new Mock<IUserRepository>();
|
|
589
|
+
mockRepo.Setup(r => r.GetByUsernameAsync("testuser"))
|
|
590
|
+
.ReturnsAsync(new User { PasswordHash = "hashed_password" });
|
|
591
|
+
|
|
592
|
+
var service = new AuthenticationService(mockRepo.Object);
|
|
593
|
+
|
|
594
|
+
// Act - 執行測試
|
|
595
|
+
var result = await service.AuthenticateAsync("testuser", "wrong_password");
|
|
596
|
+
|
|
597
|
+
// Assert - 驗證結果
|
|
598
|
+
Assert.Null(result); // 密碼錯誤應返回 null
|
|
599
|
+
}
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
---
|
|
603
|
+
|
|
604
|
+
## Typography Standards | 排版標準
|
|
605
|
+
|
|
606
|
+
### Chinese-English Mixed Text | 中英混合文字
|
|
607
|
+
|
|
608
|
+
**Add spaces between Chinese and English**:
|
|
609
|
+
|
|
610
|
+
```markdown
|
|
611
|
+
✅ CORRECT:
|
|
612
|
+
本專案使用 ASP.NET Core 8.0 開發,採用 Clean Architecture 設計模式。
|
|
613
|
+
|
|
614
|
+
❌ WRONG:
|
|
615
|
+
本專案使用ASP.NET Core 8.0開發,採用Clean Architecture設計模式。
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
### Punctuation | 標點符號
|
|
619
|
+
|
|
620
|
+
**Use Chinese punctuation in Chinese text**:
|
|
621
|
+
|
|
622
|
+
```markdown
|
|
623
|
+
✅ CORRECT:
|
|
624
|
+
專案包含:認證模組、API 層、資料庫層。
|
|
625
|
+
|
|
626
|
+
❌ WRONG:
|
|
627
|
+
專案包含:認證模組,API層,資料庫層.
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
**Use English punctuation in code and English text**:
|
|
631
|
+
|
|
632
|
+
```csharp
|
|
633
|
+
// ✅ CORRECT: English punctuation in comments
|
|
634
|
+
// This method validates user credentials, checks permissions, and generates JWT token.
|
|
635
|
+
|
|
636
|
+
// ❌ WRONG: Chinese punctuation in English comments
|
|
637
|
+
// This method validates user credentials,checks permissions,and generates JWT token。
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
### Numbers | 數字
|
|
641
|
+
|
|
642
|
+
**Use Arabic numerals**:
|
|
643
|
+
|
|
644
|
+
```markdown
|
|
645
|
+
✅ CORRECT:
|
|
646
|
+
專案包含 15 個 API 端點、8 個資料模型、120 個單元測試。
|
|
647
|
+
|
|
648
|
+
❌ WRONG:
|
|
649
|
+
專案包含十五個 API 端點、八個資料模型、一百二十個單元測試。
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
---
|
|
653
|
+
|
|
654
|
+
## Terminology Consistency | 術語一致性
|
|
655
|
+
|
|
656
|
+
Maintain a **terminology glossary** for consistent Chinese translations:
|
|
657
|
+
|
|
658
|
+
### Common Software Terms | 常見軟體術語
|
|
659
|
+
|
|
660
|
+
| English | 繁體中文 | Notes |
|
|
661
|
+
|---------|---------|-------|
|
|
662
|
+
| Authentication | 認證 | NOT "身份驗證" |
|
|
663
|
+
| Authorization | 授權 | |
|
|
664
|
+
| Repository | 儲存庫 | In code pattern context |
|
|
665
|
+
| Service | 服務 | |
|
|
666
|
+
| Controller | 控制器 | |
|
|
667
|
+
| Middleware | 中介軟體 | |
|
|
668
|
+
| Dependency Injection | 依賴注入 | |
|
|
669
|
+
| Unit Test | 單元測試 | |
|
|
670
|
+
| Integration Test | 整合測試 | |
|
|
671
|
+
| Code Review | 程式碼審查 | |
|
|
672
|
+
| Pull Request | Pull Request | Keep English term |
|
|
673
|
+
| Commit | Commit | Keep English term |
|
|
674
|
+
| Branch | 分支 | |
|
|
675
|
+
| Merge | 合併 | |
|
|
676
|
+
| Refactor | 重構 | |
|
|
677
|
+
| Bug | Bug | Keep English term or "錯誤" |
|
|
678
|
+
| Feature | 功能 | |
|
|
679
|
+
| Performance | 效能 | NOT "性能" |
|
|
680
|
+
| Database | 資料庫 | |
|
|
681
|
+
| Cache | 快取 | |
|
|
682
|
+
| API | API | Keep English |
|
|
683
|
+
| SDK | SDK | Keep English |
|
|
684
|
+
| Framework | 框架 | |
|
|
685
|
+
| Changelog | 變更日誌 | |
|
|
686
|
+
| Release Notes | 發布說明 | |
|
|
687
|
+
| Breaking Change | 破壞性變更 | |
|
|
688
|
+
| Deprecate | 棄用 | |
|
|
689
|
+
| Semantic Versioning | 語義化版本 | |
|
|
690
|
+
|
|
691
|
+
**Project-Specific Customization**: Create `docs/terminology.md` for your project.
|
|
692
|
+
|
|
693
|
+
---
|
|
694
|
+
|
|
695
|
+
## Version History | 版本歷史
|
|
696
|
+
|
|
697
|
+
| Version | Date | Changes |
|
|
698
|
+
|---------|------|--------|
|
|
699
|
+
| 1.2.0 | 2025-12-12 | Add Chinese certainty tags section with mapping table and usage examples 新增中文確定性標籤章節,包含對照表與使用範例 |
|
|
700
|
+
| 1.1.0 | 2025-12-05 | Sync with commit-message-guide.md v1.2.0: Fix chore→維護 mapping; Add security/安全 type 與 commit-message-guide.md v1.2.0 同步:修正 chore→維護 對照;新增 security/安全 類型 |
|
|
701
|
+
| 1.0.0 | 2025-11-12 | Initial Traditional Chinese standard |
|
|
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/) 授權發布。
|