diff --git a/scripts/agent-claim.mjs b/scripts/agent-claim.mjs index 46051abd..790eec7a 100644 --- a/scripts/agent-claim.mjs +++ b/scripts/agent-claim.mjs @@ -71,7 +71,8 @@ const queue = openReady }) .filter((entry) => entry.blockedBy.length === 0) .sort((a, b) => { - const rank = priorityRank(a.priority.replace('prio:', '')) - priorityRank(b.priority.replace('prio:', '')) + const rank = + priorityRank(a.priority.replace('prio:', '')) - priorityRank(b.priority.replace('prio:', '')) return rank !== 0 ? rank : a.issue.createdAt.localeCompare(b.issue.createdAt) }) @@ -96,15 +97,13 @@ if (!pick) { } // Optimistic lock: re-read right before flipping. -const fresh = ghJson([ - 'issue', - 'view', - String(pick.issue.number), - '--json', - 'number,labels,state', -]) +const fresh = ghJson(['issue', 'view', String(pick.issue.number), '--json', 'number,labels,state']) const freshLabels = labelNames(fresh) -if (fresh.state !== 'OPEN' || !freshLabels.includes('ready') || freshLabels.includes('in-progress')) { +if ( + fresh.state !== 'OPEN' || + !freshLabels.includes('ready') || + freshLabels.includes('in-progress') +) { die(`Issue #${pick.issue.number} was just claimed or closed by someone else. Re-run claim.`) } diff --git a/scripts/agent-file-miss.mjs b/scripts/agent-file-miss.mjs index 022c2f87..bf56bada 100644 --- a/scripts/agent-file-miss.mjs +++ b/scripts/agent-file-miss.mjs @@ -15,7 +15,9 @@ const die = dieAgent('file-miss') const { flags } = parseArgs(process.argv.slice(2), new Set(['title', 'body', 'kind'])) if (!flags.title) { - die('Usage: pnpm agent:file-miss -- --title [--body details] [--kind agent-miss|defect]') + die( + 'Usage: pnpm agent:file-miss -- --title [--body details] [--kind agent-miss|defect]', + ) } const kind = flags.kind === 'defect' ? 'defect' : 'agent-miss' diff --git a/scripts/agent-promote.mjs b/scripts/agent-promote.mjs index f925db6f..625bf292 100644 --- a/scripts/agent-promote.mjs +++ b/scripts/agent-promote.mjs @@ -58,7 +58,11 @@ const stageRuns = ghJson([ 'headSha,status,conclusion,url', ]) const latestStageRun = stageRuns.find((run) => run.headSha === stageSha) -if (!latestStageRun || latestStageRun.status !== 'completed' || latestStageRun.conclusion !== 'success') { +if ( + !latestStageRun || + latestStageRun.status !== 'completed' || + latestStageRun.conclusion !== 'success' +) { die( `CI stage não está verde no head de stage (${stageSha.slice(0, 8)}). ` + `Último run: ${latestStageRun ? `${latestStageRun.status}/${latestStageRun.conclusion} — ${latestStageRun.url}` : 'nenhum'}`, diff --git a/scripts/agent-register.mjs b/scripts/agent-register.mjs index 190e74d8..048554f7 100644 --- a/scripts/agent-register.mjs +++ b/scripts/agent-register.mjs @@ -8,13 +8,7 @@ * Starts life labeled `ready` (or `blocked` when --blocked). */ -import { - dieAgent, - gh, - issuesById, - parseArgs, - serializeFrontmatter, -} from './lib/agent-github.mjs' +import { dieAgent, gh, issuesById, parseArgs, serializeFrontmatter } from './lib/agent-github.mjs' const die = dieAgent('register') const { flags } = parseArgs( @@ -22,13 +16,22 @@ const { flags } = parseArgs( new Set(['id', 'title', 'prio', 'depends', 'kind', 'plan', 'body', 'labels']), ) -if (!flags.id || !flags.title) die('Usage: pnpm agent:register -- --id --title [--prio P2] [--depends A,B] [--kind feature] [--plan path] [--body text] [--labels extra,labels] [--blocked]') +if (!flags.id || !flags.title) + die( + 'Usage: pnpm agent:register -- --id <ID> --title <title> [--prio P2] [--depends A,B] [--kind feature] [--plan path] [--body text] [--labels extra,labels] [--blocked]', + ) -const priority = /^P[0-3]$/.test(flags.prio ?? 'P2') ? (flags.prio ?? 'P2') : die(`Invalid --prio "${flags.prio}" (P0..P3).`) -const depends = (flags.depends ?? '').split(',').map((v) => v.trim()).filter(Boolean) +const priority = /^P[0-3]$/.test(flags.prio ?? 'P2') + ? (flags.prio ?? 'P2') + : die(`Invalid --prio "${flags.prio}" (P0..P3).`) +const depends = (flags.depends ?? '') + .split(',') + .map((v) => v.trim()) + .filter(Boolean) const existing = issuesById().get(flags.id) -if (existing) die(`An issue with id ${flags.id} already exists: #${existing.number} — ${existing.title}`) +if (existing) + die(`An issue with id ${flags.id} already exists: #${existing.number} — ${existing.title}`) const body = serializeFrontmatter( { id: flags.id, depends, serializes: [], priority }, @@ -41,7 +44,10 @@ const labels = [ flags.blocked ? 'blocked' : 'ready', `prio:${priority}`, `kind:${flags.kind ?? 'feature'}`, - ...(flags.labels ?? '').split(',').map((v) => v.trim()).filter(Boolean), + ...(flags.labels ?? '') + .split(',') + .map((v) => v.trim()) + .filter(Boolean), ] const url = gh([