diff --git a/.pi/extensions/run_make_test.ts b/.pi/extensions/run_make_test.ts new file mode 100644 index 0000000..7983ba6 --- /dev/null +++ b/.pi/extensions/run_make_test.ts @@ -0,0 +1,37 @@ +import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; + +export default function (pi: ExtensionAPI) { + pi.on("session_start", async (_event, ctx) => { + try { + const { stdout, stderr, code } = await pi.exec("make", ["test"]); + const output = stdout + stderr; + + if (code === 0) { + ctx.ui.notify("make test passed", "info"); + } else { + ctx.ui.notify(`make test failed (exit ${code})`, "error"); + } + + // Also send the output as a message so it's visible in the session + pi.sendMessage({ + customType: "run-make-test", + content: [ + { + type: "text", + text: `Here's the result of running \`make test\`:\n\n\`\`\`\n${output}\`\`\``, + }, + ], + display: true, + }, { deliverAs: "followUp" }); + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + pi.sendMessage({ + customType: "run-make-test", + content: [ + { type: "text", text: `Error running make test: ${message}` }, + ], + display: true, + }, { deliverAs: "followUp" }); + } + }); +}