@aibyzero/cm-workflow 0.13.2 → 0.13.3

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,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-workflow",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "Spec-driven product development workflow for Codex: external research, PRD, implementation, read-only feature testing, review, QA, fixes, refactors, and documentation.",
5
5
  "author": {
6
6
  "name": "cm-workflow maintainers",
package/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@
7
7
 
8
8
  (暂无)
9
9
 
10
+ ## 0.13.3 — 2026-09-17
11
+
12
+ - 第 28 步:`cm-runtime` 无参数在 TTY 中进入范围、工具/写码方、确认三问向导,复用安装器提问与既有 set/decision 日志,完成后显示有效配置;非 TTY 退出 2。安装器、向导与诊断共用系统语言中英文文案,机器字段不变;会话无参数按对话语言提问,文档与帮助同步。
13
+ - 测试隔离:7 个宿主测试文件把 `CM_WORKFLOW_HOME` / `CM_WORKFLOW_LOG_HOME` 指向进程专属临时目录,本机存在用户级 `runtimes.yml` 时不再有 6 个夹具误判为 declared-adapter。
14
+
10
15
  ## 0.13.2 — 2026-09-17
11
16
 
12
17
  - 第 27 步:三种安装器交互声明单/双 AI 与谁写代码,原子保存用户级 `~/.cm-workflow/runtimes.yml`;非交互/yes 不写。配置按项目 > 用户 > 未声明解析并输出来源,cm-init 优先继承。新增独立 `cm-runtime show/set/set --user/unset --user` 与兼容别名,保留项目其他原文、复用诊断与决策日志,只影响新 run;同步检查、分发清单与文档。
package/README.md CHANGED
@@ -17,6 +17,11 @@
17
17
 
18
18
  ## 最近更新
19
19
 
20
+ **0.13.3**
21
+
22
+ - **`cm-runtime` 直接敲就是向导**:不带参数运行时按编号三问——改哪一层(当前项目 / 用户级默认)→ 手上有哪个 AI(只有 Codex / 只有 Claude / 两个都有)→ 谁写代码,预览后确认才写入,然后回显有效配置;非终端环境只打印用法并退出 2,脚本化仍用 `show` / `set` / `unset --user`。
23
+ - **中英文提示跟随系统语言**:安装器、向导与人类可读诊断按 `CM_WORKFLOW_LANG` > `LC_ALL` > `LC_MESSAGES` > `LANG` > Node Intl 判定中文或英文(Windows 安装器传 `Get-Culture`);预设名、机器字段与退出码不变。
24
+
20
25
  **0.13.2**
21
26
 
22
27
  - **安装时声明单/双 AI 与谁写代码**:`install.sh` / `install.ps1` / `install-codex.sh` 装完后问一次"只有 Codex / 只有 Claude / 两个都有→谁写代码",保存为用户级默认 `~/.cm-workflow/runtimes.yml`(`--yes` 或非终端跳过);配置解析顺序改为 项目 > 用户默认 > 未声明,`cm-init` 有默认时不再重复询问。
@@ -96,7 +101,7 @@ $cm-check
96
101
 
97
102
  仓库直接分发 Skills 和脚本,无需在仓库根目录运行 `npm install` 或构建。完整安装行为、覆盖范围和卸载说明见[安装指南](docs/installation.md)。
98
103
 
99
- 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.13.2 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
104
+ 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.13.3 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
100
105
 
101
106
  ## 升级旧版本
102
107
 
@@ -140,7 +145,7 @@ git pull --ff-only origin main
140
145
  | 测试已有功能 | `$cm-test {项目路径}` | 分层测试结果与证据 |
141
146
  | 修复可复现缺陷 | `$cm-fix {specs路径} {项目路径} {问题}` | 红灯测试、最小修复、回归验证 |
142
147
  | 整理结构并保持行为 | `$cm-refactor` | 按行为等价约束分批重构 |
143
- | 查看/切换运行时声明 | `$cm-runtime show` / `set codex-codes` / `set --user claude-only` / `unset --user` | 有效声明、来源与新 run 的派发偏好 |
148
+ | 查看/切换运行时声明 | `$cm-runtime` 三问向导;支持 `show` / `set` / `unset --user` | 会话随对话语言、终端随系统语言中英提示;仅影响新 run |
144
149
  | 检查安装与工作流 | `$cm-check` | 环境、引用和合同检查结果 |
145
150
 
146
151
  需要单独讨论方案或研究复杂问题时,可显式使用可选工具 `$external-expert`。外部建议由本地核验,不能代替独立代码审查或测试证据。详见[使用手册](docs/user-guide.md)与[外部专家合同](runtime/external-expert.md)。
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.2
1
+ 0.13.3
@@ -73,7 +73,7 @@ Install or upgrade with the same command:
73
73
  npx @aibyzero/cm-workflow@latest install
74
74
  ```
75
75
 
76
- To pin a version, use `npx @aibyzero/cm-workflow@0.13.2 install` from outside
76
+ To pin a version, use `npx @aibyzero/cm-workflow@0.13.3 install` from outside
77
77
  the CM Workflow source checkout (for example, your home directory). Inside a
78
78
  checkout with the same package name and version, npm can select the local
79
79
  uninstalled package and report `cm-workflow: command not found`.
@@ -230,7 +230,7 @@ ask which tools you have: Codex only, Claude only, or both. When both are select
230
230
  choose the coder (Codex recommended, Claude reviews; or the reverse).
231
231
  The shared prompt writes only `~/.cm-workflow/runtimes.yml` using a temporary file
232
232
  and atomic rename. It never changes settings.json or CLAUDE.md.
233
- An existing declaration is displayed and “保留?[Y/n]” defaults to keeping it.
233
+ An existing declaration is displayed and “Keep it? [Y/n]” (or “保留?[Y/n]”) defaults to keeping it.
234
234
  `--yes` (Bash), `-Yes` (PowerShell, also implies the existing `-Force`), `-Force`,
235
235
  or non-TTY input/output skips this prompt without creating or changing the file.
236
236
 
@@ -247,7 +247,22 @@ The preset supplies coder/reviewer adapter/source defaults; explicit project rol
247
247
  fields still take precedence and conflicts fail validation. `cm-init` inherits the
248
248
  user default without asking again and reports `来源: 用户级默认`.
249
249
 
250
- Use `$cm-runtime` in Codex, `/cm-runtime` in Claude Code, or `/cm:runtime` on macOS/Linux:
250
+ Run `$cm-runtime` in Codex, `/cm-runtime` in Claude Code, or `/cm:runtime` on macOS/Linux
251
+ without arguments for three questions in your current conversation language:
252
+ `[1] Current project / [2] User default` → `[1] Codex only / [2] Claude only / [3] Both`
253
+ (with `[1] Codex writes, Claude reviews (recommended) / [2] Claude writes, Codex reviews`
254
+ when both are selected) → preview the preset/current value and confirm `[Y/n]`.
255
+ In a terminal, `node <workflow-root>/scripts/cm-runtime.mjs [--project PATH]` opens the same wizard.
256
+ Scope defaults to 1 with an existing project config, otherwise 2. Choosing 1 without a config
257
+ announces creation from the template. The tool question has no default. Ctrl+C, three consecutive
258
+ empty answers to that required question, or declining confirmation cancels without writing.
259
+ Without a TTY, no command prints usage and exits 2.
260
+
261
+ Installer prompts, terminal wizard, diagnostics and the user-file comment use Chinese or English:
262
+ `CM_WORKFLOW_LANG=zh|en` > `LC_ALL` > `LC_MESSAGES` > `LANG` > Node Intl locale > English fallback.
263
+ A locale starting with `zh` selects Chinese; other locales select English. Windows `install.ps1`
264
+ passes `(Get-Culture).Name` as the locale. Machine keys, preset/adapter names and exit codes stay unchanged.
265
+ For scripting, use explicit commands:
251
266
 
252
267
  ```text
253
268
  cm-runtime show [--project PATH]
@@ -573,6 +573,19 @@ $cm-security {项目路径} --semgrep-rules {外部本地规则文件} --osv-db
573
573
  | `codex-codes` | Codex | Claude |
574
574
  | `claude-codes` | Claude | Codex |
575
575
 
576
+ 直接输入 `$cm-runtime`(Claude Code 为 `/cm-runtime`)即可由会话按当前对话语言三问:
577
+ `[1] 当前项目 / [2] 用户级默认` → `[1] 只有 Codex / [2] 只有 Claude / [3] 两个都有`
578
+ (选 3 再选 `[1] Codex 写、Claude 审(推荐) / [2] Claude 写、Codex 审`)→ 显示预设和当前值并确认。
579
+ 终端无参数运行 `node <workflow-root>/scripts/cm-runtime.mjs [--project PATH]` 进入同一向导。
580
+ 有项目配置时范围默认 1,否则默认 2;无配置选 1 会提示从模板新建。工具问题必须选择;
581
+ Ctrl+C、必选问题连续三次空输入或拒绝确认均不写。非 TTY 无参数打印用法并退出 2。
582
+
583
+ 安装器、终端向导与人类可读诊断按系统语言显示中文或英文:
584
+ `CM_WORKFLOW_LANG=zh|en` > `LC_ALL` > `LC_MESSAGES` > `LANG` > Node Intl > 英文兜底;
585
+ locale 以 `zh` 开头用中文,其他用英文。Windows 安装器传入 `Get-Culture` 作为 locale。
586
+ 机器字段、预设名和退出码保持不变;用户默认文件的注释也随语言切换。
587
+ 自动化可继续使用显式子命令:
588
+
576
589
  ```text
577
590
  $cm-runtime show
578
591
  $cm-runtime set claude-codes --project /path/to/project
package/install.ps1 CHANGED
@@ -196,7 +196,7 @@ try {
196
196
  if ($InstallComplete) {
197
197
  # User runtimes.yml: same JS authority and atomic writer as Bash/Codex.
198
198
  if (-not $Yes -and -not $Force -and -not [Console]::IsInputRedirected -and -not [Console]::IsOutputRedirected) {
199
- & node (Join-Path $Dest "scripts/cm-runtime-install.mjs")
199
+ & node (Join-Path $Dest "scripts/cm-runtime-install.mjs") --lang (Get-Culture).Name
200
200
  if ($LASTEXITCODE -ne 0) { throw "运行时声明未完成(核心安装已成功)" }
201
201
  }
202
202
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibyzero/cm-workflow",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "Spec-driven business development workflow for Pi, Codex, and Claude Code",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -1,5 +1,5 @@
1
1
  import {buildManifest} from './cm-spec-manifest.mjs';
2
- import test from 'node:test';
2
+ import test,{after} from 'node:test';
3
3
  import assert from 'node:assert/strict';
4
4
  import fs from 'node:fs';
5
5
  import os from 'node:os';
@@ -17,6 +17,12 @@ import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
17
17
  import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
18
18
  import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
19
19
 
20
+ // Keep runtime declarations and log mirrors independent of the invoking user's home.
21
+ const isolatedWorkflowHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-ai-bootstrap-home-'));
22
+ process.env.CM_WORKFLOW_HOME=path.join(isolatedWorkflowHome,'user');
23
+ process.env.CM_WORKFLOW_LOG_HOME=path.join(isolatedWorkflowHome,'logs');
24
+ after(()=>fs.rmSync(isolatedWorkflowHome,{recursive:true,force:true}));
25
+
20
26
  const workflowRoot=fileURLToPath(new URL('..',import.meta.url)).replace(/\/$/,'');
21
27
  const selection={versionControl:'none',modules:['frontend'],analysis:'Approved synthetic JavaScript project'};
22
28
  const checks=()=>Object.fromEntries(['commands','globs','file_references','constraint_preservation','rule_applicability']
@@ -1,5 +1,5 @@
1
1
  import {buildManifest} from './cm-spec-manifest.mjs';
2
- import test from 'node:test';
2
+ import test,{after} from 'node:test';
3
3
  import assert from 'node:assert/strict';
4
4
  import fs from 'node:fs';
5
5
  import os from 'node:os';
@@ -10,6 +10,12 @@ import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
10
10
  import {createConversationExecution} from './cm-ai-host.mjs';
11
11
  import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
12
12
 
13
+ // Keep runtime declarations and log mirrors independent of the invoking user's home.
14
+ const isolatedWorkflowHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-ai-host-home-'));
15
+ process.env.CM_WORKFLOW_HOME=path.join(isolatedWorkflowHome,'user');
16
+ process.env.CM_WORKFLOW_LOG_HOME=path.join(isolatedWorkflowHome,'logs');
17
+ after(()=>fs.rmSync(isolatedWorkflowHome,{recursive:true,force:true}));
18
+
13
19
  const cli=fileURLToPath(new URL('./cm-ai-host.mjs',import.meta.url));
14
20
  const identity={repositoryId:'host-fixture',runId:'host-fixture-run',taskId:'T-001',attempt:1};
15
21
  const request=(operation,requestId=operation)=>({version:1,operation,requestId,identity});
@@ -1,5 +1,5 @@
1
1
  import {buildManifest} from './cm-spec-manifest.mjs';
2
- import test from 'node:test';
2
+ import test,{after} from 'node:test';
3
3
  import assert from 'node:assert/strict';
4
4
  import fs from 'node:fs';
5
5
  import path from 'node:path';
@@ -14,6 +14,12 @@ import {applyProtectedEdits,captureProtectedEdits,commitProtectedEdits} from '..
14
14
  import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
15
15
  import {reviewResult,reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
16
16
 
17
+ // Keep runtime declarations and log mirrors independent of the invoking user's home.
18
+ const isolatedWorkflowHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-ai-multi-root-home-'));
19
+ process.env.CM_WORKFLOW_HOME=path.join(isolatedWorkflowHome,'user');
20
+ process.env.CM_WORKFLOW_LOG_HOME=path.join(isolatedWorkflowHome,'logs');
21
+ after(()=>fs.rmSync(isolatedWorkflowHome,{recursive:true,force:true}));
22
+
17
23
  const identity={repositoryId:'multi-root-fixture',runId:'r3-fixture',taskId:'T-001',attempt:1};
18
24
  const checks=[{id:'aggregate',command:['node','check.mjs'],outcome:'passed',exitCode:0,evidence:'Synthetic aggregate check'}];
19
25
  const moduleURL=new URL('../runtime/js/cm-ai/review-package.mjs',import.meta.url).href;
@@ -1,4 +1,4 @@
1
- import test from 'node:test';
1
+ import test,{after} from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import fs from 'node:fs';
4
4
  import os from 'node:os';
@@ -11,6 +11,12 @@ import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
11
11
  import {buildManifest} from './cm-spec-manifest.mjs';
12
12
  import {loadConfig,resolveProtectedRuntimes} from './cm-workflow-config.mjs';
13
13
 
14
+ // Keep runtime declarations and log mirrors independent of the invoking user's home.
15
+ const isolatedWorkflowHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-ai-nested-execution-home-'));
16
+ process.env.CM_WORKFLOW_HOME=path.join(isolatedWorkflowHome,'user');
17
+ process.env.CM_WORKFLOW_LOG_HOME=path.join(isolatedWorkflowHome,'logs');
18
+ after(()=>fs.rmSync(isolatedWorkflowHome,{recursive:true,force:true}));
19
+
14
20
  const supported=process.platform==='darwin'&&Number(process.versions.node.split('.')[0])>=24;
15
21
  const identity={repositoryId:'fixture',runId:'nested-run',taskId:'T-001',attempt:1};
16
22
  const request=operation=>({version:1,operation,requestId:operation,identity});
@@ -1,4 +1,4 @@
1
- import test from 'node:test';
1
+ import test,{after} from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
@@ -8,6 +8,12 @@ import {once} from 'node:events';
8
8
  import {createInterface} from 'node:readline';
9
9
  import {fileURLToPath} from 'node:url';
10
10
  import {createCmCheckHost} from '../runtime/js/cm-check/host.mjs';
11
+
12
+ // Keep runtime declarations and log mirrors independent of the invoking user's home.
13
+ const isolatedWorkflowHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-check-host-home-'));
14
+ process.env.CM_WORKFLOW_HOME=path.join(isolatedWorkflowHome,'user');
15
+ process.env.CM_WORKFLOW_LOG_HOME=path.join(isolatedWorkflowHome,'logs');
16
+ after(()=>fs.rmSync(isolatedWorkflowHome,{recursive:true,force:true}));
11
17
  const root=fileURLToPath(new URL('..',import.meta.url));
12
18
  function fixture(t,exitCode=0){
13
19
  const dir=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-check-host-'))),project=path.join(dir,'project');fs.mkdirSync(project);
@@ -1,4 +1,4 @@
1
- import test from 'node:test';
1
+ import test,{after} from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import fs from 'node:fs';
4
4
  import os from 'node:os';
@@ -12,6 +12,12 @@ import {checkN4} from './cm-task-gate.mjs';
12
12
  import {fixCompletionProjection} from '../runtime/js/cm-fix/finish.mjs';
13
13
  import {loadConfig,resolveRole} from './cm-workflow-config.mjs';
14
14
 
15
+ // Keep runtime declarations and log mirrors independent of the invoking user's home.
16
+ const isolatedWorkflowHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-fix-host-review-home-'));
17
+ process.env.CM_WORKFLOW_HOME=path.join(isolatedWorkflowHome,'user');
18
+ process.env.CM_WORKFLOW_LOG_HOME=path.join(isolatedWorkflowHome,'logs');
19
+ after(()=>fs.rmSync(isolatedWorkflowHome,{recursive:true,force:true}));
20
+
15
21
  for(const runtime of ['codex','claude']){
16
22
  test(`${runtime} CLI cause review requires opt-in and matching diagnostic, then resumes without dispatch`,async()=>{
17
23
  const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-host-review-')));
@@ -1,4 +1,4 @@
1
- import test from 'node:test';
1
+ import test,{after} from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
@@ -10,6 +10,12 @@ import {fileURLToPath} from 'node:url';
10
10
  import {inspectPrdChangeSnapshot,inspectPrdChangeProposal,applyPrdChange} from '../runtime/js/cm-prd/change.mjs';
11
11
  import {loadConfig} from './cm-workflow-config.mjs';
12
12
  import {recordPrdReview} from './cm-prd-review-gate.mjs';
13
+
14
+ // Keep runtime declarations and log mirrors independent of the invoking user's home.
15
+ const isolatedWorkflowHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-prd-completion-home-'));
16
+ process.env.CM_WORKFLOW_HOME=path.join(isolatedWorkflowHome,'user');
17
+ process.env.CM_WORKFLOW_LOG_HOME=path.join(isolatedWorkflowHome,'logs');
18
+ after(()=>fs.rmSync(isolatedWorkflowHome,{recursive:true,force:true}));
13
19
  const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
14
20
  const version='\n| 日期 | 版本 | 说明 |\n| --- | --- | --- |\n| 2026-09-08 | v1 | original |\n';
15
21
  const docs=()=>[
@@ -0,0 +1,32 @@
1
+ // Human-readable runtime text only; persisted keys and preset identifiers stay stable.
2
+ export function runtimeLanguage(env=process.env,intlLocale=()=>Intl.DateTimeFormat().resolvedOptions().locale){
3
+ if(['zh','en'].includes(env.CM_WORKFLOW_LANG))return env.CM_WORKFLOW_LANG;
4
+ const locale=env.LC_ALL||env.LC_MESSAGES||env.LANG;
5
+ if(locale)return /^zh/i.test(locale)?'zh':'en';
6
+ try{return /^zh/i.test(intlLocale()||'')?'zh':'en';}catch{return 'en';}
7
+ }
8
+ export const messages={
9
+ tools:{zh:'你手上有哪个 AI 工具?[1] 只有 Codex [2] 只有 Claude [3] 两个都有: ',en:'Which AI tools do you have? [1] Codex only [2] Claude only [3] Both: '},
10
+ coder:{zh:'谁写代码?[1] Codex(Claude 审,推荐) [2] Claude(Codex 审): ',en:'Who writes code? [1] Codex (Claude reviews, recommended) [2] Claude (Codex reviews): '},
11
+ scope:{zh:'改哪一层?[1] 当前项目({project}) [2] 用户级默认({user}) [{default}]: ',en:'Which scope? [1] Current project ({project}) [2] User default ({user}) [{default}]: '},
12
+ create:{zh:'将从模板新建项目配置:{file}\n',en:'Will create project configuration from the template: {file}\n'},
13
+ current:{zh:'当前用户级默认: {available} / {preset}\n',en:'Current user default: {available} / {preset}\n'},
14
+ invalid:{zh:'当前用户级默认无效: {error}\n',en:'Invalid user default: {error}\n'},
15
+ keep:{zh:'保留?[Y/n] ',en:'Keep it? [Y/n] '},
16
+ preview:{zh:'将写入: {file}\n预设: {preset}\n当前值:\n{current}\n',en:'Will write: {file}\nPreset: {preset}\nCurrent value:\n{current}\n'},
17
+ absent:{zh:'未声明',en:'Undeclared'},
18
+ confirm:{zh:'确认?[Y/n] ',en:'Confirm? [Y/n] '},
19
+ cancelled:{zh:'已放弃,未修改运行时声明。\n',en:'Cancelled; runtime declaration unchanged.\n'},
20
+ installed:{zh:'✓ 用户级运行时默认已写入 {file} ({preset})\n',en:'✓ User runtime default saved to {file} ({preset})\n'},
21
+ comment:{zh:'用 cm-runtime set --user <preset> 修改用户级默认。',en:'Use cm-runtime set --user <preset> to change the user default.'},
22
+ declared:{zh:'(已声明未派发)',en:' (declared, not dispatched)'},
23
+ cli:{zh:'{runtime} CLI: 可解析(可解析≠配额可用)',en:'{runtime} CLI: resolvable (presence does not prove quota)'},
24
+ warning:{zh:'WARN: runtimes.available 声明 {available},但本机 {runtime} CLI 不可解析(可解析≠配额可用)',en:'WARN: runtimes.available declares {available}, but {runtime} CLI is not resolvable (presence does not prove quota)'},
25
+ saved:{zh:'已保存 {file}: {preset} ({source});已有 run 不变',en:'Saved {file}: {preset} ({source}); existing runs unchanged'},
26
+ removed:{zh:'已删除用户默认: {file};项目声明仍优先',en:'Removed user default: {file}; project declarations still take precedence'},
27
+ help:{zh:'cm-runtime [--project PATH]:无参数在 TTY 下进入交互向导;非 TTY 显示用法并退出 2。',en:'cm-runtime [--project PATH]: no command opens the interactive wizard in a TTY; non-TTY prints usage and exits 2.'},
28
+ failed:{zh:'运行时声明未完成: {error}',en:'Runtime declaration incomplete: {error}'},
29
+ };
30
+ export function runtimeText(key,lang=runtimeLanguage(),values={}){
31
+ return messages[key][lang].replace(/\{(\w+)\}/g,(_,name)=>String(values[name]??`{${name}}`));
32
+ }
@@ -3,40 +3,66 @@
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import {fileURLToPath} from 'node:url';
6
- import {createInterface} from 'node:readline/promises';
6
+ import {createInterface} from 'node:readline';
7
7
  import {userRuntimesPath,readConfigText,parseUserRuntimes} from './cm-workflow-config.mjs';
8
8
  import {writeUserRuntime} from './cm-runtime.mjs';
9
+ import {runtimeLanguage,runtimeText as t} from './cm-runtime-i18n.mjs';
9
10
 
10
- export async function promptRuntime(argv=process.argv.slice(2),input=process.stdin,output=process.stdout){
11
- if(argv.some(arg=>arg!=='--yes'))throw new Error('usage: cm-runtime-install.mjs [--yes]');
12
- if(argv.includes('--yes')||!input.isTTY||!output.isTTY)return;
13
- const rl=createInterface({input,output});let closed=false;
14
- rl.on('close',()=>{closed=true;});
15
- const ask=async question=>{
16
- if(closed)throw new Error('输入已关闭,未修改运行时声明');
17
- return (await rl.question(question)).trim();
11
+ export class PromptCancelled extends Error {}
12
+ // Queue lines so injected streams and pasted answers cannot lose later responses.
13
+ export function runtimeQuestions(input,output,lang=runtimeLanguage()){
14
+ const rl=createInterface({input,output,terminal:false});
15
+ const queue=[];let pending=null,closed=false,cancelled=false;
16
+ rl.on('line',line=>{if(pending){const resolve=pending;pending=null;resolve(line);}else queue.push(line);});
17
+ const close=()=>{closed=true;if(pending){pending(null);pending=null;}};
18
+ rl.on('close',close);
19
+ const interrupt=()=>{cancelled=true;queue.length=0;rl.close();close();};
20
+ rl.on('SIGINT',interrupt);process.on('SIGINT',interrupt);
21
+ return {
22
+ async ask(question){
23
+ if(cancelled||closed&&!queue.length)throw new PromptCancelled();
24
+ output.write(question);
25
+ const answer=queue.length?queue.shift():await new Promise(resolve=>{pending=resolve;});
26
+ if(answer===null||cancelled)throw new PromptCancelled();
27
+ return answer.trim();
28
+ },
29
+ close(){process.removeListener('SIGINT',interrupt);rl.close();},
18
30
  };
31
+ }
32
+ export async function askRuntimePreset(ask,lang=runtimeLanguage()){
33
+ let choice,empty=0;
34
+ do{
35
+ choice=await ask(t('tools',lang));
36
+ if(choice===''){if(++empty===3)throw new PromptCancelled();}else empty=0;
37
+ }while(!['1','2','3'].includes(choice));
38
+ if(choice!=='3')return choice==='1'?'codex-only':'claude-only';
39
+ let coder;
40
+ do{coder=await ask(t('coder',lang));}while(!['','1','2'].includes(coder));
41
+ return coder==='2'?'claude-codes':'codex-codes';
42
+ }
43
+ export async function promptRuntime(argv=process.argv.slice(2),input=process.stdin,output=process.stdout){
44
+ const args=[...argv];let culture;
45
+ const index=args.indexOf('--lang');
46
+ if(index>=0){culture=args[index+1];if(!culture||culture.startsWith('--'))throw new Error('missing --lang value');args.splice(index,2);}
47
+ if(args.some(arg=>arg!=='--yes'))throw new Error('usage: cm-runtime-install.mjs [--yes] [--lang CULTURE]');
48
+ if(args.includes('--yes')||!input.isTTY||!output.isTTY)return;
49
+ const lang=runtimeLanguage({...process.env,...(culture?{LANG:culture}:{})});
50
+ const questions=runtimeQuestions(input,output,lang),ask=questions.ask;
19
51
  try{
20
52
  const file=userRuntimesPath();
21
53
  if(fs.existsSync(file)){
22
54
  try{
23
55
  const current=parseUserRuntimes(readConfigText(file));
24
- output.write(`当前用户级默认: ${current.runtimes.available} / ${current.preset}\n`);
25
- }catch(error){output.write(`当前用户级默认无效: ${error.message}\n`);}
26
- const keep=await ask('保留?[Y/n] ');
56
+ output.write(t('current',lang,{available:current.runtimes.available,preset:current.preset}));
57
+ }catch(error){output.write(t('invalid',lang,{error:error.message}));}
58
+ const keep=await ask(t('keep',lang));
27
59
  if(keep!=='n'&&keep!=='N')return;
28
60
  }
29
- let choice;
30
- do{choice=await ask('你手上有哪个 AI 工具?[1] 只有 Codex [2] 只有 Claude [3] 两个都有: ');}while(!['1','2','3'].includes(choice));
31
- let preset=choice==='1'?'codex-only':'claude-only';
32
- if(choice==='3'){
33
- let coder;
34
- do{coder=await ask('谁写代码?[1] Codex(Claude 审,推荐) [2] Claude(Codex 审): ');}while(!['','1','2'].includes(coder));
35
- preset=coder==='2'?'claude-codes':'codex-codes';
36
- }
37
- output.write(`✓ 用户级运行时默认已写入 ${writeUserRuntime(preset)} (${preset})\n`);
38
- }finally{rl.close();}
61
+ const preset=await askRuntimePreset(ask,lang);
62
+ output.write(t('installed',lang,{file:writeUserRuntime(preset,{lang}),preset}));
63
+ }catch(error){if(error instanceof PromptCancelled)output.write(t('cancelled',lang));else throw error;}
64
+ finally{questions.close();}
39
65
  }
40
66
  if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){
41
- try{await promptRuntime();}catch(error){console.error(`运行时声明未完成: ${error.message}`);process.exitCode=1;}
67
+ try{await promptRuntime();}catch(error){console.error(t('failed',undefined,{error:error.message}));process.exitCode=1;}
42
68
  }
@@ -8,6 +8,9 @@ import {fileURLToPath} from 'node:url';
8
8
  import {ConfigError,findConfig,loadConfig,readConfigText,parseUserRuntimes,
9
9
  userRuntimesPath,runtimePreset,RUNTIME_PRESETS,resolveRole,runtimesSource} from './cm-workflow-config.mjs';
10
10
  import {editRuntimeDeclaration} from './cm-runtime-edit.mjs';
11
+ import {runtimeLanguage,runtimeText as t} from './cm-runtime-i18n.mjs';
12
+ import {askRuntimePreset,runtimeQuestions,PromptCancelled} from './cm-runtime-install.mjs';
13
+ export {askRuntimePreset} from './cm-runtime-install.mjs';
11
14
  import {probeRuntimes} from './cm-failover.mjs';
12
15
 
13
16
  const scripts=path.dirname(fileURLToPath(import.meta.url));
@@ -29,10 +32,10 @@ export function atomicRuntimeWrite(file,text,{before=null,privateFile=false}={})
29
32
  fs.renameSync(temporary,file);
30
33
  }finally{if(stat(temporary))fs.unlinkSync(temporary);}
31
34
  }
32
- export function writeUserRuntime(preset){
35
+ export function writeUserRuntime(preset,{lang=runtimeLanguage()}={}){
33
36
  const declaration=runtimePreset(preset),file=userRuntimesPath();
34
37
  safeTarget(file);
35
- const text=`# 用 cm-runtime set --user <preset> 修改用户级默认。\nruntimes: {available: ${declaration.runtimes.available}}\npreset: ${preset}\n`;
38
+ const text=`# ${t('comment',lang)}\nruntimes: {available: ${declaration.runtimes.available}}\npreset: ${preset}\n`;
36
39
  parseUserRuntimes(text);
37
40
  atomicRuntimeWrite(file,text,{before:stat(file)?fs.readFileSync(file):null,privateFile:true});
38
41
  return file;
@@ -54,7 +57,7 @@ export function setProjectRuntime(project,preset){
54
57
  loadConfig({projectRoot:root,configPath:file,text});
55
58
  atomicRuntimeWrite(file,text,{before});return file;
56
59
  }
57
- export function showRuntime(project,{runtime=process.env.CM_RUNTIME||'codex',probe=probeRuntimes}={}){
60
+ export function showRuntime(project,{runtime=process.env.CM_RUNTIME||'codex',probe=probeRuntimes,lang=runtimeLanguage()}={}){
58
61
  const config=loadConfig({projectRoot:project});
59
62
  const preset=Object.keys(RUNTIME_PRESETS).find(name=>{
60
63
  const value=runtimePreset(name);
@@ -64,12 +67,12 @@ export function showRuntime(project,{runtime=process.env.CM_RUNTIME||'codex',pro
64
67
  const lines=[`runtimes.available: ${config.runtimes.available}`,`preset: ${preset}`,`runtimes_source: ${runtimesSource(config)}`];
65
68
  for(const role of ['coder','reviewer']){
66
69
  const resolved=resolveRole(config,role,runtime);
67
- lines.push(`${role}: adapter=${resolved.adapter} source=${resolved.source} route_state=${resolved.route_state}${resolved.route_state==='declared-adapter'?'(已声明未派发)':''}`);
70
+ lines.push(`${role}: adapter=${resolved.adapter} source=${resolved.source} route_state=${resolved.route_state}${resolved.route_state==='declared-adapter'?t('declared',lang):''}`);
68
71
  }
69
72
  const wanted=config.runtimes.available==='both'?['codex','claude']:config.runtimes.available==='unknown'?[]:[config.runtimes.available];
70
73
  for(const result of probe(wanted))lines.push(result.available
71
- ?`${result.runtime} CLI: 可解析(可解析≠配额可用)`
72
- :`WARN: runtimes.available 声明 ${config.runtimes.available},但本机 ${result.runtime} CLI 不可解析(可解析≠配额可用)`);
74
+ ?t('cli',lang,{runtime:result.runtime})
75
+ :t('warning',lang,{available:config.runtimes.available,runtime:result.runtime}));
73
76
  return lines.join('\n');
74
77
  }
75
78
  function logSet(preset,source,project){
@@ -87,11 +90,38 @@ function logSet(preset,source,project){
87
90
  }
88
91
  throw new ConfigError('preference saved, decision log failed: Python 3.9+ lock adapter unavailable');
89
92
  }
90
- const USAGE='cm-runtime show [--project PATH]\ncm-runtime set <preset> [--project PATH]\ncm-runtime set --user <preset>\ncm-runtime unset --user';
91
- export function main(argv=process.argv.slice(2)){
93
+ const COMMANDS='cm-runtime show [--project PATH]\ncm-runtime set <preset> [--project PATH]\ncm-runtime set --user <preset>\ncm-runtime unset --user';
94
+ export async function interactiveRuntime(project,{input=process.stdin,output=process.stdout,lang=runtimeLanguage()}={}){
95
+ const root=projectDirectory(project),existing=findConfig(root),file=existing??path.join(root,'.cm-workflow.yml');
96
+ const questions=runtimeQuestions(input,output,lang),ask=questions.ask;
92
97
  try{
93
- if(argv.length===1&&['--help','-h'].includes(argv[0])){console.log(USAGE);return 0;}
94
- const [command,...args]=argv;let project=process.cwd(),user=false,preset=null,projectSeen=false;
98
+ const fallback=existing?'1':'2';let scope;
99
+ do{scope=await ask(t('scope',lang,{project:file,user:userRuntimesPath(),default:fallback}));scope=scope||fallback;}while(!['1','2'].includes(scope));
100
+ const user=scope==='2';
101
+ if(!user&&!existing)output.write(t('create',lang,{file}));
102
+ const preset=await askRuntimePreset(ask,lang);
103
+ const target=user?userRuntimesPath():file;
104
+ const current=user?(stat(target)?readConfigText(target):t('absent',lang)):showRuntime(root,{lang,probe:()=>[]});
105
+ output.write(t('preview',lang,{file:target,preset,current}));
106
+ let confirm;
107
+ do{confirm=(await ask(t('confirm',lang))).toLowerCase();}while(!['','y','n'].includes(confirm));
108
+ if(confirm==='n')throw new PromptCancelled();
109
+ saveRuntime(root,preset,user,lang,output);
110
+ output.write(showRuntime(root,{lang})+'\n');return 0;
111
+ }catch(error){if(error instanceof PromptCancelled){output.write(t('cancelled',lang));return 0;}throw error;}
112
+ finally{questions.close();}
113
+ }
114
+ function saveRuntime(project,preset,user,lang,output){
115
+ runtimePreset(preset);project=projectDirectory(project);
116
+ const file=user?writeUserRuntime(preset,{lang}):setProjectRuntime(project,preset);
117
+ logSet(preset,user?'user':'project',project);
118
+ output.write(t('saved',lang,{file,preset,source:user?'user':'project'})+'\n');
119
+ }
120
+ export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,lang=runtimeLanguage()}={}){
121
+ const USAGE=t('help',lang)+'\n'+COMMANDS;
122
+ try{
123
+ if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(USAGE+'\n');return 0;}
124
+ const command=argv[0]?.startsWith('--')?undefined:argv[0];const args=command?argv.slice(1):argv;let project=process.cwd(),user=false,preset=null,projectSeen=false;
95
125
  for(let i=0;i<args.length;i++){
96
126
  if(args[i]==='--user'&&!user){user=true;continue;}
97
127
  if(args[i]==='--project'&&!projectSeen&&args[i+1]&&!args[i+1].startsWith('--')){project=args[++i];projectSeen=true;continue;}
@@ -99,15 +129,13 @@ export function main(argv=process.argv.slice(2)){
99
129
  throw new ConfigError(USAGE);
100
130
  }
101
131
  if(user&&projectSeen)throw new ConfigError('--user cannot be combined with --project');
102
- if(command==='show'&&!user){console.log(showRuntime(project));return 0;}
132
+ if(!command&&!user){if(!input.isTTY||!output.isTTY){output.write(USAGE+'\n');return 2;}return await interactiveRuntime(project,{input,output,lang});}
133
+ if(command==='show'&&!user){output.write(showRuntime(project,{lang})+'\n');return 0;}
103
134
  if(command==='set'&&preset){
104
- runtimePreset(preset);project=projectDirectory(project);
105
- const file=user?writeUserRuntime(preset):setProjectRuntime(project,preset);
106
- logSet(preset,user?'user':'project',project);
107
- console.log(`Saved ${file}: ${preset} (${user?'user':'project'}); existing runs unchanged`);return 0;
135
+ saveRuntime(project,preset,user,lang,output);return 0;
108
136
  }
109
- if(command==='unset'&&user){const file=userRuntimesPath();safeTarget(file);if(stat(file))fs.unlinkSync(file);console.log(`Removed user default: ${file}; project declarations still take precedence`);return 0;}
137
+ if(command==='unset'&&user){const file=userRuntimesPath();safeTarget(file);if(stat(file))fs.unlinkSync(file);output.write(t('removed',lang,{file})+'\n');return 0;}
110
138
  throw new ConfigError(USAGE);
111
139
  }catch(error){console.error(`cm-runtime: ${error.message}`);return 1;}
112
140
  }
113
- if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url))process.exitCode=main();
141
+ if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url))process.exitCode=await main();
@@ -115,3 +115,104 @@ test('candidate over the shared file size limit is rejected before atomic replac
115
115
  assert.throws(()=>setProjectRuntime(root,'codex-codes'),/exceeds/);
116
116
  assert.equal(fs.readFileSync(file,'utf8'),original);
117
117
  }));
