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

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 (68) hide show
  1. package/bin/uds.js +12 -0
  2. package/bundled/ai/standards/agent-communication-protocol.ai.yaml +34 -0
  3. package/bundled/ai/standards/anti-sycophancy-prompting.ai.yaml +111 -0
  4. package/bundled/ai/standards/capability-declaration.ai.yaml +113 -0
  5. package/bundled/ai/standards/circuit-breaker.ai.yaml +93 -0
  6. package/bundled/ai/standards/developer-memory.ai.yaml +13 -0
  7. package/bundled/ai/standards/dual-phase-output.ai.yaml +108 -0
  8. package/bundled/ai/standards/failure-source-taxonomy.ai.yaml +115 -0
  9. package/bundled/ai/standards/frontend-design-standards.ai.yaml +305 -0
  10. package/bundled/ai/standards/health-check-standards.ai.yaml +140 -0
  11. package/bundled/ai/standards/immutability-first.ai.yaml +112 -0
  12. package/bundled/ai/standards/model-selection.ai.yaml +111 -3
  13. package/bundled/ai/standards/packaging-standards.ai.yaml +142 -0
  14. package/bundled/ai/standards/recovery-recipe-registry.ai.yaml +200 -0
  15. package/bundled/ai/standards/retry-standards.ai.yaml +134 -0
  16. package/bundled/ai/standards/security-decision.ai.yaml +87 -0
  17. package/bundled/ai/standards/skill-standard-alignment-check.ai.yaml +119 -0
  18. package/bundled/ai/standards/standard-admission-criteria.ai.yaml +107 -0
  19. package/bundled/ai/standards/standard-lifecycle-management.ai.yaml +144 -0
  20. package/bundled/ai/standards/timeout-standards.ai.yaml +104 -0
  21. package/bundled/ai/standards/token-budget.ai.yaml +108 -0
  22. package/bundled/core/anti-sycophancy-prompting.md +184 -0
  23. package/bundled/core/capability-declaration.md +59 -0
  24. package/bundled/core/circuit-breaker.md +58 -0
  25. package/bundled/core/developer-memory.md +29 -1
  26. package/bundled/core/dual-phase-output.md +56 -0
  27. package/bundled/core/failure-source-taxonomy.md +72 -0
  28. package/bundled/core/frontend-design-standards.md +474 -0
  29. package/bundled/core/health-check-standards.md +72 -0
  30. package/bundled/core/immutability-first.md +105 -0
  31. package/bundled/core/model-selection.md +80 -0
  32. package/bundled/core/packaging-standards.md +216 -0
  33. package/bundled/core/recovery-recipe-registry.md +69 -0
  34. package/bundled/core/retry-standards.md +62 -0
  35. package/bundled/core/security-decision.md +65 -0
  36. package/bundled/core/skill-standard-alignment-check.md +79 -0
  37. package/bundled/core/standard-admission-criteria.md +84 -0
  38. package/bundled/core/standard-lifecycle-management.md +94 -0
  39. package/bundled/core/timeout-standards.md +63 -0
  40. package/bundled/core/token-budget.md +58 -0
  41. package/bundled/locales/zh-CN/CHANGELOG.md +22 -3
  42. package/bundled/locales/zh-CN/README.md +1 -1
  43. package/bundled/locales/zh-TW/CHANGELOG.md +22 -3
  44. package/bundled/locales/zh-TW/README.md +1 -1
  45. package/bundled/locales/zh-TW/core/anti-sycophancy-prompting.md +184 -0
  46. package/bundled/locales/zh-TW/core/packaging-standards.md +224 -0
  47. package/bundled/skills/e2e-assistant/SKILL.md +19 -5
  48. package/bundled/skills/testing-guide/SKILL.md +5 -0
  49. package/bundled/skills/testing-guide/test-skeleton-templates.md +316 -0
  50. package/package.json +1 -1
  51. package/src/commands/config.js +9 -0
  52. package/src/commands/init.js +91 -46
  53. package/src/commands/mcp.js +26 -0
  54. package/src/commands/run-intent.js +66 -0
  55. package/src/commands/update.js +35 -4
  56. package/src/core/command-router.js +85 -0
  57. package/src/core/project-config.js +91 -0
  58. package/src/flows/init-flow.js +6 -1
  59. package/src/i18n/messages.js +6 -6
  60. package/src/mcp/__tests__/server.test.js +251 -0
  61. package/src/mcp/server.js +352 -0
  62. package/src/prompts/init.js +157 -1
  63. package/src/reconciler/actual-state-scanner.js +24 -0
  64. package/src/uninstallers/hook-uninstaller.js +32 -1
  65. package/src/utils/e2e-analyzer.js +88 -5
  66. package/src/utils/e2e-detector.js +73 -1
  67. package/src/utils/integration-generator.js +22 -3
  68. package/standards-registry.json +193 -5
