universal-dev-standards 5.1.1 → 5.3.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 (65) hide show
  1. package/bundled/ai/options/push/single-owner-mode.ai.yaml +60 -0
  2. package/bundled/ai/options/push/team-mode.ai.yaml +64 -0
  3. package/bundled/ai/options/release/publish-mode-github-actions.ai.yaml +65 -0
  4. package/bundled/ai/standards/agent-behavior-discipline.ai.yaml +142 -0
  5. package/bundled/ai/standards/cd-deployment-strategies.ai.yaml +73 -0
  6. package/bundled/ai/standards/no-cicd-deployment.ai.yaml +134 -0
  7. package/bundled/ai/standards/pipeline-security-gates.ai.yaml +71 -0
  8. package/bundled/ai/standards/push-standards.ai.yaml +105 -0
  9. package/bundled/ai/standards/rollback-standards.ai.yaml +68 -0
  10. package/bundled/core/agent-behavior-discipline.md +178 -0
  11. package/bundled/core/cd-deployment-strategies.md +121 -0
  12. package/bundled/core/no-cicd-deployment.md +205 -0
  13. package/bundled/core/pipeline-security-gates.md +109 -0
  14. package/bundled/core/rollback-standards.md +104 -0
  15. package/bundled/core/versioning.md +1 -1
  16. package/bundled/locales/zh-CN/CHANGELOG.md +34 -3
  17. package/bundled/locales/zh-CN/README.md +54 -7
  18. package/bundled/locales/zh-CN/SECURITY.md +8 -0
  19. package/bundled/locales/zh-CN/core/ai-friendly-architecture.md +8 -0
  20. package/bundled/locales/zh-CN/core/workflow-enforcement.md +8 -0
  21. package/bundled/locales/zh-CN/docs/CHEATSHEET.md +8 -0
  22. package/bundled/locales/zh-CN/docs/CLI-FLOW.md +8 -0
  23. package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +8 -0
  24. package/bundled/locales/zh-CN/docs/STANDARDS-REFERENCE.md +8 -0
  25. package/bundled/locales/zh-CN/skills/commands/requirement.md +8 -0
  26. package/bundled/locales/zh-CN/skills/commands/reverse-bdd.md +8 -0
  27. package/bundled/locales/zh-CN/skills/commands/reverse-sdd.md +8 -0
  28. package/bundled/locales/zh-CN/skills/commands/reverse-tdd.md +8 -0
  29. package/bundled/locales/zh-CN/skills/commands/reverse.md +8 -0
  30. package/bundled/locales/zh-CN/skills/commands/review.md +8 -0
  31. package/bundled/locales/zh-CN/skills/commands/sdd-retro.md +8 -0
  32. package/bundled/locales/zh-CN/skills/commands/sdd.md +8 -0
  33. package/bundled/locales/zh-CN/skills/commands/tdd.md +8 -0
  34. package/bundled/locales/zh-CN/skills/commands/update.md +8 -0
  35. package/bundled/locales/zh-TW/CHANGELOG.md +34 -3
  36. package/bundled/locales/zh-TW/MAINTENANCE.md +17 -6
  37. package/bundled/locales/zh-TW/README.md +53 -6
  38. package/bundled/locales/zh-TW/SECURITY.md +8 -0
  39. package/bundled/locales/zh-TW/adoption/STATIC-DYNAMIC-GUIDE.md +1 -1
  40. package/bundled/locales/zh-TW/core/ai-friendly-architecture.md +8 -0
  41. package/bundled/locales/zh-TW/core/anti-hallucination.md +8 -0
  42. package/bundled/locales/zh-TW/core/git-workflow.md +8 -0
  43. package/bundled/locales/zh-TW/core/refactoring-standards.md +8 -0
  44. package/bundled/locales/zh-TW/core/spec-driven-development.md +8 -0
  45. package/bundled/locales/zh-TW/core/structured-task-definition.md +8 -0
  46. package/bundled/locales/zh-TW/core/test-driven-development.md +8 -0
  47. package/bundled/locales/zh-TW/core/versioning.md +1 -1
  48. package/bundled/locales/zh-TW/core/workflow-enforcement.md +8 -0
  49. package/bundled/locales/zh-TW/core/workflow-state-protocol.md +8 -0
  50. package/bundled/locales/zh-TW/docs/CHEATSHEET.md +8 -0
  51. package/bundled/locales/zh-TW/docs/CLI-FLOW.md +8 -0
  52. package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +8 -0
  53. package/bundled/locales/zh-TW/docs/MIGRATION-V5.md +8 -0
  54. package/bundled/locales/zh-TW/docs/STANDARDS-REFERENCE.md +8 -0
  55. package/bundled/locales/zh-TW/integrations/claude-code/README.md +8 -0
  56. package/bundled/locales/zh-TW/skills/deploy-assistant/SKILL.md +178 -0
  57. package/bundled/skills/deploy-assistant/SKILL.md +183 -0
  58. package/bundled/skills/push/SKILL.md +203 -0
  59. package/package.json +1 -1
  60. package/src/config/ai-agent-paths.js +0 -1
  61. package/standards-registry.json +71 -4
  62. package/bundled/locales/zh-CN/docs/AI-AGENT-ROADMAP.md +0 -410
  63. package/bundled/locales/zh-CN/docs/OPERATION-WORKFLOW.md +0 -1074
  64. package/bundled/locales/zh-TW/docs/AI-AGENT-ROADMAP.md +0 -410
  65. package/bundled/locales/zh-TW/docs/OPERATION-WORKFLOW.md +0 -1074
