universal-dev-standards 5.14.0 → 5.16.0

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.
Files changed (134) hide show
  1. package/bin/uds.js +2 -0
  2. package/bundled/ai/standards/acceptance-criteria-traceability.ai.yaml +31 -0
  3. package/bundled/ai/standards/ai-instruction-standards.ai.yaml +190 -3
  4. package/bundled/ai/standards/forward-derivation-standards.ai.yaml +23 -0
  5. package/bundled/ai/standards/knowledge-graph-memory.ai.yaml +83 -0
  6. package/bundled/core/acceptance-criteria-traceability.md +46 -0
  7. package/bundled/core/ai-instruction-standards.md +136 -11
  8. package/bundled/core/forward-derivation-standards.md +19 -0
  9. package/bundled/core/knowledge-graph-memory.md +119 -0
  10. package/bundled/locales/COVERAGE.md +226 -0
  11. package/bundled/locales/zh-CN/CHANGELOG.md +42 -3
  12. package/bundled/locales/zh-CN/README.md +1 -1
  13. package/bundled/locales/zh-CN/SECURITY.md +1 -1
  14. package/bundled/locales/zh-CN/core/acceptance-criteria-traceability.md +46 -0
  15. package/bundled/locales/zh-CN/core/ai-instruction-standards.md +111 -5
  16. package/bundled/locales/zh-CN/core/forward-derivation-standards.md +19 -0
  17. package/bundled/locales/zh-CN/skills/ac-coverage/SKILL.md +194 -0
  18. package/bundled/locales/zh-CN/skills/adr-assistant/SKILL.md +135 -40
  19. package/bundled/locales/zh-CN/skills/brainstorm-assistant/SKILL.md +217 -63
  20. package/bundled/locales/zh-CN/skills/brainstorm-assistant/guide.md +599 -0
  21. package/bundled/locales/zh-CN/skills/commands/brainstorm.md +92 -25
  22. package/bundled/locales/zh-CN/skills/commit-standards/SKILL.md +78 -16
  23. package/bundled/locales/zh-CN/skills/contract-test-assistant/SKILL.md +85 -26
  24. package/bundled/locales/zh-CN/skills/deploy-assistant/SKILL.md +189 -0
  25. package/bundled/locales/zh-CN/skills/dev-methodology/SKILL.md +110 -0
  26. package/bundled/locales/zh-CN/skills/dev-methodology/guide.md +255 -0
  27. package/bundled/locales/zh-CN/skills/dev-workflow-guide/SKILL.md +70 -11
  28. package/bundled/locales/zh-CN/skills/journey-test-assistant/SKILL.md +209 -0
  29. package/bundled/locales/zh-CN/skills/knowledge-graph/SKILL.md +58 -0
  30. package/bundled/locales/zh-CN/skills/knowledge-graph/guide.md +74 -0
  31. package/bundled/locales/zh-CN/skills/migration-assistant/SKILL.md +125 -8
  32. package/bundled/locales/zh-CN/skills/observability-assistant/guide.md +188 -0
  33. package/bundled/locales/zh-CN/skills/orchestrate/SKILL.md +173 -0
  34. package/bundled/locales/zh-CN/skills/plan/SKILL.md +240 -0
  35. package/bundled/locales/zh-CN/skills/push/SKILL.md +242 -0
  36. package/bundled/locales/zh-CN/skills/retrospective-assistant/SKILL.md +104 -36
  37. package/bundled/locales/zh-CN/skills/reverse-engineer/SKILL.md +88 -32
  38. package/bundled/locales/zh-CN/skills/runbook-assistant/guide.md +216 -0
  39. package/bundled/locales/zh-CN/skills/skill-builder/SKILL.md +149 -0
  40. package/bundled/locales/zh-CN/skills/slo-assistant/guide.md +188 -0
  41. package/bundled/locales/zh-CN/skills/spec-derivation/SKILL.md +86 -0
  42. package/bundled/locales/zh-CN/skills/spec-derivation/guide.md +476 -0
  43. package/bundled/locales/zh-CN/skills/spec-driven-dev/SKILL.md +155 -81
  44. package/bundled/locales/zh-CN/skills/sweep/SKILL.md +151 -0
  45. package/bundled/locales/zh-CN/skills/testing-guide/SKILL.md +207 -110
  46. package/bundled/locales/zh-TW/CHANGELOG.md +46 -3
  47. package/bundled/locales/zh-TW/README.md +1 -1
  48. package/bundled/locales/zh-TW/SECURITY.md +1 -1
  49. package/bundled/locales/zh-TW/core/acceptance-criteria-traceability.md +46 -0
  50. package/bundled/locales/zh-TW/core/ai-instruction-standards.md +130 -5
  51. package/bundled/locales/zh-TW/core/browser-compatibility-standards.md +222 -5
  52. package/bundled/locales/zh-TW/core/contract-testing-standards.md +184 -5
  53. package/bundled/locales/zh-TW/core/cross-flow-regression.md +192 -5
  54. package/bundled/locales/zh-TW/core/forward-derivation-standards.md +19 -0
  55. package/bundled/locales/zh-TW/core/knowledge-graph-memory.md +127 -0
  56. package/bundled/locales/zh-TW/core/release-readiness-gate.md +186 -5
  57. package/bundled/locales/zh-TW/core/self-review-protocol.md +9 -1
  58. package/bundled/locales/zh-TW/skills/ac-coverage/SKILL.md +192 -0
  59. package/bundled/locales/zh-TW/skills/adr-assistant/SKILL.md +21 -42
  60. package/bundled/locales/zh-TW/skills/ai-collaboration-standards/SKILL.md +5 -1
  61. package/bundled/locales/zh-TW/skills/brainstorm-assistant/SKILL.md +212 -59
  62. package/bundled/locales/zh-TW/skills/brainstorm-assistant/guide.md +266 -579
  63. package/bundled/locales/zh-TW/skills/commands/brainstorm.md +91 -26
  64. package/bundled/locales/zh-TW/skills/commit-standards/SKILL.md +77 -15
  65. package/bundled/locales/zh-TW/skills/contract-test-assistant/SKILL.md +75 -16
  66. package/bundled/locales/zh-TW/skills/deploy-assistant/SKILL.md +187 -0
  67. package/bundled/locales/zh-TW/skills/dev-methodology/SKILL.md +108 -0
  68. package/bundled/locales/zh-TW/skills/dev-methodology/guide.md +255 -0
  69. package/bundled/locales/zh-TW/skills/dev-workflow-guide/SKILL.md +125 -64
  70. package/bundled/locales/zh-TW/skills/journey-test-assistant/SKILL.md +222 -0
  71. package/bundled/locales/zh-TW/skills/knowledge-graph/SKILL.md +56 -0
  72. package/bundled/locales/zh-TW/skills/knowledge-graph/guide.md +74 -0
  73. package/bundled/locales/zh-TW/skills/migration-assistant/SKILL.md +128 -11
  74. package/bundled/locales/zh-TW/skills/observability-assistant/guide.md +188 -0
  75. package/bundled/locales/zh-TW/skills/orchestrate/SKILL.md +173 -0
  76. package/bundled/locales/zh-TW/skills/plan/SKILL.md +240 -0
  77. package/bundled/locales/zh-TW/skills/project-structure-guide/SKILL.md +5 -1
  78. package/bundled/locales/zh-TW/skills/push/SKILL.md +242 -0
  79. package/bundled/locales/zh-TW/skills/retrospective-assistant/SKILL.md +94 -28
  80. package/bundled/locales/zh-TW/skills/reverse-engineer/SKILL.md +84 -28
  81. package/bundled/locales/zh-TW/skills/runbook-assistant/guide.md +216 -0
  82. package/bundled/locales/zh-TW/skills/skill-builder/SKILL.md +165 -0
  83. package/bundled/locales/zh-TW/skills/slo-assistant/guide.md +188 -0
  84. package/bundled/locales/zh-TW/skills/spec-derivation/SKILL.md +83 -0
  85. package/bundled/locales/zh-TW/skills/spec-derivation/guide.md +476 -0
  86. package/bundled/locales/zh-TW/skills/spec-driven-dev/SKILL.md +148 -77
  87. package/bundled/locales/zh-TW/skills/sweep/SKILL.md +149 -0
  88. package/bundled/locales/zh-TW/skills/testing-guide/SKILL.md +141 -44
  89. package/bundled/skills/adr-assistant/SKILL.md +1 -1
  90. package/bundled/skills/ai-collaboration-standards/SKILL.md +1 -1
  91. package/bundled/skills/ai-friendly-architecture/SKILL.md +1 -1
  92. package/bundled/skills/ai-instruction-standards/SKILL.md +1 -1
  93. package/bundled/skills/api-design-assistant/SKILL.md +1 -1
  94. package/bundled/skills/audit-assistant/SKILL.md +1 -1
  95. package/bundled/skills/brainstorm-assistant/SKILL.md +142 -106
  96. package/bundled/skills/brainstorm-assistant/guide.md +256 -661
  97. package/bundled/skills/ci-cd-assistant/SKILL.md +1 -1
  98. package/bundled/skills/commands/brainstorm.md +51 -30
  99. package/bundled/skills/contract-test-assistant/SKILL.md +1 -1
  100. package/bundled/skills/database-assistant/SKILL.md +1 -1
  101. package/bundled/skills/deploy-assistant/SKILL.md +1 -1
  102. package/bundled/skills/documentation-guide/SKILL.md +1 -1
  103. package/bundled/skills/error-code-guide/SKILL.md +1 -1
  104. package/bundled/skills/git-workflow-guide/SKILL.md +1 -1
  105. package/bundled/skills/incident-response-assistant/SKILL.md +1 -1
  106. package/bundled/skills/journey-test-assistant/SKILL.md +1 -1
  107. package/bundled/skills/knowledge-graph/SKILL.md +58 -0
  108. package/bundled/skills/knowledge-graph/guide.md +69 -0
  109. package/bundled/skills/logging-guide/SKILL.md +1 -1
  110. package/bundled/skills/observability-assistant/SKILL.md +1 -1
  111. package/bundled/skills/orchestrate/SKILL.md +1 -1
  112. package/bundled/skills/plan/SKILL.md +1 -1
  113. package/bundled/skills/pr-automation-assistant/SKILL.md +1 -1
  114. package/bundled/skills/project-structure-guide/SKILL.md +1 -1
  115. package/bundled/skills/push/SKILL.md +1 -1
  116. package/bundled/skills/retrospective-assistant/SKILL.md +1 -1
  117. package/bundled/skills/reverse-engineer/SKILL.md +1 -1
  118. package/bundled/skills/runbook-assistant/SKILL.md +1 -1
  119. package/bundled/skills/security-assistant/SKILL.md +1 -1
  120. package/bundled/skills/security-scan-assistant/SKILL.md +1 -1
  121. package/bundled/skills/slo-assistant/SKILL.md +1 -1
  122. package/bundled/skills/sweep/SKILL.md +1 -1
  123. package/bundled/skills/testing-guide/SKILL.md +1 -1
  124. package/package.json +2 -2
  125. package/src/commands/check.js +80 -0
  126. package/src/commands/init.js +8 -1
  127. package/src/commands/update.js +49 -14
  128. package/src/i18n/messages.js +32 -5
  129. package/src/installers/skills-installer.js +49 -0
  130. package/src/lint/i18n.js +424 -0
  131. package/src/utils/config-manager.js +39 -0
  132. package/src/utils/skills-installer.js +39 -7
  133. package/standards-registry.json +16 -4
  134. package/bundled/locales/zh-TW/docs/SKILL-FALLBACK-GUIDE.md +0 -407
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  source: ../../../core/ai-instruction-standards.md
3
- source_version: 1.0.0
4
- translation_version: 1.0.0
5
- last_synced: 2026-01-14
3
+ source_version: 1.1.0
4
+ translation_version: 1.1.0
5
+ last_synced: 2026-05-28
6
6
  status: current
