Keep main's one-line guards where no rule needs braces
Check / check (pull_request) Successful in 37s
Check / check (pull_request) Successful in 37s
This commit is contained in:
+1
-3
@@ -55,9 +55,7 @@ export async function killProfileProcesses(uid: number, attempt = 0): Promise<vo
|
||||
throw new Error(`profile UID ${uid} still owns processes after cleanup`);
|
||||
}
|
||||
const ids = await profileProcessIds(uid);
|
||||
if (ids.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (ids.length === 0) return;
|
||||
for (const pid of ids) {
|
||||
try {
|
||||
process.kill(pid, "SIGKILL");
|
||||
|
||||
+5
-6
@@ -41,9 +41,7 @@ class GiteaRequestError extends Error {}
|
||||
|
||||
function parseAnchors(text: string, sourcePath: string): Anchor[] {
|
||||
const entries: unknown = JSON.parse(text);
|
||||
if (!Array.isArray(entries)) {
|
||||
throw new TypeError(`${sourcePath}: not an array`);
|
||||
}
|
||||
if (!Array.isArray(entries)) throw new TypeError(`${sourcePath}: not an array`);
|
||||
return entries.map((entry: unknown, index) => {
|
||||
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<void> =>
|
||||
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,
|
||||
})),
|
||||
|
||||
+1
-3
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
+5
-15
@@ -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<void> {
|
||||
|
||||
async function runRoot(command: string, args: string[]): Promise<void> {
|
||||
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<void> {
|
||||
@@ -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<void> {
|
||||
@@ -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<AttemptResult> {
|
||||
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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user