mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-23 06:33:06 +00:00
chore: format agent scripts
This commit is contained in:
parent
c362b63adb
commit
5b857814c3
4 changed files with 34 additions and 23 deletions
|
|
@ -71,7 +71,8 @@ const queue = openReady
|
||||||
})
|
})
|
||||||
.filter((entry) => entry.blockedBy.length === 0)
|
.filter((entry) => entry.blockedBy.length === 0)
|
||||||
.sort((a, b) => {
|
.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)
|
return rank !== 0 ? rank : a.issue.createdAt.localeCompare(b.issue.createdAt)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -96,15 +97,13 @@ if (!pick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optimistic lock: re-read right before flipping.
|
// Optimistic lock: re-read right before flipping.
|
||||||
const fresh = ghJson([
|
const fresh = ghJson(['issue', 'view', String(pick.issue.number), '--json', 'number,labels,state'])
|
||||||
'issue',
|
|
||||||
'view',
|
|
||||||
String(pick.issue.number),
|
|
||||||
'--json',
|
|
||||||
'number,labels,state',
|
|
||||||
])
|
|
||||||
const freshLabels = labelNames(fresh)
|
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.`)
|
die(`Issue #${pick.issue.number} was just claimed or closed by someone else. Re-run claim.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ const die = dieAgent('file-miss')
|
||||||
const { flags } = parseArgs(process.argv.slice(2), new Set(['title', 'body', 'kind']))
|
const { flags } = parseArgs(process.argv.slice(2), new Set(['title', 'body', 'kind']))
|
||||||
|
|
||||||
if (!flags.title) {
|
if (!flags.title) {
|
||||||
die('Usage: pnpm agent:file-miss -- --title <what went wrong> [--body details] [--kind agent-miss|defect]')
|
die(
|
||||||
|
'Usage: pnpm agent:file-miss -- --title <what went wrong> [--body details] [--kind agent-miss|defect]',
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const kind = flags.kind === 'defect' ? 'defect' : 'agent-miss'
|
const kind = flags.kind === 'defect' ? 'defect' : 'agent-miss'
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,11 @@ const stageRuns = ghJson([
|
||||||
'headSha,status,conclusion,url',
|
'headSha,status,conclusion,url',
|
||||||
])
|
])
|
||||||
const latestStageRun = stageRuns.find((run) => run.headSha === stageSha)
|
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(
|
die(
|
||||||
`CI stage não está verde no head de stage (${stageSha.slice(0, 8)}). ` +
|
`CI stage não está verde no head de stage (${stageSha.slice(0, 8)}). ` +
|
||||||
`Último run: ${latestStageRun ? `${latestStageRun.status}/${latestStageRun.conclusion} — ${latestStageRun.url}` : 'nenhum'}`,
|
`Último run: ${latestStageRun ? `${latestStageRun.status}/${latestStageRun.conclusion} — ${latestStageRun.url}` : 'nenhum'}`,
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,7 @@
|
||||||
* Starts life labeled `ready` (or `blocked` when --blocked).
|
* Starts life labeled `ready` (or `blocked` when --blocked).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { dieAgent, gh, issuesById, parseArgs, serializeFrontmatter } from './lib/agent-github.mjs'
|
||||||
dieAgent,
|
|
||||||
gh,
|
|
||||||
issuesById,
|
|
||||||
parseArgs,
|
|
||||||
serializeFrontmatter,
|
|
||||||
} from './lib/agent-github.mjs'
|
|
||||||
|
|
||||||
const die = dieAgent('register')
|
const die = dieAgent('register')
|
||||||
const { flags } = parseArgs(
|
const { flags } = parseArgs(
|
||||||
|
|
@ -22,13 +16,22 @@ const { flags } = parseArgs(
|
||||||
new Set(['id', 'title', 'prio', 'depends', 'kind', 'plan', 'body', 'labels']),
|
new Set(['id', 'title', 'prio', 'depends', 'kind', 'plan', 'body', 'labels']),
|
||||||
)
|
)
|
||||||
|
|
||||||
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]')
|
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 priority = /^P[0-3]$/.test(flags.prio ?? 'P2')
|
||||||
const depends = (flags.depends ?? '').split(',').map((v) => v.trim()).filter(Boolean)
|
? (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)
|
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(
|
const body = serializeFrontmatter(
|
||||||
{ id: flags.id, depends, serializes: [], priority },
|
{ id: flags.id, depends, serializes: [], priority },
|
||||||
|
|
@ -41,7 +44,10 @@ const labels = [
|
||||||
flags.blocked ? 'blocked' : 'ready',
|
flags.blocked ? 'blocked' : 'ready',
|
||||||
`prio:${priority}`,
|
`prio:${priority}`,
|
||||||
`kind:${flags.kind ?? 'feature'}`,
|
`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([
|
const url = gh([
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue