diff --git a/src/isolation.ts b/src/isolation.ts index 0563a93..04745b3 100644 --- a/src/isolation.ts +++ b/src/isolation.ts @@ -55,9 +55,7 @@ export async function killProfileProcesses(uid: number, attempt = 0): Promise { const at = `${sourcePath}[${index}]`; if (!isObject(entry)) { @@ -194,14 +192,15 @@ export async function postRuntime( const [event, mark] = VERDICTS[verdict.trim()] ?? ["COMMENT", "💬"]; const anchorText = await readAgentArtifact(manifest, outcome.anchorsPath, "anchors.json"); const anchors = anchorText === null ? [] : parseAnchors(anchorText, outcome.anchorsPath); - const { profile } = outcome; const postReview = (entries: Anchor[]): Promise => request(`repos/${context.repository}/pulls/${context.issueIndex}/reviews`, { - body: stripAnsi(withProfile([`${mark} ${verdict.trim()}`, ...rest].join("\n"), profile)), + body: stripAnsi( + withProfile([`${mark} ${verdict.trim()}`, ...rest].join("\n"), outcome.profile), + ), event, comments: entries.map(({ path, line, side, body }) => ({ path, - body: stripAnsi(withProfile(body, profile)), + body: stripAnsi(withProfile(body, outcome.profile)), new_position: side === "new" ? line : 0, old_position: side === "old" ? line : 0, })), diff --git a/src/prepare.ts b/src/prepare.ts index e1c2aa0..9630030 100644 --- a/src/prepare.ts +++ b/src/prepare.ts @@ -5,9 +5,7 @@ import { prepareRuntime } from "./runtime.ts"; const env = (name: string): string => { const value = process.env[name]; - if (value === undefined || value === "") { - throw new Error(`${name} is not set`); - } + if (value === undefined || value === "") throw new Error(`${name} is not set`); return value; }; diff --git a/src/run.ts b/src/run.ts index 34cdfe6..1092ca0 100644 --- a/src/run.ts +++ b/src/run.ts @@ -52,9 +52,7 @@ type ClaudeResult = ClaudeFailureFields & const env = (name: string): string => { const value = process.env[name]; - if (value === undefined) { - throw new Error(`${name} is not set`); - } + if (value === undefined) throw new Error(`${name} is not set`); return value; }; @@ -101,9 +99,7 @@ async function postAuthorComment(body: string): Promise { async function runRoot(command: string, args: string[]): Promise { const { success, code } = await output(command, { args, env: PROCESS_ENV, clearEnv: true }); - if (!success) { - throw new Error(`${command} ${args[0]} exited with ${code}`); - } + if (!success) throw new Error(`${command} ${args[0]} exited with ${code}`); } async function configureGitAuthor(): Promise { @@ -131,9 +127,7 @@ async function runAgentCommand( env: agentEnvironment(PROCESS_ENV, profile, token), clearEnv: true, }).output(); - if (!success) { - throw new Error(`${command} ${args[0]} exited with ${code}`); - } + if (!success) throw new Error(`${command} ${args[0]} exited with ${code}`); } async function prepareProfile(profile: RuntimeProfile): Promise { @@ -361,9 +355,7 @@ async function runCodex( env: environment, clearEnv: true, }).output(); - if (!loggedIn.success) { - await codexDeviceLogin(profile, environment); - } + if (!loggedIn.success) await codexDeviceLogin(profile, environment); } const outputPath = await makeProfileFile(profile, "result.md"); const attempt = async (): Promise<{ status: CommandStatus; error: string }> => { @@ -479,9 +471,7 @@ async function runProfile(profile: RuntimeProfile): Promise { await persistCodexAuth(stagedCodexAuth, CODEX_AUTH); } } - if (resultPath !== null) { - body = await readProfileFile(profile, resultPath); - } + if (resultPath !== null) body = await readProfileFile(profile, resultPath); if (body === undefined || reviewPath === undefined || anchorsPath === undefined) { throw new Error("agent attempt produced no result"); }