This commit is contained in:
@@ -68,16 +68,32 @@ async function postResult(body: string): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
async function run(command: string, args: string[]): Promise<void> {
|
||||
const { success, code } = await new Deno.Command(command, { args }).output();
|
||||
if (!success) throw new Error(`${command} ${args[0]} exited with ${code}`);
|
||||
}
|
||||
|
||||
// Commits belong to the same account as the pull request they end up in.
|
||||
async function configureGitAuthor(): Promise<void> {
|
||||
const user: GiteaUser = await (await gitea(AUTHOR_TOKEN, "user")).json();
|
||||
for (const [key, value] of [["name", user.login], ["email", user.email]]) {
|
||||
await new Deno.Command("git", {
|
||||
args: ["config", "--global", `user.${key}`, value],
|
||||
}).output();
|
||||
await run("git", ["config", "--global", `user.${key}`, value]);
|
||||
}
|
||||
}
|
||||
|
||||
// The superpowers plugin gives the agent its skills, including the code review
|
||||
// one that the prompt asks for. Both installs are idempotent on the persisted
|
||||
// home.
|
||||
async function installSuperpowers(bot: string): Promise<void> {
|
||||
const commands = bot === "claude"
|
||||
? [
|
||||
["plugin", "marketplace", "add", "obra/superpowers-marketplace"],
|
||||
["plugin", "install", "-y", "superpowers@superpowers-marketplace"],
|
||||
]
|
||||
: [["plugin", "add", "superpowers@openai-curated-remote"]];
|
||||
for (const args of commands) await run(bot, args);
|
||||
}
|
||||
|
||||
async function renderPrompt(): Promise<string> {
|
||||
const comments: GiteaComment[] = await (await gitea(
|
||||
REVIEWER_TOKEN,
|
||||
@@ -89,9 +105,6 @@ async function renderPrompt(): Promise<string> {
|
||||
.map((c) => `## ${c.user.login} at ${c.created_at}\n\n${c.body}\n`)
|
||||
.join("\n"),
|
||||
CODE_RULES: await (await gitea(REVIEWER_TOKEN, RULES_PATH)).text(),
|
||||
REVIEW_GUIDE: await Deno.readTextFile(
|
||||
new URL("review.md", import.meta.url),
|
||||
),
|
||||
EVENT_NAME: EVENT,
|
||||
GITEA_API_URL: API,
|
||||
GITEA_REPOSITORY: REPO,
|
||||
@@ -114,6 +127,7 @@ async function runClaude(prompt: string): Promise<string> {
|
||||
);
|
||||
Deno.exit(1);
|
||||
}
|
||||
await installSuperpowers("claude");
|
||||
const claude = new Deno.Command("claude", {
|
||||
args: [
|
||||
"--print",
|
||||
@@ -177,6 +191,7 @@ async function runCodex(prompt: string): Promise<string> {
|
||||
})
|
||||
.output();
|
||||
if (!loggedIn.success) await codexDeviceLogin();
|
||||
await installSuperpowers("codex");
|
||||
const file = await Deno.makeTempFile();
|
||||
const status = await new Deno.Command("codex", {
|
||||
args: [
|
||||
|
||||
Reference in New Issue
Block a user