@@ -1,12 +1,23 @@
1
+ ---
2
+ source: ../../MAINTENANCE.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # 維護指南
2
10
 
3
- > **本文件已合併至 [OPERATION-WORKFLOW.md](../../docs/OPERATION-WORKFLOW.md)。**
11
+ > **維護流程已遷至 AsiaOstrich dev-platform 規劃中心。**
12
+ >
13
+ > 自 v2.0.0 起,所有維護工作流程整合至 `OPERATION-WORKFLOW.md`;自 v5.1.1 起依 DEC-047 遷至內部規劃中心(`cross-project/ops/uds-operation.md`)。
4
14
  >
5
- > v2.0.0 起,所有維護工作流程、檔案同步對照表及目錄參考已整合至單一文件。
15
+ > **Maintenance workflow has moved to the AsiaOstrich dev-platform planning hub.**
6
16
  >
7
- > **This document has been merged into [OPERATION-WORKFLOW.md](../../docs/OPERATION-WORKFLOW.md).**
17
+ > Merged into `OPERATION-WORKFLOW.md` in v2.0.0; migrated to internal planning hub in v5.1.1 per DEC-047.
18
+
19
+ ## 快速參考
8
20
 
9
- ## 快速連結
21
+ 日常維護請遵循 `CLAUDE.md` 中的驗證步驟(§Post-Modification Verification)。
10
22
 
11
- - [Operation Workflow](../../docs/OPERATION-WORKFLOW.md) — 完整維護參考文件
12
- - [歸檔版本](../../docs/archive/MAINTENANCE-v1.md) — 原始獨立指南 (v1.1.0)
23
+ - [歸檔版本 v1.1.0](../../docs/archive/MAINTENANCE-v1.md) — 原始獨立指南
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../README.md
3
+ source_version: 5.2.0
4
+ translation_version: 5.2.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # Universal Development Standards
2
10
 