@@ -0,0 +1,94 @@
1
+ # Standard Lifecycle Management
2
+
3
+ > **Source**: XSPEC-070 | **Driven by**: DEC-043 Wave 1 Governance Meta Pack | **Status**: Trial (2026-04-17 ~ 2026-10-17)
4
+
5
+ ## Overview
6
+
7
+ UDS 標準生命週期狀態機。既有 66 個標準無明確狀態管理:新增標準沒有試驗期、過時標準無棄用路徑、廢棄標準仍被引用。本標準建立五狀態機(Proposed / Trial / Active / Deprecated / Archived)與合法轉移規則,並規範所有 `.ai.yaml` 標準必須在 frontmatter 標示 `status` / `since` / `expires` / `supersedes`。
8
+
9
+ ## Key Principles
10
+
11
+ - **所有標準必有狀態**:frontmatter 必須包含 `status` 和 `since`
12
+ - **Trial 必有期限**:`expires` 預設 since + 6 months
13
+ - **Deprecated 必有替代**:`supersedes` 指向替代標準 id 或遷移文件
14
+ - **禁止反向轉移**:Active → Proposed、Archived → Active 均無意義
15
+ - **逾期自動 Archived**:Trial 到期未決則自動歸檔
16
+
17
+ ## States
18
+
19
+ | State | Description | Skill-referenceable? |
20
+ |-------|-------------|----------------------|
21
+ | **Proposed** | 草案階段,未通過 admission | No |
22
+ | **Trial** | 批准但試驗中(預設 6 個月)| Yes(標註 trial)|
23
+ | **Active** | 全面採用,standard-of-truth | Yes |
24
+ | **Deprecated** | 標記棄用,必須提供 `supersedes` | Yes(Skill 應警示)|
25
+ | **Archived** | 已移除,僅保留歷史 | No |
26
+
27
+ ## Legal Transitions
28
+
29
+ ```
30
+ Proposed ──(admission passed)──→ Trial
31
+ Trial ──(validated)──────────→ Active
32
+ Trial ──(expired/rejected)───→ Archived
33
+ Active ──(superseded)─────────→ Deprecated
34
+ Deprecated ──(migration done)───→ Archived
35
+ ```
36
+
37
+ **禁止的轉移**:
38
+
39
+ - Active → Proposed(無意義)
40
+ - Archived → Active(應重新申請 admission)
41
+ - Deprecated → Active(應重新 Trial)
42
+ - Proposed → Active(須先 Trial)
43
+
44
+ ## Frontmatter Required Fields
45
+
46
+ ### Always Required
47
+
48
+ - `status`: proposed | trial | active | deprecated | archived
49
+ - `since`: ISO-8601(進入當前狀態的日期)
50
+ - `version`: semver 字串
51
+
52
+ ### Conditional
53
+
54
+ | Field | When |
55
+ |-------|------|
56
+ | `expires` | `status = trial`(預設 since + 6 months)|
57
+ | `supersedes` | `status = deprecated`(替代標準 id 或遷移文件路徑)|
58
+ | `migration_guide` | `status = deprecated`(相對路徑,選填但強烈建議)|
59
+
60
+ ## Usage Examples
61
+
62
+ - **Scenario 1 — Trial → Active**:`retry-standards` 處於 trial。2026-08-01 審視發現 DevAP Fix Loop 和 VibeOps Builder 均採用且無重大缺陷 → 轉 Active,`since=2026-08-01`,移除 `expires`
63
+ - **Scenario 2 — Trial 逾期自動 Archived**:某標準 trial 期限 2026-10-17 到期未通過驗證 → 狀態轉 Archived,記錄原因
64
+ - **Scenario 3 — Deprecated 帶遷移**:`legacy-retry-logic` 被 `retry-standards` 取代 → `status=deprecated, supersedes=retry-standards, migration_guide=docs/migrations/retry-v1-to-v2.md`;Skill 使用時顯示警告
65
+
66
+ ## Telemetry Event
67
+
68
+ `standard_state_change`:
69
+
70
+ ```
71
+ {
72
+ standard_id: string,
73
+ from_state: proposed|trial|active|deprecated|archived,
74
+ to_state: proposed|trial|active|deprecated|archived,
75
+ reason: string,
76
+ timestamp: ISO-8601
77
+ }
78
+ ```
79
+
80
+ ## Error Codes
81
+
82
+ - `LIFECYCLE-001` — `MISSING_STATUS`
83
+ - `LIFECYCLE-002` — `MISSING_EXPIRES`(trial 狀態)
84
+ - `LIFECYCLE-003` — `MISSING_SUPERSEDES`(deprecated 狀態)
85
+ - `LIFECYCLE-004` — `FORBIDDEN_TRANSITION`
86
+ - `LIFECYCLE-005` — `TRIAL_EXPIRED`(期限已過但未決策)
87
+
88
+ ## References
89
+
90
+ - AI-optimized: [ai/standards/standard-lifecycle-management.ai.yaml](../ai/standards/standard-lifecycle-management.ai.yaml)
91
+ - XSPEC-070: DEC-043 Wave 1 Governance Meta Pack 跨專案規格
92
+ - DEC-043: UDS 覆蓋完整性路線圖(驅動來源)
93
+ - Related: `standard-admission-criteria`, `skill-standard-alignment-check`, `adr-standards`
94
+ - Industry: IETF RFC lifecycle (Proposed → Draft → Internet Standard), Python PEP states, W3C Recommendation Track
@@ -0,0 +1,63 @@
1
+ # Timeout Standards
2
+
3
+ > **Source**: XSPEC-067 | **Driven by**: DEC-043 Wave 1 Reliability Pack | **Status**: Trial (2026-04-17 ~ 2026-10-17)
4
+
5
+ ## Overview
6
+
7
+ Timeout 標準 — 避免多層呼叫鏈中下層 timeout 大於上層(導致上層先 timeout 而下層仍在執行的資源浪費)。透過 cascading 預算規則(每層 ≤ 0.8× 上層)與 deadline propagation(傳 absolute timestamp)讓整條呼叫鏈精準 fail-fast。與 `circuit-breaker` 整合,timeout 計入 failure count。
8
+
9
+ ## Key Principles
10
+
11
+ - **Cascading 預算**:多層呼叫的 timeout 必須逐層遞減,每下一層 ≤ `0.8 × 上層`(預留 20% buffer)
12
+ - **Deadline Propagation**:跨服務呼叫必須傳遞 deadline(absolute timestamp),不得只傳 relative duration
13
+ - **Fail-fast on Expired**:收到請求後若 `now > deadline`,立即 fail-fast,禁止發起下游呼叫
14
+ - **Breaker 整合**:timeout 觸發計入對應 circuit-breaker 的 failure count
15
+ - **禁止倒置**:下層 timeout 大於上層 timeout 等同沒設 timeout,配置違規
16
+
17
+ ## Cascading Budget Example
18
+
19
+ ```
20
+ Client timeout = 10000 ms
21
+ Gateway timeout = 8000 ms (10000 × 0.8)
22
+ Service A timeout = 6400 ms (8000 × 0.8)
23
+ Downstream DB timeout = 5120 ms (6400 × 0.8)
24
+ ```
25
+
26
+ 0.8 為業界經驗值(gRPC / Envoy 常用 0.7~0.85),預留 20% buffer 給序列化、網路傳輸、重試開銷。
27
+
28
+ ## Deadline Propagation
29
+
30
+ - Header: `X-Deadline`
31
+ - Format: absolute ISO-8601 timestamp(不是 relative duration)
32
+ - 發起呼叫前:`deadline = now + timeout`,寫入 header
33
+ - 收到請求後:立即檢查 `now > deadline_header`,若是則回 `DEADLINE_EXCEEDED`
34
+ - 向下游呼叫:`timeout = min(cascading_budget, deadline - now)`
35
+
36
+ ## Timeout Categories
37
+
38
+ | Category | Default ms | Purpose |
39
+ |----------|------------|---------|
40
+ | `connect_timeout` | 5000 | 建立 TCP / TLS 連線 |
41
+ | `request_timeout` | 30000 | 發送請求到收到完整回應 |
42
+ | `idle_timeout` | 60000 | 連線閒置多久後關閉 |
43
+ | `total_deadline` | 60000 | 含所有重試的整體上限 |
44
+
45
+ ## Usage Examples
46
+
47
+ - **Scenario 1 — Cascading 預算**:Client 10s → Gateway 8s → Service A 6.4s → DB 5.12s,確保下層先 timeout,上層有機會 fallback
48
+ - **Scenario 2 — Deadline 過期**:請求抵達 Service A 時 `X-Deadline` 已過期,立即回 `DEADLINE_EXCEEDED`,不呼叫 DB
49
+ - **Scenario 3 — Timeout 觸發 breaker**:連續 3 次下游呼叫皆 timeout(failureThreshold=3),第 4 次 breaker 進入 OPEN
50
+
51
+ ## Error Codes
52
+
53
+ - `TIMEOUT-001` — `REQUEST_TIMEOUT`(單次請求超時)
54
+ - `TIMEOUT-002` — `DEADLINE_EXCEEDED`(整體 deadline 已過)
55
+ - `TIMEOUT-003` — `CASCADING_BUDGET_VIOLATION`(下層 > 上層,配置錯誤)
56
+
57
+ ## References
58
+
59
+ - AI-optimized: [ai/standards/timeout-standards.ai.yaml](../ai/standards/timeout-standards.ai.yaml)
60
+ - XSPEC-067: DEC-043 Wave 1 Reliability Pack 跨專案規格
61
+ - DEC-043: UDS 覆蓋完整性路線圖(驅動來源)
62
+ - Related: `circuit-breaker`, `retry-standards`, `failure-source-taxonomy`
63
+ - Industry: gRPC deadline propagation, Envoy timeout budgeting, Google SRE Book Ch.22
@@ -0,0 +1,58 @@
1
+ # Token Budget Zone Standard
2
+
3
+ > **Source**: XSPEC-036 | **Borrowed from**: claude-code-book Ch.7
4
+
5
+ ## Overview
6
+
7
+ The Token Budget Zone model divides token usage into four progressive zones, each triggering increasingly aggressive protection strategies. This prevents the "works fine until sudden crash" failure mode and gives systems time to gracefully degrade before hitting hard limits.
8
+
9
+ ## Zones
10
+
11
+ | Zone | Range | Action | Log Level |
12
+ |------|-------|--------|-----------|
13
+ | **SAFE** | 0–84% | Normal operation | — |
14
+ | **WARNING** | 85–89% | Emit event, notify coordinator | info |
15
+ | **DANGER** | 90–94% | Trigger lightweight compression (Snip) | warn |
16
+ | **BLOCKING** | 95–100% | Reject new requests, return error | error |
17
+
18
+ ## Constants
19
+
20
+ ```typescript
21
+ const TOKEN_BUDGET_ZONE = {
22
+ WARNING_THRESHOLD: 0.85,
23
+ DANGER_THRESHOLD: 0.90,
24
+ BLOCKING_THRESHOLD: 0.95,
25
+ } as const;
26
+
27
+ type TokenBudgetZone = "safe" | "warning" | "danger" | "blocking";
28
+ ```
29
+
30
+ ## DANGER Zone Actions
31
+
32
+ When entering DANGER zone (90–94%):
33
+ 1. **Tool Result Snip**: Truncate large tool outputs, keep summaries
34
+ 2. **Reduce maxToolRounds**: Cut by 20% for remaining agents
35
+ 3. **Persist to disk**: Move important outputs out of context
36
+
37
+ ## Post-Compact Budget
38
+
39
+ Compression operations need output space to succeed. Reserve constants:
40
+
41
+ | Constant | Value | Purpose |
42
+ |----------|-------|---------|
43
+ | `MAX_FILES_TO_RESTORE` | 5 | Max files to restore after compaction |
44
+ | `TOTAL_TOKEN_BUDGET` | 50,000 | Total post-compact token budget |
45
+ | `MAX_TOKENS_PER_FILE` | 5,000 | Per-file token limit |
46
+
47
+ ## Applicable Scenarios
48
+
49
+ - DevAP task execution token monitoring
50
+ - VibeOps 9-Agent pipeline cumulative context management
51
+ - VibeOps PipelineMemory Snip trigger condition
52
+ - Any environment with `maxTotalTokens` limit
53
+
54
+ ## References
55
+
56
+ - AI-optimized: [ai/standards/token-budget.ai.yaml](../ai/standards/token-budget.ai.yaml)
57
+ - XSPEC-036: Cross-project specification
58
+ - Borrowed from: [claude-code-book](https://github.com/lintsinghua/claude-code-book) Ch.7 four-zone context management
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  source: ../../CHANGELOG.md
3
- source_version: 5.1.0-beta.6
4
- translation_version: 5.1.0-beta.6
5
- last_synced: 2026-04-13
3
+ source_version: 5.1.0-beta.7
4
+ translation_version: 5.1.0-beta.7
5
+ last_synced: 2026-04-17
6
6
  status: current
7
7
  ---
8
8
 
@@ -17,6 +17,25 @@ status: current
17
17
 
18
18
  ## [Unreleased]
19
19
 
20
+ ## [5.1.0-beta.7] - 2026-04-17
21
+
22
+ > **Beta Release**:DEC-043 Wave 1 — 六个 Trial 状态标准,涵盖可靠性模式与治理 Meta 框架。
23
+
24
+ ### 新增
25
+ - **Reliability 包(XSPEC-067)**:三个 Trial 状态的韧性模式标准。
26
+ - `retry-standards`:重试策略(指数退避、Jitter、幂等性保护)。
27
+ - `timeout-standards`:分层 timeout 预算(call / request / end-to-end)与传递规则。
28
+ - `health-check-standards`:Liveness / Readiness / Startup probe 语义。
29
+ - **治理 Meta 包(XSPEC-070,Wave 1 前置)**:三个定义「标准如何被纳入、管理、与 Skill 对齐」的 Trial 标准。
30
+ - `standard-admission-criteria`:新标准提案的入场门槛。
31
+ - `standard-lifecycle-management`:Trial → Stable → Deprecated → Archived 状态流转。
32
+ - `skill-standard-alignment-check`:Skill 与其引用标准之间的对齐稽核。
33
+ - 六份标准皆遵循 UDS 三方同步要求:`.ai.yaml`(机器)+ `.md`(人类)+ `cli/standards-registry.json` entry(+66 行)。
34
+
35
+ ### 背景
36
+ - 由 **DEC-043**(UDS 覆盖完整性路线图)驱动。治理 Meta 包为 Wave 1 前置条件,解锁 Wave 2–4(八个主题标准包:SRE / CI-CD / IaC / 合规 / Reliability / 资料工程 / 产品 / 治理 — XSPEC-063~070)。
37
+ - PR:#77
38
+
20
39
  ## [5.1.0-beta.6] - 2026-04-13
21
40
 
22
41
  > **Beta 版本**:修复 `uds init` 崩溃问题、E2E 测试隔离问题,以及 macOS 显示语言检测失效问题。
@@ -6,7 +6,7 @@
6
6
 
7
7
  > **语言**: [English](../../README.md) | [繁體中文](../zh-TW/README.md) | 简体中文
8
8
 
9
- **版本**: 5.1.0-beta.6 (Pre-release) | **发布日期**: 2026-04-13 | **授权**: [双重授权](../../LICENSE) (CC BY 4.0 + MIT)
9
+ **版本**: 5.1.0-beta.7 (Pre-release) | **发布日期**: 2026-04-13 | **授权**: [双重授权](../../LICENSE) (CC BY 4.0 + MIT)
10
10
 
11
11
  语言无关、框架无关的软件项目文档标准。通过 AI 原生工作流,确保不同技术栈之间的一致性、质量和可维护性。
12
12
 
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  source: ../../CHANGELOG.md
3
- source_version: 5.1.0-beta.6
4
- translation_version: 5.1.0-beta.6
5
- last_synced: 2026-04-13
3
+ source_version: 5.1.0-beta.7
4
+ translation_version: 5.1.0-beta.7
5
+ last_synced: 2026-04-17
6
6
  status: current
7
7
  ---
8
8
 
@@ -17,6 +17,25 @@ status: current
17
17
 
18
18
  ## [Unreleased]
19
19
 
20
+ ## [5.1.0-beta.7] - 2026-04-17
21
+
22
+ > **Beta Release**:DEC-043 Wave 1 — 六個 Trial 狀態標準,涵蓋可靠性模式與治理 Meta 框架。
23
+
24
+ ### 新增
25
+ - **Reliability 包(XSPEC-067)**:三個 Trial 狀態的韌性模式標準。
26
+ - `retry-standards`:重試策略(指數退避、Jitter、冪等性保護)。
27
+ - `timeout-standards`:分層 timeout 預算(call / request / end-to-end)與傳遞規則。
28
+ - `health-check-standards`:Liveness / Readiness / Startup probe 語義。
29
+ - **治理 Meta 包(XSPEC-070,Wave 1 前置)**:三個定義「標準如何被納入、管理、與 Skill 對齊」的 Trial 標準。
30
+ - `standard-admission-criteria`:新標準提案的入場門檻。
31
+ - `standard-lifecycle-management`:Trial → Stable → Deprecated → Archived 狀態流轉。
32
+ - `skill-standard-alignment-check`:Skill 與其引用標準之間的對齊稽核。
33
+ - 六份標準皆遵循 UDS 三方同步要求:`.ai.yaml`(機器)+ `.md`(人類)+ `cli/standards-registry.json` entry(+66 行)。
34
+
35
+ ### 背景
36
+ - 由 **DEC-043**(UDS 覆蓋完整性路線圖)驅動。治理 Meta 包為 Wave 1 前置條件,解鎖 Wave 2–4(八個主題標準包:SRE / CI-CD / IaC / 合規 / Reliability / 資料工程 / 產品 / 治理 — XSPEC-063~070)。
37
+ - PR:#77
38
+
20
39
  ## [5.1.0-beta.6] - 2026-04-13
21
40
 
22
41
  > **Beta 版本**:修復 `uds init` 當機問題、E2E 測試隔離問題,以及 macOS 顯示語言偵測失效問題。
@@ -6,7 +6,7 @@
6
6
 
7
7
  > **語言**: [English](../../README.md) | 繁體中文 | [简体中文](../zh-CN/README.md)
8
8
 
9
- **版本**: 5.1.0-beta.6 (Pre-release) | **發布日期**: 2026-04-13 | **授權**: [雙重授權](../../LICENSE) (CC BY 4.0 + MIT)
9
+ **版本**: 5.1.0-beta.7 (Pre-release) | **發布日期**: 2026-04-13 | **授權**: [雙重授權](../../LICENSE) (CC BY 4.0 + MIT)
10
10
 
11
11
  語言無關、框架無關的軟體專案文件標準。透過 AI 原生工作流,確保不同技術堆疊之間的一致性、品質和可維護性。
12
12
 
@@ -0,0 +1,184 @@
1
+ # 防迎合提示詞設計標準
2
+
3
+ > **語言**: [English](../../../core/anti-sycophancy-prompting.md) | 繁體中文
4
+
5
+ **版本**: 1.0.0
6
+ **最後更新**: 2026-04-15
7
+ **適用範圍**: 所有 AI Agent 實作與 LLM Prompt 設計
8
+ **Scope**: universal
9
+ **業界標準**: 無(UDS 原創,參考 RLHF 迎合性研究)
10
+
11
+ ---
12
+
13
+ ## 目的
14
+
15
+ 本標準定義一套技法與規則,用於設計能讓 LLM 給出真實、批判性回應的提示詞,而非迎合使用者的隱含偏好。
16
+
17
+ LLM 的迎合性源自 RLHF 訓練目標:人類評分者傾向於給予令人愉快的回應高分,導致模型將「讓使用者滿意」置於「準確性」之上。
18
+
19
+ ---
20
+
21
+ ## 核心技法
22
+
23
+ ### 1. Socratic 反詰框架(REQ-1)
24
+
25
+ 將任務從「評估我的想法」改為「攻擊我的想法」,消除迎合誘因。
26
+
27
+ | 應該做 | 不應該做 |
28
+ |--------|----------|
29
+ | ✅ 要求列出最致命的 3 個質疑 | ❌ 問「這個想法好嗎?」 |
30
+ | ✅ 每個質疑必須有技術依據 | ❌ 允許模糊的正向框架 |
31
+ | ✅ 明確禁止正向開場詞語 | ❌ 接受「很好的想法,但是...」模式 |
32
+
33
+ **Prompt 模板**:
34
+ ```
35
+ 不要評估好壞。
36
+ 針對以下想法,列出最致命的 3 個質疑:[你的想法]
37
+ 每個質疑必須有技術依據,且讓我無法輕易反駁。
38
+ ```
39
+
40
+ ---
41
+
42
+ ### 2. 先問立場防錨定協議(REQ-2)
43
+
44
+ 在使用者揭示立場前先取得 LLM 的獨立判斷,防止錨定效應。
45
+
46
+ | 步驟 | 動作 |
47
+ |------|------|
48
+ | 1 | 在未揭示偏好的情況下詢問中立比較 |
49
+ | 2 | 取得獨立判斷 |
50
+ | 3 | 揭示使用者立場 |
51
+ | 4 | 若模型改變立場,要求提出明確的技術理由 |
52
+
53
+ **工作流程**:
54
+ ```
55
+ 回合 1:「針對 [情境],[A] 和 [B] 哪個更好?」
56
+ → 等待獨立判斷
57
+
58
+ 回合 2:「我傾向 [A]。這改變你的評估嗎?為什麼?」
59
+ → 模型若改口必須以技術事實為依據
60
+ ```
61
+
62
+ ---
63
+
64
+ ### 3. 強制雙欄對稱輸出(REQ-3)
65
+
66
+ 用格式約束強迫呈現對立觀點的平衡。
67
+
68
+ **必要格式**:
69
+ ```
70
+ | 支持這個決策的論點 | 反對這個決策的論點 |
71
+ |-------------------|-------------------|
72
+ | [同等份量的內容] | [同等份量的內容] |
73
+
74
+ 淨建議:[必須明確表態,可以是「建議反對」]
75
+ ```
76
+
77
+ **規則**:
78
+ - 兩欄字數差距不超過 20%
79
+ - 淨建議必須明確,可以是否定的
80
+ - 模型不得藉由填充一欄來規避格式
81
+
82
+ ---
83
+
84
+ ### 4. 信心度與不確定性標記(REQ-4)
85
+
86
+ 要求在所有建議上附加信心評分,呈現不確定性。
87
+
88
+ **格式**:
89
+ ```
90
+ 建議:[具體行動]
91
+ 信心:[1-5] — [不確定性原因]
92
+ 未知:[哪些資訊會改變這個評估]
93
+ ```
94
+
95
+ **信心度定義**:
96
+
97
+ | 等級 | 意義 |
98
+ |------|------|
99
+ | 5 | 已在類似規模驗證,高確定性 |
100
+ | 4 | 業界標準,有充分文獻支持 |
101
+ | 3 | 合理推斷,建議 PoC 驗證 |
102
+ | 2 | 不確定,強烈建議先進行 Spike |
103
+ | 1 | 高度不確定,不建議直接採用 |
104
+
105
+ **規則**:
106
+ - 信心 < 3 必須標示「需要更多資訊才能確認」
107
+ - 所有重要主張都需要信心標記
108
+ - 不確定性必須具體(說明哪些資訊可以解決不確定性)
109
+
110
+ ---
111
+
112
+ ### 5. 迎合性回應啟發式偵測(REQ-5)
113
+
114
+ 用於偵測迎合性回應的啟發式規則,可用於自動化後處理。
115
+
116
+ | 信號類型 | 偵測規則 |
117
+ |----------|----------|
118
+ | 正向開場 | 回應前 50 個 token 包含迎合性詞語(如「很好」「有趣」「當然」「當然可以」) |
119
+ | 立場翻轉 | 使用者揭示偏好後,模型在沒有新技術證據的情況下改變立場 |
120
+ | 風險淡化 | 句式:「雖然有些小問題,但整體上...」而未說明具體問題 |
121
+ | 缺乏量化 | 重要建議缺少信心評分或具體度量指標 |
122
+
123
+ **觸發條件**:偵測到 2 個以上信號 → 以 Red Team 框架觸發再評估。
124
+
125
+ ---
126
+
127
+ ## 禁止行為
128
+
129
+ | 禁止 | 正確做法 |
130
+ |------|----------|
131
+ | 以正向肯定開場批評 | 直接從分析開始 |
132
+ | 在無新技術證據的情況下改變立場 | 維持立場,或引用具體的新資訊 |
133
+ | 在無依據的情況下將風險描述為「小問題」 | 量化風險或解釋為何風險有界 |
134
+ | 提供重要建議卻不附信心評分 | 始終附上信心(1-5)與不確定性說明 |
135
+
136
+ ---
137
+
138
+ ## 與 Agent Prompt 的整合
139
+
140
+ 套用至 AI Agent 時:
141
+
142
+ | Agent 類型 | 套用規則 |
143
+ |------------|----------|
144
+ | 程式碼審查 Agent | REQ-1(Socratic)+ REQ-3(雙欄)+ REQ-5(偵測) |
145
+ | 架構建議 Agent | REQ-2(先問立場)+ REQ-4(信心度)+ REQ-5(偵測) |
146
+ | Bug 分析 Agent | REQ-1(Socratic)+ REQ-4(信心度) |
147
+ | 一般諮詢 Agent | REQ-3(雙欄)+ REQ-4(信心度) |
148
+
149
+ ---
150
+
151
+ ## 完整防迎合 Prompt 模板
152
+
153
+ ```
154
+ 你是一位對我毫無感情的領域專家。
155
+ 你的職責是找出我思考中的盲點,不是讓我感覺良好。
156
+
157
+ 規則:
158
+ - 禁止以正向詞語開場(很好、有趣、不錯、當然)
159
+ - 每個建議必須附上信心等級(1-5)和你不確定的地方
160
+ - 若你認為我的方向是錯的,直接說
161
+
162
+ 我的問題:[問題]
163
+
164
+ 請先列出這個問題中我可能持有的錯誤假設,
165
+ 再給出你認為正確的建議。
166
+ ```
167
+
168
+ ---
169
+
170
+ ## 檢查清單
171
+
172
+ - [ ] 提示詞未邀請認同(「這樣好嗎?」)
173
+ - [ ] 明確禁止正向開場詞語
174
+ - [ ] 在揭示使用者偏好前先取得模型的獨立立場(若適用)
175
+ - [ ] 評估任務強制使用雙欄格式
176
+ - [ ] 重要建議需要信心等級
177
+ - [ ] 對輸出套用迎合性偵測,再呈現給使用者
178
+
179
+ ---
180
+
181
+ ## 相關標準
182
+
183
+ - [anti-hallucination.md](../../../core/anti-hallucination.md) — 防止幻覺;與防迎合互補
184
+ - [agent-epistemic-calibration.md](../../../core/agent-epistemic-calibration.md) — Agent 設計中的認知謙遜(若適用)