7
7
  ---
8
8
 
@@ -10,8 +10,8 @@ status: current
10
10
 
11
11
  > **語言**: [English](../../../core/ai-instruction-standards.md) | 繁體中文
12
12
 
13
- **版本**: 1.0.0
14
- **最後更新**: 2026-01-14
13
+ **版本**: 1.1.0
14
+ **最後更新**: 2026-05-28
15
15
  **適用範圍**: 所有使用 AI 編碼助手的專案
16
16
 
17
17
  ---
@@ -151,6 +151,130 @@ AI 指令檔案通常混合兩種類型的內容:
151
151
 
152
152
  ---
153
153
 
154
+ ## 國際化(i18n)
155
+
156
+ AI 指令檔常需提供多語言版本——既為了國際採用者,也為了非英語母語維護者主導的專案。本章節定義多語言指令檔的組織、驗證與安裝規則。
157
+
158
+ ### AI 指令檔的範圍
159
+
160
+ 本標準涵蓋兩個層級的 AI 指令檔:
161
+
162
+ | 層級 | 範例 | i18n 模式 |
163
+ |------|------|----------|
164
+ | **Root 層** | `CLAUDE.md`、`.cursorrules`、`.windsurfrules`、`.opencode/instructions.md` | 單檔內以 inline 段落分語言(例:`## 中文` / `## English`)|
165
+ | **Skill 層** | Claude Code `.claude/skills/{name}/SKILL.md`、OpenCode plugin instructions | Canonical(英文)+ `locales/{lang}/` 變體 |
166
+
167
+ > 注意:skill 層的多檔結構主要對 Claude Code 適用。其他工具是 root 單檔;對它們只有下方「分層語言策略」與「Chimera 防範」規則適用。
168
+
169
+ ### 分層語言策略
170
+
171
+ 每份 AI 指令檔概念上有 **4 層**,各層語言責任不同:
172
+
173
+ | 層 | 內容 | Canonical (en) | Locale ({lang}) | 為何分這層 |
174
+ |----|------|---------------|----------------|-----------|
175
+ | **L1 — Metadata** | YAML frontmatter `description`、`argument-hint`、`allowed-tools` | **必須英文** | **必須對應 locale 語言** | AI 觸發訊號;英文 token 效率最高 + 訓練語料密度高 |
176
+ | **L2 — 指令(Instructions)** | 對 AI 的命令式規則(steps、behavior、allowed-tools 理由)| **必須英文** | 對應 locale 語言(可選;可保留英文)| AI 讀英文指令最精準;只有當維護者需要以母語讀指令時才翻譯 |
177
+ | **L3 — 輸出範本(Output Templates)** | 範例輸出、回應格式、情境範本 | 英文(canonical 鎖定英文)| **強制對應 locale**(mandatory)| **唯一直接影響 AI 輸出語言的層**——AI 會繼承所見範本的語言 |
178
+ | **L4 — 人類文件** | 維護者註解、貢獻者說明、walkthrough | 英文 | 對應 locale 語言(強烈建議)| 給人類維護者讀,AI 不讀 |
179
+
180
+ **關鍵 insight**:L1(description)是 AI 用來決定「**是否呼叫**」此 skill 的觸發訊號——它**不**影響 AI 之後說什麼。L3(output template)才是控制 AI 輸出語言的唯一開關,因為 AI 會慣性沿用範本語言。**i18n 強制檢查應該聚焦在 L3——加強 L1 的強制(例如強制 description 用 locale)是常見錯誤,它解決的是錯誤的問題。**
181
+
182
+ ### Canonical / Locale 檔案結構
183
+
184
+ UDS 標準與 skill 的 locale 變體結構:
185
+
186
+ ```text
187
+ core/{name}.md ← canonical(英文)— single source of truth
188
+ core/{name}.ai.yaml ← canonical 結構化(英文)
189
+ locales/{lang}/core/{name}.md ← locale 變體(匹配 lang)
190
+ locales/{lang}/ai/standards/{name}.ai.yaml ← locale .ai.yaml(匹配 lang)
191
+ skills/{name}/SKILL.md ← canonical skill(英文)
192
+ locales/{lang}/skills/{name}/SKILL.md ← locale skill 變體
193
+ ```
194
+
195
+ **命名慣例**:使用 BCP 47 語言標籤——`zh-TW`、`zh-CN`、`ja`、`ko`、`en-US` 等。
196
+
197
+ ### Locale 變體 Frontmatter 必填欄位
198
+
199
+ 每個 locale 變體必須含追蹤用 frontmatter,方便偵測 drift:
200
+
201
+ ```yaml
202
+ ---
203
+ name: {與 canonical 同名}
204
+ source: {指回 canonical 的相對路徑}
205
+ source_version: {翻譯時 canonical 的版本}
206
+ translation_version: {本翻譯的版本}
207
+ ---
208
+ ```
209
+
210
+ 當 canonical 更新(bump `source_version`),locale 維護者應重新同步並 bump `translation_version`。若 `source_version` 落後超過 2 個 minor 版本,會觸發 drift 警告(見「Chimera 防範」)。
211
+
212
+ ### 責任邊界
213
+
214
+ | 角色 | 擁有 | 必須做 |
215
+ |------|------|--------|
216
+ | **Canonical 擁有者** | `core/{name}.md`、`core/{name}.ai.yaml`、`skills/{name}/SKILL.md` | 維持 L1/L2/L3/L4 為英文;每次 breaking change 時 bump `source_version` |
217
+ | **Locale 維護者** | `locales/{lang}/...` 檔 | `translation_version` 對齊 `source_version`;翻譯 L1(必)、L2(選)、L3(必)、L4(建議)|
218
+ | **採用者(下游專案)** | 自己的 `.claude/skills/`、`CLAUDE.md` 等 | 用 `uds install --locale {lang}` 安裝;**絕不**手動修改 canonical 檔(要客製化請用 locale 變體或 overlay)|
219
+
220
+ ### Chimera 防範
221
+
222
+ **Chimera**(混血兒)指違反分層規則、混合語言的檔案。常見 chimera 模式:
223
+
224
+ | 模式 | 嚴重度 | 偵測方式 |
225
+ |------|--------|----------|
226
+ | Canonical 檔的 `description` 含 CJK | ❌ Error | Lint:`canonical:description-must-be-ascii` |
227
+ | Locale 變體的 `description` 是純 ASCII | ❌ Error | Lint:`locale:description-must-match-language` |
228
+ | Locale 變體缺 `source:` frontmatter | ❌ Error | Lint:`locale:must-have-source-frontmatter` |
229
+ | Canonical L3 output template 含非英文範例回應 | ⚠️ Warn | Lint:`canonical:l3-language-consistency` |
230
+ | 採用者 `.claude/skills/` 的檔案與 canonical 和任何 locale 變體都不同 | ⚠️ Warn | Sync check:`adopter:must-match-installed-locale` |
231
+ | `translation_version` 落後 `source_version` 超過 2 minor | ⚠️ Warn | Drift check |
232
+
233
+ Pre-commit / CI lint 強制 error 級規則;warn 級規則只在 dashboard 揭露不阻擋。
234
+
235
+ ### 採用者安裝模式
236
+
237
+ 採用者透過 UDS CLI 安裝指令檔:
238
+
239
+ ```bash
240
+ uds install --locale zh-TW # 以繁體中文安裝 skills 與 standards
241
+ ```
242
+
243
+ **Locale 解析優先順序**:
244
+ 1. `--locale` CLI 旗標(最高)
245
+ 2. `.uds/install.yaml` 的 `locale:` 欄位
246
+ 3. 環境變數 `UDS_LOCALE`
247
+ 4. Fallback:`en`
248
+
249
+ **Locale 不存在時的 fallback 行為**:當索求的 locale 對某個 skill 沒有變體時,CLI:
250
+ - 安裝 canonical(英文)檔案
251
+ - 發出 WARN 列出哪些 skill fallback 了
252
+ - **不**阻斷安裝
253
+
254
+ 這確保覆蓋率不完整時採用者仍能用。採用者可查 `locales/COVERAGE.md` 知道哪些有翻譯、哪些沒有。
255
+
256
+ ### 遷移:已有 chimera 的採用者
257
+
258
+ 若採用者已手動修改過專案中的 canonical 檔(例:在 `.claude/skills/` 翻譯了描述):
259
+
260
+ 1. **辨識 chimera**:比對採用者檔案與 UDS canonical / canonical 的 locale 變體。
261
+ 2. **安裝正確變體**:執行 `uds install --locale {lang}` 替換 chimera 為 locale 變體。
262
+ 3. **保留專案級客製**:若 chimera 含合理的專案級客製(非翻譯),抽出為 overlay 或記錄到客製化日誌(例:`UDS-CUSTOMIZATION.md`)。
263
+ 4. **丟棄純翻譯**:chimera 中純翻譯部分直接丟棄——locale 變體會取代它。
264
+
265
+ ### 快速參考
266
+
267
+ | 動作 | 何時 | 工具 / 檔案 |
268
+ |------|------|------------|
269
+ | 新增語言支援 | 想支援新 locale | 建立 `locales/{lang}/...` 對應 canonical 結構 |
270
+ | 更新 canonical | 改進英文 source | Bump `source_version`;通知 locale 維護者 |
271
+ | 翻譯 / 同步 locale | 新增或更新 locale 內容 | Bump `translation_version`;參照當前 `source_version` |
272
+ | 檢查覆蓋率 | 定期 review | 看自動產生的 `locales/COVERAGE.md` |
273
+ | 帶 locale 安裝 | 採用者初設或重新同步 | `uds install --locale {lang}` |
274
+ | 跑 i18n lint | Commit 前 / CI | `uds lint --i18n` |
275
+
276
+ ---
277
+
154
278
  ## 維護檢查清單
