universal-dev-standards 5.1.0-beta.7 → 5.1.1

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 (116) hide show
  1. package/README.md +6 -0
  2. package/bin/uds.js +2 -0
  3. package/bundled/ai/standards/checkin-standards.ai.yaml +18 -0
  4. package/bundled/ai/standards/test-governance.ai.yaml +12 -0
  5. package/bundled/ai/standards/testing.ai.yaml +14 -0
  6. package/bundled/ai/standards/translation-lifecycle-standards.ai.yaml +145 -0
  7. package/bundled/core/checkin-standards.md +21 -2
  8. package/bundled/core/test-governance.md +3 -0
  9. package/bundled/core/testing-standards.md +25 -2
  10. package/bundled/core/translation-lifecycle-standards.md +162 -0
  11. package/bundled/locales/zh-CN/CHANGELOG.md +50 -3
  12. package/bundled/locales/zh-CN/README.md +1 -1
  13. package/bundled/locales/zh-CN/core/anti-hallucination.md +22 -3
  14. package/bundled/locales/zh-CN/core/anti-sycophancy-prompting.md +192 -0
  15. package/bundled/locales/zh-CN/core/capability-declaration.md +123 -0
  16. package/bundled/locales/zh-CN/core/checkin-standards.md +22 -3
  17. package/bundled/locales/zh-CN/core/circuit-breaker.md +106 -0
  18. package/bundled/locales/zh-CN/core/dual-phase-output.md +103 -0
  19. package/bundled/locales/zh-CN/core/failure-source-taxonomy.md +99 -0
  20. package/bundled/locales/zh-CN/core/frontend-design-standards.md +289 -0
  21. package/bundled/locales/zh-CN/core/health-check-standards.md +144 -0
  22. package/bundled/locales/zh-CN/core/immutability-first.md +96 -0
  23. package/bundled/locales/zh-CN/core/packaging-standards.md +224 -0
  24. package/bundled/locales/zh-CN/core/recovery-recipe-registry.md +146 -0
  25. package/bundled/locales/zh-CN/core/retry-standards.md +131 -0
  26. package/bundled/locales/zh-CN/core/security-decision.md +104 -0
  27. package/bundled/locales/zh-CN/core/skill-standard-alignment-check.md +112 -0
  28. package/bundled/locales/zh-CN/core/standard-admission-criteria.md +104 -0
  29. package/bundled/locales/zh-CN/core/standard-lifecycle-management.md +116 -0
  30. package/bundled/locales/zh-CN/core/test-governance.md +14 -3
  31. package/bundled/locales/zh-CN/core/testing-standards.md +26 -3
  32. package/bundled/locales/zh-CN/core/timeout-standards.md +117 -0
  33. package/bundled/locales/zh-CN/core/token-budget.md +108 -0
  34. package/bundled/locales/zh-CN/core/translation-lifecycle-standards.md +159 -0
  35. package/bundled/locales/zh-TW/CHANGELOG.md +50 -3
  36. package/bundled/locales/zh-TW/README.md +1 -1
  37. package/bundled/locales/zh-TW/core/anti-sycophancy-prompting.md +8 -0
  38. package/bundled/locales/zh-TW/core/capability-declaration.md +111 -0
  39. package/bundled/locales/zh-TW/core/checkin-standards.md +24 -3
  40. package/bundled/locales/zh-TW/core/circuit-breaker.md +111 -0
  41. package/bundled/locales/zh-TW/core/dual-phase-output.md +132 -0
  42. package/bundled/locales/zh-TW/core/failure-source-taxonomy.md +146 -0
  43. package/bundled/locales/zh-TW/core/frontend-design-standards.md +460 -0
  44. package/bundled/locales/zh-TW/core/health-check-standards.md +144 -0
  45. package/bundled/locales/zh-TW/core/immutability-first.md +159 -0
  46. package/bundled/locales/zh-TW/core/recovery-recipe-registry.md +146 -0
  47. package/bundled/locales/zh-TW/core/retry-standards.md +140 -0
  48. package/bundled/locales/zh-TW/core/security-decision.md +120 -0
  49. package/bundled/locales/zh-TW/core/skill-standard-alignment-check.md +112 -0
  50. package/bundled/locales/zh-TW/core/standard-admission-criteria.md +104 -0
  51. package/bundled/locales/zh-TW/core/standard-lifecycle-management.md +116 -0
  52. package/bundled/locales/zh-TW/core/test-governance.md +14 -3
  53. package/bundled/locales/zh-TW/core/testing-standards.md +31 -0
  54. package/bundled/locales/zh-TW/core/timeout-standards.md +117 -0
  55. package/bundled/locales/zh-TW/core/token-budget.md +143 -0
  56. package/bundled/locales/zh-TW/core/translation-lifecycle-standards.md +159 -0
  57. package/bundled/locales/zh-TW/skills/ac-coverage-assistant/SKILL.md +1 -0
  58. package/bundled/locales/zh-TW/skills/adr-assistant/SKILL.md +1 -0
  59. package/bundled/locales/zh-TW/skills/ai-collaboration-standards/SKILL.md +1 -0
  60. package/bundled/locales/zh-TW/skills/ai-friendly-architecture/SKILL.md +1 -0
  61. package/bundled/locales/zh-TW/skills/ai-instruction-standards/SKILL.md +1 -0
  62. package/bundled/locales/zh-TW/skills/api-design-assistant/SKILL.md +1 -0
  63. package/bundled/locales/zh-TW/skills/atdd-assistant/SKILL.md +1 -0
  64. package/bundled/locales/zh-TW/skills/audit-assistant/SKILL.md +1 -0
  65. package/bundled/locales/zh-TW/skills/bdd-assistant/SKILL.md +1 -0
  66. package/bundled/locales/zh-TW/skills/brainstorm-assistant/SKILL.md +1 -0
  67. package/bundled/locales/zh-TW/skills/changelog-guide/SKILL.md +1 -0
  68. package/bundled/locales/zh-TW/skills/checkin-assistant/SKILL.md +1 -0
  69. package/bundled/locales/zh-TW/skills/ci-cd-assistant/SKILL.md +1 -0
  70. package/bundled/locales/zh-TW/skills/code-review-assistant/SKILL.md +1 -0
  71. package/bundled/locales/zh-TW/skills/commit-standards/SKILL.md +1 -0
  72. package/bundled/locales/zh-TW/skills/contract-test-assistant/SKILL.md +1 -0
  73. package/bundled/locales/zh-TW/skills/database-assistant/SKILL.md +1 -0
  74. package/bundled/locales/zh-TW/skills/dev-workflow-guide/SKILL.md +1 -0
  75. package/bundled/locales/zh-TW/skills/docs-generator/SKILL.md +1 -0
  76. package/bundled/locales/zh-TW/skills/documentation-guide/SKILL.md +1 -0
  77. package/bundled/locales/zh-TW/skills/durable-execution-assistant/SKILL.md +1 -0
  78. package/bundled/locales/zh-TW/skills/e2e-assistant/SKILL.md +1 -0
  79. package/bundled/locales/zh-TW/skills/forward-derivation/SKILL.md +1 -0
  80. package/bundled/locales/zh-TW/skills/incident-response-assistant/SKILL.md +1 -0
  81. package/bundled/locales/zh-TW/skills/methodology-system/SKILL.md +1 -0
  82. package/bundled/locales/zh-TW/skills/metrics-dashboard-assistant/SKILL.md +1 -0
  83. package/bundled/locales/zh-TW/skills/migration-assistant/SKILL.md +1 -0
  84. package/bundled/locales/zh-TW/skills/observability-assistant/SKILL.md +1 -0
  85. package/bundled/locales/zh-TW/skills/pr-automation-assistant/SKILL.md +1 -0
  86. package/bundled/locales/zh-TW/skills/process-automation/SKILL.md +1 -0
  87. package/bundled/locales/zh-TW/skills/project-discovery/SKILL.md +1 -0
  88. package/bundled/locales/zh-TW/skills/project-structure-guide/SKILL.md +1 -0
  89. package/bundled/locales/zh-TW/skills/refactoring-assistant/SKILL.md +1 -0
  90. package/bundled/locales/zh-TW/skills/release-standards/SKILL.md +1 -0
  91. package/bundled/locales/zh-TW/skills/requirement-assistant/SKILL.md +1 -0
  92. package/bundled/locales/zh-TW/skills/retrospective-assistant/SKILL.md +1 -0
  93. package/bundled/locales/zh-TW/skills/reverse-engineer/SKILL.md +1 -0
  94. package/bundled/locales/zh-TW/skills/runbook-assistant/SKILL.md +1 -0
  95. package/bundled/locales/zh-TW/skills/security-assistant/SKILL.md +1 -0
  96. package/bundled/locales/zh-TW/skills/security-scan-assistant/SKILL.md +1 -0
  97. package/bundled/locales/zh-TW/skills/slo-assistant/SKILL.md +1 -0
  98. package/bundled/locales/zh-TW/skills/spec-driven-dev/SKILL.md +1 -0
  99. package/bundled/locales/zh-TW/skills/tdd-assistant/SKILL.md +1 -0
  100. package/bundled/locales/zh-TW/skills/test-coverage-assistant/SKILL.md +1 -0
  101. package/bundled/skills/ai-collaboration-standards/SKILL.md +1 -0
  102. package/bundled/skills/ai-friendly-architecture/SKILL.md +1 -0
  103. package/bundled/skills/ai-instruction-standards/SKILL.md +1 -0
  104. package/bundled/skills/documentation-guide/SKILL.md +1 -0
  105. package/bundled/skills/error-code-guide/SKILL.md +1 -0
  106. package/bundled/skills/git-workflow-guide/SKILL.md +1 -0
  107. package/bundled/skills/logging-guide/SKILL.md +1 -0
  108. package/bundled/skills/project-structure-guide/SKILL.md +1 -0
  109. package/bundled/skills/testing-guide/SKILL.md +1 -0
  110. package/package.json +5 -4
  111. package/src/commands/check.js +6 -0
  112. package/src/commands/init.js +6 -0
  113. package/src/commands/update.js +6 -0
  114. package/src/utils/detect-self-adoption.js +173 -0
  115. package/src/utils/directory-mapper.js +2 -2
  116. package/standards-registry.json +15 -4
