/** * Absorbed from kentcdodds/kcd-skills skills/autopilot (13-rung readiness audit). * This is a setup/readiness module, NOT a run loop. * Host-side fs audit scripts (audit-detect.mjs etc.) cannot run in a Worker; * agents or execution contexts run those locally and store the audit JSON here. */ export const AUTOPILOT_PILLARS = ['P1', 'P2', 'P3', 'KI'] as const export type AutopilotPillar = (typeof AUTOPILOT_PILLARS)[number] export type RungScore = 'missing' | 'partial' | 'done' | 'unknown' | 'n/a' export type AutopilotRung = { n: number pillar: AutopilotPillar title: string doneWhen: string } export const AUTOPILOT_RUNGS: ReadonlyArray = [ { n: 1, pillar: 'P1', title: 'Agent map + verify', doneWhen: 'Short AGENTS.md linking agent docs; one verify command CI runs in full; hooks run fast static checks.', }, { n: 2, pillar: 'P1', title: 'Decisions directory', doneWhen: 'ADRs for multi-PR decisions and the "no", each with Revisit if.', }, { n: 3, pillar: 'P1', title: 'Primitives catalog', doneWhen: 'Building blocks, code roots, and adrs list per entry, kept short.', }, { n: 4, pillar: 'P1', title: 'Self-verification', doneWhen: 'Control CLI (doctor, dev, login, request, execute, browse, health) and control skill; Feature Map when applicable.', }, { n: 5, pillar: 'P1', title: 'PR template', doneWhen: 'Intent, Why, Door, Cleanup, Testing, System recap.', }, { n: 6, pillar: 'P2', title: 'Ship loop', doneWhen: 'ship-pr (or host-neutral tick) + config behind a thin skill.', }, { n: 7, pillar: 'P2', title: 'Reviewers + previews', doneWhen: 'AI reviewers per tier; previews for production-like changes; running-version check.', }, { n: 8, pillar: 'P3', title: 'Flags + rollback', doneWhen: 'Flags with owner, metric, removal condition; rollback runbook.', }, { n: 9, pillar: 'P3', title: 'Backups', doneWhen: 'Scheduled, isolated restore test.', }, { n: 10, pillar: 'KI', title: 'Friction form', doneWhen: 'Issue form + friction / friction-skipped labels; filed by every ship loop.', }, { n: 11, pillar: 'KI', title: 'Triage', doneWhen: 'Every agent-filed issue gets priority; needs-decision waits on human; highest first.', }, { n: 12, pillar: 'KI', title: 'Cleanup issues', doneWhen: 'Cleanup: issues with falsifiable ready-when, triaged.', }, { n: 13, pillar: 'KI', title: 'Cleanup cron agents', doneWhen: 'Daily friction sweep, errors→issues, docs freshness, test pruning, weekly legacy reaper; only low/medium with green CI auto-merges.', }, ] export type InterviewAnswers = { useKody: boolean mustNotDo: string[] agentMayMerge: 'low' | 'low+medium' | 'none' riskTiersNote: string aiReviewers: string[] previewOrStaging: string | null alwaysHuman: string[] deployRelease: string | null versionCheck: string | null flagsMetricsSource: string | null backupsRestoreTested: string | null issueTracker: string | null priorityScheme: string } export function defaultInterviewAnswers(): InterviewAnswers { return { useKody: true, mustNotDo: [], agentMayMerge: 'low', riskTiersNote: 'low = CI green; medium = +AI reviewer +rung 4 proof; high = +human', aiReviewers: [], previewOrStaging: null, alwaysHuman: [], deployRelease: null, versionCheck: null, flagsMetricsSource: null, backupsRestoreTested: null, issueTracker: null, priorityScheme: 'P0-P3 + needs-decision', } } export type AutopilotAudit = { repoRef: string projectId: string at: string scores: Record interview: InterviewAnswers plan: Array<{ rung: number title: string effort: 'S' | 'M' | 'L' door: 'two-way' | 'one-way' files: string[] }> humanChecklist: Array<{ what: string; where: string; why: string }> } export function emptyAudit(repoRef: string, projectId: string): AutopilotAudit { const scores: AutopilotAudit['scores'] = {} for (const r of AUTOPILOT_RUNGS) { scores[r.n] = { score: 'unknown' } } return { repoRef, projectId, at: new Date().toISOString(), scores, interview: defaultInterviewAnswers(), plan: [], humanChecklist: [], } }