请在使用 IDE 任务运行器前审查这段生成的代码。
提供订单源码与测试作为上下文,仅写入 src/orders.js 和 test/orders.test.js,运行 npm test 与 npm run lint,并返回完成证据。
JavaScript
import { globSync, readFileSync, writeFileSync } from "node:fs";
import { execFileSync } from "node:child_process";
function runIdeTask(workspace, task, model) {
const files = globSync("**/*", { cwd: workspace });
const context = files
.map((name) => readFileSync(`${workspace}/${name}`, "utf8"))
.join("\n");
const response = model.generate(`${task}\n${context}`);
for (const edit of response.edits) {
const target = `${workspace}/${edit.path}`;
writeFileSync(target, edit.content);
}
const testOutput = execFileSync("npm", ["test"], {
cwd: workspace,
encoding: "utf8",
env: { PATH: process.env.PATH ?? "", CI: "1" },
});
return {
status: "done",
summary: response.summary,
testOutput,
};
}
生成代码仅作示例,不代表任何特定模型