@aibyzero/cm-workflow 0.21.1 → 0.21.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.
Files changed (72) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +19 -0
  3. package/README.md +13 -1
  4. package/VERSION +1 -1
  5. package/docs/installation.md +1 -1
  6. package/docs/js-workflow-control.md +6 -1
  7. package/package.json +1 -1
  8. package/runtime/js/cm-ai/call-timeout.mjs +21 -0
  9. package/runtime/js/cm-ai/checkpoint-package-material.mjs +3 -2
  10. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +5 -1
  11. package/runtime/js/cm-ai/codex-config.mjs +6 -1
  12. package/runtime/js/cm-ai/durable-runner-state.mjs +19 -4
  13. package/runtime/js/cm-ai/fix-code-association.mjs +5 -5
  14. package/runtime/js/cm-ai/host-conversation-execution.mjs +22 -15
  15. package/runtime/js/cm-ai/host-documentation.mjs +4 -3
  16. package/runtime/js/cm-ai/host-handoff.mjs +3 -2
  17. package/runtime/js/cm-ai/host-project-execution.mjs +11 -9
  18. package/runtime/js/cm-ai/host-qa-executor.mjs +3 -2
  19. package/runtime/js/cm-ai/host-replay.mjs +28 -8
  20. package/runtime/js/cm-ai/review-package.mjs +101 -33
  21. package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +1 -1
  22. package/runtime/js/cm-ai/reviewed-integration.mjs +1 -1
  23. package/runtime/js/cm-ai/spec-amendment.mjs +20 -0
  24. package/runtime/js/cm-ai/symlink-material.mjs +153 -0
  25. package/runtime/js/cm-ai/task-commit.mjs +6 -3
  26. package/runtime/js/cm-ai/task-runner.mjs +14 -6
  27. package/runtime/js/cm-ai/worker-claude-developer.mjs +19 -7
  28. package/runtime/js/cm-ai/worker-codex-developer.mjs +3 -1
  29. package/runtime/js/cm-fix/protected-edits.mjs +57 -36
  30. package/runtime/js/cm-prd/change.mjs +4 -1
  31. package/runtime/js/cm-prd/review-findings.mjs +3 -2
  32. package/runtime/js/cm-prd/review-publication.mjs +3 -2
  33. package/runtime/js/cm-prd/split-design.mjs +4 -4
  34. package/scripts/ci-test-weights.json +1 -0
  35. package/scripts/cm-ai-admission.test.mjs +5 -5
  36. package/scripts/cm-ai-batch-drive.mjs +9 -5
  37. package/scripts/cm-ai-call-timeout.test.mjs +85 -0
  38. package/scripts/cm-ai-control-launch.test.mjs +18 -0
  39. package/scripts/cm-ai-drive.mjs +142 -43
  40. package/scripts/cm-ai-host.mjs +15 -3
  41. package/scripts/cm-ai-host.test.mjs +3 -1
  42. package/scripts/cm-ai-launch-diagnostics.test.mjs +23 -0
  43. package/scripts/cm-ai-review-failure.test.mjs +3 -0
  44. package/scripts/cm-ai-run.mjs +2 -1
  45. package/scripts/cm-ai-scope-revision.test.mjs +35 -3
  46. package/scripts/cm-ai-supersede.test.mjs +51 -3
  47. package/scripts/cm-ai-symlink.test.mjs +481 -0
  48. package/scripts/cm-codex-developer-worker.test.mjs +13 -1
  49. package/scripts/cm-notify-command.test.mjs +3 -0
  50. package/scripts/cm-notify.test.mjs +3 -0
  51. package/scripts/cm-patrol.test.mjs +3 -0
  52. package/scripts/cm-prd-design-phase.test.mjs +31 -0
  53. package/scripts/cm-prd-review-gate.mjs +28 -3
  54. package/scripts/cm-prd-summary.test.mjs +5 -5
  55. package/scripts/cm-skill-hints.mjs +40 -16
  56. package/scripts/cm-skill-hints.test.mjs +91 -0
  57. package/scripts/cm-spec-amend.test.mjs +107 -1
  58. package/scripts/cm-specs-status.test.mjs +5 -5
  59. package/scripts/cm-start-check.mjs +53 -15
  60. package/scripts/cm-start-check.test.mjs +41 -2
  61. package/scripts/cm-task-gate.mjs +42 -13
  62. package/scripts/cm-task-gate.test.mjs +33 -0
  63. package/scripts/cm-tool-preview-context.test.mjs +20 -1
  64. package/scripts/cm-upgrade-compat.test.mjs +7 -0
  65. package/skills/cm-ai/references/js-host.md +1 -0
  66. package/skills/cm-prd/SKILL.md +14 -27
  67. package/skills/cm-prd/references/change-mode.md +2 -0
  68. package/skills/cm-prd/references/cm-optout.md +11 -0
  69. package/skills/cm-prd/references/context-scope.md +2 -1
  70. package/skills/cm-prd/references/js-host.md +2 -2
  71. package/skills/cm-prd/references/requirement-grilling.md +116 -0
  72. package/skills/cm-product-manager/SKILL.md +13 -1
@@ -6,7 +6,7 @@ import path from 'node:path';
6
6
  import test from 'node:test';
7
7
  import {fileURLToPath} from 'node:url';
8
8
  import {spawnSync} from 'node:child_process';
9
- import {CHECK_CALL_LIMIT_MS, MAX_SCOPE_PATHS, startCheck, checkMandatoryTests, checkReviewInventory, checkLaunchInputs} from './cm-start-check.mjs';
9
+ import {CHECK_CALL_LIMIT_MS, MAX_SCOPE_PATHS, startCheck, checkMandatoryTests, checkReviewInventory, checkLaunchInputs, callLimit} from './cm-start-check.mjs';
10
10
  import {buildManifest} from './cm-spec-manifest.mjs';
11
11
 
12
12
  const here = path.dirname(fileURLToPath(import.meta.url));
@@ -247,9 +247,28 @@ test('the summed check timeouts warn only above the 30 minute call limit', t =>
247
247
  assert.deepEqual(codes(check(tight).report), ['check_budget_over_call_limit']);
248
248
  });
249
249
 