@@ -0,0 +1,146 @@
1
+ ---
2
+ source: ../../../core/failure-source-taxonomy.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-20
6
+ status: current
7
+ ---
8
+
9
+ # 失敗來源分類法標準
10
+
11
+ > **語言**: [English](../../../core/failure-source-taxonomy.md) | 繁體中文
12
+
13
+ **版本**: 1.0.0
14
+ **最後更新**: 2026-04-16
15
+ **適用範圍**: 所有 Agent 執行結果的失敗分類
16
+ **Scope**: universal
17
+ **來源**: XSPEC-045(claw-code ROADMAP Phase 2 Failure Taxonomy,DEC-035)
18
+
19
+ ---
20
+
21
+ ## 目的
22
+
23
+ 失敗來源分類法:在 `TaskStatus`(what)之上新增 `failureSource`(why)維度,提供 8 類結構化失敗來源。
24
+
25
+ 現有的 `TaskStatus` 只回答「發生了什麼」,`failureSource` 補充「為什麼失敗」。結構化的失敗來源使下游恢復機制(Recovery Recipe Registry,XSPEC-046)能精準匹配策略,避免用同一套重試邏輯處理本質不同的失敗類型。
26
+
27
+ ---
28
+
29
+ ## 核心規範
30
+
31
+ - 所有失敗結果應攜帶 `failureSource`,使恢復策略可精準匹配
32
+ - `failureSource` 為 optional 欄位,不得破壞現有不含此欄位的程式碼
33
+ - 在同一失敗事件中,選擇最根本的來源作為 `failureSource`(例如 `branch_divergence` 比 `compilation` 更根本)
34
+ - `failureSource` 應由偵測到失敗的元件設定(QualityGate / Adapter / SafetyHook / BranchDriftChecker)
35
+ - 跨專案(DevAP / VibeOps)各自獨立定義 `FailureSource` type,語義保持一致
36
+
37
+ ---
38
+
39
+ ## 8 類失敗來源
40
+
41
+ ### `prompt_delivery`
42
+
43
+ - **描述**:Prompt 未正確傳遞給 LLM(API 4xx、空回應、格式解析失敗)
44
+ - **偵測提示**:API 回傳 4xx / 空回應 / JSON 解析失敗
45
+ - **建議恢復**:重試或 `model_switch`
46
+ - **嚴重度範圍**:critical, high
47
+
48
+ ### `model_degradation`
49
+
50
+ - **描述**:LLM 降智或回應品質明顯下降(重複輸出、無關回應、品質驟降)
51
+ - **偵測提示**:輸出品質評分低於基準線 / 連續重複輸出 / 評估分數 < 30
52
+ - **建議恢復**:`model_switch`
53
+ - **嚴重度範圍**:critical, high, medium
54
+
55
+ ### `branch_divergence`
56
+
57
+ - **描述**:工作分支落後基底分支,可能導致合併衝突或假回歸
58
+ - **偵測提示**:`git rev-list --count HEAD..origin/{baseBranch} > 0`
59
+ - **建議恢復**:`rebase_and_retry`
60
+ - **嚴重度範圍**:critical, high, medium
61
+ - **備註**:severity 由落後 commit 數決定:1-5 為 medium,6+ 為 high/critical
62
+
63
+ ### `compilation`
64
+
65
+ - **描述**:編譯或型別檢查錯誤(TypeScript tsc、Go build、Rust cargo 等)
66
+ - **偵測提示**:build / tsc / compile 指令 exit code != 0
67
+ - **建議恢復**:`fix_loop`
68
+ - **嚴重度範圍**:high, medium, low
69
+
70
+ ### `test_failure`
71
+
72
+ - **描述**:測試失敗(unit / integration / system / e2e 任一層級)
73
+ - **偵測提示**:test 指令 exit code != 0
74
+ - **建議恢復**:`fix_loop`
75
+ - **嚴重度範圍**:high, medium, low
76
+
77
+ ### `tool_failure`
78
+
79
+ - **描述**:工具層失敗(MCP server 無回應、Plugin 載入失敗、CLI 工具不存在)
80
+ - **偵測提示**:MCP / Plugin / shell 工具執行失敗或 timeout
81
+ - **建議恢復**:circuit_breaker 保護後重試,或降級模式繼續
82
+ - **嚴重度範圍**:critical, high, medium
83
+
84
+ ### `policy_violation`
85
+
86
+ - **描述**:安全或治理策略攔截(Guardian deny、SafetyHook 阻擋、Fail-Closed 觸發)
87
+ - **偵測提示**:`SecurityDecision` 為 deny / Guardian verdict 為 `blocking: true`
88
+ - **建議恢復**:`human_checkpoint`(不自動重試,需人工審查)
89
+ - **嚴重度範圍**:critical, high
90
+
91
+ ### `resource_exhaustion`
92
+
93
+ - **描述**:資源耗盡(token 預算超限、時間 timeout、美元預算耗盡)
94
+ - **偵測提示**:`error_max_turns` / `error_max_budget_usd` / token zone BLOCKING
95
+ - **建議恢復**:`degraded_mode` 或 `human_checkpoint`
96
+ - **嚴重度範圍**:critical, high
97
+
98
+ ---
99
+
100
+ ## 類型定義
101
+
102
+ ### FailureSource
103
+
104
+ 8 類失敗來源的 union type:
105
+
106
+ ```
107
+ prompt_delivery | model_degradation | branch_divergence | compilation |
108
+ test_failure | tool_failure | policy_violation | resource_exhaustion
109
+ ```
110
+
111
+ ### FailureDetail
112
+
113
+ | 欄位 | 類型 | 說明 |
114
+ |------|------|------|
115
+ | `source` | `FailureSource` | 失敗來源 |
116
+ | `raw_error` | `string` | 原始錯誤訊息 |
117
+ | `detected_by` | `string` | 偵測元件名稱(quality-gate / claude-adapter / safety-hook / branch-drift) |
118
+ | `timestamp` | `string` | ISO 8601 格式 |
119
+
120
+ ---
121
+
122
+ ## 優先級規則
123
+
124
+ 當多個失敗來源並存時:
125
+
126
+ | 規則 | 說明 |
127
+ |------|------|
128
+ | `branch_divergence` > `compilation` | 分支漂移通常是 compilation 失敗的根因 |
129
+ | `policy_violation` > 其他 | 安全優先,不嘗試繞過 |
130
+ | `resource_exhaustion` > 其他 | 資源耗盡時無意義重試 |
131
+ | 其他情況 | 取最先偵測到的來源 |
132
+
133
+ ---
134
+
135
+ ## 整合點
136
+
137
+ ### DevAP
138
+
139
+ - `packages/core/src/types.ts` — `TaskResult.failureSource` / `FailureSource` type
140
+ - `packages/core/src/quality-gate.ts` — `QualityGateResult.failureSource` 推斷
141
+ - `packages/adapter-claude/src/claude-adapter.ts` — `resource_exhaustion` 映射
142
+
143
+ ### VibeOps
144
+
145
+ - `src/types/index.ts` — `IterationRecord.failureSource`(獨立定義,AGPL 隔離)
146
+ - `src/runner/pipeline-runner.ts` — `agent:error` 事件 payload
@@ -0,0 +1,460 @@
1
+ ---
2
+ source: ../../../core/frontend-design-standards.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-20
6
+ status: current
7
+ ---
8
+
9
+ # 前端設計標準
10
+
11
+ > **語言**: [English](../../../core/frontend-design-standards.md) | 繁體中文
12
+
13
+ **版本**: 1.0.0
14
+ **最後更新**: 2026-04-13
15
+ **狀態**: Active
16
+ **適用範圍**: 所有具備前端使用者介面的專案
17
+ **參考**: DEC-029(awesome-design-md, MIT)、DEC-030(OpenAI Frontend Guide)
18
+
19
+ ---
20
+
21
+ ## 目的
22
+
23
+ 本標準定義一套機器可讀的前端設計規格格式(DESIGN.md),用於 AI 輔助開發。建立 9 段式 DESIGN.md 結構、強制設計 token 詞彙、UI 硬性約束,以及反模式拒絕規則。
24
+
25
+ 目標是透過結構化設計約束(而非自由形式的風格描述)確保 AI Agent 在不同執行情境下產生一致、高品質的 UI。
26
+
27
+ **核心原則**:
28
+ - DESIGN.md 是設計規格的唯一真實來源
29
+ - 語意化 token 命名(框架無關)
30
+ - 約束式提示:自由度越少 = UI 品質越高
31
+ - 與原始碼同步進行版本控制
32
+
33
+ ---
34
+
35
+ ## DESIGN.md 結構
36
+
37
+ DESIGN.md 是放在專案根目錄的 Markdown 檔案,作為機器可讀的設計規格書。使用結構化 Markdown,人類與 AI Agent 皆可讀取。
38
+
39
+ ```
40
+ 傳統方式:Figma 設計稿 → 人類開發者 → 程式碼
41
+ 新方式:DESIGN.md → AI Agent → 程式碼
42
+
43
+ DESIGN.md = 給 AI 讀的設計規格書
44
+ - 人類可讀(Markdown 格式)
45
+ - AI 可消費(結構化純文字)
46
+ - 版本控制友善(放在 repo 根目錄)
47
+ - 與程式碼同步演進
48
+ ```
49
+
50
+ ### 必填段落
51
+
52
+ 完整的 DESIGN.md 必須依序包含全部 9 個段落:
53
+
54
+ | # | 段落鍵值 | 必填 | 說明 |
55
+ |---|---------|------|------|
56
+ | 1 | `visual-theme` | 是 | 整體風格與氛圍定義 |
57
+ | 2 | `color-palette` | 是 | 語意色彩 token 與 hex 值 |
58
+ | 3 | `typography` | 是 | 字型家族與字型階層角色 |
59
+ | 4 | `component-styling` | 是 | UI 元件的視覺規則 |
60
+ | 5 | `layout-spacing` | 是 | 間距尺度與格線定義 |
61
+ | 6 | `depth-shadow` | 是 | 層次感與陰影系統 |
62
+ | 7 | `design-guidelines` | 是 | 設計規則與反模式清單 |
63
+ | 8 | `responsive` | 是 | 斷點與響應式規則 |
64
+ | 9 | `agent-prompt-refs` | 是 | AI 可消費的設計意圖摘要 |
65
+
66
+ ---
67
+
68
+ ## 第 1 段:視覺主題與氛圍
69
+
70
+ **目的**:定義產品的整體美學意圖。AI Agent 在生成 UI 時以此作為高層次約束。
71
+
72
+ **必填欄位**:
73
+ - `theme`: 單行風格描述(如「極簡、專業、資料密集」)
74
+ - `mood`: 情感品質(如「沉穩、專注、可信賴」)
75
+ - `inspiration`: 參考產品或設計流派(如「Linear、Stripe dashboard」)
76
+ - `dark-mode`: 深色模式是 primary / secondary / 不支援
77
+
78
+ **範例**:
79
+ ```markdown
80
+ ## Visual Theme & Mood
81
+
82
+ - **Theme**: Minimal, professional, data-dense
83
+ - **Mood**: Calm, focused, trustworthy
84
+ - **Inspiration**: Linear app, Stripe dashboard
85
+ - **Dark Mode**: Primary (dark-first design)
86
+ ```
87
+
88
+ ---
89
+
90
+ ## 第 2 段:色彩系統
91
+
92
+ **目的**:定義完整的語意色彩系統。所有顏色以語意 token 表示,不直接在程式碼中使用原始 hex 值。
93
+
94
+ **必填**:全部 5 個語意 token(詳見[語意色彩 Token](#語意色彩-token))
95
+
96
+ **選填**:狀態延伸 token(error、warning、success、info)、border、overlay。
97
+
98
+ **範例**:
99
+ ```markdown
100
+ ## Color Palette
101
+
102
+ ### Semantic Tokens(必填)
103
+ - **background**: `#0A0A0A` — 頁面背景
104
+ - **surface**: `#1A1A1A` — 卡片、面板、Modal
105
+ - **primary-text**: `#F5F5F5` — 主要正文
106
+ - **muted-text**: `#888888` — 次要文字、placeholder
107
+ - **accent**: `#6366F1` — CTA 按鈕、連結、強調
108
+
109
+ ### Extended Tokens(選填)
110
+ - **error**: `#EF4444`
111
+ - **warning**: `#F59E0B`
112
+ - **success**: `#10B981`
113
+ - **border**: `#2A2A2A`
114
+ ```
115
+
116
+ ---
117
+
118
+ ## 第 3 段:字型系統
119
+
120
+ **目的**:定義字型家族與字型階層角色。約束 AI 最多使用 2 個字型家族。
121
+
122
+ **必填**:全部 4 個字型角色定義(詳見[字型角色](#字型角色))
123
+
124
+ **約束**:最多 2 個字型家族(display + body)。使用 3 個以上屬反模式。
125
+
126
+ **範例**:
127
+ ```markdown
128
+ ## Typography
129
+
130
+ ### Font Families(最多 2 個)
131
+ - **Display font**: Inter(標題、展示文字)
132
+ - **Body font**: Inter(同一家族,不同字重可接受)
133
+
134
+ ### Typographic Scale
135
+ - **display**: 48px+,weight 700,line-height 1.1 — 英雄標題
136
+ - **headline**: 24–32px,weight 600,line-height 1.3 — 段落標題
137
+ - **body**: 16px,weight 400,line-height 1.6 — 主要內文
138
+ - **caption**: 12–14px,weight 400,line-height 1.4 — 標籤、Metadata
139
+ ```
140
+
141
+ ---
142
+
143
+ ## 第 4 段:元件樣式
144
+
145
+ **目的**:定義常見 UI 元件(按鈕、卡片、輸入框、徽章)的視覺規則。
146
+
147
+ **必填欄位**:
148
+ - 圓角尺度
149
+ - 按鈕變體(primary、secondary、ghost)
150
+ - 輸入框樣式
151
+ - 卡片 / surface 樣式
152
+
153
+ **範例**:
154
+ ```markdown
155
+ ## Component Styling
156
+
157
+ ### Border Radius
158
+ - **sm**: 4px(小元素、徽章)
159
+ - **md**: 8px(按鈕、輸入框)
160
+ - **lg**: 12px(卡片、Modal)
161
+ - **full**: 9999px(圓形徽章、頭像)
162
+
163
+ ### Buttons
164
+ - **Primary**: `accent` 背景,`#FFFFFF` 文字,`md` 圓角
165
+ - **Secondary**: `surface` 背景,`primary-text` 文字,`md` 圓角,1px border
166
+ - **Ghost**: 透明背景,`accent` 文字,無 border
167
+
168
+ ### Inputs
169
+ - 背景:`surface`
170
+ - Border:1px solid `border`
171
+ - Focus:2px ring in `accent`
172
+ - 圓角:`md`
173
+ ```
174
+
175
+ ---
176
+
177
+ ## 第 5 段:版面與間距
178
+
179
+ **目的**:定義間距尺度與格線系統。以 8px 基礎格線,定義 7 個間距步驟。
180
+
181
+ **必填**:標準尺度的全部 7 個間距步驟(詳見[間距尺度](#間距尺度))
182
+
183
+ **範例**:
184
+ ```markdown
185
+ ## Layout & Spacing
186
+
187
+ ### Spacing Scale(8px 基礎)
188
+ - **space-1**: 4px
189
+ - **space-2**: 8px
190
+ - **space-3**: 16px
191
+ - **space-4**: 24px
192
+ - **space-5**: 32px
193
+ - **space-6**: 48px
194
+ - **space-8**: 64px
195
+
196
+ ### Grid
197
+ - **欄數**:12 欄格線
198
+ - **Gutter**:space-4(24px)
199
+ - **最大內容寬度**:1280px
200
+ - **頁面 padding**:行動端 space-4(24px),桌面端 space-6(48px)
201
+ ```
202
+
203
+ ---
204
+
205
+ ## 第 6 段:層次感與陰影系統
206
+
207
+ **目的**:以陰影定義高度層次感,不依賴顏色建立視覺階層。
208
+
209
+ **必填**:至少 3 個高度層級。
210
+
211
+ **範例**:
212
+ ```markdown
213
+ ## Depth & Shadow System
214
+
215
+ - **elevation-0**: 無陰影(flat,surface 上的元素)
216
+ - **elevation-1**: `0 1px 2px rgba(0,0,0,0.4)`(細微,靜止狀態卡片)
217
+ - **elevation-2**: `0 4px 8px rgba(0,0,0,0.3)`(下拉選單、tooltip)
218
+ - **elevation-3**: `0 8px 24px rgba(0,0,0,0.5)`(Modal、對話框)
219
+ - **elevation-4**: `0 16px 48px rgba(0,0,0,0.6)`(全螢幕 overlay)
220
+ ```
221
+
222
+ ---
223
+
224
+ ## 第 7 段:設計準則與反模式
225
+
226
+ **目的**:對 AI Agent 明確列出規則和禁止的 UI 模式。此段落是約束式提示的主要機制。
227
+
228
+ **必填子段落**:
229
+ 1. UI 硬性約束(≥4 條規則)
230
+ 2. 反模式清單(≥5 個禁止模式)
231
+
232
+ 詳見 [UI 硬性約束](#ui-硬性約束)與[反模式](#反模式)。
233
+
234
+ **範例**:
235
+ ```markdown
236
+ ## Design Guidelines & Anti-patterns
237
+
238
+ ### UI Hard Constraints
239
+ - 每頁最多 1 個 H1
240
+ - 每頁最多 6 個段落
241
+ - 最多 2 個字型家族
242
+ - 最多 1 個強調色(禁止混用多個強調色)
243
+ - 資訊階層:Hero → Support → Detail → CTA
244
+
245
+ ### Anti-patterns(禁止)
246
+ - 禁止浮動徽章(floating badges)
247
+ - 禁止以通用卡片版面作為主要內容結構
248
+ - 禁止將 dashboard 格線用於首頁
249
+ - 禁止超過 3 層視覺巢狀
250
+ - 禁止純色彩差異(需搭配圖示或文字標籤)
251
+ - 禁止不傳遞資訊的裝飾性插圖
252
+ - 禁止同一畫面出現視覺權重相同的多個 CTA
253
+ ```
254
+
255
+ ---
256
+
257
+ ## 第 8 段:響應式行為
258
+
259
+ **目的**:定義斷點與響應式規則。必須採用 Mobile-first 做法。
260
+
261
+ **必填**:至少 3 個斷點(mobile、tablet、desktop)。
262
+
263
+ **範例**:
264
+ ```markdown
265
+ ## Responsive Behavior
266
+
267
+ ### Breakpoints(Mobile-first)
268
+ - **xs**: < 480px(小螢幕手機)
269
+ - **sm**: ≥ 768px(平板)
270
+ - **md**: ≥ 1024px(筆電)
271
+ - **lg**: ≥ 1280px(桌機)
272
+ - **xl**: ≥ 1536px(寬螢幕)
273
+
274
+ ### Rules
275
+ - Mobile-first CSS(min-width 媒體查詢)
276
+ - xs/sm 單欄,md+ 多欄
277
+ - 行動端觸控目標 ≥ 44×44px
278
+ - sm 以下導覽收合為漢堡選單 / 底部導覽列
279
+ ```
280
+
281
+ ---
282
+
283
+ ## 第 9 段:Agent 提示參考
284
+
285
+ **目的**:設計意圖的精簡 AI 最佳化摘要。AI Agent 應先讀此段作快速定向,再查閱其他段落。
286
+
287
+ **必填欄位**:
288
+ - `style-summary`: 1–2 句設計意圖
289
+ - `key-constraints`: 最關鍵規則的條列清單
290
+ - `tone`: 設計帶給使用者的「感受」
291
+
292
+ **範例**:
293
+ ```markdown
294
+ ## Agent Prompt References
295
+
296
+ ### Style Summary
297
+ 深色、極簡、以資料為核心的介面。優先追求清晰的專業美學,而非裝飾。
298
+
299
+ ### Key Constraints for AI Generation
300
+ - 一律使用語意 token 名稱(background、surface、accent),元件中禁止直接使用 hex 值
301
+ - 每頁只有 1 個 H1;段落 ≤ 6 個
302
+ - accent(#6366F1)是唯一允許的強調色
303
+ - 偏好文字勝於裝飾性元件;克制勝於複雜
304
+
305
+ ### Tone
306
+ 沉穩、自信、技術感。類似 Linear 或 Vercel dashboard 的美學。
307
+ ```
308
+
309
+ ---
310
+
311
+ ## 語意色彩 Token
312
+
313
+ 每個 DESIGN.md **必須**定義以下 5 個語意色彩 token。它們與框架無關,必須使用這些精確名稱。
314
+
315
+ | Token | 角色 | 對應範例 |
316
+ |-------|------|---------|
317
+ | `background` | 頁面 / App 背景 | `#0A0A0A`(深色)/ `#FFFFFF`(淺色)|
318
+ | `surface` | 卡片、面板、Modal | `#1A1A1A`(深色)/ `#F9FAFB`(淺色)|
319
+ | `primary-text` | 主要正文 | `#F5F5F5`(深色)/ `#111827`(淺色)|
320
+ | `muted-text` | 次要文字、placeholder | `#888888`(深色)/ `#6B7280`(淺色)|
321
+ | `accent` | CTA 按鈕、連結、強調 | `#6366F1`(靛藍範例)|
322
+
323
+ **規則**:
324
+ - Token 名稱為 kebab-case,必須完全相符
325
+ - 每個 token 必須定義 hex 值
326
+ - `accent` 必須是單一顏色,禁止多個強調色
327
+ - 延伸 token(error、warning、success)為選填,但必須遵循相同命名模式
328
+
329
+ ---
330
+
331
+ ## 字型角色
332
+
333
+ 每個 DESIGN.md **必須**定義以下 4 個字型角色:
334
+
335
+ | 角色 | 大小 | 字重 | 行高 | 用途 |
336
+ |------|------|------|------|------|
337
+ | `display` | 48px+ | 700 | 1.1 | 英雄標題、展示文字 |
338
+ | `headline` | 24–32px | 600 | 1.3 | 段落標題、卡片標題 |
339
+ | `body` | 16px | 400 | 1.6 | 段落、主要內文 |
340
+ | `caption` | 12–14px | 400 | 1.4 | 標籤、Metadata、輔助文字 |
341
+
342
+ **規則**:
343
+ - 角色名稱為小寫,必須完全相符
344
+ - 4 個角色最多使用 2 個字型家族
345
+ - 字型大小為最小值,響應式縮放可接受
346
+ - `display` 和 `headline` 可共用一個字型家族;`body` 和 `caption` 共用另一個(或相同)
347
+
348
+ ---
349
+
350
+ ## 間距尺度
351
+
352
+ 標準間距尺度以 8px 基礎格線,定義 7 個命名步驟:
353
+
354
+ | Token | 值 | 用途 |
355
+ |-------|-----|------|
356
+ | `space-1` | 4px | 圖示內距、緊湊元素 |
357
+ | `space-2` | 8px | 預設元素內距 |
358
+ | `space-3` | 16px | 元件內部間距 |
359
+ | `space-4` | 24px | 段落內距、Gutter |
360
+ | `space-5` | 32px | 元件之間 |
361
+ | `space-6` | 48px | 主要段落之間 |
362
+ | `space-8` | 64px | 頁面層級分隔 |
363
+
364
+ **規則**:
365
+ - 所有程式碼中的間距必須使用這些步驟 token,不得使用任意 px 值
366
+ - `space-7` 刻意跳過(直接跳到 space-8=64px 維持視覺節奏)
367
+ - 響應式調整仍須使用尺度步驟(如行動端用 space-4,桌面端用 space-6)
368
+
369
+ ---
370
+
371
+ ## UI 硬性約束
372
+
373
+ 以下約束適用於本標準下生成的所有 UI。實作約束式提示:限制自由度可產生品質更高、更一致的 UI。
374
+
375
+ | 約束 | 規則 | 理由 |
376
+ |------|------|------|
377
+ | H1 數量 | 每頁最多 1 個 H1 | 清晰內容階層 |
378
+ | 段落數量 | 每頁最多 6 個段落 | 防止認知過載 |
379
+ | 字型家族 | 最多 2 個字型家族 | 視覺一致性 |
380
+ | 強調色 | 最多 1 個強調色 | 防止視覺噪音 |
381
+ | 巢狀深度 | 最多 3 層視覺巢狀 | 可讀性 |
382
+ | 資訊階層 | Hero → Support → Detail → CTA | 敘事結構 |
383
+ | 觸控目標 | 行動端最小 44×44px | 無障礙設計 |
384
+
385
+ ---
386
+
387
+ ## 反模式
388
+
389
+ 以下 UI 模式為**禁止**。AI Agent 在生成前端程式碼或設計規格時必須拒絕這些模式。
390
+
391
+ | 反模式 | 說明 | 建議替代方案 |
392
+ |--------|------|------------|
393
+ | `floating-badge` | 與內容脫離的浮動徽章 | 行內標籤或狀態指示器 |
394
+ | `generic-card-layout` | 以完全相同的卡片堆疊作為主要內容 | 有清晰階層的多元內容結構 |
395
+ | `dashboard-grid-as-homepage` | 行銷首頁看起來像資料 dashboard | Hero → Support → CTA 敘事首頁 |
396
+ | `competing-ctas` | 同一畫面出現視覺權重相同的多個 CTA | 一個 primary CTA,零或一個 secondary CTA |
397
+ | `color-only-differentiation` | 僅用顏色傳達狀態或類別 | 搭配圖示、圖案或文字標籤 |
398
+ | `decorative-overload` | 不傳遞資訊的插圖或動畫 | 移除裝飾性元素;偏好功能性視覺 |
399
+ | `triple-nesting` | 視覺階層超過 3 層 | 攤平結構;以留白作分隔 |
400
+ | `rainbow-accents` | 多個強調 / 高亮色(紫色 CTA、橙色徽章、綠色標籤)| 單一強調色系統 |
401
+
402
+ 每個 DESIGN.md 的第 7 段必須明確列出至少 5 個反模式。
403
+
404
+ ---
405
+
406
+ ## DESIGN.md 檔案位置
407
+
408
+ DESIGN.md 必須放在**專案根目錄**,與 README.md 同層。
409
+
410
+ ```
411
+ my-project/
412
+ ├── README.md ← 專案概覽(給人看)
413
+ ├── DESIGN.md ← 設計規格(給人 + AI Agent 看)
414
+ ├── CLAUDE.md ← AI 助理設定(如適用)
415
+ ├── src/
416
+ │ └── ...
417
+ └── package.json
418
+ ```
419
+
420
+ **規則**:
421
+ - 檔名:`DESIGN.md`(大小寫必須完全相符)
422
+ - 位置:僅在專案根目錄(不在 `docs/`、`src/` 或子目錄)
423
+ - 格式:使用 `##` 層級段落標題的 Markdown
424
+ - 版本:文件標頭包含版本欄位
425
+ - 更新政策:設計 token 變更時 DESIGN.md 必須同步更新;視為程式碼,而非文件
426
+
427
+ ---
428
+
429
+ ## 驗證清單
430
+
431
+ 使用此清單驗證 DESIGN.md 是否符合本標準:
432
+
433
+ ### 結構
434
+ - [ ] 全部 9 個段落依序存在
435
+ - [ ] 檔案位於專案根目錄(與 README.md 同層)
436
+ - [ ] 檔名精確為 `DESIGN.md`
437
+
438
+ ### 色彩系統(第 2 段)
439
+ - [ ] 定義了全部 5 個語意 token:`background`、`surface`、`primary-text`、`muted-text`、`accent`
440
+ - [ ] 所有 token 都有 hex 值
441
+ - [ ] 只定義了 1 個強調色
442
+
443
+ ### 字型系統(第 3 段)
444
+ - [ ] 定義了全部 4 個角色:`display`、`headline`、`body`、`caption`
445
+ - [ ] 最多使用 2 個字型家族
446
+ - [ ] 字型大小在指定範圍內
447
+
448
+ ### 間距(第 5 段)
449
+ - [ ] 定義了全部 7 個間距步驟:space-1 到 space-8(無 space-7)
450
+ - [ ] 值符合 8px 基礎尺度
451
+
452
+ ### 設計準則(第 7 段)
453
+ - [ ] 列出至少 4 條 UI 硬性約束
454
+ - [ ] 列出至少 5 個反模式
455
+ - [ ] 明確禁止 `floating-badge`、`generic-card-layout`、`dashboard-grid-as-homepage`
456
+
457
+ ### Agent 提示參考(第 9 段)
458
+ - [ ] 風格摘要存在(1–2 句)
459
+ - [ ] 關鍵約束條列清單存在
460
+ - [ ] 氛圍(tone)已定義