155
279
 
156
280
  在提交 AI 指令檔案的變更之前:
@@ -205,6 +329,7 @@ grep -n "npm\|yarn\|pip\|cargo" CLAUDE.md | head -20
205
329
  | 版本 | 日期 | 變更 |
206
330
  |------|------|------|
207
331
  | 1.0.0 | 2026-01-14 | 初始發布 |
332
+ | 1.1.0 | 2026-05-28 | 新增 i18n 章節;範圍延伸至 skill 層級檔案 |
208
333
 
209
334
  ---
210
335
 
@@ -1,11 +1,228 @@
1
1
  ---
2
2
  source: ../../../core/browser-compatibility-standards.md
3
3
  source_version: 1.0.0
4
- translation_version: 0.0.0
5
- last_synced: 2026-05-05
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-06-02
6
+ source_hash: b806494266e8
6
7
  ---
7
8
 
8
- <!-- TODO: 待完整繁體中文翻譯 — Translation pending -->
9
- <!-- See source: core/browser-compatibility-standards.md -->
9
+ # 瀏覽器相容性標準
10
10
 
11
- > 此標準尚未完整翻譯。請參閱英文原文:[English](../../../core/browser-compatibility-standards.md)
11
+ > **語言**:[English](../../../core/browser-compatibility-standards.md) | 繁體中文
12
+
13
+ **版本**:1.0.0
14
+ **最後更新**:2026-05-05
15
+ **適用範圍**:前端專案(網頁應用程式、漸進式網頁應用程式 PWA、Web Components)
16
+ **範疇**:universal
17
+ **業界標準**:Browserslist、W3C WebDriver、WebDriver BiDi
18
+ **參考資料**:[caniuse.com](https://caniuse.com/)、[Playwright 瀏覽器支援矩陣](https://playwright.dev/docs/browsers)
19
+
20
+ ---
21
+
22
+ ## 目的
23
+
24
+ 本標準定義所支援的瀏覽器與裝置矩陣、測試自動化策略,以及瀏覽器相容性的發布閘門(即 `release-readiness-gate.md` 中的第 9 維度,Tier-3)。
25
+
26
+ 瀏覽器相容性問題屬於使用者最容易察覺的缺陷之一,卻因為團隊往往假設「在 Chrome 上能跑就好」而被系統性地測試不足。若缺少明確的支援矩陣與自動化驗證,回歸缺陷便會滲漏到正式環境,影響大量使用者族群。
27
+
28
+ ---
29
+
30
+ ## 支援層級定義
31
+
32
+ | 層級 | 定義 | 發布閘門 |
33
+ |------|-----------|--------------|
34
+ | **Tier-1**(完整支援) | 功能完全對等 + 自動化測試覆蓋 | 100% 通過 —— 任一測試失敗即阻擋發布 |
35
+ | **Tier-2**(部分支援) | 盡力支援;主要流程必須可運作 | ≥ 95% 通過 —— 低於則 WARN,< 90% 則 FAIL |
36
+ | **Tier-3**(盡力而為) | 非正式支援;缺陷會記錄但不阻擋發布 | 僅作為建議參考 |
37
+
38
+ ---
39
+
40
+ ## 預設瀏覽器矩陣
41
+
42
+ 團隊**必須**明確宣告其支援矩陣。以下預設值涵蓋了大多數網頁流量(依 2025–2026 年資料):
43
+
44
+ ### Tier-1(預設)
45
+
46
+ | 瀏覽器 | 版本 | 平台 |
47
+ |---------|----------|---------|
48
+ | Chrome | latest、latest-1 | Windows、macOS、Linux、Android |
49
+ | Safari | latest、latest-1 | macOS、iOS |
50
+ | Firefox | latest | Windows、macOS、Linux |
51
+ | Edge | latest | Windows、macOS |
52
+
53
+ ### Tier-2(預設)
54
+
55
+ | 瀏覽器 | 版本 | 平台 |
56
+ |---------|----------|---------|
57
+ | Chrome | latest-2、latest-3 | 桌面 |
58
+ | Safari | latest-2 | macOS、iOS |
59
+ | Samsung Internet | latest | Android |
60
+ | Opera | latest | 桌面 |
61
+
62
+ ### Tier-3(預設)
63
+
64
+ | 瀏覽器 | 備註 |
65
+ |---------|-------|
66
+ | IE 11 | 已終止支援(EOL);僅在合約要求時才支援 |
67
+ | Chrome < latest-3 | 列為已知限制追蹤 |
68
+
69
+ ### 裝置 / 視窗(Viewport)矩陣
70
+
71
+ | 類別 | 最小寬度 | 代表性裝置 |
72
+ |----------|-----------|-----------------------|
73
+ | 行動裝置(小) | 360px | Android(小尺寸) |
74
+ | 行動裝置(標準) | 390px | iPhone 14 |
75
+ | 平板(直向) | 768px | iPad |
76
+ | 平板(橫向) | 1024px | iPad 橫向 |
77
+ | 桌面(小) | 1280px | 13 吋筆電 |
78
+ | 桌面(標準) | 1440px | 15 吋筆電 / 外接螢幕 |
79
+ | 桌面(寬) | 1920px | Full HD 螢幕 |
80
+
81
+ 最低要求:在 **360px、768px、1280px**(行動 / 平板 / 桌面斷點)進行測試。
82
+
83
+ ---
84
+
85
+ ## 自動化測試
86
+
87
+ ### Playwright 矩陣設定
88
+
89
+ ```typescript
90
+ // playwright.config.ts
91
+ import { defineConfig, devices } from "@playwright/test";
92
+
93
+ export default defineConfig({
94
+ projects: [
95
+ // Tier-1 browsers
96
+ { name: "chromium", use: { ...devices["Desktop Chrome"] } },
97
+ { name: "firefox", use: { ...devices["Desktop Firefox"] } },
98
+ { name: "webkit", use: { ...devices["Desktop Safari"] } },
99
+ { name: "edge", use: { ...devices["Desktop Edge"] } },
100
+ // Mobile Tier-1
101
+ { name: "mobile-chrome", use: { ...devices["Pixel 7"] } },
102
+ { name: "mobile-safari", use: { ...devices["iPhone 14"] } },
103
+ // Viewport coverage
104
+ { name: "tablet", use: { ...devices["iPad Pro 11"] } },
105
+ ],
106
+ // Tier-1 failure = build failure
107
+ reporter: [["html"], ["junit", { outputFile: "results/browser-compat.xml" }]],
108
+ });
109
+ ```
110
+
111
+ ### CI 執行策略
112
+
113
+ ```bash
114
+ # Run full Tier-1 matrix on release candidate
115
+ npx playwright test --project=chromium,firefox,webkit,edge,mobile-chrome,mobile-safari,tablet
116
+
117
+ # Run Tier-1 only on every PR (fast feedback)
118
+ npx playwright test --project=chromium,firefox,webkit
119
+
120
+ # Run Tier-2 on release candidate (results feed into sign-off as WARN/PASS)
121
+ npx playwright test --project=samsung,opera
122
+ ```
123
+
124
+ ### 雲端瀏覽器測試
125
+
126
+ 針對 Tier-1 的跨作業系統測試(例如在 Windows 主機的 CI 上測試 Safari),請使用雲端服務:
127
+
128
+ | 服務 | 使用情境 |
129
+ |---------|---------|
130
+ | BrowserStack Automate | 商業專案;提供最廣泛的 OS + 瀏覽器矩陣 |
131
+ | Sauce Labs | 已有既有合約的企業 |
132
+ | LambdaTest | 開源 / 對成本敏感的專案 |
133
+
134
+ **最低雲端測試要求**:在真實 iOS 裝置上測試 Safari latest 與 latest-1(對於 WebKit 的缺陷,模擬器(Simulator)並不足夠)。
135
+
136
+ ---
137
+
138
+ ## 視覺回歸測試(選用但建議)
139
+
140
+ 像素差異(Pixel-diff)測試可偵測跨瀏覽器的版面回歸:
141
+
142
+ ```bash
143
+ # Using Playwright visual comparisons
144
+ npx playwright test --update-snapshots # update baseline
145
+ npx playwright test # compare against baseline; fail if diff > threshold
146
+ ```
147
+
148
+ 門檻建議值:版面元件 < 0.5% 像素差異;複雜的互動元件 < 2%。
149
+
150
+ ---
151
+
152
+ ## 發布閘門條件
153
+
154
+ 這是 `release-readiness-gate.md` 中的**第 9 維度**(Tier-3:前端 / 網頁專案必填;CLI / 純後端專案則標示為 `N/A`)。
155
+
156
+ | 閘門 | Pass | Warn | Fail |
157
+ |------|------|------|------|
158
+ | Tier-1 瀏覽器矩陣 | 100% 測試通過 | — | 任一測試失敗 |
159
+ | Tier-2 瀏覽器矩陣 | ≥ 95% 通過 | 90–95% | < 90% |
160
+ | 視窗覆蓋(360/768/1280) | 任何 Tier-1 瀏覽器上版面皆無破版 | — | 任一關鍵流程無法使用 |
161
+
162
+ ### 簽核所需的證據
163
+
164
+ ```
165
+ | 9 | Browser / Device Compat | PASS | Playwright: 6 browsers × 7 viewports, 100% Tier-1; Tier-2: 97%; [junit report link] | QA Lead |
166
+ ```
167
+
168
+ ### `N/A` 條件
169
+
170
+ 在以下情況標示為 `N/A`:
171
+ - 專案為純 CLI、純後端 API,或行動原生(非網頁)
172
+ - 記錄理由:`"N/A — backend API service, no browser UI"`
173
+
174
+ ---
175
+
176
+ ## Browserslist 設定
177
+
178
+ 在 repo 根目錄提交一份 `.browserslistrc`,以確保建置工具(Babel、PostCSS、Autoprefixer)針對相同的瀏覽器:
179
+
180
+ ```
181
+ # .browserslistrc
182
+ # Tier-1: production targets
183
+ last 2 Chrome versions
184
+ last 2 Firefox versions
185
+ last 2 Safari versions
186
+ last 2 Edge versions
187
+ last 2 iOS versions
188
+ last 2 ChromeAndroid versions
189
+
190
+ # Tier-2: for reference (not in build targets by default)
191
+ # last 4 Chrome versions
192
+ # Samsung Internet >= 14
193
+ ```
194
+
195
+ ---
196
+
197
+ ## 反模式
198
+
199
+ - **只測試 Chrome** —— Chrome 約佔桌面流量的 65%;剩下的 35% 是 Safari / Firefox / Edge 使用者,而你的 bug 會被他們發現
200
+ - **使用瀏覽器模擬器測試 iOS Safari** —— 模擬器上的 WebKit 與真實裝置的 WebKit 有所分歧;對於 release candidate,務必在真實 iOS 上測試
201
+ - **未指定矩陣** —— 隱含假設「支援所有瀏覽器」是不可能測試的;明確的 Tier-1 矩陣勝過毫無實質的隱含覆蓋
202
+ - **將 Tier-3 瀏覽器失敗當作阻擋項** —— Tier-3 是盡力而為;記錄問題才是恰當做法,而非阻擋發布
203
+ - **略過行動視窗測試** —— 行動優先(mobile-first)已是標準;缺少 360px 測試將為大多數行動使用者帶來破損的使用體驗
204
+
205
+ ---
206
+
207
+ ## 與其他標準的關係
208
+
209
+ - **`accessibility-standards.md`** —— 鍵盤導覽與螢幕報讀器測試需跨所有 Tier-1 瀏覽器執行
210
+ - **`e2e-testing.md`** —— Playwright 矩陣設定將 E2E 測試擴展為多瀏覽器
211
+ - **`release-readiness-gate.md`** —— 第 9 維度(Tier-3)
212
+ - **`performance-standards.md`** —— Core Web Vitals 目標適用於每個 Tier-1 瀏覽器
213
+
214
+ ---
215
+
216
+ ## 版本歷史
217
+
218
+ | 版本 | 日期 | 變更內容 |
219
+ |---------|------|---------|
220
+ | 1.0.0 | 2026-05-05 | 首次發布:Tier-1/2/3 矩陣、Playwright 設定、雲端測試、發布閘門條件 |
221
+
222
+ ---
223
+
224
+ ## 授權
225
+
226
+ 本標準依 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 授權發布。
227
+
228
+ **來源**:[universal-dev-standards](https://github.com/AsiaOstrich/universal-dev-standards)
@@ -1,11 +1,190 @@
1
1
  ---
2
2
  source: ../../../core/contract-testing-standards.md
3
3
  source_version: 1.0.0
4
- translation_version: 0.0.0
5
- last_synced: 2026-05-05
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-06-02
6
+ source_hash: 2afa2fe434a6
6
7
  ---
7
8
 
8
- <!-- TODO: 待完整繁體中文翻譯 — Translation pending -->
9
- <!-- See source: core/contract-testing-standards.md -->
9
+ # 合約測試標準(Contract Testing Standards)
10
10
 
11
- > 此標準尚未完整翻譯。請參閱英文原文:[English](../../../core/contract-testing-standards.md)
11
+ > **語言**:[English](../../../core/contract-testing-standards.md) | 繁體中文
12
+
13
+ **版本**:1.0.0
14
+ **最後更新**:2026-05-05
15
+ **適用範圍**:具有 API 消費者(服務對服務、前端對後端、公開 API)的專案
16
+ **範疇**:universal
17
+ **業界標準**:消費者驅動合約測試(Consumer-Driven Contract Testing, CDCT)、Pact Specification v3
18
+ **參考資料**:[pact.io](https://docs.pact.io/)、[Spring Cloud Contract](https://spring.io/projects/spring-cloud-contract)
19
+
20
+ ---
21
+
22
+ ## 目的
23
+
24
+ 合約測試(Contract testing)驗證 provider(API 伺服器)與其 consumer(用戶端)對於確切介面 —— 請求格式、回應 schema 與狀態碼 —— 達成共識,且無需雙方同時部署。
25
+
26
+ 若缺少合約測試:
27
+ - Provider 的變更會在 production 中悄悄破壞 consumer
28
+ - 服務之間的整合測試需要完整環境
29
+ - API 版本決策在缺乏實際使用證據的情況下做出
30
+
31
+ 本標準將消費者驅動合約測試正式化為一道**發布閘門**(`release-readiness-gate.md` 中的 Dimension 4,Tier-3)。
32
+
33
+ ---
34
+
35
+ ## 消費者驅動合約流程
36
+
37
+ ```
38
+ Consumer 撰寫互動預期
39
+
40
+ Consumer 將合約發布至 Pact Broker
41
+
42
+ Provider CI 取得 consumer 合約
43
+
44
+ Provider 驗證自身能否滿足每一筆互動
45
+
46
+ Pact Broker 記錄:can-i-deploy 結果
47
+
48
+ 發布閘門:provider 部署前所有 consumer 合約必須 GREEN
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 合約涵蓋範圍
54
+
55
+ 一份合約涵蓋:
56
+
57
+ | 元素 | 是否必須指定 | 備註 |
58
+ |---------|-------------|-------|
59
+ | 請求方法(Request method) | 是 | GET / POST / PUT / PATCH / DELETE |
60
+ | 請求路徑(Request path) | 是 | 包含路徑參數(path params) |
61
+ | 請求標頭(Request headers) | 僅必要者 | 不要過度指定可選標頭 |
62
+ | 請求 body schema | 是(針對寫入操作) | schema 層級,而非字面值 |
63
+ | 回應狀態(Response status) | 是 | 所有預期的狀態碼 |
64
+ | 回應 body schema | 是 | schema 層級;使用 matcher 而非字面值 |
65
+ | 回應標頭(Response headers) | 僅必要者 | 例如 `Content-Type` |
66
+
67
+ **寧可不足指定,也不要過度指定。** 只斷言 consumer 實際使用到的部分。
68
+
69
+ ---
70
+
71
+ ## 向後相容視窗
72
+
73
+ | 發布類型 | 相容性要求 |
74
+ |-------------|--------------------------|
75
+ | Patch | 100% 向後相容;不預期有合約變更 |
76
+ | Minor | N-1 consumer 合約版本仍須通過 |
77
+ | Major | 需要棄用期;通知 consumer;舊合約歸檔 |
78
+
79
+ **破壞性變更政策**:若任何作用中的 consumer 合約呈紅色,provider 不得部署(MAY NOT deploy)。破壞性變更需要:
80
+ 1. 採用僅新增(additive-only)變更的新 provider 版本
81
+ 2. Consumer 遷移至新版本
82
+ 3. 舊合約明確標示棄用並歸檔
83
+
84
+ ---
85
+
86
+ ## 發布閘門準則
87
+
88
+ | 準則 | 硬性下限 | 警告區間 |
89
+ |-----------|-------------|-----------|
90
+ | 所有作用中的 consumer 合約 | 100% 綠燈 | —(二元:全有或全無) |
91
+ | N-1 向後相容 | 100% 綠燈 | — |
92
+ | 棄用合約清理 | 舊合約於 30 天內歸檔 | > 30 天 = WARN |
93
+
94
+ Pact Broker 中的 `can-i-deploy` 指令封裝了這道閘門:
95
+
96
+ ```bash
97
+ pact-broker can-i-deploy \
98
+ --pacticipant <provider-service> \
99
+ --version <version> \
100
+ --to-environment production
101
+ ```
102
+
103
+ 結束碼(Exit code)0 = PASS;非零 = FAIL(阻擋發布)。
104
+
105
+ ---
106
+
107
+ ## 實作指引
108
+
109
+ ### Consumer 端
110
+
111
+ ```typescript
112
+ // Pact consumer test (TypeScript example)
113
+ const interaction = {
114
+ state: "user 42 exists",
115
+ uponReceiving: "a request for user 42",
116
+ withRequest: {
117
+ method: "GET",
118
+ path: "/users/42",
119
+ headers: { Accept: "application/json" },
120
+ },
121
+ willRespondWith: {
122
+ status: 200,
123
+ headers: { "Content-Type": "application/json" },
124
+ body: like({ // schema matcher, not literal
125
+ id: integer(),
126
+ name: string(),
127
+ email: email(),
128
+ }),
129
+ },
130
+ };
131
+ ```
132
+
133
+ ### Provider 端
134
+
135
+ ```bash
136
+ # Provider verification in CI
137
+ PACT_BROKER_BASE_URL=https://pact-broker.internal \
138
+ PACT_PROVIDER_VERSION=$GIT_SHA \
139
+ npm run test:pact:provider
140
+ ```
141
+
142
+ ### Pact Broker 標籤
143
+
144
+ | 標籤 | 意義 |
145
+ |-----|---------|
146
+ | `main` | main 分支的最新版本 |
147
+ | `production` | 目前部署於 production 的版本 |
148
+ | `<feature-branch>` | 功能分支合約(暫時性) |
149
+
150
+ ---
151
+
152
+ ## 反模式
153
+
154
+ - **測試整個 API 表面** —— 只測試 consumer 實際使用的部分;過度指定會造成不必要的合約中斷
155
+ - **字面值比對** —— 使用 schema matcher(`like()`、`eachLike()`、`integer()`)而非精確值;合約應能容忍實際資料的合理變化
156
+ - **略過 provider 驗證** —— 發布 consumer 合約卻不進行 provider 驗證,代表該合約毫無強制效力
157
+ - **未執行 `can-i-deploy`** —— 只檢查個別合約狀態並不足夠;`can-i-deploy` 會評估整個部署矩陣
158
+
159
+ ---
160
+
161
+ ## 與其他標準的關係
162
+
163
+ - **`api-design-standards.md`** —— 合約測試強制執行 API 設計中所宣告的向後相容保證
164
+ - **`release-readiness-gate.md`** —— Dimension 4(Tier-3:當存在 API consumer 時適用)
165
+ - **`integration-testing.md`** —— 合約測試補足但不取代整合測試
166
+ - **`versioning.md`** —— 語意化版本與上述向後相容視窗互相關聯
167
+
168
+ ---
169
+
170
+ ## 另見
171
+
172
+ - [Pact 文件](https://docs.pact.io/)
173
+ - [Can I Deploy](https://docs.pact.io/pact_broker/can_i_deploy)
174
+ - [消費者驅動合約(Consumer-Driven Contracts)](https://martinfowler.com/articles/consumerDrivenContracts.html) —— Martin Fowler
175
+
176
+ ---
177
+
178
+ ## 版本歷史
179
+
180
+ | 版本 | 日期 | 變更 |
181
+ |---------|------|---------|
182
+ | 1.0.0 | 2026-05-05 | 初版發布:消費者驅動合約流程、向後相容視窗、發布閘門準則 |
183
+
184
+ ---
185
+
186
+ ## 授權
187
+
188
+ 本標準依 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 授權發布。
189
+
190
+ **來源**:[universal-dev-standards](https://github.com/AsiaOstrich/universal-dev-standards)