- scripts/ portados do teqo e adaptados (sem DB — SPA): worktree (next/plan/new/kill,
claim + branch <code>-<slug> + bun install), issue, agent:{claim,register,ready,
file-miss,status}, pr (cria PR + auto-merge sem gh), transitions de CI
- config por projeto em .forgejo/worktree.env (FORGEJO_REPOSITORY, WORKTREES_ROOT)
+ roteador global de terminal em ~/.config/shell/worktree.sh (escopo por git rev-parse)
- .opencode/commands e .agents/skills (plan-issue, work-issue, capture-review-debts,
worktree-next-issue, code-simplification) + AGENTS.md com o workflow
- CI Forgejo Actions unificado: checks (lint+build+e2e) em PR e main; deploy
gated; issue-done / plan-issue-ready / agent-pr-automerge workflows
- Playwright: config + 2 specs smoke (settings→chat, ws reconnect) — e2e só no CI
- package.json: aliases worktree/issue/agent:*/pr + gate + test:e2e
57 lines
2.1 KiB
JavaScript
57 lines
2.1 KiB
JavaScript
/**
|
|
* Autonomous-claim eligibility (pool) — portado do teqo. A Iara ainda não usa
|
|
* pool de agentes; mantido para compatibilidade com `agent-plan-lifecycle`.
|
|
*/
|
|
|
|
import { labelNames } from './agent-forgejo.mjs'
|
|
|
|
export const POOL_CIRCUIT_BREAKER_FAILURES = 2
|
|
|
|
const EXCLUDED_STATE_LABELS = ['in-progress', 'blocked', 'done', 'in-prod']
|
|
export const HUMAN_GATE_LABELS = ['requirements-changed', 'needs:consent']
|
|
|
|
export const isAutonomousClaimable = (
|
|
entry,
|
|
{ migrationBusy = false, poolFailureCount = 0 } = {},
|
|
) => {
|
|
const labels = labelNames(entry.issue)
|
|
if (entry.issue.state !== 'OPEN') return { ok: false, reason: 'not-open' }
|
|
if (!labels.includes('ready')) return { ok: false, reason: 'not-ready' }
|
|
if (EXCLUDED_STATE_LABELS.some((label) => labels.includes(label))) {
|
|
return { ok: false, reason: 'state-label' }
|
|
}
|
|
if (HUMAN_GATE_LABELS.some((label) => labels.includes(label))) {
|
|
return { ok: false, reason: 'needs-human' }
|
|
}
|
|
if ((entry.blockedBy ?? []).length > 0) return { ok: false, reason: 'blocked-by-deps' }
|
|
if (poolFailureCount >= POOL_CIRCUIT_BREAKER_FAILURES) {
|
|
return { ok: false, reason: 'circuit-breaker' }
|
|
}
|
|
const serializes = Array.isArray(entry.meta?.serializes) ? entry.meta.serializes : []
|
|
const touchesSchema = labels.includes('needs:migration') || serializes.includes('migrations')
|
|
if (touchesSchema && migrationBusy) return { ok: false, reason: 'migration-busy' }
|
|
return { ok: true }
|
|
}
|
|
|
|
/** Plan link is a preference for claim/pool status (warn), never a claim blocker. */
|
|
export const issueHasPlanLink = (issue) => /docs\/plans\//.test(issue?.body ?? '')
|
|
|
|
export const buildPoolQueue = (
|
|
claimQueue,
|
|
{ migrationBusy = false, failureCountsByIssue = new Map() } = {},
|
|
) => {
|
|
const eligible = []
|
|
const excluded = []
|
|
for (const entry of claimQueue) {
|
|
const verdict = isAutonomousClaimable(entry, {
|
|
migrationBusy,
|
|
poolFailureCount: failureCountsByIssue.get(entry.issue.number) ?? 0,
|
|
})
|
|
if (verdict.ok) {
|
|
eligible.push({ entry, hasPlan: issueHasPlanLink(entry.issue) })
|
|
} else {
|
|
excluded.push({ entry, reason: verdict.reason })
|
|
}
|
|
}
|
|
return { eligible, excluded }
|
|
}
|