universal-dev-standards 5.13.3 → 5.15.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 (71) hide show
  1. package/bin/uds.js +2 -0
  2. package/bundled/ai/standards/ai-instruction-standards.ai.yaml +190 -3
  3. package/bundled/ai/standards/knowledge-graph-memory.ai.yaml +83 -0
  4. package/bundled/core/ai-instruction-standards.md +136 -11
  5. package/bundled/core/knowledge-graph-memory.md +119 -0
  6. package/bundled/locales/COVERAGE.md +226 -0
  7. package/bundled/locales/zh-CN/CHANGELOG.md +43 -3
  8. package/bundled/locales/zh-CN/README.md +1 -1
  9. package/bundled/locales/zh-CN/SECURITY.md +1 -1
  10. package/bundled/locales/zh-CN/core/ai-instruction-standards.md +111 -5
  11. package/bundled/locales/zh-TW/CHANGELOG.md +47 -3
  12. package/bundled/locales/zh-TW/README.md +1 -1
  13. package/bundled/locales/zh-TW/SECURITY.md +1 -1
  14. package/bundled/locales/zh-TW/core/ai-instruction-standards.md +130 -5
  15. package/bundled/locales/zh-TW/core/knowledge-graph-memory.md +127 -0
  16. package/bundled/locales/zh-TW/core/self-review-protocol.md +9 -1
  17. package/bundled/locales/zh-TW/skills/ac-coverage/SKILL.md +192 -0
  18. package/bundled/locales/zh-TW/skills/ai-collaboration-standards/SKILL.md +5 -1
  19. package/bundled/locales/zh-TW/skills/deploy-assistant/SKILL.md +187 -0
  20. package/bundled/locales/zh-TW/skills/dev-methodology/SKILL.md +108 -0
  21. package/bundled/locales/zh-TW/skills/journey-test-assistant/SKILL.md +222 -0
  22. package/bundled/locales/zh-TW/skills/knowledge-graph/SKILL.md +56 -0
  23. package/bundled/locales/zh-TW/skills/orchestrate/SKILL.md +172 -0
  24. package/bundled/locales/zh-TW/skills/plan/SKILL.md +239 -0
  25. package/bundled/locales/zh-TW/skills/project-structure-guide/SKILL.md +5 -1
  26. package/bundled/locales/zh-TW/skills/push/SKILL.md +241 -0
  27. package/bundled/locales/zh-TW/skills/skill-builder/SKILL.md +165 -0
  28. package/bundled/locales/zh-TW/skills/spec-derivation/SKILL.md +83 -0
  29. package/bundled/locales/zh-TW/skills/sweep/SKILL.md +149 -0
  30. package/bundled/skills/adr-assistant/SKILL.md +1 -1
  31. package/bundled/skills/ai-collaboration-standards/SKILL.md +1 -1
  32. package/bundled/skills/ai-friendly-architecture/SKILL.md +1 -1
  33. package/bundled/skills/ai-instruction-standards/SKILL.md +1 -1
  34. package/bundled/skills/api-design-assistant/SKILL.md +1 -1
  35. package/bundled/skills/audit-assistant/SKILL.md +1 -1
  36. package/bundled/skills/ci-cd-assistant/SKILL.md +1 -1
  37. package/bundled/skills/contract-test-assistant/SKILL.md +1 -1
  38. package/bundled/skills/database-assistant/SKILL.md +1 -1
  39. package/bundled/skills/deploy-assistant/SKILL.md +1 -1
  40. package/bundled/skills/documentation-guide/SKILL.md +1 -1
  41. package/bundled/skills/error-code-guide/SKILL.md +1 -1
  42. package/bundled/skills/git-workflow-guide/SKILL.md +1 -1
  43. package/bundled/skills/incident-response-assistant/SKILL.md +1 -1
  44. package/bundled/skills/journey-test-assistant/SKILL.md +1 -1
  45. package/bundled/skills/knowledge-graph/SKILL.md +58 -0
  46. package/bundled/skills/knowledge-graph/guide.md +69 -0
  47. package/bundled/skills/logging-guide/SKILL.md +1 -1
  48. package/bundled/skills/observability-assistant/SKILL.md +1 -1
  49. package/bundled/skills/orchestrate/SKILL.md +1 -1
  50. package/bundled/skills/plan/SKILL.md +1 -1
  51. package/bundled/skills/pr-automation-assistant/SKILL.md +1 -1
  52. package/bundled/skills/project-structure-guide/SKILL.md +1 -1
  53. package/bundled/skills/push/SKILL.md +1 -1
  54. package/bundled/skills/retrospective-assistant/SKILL.md +1 -1
  55. package/bundled/skills/reverse-engineer/SKILL.md +1 -1
  56. package/bundled/skills/runbook-assistant/SKILL.md +1 -1
  57. package/bundled/skills/security-assistant/SKILL.md +1 -1
  58. package/bundled/skills/security-scan-assistant/SKILL.md +1 -1
  59. package/bundled/skills/slo-assistant/SKILL.md +1 -1
  60. package/bundled/skills/sweep/SKILL.md +1 -1
  61. package/bundled/skills/testing-guide/SKILL.md +1 -1
  62. package/package.json +1 -1
  63. package/src/commands/check.js +91 -1
  64. package/src/commands/init.js +8 -1
  65. package/src/commands/update.js +49 -14
  66. package/src/i18n/messages.js +32 -5
  67. package/src/installers/skills-installer.js +49 -0
  68. package/src/lint/i18n.js +338 -0
  69. package/src/utils/config-manager.js +39 -0
  70. package/src/utils/skills-installer.js +39 -7
  71. package/standards-registry.json +16 -4
@@ -0,0 +1,187 @@
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-05-28
7
+ scope: universal
8
+ description: |
9
+ [UDS] 無 CI/CD 平台環境下的可靠部署指引(不依賴 GitHub Actions / GitLab CI)。
10
+ Use when: deploying to VPS, air-gapped servers, or environments without CI/CD infrastructure.
11
+ Keywords: deployment, no-cicd, shell script, blue-green, smoke test, rollback, 無CI/CD, 部署.
12
+ allowed-tools: Read, Bash(cat VERSION:*), Bash(git describe:*), Bash(which nginx:*), Bash(which rsync:*)
13
+ argument-hint: "[專案類型: node/python/docker/go]"
14
+ ---
15
+
16
+ # 無 CI/CD 部署助手
17
+
18
+ > **語言**: [English](../../../../skills/deploy-assistant/SKILL.md) | 繁體中文
19
+
20
+ 引導無 CI/CD 平台環境下的可靠部署,採用三層架構:防錯、驗證、快速回復。
21
+
22
+ ## 三層部署架構
23
+
24
+ ```
25
+ Layer 1:防止錯誤部署 Layer 2:驗證正確性 Layer 3:快速回復
26
+ set -euo pipefail Smoke Test + /health Blue-Green 切換
27
+ 版本 tag 強制 版本號比對 rollback.sh < 30s
28
+ deploy.lock 並發守衛 驗證失敗自動回滾
29
+ ```
30
+
31
+ ## 引導式問答
32
+
33
+ | 問題 | 選項 | 影響 |
34
+ |------|------|------|
35
+ | 專案類型 | node / python / go / docker | 建置指令 |
36
+ | 部署目標 | SSH+rsync / Docker Compose | 傳輸方式 |
37
+ | Blue-Green 支援 | yes / no | rollback.sh 是否生成 |
38
+ | 健康檢查 URL | URL 輸入 | verify.sh 目標 |
39
+ | 版本來源 | VERSION 檔 / package.json / git tag | 版本比對邏輯 |
40
+
41
+ ## 生成的腳本組
42
+
43
+ ### deploy.sh — 主要部署腳本
44
+
45
+ ```bash
46
+ #!/usr/bin/env bash
47
+ set -euo pipefail
48
+
49
+ LOCK_FILE="/tmp/deploy.lock"
50
+ trap "rm -f $LOCK_FILE" EXIT
51
+
52
+ # 防並發守衛
53
+ if [ -f "$LOCK_FILE" ]; then
54
+ echo "❌ 已有部署進行中(PID: $(cat $LOCK_FILE))"
55
+ exit 1
56
+ fi
57
+ echo $$ > "$LOCK_FILE"
58
+
59
+ # 版本 tag 強制
60
+ CURRENT_TAG=$(git describe --exact-match --tags HEAD 2>/dev/null || echo "")
61
+ if [ -z "$CURRENT_TAG" ]; then
62
+ echo "❌ HEAD 沒有版本 tag。請執行:git tag vX.Y.Z && git push --tags"
63
+ exit 1
64
+ fi
65
+
66
+ echo "[1/4] 執行測試..."
67
+ # {TEST_COMMAND}
68
+
69
+ echo "[2/4] 建置產物..."
70
+ # {BUILD_COMMAND}
71
+
72
+ echo "[3/4] 同步至伺服器..."
73
+ rsync -avz --delete ./dist/ {USER}@{SERVER}:/app/
74
+
75
+ echo "[4/4] 驗證部署..."
76
+ ./verify.sh || { echo "驗證失敗,啟動回滾..."; ./rollback.sh; exit 1; }
77
+
78
+ echo "{\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"version\":\"$CURRENT_TAG\",\"operator\":\"$(whoami)\",\"result\":\"success\"}" >> /var/log/deployments.jsonl
79
+ echo "✅ 部署成功:$CURRENT_TAG"
80
+ ```
81
+
82
+ ### verify.sh — Smoke Test
83
+
84
+ ```bash
85
+ #!/usr/bin/env bash
86
+ set -euo pipefail
87
+
88
+ HEALTH_URL="${HEALTH_URL:-{HEALTH_URL}}"
89
+ EXPECTED_VERSION=$(cat VERSION)
90
+
91
+ for i in $(seq 1 3); do
92
+ RESPONSE=$(curl -sf --max-time 10 "$HEALTH_URL" 2>/dev/null) && break
93
+ echo "健康檢查第 $i/3 次失敗,5 秒後重試..."
94
+ sleep 5
95
+ done
96
+
97
+ ACTUAL_VERSION=$(echo "$RESPONSE" | python3 -c "import json,sys; print(json.load(sys.stdin)['version'])")
98
+
99
+ if [ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]; then
100
+ echo "❌ 版本不符!預期 $EXPECTED_VERSION,實際 $ACTUAL_VERSION"
101
+ exit 1
102
+ fi
103
+
104
+ echo "✅ 版本驗證通過:$ACTUAL_VERSION"
105
+ ```
106
+
107
+ ### rollback.sh — Blue-Green 回滾
108
+
109
+ ```bash
110
+ #!/usr/bin/env bash
111
+ set -euo pipefail
112
+
113
+ CURRENT=$(readlink /app/current 2>/dev/null || echo "/app/blue")
114
+ TARGET=$([[ "$CURRENT" == *"green"* ]] && echo "/app/blue" || echo "/app/green")
115
+
116
+ ln -sfn "$TARGET" /app/current
117
+ nginx -s reload
118
+
119
+ echo "✅ 已回滾至 $TARGET ($(date -u +%Y-%m-%dT%H:%M:%SZ))"
120
+ echo "{\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"event\":\"rollback\",\"from\":\"$CURRENT\",\"to\":\"$TARGET\",\"operator\":\"$(whoami)\"}" >> /var/log/deployments.jsonl
121
+ ```
122
+
123
+ ### Makefile
124
+
125
+ ```makefile
126
+ .PHONY: deploy rollback verify status
127
+
128
+ deploy:
129
+ @./deploy.sh
130
+
131
+ rollback:
132
+ @./rollback.sh
133
+
134
+ verify:
135
+ @./verify.sh
136
+
137
+ status:
138
+ @echo "目前 slot:$$(readlink /app/current 2>/dev/null || echo 'N/A')"
139
+ @curl -s $${HEALTH_URL:-http://localhost/health} | python3 -m json.tool 2>/dev/null || echo "健康檢查失敗"
140
+ ```
141
+
142
+ ## 輸出確認清單
143
+
144
+ 腳本生成後,AI 助手必須確認:
145
+
146
+ - [ ] `deploy.sh` 含 `set -euo pipefail`
147
+ - [ ] `deploy.sh` 含 deploy.lock 並發守衛
148
+ - [ ] `verify.sh` 比對版本號(不只是 HTTP 200)
149
+ - [ ] `rollback.sh` 在 verify 失敗時自動觸發
150
+ - [ ] `Makefile` 提供 `make deploy / make rollback / make status`
151
+
152
+ ## 使用方式
153
+
154
+ ```bash
155
+ /deploy # 互動模式 — 自動偵測專案類型
156
+ /deploy node # Node.js 專案,直接生成
157
+ /deploy docker # Docker Compose 部署模式
158
+ /deploy --verify-only # 僅生成 verify.sh
159
+ ```
160
+
161
+ ## 下一步引導
162
+
163
+ `/deploy` 完成後,AI 助手應建議:
164
+
165
+ > **部署腳本已生成,建議下一步:**
166
+ > - `chmod +x deploy.sh verify.sh rollback.sh` — 設定執行權限
167
+ > - `make verify` — 測試健康檢查設定
168
+ > - `git tag v1.0.0 && git push --tags` — 建立版本 tag
169
+ > - `make deploy` — 執行第一次部署
170
+
171
+ ## 參考
172
+
173
+ - 核心標準:[no-cicd-deployment.md](../../../../core/no-cicd-deployment.md)
174
+ - 核心標準:[deployment-standards.md](../../../../core/deployment-standards.md)
175
+ - 核心標準:[deployment-standards.md § Defensive Deployment Ordering](../../../../core/deployment-standards.md#defensive-deployment-ordering) — **強制**遵循 extract-verify-then-delete 順序
176
+ - 核心標準:[packaging-standards.md § Archive Format Integrity](../../../../core/packaging-standards.md#archive-format-integrity) — 消費 archive 前先驗證格式
177
+ - 相關:[ci-cd-assistant](../ci-cd-assistant/SKILL.md) — 適用於有 CI/CD 的環境
178
+
179
+ ## 版本歷史
180
+
181
+ | 版本 | 日期 | 變更說明 |
182
+ |------|------|----------|
183
+ | 1.0.0 | 2026-04-26 | 初始版本 — XSPEC-085 Phase 1b |
184
+
185
+ ## 授權
186
+
187
+ CC BY 4.0 — 文件內容
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: methodology
3
+ source: ../../../../skills/dev-methodology/SKILL.md
4
+ source_version: 1.0.0
5
+ translation_version: 1.0.0
6
+ last_synced: 2026-05-28
7
+ scope: partial
8
+ description: |
9
+ [UDS] /methodology: 選擇並追蹤開發方法論(SDD/BDD/TDD)。
10
+ Use when: 選擇方法論、切換開發模式、查詢當前方法論狀態。
11
+ 若要查詢各階段對應指令請用 /dev-workflow。
12
+ allowed-tools: Read, Write, Grep, Glob
13
+ argument-hint: "[動作] [參數]"
14
+ ---
15
+
16
+ # 方法論系統
17
+
18
+ > **語言**: [English](../../../../skills/dev-methodology/SKILL.md) | 繁體中文
19
+
20
+ > [!WARNING]
21
+ > **實驗性功能**
22
+ >
23
+ > 此功能正在積極開發中,可能在 v4.0 中有重大變更。
24
+
25
+ 選擇並管理當前專案啟用的開發方法論。本技能專注於**選擇使用哪種方法論**(SDD、BDD、TDD),並追蹤所選方法論內的階段進度。
26
+
27
+ > **相關**:如需查詢開發階段對應的 UDS 指令,請改用 `/dev-workflow`。
28
+
29
+ ### 何時使用 `/methodology` 與 `/dev-workflow`
30
+
31
+ | 情境 | `/methodology` | `/dev-workflow` |
32
+ |------|---------------|-----------------|
33
+ | 在 SDD / BDD / TDD 之間選擇 | ✅ | ❌ |
34
+ | 切換不同方法論 | ✅ | ❌ |
35
+ | 追蹤目前階段進度 | ✅ | ❌ |
36
+ | 找出某個任務該用的 UDS 指令 | ❌ | ✅ |
37
+ | 取得新功能 / Bug 修復的逐步流程 | ❌ | ✅ |
38
+ | 巡覽 8 個開發階段 | ❌ | ✅ |
39
+
40
+ **兩個獨立系統:**
41
+ - **System A:SDD** — 規格驅動開發(AI 時代,spec-first)
42
+ - **System B:雙迴圈 TDD** — BDD(外圈)+ TDD(內圈)(傳統)
43
+
44
+ **選用輸入:** ATDD — 驗收測試驅動開發(可餵入任一系統)
45
+
46
+ ## 動作
47
+
48
+ | 動作 | 說明 |
49
+ |------|------|
50
+ | *(無)* / `status` | 顯示當前階段與檢查清單 |
51
+ | `switch <id>` | 切換到不同方法論 |
52
+ | `phase [name]` | 顯示或變更當前階段 |
53
+ | `checklist` | 顯示當前階段檢查清單 |
54
+ | `skip` | 跳過當前階段(會出現警告) |
55
+ | `list` | 列出可用方法論 |
56
+ | `create` | 建立自訂方法論 |
57
+
58
+ ## 可用方法論
59
+
60
+ | 系統 | ID | 工作流程 | 說明 |
61
+ |------|-----|----------|------|
62
+ | A: SDD | `sdd` | /sdd → 審查 → /derive-all → 實作 | 規格優先 |
63
+ | B: BDD | `bdd` | Discovery → Formulation → Automation | 外部迴圈 |
64
+ | B: TDD | `tdd` | Red → Green → Refactor | 內部迴圈 |
65
+ | 輸入 | `atdd` | Workshop → Examples → Tests | 驗收測試驅動 |
66
+
67
+ ## 使用範例
68
+
69
+ ```bash
70
+ /methodology # 顯示目前狀態
71
+ /methodology switch sdd # 切換至規格驅動開發
72
+ /methodology phase green # 移動到 GREEN 階段(TDD)
73
+ /methodology checklist # 顯示當前階段檢查清單
74
+ /methodology list # 列出所有可用方法論
75
+ /methodology skip # 跳過當前階段(會出現警告)
76
+ /methodology create # 啟動自訂方法論精靈
77
+ ```
78
+
79
+ ## 配置
80
+
81
+ 方法論設定儲存於 `.standards/manifest.json`:
82
+
83
+ ```json
84
+ {
85
+ "methodology": {
86
+ "active": "sdd",
87
+ "available": ["tdd", "bdd", "sdd", "atdd"]
88
+ }
89
+ }
90
+ ```
91
+
92
+ ## 下一步引導
93
+
94
+ `/methodology` 完成後,AI 助手應依所選方法論建議下一步:
95
+
96
+ > **方法論已設定。建議下一步:**
97
+ > - SDD 方法論 → 執行 `/sdd` 建立規格 ⭐ **推薦**
98
+ > - BDD 方法論 → 執行 `/bdd` 開始場景探索
99
+ > - TDD 方法論 → 執行 `/tdd` 開始紅綠重構
100
+ > - ATDD 方法論 → 執行 `/atdd` 定義驗收條件
101
+
102
+ ## 參考
103
+
104
+ - 詳細指南:[guide.md](./guide.md)
105
+
106
+ ## AI 代理行為
107
+
108
+ > 完整的 AI 行為定義請參閱對應的命令文件:[`/methodology`](../../../../skills/commands/methodology.md#ai-agent-behavior--ai-代理行為)
@@ -0,0 +1,222 @@
1
+ ---
2
+ name: journey-test-assistant
3
+ source: ../../../../skills/journey-test-assistant/SKILL.md
4
+ source_version: 1.0.0
5
+ translation_version: 1.0.0
6
+ last_synced: 2026-05-28
7
+ scope: partial
8
+ description: "[UDS] 從專案描述生成連貫使用者旅程測試計畫(TESTPLAN)與 E2E 骨架"
9
+ allowed-tools: Read, Write, Grep, Glob
10
+ argument-hint: "[專案描述 | --analyze | --archetype A1|A2|A3]"
11
+ status: stable
12
+ ---
13
+
14
+ # 旅程測試助手
15
+
16
+ > **語言**: [English](../../../../skills/journey-test-assistant/SKILL.md) | 繁體中文
17
+
18
+ 從專案描述生成連貫的使用者旅程測試計畫(TESTPLAN-NNN.md)與對應的 E2E 骨架,讓每個新專案從第一天起就擁有完整測試旅程。
19
+
20
+ ## 選擇正確的測試 Skill
21
+
22
+ | 需求 | 使用 |
23
+ |------|------|
24
+ | 單元測試 / TDD 紅綠重構 | `/tdd-assistant` |
25
+ | BDD 場景 / Given-When-Then | `/bdd-assistant` |
26
+ | 驗收測試 / ATDD / 使用者故事 | `/atdd-assistant` |
27
+ | E2E / Playwright / 瀏覽器測試 | `/e2e-assistant` |
28
+ | 合約測試 / API consumer-driven | `/contract-test-assistant` |
29
+ | 測試覆蓋率差距分析 | `/test-coverage-assistant` |
30
+ | 使用者旅程測試計畫 | `/journey-test-assistant` |
31
+ | 一般測試策略 / 測試金字塔 | `/testing-guide` |
32
+
33
+ ## 與 /e2e 的差異
34
+
35
+ | 維度 | /e2e | /journey-test |
36
+ |------|------|--------------|
37
+ | 組織單位 | 單一 XSPEC / AC | 跨 Story 的使用者旅程 |
38
+ | 測試結構 | 隔離、獨立 | 連貫、狀態共享 |
39
+ | 產物 | `*.spec.ts` 骨架 | `TESTPLAN.md` + `*.journey.spec.ts` |
40
+ | 觸發時機 | 功能完成後 | 專案建立時(Journey-First) |
41
+ | 偵測目標 | 單一 AC 是否正確 | 跨步驟狀態傳遞是否連貫 |
42
+
43
+ ## 工作流程
44
+
45
+ ```
46
+ 輸入:專案描述 / 現有 TESTPLAN / --analyze
47
+
48
+ Phase 1:定義 Persona
49
+ 分析專案描述 → 識別所有使用者角色 → 定義 Actor / Role / Key Permissions
50
+
51
+ Phase 2:設計旅程地圖
52
+ 列出主要業務目標 → 拆解為 T-NNN 群組 → 宣告依賴鏈
53
+
54
+ Phase 3:生成 TESTPLAN
55
+ 按格式輸出 test-plans/TESTPLAN-001.md(含 Personas、步驟、依賴圖)
56
+
57
+ Phase 4:生成 E2E 骨架
58
+ 從 TESTPLAN T-NNN 生成 *.journey.spec.ts(含 skipIf + 共享 state)
59
+ ```
60
+
61
+ ## 模式
62
+
63
+ ### 1. 生成模式(預設)
64
+
65
+ 從專案描述生成完整的 TESTPLAN + E2E 骨架。
66
+
67
+ ```
68
+ /journey-test "電商平台,需要 buyer/seller/admin 三個角色"
69
+ ```
70
+
71
+ 產物:
72
+ - `test-plans/TESTPLAN-001.md`:含 Personas、T-000 環境重置、T-001 ~ T-NNN 步驟群組、執行順序依賴圖
73
+ - `src/e2e/journey/main-flow.journey.spec.ts`:含 `describe.skipIf` + 共享 state + T-NNN 對應的完整骨架
74
+
75
+ ### 2. 分析模式(--analyze)
76
+
77
+ 掃描現有測試,找出旅程覆蓋缺口。
78
+
79
+ ```
80
+ /journey-test --analyze
81
+ ```
82
+
83
+ 執行步驟:
84
+ 1. 讀取 `test-plans/TESTPLAN-NNN.md`(若存在)
85
+ 2. 掃描 `src/e2e/` 下所有 `*.journey.spec.ts` 與 `*.journey.e2e.test.ts`
86
+ 3. 比對 TESTPLAN T-NNN 與自動化測試中的 T-NNN 引用
87
+ 4. 輸出覆蓋缺口報告:列出 TESTPLAN 中缺乏自動化對應的 T-NNN 步驟
88
+
89
+ ### 3. Archetype 模式(--archetype)
90
+
91
+ 使用預設旅程模板,適合已知類型的專案快速啟動。
92
+
93
+ ```
94
+ /journey-test --archetype A1 # Spec-driven 旅程
95
+ /journey-test --archetype A2 # UI-driven 旅程
96
+ /journey-test --archetype A3 # Brownfield 旅程
97
+ ```
98
+
99
+ | Archetype | 模板 | 適用場景 |
100
+ |-----------|------|---------|
101
+ | A1 | Spec-driven | 需求 → Spec → Code → Test,適合 API / Backend 專案 |
102
+ | A2 | UI-driven | 設計稿 → UI → 視覺回歸,適合前端 / 全端專案 |
103
+ | A3 | Brownfield | 現有程式碼 → 分析 → 重構驗證,適合既有專案補測試 |
104
+
105
+ ## TESTPLAN 格式(T-NNN)
106
+
107
+ 以下為完整的 TESTPLAN 範本,展示所有必要區段:
108
+
109
+ ```markdown
110
+ # TESTPLAN-001 <ProjectName> 主線旅程
111
+
112
+ ## Personas
113
+
114
+ | Actor | Role | Key Permissions |
115
+ |----------------|----------------|--------------------------------|
116
+ | platform_admin | Platform Admin | 建立 Org、管理使用者、查看所有資源 |
117
+ | org_member | Org Member | 讀取專案、執行 Pipeline |
118
+
119
+ ## Environment
120
+
121
+ - BASE_URL:`http://localhost:3000`(本機) / `$JOURNEY_BASE_URL`(CI)
122
+ - 驗證指令:`curl $BASE_URL/health`
123
+ - 必要帳號:`ADMIN_EMAIL`、`ADMIN_PASSWORD` 環境變數
124
+
125
+ ## T-000 環境重置(optional)
126
+
127
+ 前置條件:無
128
+ depends_on:無
129
+
130
+ | 步驟 | 操作 | 預期結果 |
131
+ |---------|-------------------------------|---------------|
132
+ | T-000-1 | [API] GET /health | 回傳 200 OK |
133
+ | T-000-2 | [CHECK] 資料庫連線正常 | 無錯誤日誌 |
134
+
135
+ ## T-001 Platform Admin 登入
136
+
137
+ 前置條件:環境正常運行(T-000 通過)
138
+ depends_on:T-000
139
+
140
+ | 步驟 | 操作 | 預期結果 |
141
+ |---------|--------------------------------------------|-------------------------|
142
+ | T-001-1 | [API] POST /api/auth/login(admin 帳號) | 回傳 200 + authToken |
143
+ | T-001-2 | [CHECK] authToken 存入共享 state | let authToken 有值 |
144
+
145
+ ## T-010 主要功能操作
146
+
147
+ 前置條件:authToken 已取得(T-001 通過)
148
+ depends_on:T-001
149
+
150
+ | 步驟 | 操作 | 預期結果 |
151
+ |---------|--------------------------------------------|-------------------------|
152
+ | T-010-1 | [API] POST /api/resources(帶 authToken) | 回傳 201 + resourceId ★ |
153
+ | T-010-2 | [CHECK] resourceId 存入共享 state | let resourceId 有值 |
154
+
155
+ ## 執行順序依賴圖
156
+
157
+ T-000 → T-001 → T-010
158
+ ```
159
+
160
+ ## E2E 骨架格式(.journey.spec.ts)
161
+
162
+ 生成的骨架展示三個核心模式:`describe.skipIf` 環境保護、共享 `let` 狀態、T-NNN 識別碼對應。
163
+
164
+ ```typescript
165
+ import { describe, it, expect } from "vitest"
166
+
167
+ // Journey E2E:需要真實後端,不設定 JOURNEY_BASE_URL 則全部 skip
168
+ const BASE_URL = process.env.JOURNEY_BASE_URL || ""
169
+
170
+ describe.skipIf(!BASE_URL)("Platform Admin Journey — T-001 → T-010", () => {
171
+ // 共享 state:每個步驟從前一步驟的結果取值
172
+ let authToken: string
173
+ let resourceId: string
174
+
175
+ it("T-001: Platform Admin 登入並取得 authToken", async () => {
176
+ const res = await fetch(`${BASE_URL}/api/auth/login`, {
177
+ method: "POST",
178
+ headers: { "Content-Type": "application/json" },
179
+ body: JSON.stringify({
180
+ email: process.env.ADMIN_EMAIL,
181
+ password: process.env.ADMIN_PASSWORD,
182
+ }),
183
+ })
184
+ expect(res.status, "T-001 失敗:登入應回傳 200").toBe(200)
185
+ const data = await res.json()
186
+ expect(data.token, "T-001 失敗:應有 token").toBeTruthy()
187
+ authToken = data.token // ← 傳遞給後續步驟
188
+ })
189
+
190
+ it("T-010: 執行主要操作(depends on T-001)", async () => {
191
+ // 若 T-001 失敗,authToken 為 undefined,此步驟的錯誤訊息會清楚說明
192
+ expect(authToken, "T-010 前置失敗:T-001 的 authToken 不存在").toBeTruthy()
193
+
194
+ const res = await fetch(`${BASE_URL}/api/resources`, {
195
+ method: "POST",
196
+ headers: {
197
+ "Content-Type": "application/json",
198
+ Authorization: `Bearer ${authToken}`,
199
+ },
200
+ body: JSON.stringify({ name: "journey-test-resource" }),
201
+ })
202
+ expect(res.status, `T-010 失敗:預期 201,實際 ${res.status}`).toBe(201)
203
+ const data = await res.json()
204
+ resourceId = data.id // ← 傳遞給後續步驟
205
+ })
206
+ })
207
+ ```
208
+
209
+ ## 後續步驟
210
+
211
+ 完成後建議:
212
+
213
+ > **TESTPLAN 與 Journey E2E 骨架已生成。建議下一步:**
214
+ > - 執行 `/e2e` 生成各功能的 AC 層測試(補充旅程測試的細節覆蓋)
215
+ > - 執行 `/atdd` 定義各 T-NNN 步驟對應的驗收條件
216
+ > - 執行 `/journey-test --analyze` 定期檢查自動化覆蓋缺口
217
+
218
+ ## 參考
219
+
220
+ - 標準:[user-journey-testing.ai.yaml](../../../../.standards/user-journey-testing.ai.yaml)
221
+ - 相關 XSPEC:XSPEC-128(UDS 標準定義)
222
+ - 相關 Skill:`/e2e`(AC 層測試)、`/atdd`(驗收條件定義)
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: knowledge-graph
3
+ source: ../../../../skills/knowledge-graph/SKILL.md
4
+ source_version: 1.0.0
5
+ translation_version: 1.0.0
6
+ last_synced: 2026-05-30
7
+ status: current
8
+ description: "[UDS] 透過知識圖追蹤規格/決策/程式碼的影響鏈(引擎或 Markdown 後備)"
9
+ ---
10
+
11
+ # 知識圖
12
+
13
+ > **語言**: [English](../../../../skills/knowledge-graph/SKILL.md) | 繁體中文
14
+
15
+ 依據[知識圖記憶標準](../../../../core/knowledge-graph-memory.md)的關係 schema,回答橫跨規格、決策與程式碼的結構性問題——*「XSPEC-205 的完整影響鏈是什麼?」*。有無圖引擎皆可運作。
16
+
17
+ > **Implements**: XSPEC-237 Phase 5 — knowledge-graph skill(CodeSage opt-in)
18
+
19
+ ## 模式選擇
20
+
21
+ 回答**前**先判斷使用哪種模式:
22
+
23
+ | 條件 | 模式 |
24
+ |------|------|
25
+ | 設定了 `CODESAGE_URL`,或本機圖引擎 `/health` 有回應 | 服務模式(引擎)|
26
+ | 否則 | 降級模式(Markdown)|
27
+
28
+ ## 工作流程
29
+
30
+ 1. **解析目標**——將參數正規化為標準 id(`XSPEC-205`、`DEC-062`、函式名)。
31
+ 2. **選擇模式**——探測圖引擎(服務)否則後備(降級)。
32
+ 3. **服務模式(AC-5b)**——送出單一多跳查詢,呈現回傳的鏈(含跨域連結 code → spec → decision):
33
+ ```bash
34
+ curl -s -X POST "$CODESAGE_URL/graph/impact-analysis" \
35
+ -H 'content-type: application/json' \
36
+ -d '{"nodeId":"XSPEC-205","maxHops":3}'
37
+ ```
38
+ 4. **降級模式(AC-5a)**——無引擎時,讀取目標文件,沿其 `impacts`/`impacted_by`/`supersedes`/`related` front-matter 與內文 `[[ref]]` 連結讀取被連結檔案,手動組出鏈(受讀取深度限制)。
39
+ 5. **呈現鏈**——列出相連的 Spec 與 Decision、每跳的邊型別、以及(若有)各節點的 `confidence`,高者在前。
40
+ 6. **說明使用的模式**——務必告知答案來自引擎或 Markdown 後備,以明確完整度。
41
+
42
+ ## 關係 schema
43
+
44
+ 見[知識圖記憶標準](../../../../core/knowledge-graph-memory.md)。front-matter 欄位:`related`、`impacts`、`impacted_by`、`supersedes`、`implements`。
45
+
46
+ ## 下一步引導
47
+
48
+ - 降級模式若觸及讀取深度上限,告知使用者圖引擎(如 CodeSage)可給出完整鏈,以及如何設定 `CODESAGE_URL`。
49
+ - 若參照的 id 找不到,標示為待修的懸空參照。
50
+ - 主動提議為遍歷過的文件補上缺漏的 `impacts`/`impacted_by` front-matter。
51
+
52
+ ## 參考
53
+
54
+ - 標準:[core/knowledge-graph-memory.md](../../../../core/knowledge-graph-memory.md)
55
+ - 引擎(opt-in):[CodeSage](https://github.com/AsiaOstrich/CodeSage) — `@asiaostrich/codesage`
56
+ - 詳細指南:[guide.md](guide.md)