@aibyzero/cm-workflow 0.15.4 → 0.15.5

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.15.4",
3
+ "version": "0.15.5",
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,12 @@
7
7
 
8
8
  (暂无)
9
9
 
10
+ ## 0.15.5 — 2026-09-20
11
+
12
+ - **安装时按实际状态询问是否开启更新播报**。安装器结尾此前无条件打印「自动更新器未自动启用」:对已启用的人这句是错的(实测 hook 已配、后台更新器也在跑,仍这么说),对未启用的人它读着像普通说明而不像少配了一步——两边都没起作用,这才是装了包的人收不到新版提示的真实原因,不是缺功能。现改为检测后再说话:已配好则确认一句;未配好且交互安装则询问一次,答 y 才写入;`--yes` 与非交互安装不写任何东西,改为打印确切的 hook 条目;此前拒绝过则不再打扰(记在 `~/.cm-workflow/announce-hook-declined`,删掉该文件并重装即可重新被问)。
13
+ - 只添加播报 hook,**绝不添加后台升级器**——告知有新版与让工具自我替换是两个决定。`settings.json` 属于用户:无法解析时原文件逐字节不动、写入走临时文件加原子改名、已存在则不重复添加。安装器此前从不碰该文件,本次开的口子范围写死,只加这一条 hook 且只在明确同意时。
14
+ - 注意:只开播报而不开后台升级器时没有东西会产生播报内容(`cm-announce.sh` 只消费 `cm-update.sh` 留下的文件),两者需一起开启才有效果,详见 `docs/installation.md`。
15
+
10
16
  ## 0.15.4 — 2026-09-20
11
17
 
12
18
  - **`cm-check --quick`:约 12 秒收口的快速检查**。完整检查耗时拆分为查更新 0.7 秒、机械检查 12.4 秒,其余几乎全在八组语义检查上——那不是程序在跑,而是执行者逐个文件读取并取证行号,且控制器强制八组齐全、passed 必须附真实行号,慢是设计换来的。日常「装没装对、版本对不对」这类问题机械检查已能回答,`--quick` 让更新与机械检查照常跑、机械通过后直接收口,不进语义检查。结论为 `MECHANICAL_ONLY` 而**不是 PASSED**:八组一组没读,不得据此宣称安装完整无断链;结果带 `semanticChecked:false` 与 `reason:quick_mode_semantic_not_run`。机械失败仍照常报 FAILED/BLOCKED,快速模式不跳过任何失败。默认不带该参数时行为不变。
package/README.md CHANGED
@@ -17,6 +17,11 @@
17
17
 
18
18
  ## 最近更新
19
19
 
20
+ **0.15.5**
21
+
22
+ - **安装时会问你要不要开启新版提示**。此前安装完只有一句含糊的「自动更新器未自动启用」,已经开启的人也会看到这句(是错的),没开启的人又不会当回事,结果几乎没人用上这个功能。现在安装器会先看你实际配没配,再决定说什么;没配且是手动安装时,问一句、你答 y 才写入。用 `--yes` 静默安装的不会被改动任何配置,只会打印该加什么。
23
+ - 它**只加一条「有新版就告诉你」的提示**,不会顺手打开后台自动升级——那是另一回事,仍需你自己决定。你的 `settings.json` 里原有的内容(比如自定义状态栏)不会被动。
24
+
20
25
  **0.15.4**
21
26
 
22
27
  - **`/cm-check` 新增快速模式**:日常只想确认「装没装对、版本对不对」时,跑快速检查约 12 秒出结果,不再等十几分钟。完整检查的时间几乎全花在逐个文件核对引用关系上,快速模式跳过这一段。结论会明确标为「仅机械检查」而不是「通过」——跳过的部分不会被说成检查过了。机械检查本身发现的问题照常报错,不会被跳过。
@@ -143,7 +148,7 @@ $cm-check
143
148
 
144
149
  仓库直接分发 Skills 和脚本,无需在仓库根目录运行 `npm install` 或构建。完整安装行为、覆盖范围和卸载说明见[安装指南](docs/installation.md)。
145
150
 
146
- 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.15.4 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
151
+ 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.15.5 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
147
152
 
148
153
  ## 升级旧版本