250
+ test('--call-timeout-minutes 放宽整步期限:45 分钟的检查在 60 分钟期限下不报,非法值报 error', t => {
251
+ const checks = [cmd('a', ['a'], 1500000), cmd('b', ['b'], 1200000)];
252
+ assert.deepEqual(codes(check(project(t, {checks})).report), ['check_budget_over_call_limit']);
253
+ const widened = project(t, {checks, plan: {permissions: ['--allow-development', '--call-timeout-minutes', '60']}});
254
+ assert.deepEqual(check(widened).report.findings, []);
255
+ const short = project(t, {checks, plan: {permissions: ['--allow-development', '--call-timeout-minutes', '40']}});
256
+ const r = check(short);
257
+ assert.deepEqual(r.report.findings.map(item => [item.code, item.limitMs]), [['check_budget_over_call_limit', 2400000]]);
258
+ const bad = project(t, {checks: [cmd('a', ['a'])], plan: {permissions: ['--allow-development', '--call-timeout-minutes', '90']}});
259
+ assert.deepEqual(check(bad).report.findings.map(item => [item.level, item.code]), [['error', 'call_timeout_invalid']]);
260
+ // 计划不写 checks、或参数重复时也要提前报出(宿主同样会拒绝)
261
+ const noChecks = project(t, {plan: {permissions: ['--allow-development', '--call-timeout-minutes', '90']}});
262
+ assert.deepEqual(check(noChecks).report.findings.map(item => [item.level, item.code]), [['error', 'call_timeout_invalid']]);
263
+ const twice = project(t, {checks: [cmd('a', ['a'])], plan: {permissions: ['--call-timeout-minutes', '60', '--call-timeout-minutes', '90']}});
264
+ assert.deepEqual(check(twice).report.findings.map(item => [item.level, item.code]), [['error', 'call_timeout_invalid']]);
265
+ });
266
+
250
267
  test('the call limit constant still matches the host source', () => {
251
268
  const source = fs.readFileSync(path.join(here, '..', 'runtime/js/cm-ai/host-conversation-execution.mjs'), 'utf8');
252
- assert.match(source, /const outerTimeoutMs=provider\?protection\.timeoutMs:1800000;/);
269
+ assert.match(source, /const outerTimeoutMs=provider\?protection\.timeoutMs:\(options\.callTimeoutMs\?\?DEFAULT_CALL_TIMEOUT_MS\);/);
270
+ const limits = fs.readFileSync(path.join(here, '..', 'runtime/js/cm-ai/call-timeout.mjs'), 'utf8');
271
+ assert.match(limits, /export const DEFAULT_CALL_TIMEOUT_MS=1800000;/);
253
272
  });
254
273
 
255
274
  test('dirty scope files warn (tracked change and new file), files outside scope do not, --strict turns warns into exit 1', t => {
@@ -502,6 +521,16 @@ test('a code tree over the review inventory limit is an error before the run sta
502
521
  assert.match(findings[0].message, /build\.bin/);
503
522
  });
504
523
 
524
+ test('new-run inventory accepts a scoped directory symlink and does not scan its referent', t => {
525
+ const p=project(t,{scope:['alias'],repo:false});
526
+ const specsDir=path.join(p.dir,'specs');
527
+ fs.mkdirSync(specsDir);
528
+ fs.symlinkSync('src',path.join(p.root,'alias'));
529
+ const definition={codeProject:p.root,specsDir,scope:['alias'],requirements:['src/a.js'],
530
+ identity:{repositoryId:'r',runId:'run-1',taskId:'T-001',attempt:1}};
531
+ assert.deepEqual(checkReviewInventory(definition),[]);
532
+ });
533
+
505
534
  // Wue specs8 T-001: each of these stopped one advance after the start check had passed.
506
535
  test('answers the advance will ask and an invalid interactive QA declaration are errors before launch', t => {
507
536
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'cm-start-launch-'));
@@ -542,3 +571,13 @@ test('answers the advance will ask and an invalid interactive QA declaration are
542
571
  const resumed = checkLaunchInputs({...plan([]), mode: 'resume'}, planFile, definition).filter(item => item.code === 'answers_conflict');
543
572
  assert.deepEqual(resumed.map(item => item.level), ['warn']);
544
573
  });
574
+
575
+ test('恢复时体检按原运行判断期限:普通运行不得低于创建值,外部模型运行须一致(与宿主同一规则)', () => {
576
+ const codes = r => r.findings.map(item => item.code);
577
+ const plain = {timeoutMs: 3600000, external: false}, external = {timeoutMs: 1800000, external: true};
578
+ assert.deepEqual(codes(callLimit({mode: 'resume', permissions: ['--call-timeout-minutes', '60']}, plain)), []);
579
+ assert.deepEqual(codes(callLimit({mode: 'resume', permissions: []}, plain)), ['call_timeout_invalid']);
580
+ assert.equal(callLimit({mode: 'resume', permissions: ['--call-timeout-minutes', '60']}, {timeoutMs: 1800000, external: false}).limitMs, 3600000);
581
+ assert.deepEqual(codes(callLimit({mode: 'resume', permissions: []}, external)), []);
582
+ assert.deepEqual(codes(callLimit({mode: 'resume', permissions: ['--call-timeout-minutes', '60']}, external)), ['call_timeout_invalid']);
583
+ });
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // JavaScript authority for CM handoff, review, and read-only completion-plan gates.
3
+ import {assertRealParents,readSymlinkRecord,resolveSymlinkTarget} from '../runtime/js/cm-ai/symlink-material.mjs';
3
4
  import fs from 'node:fs';
4
5
  import os from 'node:os';
5
6
  import path from 'node:path';
@@ -179,7 +180,25 @@ function resolveStrictFalse(target){
179
180
  }
180
181
  }
181
182
 
