在这个生成式交付门决定智能体补丁能否交付前,对它进行审查。
运行一条或多条配置的测试命令且不经过 shell 解释;拒绝空命令列表;要求结构化的通过测试数量;以路径语义强制工作区范围;限制捕获输出,并返回可审计证据。
JavaScript
import { exec } from "node:child_process";
import { promisify } from "node:util";
const run = promisify(exec);
export async function gate(task) {
const results = [];
for (const command of task.commands) {
const { stdout, stderr } = await run(command, { cwd: task.cwd });
results.push({ command, stdout, stderr });
}
const passed = results.every((result) =>
result.stdout.includes("pass"));
const inScope = task.changedFiles.every((file) =>
file.startsWith(task.workspace));
return {
ok: passed && inScope,
evidence: results.map(({ command, stdout }) => ({ command, stdout })),
};
}
生成代码仅作示例,不代表任何特定模型