149
154
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.15.4
1
+ 0.15.5
@@ -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.15.4 install` from outside
76
+ To pin a version, use `npx @aibyzero/cm-workflow@0.15.5 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`.
@@ -181,7 +181,14 @@ platforms; any admitted task still uses the shared Review/N5 gates.
181
181
  ## Optional Claude auto-update (macOS/Linux)
182
182
 
183
183
  The Bash installer copies the updater on a best-effort basis but does not activate
184
- it. A copy failure is reported as a warning and does not invalidate a core runtime
184
+ it. An interactive install now asks once whether to enable the **announcement** hook
185
+ and, on yes, adds that single `hooks.SessionStart` entry for you; it never adds the
186
+ background updater, and it never edits `settings.json` without that yes. A refusal is
187
+ remembered in `~/.cm-workflow/announce-hook-declined`; delete that file and reinstall
188
+ to be asked again. `--yes` and non-interactive installs write nothing and print the
189
+ exact entry to add. Announcing a new version and letting the tool replace itself are
190
+ separate decisions, so enabling the announcement alone leaves the updater off: with no
191
+ updater scheduled there is nothing to announce, so enable it below if you want both. A copy failure is reported as a warning and does not invalidate a core runtime
185
192
  that already passed its installed self-check. The PowerShell
186
193
  installer intentionally does not copy this Bash-based updater; Windows users who
187
194
  want it must run the Bash installer from WSL or Git Bash. To enable it on a
package/install.sh CHANGED
@@ -246,4 +246,15 @@ echo
246
246
  echo "完成(已安装版本: v${VERSION})。"
247
247
  echo "建议在 Claude Code 中运行 /cm-check 校验;macOS/Linux 也保留 /cm:check 别名。"
248
248
  echo "使用手册: $DEST/cm-workflow/docs/user-guide.md"
249
- echo "自动更新器未自动启用;按 docs/installation.md 手工配置 SessionStart hook。"
249
+ # 播报 hook 的实际状态由脚本判断后再说话:此前这行无条件打印,对已启用的人是错的,
250
+ # 对未启用的人又读着像普通说明,两边都没起作用。仅在交互安装时询问,且只加播报 hook。
251
+ if [ -x "$DEST/scripts/cm-announce-hook.mjs" ] || [ -f "$DEST/scripts/cm-announce-hook.mjs" ]; then
252
+ if [ "$ASSUME_YES" -ne 1 ] && [ -t 0 ] && [ -t 1 ]; then
253
+ node "$DEST/scripts/cm-announce-hook.mjs" || true
254
+ else
255
+ CM_NONINTERACTIVE=1 node "$DEST/scripts/cm-announce-hook.mjs" </dev/null || true
256
+ fi
257
+ else
258
+ echo "自动更新器未自动启用;按 docs/installation.md 手工配置 SessionStart hook。"
259
+ fi
260
+ echo "后台自动升级仍需另行开启,见 docs/installation.md。"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibyzero/cm-workflow",
3
- "version": "0.15.4",
3
+ "version": "0.15.5",
4
4
  "description": "Spec-driven business development workflow for Pi, Codex, and Claude Code",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+ // Reports whether the update announcement hook is wired, and — only when the user
3
+ // says yes — adds that one SessionStart hook to their Claude settings.
4
+ //
5
+ // Scope is deliberately narrow. The installer otherwise never touches settings.json,
6
+ // which belongs to the user: it may carry their own statusline and hooks. This adds
7
+ // the announcement hook alone and never the background updater, because announcing a
8
+ // new version is not the same decision as letting the tool replace itself.
9
+ import fs from 'node:fs';
10
+ import path from 'node:path';
11
+ import os from 'node:os';
12
+ import {createInterface} from 'node:readline';
13
+
14
+ export const ANNOUNCE_COMMAND='~/.cm-workflow/cm-announce.sh';
15
+ const DECLINED='announce-hook-declined';
16
+
17
+ export const settingsPath=(env=process.env)=>
18
+ path.join(path.resolve(env.CLAUDE_HOME||path.join(env.HOME||os.homedir(),'.claude')),'settings.json');
19
+ export const declinedPath=(env=process.env)=>
20
+ path.join(path.resolve(env.CM_WORKFLOW_HOME||path.join(env.HOME||os.homedir(),'.cm-workflow')),DECLINED);
21
+
22
+ export function readSettings(file){
23
+ let text;
24
+ try{text=fs.readFileSync(file,'utf8');}catch(error){if(error.code==='ENOENT')return {};throw error;}
25
+ if(!text.trim())return {};
26
+ // A settings file we cannot parse is never rewritten: that would destroy user content.
27
+ return JSON.parse(text);
28
+ }
29
+
30
+ export const hasAnnounceHook=settings=>
31
+ (settings?.hooks?.SessionStart??[]).some(group=>
32
+ Array.isArray(group?.hooks)&&group.hooks.some(hook=>hook?.command===ANNOUNCE_COMMAND));
33
+
34
+ // Append to the existing SessionStart list; every other key and hook is preserved.
35
+ export function withAnnounceHook(settings){
36
+ const next=structuredClone(settings??{});
37
+ next.hooks??={};
38
+ const sessionStart=Array.isArray(next.hooks.SessionStart)?[...next.hooks.SessionStart]:[];
39
+ sessionStart.push({hooks:[{type:'command',command:ANNOUNCE_COMMAND,timeout:5}]});
40
+ next.hooks.SessionStart=sessionStart;
41
+ return next;
42
+ }
43
+
44
+ export function writeSettings(file,settings){
45
+ fs.mkdirSync(path.dirname(file),{recursive:true});
46
+ const temporary=`${file}.cm-announce.${process.pid}.tmp`;
47
+ fs.writeFileSync(temporary,JSON.stringify(settings,null,2)+'\n',{mode:0o600});
48
+ try{fs.renameSync(temporary,file);}finally{if(fs.existsSync(temporary))fs.unlinkSync(temporary);}
49
+ }
50
+
51
+ export async function main({env=process.env,input=process.stdin,output=process.stdout,
52
+ interactive=Boolean(process.stdin.isTTY&&process.stdout.isTTY)}={}){
53
+ const file=settingsPath(env);
54
+ let settings;
55
+ try{settings=readSettings(file);}
56
+ catch{output.write(`⚠ 无法解析 ${file},未改动它。更新播报可按 docs/installation.md 手工开启。\n`);return 0;}
57
+ if(hasAnnounceHook(settings)){output.write('更新播报已启用(新版本会在下次启动时告知)。\n');return 0;}
58
+
59
+ const declined=declinedPath(env);
60
+ if(fs.existsSync(declined)){output.write(`更新播报未启用(此前已选择不开启)。要开启:删除 ${declined} 后重新安装。\n`);return 0;}
61
+
62
+ const manual=`要开启:在 ${file} 的 hooks.SessionStart 增加 {"type":"command","command":"${ANNOUNCE_COMMAND}","timeout":5}`;
63
+ if(!interactive){output.write(`更新播报未启用。${manual}\n`);return 0;}
64
+
65
+ const rl=createInterface({input,output,terminal:false});
66
+ let answer;
67
+ try{answer=await new Promise(resolve=>{
68
+ output.write(' 开启更新播报?新版本会在下次启动 Claude Code 时告知一次。这只增加一条播报 hook,不会自动升级。[y/N] ');
69
+ rl.once('line',line=>resolve(line));rl.once('close',()=>resolve(null));
70
+ });}finally{rl.close();}
71
+
72
+ if(!/^y(es)?$/i.test((answer??'').trim())){
73
+ try{fs.mkdirSync(path.dirname(declined),{recursive:true});fs.writeFileSync(declined,'');}catch{/* 记不住也只是下次再问一次 */}
74
+ output.write(` 未开启。${manual}\n`);return 0;
75
+ }
76
+ try{writeSettings(file,withAnnounceHook(settings));}
77
+ catch{output.write(` ⚠ 写入 ${file} 失败,未改动它。${manual}\n`);return 0;}
78
+ output.write(' 已开启:下次启动 Claude Code 时会告知更新。\n');
79
+ return 0;
80
+ }
81
+
82
+ if(process.argv[1]&&fs.realpathSync(process.argv[1])===fs.realpathSync(new URL(import.meta.url).pathname))
83
+ process.exitCode=await main();
@@ -0,0 +1,90 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import {Readable,Writable} from 'node:stream';
7
+ import {main,settingsPath,declinedPath,hasAnnounceHook,withAnnounceHook,ANNOUNCE_COMMAND} from './cm-announce-hook.mjs';
8
+
9
+ function fixture(t,settings){
10
+ const home=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-announce-')));
11
+ t.after(()=>fs.rmSync(home,{recursive:true,force:true}));
12
+ const env={HOME:home,CLAUDE_HOME:path.join(home,'.claude'),CM_WORKFLOW_HOME:path.join(home,'.cm-workflow')};
13
+ if(settings!==undefined){
14
+ fs.mkdirSync(env.CLAUDE_HOME,{recursive:true});
15
+ fs.writeFileSync(settingsPath(env),typeof settings==='string'?settings:JSON.stringify(settings,null,2));
16
+ }
17
+ return {env,read:()=>JSON.parse(fs.readFileSync(settingsPath(env),'utf8'))};
18
+ }
19
+ const run=async(env,answer,interactive=true)=>{
20
+ let text='';
21
+ const output=new Writable({write(chunk,_e,cb){text+=chunk;cb();}});
22
+ await main({env,input:Readable.from(answer===null?[]:[`${answer}\n`]),output,interactive});
23
+ return text;
24
+ };
25
+
26
+ test('an existing hook is reported, never duplicated',async t=>{
27
+ const existing={hooks:{SessionStart:[{hooks:[{type:'command',command:ANNOUNCE_COMMAND,timeout:5}]}]}};
28
+ const f=fixture(t,existing);
29
+ const text=await run(f.env,'y');
30
+ assert.match(text,/已启用/);
31
+ assert.deepEqual(f.read(),existing,'settings must be untouched');
32
+ });
33
+
34
+ test('yes adds only the announcement hook and preserves every other setting',async t=>{
35
+ const original={statusLine:{type:'command',command:'~/.claude/statusline.sh'},
36
+ env:{FOO:'bar'},hooks:{SessionStart:[{hooks:[{type:'command',command:'~/mine.sh'}]}],
37
+ PreToolUse:[{hooks:[{type:'command',command:'~/guard.sh'}]}]}};
38
+ const f=fixture(t,original);
39
+ await run(f.env,'y');
40
+ const after=f.read();
41
+ assert.deepEqual(after.statusLine,original.statusLine,'the user statusline survives');
42
+ assert.deepEqual(after.env,original.env);
43
+ assert.deepEqual(after.hooks.PreToolUse,original.hooks.PreToolUse,'other hook kinds survive');
44
+ assert.deepEqual(after.hooks.SessionStart[0],original.hooks.SessionStart[0],'the existing SessionStart hook survives');
45
+ assert.equal(hasAnnounceHook(after),true);
46
+ assert.equal(after.hooks.SessionStart.length,2);
47
+ // The background updater is a separate decision and must never be added here.
48
+ assert.equal(JSON.stringify(after).includes('cm-update.sh'),false);
49
+ });
50
+
51
+ test('no answer leaves settings alone and is remembered',async t=>{
52
+ const f=fixture(t,{statusLine:{type:'command',command:'~/mine.sh'}});
53
+ const text=await run(f.env,'n');
54
+ assert.equal(hasAnnounceHook(f.read()),false);
55
+ assert.match(text,/未开启/);
56
+ assert.equal(fs.existsSync(declinedPath(f.env)),true);
57
+ const again=await run(f.env,'y');
58
+ assert.match(again,/此前已选择不开启/);
59
+ assert.equal(hasAnnounceHook(f.read()),false,'a remembered refusal is not overridden');
60
+ });
61
+
62
+ test('non-interactive installs never write and print the exact manual step',async t=>{
63
+ const f=fixture(t,{});
64
+ const text=await run(f.env,null,false);
65
+ assert.equal(hasAnnounceHook(f.read()),false);
66
+ assert.match(text,/hooks\.SessionStart/);
67
+ assert.match(text,new RegExp(ANNOUNCE_COMMAND.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')));
68
+ assert.equal(fs.existsSync(declinedPath(f.env)),false,'declining was never asked, so nothing is remembered');
69
+ });
70
+
71
+ test('unparsable settings are reported and left byte-identical',async t=>{
72
+ const broken='{ this is not json';
73
+ const f=fixture(t,broken);
74
+ const text=await run(f.env,'y');
75
+ assert.match(text,/无法解析/);
76
+ assert.equal(fs.readFileSync(settingsPath(f.env),'utf8'),broken);
77
+ });
78
+
79
+ test('a missing settings file is created with just the hook',async t=>{
80
+ const f=fixture(t);
81
+ await run(f.env,'y');
82
+ assert.deepEqual(f.read(),{hooks:{SessionStart:[{hooks:[{type:'command',command:ANNOUNCE_COMMAND,timeout:5}]}]}});
83
+ });
84
+
85
+ test('withAnnounceHook does not mutate its input',()=>{
86
+ const input={hooks:{SessionStart:[]}};
87
+ const snapshot=JSON.stringify(input);
88
+ withAnnounceHook(input);
89
+ assert.equal(JSON.stringify(input),snapshot);
90
+ });