universal-dev-standards 6.14.0-beta.7 → 6.14.0-beta.9

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.
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  source: ../../CHANGELOG.md
3
- source_version: 6.14.0-beta.7
4
- translation_version: 6.14.0-beta.7
5
- last_synced: 2026-10-08
3
+ source_version: 6.14.0-beta.9
4
+ translation_version: 6.14.0-beta.9
5
+ last_synced: 2026-10-10
6
6
  status: current
7
7
  ---
8
8
 
@@ -17,6 +17,44 @@ status: current
17
17
 
18
18
  ## [Unreleased]
19
19
 
20
+ ## [6.14.0-beta.9] - 2026-10-10
21
+
22
+ > **测试版**——以 `npm install -g universal-dev-standards@beta` 安装。要测什么、如何退回正式版:[docs/PRE-RELEASE.md](../../docs/PRE-RELEASE.md)。
23
+ >
24
+ > **行为改变:**对不存在的规格执行 `uds spec delete <id>`,现在不先询问,直接以结束码 1 结束。
25
+
26
+ ### Fixed
27
+
28
+ - **`uds spec delete` 先说规格不存在再问要不要删;`uds spec split` 在 `**Confirmed**` 前保留空行;`uds check` 与 `uds update` 的 error-exit 闸门提示改随界面语言(6.14.0-beta.8 macOS 人工验收时发现)。** 删除不存在的规格 ID,过去会先问「要删除吗」,答 yes 后才印「找不到规格」;现在直接印「找不到规格:<id>」并以 1 结束,不再询问。`uds spec split` 写出的新规格,`**Confirmed**: No` 原本紧贴最后一条验收条件,现在中间保留空行。`uds check`(「[error-exit] 没有错误信息单一出口检查」)与 `uds update`(询问是否写入 `scripts/check-error-exit.mjs`)过去不论界面语言一律印繁体中文,现在与 CLI 其他部分一样依界面语言显示英文、繁体中文或简体中文。闸门脚本本身(`templates/gates/check-error-exit.mjs`)仍印中文,本版未改。
29
+ - **CI:发版后验收改为等待 `npm install` 实际读取的文件,版本尚未可见时重试安装(XSPEC-471 R1)。** 6.14.0-beta.8 发布后,`wait-for-npm.mjs` 在单一版本文件回 200 时就宣告找到,但紧接的 `npm install` 在前三个作业失败(0 步执行)——`npm install` 读的是包总览文件,当时尚未更新。现在依序确认包总览列出该版本、tarball 可取得、`npm view` 看得到;`run.mjs` 遇到 E404/ETARGET 会重试安装(最多 5 次,间隔 5/10/20/40 秒,180 秒后不再开始新的尝试),并把重试次数记进报告。其他安装错误仍立即失败。`--install-retries <n>` 与 `--install-retry-wait <sec>` 可调整上限。属维护者工具,不在 npm 包内。
30
+
31
+ ## [6.14.0-beta.8] - 2026-10-10
32
+
33
+ > **测试版**——以 `npm install -g universal-dev-standards@beta` 安装。要测什么、如何退回正式版:[docs/PRE-RELEASE.md](../../docs/PRE-RELEASE.md)。
34
+ >
35
+ > **行为改变:**`uds hitl check` 无人可答时拒绝(结束码 1);`uds release verify` 失败以 1、无法验证以 2 结束;`uds release promote` 不再为没做的事印「✓」;移除 `uds mcp serve --root`;没有终端机时 `uds spec delete/split` 以 2、`uds spec create` 以 0 结束;`uds uninstall` 只移除 UDS 写的、你没改过的文件。
36
+
37
+ ### Added
38
+
39
+ - **CI:uds CLI 的每个命令、子命令与选项都要有验收步骤,而且步骤必须读回效果,不能只看退出码(XSPEC-471 R2、R3)。** `node scripts/beta-acceptance/check-cli-coverage.mjs`(CI 工作「Beta Acceptance Coverage」)加载真正的 `cli/bin/uds.js`,记录它建出的 commander 程序(含隐藏命令、隐藏选项与别名;不读帮助文本),当 `scripts/beta-acceptance/steps.json` 的任何步骤都没用到某个命令、子命令或选项时,逐一列名并使 CI 变红,并打印已用、豁免与缺少各几个。要豁免只能在 `exemptions` 加 `{"command": ...}` 或 `{"option": ...}`,并附至少 20 字符的理由;空白或单字理由等于没有豁免。加入这项检查时已存在的缺口(31 个命令与子命令、115 个选项)列在 `scripts/beta-acceptance/coverage-baseline.json`,这份文件只能减少:不在其中的缺口会红,已被步骤用到的条目若没移除也会红(`--shrink-baseline`),所以文件不会腐烂;`--baseline-not-larger-than <ref>` 会让新增条目的变更变红。`check-steps.mjs` 现在也会指名 `expect` 只有退出码的步骤(含人工步骤;`{"step": ..., "reason": ...}` 可豁免一个步骤)。**未验证**:CI 接线只由 YAML 解析器与测试读过,尚未由 GitHub 实际执行。
40
+ - **CI:`scripts/bump-version.mjs` 遇到不带预览标记的版本号,除非它最近一个预览版已在三个平台验收通过,否则拒绝(XSPEC-471 R5)。** 在改动任何文件之前,它先确认:`scripts/beta-acceptance/reports/<预览版>/` 有 Windows、macOS、Linux 三个平台、来自已发布包的报告(用 `--local-bin`、`--source` 或注入的安装器做出的报告不算;同一平台从多种 shell 跑过时,每一种都要看,取最差的),其中没有任何自动步骤失败,`check-cli-coverage.mjs` 与 `check-steps.mjs` 为绿、`coverage-baseline.json` 为空,当前 `steps.json` 的每一步都在这些报告里(预览版发布之后新增的步骤需要更新的预览版),而且 `steps.json` 没有任何豁免写明功能“已知坏掉”(R4 的写法 "known broken",`已知壞掉` 也会读)。缺的东西会在一次拒绝中全部列出,退出码为 1。没人确认的人工步骤会列出,但不挡。预览版本号不检查。这道关卡没有跳过的开关,连 `SKIP_BUNDLE_PARITY` 也管不到:补丁版先以预览版发出,发版后的验收会自动跑。规则在 `scripts/beta-acceptance/lib/stable-gate.mjs`。
41
+
42
+ ### 变更
43
+
44
+ - **行为变更——`uds release verify` 验证失败时改以退出码 1 结束,无法验证时以 2 结束(XSPEC-471 R4)。** 它打印“Manifest 驗證失敗”后仍以 0 结束,把验证当作发布关卡的脚本或 CI 步骤会把每一次失败都读成通过。退出码 0 表示 manifest 验证通过;1 表示 commit 或 artifact 的 checksum 与 manifest 的记录不符;2 表示根本无法验证:没有 `build-manifest.json`、文件不是合法 JSON、`--artifact` 指的文件不存在,或发布模式(`ci-cd`)没有 `verify`。分法与 `uds hitl check` 相同(1=答案是否,2=没有答案)。缺少 staging 结果仍只是警告,不改变退出码。若有脚本一直假设 `uds release verify` 必回 0,请处理 1 与 2。
45
+ - **`uds release promote <版本>` 不再为它没做的事打印“✓ 晉升紀錄建立”与“✓ Git tag”(XSPEC-471 R4)。** 这个命令不写晋升记录、也不建 tag,只打印文字;相信那些勾号的人可能把一个从未打过 tag 的版本拿去部署。现在它明说“這個指令不會建立晉升紀錄,也不會建立 Git tag”,并列出要你自己执行的下一步,包含 `git tag v<版本>`。没有新增任何行为:它仍然什么都不写、什么 tag 都不建。
46
+ - **行为变更——移除 `uds mcp serve` 的 `--root <path>` 选项(XSPEC-471 R4)。** 它被接受并存起来,但没有任何程序读它,所以 `--root /elsewhere` 不改变任何回答,却看起来像在指定标准从哪里来。服务器照旧从已安装的包读 UDS 随附的文件。`uds mcp serve --root <path>` 现在会以 `error: unknown option '--root'` 与退出码 1 停下;请从任何传入它的 MCP 客户端配置中移除这个选项。
47
+
48
+ ### 修复
49
+
50
+ - **`uds mcp serve`:`get_design_standards` 与 `get_design_token` 的 DESIGN.md 模板后备,在每一种安装方式下都返回 ENOENT(XSPEC-471 R4)。** 服务器去“`cli/src/mcp/` 往上四层”找 UDS 随附的文件,那个位置在仓库之外,已安装的包也一样在包之外。现在改找包的 `bundled/` 文件夹,在源码检出时则找 `cli/` 的上一层。服务器的单元测试把文件系统换掉了,所以从没发现;新增的端到端测试会启动真正的 `uds mcp serve` 并读回响应。
51
+ - **`uds release deploy <env>` 在“`release-config.yaml` 是 UDS 自己生成”的项目里,拒绝每一个环境(XSPEC-471 R4)。** `uds init` 与 `uds config` 把 `release.environments` 写成对象(`- name: staging`),检查却拿用户输入的名称去比这些对象,于是说“未知的环境”并列出 `[object Object]`。现在对象形式与纯名称都能读懂。
52
+ - **`uds agent list` 与 `uds agent info` 显示空白的说明,也没有专长、工具、技能(XSPEC-471 R4)。** 代理文件是 YAML(`description: |`、列表),读取程序一次只看一行 `key: value`,把说明看成 `|`。现在 front matter 以 YAML 解析。
53
+ - **行为变更——`uds hitl check` 在无法询问时不再以退出码 0 结束(XSPEC-471 R4)。** 没有终端可回答、也没有 `CI` 变量时,高风险的 `--op` 会打开一个永远等不到回答的提示,打印堆栈跟踪后以 0 结束,脚本会把它当成“已批准”。现在打印“Blocked (Safety First)”与“Denied”并以 1 结束,与 CI 下相同。`uds hitl check` 没给 `--op` 时以 2 结束(原本是 0)。
54
+ - **`uds list` 只显示它所计算的 163 个标准中的 81 个,而且拒绝 `--category core`(编写 XSPEC-471 R4 验收步骤时发现)。** “Total”行计入注册表中的每一个标准,但列表只走固定的五个分类,所以 `core`、`testing`、`security`、`deployment`、`operations` 这五个分类里的 82 个标准被计入却从未显示,`uds list --category core` 还回答“Unknown category”。现在列表会显示注册表里有标准的每一个分类,每个分类各有标题与数量,标题上的数字加起来等于 Total;这五个分类已声明在 `cli/standards-registry.json`(并注明它们不由 `uds init` 安装,要用 `uds update --apply --add-standard` 按编号加入),日后注册表新增的分类会以它自己的名称列出,不会再被丢掉。“有效分类”提示现在列出全部十个。标题与 Total 不一致时 `npm test` 会失败。
55
+ - **`uds quickstart`、`uds spec create`、`uds spec delete`、`uds spec split` 在没有任何东西能回答它们的问题时,以 Node 堆栈跟踪结束,且退出码为 0(编写 XSPEC-471 R4 验收步骤时发现)。** 在没有终端的环境(AI 助手、CI、管道)运行时,它们画出问题后就死在 `ExitPromptError`,整次运行看起来像成功。`uds update` 与 `uds uninstall` 早先已用同样方式修复。现在:`uds quickstart` 打印四个流程与各自的命令(这份指南本来的工作就是列出命令);没给 `--yes` 的 `uds spec create` 把已写好的规格留作草稿并说明如何确认(退出码 0);没给 `--yes` 的 `uds spec delete` 什么都不删、说明要加 `--yes` 重跑,并以 2 结束(原为 0);`uds spec split` 什么都不改、说明要在终端运行,并以 2 结束(原为 0)。有终端时行为不变。
56
+ - **验收步骤 `init-locale-pack-missing-is-said` 在任何跑过 `prepack` 的 checkout 上,用 `run.mjs --local-bin cli/bin/uds.js` 会失败(XSPEC-471 R5)。** 它以 `cli/bundled/` 是否存在来区分已发布包与源码 checkout,但源码 checkout 在 `prepack` 之后也有那个文件夹,于是“缺少 zh-TW 技能文本”的副本被建在仓库根目录,`skills-installer.js` 照样在那里找到 `locales/zh-TW`,装了中文技能。现在步骤改问 `locales/zh-TW` 是否在 `cli/` 旁边。已发布的包从未受影响,`uds init` 也没有。
57
+
20
58
  ## [6.14.0-beta.7] - 2026-10-08
21
59
 
22
60
  > **测试版**——以 `npm install -g universal-dev-standards@beta` 安装。要测什么、如何退回正式版:[docs/PRE-RELEASE.md](../../docs/PRE-RELEASE.md)。
@@ -15,7 +15,7 @@ status: current
15
15
 
16
16
  > **语言**: [English](../../README.md) | [繁體中文](../zh-TW/README.md) | 简体中文
17
17
 
18
- **版本**: 6.14.0-beta.7 (Pre-release) | **发布日期**: 2026-10-07 | **授权**: [双重授权](../../LICENSE) (CC BY 4.0 + MIT)
18
+ **版本**: 6.14.0-beta.9 (Pre-release) | **发布日期**: 2026-10-07 | **授权**: [双重授权](../../LICENSE) (CC BY 4.0 + MIT)
19
19
 
20
20
  语言无关、框架无关的软件项目文档标准。通过 AI 原生工作流,确保不同技术栈之间的一致性、质量和可维护性。
21
21
 
@@ -13,7 +13,7 @@ status: current
13
13
  <!-- UDS_SUPPORTED_VERSIONS_START -->
14
14
  | 版本 | 支持状态 |
15
15
  |------|--------|
16
- | 6.14.0-beta.7 | ✅ 预发布版本 |
16
+ | 6.14.0-beta.9 | ✅ 预发布版本 |
17
17
  | 6.13.1 | ✅ 最新正式版 |
18
18
  | < 6.0.0 | ❌ 已终止支持 |
19
19
  <!-- UDS_SUPPORTED_VERSIONS_END -->
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  source: ../../CHANGELOG.md
3
- source_version: 6.14.0-beta.7
4
- translation_version: 6.14.0-beta.7
5
- last_synced: 2026-10-08
3
+ source_version: 6.14.0-beta.9
4
+ translation_version: 6.14.0-beta.9
5
+ last_synced: 2026-10-10
6
6
  status: current
7
7
  ---
8
8
 
@@ -17,6 +17,44 @@ status: current
17
17
 
18
18
  ## [Unreleased]
19
19
 
20
+ ## [6.14.0-beta.9] - 2026-10-10
21
+
22
+ > **測試版**——以 `npm install -g universal-dev-standards@beta` 安裝。要測什麼、如何退回正式版:[docs/PRE-RELEASE.md](../../docs/PRE-RELEASE.md)。
23
+ >
24
+ > **行為改變:**對不存在的規格執行 `uds spec delete <id>`,現在不先詢問,直接以結束碼 1 結束。
25
+
26
+ ### Fixed
27
+
28
+ - **`uds spec delete` 先說規格不存在再問要不要刪;`uds spec split` 在 `**Confirmed**` 前保留空行;`uds check` 與 `uds update` 的 error-exit 閘門提示改隨介面語言(6.14.0-beta.8 macOS 人工驗收時發現)。** 刪除不存在的規格 ID,過去會先問「要刪除嗎」,答 yes 後才印「找不到規格」;現在直接印「找不到規格:<id>」並以 1 結束,不再詢問。`uds spec split` 寫出的新規格,`**Confirmed**: No` 原本緊貼最後一條驗收條件,現在中間保留空行。`uds check`(「[error-exit] 沒有錯誤訊息單一出口檢查」)與 `uds update`(詢問是否寫入 `scripts/check-error-exit.mjs`)過去不論介面語言一律印繁體中文,現在與 CLI 其他部分一樣依介面語言顯示英文、繁體中文或簡體中文。閘門腳本本身(`templates/gates/check-error-exit.mjs`)仍印中文,本版未改。
29
+ - **CI:發版後驗收改為等待 `npm install` 實際讀取的文件,版本尚未可見時重試安裝(XSPEC-471 R1)。** 6.14.0-beta.8 發布後,`wait-for-npm.mjs` 在單一版本文件回 200 時就宣告找到,但緊接的 `npm install` 在前三個工作失敗(0 步執行)——`npm install` 讀的是套件總覽文件,當時尚未更新。現在依序確認套件總覽列出該版本、tarball 可取得、`npm view` 看得到;`run.mjs` 遇到 E404/ETARGET 會重試安裝(最多 5 次,間隔 5/10/20/40 秒,180 秒後不再開始新的嘗試),並把重試次數記進報告。其他安裝錯誤仍立即失敗。`--install-retries <n>` 與 `--install-retry-wait <sec>` 可調整上限。屬維護者工具,不在 npm 套件內。
30
+
31
+ ## [6.14.0-beta.8] - 2026-10-10
32
+
33
+ > **測試版**——以 `npm install -g universal-dev-standards@beta` 安裝。要測什麼、如何退回正式版:[docs/PRE-RELEASE.md](../../docs/PRE-RELEASE.md)。
34
+ >
35
+ > **行為改變:**`uds hitl check` 無人可答時拒絕(結束碼 1);`uds release verify` 失敗以 1、無法驗證以 2 結束;`uds release promote` 不再為沒做的事印「✓」;移除 `uds mcp serve --root`;沒有終端機時 `uds spec delete/split` 以 2、`uds spec create` 以 0 結束;`uds uninstall` 只移除 UDS 寫的、你沒改過的檔。
36
+
37
+ ### Added
38
+
39
+ - **CI:uds CLI 的每個指令、子指令與選項都要有驗收步驟,而且步驟必須讀回效果,不能只看結束碼(XSPEC-471 R2、R3)。** `node scripts/beta-acceptance/check-cli-coverage.mjs`(CI 工作「Beta Acceptance Coverage」)載入真正的 `cli/bin/uds.js`,記錄它建出的 commander 程式(含隱藏指令、隱藏選項與別名;不讀說明文字),當 `scripts/beta-acceptance/steps.json` 的任何步驟都沒用到某個指令、子指令或選項時,逐一列名並使 CI 變紅,並印出已用、豁免與缺少各幾個。要豁免只能在 `exemptions` 加 `{"command": ...}` 或 `{"option": ...}`,並附至少 20 字元的理由;空白或單字理由等於沒有豁免。加入這項檢查時已存在的缺口(31 個指令與子指令、115 個選項)列在 `scripts/beta-acceptance/coverage-baseline.json`,這份檔案只能減少:不在其中的缺口會紅,已被步驟用到的項目若沒移除也會紅(`--shrink-baseline`),所以檔案不會腐爛;`--baseline-not-larger-than <ref>` 會讓新增項目的變更變紅。`check-steps.mjs` 現在也會指名 `expect` 只有結束碼的步驟(含人工步驟;`{"step": ..., "reason": ...}` 可豁免一個步驟)。**未驗證**:CI 接線只由 YAML 解析器與測試讀過,尚未由 GitHub 實際執行。
40
+ - **CI:`scripts/bump-version.mjs` 遇到不帶預覽標記的版號,除非它最近一個預覽版已在三個平台驗收通過,否則拒絕(XSPEC-471 R5)。** 在改動任何檔案之前,它先確認:`scripts/beta-acceptance/reports/<預覽版>/` 有 Windows、macOS、Linux 三個平台、來自已發布套件的報告(用 `--local-bin`、`--source` 或注入的安裝器做出的報告不算;同一平台從多種殼層跑過時,每一種都要看,取最差的),其中沒有任何自動步驟失敗,`check-cli-coverage.mjs` 與 `check-steps.mjs` 為綠、`coverage-baseline.json` 為空,目前 `steps.json` 的每一步都在這些報告裡(預覽版發布之後新增的步驟需要更新的預覽版),而且 `steps.json` 沒有任何豁免寫明功能「已知壞掉」(R4 的寫法 "known broken",`已知壞掉` 也會讀)。缺的東西會在一次拒絕中全部列出,結束碼為 1。沒人確認的人工步驟會列出,但不擋。預覽版號不檢查。這道關卡沒有跳過的開關,連 `SKIP_BUNDLE_PARITY` 也管不到:修補版先以預覽版發出,發版後的驗收會自動跑。規則在 `scripts/beta-acceptance/lib/stable-gate.mjs`。
41
+
42
+ ### 變更
43
+
44
+ - **行為變更——`uds release verify` 驗證失敗時改以結束碼 1 結束,無法驗證時以 2 結束(XSPEC-471 R4)。** 它印出「Manifest 驗證失敗」後仍以 0 結束,把驗證當作發布關卡的腳本或 CI 步驟會把每一次失敗都讀成通過。結束碼 0 表示 manifest 驗證通過;1 表示 commit 或 artifact 的 checksum 與 manifest 的紀錄不符;2 表示根本無法驗證:沒有 `build-manifest.json`、檔案不是合法 JSON、`--artifact` 指的檔案不存在,或發布模式(`ci-cd`)沒有 `verify`。分法與 `uds hitl check` 相同(1=答案是否,2=沒有答案)。缺少 staging 結果仍只是警告,不改變結束碼。若有腳本一直假設 `uds release verify` 必回 0,請處理 1 與 2。
45
+ - **`uds release promote <版本>` 不再為它沒做的事印出「✓ 晉升紀錄建立」與「✓ Git tag」(XSPEC-471 R4)。** 這個指令不寫晉升紀錄、也不建 tag,只印出文字;相信那些勾號的人可能把一個從未打過 tag 的版本拿去部署。現在它明說「這個指令不會建立晉升紀錄,也不會建立 Git tag」,並列出要你自己執行的下一步,包含 `git tag v<版本>`。沒有新增任何行為:它仍然什麼都不寫、什麼 tag 都不建。
46
+ - **行為變更——移除 `uds mcp serve` 的 `--root <path>` 選項(XSPEC-471 R4)。** 它被接受並存起來,但沒有任何程式讀它,所以 `--root /elsewhere` 不改變任何回答,卻看起來像在指定標準從哪裡來。伺服器照舊從已安裝的套件讀 UDS 隨附的檔案。`uds mcp serve --root <path>` 現在會以 `error: unknown option '--root'` 與結束碼 1 停下;請從任何傳入它的 MCP 用戶端設定中移除這個選項。
47
+
48
+ ### 修正
49
+
50
+ - **`uds mcp serve`:`get_design_standards` 與 `get_design_token` 的 DESIGN.md 範本後備,在每一種安裝方式下都回 ENOENT(XSPEC-471 R4)。** 伺服器去「`cli/src/mcp/` 往上四層」找 UDS 隨附的檔案,那個位置在 repository 之外,已安裝的套件也一樣在套件之外。現在改找套件的 `bundled/` 資料夾,在原始碼檢出時則找 `cli/` 的上一層。伺服器的單元測試把檔案系統換掉了,所以從沒看到;新增的端對端測試會啟動真正的 `uds mcp serve` 並讀回回應。
51
+ - **`uds release deploy <env>` 在「`release-config.yaml` 是 UDS 自己產生」的專案裡,拒絕每一個環境(XSPEC-471 R4)。** `uds init` 與 `uds config` 把 `release.environments` 寫成物件(`- name: staging`),檢查卻拿使用者輸入的名稱去比那些物件,於是說「未知的環境」並列出 `[object Object]`。現在物件形式與純名稱都讀得懂。
52
+ - **`uds agent list` 與 `uds agent info` 顯示空白的說明,也沒有專長、工具、技能(XSPEC-471 R4)。** 代理檔是 YAML(`description: |`、清單),讀取程式一次只看一行 `key: value`,把說明看成 `|`。現在 front matter 以 YAML 解析。
53
+ - **行為變更——`uds hitl check` 在無法詢問時不再以結束碼 0 結束(XSPEC-471 R4)。** 沒有終端機可回答、也沒有 `CI` 變數時,高風險的 `--op` 會開一個永遠等不到回答的提示,印出堆疊追蹤後以 0 結束,腳本會把它當成「已核准」。現在印出「Blocked (Safety First)」與「Denied」並以 1 結束,與 CI 下相同。`uds hitl check` 沒給 `--op` 時以 2 結束(原本是 0)。
54
+ - **`uds list` 只顯示它所計算的 163 個標準中的 81 個,而且拒絕 `--category core`(撰寫 XSPEC-471 R4 驗收步驟時發現)。** 「Total」行計入登錄檔中的每一個標準,但列表只走固定的五個分類,所以 `core`、`testing`、`security`、`deployment`、`operations` 這五個分類裡的 82 個標準被計入卻從未顯示,`uds list --category core` 還回答「Unknown category」。現在列表會顯示登錄檔裡有標準的每一個分類,每個分類各有標題與數量,標題上的數字加起來等於 Total;這五個分類已宣告在 `cli/standards-registry.json`(並註明它們不由 `uds init` 安裝,要用 `uds update --apply --add-standard` 依編號加入),日後登錄檔新增的分類會以它自己的名稱列出,不會再被丟掉。「有效分類」提示現在列出全部十個。標題與 Total 不一致時 `npm test` 會失敗。
55
+ - **`uds quickstart`、`uds spec create`、`uds spec delete`、`uds spec split` 在沒有任何東西能回答它們的問題時,以 Node 堆疊追蹤結束,且結束碼為 0(撰寫 XSPEC-471 R4 驗收步驟時發現)。** 在沒有終端機的環境(AI 助理、CI、管線)執行時,它們畫出問題後就死在 `ExitPromptError`,整次執行看起來像成功。`uds update` 與 `uds uninstall` 早先已用同樣方式修正。現在:`uds quickstart` 印出四個流程與各自的指令(這份指南本來的工作就是列出指令);沒給 `--yes` 的 `uds spec create` 把已寫好的規格留作草稿並說明如何確認(結束碼 0);沒給 `--yes` 的 `uds spec delete` 什麼都不刪、說明要加 `--yes` 重跑,並以 2 結束(原為 0);`uds spec split` 什麼都不改、說明要在終端機執行,並以 2 結束(原為 0)。有終端機時行為不變。
56
+ - **驗收步驟 `init-locale-pack-missing-is-said` 在任何跑過 `prepack` 的 checkout 上,用 `run.mjs --local-bin cli/bin/uds.js` 會失敗(XSPEC-471 R5)。** 它以 `cli/bundled/` 是否存在來分辨已發布套件與原始碼 checkout,但原始碼 checkout 在 `prepack` 之後也有那個資料夾,於是「缺少 zh-TW 技能文字」的複本被建在 repository 根目錄,`skills-installer.js` 照樣在那裡找到 `locales/zh-TW`,裝了中文技能。現在步驟改問 `locales/zh-TW` 是否在 `cli/` 旁邊。已發布的套件從未受影響,`uds init` 也沒有。
57
+
20
58
  ## [6.14.0-beta.7] - 2026-10-08
21
59
 
22
60
  > **測試版**——以 `npm install -g universal-dev-standards@beta` 安裝。要測什麼、如何退回正式版:[docs/PRE-RELEASE.md](../../docs/PRE-RELEASE.md)。
@@ -15,7 +15,7 @@ status: current
15
15
 
16
16
  > **語言**: [English](../../README.md) | 繁體中文 | [简体中文](../zh-CN/README.md)
17
17
 
18
- **版本**: 6.14.0-beta.7 (Pre-release) | **發布日期**: 2026-10-07 | **授權**: [雙重授權](../../LICENSE) (CC BY 4.0 + MIT)
18
+ **版本**: 6.14.0-beta.9 (Pre-release) | **發布日期**: 2026-10-07 | **授權**: [雙重授權](../../LICENSE) (CC BY 4.0 + MIT)
19
19
 
20
20
  語言無關、框架無關的軟體專案文件標準。透過 AI 原生工作流,確保不同技術堆疊之間的一致性、品質和可維護性。
21
21
 
@@ -13,7 +13,7 @@ status: current
13
13
  <!-- UDS_SUPPORTED_VERSIONS_START -->
14
14
  | 版本 | 支援狀態 |
15
15
  |------|--------|
16
- | 6.14.0-beta.7 | ✅ 預發布版本 |
16
+ | 6.14.0-beta.9 | ✅ 預發布版本 |
17
17
  | 6.13.1 | ✅ 最新正式版 |
