feat(hooks): the merge question says how the run was tested and how it is undone

This commit is contained in:
Kjell Tore Guttormsen 2026-11-02 21:23:24 +01:00
commit ec5b6483ec
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
10 changed files with 1371 additions and 6 deletions

View file

@ -779,13 +779,32 @@ if (approvals.length > 0) {
const unlogged = loggable.length > 0 && !recorded
? ' Note: this approval will not be logged (Voyage could not record the question).' : '';
const advisory = (warnings.length > 0 ? ` Advisory: ${warnings.map((w) => w.trim()).join(' ')}` : '') + unlogged;
process.stdout.write(JSON.stringify({
const answer = {
hookSpecificOutput: {
hookEventName: 'PreToolUse',
permissionDecision: 'ask',
permissionDecisionReason: askReason(approvals) + advisory,
},
}));
};
// BEGIN merge-evidence
// A merge into main also says how the run was tested and how it is undone,
// read from the evidence file /trekexecute Phase 8 wrote (hooks/lib/merge-evidence.mjs).
// The decision above is already 'ask'; this block only adds text to the
// reason, and a reader that fails to load or throws leaves a note, never a
// green line.
const merge = approvals.find((m) => m.cls === 'merge');
if (merge) {
let evidence;
try {
const { evidenceLines } = await import('../lib/merge-evidence.mjs');
evidence = ' ' + evidenceLines(merge.subject, merge.merge && merge.merge.args);
} catch {
evidence = ' (run evidence not loaded)';
}
answer.hookSpecificOutput.permissionDecisionReason += evidence;
}
// END merge-evidence
process.stdout.write(JSON.stringify(answer));
}
process.exit(0);