Keep main's one-line guards where no rule needs braces
Check / check (pull_request) Successful in 37s

This commit is contained in:
Danny Kim
2026-10-17 18:52:49 +09:00
parent 3cbe4171ea
commit eba9b9c57c
4 changed files with 12 additions and 27 deletions
+1 -3
View File
@@ -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`); throw new Error(`profile UID ${uid} still owns processes after cleanup`);
} }
const ids = await profileProcessIds(uid); const ids = await profileProcessIds(uid);
if (ids.length === 0) { if (ids.length === 0) return;
return;
}
for (const pid of ids) { for (const pid of ids) {
try { try {
process.kill(pid, "SIGKILL"); process.kill(pid, "SIGKILL");
+5 -6
View File
@@ -41,9 +41,7 @@ class GiteaRequestError extends Error {}
function parseAnchors(text: string, sourcePath: string): Anchor[] { function parseAnchors(text: string, sourcePath: string): Anchor[] {
const entries: unknown = JSON.parse(text); const entries: unknown = JSON.parse(text);
if (!Array.isArray(entries)) { if (!Array.isArray(entries)) throw new TypeError(`${sourcePath}: not an array`);
throw new TypeError(`${sourcePath}: not an array`);
}
return entries.map((entry: unknown, index) => { return entries.map((entry: unknown, index) => {
const at = `${sourcePath}[${index}]`; const at = `${sourcePath}[${index}]`;
if (!isObject(entry)) { if (!isObject(entry)) {
@@ -194,14 +192,15 @@ export async function postRuntime(
const [event, mark] = VERDICTS[verdict.trim()] ?? ["COMMENT", "💬"]; const [event, mark] = VERDICTS[verdict.trim()] ?? ["COMMENT", "💬"];
const anchorText = await readAgentArtifact(manifest, outcome.anchorsPath, "anchors.json"); const anchorText = await readAgentArtifact(manifest, outcome.anchorsPath, "anchors.json");
const anchors = anchorText === null ? [] : parseAnchors(anchorText, outcome.anchorsPath); const anchors = anchorText === null ? [] : parseAnchors(anchorText, outcome.anchorsPath);
const { profile } = outcome;
const postReview = (entries: Anchor[]): Promise<void> => const postReview = (entries: Anchor[]): Promise<void> =>
request(`repos/${context.repository}/pulls/${context.issueIndex}/reviews`, { 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, event,
comments: entries.map(({ path, line, side, body }) => ({ comments: entries.map(({ path, line, side, body }) => ({
path, path,
body: stripAnsi(withProfile(body, profile)), body: stripAnsi(withProfile(body, outcome.profile)),
new_position: side === "new" ? line : 0, new_position: side === "new" ? line : 0,
old_position: side === "old" ? line : 0, old_position: side === "old" ? line : 0,
})), })),
+1 -3
View File
@@ -5,9 +5,7 @@ import { prepareRuntime } from "./runtime.ts";
const env = (name: string): string => { const env = (name: string): string => {
const value = process.env[name]; const value = process.env[name];
if (value === undefined || value === "") { if (value === undefined || value === "") throw new Error(`${name} is not set`);
throw new Error(`${name} is not set`);
}
return value; return value;
}; };
+5 -15
View File
@@ -52,9 +52,7 @@ type ClaudeResult = ClaudeFailureFields &
const env = (name: string): string => { const env = (name: string): string => {
const value = process.env[name]; const value = process.env[name];
if (value === undefined) { if (value === undefined) throw new Error(`${name} is not set`);
throw new Error(`${name} is not set`);
}
return value; return value;
}; };
@@ -101,9 +99,7 @@ async function postAuthorComment(body: string): Promise<void> {
async function runRoot(command: string, args: string[]): Promise<void> { async function runRoot(command: string, args: string[]): Promise<void> {
const { success, code } = await output(command, { args, env: PROCESS_ENV, clearEnv: true }); const { success, code } = await output(command, { args, env: PROCESS_ENV, clearEnv: true });
if (!success) { if (!success) throw new Error(`${command} ${args[0]} exited with ${code}`);
throw new Error(`${command} ${args[0]} exited with ${code}`);
}
} }
async function configureGitAuthor(): Promise<void> { async function configureGitAuthor(): Promise<void> {
@@ -131,9 +127,7 @@ async function runAgentCommand(
env: agentEnvironment(PROCESS_ENV, profile, token), env: agentEnvironment(PROCESS_ENV, profile, token),
clearEnv: true, clearEnv: true,
}).output(); }).output();
if (!success) { if (!success) throw new Error(`${command} ${args[0]} exited with ${code}`);
throw new Error(`${command} ${args[0]} exited with ${code}`);
}
} }
async function prepareProfile(profile: RuntimeProfile): Promise<void> { async function prepareProfile(profile: RuntimeProfile): Promise<void> {
@@ -361,9 +355,7 @@ async function runCodex(
env: environment, env: environment,
clearEnv: true, clearEnv: true,
}).output(); }).output();
if (!loggedIn.success) { if (!loggedIn.success) await codexDeviceLogin(profile, environment);
await codexDeviceLogin(profile, environment);
}
} }
const outputPath = await makeProfileFile(profile, "result.md"); const outputPath = await makeProfileFile(profile, "result.md");
const attempt = async (): Promise<{ status: CommandStatus; error: string }> => { const attempt = async (): Promise<{ status: CommandStatus; error: string }> => {
@@ -479,9 +471,7 @@ async function runProfile(profile: RuntimeProfile): Promise<AttemptResult> {
await persistCodexAuth(stagedCodexAuth, CODEX_AUTH); await persistCodexAuth(stagedCodexAuth, CODEX_AUTH);
} }
} }
if (resultPath !== null) { if (resultPath !== null) body = await readProfileFile(profile, resultPath);
body = await readProfileFile(profile, resultPath);
}
if (body === undefined || reviewPath === undefined || anchorsPath === undefined) { if (body === undefined || reviewPath === undefined || anchorsPath === undefined) {
throw new Error("agent attempt produced no result"); throw new Error("agent attempt produced no result");
} }