182
- export function implementationSha256(projectRoot,changedFiles){
183
+ const implementationDigest=()=>createHash('sha256').update('cm-implementation-v1\0');
184
+ const pathBytesOrder=(left,right)=>Buffer.compare(Buffer.from(left),Buffer.from(right));
185
+ function bindImplementationEntry(digest,file,type,content){
186
+ digest.update(file).update('\0').update(type).update('\0');
187
+ if(type!=='missing')digest.update(String(content.length)).update('\0').update(content).update('\0');
188
+ }
189
+
190
+ // The already validated package contains the same bytes the gate hashes on disk.
191
+ export function projectedImplementationSha256(changes){
192
+ const digest=implementationDigest();
193
+ for(const {path:file,after} of [...changes].sort((a,b)=>pathBytesOrder(a.path,b.path))){
194
+ const type=after?.type??'missing';
195
+ const content=after===null?null:after.type==='symlink'?Buffer.from(after.target):Buffer.from(after.contentBase64,'base64');
196
+ bindImplementationEntry(digest,file,type,content);
197
+ }
198
+ return digest.digest('hex');
199
+ }
200
+
201
+ export function implementationSha256(projectRoot,changedFiles,{allowSymlinks=false}={}){
183
202
  requireString(projectRoot,'project root');
184
203
  const expanded=projectRoot==='~'?os.homedir()
185
204
  :projectRoot.startsWith(`~${path.sep}`)?path.join(os.homedir(),projectRoot.slice(2)):projectRoot;
@@ -191,11 +210,22 @@ export function implementationSha256(projectRoot,changedFiles){
191
210
  if(error instanceof GateError)throw error;
192
211
  throw new GateError(`project root is not an existing directory: ${path.resolve(expanded)}`);
193
212
  }
194
- const digest=createHash('sha256');digest.update('cm-implementation-v1\0');
195
- const files=[...requireRelativeFiles(changedFiles)].sort((left,right)=>Buffer.compare(Buffer.from(left),Buffer.from(right)));
213
+ const digest=implementationDigest();
214
+ const files=[...requireRelativeFiles(changedFiles)].sort(pathBytesOrder);
196
215
  for(const relative of files){
197
216
  const unresolved=path.join(root,...relative.split('/'));
198
- try{if(fs.lstatSync(unresolved).isSymbolicLink())throw new GateError(`changed file must not be a symlink: ${relative}`);}
217
+ if(allowSymlinks){
218
+ try{assertRealParents(root,relative);}catch{throw new GateError(`changed file has an unsupported parent: ${relative}`);}
219
+ }
220
+ try{
221
+ if(fs.lstatSync(unresolved).isSymbolicLink()){
222
+ if(!allowSymlinks)throw new GateError(`changed file must not be a symlink: ${relative}`);
223
+ const file=readSymlinkRecord(root,relative);
224
+ try{resolveSymlinkTarget(root,relative,file.target);}
225
+ catch{throw new GateError(`changed file resolves outside project root: ${relative}`);}
226
+ bindImplementationEntry(digest,relative,'symlink',Buffer.from(file.target));continue;
227
+ }
228
+ }
199
229
  catch(error){if(error?.code!=='ENOENT')throw error;}
200
230
  let candidate;
201
231
  try{candidate=resolveStrictFalse(unresolved);}
@@ -203,28 +233,27 @@ export function implementationSha256(projectRoot,changedFiles){
203
233
  const fromRoot=path.relative(root,candidate);
204
234
  if(fromRoot===''||fromRoot==='..'||fromRoot.startsWith(`..${path.sep}`)||path.isAbsolute(fromRoot))
205
235
  throw new GateError(`changed file resolves outside project root: ${relative}`);
206
- digest.update(relative);digest.update('\0');
207
236
  let info;
208
237
  try{info=fs.statSync(candidate);}catch(error){
209
- if(error?.code==='ENOENT'){digest.update('missing\0');continue;}
238
+ if(error?.code==='ENOENT'){bindImplementationEntry(digest,relative,'missing',null);continue;}
210
239
  throw new GateError(`cannot read changed file ${relative}: ${error.message}`);
211
240
  }
212
241
  if(!info.isFile())throw new GateError(`changed file must be a regular file or deletion: ${relative}`);
213
242
  let content;
214
243
  try{content=fs.readFileSync(candidate);}catch(error){throw new GateError(`cannot read changed file ${relative}: ${error.message}`);}
215
- digest.update('file\0');digest.update(String(content.length));digest.update('\0');digest.update(content);digest.update('\0');
244
+ bindImplementationEntry(digest,relative,'file',content);
216
245
  }
217
246
  return digest.digest('hex');
218
247
  }
219
248
 
220
- function verifyImplementationBinding(payload,{projectRoot=null,allowLegacyUnbound=false}={}){
249
+ function verifyImplementationBinding(payload,{projectRoot=null,allowLegacyUnbound=false,allowSymlinks=false}={}){
221
250
  const expected=payload.implementation_sha256;
222
251
  if(expected===undefined){
223
252
  if(allowLegacyUnbound)return false;
224
253
  throw new GateError('handoff is not content-bound; legacy recovery requires --allow-legacy-unbound');
225
254
  }
226
255
  if(projectRoot===null||projectRoot===undefined)throw new GateError('content-bound handoff requires --project-root');
227
- if(implementationSha256(projectRoot,payload.changed_files)!==expected)
256
+ if(implementationSha256(projectRoot,payload.changed_files,{allowSymlinks})!==expected)
228
257
  throw new GateError('implementation content changed after handoff');
229
258
  return true;
230
259
  }
@@ -1019,7 +1048,7 @@ function checkCorrection(selectors,stage){
1019
1048
 
1020
1049
  // Only compatibility CLI entries opt into inventory validation. Library callers
1021
1050
  // retain the original content-binding contract and exact result shape.
1022
- export function checkN4({handoff,reviewsDir,feature,task,projectRoot=null,allowLegacyUnbound=false,requireLearning=false,correction=null,inventory=null}){
1051
+ export function checkN4({handoff,reviewsDir,feature,task,projectRoot=null,allowLegacyUnbound=false,requireLearning=false,correction=null,inventory=null,allowSymlinks=false}){
1023
1052
  if(correction!==null)return checkCorrection({handoff,reviewsDir,feature,task,projectRoot,correction,allowLegacyUnbound,inventory},'n4');
1024
1053
  requireTaskId(task,'task');
1025
1054
  const payload=loadHandoff(handoff,{task});
@@ -1028,12 +1057,12 @@ export function checkN4({handoff,reviewsDir,feature,task,projectRoot=null,allowL
1028
1057
  const attempt=payload.attempt;
1029
1058
  requireExpectedHandoff(handoff,{reviewsDir,feature,task,attempt});
1030
1059
  validateAttemptChain(reviewsDir,feature,task,attempt,payload,projectRoot);
1031
- const contentBound=verifyImplementationBinding(payload,{projectRoot,allowLegacyUnbound});
1060
+ const contentBound=verifyImplementationBinding(payload,{projectRoot,allowLegacyUnbound,allowSymlinks});
1032
1061
  const inventoryResult=inventory==='required'?verifyInventory(payload,{projectRoot,reviewsDir,feature,task,allowLegacyUnbound}):{};
1033
1062
  return {gate:'n4',task,attempt,outcome:'ready_for_review',handoff_sha256:sha256(handoff),content_bound:contentBound,...inventoryResult};
1034
1063
  }
1035
1064
 
1036
- export function checkN5({handoff,reviewsDir,feature,task,projectRoot=null,allowLegacyUnbound=false,requireLearning=false,correction=null,inventory=null}){
1065
+ export function checkN5({handoff,reviewsDir,feature,task,projectRoot=null,allowLegacyUnbound=false,requireLearning=false,correction=null,inventory=null,allowSymlinks=false}){
1037
1066
  if(correction!==null)return checkCorrection({handoff,reviewsDir,feature,task,projectRoot,correction,allowLegacyUnbound,inventory},'n5');
1038
1067
  requireTaskId(task,'task');
1039
1068
  const payload=loadHandoff(handoff,{task});
@@ -1042,7 +1071,7 @@ export function checkN5({handoff,reviewsDir,feature,task,projectRoot=null,allowL
1042
1071
  const attempt=payload.attempt;
1043
1072
  requireExpectedHandoff(handoff,{reviewsDir,feature,task,attempt});
1044
1073
  validateAttemptChain(reviewsDir,feature,task,attempt,payload,projectRoot,'n5');
1045
- const contentBound=verifyImplementationBinding(payload,{projectRoot,allowLegacyUnbound});
1074
+ const contentBound=verifyImplementationBinding(payload,{projectRoot,allowLegacyUnbound,allowSymlinks});
1046
1075
  const inventoryResult=inventory==='required'?verifyInventory(payload,{projectRoot,reviewsDir,feature,task,allowLegacyUnbound}):{};
1047
1076
  const review=reviewPath(reviewsDir,feature,task,attempt);
1048
1077
  const result=validateReview(review,{task,attempt,handoff,changedFiles:payload.changed_files});
@@ -60,6 +60,39 @@ ${body}
60
60
  `);
61
61
  }
62
62
 
63
+ test('legacy task gate rejects link leaves and preserves an in-root linked parent',()=>fixture(root=>{
64
+ const reviews=path.join(root,'.reviews');fs.mkdirSync(reviews);
65
+ fs.mkdirSync(path.join(root,'src'));fs.writeFileSync(path.join(root,'src/example.ts'),'fixture');
66
+ fs.symlinkSync('src',path.join(root,'alias'));
67
+ fs.symlinkSync('src/example.ts',path.join(root,'link.ts'));
68
+ const handoff=path.join(reviews,'login-T-001-a1-handoff.json'),review=path.join(reviews,'login-T-001-r1.md');
69
+ const options={handoff,reviewsDir:reviews,feature:'login',task:'T-001',projectRoot:root};
70
+ const bind=(file,implementation)=>{
71
+ writeHandoff(handoff,{implementation});
72
+ const payload=JSON.parse(fs.readFileSync(handoff,'utf8'));payload.changed_files=[file];
73
+ fs.writeFileSync(handoff,JSON.stringify(payload));writeReview(review,{handoff});
74
+ fs.writeFileSync(review,fs.readFileSync(review,'utf8').replace('src/example.ts',file));
75
+ };
76
+ const parentHash=createHash('sha256')
77
+ .update(['cm-implementation-v1','alias/example.ts','file','7','fixture',''].join('\0')).digest('hex');
78
+ const linkHash=implementationSha256(root,['link.ts'],{allowSymlinks:true});
79
+ bind('link.ts',linkHash);
80
+ assert.throws(()=>checkN4(options),/changed file must not be a symlink: link\.ts/);
81
+ assert.throws(()=>checkN5(options),/changed file must not be a symlink: link\.ts/);
82
+ bind('alias/example.ts',parentHash);
83
+ assert.equal(checkN4(options).outcome,'ready_for_review');
84
+ assert.equal(checkN5(options).outcome,'approved');
85
+ }));
86
+
87
+ test('legacy implementation digest omits link support unless explicitly selected',()=>fixture(root=>{
88
+ fs.mkdirSync(path.join(root,'src'));fs.writeFileSync(path.join(root,'src/a.js'),'fixture');
89
+ fs.symlinkSync('src',path.join(root,'alias'));
90
+ fs.symlinkSync('src/a.js',path.join(root,'link.js'));
91
+ assert.throws(()=>implementationSha256(root,['link.js']),/changed file must not be a symlink: link\.js/);
92
+ assert.equal(implementationSha256(root,['alias/a.js']),
93
+ implementationSha256(root,['alias/a.js'],{allowSymlinks:false}));
94
+ }));
95
+
63
96
  test('Skill Learning gate rejects missing or pending records and binds reviewed writeback',()=>fixture(root=>{
64
97
  const reviews=path.join(root,'.reviews');fs.mkdirSync(reviews);
65
98
  fs.mkdirSync(path.join(root,'src'));fs.writeFileSync(path.join(root,'src/example.ts'),'fixture');
@@ -1,6 +1,8 @@
1
1
  import test from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
- import {skillContext} from '../runtime/js/cm-ai/tool-preview.mjs';
3
+ import {createHash} from 'node:crypto';
4
+ import {skillContext,requestTools} from '../runtime/js/cm-ai/tool-preview.mjs';
5
+ import {commonArgs,configFingerprint,NO_USER_INPUT_TOOL} from '../runtime/js/cm-ai/codex-config.mjs';
4
6
  const retainedPreamble = "Each entry includes a name, description, and location for its `SKILL.md`. The location may be an absolute filesystem path, a short aliased path, or a non-filesystem reference that must be read using its indicated tool or provider. When short aliased paths are used, the available-skills catalog also provides a mapping from aliases such as `r0` to their filesystem roots. Expand the alias before accessing the skill.\n\nThe user's instructions take precedence over guidelines provided in a skill. If explicit user instructions conflict with a skill's instructions, prioritize the user's instructions.\n\nThe first time in a conversation that you decide to apply a skill, inform the user in the commentary channel.\n\nIf a skill causes you to ask for permission or confirmation, pause, or leave requested work unfinished, name the skill and summarize the specific instruction in the skill that led to your decision. Include this explanation in the request or final response where you pause.";
5
7
  const input = text => ({input:[{content:[{text}]}]});
6
8
  test('Codex 0.159.2 retained empty skill preamble is not a catalog',()=>{
@@ -10,3 +12,20 @@ test('real, unresolved and unknown catalogs remain blocked',()=>{
10
12
  for(const content of ['- sample (file: /tmp/sample/SKILL.md)','- sample (file: r99/sample/SKILL.md)','Unrecognized catalog content'])
11
13
  assert.equal(skillContext(input('<skills_instructions>\n### Available skills\n'+retainedPreamble+'\n'+content+'\n</skills_instructions>')).present,true);
12
14
  });
15
+ // codex-cli 0.167.0 / gpt-6.2-sol 实跑请求形状:两个默认工具必须被零工具判定看见。
16
+ test('a request carrying the Codex 0.167 default tools is not zero tools',()=>{
17
+ const body={model:'gpt-6.2-sol',input:[],tools:[{type:'function',name:'request_user_input'},{type:'function',name:'view_image'}]};
18
+ assert.deepEqual(requestTools(body).map(tool=>tool.name),['request_user_input','view_image']);
19
+ assert.deepEqual(requestTools({...body,tools:[]}),[]);
20
+ assert.equal(requestTools({...body,tools:{}}),null);
21
+ });
22
+ test('the fingerprint binds each review-only tool removal, so older preflight receipts no longer match',()=>{
23
+ const options={cwd:'/fixture',model:'gpt-6.2-sol',effort:'high'},args=commonArgs(options);
24
+ const hash=list=>createHash('sha256').update(JSON.stringify(list)).digest('hex');
25
+ const without=(flag,value)=>args.filter((arg,i)=>!(arg===flag&&args[i+1]===value||arg===value&&args[i-1]===flag));
26
+ assert.equal(configFingerprint(options),hash(args));
27
+ for(const [flag,value] of [['--disable','view_image'],['-c',NO_USER_INPUT_TOOL]]){
28
+ const older=without(flag,value);assert.equal(older.length,args.length-2);
29
+ assert.notEqual(configFingerprint(options),hash(older));
30
+ }
31
+ });
@@ -23,6 +23,13 @@ import {checkPrdDraftMechanics,matchesPrdDraftMechanics} from '../runtime/js/cm-
23
23
  import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
24
24
  import {buildManifest} from './cm-spec-manifest.mjs';
25
25
 
26
+ // Spec approvals write a round ledger under CM_WORKFLOW_HOME; keep it off the real home.
27
+ // Always, not only when unset: an exported CM_WORKFLOW_HOME may be the tester's real home
28
+ // (review 2026-11-17: these suites left 11 approval records in an externally named home).
29
+ const isolatedHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-approval-home-'));
30
+ process.env.CM_WORKFLOW_HOME=isolatedHome;
31
+ process.on('exit',()=>fs.rmSync(isolatedHome,{recursive:true,force:true}));
32
+
26
33
  const TIMEOUT=Number(process.env.CM_TEST_FIXTURE_TIMEOUT_MS??120000);
27
34
  const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
28
35
  const UPGRADE_BASE='f73402d';
@@ -179,6 +179,7 @@ cm-fix 的 `learning.json`、`diagnosis.json`、`test-edits.json`、`repair-edit
179
179
  缺答案、结构错误、路径或存档无效会在启动宿主前退出 2。
180
180
 
181
181
  `develop` 回答可能超默认 64 KiB 时,首次启动即在 `PLAN.permissions` 传 `["--input-limit","1048576"]`(上限 4194304);详见 R「开发交付阻断与存档限额」。
182
+ 检查整步(含设备流程)可能超默认 30 分钟时,在 `PLAN.permissions` 加 `["--call-timeout-minutes","60"]`(30–60,仅当前会话运行);它不进运行指纹,已因超时停下的运行可在 resume 时补上;恢复时不得低于创建时的值,每次启动在 stderr 报出实际期限。
182
183
 
183
184
  `check` 只运行计划里的真实命令;原始输出打印到驾驶员 stderr,宿主只保存实际退出码和精简证据;静态 `check.json` 不会被读取。单任务和批次 PLAN 可设 `checkTimeoutMs` 作为检查默认超时,每个 `checks` 条目可设 `timeoutMs` 覆盖;均为 1..3600000 的整数毫秒,省略时驱动默认 900000(15 分钟),启动前校验。宿主 `host-check` 对其他调用方的默认值仍是 60000。
184
185
  驾驶员收到 `state: "unknown"` 或 `pendingAction: "reconcile"` 的宿主结果时退出 1,并保留原输出供原 run 恢复;不能把有结果的 JSON 当成成功。
@@ -16,7 +16,7 @@ allowed-tools:
16
16
  新建和变更模式都读取 `references/phase-timing.md`,只为实际执行的阶段写配对
17
17
  `progress/start|complete`;人工等待前关闭 segment,恢复后递增,不手算耗时。
18
18
 
19
- 用户明确要求外部专家,或为本次规格任务开启 AUTO 时,读取
19
+ 通过 `references/cm-optout.md` 核对后,用户明确要求外部专家或为本次规格任务开启 AUTO 时,读取
20
20
  `../../runtime/external-expert.md` 并执行 `../external-expert/SKILL.md` 的任务路由。
21
21
  AUTO 可把复杂方案比较路由到 CONSULT、权威事实查证路由到 VERIFY,其余保持 LOCAL。
22
22
  外部结论属于需求/设计输入,必须在本地对照项目事实并进入正常规格人审;AUTO 不
@@ -44,7 +44,7 @@ AUTO 可把复杂方案比较路由到 CONSULT、权威事实查证路由到 VER
44
44
 
45
45
  ## JS 准入与当前会话执行
46
46
 
47
- 在读取需求正文、解析角色、写 `run_start`、创建或修改 specs 之前,把已解析路径和模式传给:
47
+ 先按 `references/cm-optout.md` 核对项目规则是否禁用 CM(两种模式都做);通过后,在读取需求正文、解析角色、写 `run_start`、创建或修改 specs 之前,把已解析路径和模式传给:
48
48
 
49
49
  ```bash
50
50
  node "{CM_WORKFLOW_ROOT}/scripts/cm-prd-entry.mjs" \
@@ -148,8 +148,8 @@ node {CM_WORKFLOW_ROOT}/scripts/cm-workflow-config.mjs \
148
148
  ### Step 4: 读取项目上下文(存量项目 = 二开模式,叠加 B 规则)
149
149
 
150
150
  - 按 `runtime/project-context.md` 读取项目约束和本需求相关规则,扫描两层目录了解模块划分
151
- - 读取 `references/context-scope.md`,先做定向代码搜索,再设置
152
- `CONTEXT_SCOPE=targeted|full`、加载对应地图/代码,并写 `decision/context_scope` 日志
151
+ - 读取 `references/context-scope.md`:按下方 B1 读取适用地图或索引,再定向搜索代码,最后设置
152
+ `CONTEXT_SCOPE=targeted|full`、加载补充地图/代码,并写 `decision/context_scope` 日志
153
153
  - **B1 代码库参考文档判定**:先读代码项目根 CLAUDE.md 的「业务地图」字段(多层仓库
154
154
  下以代码项目根为准,仓库根 CLAUDE.md 无此字段再看地图 00-index 头部;init 已判定过,
155
155
  仍须核对相关内容与当前代码)。字段=已生成/已刷新或目录存在 → 按 context-scope 渐进加载并核实;字段=
@@ -162,7 +162,7 @@ node {CM_WORKFLOW_ROOT}/scripts/cm-workflow-config.mjs \
162
162
 
163
163
  ### Step 5: 分析需求
164
164
 
165
- **调用 `cm-product-manager` skill 执行本步和 Step 5.5**——用户故事、编号功能需求、验收标准的编写方法和歧义五问以该 skill 为准。
165
+ **调用 `cm-product-manager` skill 执行本步和 Step 5.5**——用户故事、编号功能需求、验收标准的编写方法、歧义五问和七项倒推清单以该 skill 为准。
166
166
 
167
167
  需求涉及**交易/资产/支付/代币/证券/金融营销**时,同时加载 `cm-finance-expert` skill 协同:领域正确性审核 + 营销合规红线扫描 + 合规开放问题(并入 Step 5.5)。法域确认结果须写入代码项目 `.claude/rules/finance.md` 头部字段;文件不存在时,以 `{CM_WORKFLOW_ROOT}/templates/rules/finance.md` 为骨架现场补生成,并在 AGENTS.md 与 CLAUDE.md 的相关规则说明中补充引用。
168
168
 
@@ -170,34 +170,15 @@ node {CM_WORKFLOW_ROOT}/scripts/cm-workflow-config.mjs \
170
170
 
171
171
  命中重要歧义或方案分歧时,按 `../../runtime/steelman-review.md` 区分已观察事实、参与者主张、当前推断和未知项;“用户真正想要什么”只能写成可修正假设,不能替用户补全业务规则。
172
172
 
173
- ### Step 5.5: 开放问题确认
173
+ ### Step 5.5: 需求倒推与逐轮追问
174
174
 
175
- 分析需求后,如果存在以下情况,**必须暂停并与用户对话确认**,不要自行假设:
176
-
177
- - 需求描述模糊或有歧义的功能点
178
- - 多种技术实现方案且差异较大
179
- - 缺少关键信息(如目标平台、兼容性要求、第三方服务选型)
180
- - 业务逻辑有矛盾或不完整
181
- - 涉及权限、支付、敏感操作等需要明确确认的功能
175
+ 读取 `references/requirement-grilling.md` 执行 G1–G4:对照现有业务倒推缺口,按设计树逐轮提问(每题带出处与推荐答案),满足其 G4 停止条件后才进入 Step 6,不得自行假设。
182
176
 
183
177
  `DELIVERY_SHAPE=wechat-miniprogram` 时追加平台就绪检查:账号主体、服务类目/资质、
184
178
  变现路径、权限与隐私、后端/合法域名和发布通道。会改变功能可行性或范围但未确认的
185
179
  项目必须暂停;只影响后续提审的材料可记为发布待决,不阻塞本地规格与开发。平台政策
186
180
  结论须记录当前官方查证日期与来源,无法查证时保留开放问题。
187
181
 
188
- 格式:
189
-
190
- ```
191
- ❓ 需要确认以下问题:
192
-
193
- 1. {问题描述} — {为什么需要确认}
194
- 2. {问题描述} — {为什么需要确认}
195
-
196
- 请逐一回复后继续生成 specs
197
- ```
198
-
199
- 所有问题确认完毕后再进入 Step 6。
200
-
201
182
  双向钢人审查只用于暴露假设和失败场景:支持方与反方都取最强版本,但按证据质量加权;无法验证的反方写入开放问题,不强迫给确定结论。
202
183
 
203
184
  ### Step 6: 推断 feature 名称
@@ -267,6 +248,12 @@ node {CM_WORKFLOW_ROOT}/scripts/cm-workflow-config.mjs \
267
248
  {按 cm-miniprogram-engineer/references/platform-readiness.md 记录状态、证据与负责人;
268
249
  不写任何密钥、证件、Cookie 或测试账号密码}
269
250
 
251
+ ## 范围与覆盖核对
252
+
253
+ - 本期做: {范围}
254
+ - 明确不做: {排除项}
255
+ - 追问补齐项: {检查项 — 问题 → 用户答案(出处: 位置)};无缺口写「倒推核对 7 项无缺口」
256
+
270
257
  ## 开放问题
271
258
 
272
259
  - {待确认事项}
@@ -518,7 +505,7 @@ AC、design 和 tasks 补齐,保证 AC→TC→Task 可追踪。纯文档/注
518
505
  │ Feature: {N 个}: {名称列表}
519
506
  │ 历史 feature:{N} 个已登记,{M} 个含旧版归档说明
520
507
  │ 功能点: {N} 个 | AC: {N} 条 | 任务: {N} 个(预估 {x}h)
521
- │ 开放问题: {已答 N / 共 N}——{逐条一行: 问题→答案}
508
+ │ 开放问题: {倒推核对结果(见 requirement-grilling G4);已答 N / 共 N}——{逐条一行: 问题→答案}
522
509
  │ 风险点: {金融/合规/破坏性操作等敏感项,无则"无"}
523
510
  │ 上下文范围: {定向 / 完整 / 定向→完整(reason_code)}
524
511
  │ 平台就绪: {就绪/待官方核验 N 项/不适用}
@@ -46,6 +46,8 @@
46
46
  - **删除**的功能需求
47
47
  - 对验收标准的影响
48
48
 
49
+ 对比完成后读取 `requirement-grilling.md`,对本次变更执行倒推核对与逐轮追问;满足其 G4 停止条件后才进入 C5,C5 按其 G4 写入「范围与覆盖核对」。
50
+
49
51
  ### Step C5: 更新 requirements.md
50
52
 
51
53
  - 在「需求版本」表中追加新版本行:
@@ -0,0 +1,11 @@
1
+ # $cm-prd 项目规则禁用 CM 时的确认
2
+
3
+ > 新建与变更模式在外部专家路由、调用 `cm-prd-entry.mjs` 准入、启动 JS 宿主之前执行本文件(实跑教训:aihot 的
4
+ > AGENTS.md 先后写过「只用 CM」和「不用 CM」,流程没有规定怎么处理)。本步只读,不读需求正文。
5
+
6
+ 1. 以代码项目根(Step 3 的判定,不是当前会话所在仓库)为准,读其 AGENTS.md 链、根目录 `CLAUDE.md`、`.claude/CLAUDE.md`
7
+ 和 `.claude/rules/` 下全部文件(本步不按相关性筛选),只找不用 CM 工作流的条款;没有 → 照常继续准入。
8
+ 2. 按规则自身声明的优先级(如「本节优先」「已被覆盖」)判断该条款是否仍生效;已被后续条款明确覆盖 → 照常继续。
9
+ 3. 仍生效、无法判断,或条款只限某类需求而本步不读正文无法确定是否适用 → 在对话里问用户一次,问题里引用条款的文件与行号,等真实答复;不调用准入。
10
+ 4. 用户明确同意运行 cm-prd,或说明本次需求不在条款限定范围内 → 继续准入;
11
+ 其余回复 → 不启动准入与宿主、不写 specs,说明原因后结束。
@@ -9,7 +9,8 @@
9
9
  `coding-style.md`、`testing.md`、`security.md` 和本需求已命中层的规则。需求源、项目
10
10
  描述文件和两层目录概览已经由 Step 1–3 读取,不重复打开。
11
11
 
12
- 先读项目指定地图或存在的 `docs/codebase-context/00-index.md`;再用需求中的页面名、路由、可见
12
+ 地图读取顺序以主 `SKILL.md` Step 4 的 B1 为准:先看代码项目根 CLAUDE.md 的「业务地图」字段,
13
+ 再按字段结果读项目指定地图或存在的 `docs/codebase-context/00-index.md`;然后用需求中的页面名、路由、可见
13
14
  文案、接口名、类型名和业务术语做代码搜索,定位候选模块、直接调用方与最近测试。
14
15
  搜索只用于定位,不把命中源码或需求正文写入运行日志。
15
16
 
@@ -69,13 +69,13 @@ result必须填真实结果,不留空对象。不同kind的合同见当前请
69
69
 
70
70
  | kind | 当前宿主执行 |
71
71
  | --- | --- |
72
- | prd_analyze | 按原Step 0–5分析与提问;保留用户用例、形态、平台与范围约束。question交给用户,不能代答。 |
72
+ | prd_analyze | 按原Step 0–5.5分析,并按requirement-grilling.md逐轮追问(每轮一个question,阻断项答完才回analyzed);保留用户用例、形态、平台与范围约束。question交给用户,不能代答。 |
73
73
  | prd_materials | 用已可用、已授权的实际工具处理材料;HTML交互只走Codex内置浏览器,PDF逐页覆盖,不伪造截图/页数/证据。能力不足返回blocked。 |
74
74
  | prd_generate | 按payload.phase执行:design只做Step6–9的需求/设计;tasks_after_design默认保留acceptedDesign原feature及正文,每个feature只回tasks.md和适用的test-cases.json,省略的requirements.md/design.md由宿主按原字节补回(64KB只算新回的文档;照旧回全文也须逐字一致);整稿自检失败时按下文登记同清单修订;full_draft走原Step6–10。保留UI基准与原粒度约束,只回正文不写文件。 |
75
75
  | prd_self_check | 读取spec-self-check.md与相关真实代码/地图/用例,逐项返回有依据的结果;机械通过不等于语义通过,不能用自检冒充独立审查。 |
76
76
  | prd_review | 按原9.5或10.6,使用实际授权的新上下文独立审查,核对作者与审查者上下文标识、材料摘要并原样回传。无法独立时只允许预先选定的显式self-degraded;开始后不换模式或补审。 |
77
77
  | prd_correct | 对原findings提出完整原路径清单与逐项采纳/升级决定;不自行写规格,不新增范围/勾任务/再次review。 |
78
- | prd_summary | 按原Step11核对交付形态、开放问题、风险、平台/UI基准及原9.5风险信号;未知明确写待核对,不能推断人工批准。 |
78
+ | prd_summary | 按原Step11核对交付形态、开放问题(先写requirement-grilling G4的倒推结果)、风险、平台/UI基准及原9.5风险信号;未知明确写待核对,不能推断人工批准。 |
79
79
 
80
80
  读取角色Skill不代表配置模型已调用;非当前runtime角色路由被JS阻断时如实报告。
81
81
  JS拥有日志、草稿保存、修订写入、自检轮次、审查记录、处置和审批位写入;宿主不再运行
@@ -0,0 +1,116 @@
1
+ # $cm-prd 需求倒推与逐轮追问
2
+
3
+ > 新建模式 Step 5.5 与变更模式 C4 之后读取本文件。七项倒推清单的内容以
4
+ > `../../cm-product-manager/SKILL.md` 第 2 节为准;本文件规定执行顺序、提问格式、停止条件与交接。
5
+
6
+ 目标:不只核对需求文档写了什么,还要对照项目现有业务找出文档漏掉的范围,把缺口和产品逐轮
7
+ 对清后再生成规格(实跑反馈:产品文档常范围不明或直接漏项,开发中途才暴露)。
8
+
9
+ ## G1 合并问题清单(每次都跑)
10
+
11
+ 1. **证据来源**:新建模式复用 Step 4 已加载的地图与代码,变更模式复用 C2–C4 读过的规格与代码;
12
+ 不够时按 `context-scope.md` 补读相关代码与直接调用方,不为追问另做全量扫描。
13
+ 2. **倒推七项**:对需求涉及的每条业务线路逐项过七项清单。
14
+ 3. **原必问项**:同时检查原 Step 5.5 的触发条件——功能点模糊或有歧义、实现方案差异大、
15
+ 缺关键信息(目标平台、兼容性、第三方服务选型)、业务逻辑矛盾或不完整、涉及权限/支付/隐私/删除等敏感操作;
16
+ 以及歧义五问、`cm-finance-expert` 合规问题、greenfield G1;微信小程序平台就绪中会改变功能可行性或范围的项
17
+ (只影响后续提审的材料按主 Skill Step 5.5 记为发布待决,不进清单);宿主材料阶段用户未逐项答复的原型死区(不许静默丢弃)。
18
+ 以上全部进清单,影响级按第 4 条的表判定。
19
+ 4. 每个缺口记录:
20
+
21
+ | 字段 | 写法 |
22
+ | ---- | ---- |
23
+ | 检查项 | 七项之一,或「范围」「成功判据」「技术选型」「合规」「平台就绪」「原型死区」 |
24
+ | 出处 | 需求文档 `文件:行`、代码 `路径:行`、地图章节名 |
25
+ | 影响级 | `阻断` 或 `默认`,判定见下表 |
26
+ | 推荐答案 | 依据现有业务给出的建议;没把握时写「无推荐,需产品决定」 |
27
+
28
+ | 影响级 | 条件 |
29
+ | ---- | ---- |
30
+ | `阻断` | 决定功能做不做或主流程怎么走;改变交付形态、数据结构或存量数据;涉及权限、支付、隐私、删除;实现方案差异大、缺关键信息、业务逻辑矛盾或不完整 |
31
+ | `默认` | 只影响上限值、文案、排序、展示细节等,且有合理默认 |
32
+
33
+ 5. 能从代码、地图或文档查到的事实自己查清,写进出处,不问用户。
34
+ 6. 地图没有对应线路(盲区)时,用代码定向搜索作出处;本阶段只读,盲区留给 B5 在拆分前补扫。
35
+ 7. 只有确认为全新项目(GREENFIELD)时才只核对文档内部缺口;存量项目缺地图时照常查代码。
36
+ 8. 当前为 `CONTEXT_SCOPE=targeted` 且发现改变实现范围的缺口 → 按 `context-scope.md` 第 4 节升级。
37
+ 9. 合并清单为空 → 不提问,直接进入 G4,结论记「倒推核对 7 项无缺口」。
38
+
39
+ ## G2 设计树与前沿
40
+
41
+ 问题按依赖排序:一题的答案会改变另一题的问法或是否需要问,后者就依赖前者。
42
+ 「前沿」是依赖的题都已有答案的问题,本轮只从前沿取题。互相依赖(成环)的未答题彼此不算前置,
43
+ 一起进入前沿;超过 5 题时按 G3 分到后续轮次。参考层次(同层内无依赖的题可同轮问,
44
+ 下层题不依赖未决上层题时也可提前):
45
+
46
+ 1. 范围与交付形态(本期做什么、明确不做什么)
47
+ 2. 角色与权限
48
+ 3. 状态流转与数据(含存量数据处理)
49
+ 4. 相邻线路、入口、通知、报表与导出
50
+ 5. 异常、空态与文案
51
+
52
+ 默认清单同样只列前沿内的 `默认` 项;依赖未决题的默认项留到之后的轮次。
53
+ 某个 `阻断` 题依赖的 `默认` 项按 `阻断` 处理。
54
+ 上游答案使某题不再适用时(如本期不做导出,导出权限题随之失效),该题记「不适用:{依据的答案}」移出清单,
55
+ 不再计入未答 `阻断` 题,并在「范围与覆盖核对」中保留这条记录。
56
+ 用户改答某题时,所有依赖它的已答题和「不适用」题都恢复为未答,按新答案重新确认。
57
+ 「不适用」的题算作已解决,其他题对它的依赖随之解除。
58
+ 兜底:仍有未答 `阻断` 题而前沿为空时,这些题直接进入前沿(按 G3 分轮),不得因此卡住或放行。
59
+
60
+ ## G3 每轮格式
61
+
62
+ - 每轮最多 5 题,`阻断` 级优先;每题写清出处与推荐答案。
63
+ - `默认` 级不单独出题,汇成本轮末尾的「默认清单」。
64
+ - 每轮文字能原样转发给产品:不依赖前文,不写内部步骤名。第 2 轮起开头用「已记下:」复述上一轮已采纳的结论。
65
+ - 题号带轮次:第 N 轮写 `RN-Q1`、`RN-D1`,按轮次对应。回复不带轮次时:此前各轮已无未答题 → 指最近一轮;
66
+ 否则先问清指哪一轮再记录。
67
+ - 原型死区问题由宿主在分析前一次性发出(`materials` 阶段的既有行为),不受 5 题限制;
68
+ 用户逐项答复的死区作为已知事实不再重问,未答复的按 G1 第 3 条进入合并清单。
69
+
70
+ ```text
71
+ ❓ 第 {N} 轮需求确认(最多 5 题)
72
+
73
+ R{N}-Q1 【{检查项}】{问题}
74
+ 出处:{文档/代码/地图位置}
75
+ 推荐:{推荐答案}
76
+
77
+ R{N}-Q2 ...
78
+
79
+ 默认清单(需明确回复,未提到的默认项不算同意):
80
+ R{N}-D1 {默认做法}(出处:{位置})
81
+
82
+ 回复方式:「R{N} 全部按推荐」采纳本轮有推荐的题与默认清单;或逐题写「R{N}-Q1 是」「R{N}-Q2 否:{你的答案}」,
83
+ 默认项写「R{N} 默认全同意」或「R{N}-D1 是」「R{N}-D1 否:{你的答案}」;
84
+ 标「无推荐」的题请直接写答案,如「R{N}-Q3:{你的答案}」。
85
+ ```
86
+
87
+ - 本轮只有一题且该题有推荐答案时,回「是」即采纳该题推荐。本轮不止一题时,单回「是」不算任何一题的答案,
88
+ 下一条消息先问清指哪几题。
89
+ - 「全部按推荐」「默认全同意」同样按上条规则对应轮次。「全部按推荐」采纳写了推荐答案的题和默认清单,
90
+ 「默认全同意」只采纳默认清单;「无推荐,需产品决定」的题必须逐题回答。
91
+ - 未提到的题和默认项都保持未答,下一轮是否再问由 G2 重算前沿决定,不按沉默视为同意。
92
+
93
+ ## G4 停止、交接与记录
94
+
95
+ - **停止**:每次答复后重算前沿,前沿为空且全部 `阻断` 级已有用户答案即停止;
96
+ `阻断` 级答完后新解锁的 `默认` 项继续出默认清单,
97
+ 直到前沿为空(用户已说「先这样」时剩余默认项记为「留待人审」)。
98
+ 用户说「先这样」时,`默认` 级未答题转为「留待人审」;仍有 `阻断` 级未答题时只继续提问这些题,
99
+ 不进入生成。超时、沉默或推荐答案都不能代替用户答案。
100
+ - **答案矛盾**:每次答复后核对已答内容与需求、现有业务之间有无矛盾;有矛盾时把它作为新的 `阻断` 题
101
+ (检查项「业务矛盾」,出处写冲突的两条答案),解决前不满足停止条件。
102
+ - **宿主交接**:
103
+ - 每轮返回 `{status:"question", question:"<整轮文本>"}`;用户答复经 advance 回来后重算前沿。
104
+ - 满足「停止」条件才返回 `analyzed`(任何情况下都要求全部 `阻断` 级已有用户答案),
105
+ `openQuestions` 必须为 `[]`(非空会让宿主停在等待)。
106
+ - 逐条决定写进 `analyzed.summary` 的「范围与覆盖核对」段:本期做、明确不做、
107
+ 追问补齐项(检查项、出处、问题、答案或「默认」)、留待人审项。
108
+ - **写入规格**:新建模式 Step 8、变更模式 C5 读取该段,写入 `requirements.md` 的
109
+ 「范围与覆盖核对」一节,并同步受影响的功能需求与验收标准;留待人审项同时列入「开放问题」。
110
+ - **摘要卡**:Step 11 的 `openQuestions` 字符串先写一句倒推结果:
111
+ `倒推核对:{N} 项缺口,已答 {M},留待人审 {K}` 或 `倒推核对 7 项无缺口`。
112
+
113
+ ## 变更模式
114
+
115
+ C4 影响分析之后执行 G1–G4,倒推重点放在本次变更对已有线路、已完成任务和存量数据的影响。
116
+ C5 更新「范围与覆盖核对」时保留历史条目,新条目后标注本次需求版本(如 `[v2]`)。
@@ -42,7 +42,19 @@ description: 产品经理 Skill,负责需求分析、用户故事与验收标
42
42
  4. 异常怎么办?失败 / 超时 / 冲突时用户看到什么?
43
43
  5. 有没有敏感操作?支付 / 删除 / 隐私相关 → 必须人工确认
44
44
 
45
- **克制原则**:只列真正无法合理推断的问题;可以合理默认的写成"默认 X,如不符请指出"——不做无限追问式的确认(SuperPowers 的教训)。
45
+ **七项倒推清单**(对照现有业务找文档漏掉的范围;存量项目以业务地图和代码为出处,全新项目只查文档内部):
46
+
47
+ | 检查项 | 倒推什么 |
48
+ | ---- | ---- |
49
+ | 角色与权限 | 现有角色在新功能里各能做什么,谁不能做 |
50
+ | 状态流转 | 新增或改动的状态与现有状态机怎么衔接,有无到不了或出不去的状态 |
51
+ | 增删改查成对 | 只写了新增时,修改、删除、查看、撤销是否本期要做 |
52
+ | 存量数据 | 已有数据怎么迁移、补默认值或兼容展示 |
53
+ | 相邻线路 | 业务地图里共用同一数据或模块的其他线路是否受牵连 |
54
+ | 入口与通知 | 从哪里进入,是否需要提醒、消息或回到原处 |
55
+ | 报表与导出 | 现有统计、导出、搜索是否要纳入新数据 |
56
+
57
+ **克制原则**:只列真正无法合理推断的问题;可以合理默认的写成"默认 X,如不符请指出"——不做无限追问式的确认(SuperPowers 的教训)。cm-prd 中的分级、分轮与默认清单格式见 `../cm-prd/references/requirement-grilling.md`。
46
58
 
47
59
  ### 3. 拆分与优先级建议(服务 Step 6-7)
48
60