18
18
  | < 6.0.0 | ❌ 已終止支援 |
19
19
  <!-- UDS_SUPPORTED_VERSIONS_END -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-dev-standards",
3
- "version": "6.14.0-beta.7",
3
+ "version": "6.14.0-beta.9",
4
4
  "description": "CLI tool for adopting Universal Development Standards",
5
5
  "keywords": [
6
6
  "documentation",
@@ -1354,10 +1354,11 @@ function checkErrorExitGate(projectPath) {
1354
1354
  if (!existsSync(join(projectPath, 'src'))) {
1355
1355
  return;
1356
1356
  }
1357
- console.log(chalk.yellow(' ⚠ [error-exit] 沒有錯誤訊息單一出口檢查(scripts/check-error-exit.mjs)。'));
1358
- console.log(chalk.gray(' 這道閘門防的是「每個呼叫端各自把錯誤回應拼成給人看的字串」——'));
1359
- console.log(chalk.gray(' 第一處是實作,第二處開始就會各寫各的,而畫面上只剩一句 Bad Request。'));
1360
- console.log(chalk.gray(' 要裝的話:`uds update` 會顯示內容並徵求同意後寫入。'));
1357
+ const m = t().commands.check.errorExitGate;
1358
+ console.log(chalk.yellow(m.missing));
1359
+ console.log(chalk.gray(m.why1));
1360
+ console.log(chalk.gray(m.why2));
1361
+ console.log(chalk.gray(m.howTo));
1361
1362
  console.log();
1362
1363
  }
1363
1364
 
@@ -7,16 +7,19 @@ const MAX_OP_LENGTH = 500;
7
7
  export async function hitlCommand(options) {
8
8
  if (!options.op) {
9
9
  console.error(chalk.red('Error: --op <operation> is required'));
10
+ process.exit(2); // not 0: a caller that reads the exit code must not take a missing question for "allowed"
10
11
  return;
11
12
  }
12
13
 
13
14
  const op = String(options.op).trim();
14
15
  if (op.length === 0) {
15
16
  console.error(chalk.red('Error: --op must not be empty'));
17
+ process.exit(2);
16
18
  return;
17
19
  }
18
20
  if (op.length > MAX_OP_LENGTH) {
19
21
  console.error(chalk.red(`Error: --op must be ≤ ${MAX_OP_LENGTH} characters (got ${op.length})`));
22
+ process.exit(2);
20
23
  return;
21
24
  }
22
25
 
@@ -8,6 +8,14 @@ import {
8
8
  import { readManifest, isInitialized } from '../utils/copier.js';
9
9
  import { t, getLanguage, setLanguage, isLanguageExplicitlySet } from '../i18n/messages.js';
10
10
 
11
+ /**
12
+ * The order the listing shows its categories in. A category the registry holds standards for but that is not named
13
+ * here is still listed (after these, under its own key): the "Total" line counts every standard in the registry, so a
14
+ * category that was left out of the display used to make the total larger than the list (82 of 163 standards were
15
+ * counted and never shown, and `--category core` was refused as unknown).
16
+ */
17
+ const CATEGORY_ORDER = ['skill', 'reference', 'core', 'testing', 'security', 'deployment', 'operations', 'extension', 'integration', 'template'];
18
+
11
19
  /**
12
20
  * List command - displays available standards
13
21
  * @param {Object} options - Command options
@@ -44,7 +52,8 @@ export function listCommand(options) {
44
52
  const categoryInfo = getCategoryInfo(category);
45
53
  if (!categoryInfo) {
46
54
  console.log(chalk.red(`${msg.errorUnknownCategory} '${category}'`));
47
- console.log(chalk.gray(msg.validCategories));
55
+ const valid = CATEGORY_ORDER.filter((c) => getCategoryInfo(c));
56
+ console.log(chalk.gray(`${msg.validCategories} ${valid.join(', ')}`));
48
57
  process.exit(1);
49
58
  }
50
59
  standards = getStandardsByCategory(category);
@@ -65,13 +74,13 @@ export function listCommand(options) {
65
74
  }
66
75
 
67
76
  // Display each category
68
- const categoryOrder = ['skill', 'reference', 'extension', 'integration', 'template'];
77
+ const categoryOrder = [...CATEGORY_ORDER, ...Object.keys(grouped).filter((c) => !CATEGORY_ORDER.includes(c))];
69
78
 
70
79
  for (const cat of categoryOrder) {
71
80
  if (!grouped[cat] || grouped[cat].length === 0) continue;
72
81
 
73
82
  const catInfo = getCategoryInfo(cat);
74
- console.log(chalk.yellow.bold(`${catInfo.name} (${grouped[cat].length})`));
83
+ console.log(chalk.yellow.bold(`${catInfo?.name ?? cat} (${grouped[cat].length})`));
75
84
 
76
85
  for (const std of grouped[cat]) {
77
86
  const name = std.skillName
@@ -16,9 +16,8 @@ export function mcpCommand(program) {
16
16
  mcp
17
17
  .command('serve')
18
18
  .description('Start MCP Design Standards Server (stdio transport)')
19
- .option('--root <path>', 'UDS standards root path', process.cwd())
20
- .action((options) => {
21
- const server = new McpServer({ udsRoot: options.root });
19
+ .action(() => {
20
+ const server = new McpServer();
22
21
  server.start();
23
22
  // Log to stderr only — stdout is reserved for MCP JSON-RPC messages
24
23
  process.stderr.write('UDS MCP Design Standards Server started (stdio)\n');
@@ -21,6 +21,7 @@
21
21
 
22
22
  import chalk from 'chalk';
23
23
  import { select } from '@inquirer/prompts';
24
+ import { isPromptClosed } from '../utils/prompt-closed.js';
24
25
 
25
26
  export const WORKFLOWS = [
26
27
  {
@@ -64,6 +65,18 @@ export const WORKFLOWS = [
64
65
  },
65
66
  ];
66
67
 
68
+ /** Print one workflow: its name, what it is for, and its numbered commands. */
69
+ function printWorkflow(workflow) {
70
+ console.log(chalk.bold(`\n${workflow.name}\n`));
71
+ console.log(chalk.gray(`${workflow.description}\n`));
72
+
73
+ for (let i = 0; i < workflow.steps.length; i++) {
74
+ const step = workflow.steps[i];
75
+ console.log(` ${chalk.cyan(`${i + 1}.`)} ${chalk.yellow(step.cmd)}`);
76
+ console.log(` ${chalk.gray(step.desc)}\n`);
77
+ }
78
+ }
79
+
67
80
  /**
68
81
  * Execute the quickstart command
69
82
  */
@@ -77,20 +90,23 @@ export async function quickstartCommand() {
77
90
  description: w.description,
78
91
  }));
79
92
 
80
- const selected = await select({
81
- message: 'Which workflow do you want to follow?',
82
- choices,
83
- });
84
-
85
- const workflow = WORKFLOWS[selected];
86
- console.log(chalk.bold(`\n${workflow.name}\n`));
87
- console.log(chalk.gray(`${workflow.description}\n`));
88
-
89
- for (let i = 0; i < workflow.steps.length; i++) {
90
- const step = workflow.steps[i];
91
- console.log(` ${chalk.cyan(`${i + 1}.`)} ${chalk.yellow(step.cmd)}`);
92
- console.log(` ${chalk.gray(step.desc)}\n`);
93
+ let selected;
94
+ try {
95
+ selected = await select({
96
+ message: 'Which workflow do you want to follow?',
97
+ choices,
98
+ });
99
+ } catch (promptError) {
100
+ if (!isPromptClosed(promptError)) throw promptError;
101
+ // Nothing can answer (not a terminal: an AI assistant, CI, a pipe). The guide's whole job is to show the commands, so show all of them
102
+ // rather than a stack trace and an exit code of 0.
103
+ console.log(chalk.gray('Nothing here can answer the question (not a terminal), so every workflow is shown.'));
104
+ for (const workflow of WORKFLOWS) printWorkflow(workflow);
105
+ console.log(chalk.gray('Tip: Run "uds quickstart" in a terminal to pick one workflow.\n'));
106
+ return;
93
107
  }
94
108
 
109
+ printWorkflow(WORKFLOWS[selected]);
110
+
95
111
  console.log(chalk.gray('Tip: Run each command in order. Use "uds quickstart" anytime to see this guide again.\n'));
96
112
  }
@@ -7,8 +7,17 @@
7
7
  * deploy — Record deployment to environment (manual/hybrid mode)
8
8
  * manifest — Generate build-manifest.json (manual/hybrid mode)
9
9
  * verify — Verify manifest against git state (manual/hybrid mode)
10
+ *
11
+ * Exit codes of `verify` (a script that gates a release on it must never read a failure as a pass):
12
+ * 0 the manifest verified
13
+ * 1 verification FAILED (commit or checksum does not match what the manifest records)
14
+ * 2 could not verify (no manifest, unreadable manifest, artifact not found, or the mode has no verify)
15
+ * 1 = "the answer is no", 2 = "no answer", the same split as `uds hitl check`.
10
16
  */
11
17
 
18
+ const EXIT_VERIFY_FAILED = 1;
19
+ const EXIT_CANNOT_VERIFY = 2;
20
+
12
21
  import chalk from 'chalk';
13
22
  import * as yaml from 'js-yaml';
14
23
  import { existsSync, readFileSync, writeFileSync } from 'fs';
@@ -16,7 +25,7 @@ import { join } from 'path';
16
25
  import { execSync } from 'child_process';
17
26
  import { createHash } from 'crypto';
18
27
  import { resolveReleaseWorkflow } from '../utils/release-config.js';
19
- import { formatGitTag, createPromotionRecord, parseRCVersion, isStableVersion } from '../utils/version-promote.js';
28
+ import { formatGitTag, parseRCVersion, isStableVersion } from '../utils/version-promote.js';
20
29
 
21
30
  // Default deployment environments (overridable via release-config.yaml release.environments)
22
31
  const DEFAULT_ENVIRONMENTS = ['development', 'staging', 'canary', 'preview', 'production'];
@@ -39,6 +48,20 @@ function loadReleaseConfig(projectPath) {
39
48
  }
40
49
  }