118
+
119
+ // Pseudo TTY streams still use the production node:readline implementation.
120
+ async function wizardFixture(fn){
121
+ const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-runtime-wizard-')));
122
+ const previous={CM_WORKFLOW_HOME:process.env.CM_WORKFLOW_HOME,CM_WORKFLOW_LOG_HOME:process.env.CM_WORKFLOW_LOG_HOME};
123
+ process.env.CM_WORKFLOW_HOME=path.join(root,'user');process.env.CM_WORKFLOW_LOG_HOME=path.join(root,'logs');
124
+ try{await fn(root);}finally{
125
+ for(const [key,value] of Object.entries(previous)){if(value===undefined)delete process.env[key];else process.env[key]=value;}
126
+ fs.rmSync(root,{recursive:true,force:true});
127
+ }
128
+ }
129
+ import {PassThrough} from 'node:stream';
130
+ import {main,askRuntimePreset as wizardPreset} from './cm-runtime.mjs';
131
+ import {askRuntimePreset as installerPreset,promptRuntime} from './cm-runtime-install.mjs';
132
+ import {runtimeLanguage} from './cm-runtime-i18n.mjs';
133
+ function tty(){
134
+ const input=new PassThrough(),output=new PassThrough();input.isTTY=output.isTTY=true;
135
+ let text='';output.on('data',chunk=>{text+=chunk;});
136
+ return {input,output,text:()=>text};
137
+ }
138
+ async function wizard(root,answers,lang='en'){
139
+ const io=tty();const running=main(['--project',root],{...io,lang});
140
+ io.input.end(answers);const code=await running;return {code,text:io.text()};
141
+ }
142
+ test('wizard and installer share the same preset question function',()=>assert.equal(wizardPreset,installerPreset));
143
+ test('language priority, explicit overrides, locales, Intl and English fallback',()=>{
144
+ for(const [env,expected] of [
145
+ [{CM_WORKFLOW_LANG:'en',LC_ALL:'zh_CN.UTF-8'},'en'],
146
+ [{CM_WORKFLOW_LANG:'zh',LC_ALL:'en_US.UTF-8'},'zh'],
147
+ [{LC_ALL:'en_US.UTF-8',LC_MESSAGES:'zh_CN.UTF-8'},'en'],
148
+ [{LC_MESSAGES:'zh_CN.UTF-8',LANG:'en_US.UTF-8'},'zh'],
149
+ [{LANG:'zh_CN.UTF-8'},'zh'],[{LANG:'en_US.UTF-8'},'en'],
150
+ [{LANG:'C'},'en'],[{},'en'],
151
+ ])assert.equal(runtimeLanguage(env,()=>undefined),expected);
152
+ assert.equal(runtimeLanguage({},()=> 'zh-TW'),'zh');
153
+ assert.equal(runtimeLanguage({},()=>{throw new Error('Intl unavailable');}),'en');
154
+ });
155
+ test('TTY project wizard changes exactly five fields, logs decision and shows result',()=>wizardFixture(async root=>{
156
+ const file=path.join(root,'.cm-workflow.yml');
157
+ const before='\ufeff# keep\r\nversion: 1\r\nruntimes: {available: codex}\r\nroles:\r\n coder: {adapter: current-ai, source: local, model: default} # keep coder\r\n reviewer: {adapter: current-ai, source: local, model: default}\r\n';
158
+ const initial=before;
159
+ fs.writeFileSync(file,initial);
160
+ const result=await wizard(root,'1\n3\n1\nY\n');assert.equal(result.code,0,result.text);
161
+ assert.equal(fs.readFileSync(file,'utf8'),initial.replace('available: codex','available: both').replace('adapter: current-ai','adapter: codex-cli').replace('adapter: current-ai','adapter: claude-cli').replaceAll('source: local','source: subscription'));
162
+ assert.match(result.text,/Which AI tools do you have/);assert.match(result.text,/Who writes code/);
163
+ assert.match(result.text,/preset: codex-codes/);assert.match(result.text,/runtimes_source: project/);
164
+ const logs=fs.readdirSync(path.join(root,'logs','runs'),{recursive:true}).filter(x=>x.endsWith('.jsonl'));
165
+ assert.equal(logs.length,1);const event=JSON.parse(fs.readFileSync(path.join(root,'logs','runs',logs[0]),'utf8'));
166
+ assert.equal(event.event,'decision');assert.equal(event.preset,'codex-codes');
167
+ }));
168
+ test('missing project defaults to user scope and Chinese preset/comment/output',()=>wizardFixture(async root=>{
169
+ const result=await wizard(root,'\n2\nY\n','zh');assert.equal(result.code,0);
170
+ assert(!fs.existsSync(path.join(root,'.cm-workflow.yml')));
171
+ assert.match(fs.readFileSync(path.join(root,'user','runtimes.yml'),'utf8'),/# 用 cm-runtime.*\npreset: claude-only/s);
172
+ assert.match(result.text,/你手上有哪个 AI 工具/);assert.match(result.text,/确认?/);assert.match(result.text,/runtimes_source: user/);
173
+ }));
174
+ test('three empty mandatory answers, refusal, EOF and SIGINT do not write',()=>wizardFixture(async root=>{
175
+ for(const answers of ['2\n\n\n\n','2\n1\nn\n','2\n']){
176
+ const result=await wizard(root,answers);assert.equal(result.code,0);assert.match(result.text,/Cancelled/);assert.deepEqual(fs.readdirSync(root),[]);
177
+ }
178
+ const io=tty(),running=main(['--project',root],io);process.emit('SIGINT');
179
+ assert.equal(await running,0);assert.match(io.text(),/Cancelled/);assert.deepEqual(fs.readdirSync(root),[]);
180
+ }));
181
+ test('explicit project creation, existing-project scope default and invalid choice retry',()=>wizardFixture(async root=>{
182
+ const created=await wizard(root,'1\nwrong\n1\ny\n');assert.equal(created.code,0);assert.match(created.text,/Will create project configuration/);
183
+ const changed=await wizard(root,'\n3\n2\n\n');assert.equal(changed.code,0);assert.match(changed.text,/preset: claude-codes/);
184
+ assert.equal(loadConfig({projectRoot:root}).roles.coder.adapter,'claude-cli');
185
+ }));
186
+ test('non-TTY no command exits 2 with usage and no writes',()=>fixture((root,run)=>{
187
+ const result=run();assert.equal(result.status,2);assert.match(result.stdout,/cm-runtime/);assert.deepEqual(fs.readdirSync(root),[]);
188
+ }));
189
+ test('installer yes skips even TTY; culture selects shared English or Chinese text',()=>wizardFixture(async root=>{
190
+ for(const culture of ['en-US','zh-CN']){
191
+ const io=tty();await promptRuntime(['--yes','--lang',culture],io.input,io.output);
192
+ assert.equal(io.text(),'');assert.deepEqual(fs.readdirSync(root),[]);
193
+ }
194
+ }));
195
+ test('human diagnostics translate while structured fields and user file data stay identical',()=>wizardFixture(async root=>{
196
+ writeUserRuntime('codex-codes',{lang:'en'});
197
+ const options={probe:()=>[{runtime:'codex',available:true},{runtime:'claude',available:false}]};
198
+ const en=showRuntime(root,{...options,lang:'en'}),zh=showRuntime(root,{...options,lang:'zh'});
199
+ assert.equal(en.split('\n').slice(0,3).join('\n'),zh.split('\n').slice(0,3).join('\n'));
200
+ assert.match(en,/declared, not dispatched/);assert.match(zh,/已声明未派发/);
201
+ assert.match(en,/presence does not prove quota/);assert.match(zh,/可解析≠配额可用/);
202
+ assert.match(fs.readFileSync(path.join(root,'user','runtimes.yml'),'utf8'),/# Use cm-runtime/);
203
+ }));
204
+ test('installer culture reaches shared prompts and comments; explicit override wins',()=>wizardFixture(async root=>{
205
+ const keys=['CM_WORKFLOW_LANG','LC_ALL','LC_MESSAGES','LANG'];
206
+ const saved=Object.fromEntries(keys.map(key=>[key,process.env[key]]));
207
+ try{
208
+ for(const key of keys)delete process.env[key];
209
+ for(const [culture,override,expected] of [['zh-CN',undefined,'zh'],['en-US',undefined,'en'],['zh-CN','en','en']]){
210
+ if(override)process.env.CM_WORKFLOW_LANG=override;else delete process.env.CM_WORKFLOW_LANG;
211
+ const io=tty(),running=promptRuntime(['--lang',culture],io.input,io.output);
212
+ io.input.end('3\n2\n');await running;
213
+ assert.match(io.text(),expected==='zh'?/你手上有哪个 AI 工具/:/Which AI tools do you have/);
214
+ const file=path.join(root,'user','runtimes.yml');assert.match(fs.readFileSync(file,'utf8'),expected==='zh'?/# 用 cm-runtime/:/# Use cm-runtime/);
215
+ fs.unlinkSync(file);
216
+ }
217
+ }finally{for(const [key,value] of Object.entries(saved)){if(value===undefined)delete process.env[key];else process.env[key]=value;}}
218
+ }));
@@ -9,7 +9,29 @@ description: 用户要查看或切换 CM 自动派发偏好、单/双 AI 声明
9
9
  `../../runtime/logging.md`。Codex 入口 `$cm-runtime`;Claude Code 入口 `/cm-runtime`,
10
10
  macOS/Linux 兼容别名 `/cm:runtime`。这是独立配置工具,不进入 N1–N8,不创建业务任务。
11
11
 
12
- 从当前 Skill 目录解析 `{CM_WORKFLOW_ROOT}`,按用户参数执行:
12
+ 从当前 Skill 目录解析 `{CM_WORKFLOW_ROOT}`。无参数调用时,不直接启动依赖 TTY 的脚本;
13
+ 由当前会话用 AskUserQuestion 或纯文本完成以下三问。使用**用户当前对话语言**,
14
+ 中文对话用中文、英文对话用英文,编号、含义与终端一致;文案以
15
+ `../../scripts/cm-runtime-i18n.mjs` 为准,预设名与机器字段不翻译。
16
+
17
+ 1. 改哪一层?/ Which scope? `[1] 当前项目 / Current project`(显示检测到的配置路径)
18
+ `[2] 用户级默认 / User default`(`~/.cm-workflow/runtimes.yml`)。有项目配置默认 1,
19
+ 无配置默认 2;无配置仍选 1 时,提示将从模板新建 `.cm-workflow.yml`。
20
+ 2. 你手上有哪个 AI 工具?/ Which AI tools do you have?
21
+ `[1] 只有 Codex / Codex only` `[2] 只有 Claude / Claude only` `[3] 两个都有 / Both`。
22
+ 此问无默认,必须选择;选 3 再问:谁写代码?/ Who writes code?
23
+ `[1] Codex(Claude 审,推荐)/ Codex (Claude reviews, recommended)`
24
+ `[2] Claude(Codex 审)/ Claude (Codex reviews)`,默认 1。
25
+ 3. 显示目标路径、将写入的预设与当前值(如已有),询问确认 / Confirm? `[Y/n]`。
26
+ 用户确认后才执行对应 `set`,成功后执行 `show --project "{代码项目路径}"` 并回显。
27
+
28
+ 工具选 1/2 分别映射 `codex-only`/`claude-only`;两个都有、写代码选 1/2 分别映射
29
+ `codex-codes`/`claude-codes`。取消、拒绝确认或必选问题连续三次空输入时放弃,不写。
30
+ 会话没有回复不代表回车或确认,不得因等待超时执行。用户范围用 `set --user`,项目范围用
31
+ `set <preset> --project`;用户声明被项目覆盖时如实报告 `show` 的有效来源。
32
+
33
+ 显式自然语言“看看配置”映射 `show`。带 `show` / `set` / `unset` 参数直接执行,
34
+ 修改意图缺少预设/范围时只补问缺失项。执行示例:
13
35
 
14
36
  ```bash
15
37
  node "{CM_WORKFLOW_ROOT}/scripts/cm-runtime.mjs" show --project "{代码项目路径}"
@@ -18,7 +40,6 @@ node "{CM_WORKFLOW_ROOT}/scripts/cm-runtime.mjs" set --user claude-codes
18
40
  node "{CM_WORKFLOW_ROOT}/scripts/cm-runtime.mjs" unset --user
19
41
  ```
20
42
 
21
- - 无子命令的自然语言“看看配置”映射为 `show`;修改必须有明确预设/谁写谁审,缺失时仅询问这项。
22
43
  - 四个预设为 `codex-only`、`claude-only`、`codex-codes`、`claude-codes`;映射以共享配置合同为准。
23
44
  - `show` 只读,打印有效声明、预设、coder/reviewer adapter、source 与 `runtimes_source`;CLI 缺失只 WARN,可解析不证明配额可用。
24
45
  - `set` 默认项目级;只修改 `runtimes.available` 与 coder/reviewer 的 adapter/source,其他原文保留;新文件从模板生成。校验失败不写。