fix: distinguish read-only evidence from file delivery requirements
This commit is contained in:
@@ -20,11 +20,22 @@ export function taskContract(task, lookup = () => null) {
|
||||
const goal = original.contract?.goal ?? original.goal;
|
||||
const skip = /无需(?:任何)?测试|不(?:需要|用|要)(?:进行|做|运行)?测试|\b(?:no tests?(?: needed|required)?|without (?:running )?tests?)\b/i.test(goal);
|
||||
const required = !skip && /(?:运行|执行|通过|修复|补充|添加).{0,12}(?:测试|工程检查)|\b(?:run|pass|fix|add)\b.{0,24}\b(?:tests?|checks?)\b/i.test(goal);
|
||||
const file = /(?:创建|新建|保存|写入).{0,60}(?:文件|HTML|[\w-]+\.(?:html?|txt|svg|md)\b)|\bcreate\b.{0,60}\b(?:file|html|svg)\b/i.test(goal);
|
||||
const file = hasFileDeliveryRequest(goal);
|
||||
return { schemaVersion: 1, goal, kind: file ? 'file' : 'general', checks: skip ? 'skip' : required ? 'required' : 'unspecified',
|
||||
...(original.id !== task.id ? { inheritedFromTaskId: original.id } : {}) };
|
||||
}
|
||||
|
||||
function hasFileDeliveryRequest(goal) {
|
||||
// Do not connect a past-tense modifier ("保存的原工件") to a later
|
||||
// prohibition ("不修改文件") and turn a read into a delivery requirement.
|
||||
const clauses = String(goal).split(/[,,;;。\n]|而是|但是|\bbut\b/i);
|
||||
const action = /(?:创建|新建|保存|写入)(?!的|过的|好的|后的|下来的).{0,60}?(?:文件|HTML|[\w-]+\.(?:html?|txt|svg|md)\b)|\bcreate\b.{0,60}?\b(?:file|html|svg)\b/ig;
|
||||
return clauses.some(clause => [...clause.matchAll(action)].some(match => {
|
||||
const prefix = clause.slice(0, match.index);
|
||||
return !/(?:不要|无需|不需要|不用|禁止|不得|不必|勿|不允许|不能|不再|避免|不)(?:\s|再|去|进行|执行|直接|自动|擅自|你|任何)*(?:.{0,24}(?:或|和|以及)\s*)?$|\b(?:do not|don't|without|never|no need to|must not|cannot|can't)\b.{0,40}$/i.test(prefix);
|
||||
}));
|
||||
}
|
||||
|
||||
export function updateTaskContract(task, instruction) {
|
||||
const current = taskContract(task);
|
||||
// Only an explicit new user instruction changes the check policy.
|
||||
|
||||
Reference in New Issue
Block a user