41
50
 
51
+ /**
52
+ * The deployment environment names a release-config.yaml declares, or null when it declares none.
53
+ * An entry is a name (`- staging`) or the object `uds config` writes (`- name: staging`, with `type` and so on).
54
+ * The object form used to be compared as if it were a name, so a project set up by UDS itself could not deploy anywhere.
55
+ */
56
+ function configuredEnvironmentNames(releaseConfig) {
57
+ const declared = releaseConfig?.release?.environments;
58
+ if (!Array.isArray(declared)) return null;
59
+ const names = declared
60
+ .map((entry) => (entry && typeof entry === 'object' ? entry.name : entry))
61
+ .filter((name) => typeof name === 'string' && name.trim() !== '');
62
+ return names.length > 0 ? names : null;
63
+ }
64
+
42
65
  /**
43
66
  * Load deployments.yaml
44
67
  */
@@ -151,9 +174,13 @@ export async function releaseCommand(subcommand, args, options) {
151
174
  case 'verify':
152
175
  if (!workflow.hasManifest) {
153
176
  console.log(chalk.red('verify 子命令僅在 manual 或 hybrid 模式下可用。'));
177
+ process.exitCode = EXIT_CANNOT_VERIFY; // nothing was verified; 0 would read as "verified"
154
178
  return;
155
179
  }
156
- await handleVerify(projectPath, options);
180
+ {
181
+ const verifyExit = await handleVerify(projectPath, options);
182
+ if (verifyExit !== 0) process.exitCode = verifyExit; // wire:release-verify-exit
183
+ }
157
184
  break;
158
185
 
159
186
  default:
@@ -203,16 +230,12 @@ async function handlePromote(targetVersion, projectPath) {
203
230
  console.log(chalk.gray(` 晉升目標: ${targetVersion}`));
204
231
  }
205
232
 
206
- // Create promotion record
207
- const record = createPromotionRecord(currentVersion || 'unknown', targetVersion);
208
- console.log();
209
- console.log(chalk.green(` ✓ 晉升紀錄建立: ${record.promoted_from} → ${record.version}`));
210
-
211
- // Create git tag
233
+ // This command only prints. It writes no promotion record and creates no git tag, so it must not say it did.
212
234
  const tag = formatGitTag(targetVersion);
213
- console.log(chalk.green(` ✓ Git tag: ${tag}`));
214
235
  console.log();
215
- console.log(chalk.cyan('後續步驟:'));
236
+ console.log(chalk.yellow('這個指令不會建立晉升紀錄,也不會建立 Git tag;它只列出下一步要執行的事。'));
237
+ console.log();
238
+ console.log(chalk.cyan('下一步(由你執行):'));
216
239
  console.log(chalk.gray(` 1. 更新版本檔案為 ${targetVersion}`));
217
240
  console.log(chalk.gray(` 2. git tag ${tag}`));
218
241
  console.log(chalk.gray(' 3. 從此 commit 重新打包'));
@@ -234,10 +257,7 @@ async function handleDeploy(environment, options, projectPath) {
234
257
 
235
258
  // Validate environment against allow-list (overridable via release-config.yaml)
236
259
  const deployConfig = loadReleaseConfig(projectPath);
237
- const allowedEnvironments =
238
- Array.isArray(deployConfig?.release?.environments) && deployConfig.release.environments.length > 0
239
- ? deployConfig.release.environments
240
- : DEFAULT_ENVIRONMENTS;
260
+ const allowedEnvironments = configuredEnvironmentNames(deployConfig) || DEFAULT_ENVIRONMENTS;
241
261
  if (!allowedEnvironments.includes(environment)) {
242
262
  console.log(chalk.red(`未知的部署環境: ${environment}`));
243
263
  console.log(chalk.gray(` 允許的環境: ${allowedEnvironments.join(', ')}`));
@@ -335,6 +355,8 @@ async function handleManifest(versionArg, options, projectPath) {
335
355
  *
336
356
  * T13 (XSPEC-292): when --artifact is given, compute its SHA256 so verify
337
357
  * actually CONSUMES the checksum recorded in the manifest, not just stores it.
358
+ *
359
+ * @returns {Promise<number>} the exit code: 0 verified, EXIT_VERIFY_FAILED, or EXIT_CANNOT_VERIFY
338
360
  */
339
361
  async function handleVerify(projectPath, options = {}) {
340
362
  const manifestPath = join(projectPath, 'build-manifest.json');
@@ -342,7 +364,7 @@ async function handleVerify(projectPath, options = {}) {
342
364
  if (!existsSync(manifestPath)) {
343
365
  console.log(chalk.red('找不到 build-manifest.json'));
344
366
  console.log(chalk.gray(' 請先執行 uds release manifest'));
345
- return;
367
+ return EXIT_CANNOT_VERIFY;
346
368
  }
347
369
 
348
370
  let manifest;
@@ -350,7 +372,7 @@ async function handleVerify(projectPath, options = {}) {
350
372
  manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));
351
373
  } catch {
352
374
  console.log(chalk.red('build-manifest.json 格式不正確'));
353
- return;
375
+ return EXIT_CANNOT_VERIFY;
354
376
  }
355
377
  const currentCommit = getGitCommit();
356
378
 
@@ -360,7 +382,7 @@ async function handleVerify(projectPath, options = {}) {
360
382
  if (artifactPath) {
361
383
  if (!existsSync(artifactPath)) {
362
384
  console.log(chalk.red(`找不到 artifact:${artifactPath}`));
363
- return;
385
+ return EXIT_CANNOT_VERIFY;
364
386
  }
365
387
  actualChecksum = createHash('sha256').update(readFileSync(artifactPath)).digest('hex');
366
388
  }
@@ -396,6 +418,8 @@ async function handleVerify(projectPath, options = {}) {
396
418
  } else {
397
419
  console.log(chalk.yellow(' Staging: 未通過或無紀錄'));
398
420
  }
421
+
422
+ return result.valid ? 0 : EXIT_VERIFY_FAILED;
399
423
  }
400
424
 
401
425
  /**
@@ -13,6 +13,7 @@ import { MicroSpec } from '../vibe/micro-spec.js';
13
13
  import { existsSync, readFileSync, writeFileSync, mkdirSync, copyFileSync } from 'node:fs';
14
14
  import { join } from 'node:path';
15
15
  import { withFileTransaction } from '../utils/transaction.js';
16
+ import { isPromptClosed } from '../utils/prompt-closed.js';
16
17
 
17
18
  /**
18
19
  * Extract acceptance criteria from spec markdown
@@ -86,25 +87,36 @@ export async function specSplitCommand(id, options = {}) {
86
87
  }
87
88
  console.log();
88
89
 
89
- // Interactive selection: which ACs to move to new spec
90
- const toMove = await checkbox({
91
- message: 'Select ACs to move to a NEW spec (remaining stay in original):',
92
- choices: acs.map(ac => ({
93
- name: `${ac.id}: ${ac.text.substring(ac.id.length + 1).trim().substring(0, 60)}`,
94
- value: ac.id,
95
- })),
96
- });
97
-
98
- if (toMove.length === 0 || toMove.length === acs.length) {
99
- console.log(chalk.yellow('Must select some (but not all) ACs to move. Aborting.'));
90
+ // Interactive selection: which ACs to move to new spec. Nothing can be written before both answers are in,
91
+ // so a prompt that cannot be answered (not a terminal) changes nothing and says so.
92
+ let toMove;
93
+ let proceed;
94
+ try {
95
+ toMove = await checkbox({
96
+ message: 'Select ACs to move to a NEW spec (remaining stay in original):',
97
+ choices: acs.map(ac => ({
98
+ name: `${ac.id}: ${ac.text.substring(ac.id.length + 1).trim().substring(0, 60)}`,
99
+ value: ac.id,
100
+ })),
101
+ });
102
+
103
+ if (toMove.length === 0 || toMove.length === acs.length) {
104
+ console.log(chalk.yellow('Must select some (but not all) ACs to move. Aborting.'));
105
+ return;
106
+ }
107
+
108
+ proceed = await inquirerConfirm({
109
+ message: `Split ${id}: keep ${acs.length - toMove.length} ACs, move ${toMove.length} ACs to new spec?`,
110
+ default: true,
111
+ });
112
+ } catch (promptError) {
113
+ if (!isPromptClosed(promptError)) throw promptError;
114
+ console.log(chalk.red('\nCannot ask which ACs to move: there is nothing attached to answer the prompt (non-interactive shell, CI, or a pipe).'));
115
+ console.log(chalk.gray(` Run \`uds spec split ${id}\` in a terminal. Nothing has been changed.`));
116
+ process.exitCode = 2;
100
117
  return;
101
118
  }
102
119
 
103
- const proceed = await inquirerConfirm({
104
- message: `Split ${id}: keep ${acs.length - toMove.length} ACs, move ${toMove.length} ACs to new spec?`,
105
- default: true,
106
- });
107
-
108
120
  if (!proceed) {
109
121
  console.log(chalk.gray('Split cancelled.'));
110
122
  return;
@@ -152,7 +164,8 @@ export async function specSplitCommand(id, options = {}) {
152
164
  const acSection = movedACLines.join('\n');
153
165
  const finalContent = newContent.replace(
154
166
  /\*\*Acceptance\*\*:[\s\S]*?(?=\n\*\*|$)/,
155
- `**Acceptance**:\n${acSection}`
167
+ // The lazy match stops before the blank line that ends the section, so give it back (or **Confirmed** sticks to the last AC).
168
+ `**Acceptance**:\n${acSection}\n`
156
169
  );
157
170
 
158
171
  // T11 (XSPEC-292 §9.2): the two writes must be atomic. If creating the new
@@ -15,6 +15,7 @@ import { existsSync, readFileSync } from 'node:fs';
15
15
  import { join } from 'node:path';
16
16
  import { MicroSpec, SpecStatus } from '../vibe/micro-spec.js';
17
17
  import { msg } from '../i18n/messages.js';
18
+ import { isPromptClosed } from '../utils/prompt-closed.js';
18
19
 
19
20
  /**
20
21
  * Get localized message with fallback
@@ -69,15 +70,25 @@ export async function specCreateCommand(intent, options = {}) {
69
70
 
70
71
  // Ask for confirmation unless --yes flag
71
72
  if (!options.yes) {
72
- const action = await select({
73
- message: t('spec.confirmQuestion', 'How would you like to proceed?'),
74
- choices: [
75
- { name: t('spec.confirm', 'Confirm and proceed'), value: 'confirm' },
76
- { name: t('spec.edit', 'Edit the spec'), value: 'edit' },
77
- { name: t('spec.skip', 'Skip (keep as draft)'), value: 'skip' },
78
- { name: t('spec.discard', 'Discard'), value: 'discard' }
79
- ]
80
- });
73
+ let action;
74
+ try {
75
+ action = await select({
76
+ message: t('spec.confirmQuestion', 'How would you like to proceed?'),
77
+ choices: [
78
+ { name: t('spec.confirm', 'Confirm and proceed'), value: 'confirm' },
79
+ { name: t('spec.edit', 'Edit the spec'), value: 'edit' },
80
+ { name: t('spec.skip', 'Skip (keep as draft)'), value: 'skip' },
81
+ { name: t('spec.discard', 'Discard'), value: 'discard' }
82
+ ]
83
+ });
84
+ } catch (promptError) {
85
+ if (!isPromptClosed(promptError)) throw promptError;
86
+ // Nothing can answer (not a terminal): the spec is already written, so it stays a draft and the person is told how to confirm it.
87
+ console.log('');
88
+ console.log(chalk.yellow(t('spec.cannotAsk', 'Nothing here can answer the question, so the spec stays a draft.')));
89
+ console.log(chalk.gray(t('spec.cannotAskHint', 'Run `uds spec confirm <id>` to confirm it, or create it with --yes.')));
90
+ action = 'skip';
91
+ }
81
92
 
82
93
  if (action === 'confirm') {
83
94
  microSpec.confirm(spec.id);
@@ -264,11 +275,28 @@ export async function specDeleteCommand(id, options = {}) {
264
275
  output: options.output
265
276
  });
266
277
 
278
+ // Look the spec up before asking: asking "delete it?" about a spec that is not there, then saying so, wastes the answer.
279
+ if (!microSpec.get(id)) {
280
+ console.log(chalk.red(t('spec.notFound', 'Spec not found: ') + id));
281
+ process.exitCode = 1;
282
+ return;
283
+ }
284
+
267
285
  if (!options.yes) {
268
- const confirmed = await inquirerConfirm({
269
- message: t('spec.deleteConfirm', `Are you sure you want to delete spec '${id}'?`),
270
- default: false
271
- });
286
+ let confirmed;
287
+ try {
288
+ confirmed = await inquirerConfirm({
289
+ message: t('spec.deleteConfirm', `Are you sure you want to delete spec '${id}'?`),
290
+ default: false
291
+ });
292
+ } catch (promptError) {
293
+ if (!isPromptClosed(promptError)) throw promptError;
294
+ // Not auto-confirming: an unattended run must not be allowed to delete what a person was asked about.
295
+ console.log(chalk.red(t('spec.cannotConfirmDelete', 'Cannot ask for confirmation: there is nothing attached to answer the prompt (non-interactive shell, CI, or a pipe).')));
296
+ console.log(chalk.gray(t('spec.cannotConfirmDeleteHint', 'Re-run with --yes to delete. Nothing has been deleted.')));
297
+ process.exitCode = 2;
298
+ return;
299
+ }
272
300
 
273
301
  if (!confirmed) {
274
302
  console.log(chalk.gray(t('spec.deleteCancelled', 'Delete cancelled.')));