3
11
  [![npm version](https://img.shields.io/npm/v/universal-dev-standards.svg)](https://www.npmjs.com/package/universal-dev-standards)
@@ -6,7 +14,7 @@
6
14
 
7
15
  > **語言**: [English](../../README.md) | 繁體中文 | [简体中文](../zh-CN/README.md)
8
16
 
9
- **版本**: 5.1.1 | **發布日期**: 2026-04-13 | **授權**: [雙重授權](../../LICENSE) (CC BY 4.0 + MIT)
17
+ **版本**: 5.3.0 | **發布日期**: 2026-04-13 | **授權**: [雙重授權](../../LICENSE) (CC BY 4.0 + MIT)
10
18
 
11
19
  語言無關、框架無關的軟體專案文件標準。透過 AI 原生工作流,確保不同技術堆疊之間的一致性、品質和可維護性。
12
20
 
@@ -55,7 +63,7 @@ npx universal-dev-standards init
55
63
  <!-- UDS_STATS_TABLE_START -->
56
64
  | 類別 | 數量 | 說明 |
57
65
  |----------|-------|-------------|
58
- | **核心標準** | 72 | 通用開發準則 |
66
+ | **核心標準** | 78 | 通用開發準則 |
59
67
  | **AI Skills** | 48 | 互動式技能 |
60
68
  | **斜線命令** | 48 | 快速操作 |
61
69
  | **CLI 指令** | 6 | list, init, configure, check, update, skills |
@@ -72,8 +80,8 @@ UDS 採用 **雙層執行模型 (Dual-Layer Execution Model)**,專為高速互
72
80
  ```mermaid
73
81
  graph TD
74
82
  A[AI 助手 / 開發者] --> B{執行層}
75
- B -- "日常任務" --> C[技能層 Skills (.ai.yaml)]
76
- B -- "深度審查" --> D[標準層 Standards (.md)]
83
+ B -- "日常任務" --> C["技能層 Skills (.ai.yaml)"]
84
+ B -- "深度審查" --> D["標準層 Standards (.md)"]
77
85
 
78
86
  C --> C1[Token 最佳化]
79
87
  C --> C2[互動式引導]
@@ -96,8 +104,8 @@ graph TD
96
104
 
97
105
  | AI 工具 | 狀態 | Skills | 斜線命令 | 設定檔 |
98
106
  | :--- | :--- | :---: | :---: | :--- |
99
- | **Claude Code** | ✅ 完整支援 | **26** | **30** | `CLAUDE.md` |
100
- | **OpenCode** | ✅ 完整支援 | **26** | **30** | `AGENTS.md` |
107
+ | **Claude Code** | ✅ 完整支援 | **29** | **33** | `CLAUDE.md` |
108
+ | **OpenCode** | ✅ 完整支援 | **29** | **33** | `AGENTS.md` |
101
109
  | **Gemini CLI** | 🧪 預覽版 | **18+** | **20+** | `GEMINI.md` |
102
110
  | **Cursor** | ✅ 完整支援 | **核心** | **模擬支援** | `.cursorrules` |
103
111
  | **Cline / Roo Code**| 🔶 部分支援 | **核心** | **工作流** | `.clinerules` |
@@ -145,6 +153,28 @@ uds uninstall # 從專案移除標準
145
153
 
146
154
  ---
147
155
 
156
+ ## 🌐 生態系統
157
+
158
+ UDS 是 AsiaOstrich 三層產品架構中的**標準定義層**:
159
+
160
+ ```
161
+ UDS(定義什麼) → DevAP(代理人如何執行) → VibeOps(完整生命週期)
162
+ ```
163
+
164
+ | 層級 | 產品 | 角色 | 授權 |
165
+ |------|------|------|------|
166
+ | 標準 | **UDS** | 開發方法論框架 | MIT + CC BY 4.0 |
167
+ | 編排 | [DevAP](https://github.com/AsiaOstrich/dev-autopilot) | 代理人無關的編排引擎 | MIT |
168
+ | 生命週期 | [VibeOps](https://github.com/AsiaOstrich/vibeops360) | AI 驅動的軟體工廠 | AGPL-3.0-only |
169
+
170
+ - **UDS** 定義開發標準 → 供 DevAP(品質 Gate)和 VibeOps(代理人管線)使用
171
+ - **DevAP** 使用 UDS 標準編排 AI 代理人 → VibeOps 是其消費者之一
172
+ - **VibeOps** 提供完整軟體生命週期 → 透過 `uds init` 整合 UDS(一次複製)
173
+
174
+ UDS 保持**工具無關性**:支援 Claude Code、OpenCode、Gemini CLI、Cursor、Cline 和 Windsurf。DevAP 和 VibeOps 是消費者,並非必要依賴。
175
+
176
+ ---
177
+
148
178
  ## 📄 授權
149
179
 
150
180
  | 元件 | 授權 |
@@ -152,6 +182,23 @@ uds uninstall # 從專案移除標準
152
182
  | **文件內容** | [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) |
153
183
  | **CLI 工具** | [MIT](../../cli/LICENSE) |
154
184
 
185
+ ## 致謝
186
+
187
+ UDS 的架構靈感來自以下傑出的開源專案:
188
+
189
+ | 專案 | 借鑑概念 | 授權 |
190
+ |------|---------|------|
191
+ | [Superpowers](https://github.com/obra/superpowers) | 系統性除錯、代理人派遣、驗證證據 | MIT |
192
+ | [GSD](https://github.com/gsd-build/get-shit-done) | 結構化任務定義、可追蹤性矩陣、驗證迴圈上限 | MIT |
193
+ | [PAUL](https://github.com/ChristopherKahler/paul) | Plan-Apply-Unify 迴圈、驗收驅動開發 | MIT |
194
+ | [CARL](https://github.com/ChristopherKahler/carl) | 情境感知載入、動態規則注入 | MIT |
195
+ | [CrewAI](https://github.com/crewAIInc/crewAI) | 多代理人通訊協定、情境預算追蹤 | MIT |
196
+ | [LangGraph](https://github.com/langchain-ai/langgraph) | 工作流程狀態協定、HITL 中斷檢查點 | MIT |
197
+ | [OpenHands](https://github.com/All-Hands-AI/OpenHands) | 事件溯源、動作-觀察串流模式 | MIT |
198
+ | [DSPy](https://github.com/stanfordnlp/dspy) | 代理人簽名、結構化 I/O 契約 | MIT |
199
+
200
+ > **注意**:UDS 僅借鑑概念與方法論,不包含上述專案的任何原始碼。
201
+
155
202
  ---
156
203
 
157
204
  **由開源社群用 ❤️ 維護**
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../SECURITY.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # 安全政策
2
10
 
3
11
  ## 支援的版本
@@ -280,7 +280,7 @@ description: |
280
280
  - [CLAUDE.md 範本](../../../templates/CLAUDE.md.template) - 可立即使用的靜態規則範本
281
281
  - [Claude Code Skills](../../../skills/README.md) - 技能安裝指南
282
282
  - [採用指南](ADOPTION-GUIDE.md) - 整體採用策略
283
- - [OPERATION-WORKFLOW.md](../../../docs/OPERATION-WORKFLOW.md) - 如何新增/更新技能(維護者專用)
283
+ - 維護者流程指南 — 見內部規劃中心(`cross-project/ops/uds-operation.md`)
284
284
 
285
285
  ---
286
286
 
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../core/ai-friendly-architecture.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # AI 友善架構標準
2
10
 
3
11
  > **語言**: [English](../../../core/ai-friendly-architecture.md) | 繁體中文
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../core/anti-hallucination.md
3
+ source_version: 1.5.1
4
+ translation_version: 1.5.1
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # 防幻覺規範 (Anti-Hallucination Standards)
2
10
 
3
11
  > **語言**: [English](../../../core/anti-hallucination.md) | 繁體中文
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../core/git-workflow.md
3
+ source_version: 1.4.0
4
+ translation_version: 1.4.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # Git 工作流程標準
2
10
 
3
11
  > **語言**: [English](../../../core/git-workflow.md) | 繁體中文
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../core/refactoring-standards.md
3
+ source_version: 2.1.0
4
+ translation_version: 2.1.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # 重構標準
2
10
 
3
11
  > **語言**: [English](../../../core/refactoring-standards.md) | 繁體中文
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../core/spec-driven-development.md
3
+ source_version: 2.2.0
4
+ translation_version: 2.2.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # 規格驅動開發 (SDD) 標準
2
10
 
3
11
  > **語言**: [English](../../../core/spec-driven-development.md) | 繁體中文
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../core/structured-task-definition.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # 結構化任務定義標準
2
10
 
3
11
  > **語言**: [English](../../../core/structured-task-definition.md) | 繁體中文
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../core/test-driven-development.md
3
+ source_version: 1.2.0
4
+ translation_version: 1.2.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # 測試驅動開發 (TDD) 標準
2
10
 
3
11
  > **語言**: [English](../../../core/test-driven-development.md) | 繁體中文
@@ -242,7 +242,7 @@ CHANGELOG **不應**記錄以下類型的變更:
242
242
  | 類別 | 常見目錄/檔案 | 原因 |
243
243
  |------|--------------|------|
244
244
  | AI 協作輔助 | `.claude/`, `.cursor/`, `.ai/` | 本地開發輔助,不納入版控 |
245
- | 開發規範 | `.standards/`, `docs/internal/` | 本地規範文件,不納入版控 |
245
+ | 開發規範 | `.standards/` | 本地規範文件,不納入版控 |
246
246
  | 建置輸出 | `dist/`, `build/`, `out/` | 建置產物,不納入版控 |
247
247
  | 大型資料 | `data/`, `datasets/` | 資料檔案,不納入版控 |
248
248
 
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../core/workflow-enforcement.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # 工作流程強制執行標準
2
10
 
3
11
  **適用範圍**:所有使用結構化開發方法論的軟體專案
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../core/workflow-state-protocol.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # 工作流程狀態協議
2
10
 
3
11
  > **語言**: [English](../../../core/workflow-state-protocol.md) | 繁體中文
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../docs/CHEATSHEET.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # UDS 速查表
2
10
 
3
11
  > Quick reference for all UDS features | Last updated: 2026-03-24
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../docs/CLI-FLOW.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # CLI 指令流程
2
10
 
3
11
  > **Language**: [English](../../../docs/CLI-FLOW.md) | 繁體中文 | [简体中文](../../zh-CN/docs/CLI-FLOW.md)
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../docs/FEATURE-REFERENCE.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # UDS 功能參考手冊
2
10
 
3
11
  > Universal Development Standards - 完整功能文件
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../docs/archive/MIGRATION-V5.md
3
+ source_version: 5.0.0
4
+ translation_version: 5.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # 遷移指南:Universal Dev Standards V5
2
10
 
3
11
  > **語言**: English | [繁體中文](MIGRATION-V5.md)
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../docs/STANDARDS-REFERENCE.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # UDS 核心規範與業界標準對照表
2
10
  # UDS Core Standards vs Industry Standards Reference
3
11
 
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../../integrations/claude-code/README.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-22
6
+ status: current
7
+ ---
8
+
1
9
  # Claude Code 整合
2
10
 
3
11
  > **語言**: English | [繁體中文](README.md)
@@ -0,0 +1,178 @@
1
+ ---
2
+ name: deploy
3
+ source: ../../../../skills/deploy-assistant/SKILL.md
4
+ source_version: 1.0.0
5
+ translation_version: 1.0.0
6
+ last_synced: 2026-04-26
7
+ status: current
8
+ description: "[UDS] 引導無 CI/CD 平台下的可靠部署 — 生成 deploy.sh、verify.sh、rollback.sh、Makefile"
9
+ allowed-tools: Read, Bash(cat VERSION:*), Bash(git describe:*), Bash(which nginx:*), Bash(which rsync:*)
10
+ argument-hint: "[project type | 專案類型: node/python/docker/go]"
11
+ ---
12
+
13
+ # 無 CI/CD 部署助手
14
+
15
+ > **語言**: [English](../../../../skills/deploy-assistant/SKILL.md) | 繁體中文
16
+
17
+ 在沒有 GitHub Actions 或 GitLab CI 的環境中,引導建立可靠的部署腳本組。採用三層架構:防錯、驗證、回復。
18
+
19
+ ## 三層部署架構
20
+
21
+ ```
22
+ Layer 1: 防止錯誤部署
23
+ └─ set -euo pipefail + 版本 tag 強制 + deploy.lock
24
+
25
+ Layer 2: 驗證部署正確
26
+ └─ Smoke Test + /health 端點 + 版本號比對 + 自動 rollback
27
+
28
+ Layer 3: 快速回復能力
29
+ └─ Blue-Green 切換(Nginx)+ rollback.sh(< 30 秒)
30
+ ```
31
+
32
+ ## 引導式問答
33
+
34
+ Skill 啟動後,AI 助手應詢問:
35
+
36
+ | 問題 | 選項 | 影響 |
37
+ |------|------|------|
38
+ | 專案類型 | node / python / go / docker | 建置命令 |
39
+ | 部署目標 | SSH+rsync / Docker Compose | 傳輸方式 |
40
+ | 是否支援 Blue-Green | yes / no | 生成 rollback.sh |
41
+ | 健康檢查 URL | 輸入 URL | verify.sh 目標 |
42
+ | 版本來源 | VERSION 檔案 / package.json / git tag | 版本比對邏輯 |
43
+
44
+ ## 生成的腳本組
45
+
46
+ ### deploy.sh(主部署腳本)
47
+
48
+ ```bash
49
+ #!/usr/bin/env bash
50
+ set -euo pipefail
51
+
52
+ LOCK_FILE="/tmp/deploy.lock"
53
+ trap "rm -f $LOCK_FILE" EXIT
54
+
55
+ # 防並發
56
+ if [ -f "$LOCK_FILE" ]; then
57
+ echo "❌ 部署進行中(PID: $(cat $LOCK_FILE))"
58
+ exit 1
59
+ fi
60
+ echo $$ > "$LOCK_FILE"
61
+
62
+ # 版本 tag 強制
63
+ CURRENT_TAG=$(git describe --exact-match --tags HEAD 2>/dev/null || echo "")
64
+ if [ -z "$CURRENT_TAG" ]; then
65
+ echo "❌ 請先建立版本 tag:git tag vX.Y.Z && git push --tags"
66
+ exit 1
67
+ fi
68
+
69
+ echo "[1/4] 執行測試..."
70
+ # {TEST_COMMAND}
71
+
72
+ echo "[2/4] 建置產物..."
73
+ # {BUILD_COMMAND}
74
+
75
+ echo "[3/4] 推送到伺服器..."
76
+ rsync -avz --delete ./dist/ {USER}@{SERVER}:/app/
77
+
78
+ echo "[4/4] 驗證部署..."
79
+ ./verify.sh || { echo "驗證失敗,執行 rollback..."; ./rollback.sh; exit 1; }
80
+
81
+ echo "{\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"version\":\"$CURRENT_TAG\",\"operator\":\"$(whoami)\",\"result\":\"success\"}" >> /var/log/deployments.jsonl
82
+ echo "✅ 部署成功:$CURRENT_TAG"
83
+ ```
84
+
85
+ ### verify.sh(Smoke Test)
86
+
87
+ ```bash
88
+ #!/usr/bin/env bash
89
+ set -euo pipefail
90
+
91
+ HEALTH_URL="${HEALTH_URL:-{HEALTH_URL}}"
92
+ EXPECTED_VERSION=$(cat VERSION)
93
+
94
+ for i in $(seq 1 3); do
95
+ RESPONSE=$(curl -sf --max-time 10 "$HEALTH_URL" 2>/dev/null) && break
96
+ echo "健康檢查嘗試 $i/3 失敗,等待 5s..."
97
+ sleep 5
98
+ done
99
+
100
+ ACTUAL_VERSION=$(echo "$RESPONSE" | python3 -c "import json,sys; print(json.load(sys.stdin)['version'])")
101
+
102
+ if [ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]; then
103
+ echo "❌ 版本不符!預期 $EXPECTED_VERSION,實際 $ACTUAL_VERSION"
104
+ exit 1
105
+ fi
106
+
107
+ echo "✅ 版本驗證通過:$ACTUAL_VERSION"
108
+ ```
109
+
110
+ ### rollback.sh(Blue-Green 回滾)
111
+
112
+ ```bash
113
+ #!/usr/bin/env bash
114
+ set -euo pipefail
115
+
116
+ CURRENT=$(readlink /app/current 2>/dev/null || echo "/app/blue")
117
+ TARGET=$([[ "$CURRENT" == *"green"* ]] && echo "/app/blue" || echo "/app/green")
118
+
119
+ ln -sfn "$TARGET" /app/current
120
+ nginx -s reload
121
+
122
+ echo "✅ 已切回 $TARGET($(date -u +%Y-%m-%dT%H:%M:%SZ))"
123
+ echo "{\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"event\":\"rollback\",\"from\":\"$CURRENT\",\"to\":\"$TARGET\",\"operator\":\"$(whoami)\"}" >> /var/log/deployments.jsonl
124
+ ```
125
+
126
+ ### Makefile
127
+
128
+ ```makefile
129
+ .PHONY: deploy rollback verify status
130
+
131
+ deploy:
132
+ @./deploy.sh
133
+
134
+ rollback:
135
+ @./rollback.sh
136
+
137
+ verify:
138
+ @./verify.sh
139
+
140
+ status:
141
+ @echo "Current slot: $$(readlink /app/current 2>/dev/null || echo 'N/A')"
142
+ @curl -s $${HEALTH_URL:-http://localhost/health} | python3 -m json.tool 2>/dev/null || echo "Health check failed"
143
+ ```
144
+
145
+ ## 使用方式
146
+
147
+ ```bash
148
+ /deploy # 互動式引導,自動偵測專案類型
149
+ /deploy node # 指定 Node.js 專案直接生成
150
+ /deploy docker # Docker Compose 部署模式
151
+ /deploy --verify-only # 只生成 verify.sh
152
+ ```
153
+
154
+ ## 輸出確認清單
155
+
156
+ 生成後,AI 助手必須確認:
157
+
158
+ - [ ] `deploy.sh` 包含 `set -euo pipefail`
159
+ - [ ] `deploy.sh` 包含 deploy.lock 防並發邏輯
160
+ - [ ] `verify.sh` 比對版本號(不只檢查 HTTP 200)
161
+ - [ ] `rollback.sh` 在驗證失敗時自動觸發
162
+ - [ ] `Makefile` 提供 `make deploy / make rollback / make status`
163
+
164
+ ## 下一步引導
165
+
166
+ `/deploy` 完成後,AI 助手應建議:
167
+
168
+ > **部署腳本已生成。建議下一步:**
169
+ > - `chmod +x deploy.sh verify.sh rollback.sh` — 設定執行權限
170
+ > - `make verify` — 測試健康檢查設定
171
+ > - `git tag v1.0.0 && git push --tags` — 建立版本 tag
172
+ > - `make deploy` — 執行第一次部署
173
+
174
+ ## 參考
175
+
176
+ - 核心標準:[no-cicd-deployment.md](../../../../core/no-cicd-deployment.md)
177
+ - 核心標準:[deployment-standards.md](../../../../core/deployment-standards.md)
178
+ - 相關 Skill:[ci-cd-assistant](../../skills/ci-cd-assistant/SKILL.md) — 有 CI/CD 平台的場景