universal-dev-standards 5.1.0-beta.6 → 5.1.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 (108) hide show
  1. package/README.md +6 -0
  2. package/bin/uds.js +14 -0
  3. package/bundled/ai/standards/agent-communication-protocol.ai.yaml +34 -0
  4. package/bundled/ai/standards/anti-sycophancy-prompting.ai.yaml +111 -0
  5. package/bundled/ai/standards/capability-declaration.ai.yaml +113 -0
  6. package/bundled/ai/standards/circuit-breaker.ai.yaml +93 -0
  7. package/bundled/ai/standards/developer-memory.ai.yaml +13 -0
  8. package/bundled/ai/standards/dual-phase-output.ai.yaml +108 -0
  9. package/bundled/ai/standards/failure-source-taxonomy.ai.yaml +115 -0
  10. package/bundled/ai/standards/frontend-design-standards.ai.yaml +305 -0
  11. package/bundled/ai/standards/health-check-standards.ai.yaml +140 -0
  12. package/bundled/ai/standards/immutability-first.ai.yaml +112 -0
  13. package/bundled/ai/standards/model-selection.ai.yaml +111 -3
  14. package/bundled/ai/standards/packaging-standards.ai.yaml +142 -0
  15. package/bundled/ai/standards/recovery-recipe-registry.ai.yaml +200 -0
  16. package/bundled/ai/standards/retry-standards.ai.yaml +134 -0
  17. package/bundled/ai/standards/security-decision.ai.yaml +87 -0
  18. package/bundled/ai/standards/skill-standard-alignment-check.ai.yaml +119 -0
  19. package/bundled/ai/standards/standard-admission-criteria.ai.yaml +107 -0
  20. package/bundled/ai/standards/standard-lifecycle-management.ai.yaml +144 -0
  21. package/bundled/ai/standards/timeout-standards.ai.yaml +104 -0
  22. package/bundled/ai/standards/token-budget.ai.yaml +108 -0
  23. package/bundled/ai/standards/translation-lifecycle-standards.ai.yaml +145 -0
  24. package/bundled/core/anti-sycophancy-prompting.md +184 -0
  25. package/bundled/core/capability-declaration.md +59 -0
  26. package/bundled/core/circuit-breaker.md +58 -0
  27. package/bundled/core/developer-memory.md +29 -1
  28. package/bundled/core/dual-phase-output.md +56 -0
  29. package/bundled/core/failure-source-taxonomy.md +72 -0
  30. package/bundled/core/frontend-design-standards.md +474 -0
  31. package/bundled/core/health-check-standards.md +72 -0
  32. package/bundled/core/immutability-first.md +105 -0
  33. package/bundled/core/model-selection.md +80 -0
  34. package/bundled/core/packaging-standards.md +216 -0
  35. package/bundled/core/recovery-recipe-registry.md +69 -0
  36. package/bundled/core/retry-standards.md +62 -0
  37. package/bundled/core/security-decision.md +65 -0
  38. package/bundled/core/skill-standard-alignment-check.md +79 -0
  39. package/bundled/core/standard-admission-criteria.md +84 -0
  40. package/bundled/core/standard-lifecycle-management.md +94 -0
  41. package/bundled/core/timeout-standards.md +63 -0
  42. package/bundled/core/token-budget.md +58 -0
  43. package/bundled/core/translation-lifecycle-standards.md +162 -0
  44. package/bundled/locales/zh-CN/CHANGELOG.md +51 -3
  45. package/bundled/locales/zh-CN/README.md +1 -1
  46. package/bundled/locales/zh-CN/core/anti-hallucination.md +22 -3
  47. package/bundled/locales/zh-CN/core/anti-sycophancy-prompting.md +192 -0
  48. package/bundled/locales/zh-CN/core/capability-declaration.md +123 -0
  49. package/bundled/locales/zh-CN/core/circuit-breaker.md +106 -0
  50. package/bundled/locales/zh-CN/core/dual-phase-output.md +103 -0
  51. package/bundled/locales/zh-CN/core/failure-source-taxonomy.md +99 -0
  52. package/bundled/locales/zh-CN/core/frontend-design-standards.md +289 -0
  53. package/bundled/locales/zh-CN/core/health-check-standards.md +144 -0
  54. package/bundled/locales/zh-CN/core/immutability-first.md +96 -0
  55. package/bundled/locales/zh-CN/core/packaging-standards.md +224 -0
  56. package/bundled/locales/zh-CN/core/recovery-recipe-registry.md +146 -0
  57. package/bundled/locales/zh-CN/core/retry-standards.md +131 -0
  58. package/bundled/locales/zh-CN/core/security-decision.md +104 -0
  59. package/bundled/locales/zh-CN/core/skill-standard-alignment-check.md +112 -0
  60. package/bundled/locales/zh-CN/core/standard-admission-criteria.md +104 -0
  61. package/bundled/locales/zh-CN/core/standard-lifecycle-management.md +116 -0
  62. package/bundled/locales/zh-CN/core/timeout-standards.md +117 -0
  63. package/bundled/locales/zh-CN/core/token-budget.md +108 -0
  64. package/bundled/locales/zh-CN/core/translation-lifecycle-standards.md +159 -0
  65. package/bundled/locales/zh-TW/CHANGELOG.md +51 -3
  66. package/bundled/locales/zh-TW/README.md +1 -1
  67. package/bundled/locales/zh-TW/core/anti-sycophancy-prompting.md +192 -0
  68. package/bundled/locales/zh-TW/core/capability-declaration.md +111 -0
  69. package/bundled/locales/zh-TW/core/circuit-breaker.md +111 -0
  70. package/bundled/locales/zh-TW/core/dual-phase-output.md +132 -0
  71. package/bundled/locales/zh-TW/core/failure-source-taxonomy.md +146 -0
  72. package/bundled/locales/zh-TW/core/frontend-design-standards.md +460 -0
  73. package/bundled/locales/zh-TW/core/health-check-standards.md +144 -0
  74. package/bundled/locales/zh-TW/core/immutability-first.md +159 -0
  75. package/bundled/locales/zh-TW/core/packaging-standards.md +224 -0
  76. package/bundled/locales/zh-TW/core/recovery-recipe-registry.md +146 -0
  77. package/bundled/locales/zh-TW/core/retry-standards.md +140 -0
  78. package/bundled/locales/zh-TW/core/security-decision.md +120 -0
  79. package/bundled/locales/zh-TW/core/skill-standard-alignment-check.md +112 -0
  80. package/bundled/locales/zh-TW/core/standard-admission-criteria.md +104 -0
  81. package/bundled/locales/zh-TW/core/standard-lifecycle-management.md +116 -0
  82. package/bundled/locales/zh-TW/core/timeout-standards.md +117 -0
  83. package/bundled/locales/zh-TW/core/token-budget.md +143 -0
  84. package/bundled/locales/zh-TW/core/translation-lifecycle-standards.md +159 -0
  85. package/bundled/skills/e2e-assistant/SKILL.md +19 -5
  86. package/bundled/skills/testing-guide/SKILL.md +5 -0
  87. package/bundled/skills/testing-guide/test-skeleton-templates.md +316 -0
  88. package/package.json +2 -1
  89. package/src/commands/check.js +6 -0
  90. package/src/commands/config.js +9 -0
  91. package/src/commands/init.js +97 -46
  92. package/src/commands/mcp.js +26 -0
  93. package/src/commands/run-intent.js +66 -0
  94. package/src/commands/update.js +41 -4
  95. package/src/core/command-router.js +85 -0
  96. package/src/core/project-config.js +91 -0
  97. package/src/flows/init-flow.js +6 -1
  98. package/src/i18n/messages.js +6 -6
  99. package/src/mcp/__tests__/server.test.js +251 -0
  100. package/src/mcp/server.js +352 -0
  101. package/src/prompts/init.js +157 -1
  102. package/src/reconciler/actual-state-scanner.js +24 -0
  103. package/src/uninstallers/hook-uninstaller.js +32 -1
  104. package/src/utils/detect-self-adoption.js +173 -0
  105. package/src/utils/e2e-analyzer.js +88 -5
  106. package/src/utils/e2e-detector.js +73 -1
  107. package/src/utils/integration-generator.js +22 -3
  108. package/standards-registry.json +203 -4
