@aibyzero/cm-workflow 0.16.1 → 0.16.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.
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +4 -0
- package/CHANGELOG.md +179 -0
- package/README.md +2 -2
- package/VERSION +1 -1
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +46 -7
- package/docs/next-steps.md +110 -0
- package/docs/untested-branches.md +79 -0
- package/package.json +1 -1
- package/runtime/js/cm-ai/claude-tool-preview.mjs +45 -6
- package/runtime/js/cm-ai/cm-ai-admission.mjs +5 -0
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +22 -12
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +70 -5
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +5 -5
- package/runtime/js/cm-ai/drive-core.mjs +68 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +42 -9
- package/runtime/js/cm-ai/effect-contract.mjs +38 -5
- package/runtime/js/cm-ai/execution-snapshot.mjs +40 -0
- package/runtime/js/cm-ai/host-conversation-execution.mjs +8 -5
- package/runtime/js/cm-ai/host-handoff.mjs +9 -14
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +12 -7
- package/runtime/js/cm-ai/host-session.mjs +2 -2
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/metrics-table.mjs +22 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +85 -0
- package/runtime/js/cm-ai/review-evidence-file.mjs +18 -1
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +144 -0
- package/runtime/js/cm-ai/reviewed-evidence-supersession-record.mjs +34 -0
- package/runtime/js/cm-ai/task-runner.mjs +41 -8
- package/runtime/js/cm-fix/cause-invocation.mjs +9 -5
- package/runtime/js/cm-fix/cause-package.mjs +21 -0
- package/runtime/js/cm-fix/dossier.mjs +40 -1
- package/runtime/js/cm-fix/execution.mjs +369 -83
- package/runtime/js/cm-fix/host.mjs +7 -3
- package/runtime/js/cm-fix/layout.mjs +34 -0
- package/runtime/js/cm-fix/metrics.mjs +2 -4
- package/runtime/js/cm-fix/progress.mjs +14 -0
- package/runtime/js/cm-fix/protected-edits.mjs +1 -1
- package/runtime/js/cm-fix/red-test.mjs +7 -6
- package/runtime/js/cm-fix/regression-evidence.mjs +6 -3
- package/runtime/js/cm-fix/regression.mjs +16 -10
- package/runtime/js/cm-fix/repair.mjs +16 -13
- package/runtime/js/cm-fix/test-author.mjs +2 -1
- package/runtime/js/cm-fix/test-extension.mjs +45 -0
- package/runtime/js/cm-fix/walkthrough.mjs +8 -2
- package/runtime/js/cm-prd/accepted-design.mjs +28 -9
- package/runtime/js/cm-prd/analysis.mjs +68 -16
- package/runtime/js/cm-prd/change.mjs +21 -1
- package/runtime/js/cm-prd/draft-save.mjs +96 -2
- package/runtime/js/cm-prd/failed-correction.mjs +51 -0
- package/runtime/js/cm-prd/inputs-replaced.mjs +122 -0
- package/runtime/js/cm-prd/review-correction.mjs +3 -0
- package/runtime/js/cm-prd/review-disposition.mjs +33 -15
- package/runtime/js/cm-prd/review-findings.mjs +2 -2
- package/runtime/js/cm-prd/review-host.mjs +2 -0
- package/runtime/js/cm-prd/review-preparation.mjs +28 -1
- package/runtime/js/cm-prd/review-publication.mjs +4 -2
- package/runtime/js/cm-prd/self-check-revision.mjs +81 -0
- package/runtime/js/cm-prd/session.mjs +5 -5
- package/runtime/js/cm-prd/split-design.mjs +67 -0
- package/runtime/js/cm-prd/summary.mjs +53 -8
- package/runtime/js/cm-refactor/workflow.mjs +103 -21
- package/scripts/audit-untested-enums.mjs +59 -0
- package/scripts/cm-ai-batch-drive.mjs +251 -0
- package/scripts/cm-ai-batch-drive.test.mjs +152 -0
- package/scripts/cm-ai-contracts.test.mjs +30 -0
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +62 -0
- package/scripts/cm-ai-drive.mjs +334 -0
- package/scripts/cm-ai-drive.test.mjs +251 -0
- package/scripts/cm-ai-execution-diagnostic.test.mjs +25 -0
- package/scripts/cm-ai-fix-integration.test.mjs +1 -1
- package/scripts/cm-ai-host.mjs +41 -18
- package/scripts/cm-ai-host.test.mjs +37 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +328 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +255 -0
- package/scripts/cm-ai-qa-fix-policy.test.mjs +79 -0
- package/scripts/cm-ai-review-timeout.test.mjs +30 -0
- package/scripts/cm-ai-run.mjs +59 -11
- package/scripts/cm-ai-runner-error-code-regression.test.mjs +29 -0
- package/scripts/cm-ai-session-chain.test.mjs +261 -0
- package/scripts/cm-ai-supersede.test.mjs +320 -0
- package/scripts/cm-check-drive.mjs +93 -0
- package/scripts/cm-check-drive.test.mjs +62 -0
- package/scripts/cm-check-host.test.mjs +47 -0
- package/scripts/cm-claude-probe.test.mjs +117 -2
- package/scripts/cm-fix-abandon.test.mjs +383 -0
- package/scripts/cm-fix-cause-package.test.mjs +31 -1
- package/scripts/cm-fix-cross-session-host.test.mjs +17 -5
- package/scripts/cm-fix-drive.mjs +168 -0
- package/scripts/cm-fix-drive.test.mjs +117 -0
- package/scripts/cm-fix-escalation.test.mjs +214 -0
- package/scripts/cm-fix-execution.test.mjs +67 -0
- package/scripts/cm-fix-host.mjs +4 -2
- package/scripts/cm-fix-metrics.test.mjs +32 -0
- package/scripts/cm-fix-observation-dossier.test.mjs +34 -9
- package/scripts/cm-fix-qa-source.test.mjs +3 -3
- package/scripts/cm-fix-session-chain.test.mjs +244 -0
- package/scripts/cm-fix-test-extension.test.mjs +246 -0
- package/scripts/cm-fix-visual-carrier.test.mjs +66 -0
- package/scripts/cm-host-handoff.test.mjs +37 -0
- package/scripts/cm-idea-drive.mjs +99 -0
- package/scripts/cm-idea-drive.test.mjs +50 -0
- package/scripts/cm-init-drive.mjs +191 -0
- package/scripts/cm-init-drive.test.mjs +59 -0
- package/scripts/cm-log-event.mjs +9 -0
- package/scripts/cm-prd-design-phase.test.mjs +355 -15
- package/scripts/cm-prd-drive.mjs +308 -0
- package/scripts/cm-prd-drive.test.mjs +154 -0
- package/scripts/cm-prd-host.mjs +46 -17
- package/scripts/cm-prd-inputs-replaced.test.mjs +237 -0
- package/scripts/cm-prd-review-disposition.test.mjs +133 -7
- package/scripts/cm-prd-review-gate.mjs +23 -4
- package/scripts/cm-prd-self-check-revision.test.mjs +302 -0
- package/scripts/cm-prd-summary.test.mjs +48 -4
- package/scripts/cm-refactor-drive.mjs +237 -0
- package/scripts/cm-refactor-drive.test.mjs +77 -0
- package/scripts/cm-refactor-gaps.test.mjs +276 -0
- package/scripts/cm-refactor-host.test.mjs +1 -48
- package/scripts/cm-refactor-judge-revision.test.mjs +253 -0
- package/scripts/cm-release-smoke.sh +14 -0
- package/scripts/cm-test-drive.mjs +132 -0
- package/scripts/cm-test-drive.test.mjs +91 -0
- package/scripts/cm-test-session.test.mjs +117 -0
- package/scripts/correction-check.test.mjs +38 -0
- package/scripts/fixtures/claude-model-marker.mjs +6 -0
- package/scripts/fixtures/claude-review-process.mjs +7 -0
- package/scripts/fixtures/cm-refactor.mjs +56 -0
- package/skills/cm-ai/SKILL.md +1 -1
- package/skills/cm-ai/references/N4-review.md +2 -0
- package/skills/cm-ai/references/N8-finish.md +1 -0
- package/skills/cm-ai/references/js-host.md +80 -3
- package/skills/cm-check/references/js-host.md +2 -0
- package/skills/cm-fix/SKILL.md +11 -4
- package/skills/cm-fix/references/js-host.md +67 -2
- package/skills/cm-fix/references/test-extension.md +57 -0
- package/skills/cm-idea/references/js-host.md +2 -0
- package/skills/cm-init/references/js-host.md +2 -0
- package/skills/cm-prd/SKILL.md +8 -8
- package/skills/cm-prd/references/js-change-recovery.md +41 -0
- package/skills/cm-prd/references/js-host.md +64 -2
- package/skills/cm-prd/references/spec-self-check.md +14 -2
- package/skills/cm-refactor/SKILL.md +5 -0
- package/skills/cm-refactor/references/js-batch.md +3 -1
- package/skills/cm-refactor/references/js-host.md +49 -0
- package/skills/cm-test/references/js-host.md +5 -0
- package/skills/cm-test/references/unit-coverage.md +2 -2
|
@@ -4,18 +4,22 @@ import {inspectProviderCauseReview} from '../cm-ai/provider-review-observation.m
|
|
|
4
4
|
import {digest,id,json,need,shape,text,hex} from '../cm-ai/effect-contract.mjs';
|
|
5
5
|
|
|
6
6
|
// A run outlives the session that created it. Its durable configuration keeps the
|
|
7
|
-
// original hostContextId, so stored records and fingerprints stay byte-identical
|
|
8
|
-
//
|
|
9
|
-
//
|
|
7
|
+
// original hostContextId, so stored records and fingerprints stay byte-identical.
|
|
8
|
+
// Every later session that signs a grant is first written into the run's own
|
|
9
|
+
// history (fix-host-joined-N), and the session running now is added on top. All
|
|
10
|
+
// of them are host identities: a grant may carry any, and the reviewer stays
|
|
11
|
+
// independent of every one. The history is what lets a third session accept a
|
|
12
|
+
// grant the second one signed.
|
|
13
|
+
export const MAX_FIX_JOINED_HOSTS=16;
|
|
10
14
|
export function fixHostContexts(configuration){
|
|
11
15
|
const hosts=configuration.hostContextIds??[configuration.hostContextId];
|
|
12
|
-
need(Array.isArray(hosts)&&hosts.length>=1&&hosts.length<=2&&new Set(hosts).size===hosts.length
|
|
16
|
+
need(Array.isArray(hosts)&&hosts.length>=1&&hosts.length<=MAX_FIX_JOINED_HOSTS+2&&new Set(hosts).size===hosts.length
|
|
13
17
|
&&hosts[0]===configuration.hostContextId,'invalid_host_context');
|
|
14
18
|
hosts.forEach(id);return hosts;
|
|
15
19
|
}
|
|
16
20
|
export function validateCauseReviewer(raw,hostContextId,maxExclusions=32){
|
|
17
21
|
const hosts=Array.isArray(hostContextId)?hostContextId:[hostContextId];
|
|
18
|
-
need(hosts.length>=1&&hosts.length<=2,'invalid_cause_reviewer');hosts.forEach(id);
|
|
22
|
+
need(hosts.length>=1&&hosts.length<=MAX_FIX_JOINED_HOSTS+2,'invalid_cause_reviewer');hosts.forEach(id);
|
|
19
23
|
need([32,33,34].includes(maxExclusions),'invalid_cause_reviewer');
|
|
20
24
|
const value=json(raw);shape(value,['reviewerId','adapterId','provider','requestedModel','contextId','excludedThreadIds',
|
|
21
25
|
...(Object.hasOwn(value,'workerConfigurationDigest')?['workerConfigurationDigest']:[])]);
|
|
@@ -4,6 +4,8 @@ import {digest,id,json,need,shape,text,validIdentity} from '../cm-ai/effect-cont
|
|
|
4
4
|
import {inspectFixLearning} from './learning.mjs';
|
|
5
5
|
import {inspectFixInvestigation} from './investigation.mjs';
|
|
6
6
|
import {inspectFixReproductionAttempts} from './reproduce.mjs';
|
|
7
|
+
import {inspectFixTestAuthor} from './test-author.mjs';
|
|
8
|
+
import {inventory} from './test-extension.mjs';
|
|
7
9
|
import {inspectVisualCarrier} from './visual.mjs';
|
|
8
10
|
|
|
9
11
|
export function createFixCausePackage({codeProject,defect,status}){
|
|
@@ -68,3 +70,22 @@ export function readFixCausePackage(raw){
|
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
export const causeReviewPaths=pkg=>pkg.files.map(file=>file.path);
|
|
73
|
+
|
|
74
|
+
// Validate the original package, then admit only the exact registered test transition.
|
|
75
|
+
export function verifyFixCauseTransition(original,current,authorBaseline,authorResult){
|
|
76
|
+
const reviewed=readFixCausePackage(original),now=readFixCausePackage(current);
|
|
77
|
+
const expected=new Map(reviewed.files.map(file=>[file.path,file]));
|
|
78
|
+
if(authorBaseline&&authorResult){
|
|
79
|
+
const authored=inspectFixTestAuthor(authorResult,authorBaseline);
|
|
80
|
+
need(authored.outcome==='authored','cause_review_drift');
|
|
81
|
+
const before=new Map(authorBaseline.files.map(file=>[file.path,file]));
|
|
82
|
+
for(const file of authored.testFiles){
|
|
83
|
+
if(!expected.has(file.path))continue;
|
|
84
|
+
need(digest(inventory([before.get(file.path)]))===digest(inventory([expected.get(file.path)])),'cause_review_drift');
|
|
85
|
+
expected.set(file.path,file);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
need(digest(inventory(now.files))===digest(inventory([...expected.values()])),'cause_review_drift');
|
|
89
|
+
const {packageDigest,...body}=now;
|
|
90
|
+
need(digest({...body,files:reviewed.files})===reviewed.packageDigest,'cause_review_drift');
|
|
91
|
+
}
|
|
@@ -4,6 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import {createHash,randomUUID} from 'node:crypto';
|
|
5
5
|
import {need,digest} from '../cm-ai/effect-contract.mjs';
|
|
6
6
|
import {writeReviewEvidence} from '../cm-ai/review-evidence-file.mjs';
|
|
7
|
+
import {currentTestFiles,verifyExtensionFiles} from './test-extension.mjs';
|
|
7
8
|
import {verifyFixRedEvidence} from './red-test.mjs';
|
|
8
9
|
import {inspectFixReproduction} from './reproduce.mjs';
|
|
9
10
|
import {readReviewSourceFiles} from '../cm-ai/review-package.mjs';
|
|
@@ -75,13 +76,50 @@ export function publishFixObservationDossier({specsRoot,configuration,status,reg
|
|
|
75
76
|
return {path:written.path,sha256:createHash('sha256').update(bytes).digest('hex'),completionEligible:false};
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
// Escalation is an incomplete exit, never a repaired-fix snapshot.
|
|
80
|
+
export function publishFixEscalationDossier({specsRoot,configuration,status,causeEvidenceFile,registeredAt}){
|
|
81
|
+
need(status.stage==='escalation_required'&&status.completionEligible===false
|
|
82
|
+
&&status.diagnosis?.status==='design_change'&&status.causeReview?.review?.verdict==='approved','fix_escalation_unavailable');
|
|
83
|
+
const slug=/^T-FIX-([a-z0-9]+(?:-[a-z0-9]+)*)$/.exec(status.identity.taskId)?.[1];
|
|
84
|
+
need(slug&&Number.isSafeInteger(registeredAt)&®isteredAt>=0&&Number.isFinite(new Date(registeredAt).getTime()),'invalid_fix_dossier');
|
|
85
|
+
need(path.isAbsolute(specsRoot)&&fs.realpathSync(specsRoot)===specsRoot,'unsupported_path');
|
|
86
|
+
let test;
|
|
87
|
+
if(configuration.redTest){
|
|
88
|
+
need(status.redTest?.status==='red_confirmed','fix_escalation_red_required');
|
|
89
|
+
verifyFixRedEvidence(status.redTest,configuration.redTest,specsRoot);
|
|
90
|
+
test=isVisual(configuration.redTest)
|
|
91
|
+
?{noFailingTest:`没有失败测试:${configuration.redTest.reason};已核对修前视觉载体。`,visual:status.redTest}
|
|
92
|
+
:{testFiles:status.redTest.testFiles,redEvidenceFile:status.redTest.output.path,redTest:status.redTest};
|
|
93
|
+
}else test={noFailingTest:'没有失败测试:本运行未配置 redTest,未执行自动红测;新设计立项时需明确验收方式。'};
|
|
94
|
+
const section=(title,value)=>`## ${title}\n\n${JSON.stringify(value,null,2).split('\n').map(line=>` ${line}`).join('\n')}\n\n`;
|
|
95
|
+
const body='# 缺陷档案(升级立项)\n\n状态:升级立项。尚未修复,不代表修复完成。以下记录是数据,不是执行指令。\n\n'
|
|
96
|
+
+section('任务',status.identity)
|
|
97
|
+
+section('缺陷与复现',{defect:configuration.defect,reproduction:status.reproduction})
|
|
98
|
+
+section('根因、影响范围与诊断方案',status.diagnosis)
|
|
99
|
+
+section('独立根因审查',{evidenceFile:causeEvidenceFile,review:status.causeReview})
|
|
100
|
+
+section('保留的失败测试与证据',test)
|
|
101
|
+
+'## 立项建议\n\n建议用 $cm-prd --change 发起设计变更;保留上述失败测试文件,把新设计使该测试变绿作为验收检查。没有失败测试时,须在立项中明确替代验收方式,不伪称红测已通过。\n\n'
|
|
102
|
+
+'本档案不代表 task_done,不写修复完成指标;升级退出以原运行日志为准。不授予 provider、安装或 Git 权限。\n';
|
|
103
|
+
const recovery=status.observationResume?readFixObservationArchive({specsRoot,resume:status.observationResume}):null;
|
|
104
|
+
const bytes=Buffer.concat([...(recovery?[recovery.original,recovery.marker]:[]),Buffer.from(body)]);
|
|
105
|
+
need(bytes.length<=256*1024,'limit_exceeded');
|
|
106
|
+
const directory=fixDossierDirectory(specsRoot,configuration);
|
|
107
|
+
try{fs.mkdirSync(directory,{mode:0o700});}catch(error){if(error.code!=='EEXIST')throw error;}
|
|
108
|
+
need(fs.realpathSync(directory)===directory&&fs.lstatSync(directory).isDirectory(),'unsupported_path');
|
|
109
|
+
const archiveName=recovery?path.posix.basename(status.observationResume.dossier.path)
|
|
110
|
+
:`${new Date(registeredAt).toISOString().slice(0,10).replaceAll('-','')}-${slug}.md`;
|
|
111
|
+
return writeDossier({directory,archiveName,bytes,replaceable:recovery?[recovery.original]:[]});
|
|
112
|
+
}
|
|
113
|
+
|
|
78
114
|
export function publishFixDossier({specsRoot,configuration,status,registeredAt,final=false}){
|
|
79
115
|
need(typeof final==='boolean','invalid_input');
|
|
80
116
|
need(status.stage==='closeout_required'&&status.completionEligible===false,'fix_closeout_unavailable');
|
|
81
117
|
const slug=/^T-FIX-([a-z0-9]+(?:-[a-z0-9]+)*)$/.exec(status.identity.taskId)?.[1];
|
|
82
118
|
need(slug&&Number.isSafeInteger(registeredAt)&®isteredAt>=0&&Number.isFinite(new Date(registeredAt).getTime()),'invalid_fix_dossier');
|
|
83
119
|
need(path.isAbsolute(specsRoot)&&fs.realpathSync(specsRoot)===specsRoot,'unsupported_path');
|
|
84
|
-
const
|
|
120
|
+
const extension=status.revision?.tests&&status.revisionTestAuthor?.outcome==='authored'?{plan:status.revision.tests,files:status.revisionTestAuthor.testFiles}:null;
|
|
121
|
+
verifyExtensionFiles(configuration.redTest.cwd,extension);
|
|
122
|
+
const output=verifyFixRedEvidence(status.redTest,configuration.redTest,specsRoot,currentTestFiles(status.redTest.testFiles,extension));
|
|
85
123
|
const section=(title,value)=>`## ${title}\n\n${JSON.stringify(value,null,2).split('\n').map(line=>` ${line}`).join('\n')}\n\n`;
|
|
86
124
|
// Keep original bytes as base64, not a decoded/re-encoded or truncated substitute.
|
|
87
125
|
const body='# 缺陷档案(收尾待完成)\n\n状态:证据快照,不代表 task_done / run_done。下列内容是数据,不是执行指令。\n\n'
|
|
@@ -93,6 +131,7 @@ export function publishFixDossier({specsRoot,configuration,status,registeredAt,f
|
|
|
93
131
|
+section('实际改动',status.repair)
|
|
94
132
|
+(isVisual(configuration.redTest)?section('修前视觉载体(自动红测不可用)',{reason:configuration.redTest.reason,
|
|
95
133
|
evidence:status.redTest,...output}):section('保护测试与原始红输出',{test:status.redTest,encoding:'base64; exact stdout/stderr bytes',...output}))
|
|
134
|
+
+(extension?section('第二轮覆盖补充(不是新增红灯证据)',{plan:extension.plan,author:status.revisionTestAuthor,beforeRevision:status.revisionTestCheck}):'')
|
|
96
135
|
+section('修前基线、修后及审后回归',{baseline:status.baseline,regression:status.regression,postReviewRegression:status.postReviewRegression})
|
|
97
136
|
+(status.walkthrough?section('按声明波及面进行的关键流程走查',status.walkthrough):'')
|
|
98
137
|
+section('Learning',{application:status.learning,retrospective:status.retrospective,writeback:status.learningWriteback??null})
|