teqo-backup/scripts/agent-ready.mjs
Francisco Solla c90f70aab4 ops(OPS76): tracker de Issues migra do Forgejo para o GitHub — GitHub como host único
Decisão (2026-08-21): o GitHub passa a ser a fonte única — main, branches,
PRs, CI via Actions E tracker de Issues. O Forgejo deixa de ser canal ativo
(git.e issue tracker congelados pós-convergência).

Data: 17 issues migradas do Forgejo para o GitHub (frontmatter id/depends/
serializes/priority/model preservados, labels mapeados, comment de origem
em cada uma; tabela Forgejo→GitHub registrada).

Tooling: github-api.mjs estendido com a camada de issues/labels/comments/
close/workflow-dispatch/contents (mesmo shape normalizado do forgejo-api);
18 scripts trocam o transporte forgejo-api → github-api; forgejo-api.mjs e
seu teste (961 linhas) removidos; teste githubApi.unit.spec.ts novo (7 casos);
issue-transition-on-merge.mjs renomeado e reapontado.

Flips pós-merge: issue-done e plan-issue-ready agora usam o GITHUB_TOKEN com
issues:write no repo (sem FORGEJO_API_TOKEN) e fecham/flipam Issues no GitHub.

Docs: AGENTS.md, AGENT-OPS.md e skills do fluxo vivo (work-issue, plan-issue,
project-status, capture-review-debts, worktree-next-issue, agent-work-issue)
apontam o tracker para github.com/fsolla/teqo/issues.

Gates: tsc/lint/format/knip/cycles/unit 2416 verdes.
2026-08-21 08:19:06 -03:00

53 lines
1.8 KiB
JavaScript

/**
* `pnpm agent:ready` — flip plan-issue Issues from `blocked` → `ready` after
* the intention plan is on `main` (OPS17 Passo 6). Idempotent per issue.
*
* pnpm agent:ready -- --issue 292
* pnpm agent:ready -- --issue 292,293
*
* Fail-closed via `canPromotePlanIssue`: open + `blocked` + `docs/plans/` link,
* and not `needs:consent` / `requirements-changed` / `in-progress`|`done`|`in-prod`.
* Idempotent skip when already `ready`. Product-blocked Issues without a plan
* link stay for human triage.
*/
import { dieAgent, parseArgs, setLabels } from './lib/agent-forgejo.mjs'
import { canPromotePlanIssue } from './lib/agent-plan-lifecycle.mjs'
import { githubApi as api } from './lib/github-api.mjs'
const die = dieAgent('ready')
const { flags } = parseArgs(process.argv.slice(2), new Set(['issue']))
if (!flags.issue) {
die('Usage: pnpm agent:ready -- --issue <N[,N…]>')
}
const numbers = String(flags.issue)
.split(',')
.map((value) => value.trim())
.filter(Boolean)
.map((value) => {
if (!/^\d+$/.test(value)) die(`Invalid issue number "${value}".`)
return Number(value)
})
if (numbers.length === 0) die('Usage: pnpm agent:ready -- --issue <N[,N…]>')
for (const number of numbers) {
const issue = await api.getIssue(number)
const verdict = canPromotePlanIssue(issue)
if (!verdict.ok) {
if (verdict.reason === 'already-ready') {
console.log(`[agent:ready] #${number} already ready — skip`)
continue
}
die(`#${number} cannot mark ready (${verdict.reason}).`)
}
await setLabels(number, { add: ['ready'], remove: ['blocked'] })
await api.addComment(
number,
'Promovido a `ready`: plano de intenção em `main` (ciclo OPS17 — `pnpm agent:ready`).',
)
console.log(`[agent:ready] #${number} blocked → ready`)
}