@@ -0,0 +1,132 @@
1
+ ---
2
+ source: ../../../core/dual-phase-output.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
+ # 雙階段 LLM 輸出標準
10
+
11
+ > **語言**: [English](../../../core/dual-phase-output.md) | 繁體中文
12
+
13
+ **版本**: 1.0.0
14
+ **最後更新**: 2026-04-15
15
+ **適用範圍**: 所有需要 LLM 審查的場景(Judge、Evaluator、Guardian、AutoCompact)
16
+ **Scope**: universal
17
+ **來源**: XSPEC-035(claude-code-book Ch.7 formatCompactSummary dual-phase output)
18
+
19
+ ---
20
+
21
+ ## 目的
22
+
23
+ 雙階段 LLM 輸出模式:`<analysis>` 思考丟棄,`<summary>` 結構化保留。
24
+
25
+ 讓 LLM 充分推理的同時,避免思考過程累積在上下文中消耗 token 預算。
26
+
27
+ ---
28
+
29
+ ## 核心規範
30
+
31
+ - 所有 LLM 審查 Agent 必須要求雙階段輸出格式(`<analysis>` + `<summary>`)
32
+ - `<analysis>` 在後處理時必須丟棄,不得寫入持久化上下文或對話歷史
33
+ - `<summary>` 必須包含結構化結論欄位(`decision`、`confidence`、`findings`、`next_action`)
34
+ - 若回應缺少雙階段格式,後處理器必須降級相容(完整回應視為 summary)並記錄警告
35
+ - `summary` 欄位命名需遵循本標準,各應用場景可擴充但不可刪減核心欄位
36
+
37
+ ---
38
+
39
+ ## 輸出格式
40
+
41
+ ### `<analysis>` 標籤
42
+
43
+ - **用途**:LLM 思考草稿 — 後處理時丟棄
44
+ - **內容指引**:
45
+ - 逐條審查邏輯
46
+ - 邊界情境考量
47
+ - 替代方案比較
48
+
49
+ ### `<summary>` 標籤
50
+
51
+ - **用途**:結構化結論 — 後處理時保留
52
+
53
+ **核心欄位**(必填):
54
+
55
+ | 欄位 | 類型 | 值 |
56
+ |------|------|-----|
57
+ | `decision` | enum | `approved \| rejected \| needs_revision` |
58
+ | `confidence` | enum | `high \| medium \| low` |
59
+ | `findings` | array | `[type] description` 格式 |
60
+ | `next_action` | string | 建議的後續行動 |
61
+
62
+ **擴充欄位**(依場景新增,不可刪減核心欄位):
63
+
64
+ | 場景 | 額外欄位範例 |
65
+ |------|------------|
66
+ | 安全審查 | `severity: critical \| high \| medium \| low`, `cwe_ids: [CWE-NNN]` |
67
+ | 品質審查 | `test_coverage: number`, `tech_debt_score: number` |
68
+
69
+ ---
70
+
71
+ ## Prompt 模板
72
+
73
+ ```
74
+ You MUST respond using EXACTLY this two-phase XML structure:
75
+
76
+ <analysis>
77
+ [Your reasoning process — will be DISCARDED after processing]
78
+ - Step-by-step evaluation
79
+ - Edge case considerations
80
+ - Alternative comparisons
81
+ </analysis>
82
+
83
+ <summary>
84
+ decision: approved | rejected | needs_revision
85
+ confidence: high | medium | low
86
+ findings:
87
+ - [type] description
88
+ next_action: [recommended follow-up action]
89
+ </summary>
90
+
91
+ IMPORTANT: The <analysis> block is your scratchpad. Only <summary> persists.
92
+ ```
93
+
94
+ ---
95
+
96
+ ## 後處理規則
97
+
98
+ | 步驟 | 動作 |
99
+ |------|------|
100
+ | 提取 summary | 用正則 `<summary>([\s\S]*?)</summary>` 擷取 |
101
+ | 丟棄 analysis | 用正則 `<analysis>([\s\S]*?)</analysis>` 移除 |
102
+ | 降級相容 | 若缺少 `<summary>` 標籤,完整回應視為 summary 內容,記錄 `warn` 日誌 |
103
+
104
+ ---
105
+
106
+ ## Token 節省估算
107
+
108
+ | 指標 | 數值 |
109
+ |------|------|
110
+ | `<analysis>` 佔一般審查回應比例 | 50–70% |
111
+ | 每次審查節省 token | 1,000–3,500 |
112
+ | Fix Loop 3 輪累計節省 | 3,000–10,500 |
113
+ | 備註 | 節省效果在重複審查場景(Fix Loop、Feedback Loop)中累積 |
114
+
115
+ ---
116
+
117
+ ## 適用 Agent
118
+
119
+ - DevAP Judge Agent
120
+ - VibeOps Evaluator Agent
121
+ - VibeOps Guardian Agent
122
+ - 任何 LLM 驅動的 AutoCompact/摘要組件
123
+
124
+ ---
125
+
126
+ ## 錯誤碼
127
+
128
+ | 代碼 | 說明 |
129
+ |------|------|
130
+ | `DPO-001` | `summary` 標籤缺失 — 降級相容已啟用 |
131
+ | `DPO-002` | `analysis` 標籤缺失 — 完整回應照常處理 |
132
+ | `DPO-003` | `summary` 必填欄位缺失 — 解析錯誤 |
@@ -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