@aibyzero/cm-workflow 0.21.0 → 0.21.1
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.
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +6 -0
- package/README.md +6 -1
- package/VERSION +1 -1
- package/docs/installation.md +1 -1
- package/package.json +1 -1
- package/runtime/js/cm-ai/durable-runner-state.mjs +4 -0
- package/runtime/js/cm-ai/task-commit-codec.mjs +4 -2
- package/scripts/cm-ai-batch-run-fixture.mjs +5 -1
- package/scripts/cm-notify.test.mjs +6 -4
- package/scripts/cm-skill-hints.json +1 -1
- package/scripts/cm-skill-hints.mjs +66 -3
- package/scripts/cm-skill-hints.test.mjs +96 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cm-workflow",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.1",
|
|
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
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
## 未发布
|
|
7
7
|
|
|
8
|
+
## 0.21.1 — 2026-11-17
|
|
9
|
+
|
|
10
|
+
- **接近存档上限的任务提交可以正常读回**(CI 历史组夹具暴露:存档单条上限放到 4 MiB 后,`readCommitIntent` 仍按通用 JSON 校验的 1 MiB 默认值读取,计划接近或超过 1 MiB 的提交意图写得进却读不回):任务提交意图的读取改用 `JOURNAL_PAYLOAD_LIMIT`,与写入侧一致;运行器构造记录(`boundRunnerRecord`)先按同一上限校验载荷,再校验整条记录(上限加 1 KiB 外层余量)。
|
|
11
|
+
|
|
12
|
+
- **交接技能不再被否定句和引号里的词误触发**(实测:Jev 关闭时,“不要换个会话,继续当前任务”会让模型直接执行交接):关键词兜底时,否定词后约 4 个字(英文 3 个词)内的命中不算,“别忘了”除外;引号和行内代码里的词不算;只说换会话、没提交接时改为先问一句;英文 handoff/hand off 也算交接,new/fresh session、context is almost full 等英文说法也算换会话。拦下的情况记入日志,只记规则名和原因。Jev 路径、普通提示和 CM 内部流程不变。
|
|
13
|
+
|
|
8
14
|
## 0.21.0 — 2026-11-15
|
|
9
15
|
|
|
10
16
|
- **审查放不下的交付在开发阶段就拦下**(实跑 aihot 副本:存档上限放到 4 MiB 后,约 1.8 MB 的改动能交付,但 Codex 审查输入最多 1 MiB,运行卡在审查结果不明、只能整任务重开):开发交付时按将要发送的审查内容核对审查方输入上限,放不下即 `develop_package_too_large`,缩小改动后原运行重做本轮。
|
package/README.md
CHANGED
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
|
|
18
18
|
## 最近更新
|
|
19
19
|
|
|
20
|
+
**0.21.1**
|
|
21
|
+
|
|
22
|
+
- **接近存档上限的任务提交可以正常读回**:单条存档上限放到 4 MiB 后,任务提交记录读取时仍按 1 MiB 校验,超过 1 MiB 的提交写得进却读不回;现在读写同用一个上限。
|
|
23
|
+
- **技能交接不再被否定句和引号误触发**:「不要换个会话」这类说法和引号里的词不再触发交接。详见[更新日志](CHANGELOG.md)。
|
|
24
|
+
|
|
20
25
|
**0.21.0**
|
|
21
26
|
|
|
22
27
|
- **开发中途补规格分级生效**:只给 tasks.md 追加「范围与验收不变」这类纯声明的版本记录直接换绑;补任务范围、为已有验收标准补任务或新增用例,由独立审查者审过后生效并通知你;改需求、设计、已有用例或已完成任务,仍要你回复「开始」。改变已有任务验收的版本说明一律按改需求处理。
|
|
@@ -276,7 +281,7 @@ $cm-check
|
|
|
276
281
|
|
|
277
282
|
仓库直接分发 Skills 和脚本,无需在仓库根目录运行 `npm install` 或构建。完整安装行为、覆盖范围和卸载说明见[安装指南](docs/installation.md)。
|
|
278
283
|
|
|
279
|
-
需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.21.
|
|
284
|
+
需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.21.1 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
|
|
280
285
|
|
|
281
286
|
## 升级旧版本
|
|
282
287
|
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.21.
|
|
1
|
+
0.21.1
|
package/docs/installation.md
CHANGED
|
@@ -76,7 +76,7 @@ Install or upgrade with the same command:
|
|
|
76
76
|
npx @aibyzero/cm-workflow@latest install
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
To pin a version, use `npx @aibyzero/cm-workflow@0.21.
|
|
79
|
+
To pin a version, use `npx @aibyzero/cm-workflow@0.21.1 install` from outside
|
|
80
80
|
the CM Workflow source checkout (for example, your home directory). Inside a
|
|
81
81
|
checkout with the same package name and version, npm can select the local
|
|
82
82
|
uninstalled package and report `cm-workflow: command not found`.
|
package/package.json
CHANGED
|
@@ -734,6 +734,10 @@ export const runnerPayloadV3=(type,fields,limit=JOURNAL_PAYLOAD_LIMIT)=>json({..
|
|
|
734
734
|
export function boundRunnerRecord({id,kind,payload},seq) {
|
|
735
735
|
// Exact S3a envelope width. Digest contents do not affect encoded byte count.
|
|
736
736
|
// The envelope adds at most the 1 KiB the store allows above the payload.
|
|
737
|
+
// The payload itself is bounded like the store bounds it (S3a): the 1 KiB is
|
|
738
|
+
// envelope room only, so a payload above the record limit is refused on read
|
|
739
|
+
// as on write, not only when the envelope also overflows.
|
|
740
|
+
json(payload,JOURNAL_PAYLOAD_LIMIT);
|
|
737
741
|
json({version:1,seq,id,kind,payload,previousDigest:seq>1?'0'.repeat(64):null,digest:'0'.repeat(64)},JOURNAL_PAYLOAD_LIMIT+1024);
|
|
738
742
|
}
|
|
739
743
|
export function attemptBaseline(original,attempt) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Internal pure C2b payload validation. No filesystem or approval authority.
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import {createHash} from 'node:crypto';
|
|
4
|
-
import {need,shape,hex,json,digest,validIdentity} from './effect-contract.mjs';
|
|
4
|
+
import {need,shape,hex,json,digest,validIdentity,JOURNAL_PAYLOAD_LIMIT} from './effect-contract.mjs';
|
|
5
5
|
import {reviewSpecsPath} from './review-package.mjs';
|
|
6
6
|
const FILE_LIMIT=256*1024,sha=b=>createHash('sha256').update(b).digest('hex');
|
|
7
7
|
const same=(a,b)=>need(digest(a)===digest(b),'commit_history_invalid');
|
|
@@ -31,7 +31,9 @@ export function planBytes(raw){
|
|
|
31
31
|
need(changes===1,'invalid_plan');return {before,after};
|
|
32
32
|
}
|
|
33
33
|
export function readCommitIntent(raw,{owner,identity,fingerprints}){
|
|
34
|
-
|
|
34
|
+
// 与写入侧同一上限:提交意图按存档单条上限写入(task-commit boundedRecord),
|
|
35
|
+
// 读取若仍写死 1 MiB,计划接近 1 MiB 时写得进的意图读不回,整次提交记录变成不可读
|
|
36
|
+
const p=json(raw,JOURNAL_PAYLOAD_LIMIT);
|
|
35
37
|
shape(p,['version','protocol','type','identity','owner','fingerprints','plan','proof','parent','temporaryName']);
|
|
36
38
|
need(p.version===1&&p.protocol==='cm-task-commit'&&p.type==='intent','commit_history_invalid');
|
|
37
39
|
validIdentity(p.identity);same(p.identity,identity);same(p.owner,owner);same(p.fingerprints,fingerprints);
|
|
@@ -531,7 +531,11 @@ export async function batchFixture(mode,options={}){
|
|
|
531
531
|
if(options.redoCode==='developer_rate_limited'){
|
|
532
532
|
assert.equal(result.developFailure,'developer_rate_limited',JSON.stringify(result));
|
|
533
533
|
const {driveNotice,buildNotifyMessage}=await import('../runtime/js/notify.mjs');
|
|
534
|
-
|
|
534
|
+
// An empty CM home: the delivery under test must not follow the developer's own standing
|
|
535
|
+
// authorization (~/.cm-workflow/autonomy.json turns every stop into a 'later' notice).
|
|
536
|
+
const noticeHome=fs.mkdtempSync(path.join(root,'notify-home-'));
|
|
537
|
+
const notice=driveNotice({host:'/x/scripts/cm-ai-batch-host.mjs',cwd:codeProject,args:['--host-context','s1'],operation:'advance',row:{requestId:'drive',result},
|
|
538
|
+
env:{...process.env,CM_WORKFLOW_HOME:noticeHome}});
|
|
535
539
|
assert.equal(notice.delivery,'now');
|
|
536
540
|
assert.match(buildNotifyMessage(notice,{now:Date.now(),layout:'compact'}).body,/开发进程被限流(429):过一刻钟后回到会话「s1」,授权它重做这一轮开发/);
|
|
537
541
|
}else assert.equal(Object.hasOwn(result,'developFailure'),false);
|
|
@@ -9,10 +9,12 @@ import {notify,notifyLater,cancelPendingNotice,clearAttention,sessionTitle,sched
|
|
|
9
9
|
|
|
10
10
|
// driveNotice and spawned drivers read the standing authorization from the default
|
|
11
11
|
// home: point it at an empty directory, never the tester's own ~/.cm-workflow.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
// Always, not only when unset: a tester's exported CM_WORKFLOW_HOME may be their real
|
|
13
|
+
// home with autonomy.json on, which defers every stop and fails the 'now' expectations
|
|
14
|
+
// (dogfood 2026-11-17: four tests failed with a real home under standing authorization).
|
|
15
|
+
const DEFAULT_HOME=fs.mkdtempSync(path.join(os.tmpdir(),'cm-notify-default-home-'));
|
|
16
|
+
process.env.CM_WORKFLOW_HOME=DEFAULT_HOME;
|
|
17
|
+
process.on('exit',()=>fs.rmSync(DEFAULT_HOME,{recursive:true,force:true}));
|
|
16
18
|
const NOW=Date.parse('2026-10-08T08:00:00.000Z');
|
|
17
19
|
const DRIVE_CORE=new URL('../runtime/js/cm-ai/drive-core.mjs',import.meta.url).href;
|
|
18
20
|
const BRIDGE=new URL('../runtime/js/cm-ai/host-tool-bridge.mjs',import.meta.url).href;
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"invoke": {"mode": "direct", "when": "要结束或切换当前会话:请求写交接文档、交接摘要或接手说明,把当前进度和上下文留给新会话、新窗口或另一个 agent 接着做"},
|
|
27
27
|
"keywords": ["会话太长", "上下文太长", "上下文快满", "换个会话", "开个新会话", "新开一个会话", "context is getting long", "start a new session", "上下文不够了", "上下文要满了", "上下文快爆了", "上下文快用完", "下个会话接着做", "新会话接着做", "hand off to a new session", "running out of context", "context window is almost full", "continue in a new session"],
|
|
28
28
|
"reason": "先写交接摘要,再换新会话接着做",
|
|
29
|
-
"patterns": ["^(?=[\\s\\S]*(新会话|新的会话|下个会话|下一个会话|换(个|一个)?会话|开(个|一个)?新会话|(上下文|会话)((快|要)(满|爆|用完)|不够|满了|爆了|用完了|太长)))[\\s\\S]
|
|
29
|
+
"patterns": ["^(?=[\\s\\S]*(新会话|新的会话|下个会话|下一个会话|换(个|一个)?会话|开(个|一个)?新会话|(上下文|会话)((快|要)(满|爆|用完)|不够|满了|爆了|用完了|太长)|\\b(new|fresh|next|another) session|running out of context|context (window )?is (almost |getting )?(full|long)))[\\s\\S]*(交接|\\bhand-? ?off\\b)"]
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"id": "multi-session-work",
|
|
@@ -156,6 +156,45 @@ export function loadRules({env=process.env,rulesFile=defaultRulesPath()}={}){
|
|
|
156
156
|
// Pasted logs and code are where stray keywords live, so fenced blocks never match.
|
|
157
157
|
export const stripCode=text=>text.replace(/```[\s\S]*?(?:```|$)/g,' ');
|
|
158
158
|
|
|
159
|
+
// Keyword-fallback guards for invoke rules only (方案-否定句 2026-11-16). Hints and the Jev
|
|
160
|
+
// path are untouched: changing what Jev is sent would void the recorded exam answers.
|
|
161
|
+
// Real misfire: "不要换个会话,继续当前任务" told the model to start handoff.
|
|
162
|
+
// Quoted or inline-code words are being talked about, not asked for. ASCII ' is left
|
|
163
|
+
// alone because English contractions use it.
|
|
164
|
+
const QUOTED=[/`[^`\n]*`/g,/“[^”]*”/g,/「[^」]*」/g,/『[^』]*』/g,/"[^"\n]*"/g];
|
|
165
|
+
export const stripQuoted=text=>QUOTED.reduce((out,re)=>out.replace(re,' '),text);
|
|
166
|
+
// A negation masks only the few characters (Chinese) or words (English) right after it,
|
|
167
|
+
// within its own clause: "不要继续当前任务,换个会话交接" still asks for a handoff.
|
|
168
|
+
// "别忘了/不要忘了/别忘记" mean "do", so a negation followed by 忘 is not one.
|
|
169
|
+
export const NEGATION_WINDOW={zh:4,en:3};
|
|
170
|
+
const CLAUSE_END=/[,,。.!!??;;::\n]/;
|
|
171
|
+
// A lone 别 inside a word (别人、特别、分别、区别、告别、别名…) is not a negation (review r1),
|
|
172
|
+
// nor are A-not-A questions (要不要、用不用、想不想) or "why not" (review r2).
|
|
173
|
+
const ZH_NEGATION=/(?:先别|(?<!(?<!只)要)不要|(?<!用)不用|(?<!想)不想|无需|不必|(?<![特分区识级类个告差辨鉴性派道送判甄离])别(?![人处的致墅名扭样具]))(?!忘)/g;
|
|
174
|
+
const EN_NEGATION=/\b(?:(?<!why\s+)don['’]?t|do not|no need to|(?<!why\s+)not)\b/g;
|
|
175
|
+
const EN_WORD=/^[ \t]+[^\s,,。.!!??;;::]+/;
|
|
176
|
+
export function maskNegated(text){
|
|
177
|
+
let out=text;
|
|
178
|
+
const blank=(from,to)=>{out=out.slice(0,from)+' '.repeat(to-from)+out.slice(to);};
|
|
179
|
+
for(const match of text.matchAll(ZH_NEGATION)){
|
|
180
|
+
const start=match.index+match[0].length;
|
|
181
|
+
let end=start;
|
|
182
|
+
while(end<text.length&&end-start<NEGATION_WINDOW.zh&&!CLAUSE_END.test(text[end]))end++;
|
|
183
|
+
blank(start,end);
|
|
184
|
+
}
|
|
185
|
+
for(const match of text.matchAll(EN_NEGATION)){
|
|
186
|
+
const start=match.index+match[0].length;
|
|
187
|
+
let end=start;
|
|
188
|
+
for(let words=0;words<NEGATION_WINDOW.en;words++){
|
|
189
|
+
const next=EN_WORD.exec(text.slice(end));
|
|
190
|
+
if(!next)break;
|
|
191
|
+
end+=next[0].length;
|
|
192
|
+
}
|
|
193
|
+
blank(start,end);
|
|
194
|
+
}
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
|
|
159
198
|
// A user regex can backtrack for minutes; it runs in a context with a hard time
|
|
160
199
|
// budget, and on timeout no pattern counts as matched (keywords still do).
|
|
161
200
|
export function patternMatches(rules,text,budget=PATTERN_BUDGET_MS){
|
|
@@ -269,8 +308,31 @@ export async function pickInvoke({prompt,rules,host,env,authorCheck,judgeModule,
|
|
|
269
308
|
choices:candidates.map(rule=>({skill:rule.skill,when:rule.invoke.when,near:rule.invoke.near}))});
|
|
270
309
|
}
|
|
271
310
|
if(!verdict.error)return {rule:candidates.find(rule=>rule.skill===verdict.skill)??null,via:'jev',candidates};
|
|
272
|
-
const
|
|
273
|
-
|
|
311
|
+
const fallback={via:'keyword',error:verdict.error,candidates};
|
|
312
|
+
const unquoted=stripQuoted(stripCode(prompt.toLowerCase()));
|
|
313
|
+
const guarded=splitHits(candidates,maskNegated(unquoted));
|
|
314
|
+
// Guards only take matches away: masking can also hide a pattern's exclusion words
|
|
315
|
+
// ("不要重构一下,架构太乱了"), so a guarded hit counts only where the plain text hit too.
|
|
316
|
+
const plain=splitHits(candidates,stripCode(prompt.toLowerCase()));
|
|
317
|
+
const raw=plain.map(hit=>hit.keyword||hit.pattern);
|
|
318
|
+
const index=guarded.findIndex((hit,at)=>raw[at]&&(hit.keyword||hit.pattern));
|
|
319
|
+
if(index>=0){
|
|
320
|
+
const rule=candidates[index];
|
|
321
|
+
// A rule with patterns keeps its mode only when a pattern matched both before and after
|
|
322
|
+
// the guards; its bare keywords ("换个会话" without "交接") make the model ask first.
|
|
323
|
+
const strong=guarded[index].pattern&&plain[index].pattern;
|
|
324
|
+
return {...fallback,rule,mode:rule.patterns.length&&!strong?'ask':rule.invoke.mode};
|
|
325
|
+
}
|
|
326
|
+
// What the guards held back, for the log (rule and reason only, never the text).
|
|
327
|
+
const first=raw.findIndex(Boolean);
|
|
328
|
+
if(first<0)return {...fallback,rule:null};
|
|
329
|
+
const unguarded=splitHits([candidates[first]],unquoted)[0];
|
|
330
|
+
return {...fallback,rule:null,suppressed:{rule:candidates[first].id,skill:candidates[first].skill,
|
|
331
|
+
reason:unguarded.keyword||unguarded.pattern?'negated':'quoted'}};
|
|
332
|
+
}
|
|
333
|
+
function splitHits(rules,text){
|
|
334
|
+
const byPattern=patternMatches(rules,text);
|
|
335
|
+
return rules.map((rule,index)=>({keyword:rule.keywords.some(word=>text.includes(word)),pattern:byPattern[index]}));
|
|
274
336
|
}
|
|
275
337
|
|
|
276
338
|
export const messageText=(hints,host)=>
|
|
@@ -304,13 +366,14 @@ export async function hook(input,{env=process.env,host='claude',rulesFile=defaul
|
|
|
304
366
|
// An installed invoke rule is handled above only; the rest hint as before.
|
|
305
367
|
const handled=new Set(invoked.candidates.map(rule=>rule.id));
|
|
306
368
|
const hints=short?pickHints({prompt,rules:loaded.rules.filter(rule=>!handled.has(rule.id)),host,env,hinted:state.hinted,authorCheck}):[];
|
|
307
|
-
const start=invoked.rule?{skill:invoked.rule.skill,mode:invoked.rule.invoke.mode,reason:invoked.rule.reason}:null;
|
|
369
|
+
const start=invoked.rule?{skill:invoked.rule.skill,mode:invoked.mode??invoked.rule.invoke.mode,reason:invoked.rule.reason}:null;
|
|
308
370
|
// Bookkeeping failures cost the statistics, never the hint itself.
|
|
309
371
|
try{
|
|
310
372
|
for(const item of adopted)appendLog(env,{t:time,event:'adopted',host,rule:item.rule,skill:item.skill});
|
|
311
373
|
// A missing key is the normal state for most users, not worth a line per message.
|
|
312
374
|
if(invoked.error&&!['no-key','off'].includes(invoked.error))appendLog(env,{t:time,event:'judge-error',host,error:invoked.error});
|
|
313
375
|
if(start)appendLog(env,{t:time,event:'invoke',host,rule:invoked.rule.id,skill:start.skill,mode:start.mode,via:invoked.via});
|
|
376
|
+
if(invoked.suppressed)appendLog(env,{t:time,event:'suppressed',host,...invoked.suppressed});
|
|
314
377
|
for(const hint of hints)appendLog(env,{t:time,event:'hint',host,rule:hint.rule,skill:hint.skill});
|
|
315
378
|
}catch{/* 统计丢一条 */}
|
|
316
379
|
// Session state is never removed (decided 2026-10-24): a session resumed months
|
|
@@ -829,3 +829,99 @@ test('the shipped table marks only handoff direct and the two heavy skills ask',
|
|
|
829
829
|
assert.deepEqual(Object.fromEntries(rules.filter(rule=>rule.invoke).map(rule=>[rule.skill,rule.invoke.mode])),
|
|
830
830
|
{handoff:'direct',wayfinder:'ask','improve-codebase-architecture':'ask'});
|
|
831
831
|
});
|
|
832
|
+
|
|
833
|
+
// ---- keyword-fallback guards (方案-否定句 2026-11-16) ----
|
|
834
|
+
// Real misfire: "不要换个会话,继续当前任务" told the model to start handoff (Jev off).
|
|
835
|
+
function guarded(t,rules=readJson(defaultRulesPath()).value){
|
|
836
|
+
const f=fixture(t,{rules,local:{judge:false},authorNames:['handoff','wayfinder','improve-codebase-architecture'],
|
|
837
|
+
authorSkills:[['.claude/skills','handoff'],['.claude/skills','wayfinder'],['.claude/skills','improve-codebase-architecture']]});
|
|
838
|
+
let session=0;
|
|
839
|
+
const run=async prompt=>{
|
|
840
|
+
const out=await hook({prompt,session_id:`g${session++}`},{env:f.env,host:'claude',rulesFile:f.rulesFile,now:NOW,
|
|
841
|
+
loadAuthor:async()=>({...(await loadAuthorCheck()),skills:f.authorOptions.skills,license:f.authorOptions.license})});
|
|
842
|
+
const parsed=out?JSON.parse(out):null;
|
|
843
|
+
if(!parsed?.hookSpecificOutput)return null;
|
|
844
|
+
const line=parsed.systemMessage.split('\n')[0];
|
|
845
|
+
const ask=/先问你要不要用 \/(\S+)$/.exec(line);
|
|
846
|
+
return ask?`ask:${ask[1]}`:`direct:${/已让模型用 \/(\S+)$/.exec(line)[1]}`;
|
|
847
|
+
};
|
|
848
|
+
return {...f,run};
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
test('guards: negation, quotes and bare keywords decide direct, ask or nothing for the shipped handoff rule',async t=>{
|
|
852
|
+
const f=guarded(t);
|
|
853
|
+
const cases=[
|
|
854
|
+
['不要换个会话,继续当前任务',null],
|
|
855
|
+
['不要继续当前任务,换个会话交接一下','direct:handoff'],
|
|
856
|
+
['上下文快满了,帮我写个交接','direct:handoff'],
|
|
857
|
+
['上下文快满了','ask:handoff'],
|
|
858
|
+
['不用交接,换个会话就行','ask:handoff'],
|
|
859
|
+
['我们讨论 “换个会话” 这个关键词',null],
|
|
860
|
+
['`换个会话` 是个关键词',null],
|
|
861
|
+
['别忘了换个会话前先交接','direct:handoff'],
|
|
862
|
+
['先别管测试,换个会话交接吧','direct:handoff'],
|
|
863
|
+
["don't start a new session, keep going",null],
|
|
864
|
+
['/handoff 下个会话接着做',null],
|
|
865
|
+
['帮我把这个大改造拆成多个会话','ask:wayfinder'],
|
|
866
|
+
// "handoff" counts as 交接, and English session phrases count as 会话 (user decision 2026-11-17).
|
|
867
|
+
['上下文快满了,写个 handoff 吧','direct:handoff'],
|
|
868
|
+
['context window is almost full, write a handoff doc for a fresh session','direct:handoff'],
|
|
869
|
+
['hand off to a new session','direct:handoff'],
|
|
870
|
+
["don't hand off, start a new session",'ask:handoff'],
|
|
871
|
+
['我们讨论 handoff 这个技能',null],
|
|
872
|
+
];
|
|
873
|
+
const got=[];
|
|
874
|
+
for(const [prompt] of cases)got.push([prompt,await f.run(prompt)]);
|
|
875
|
+
assert.deepEqual(got,cases);
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
test('guards: window edges, case, everyday words with 别, and guards never add a match (review r1)',async t=>{
|
|
879
|
+
const f=guarded(t);
|
|
880
|
+
const cases=[
|
|
881
|
+
['跟别人换个会话交接','direct:handoff'],
|
|
882
|
+
['特别是上下文快满了,帮我写交接','direct:handoff'],
|
|
883
|
+
['你别换个会话,继续',null],
|
|
884
|
+
// Chinese: a hit starting within 4 characters of the negation is masked, from the 5th it is not.
|
|
885
|
+
['不要啊啊啊上下文快满了',null],
|
|
886
|
+
['不要啊啊啊啊上下文快满了','ask:handoff'],
|
|
887
|
+
// English: up to 3 words after the negation.
|
|
888
|
+
["don't a b start a new session",null],
|
|
889
|
+
["don't a b c start a new session",'ask:handoff'],
|
|
890
|
+
['no need to start a new session',null],
|
|
891
|
+
['START A NEW SESSION','ask:handoff'],
|
|
892
|
+
// Masking a pattern's exclusion words must not create a new trigger.
|
|
893
|
+
// A-not-A questions and "why not" are not negations (review r2); plain "not"/"do not" are.
|
|
894
|
+
['要不要换个会话交接','direct:handoff'],
|
|
895
|
+
['用不用换个会话交接','direct:handoff'],
|
|
896
|
+
['想不想换个会话交接','direct:handoff'],
|
|
897
|
+
['why not start a new session','ask:handoff'],
|
|
898
|
+
["why don't we start a new session",'ask:handoff'],
|
|
899
|
+
['只要不要换个会话交接就行',null],
|
|
900
|
+
['i will not start a new session',null],
|
|
901
|
+
['do not start a new session',null],
|
|
902
|
+
['用别名换个会话交接','direct:handoff'],
|
|
903
|
+
['道别前换个会话交接','direct:handoff'],
|
|
904
|
+
['不要重构一下,架构太乱了',null],
|
|
905
|
+
['架构太乱了,我说的不是`重构一下`',null],
|
|
906
|
+
];
|
|
907
|
+
const got=[];
|
|
908
|
+
for(const [prompt] of cases)got.push([prompt,await f.run(prompt)]);
|
|
909
|
+
assert.deepEqual(got,cases);
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
test('guards: what they hold back is logged with rule and reason only, never the text',async t=>{
|
|
913
|
+
const f=guarded(t);
|
|
914
|
+
await f.run('不要换个会话,继续当前任务');
|
|
915
|
+
await f.run('我们讨论 “换个会话” 这个关键词');
|
|
916
|
+
assert.deepEqual(f.log().filter(entry=>entry.event==='suppressed').map(({rule,skill,reason})=>({rule,skill,reason})),[
|
|
917
|
+
{rule:'long-session',skill:'handoff',reason:'negated'},
|
|
918
|
+
{rule:'long-session',skill:'handoff',reason:'quoted'}]);
|
|
919
|
+
assert.doesNotMatch(fs.readFileSync(logFile(f.env),'utf8'),/换个会话|继续当前任务/);
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
test('guards: masking a pattern\'s exclusion words never upgrades ask to direct (review r2)',async t=>{
|
|
923
|
+
const f=guarded(t,{version:1,rules:[{id:'long-session',skill:'handoff',author:true,keywords:['换个会话'],
|
|
924
|
+
patterns:['^(?![\\s\\S]*只是问问)[\\s\\S]*会话'],reason:'写交接',invoke:{mode:'direct',when:'写交接'}}]});
|
|
925
|
+
assert.equal(await f.run('换个会话,不要只是问问'),'ask:handoff');
|
|
926
|
+
assert.equal(await f.run('换个会话吧'),'direct:handoff');
|
|
927
|
+
});
|