← Public packages
@kody/kody-factory
Forkable multi-project software factory: signals, priority queue, project UI, sweep job. Agent runners and Sentry reach it by events.
Files
/**
* Weekly CI review, run by the factory (ported from @kentcdodds/ci-review 0.3.0, cf66617).
* It posts one factory report per week; safe wins become work cards and
* coverage trades become Needs-you recommendation cards. It never writes to GitHub.
*/
/** Report source and card source (the factory's ci-review skill picks these cards up). */
export const REPORT_SOURCE = 'ci-review'
/** Factory package that owns this review. */
export const SELF_PACKAGE = '@kody/kody-factory'
/** Factory project the cards land in. */
export const factoryProjectId = 'kody'
/** The one repository this package reviews. */
export const targetRepo = 'kody-hq/kody'
export const timezone = 'America/Denver'
/** Weekly job: Monday 4:00 AM America/Denver. */
export const weeklySchedule = '0 4 * * 1'
/** Days of GitHub Actions history each run reads. */
export const lookbackDays = 7
/** Hard cap on GitHub REST calls per run (listing, jobs, timing, caches, PR files). */
export const defaultMaxApiCalls = 450
/** Most run-listing pages for one workflow. */
export const maxListPagesPerWorkflow = 20
/** Most workflows that get job-level detail (heaviest first). */
export const maxDetailedWorkflows = 6
/** Most runs per workflow whose jobs are fetched. */
export const maxJobRunsPerWorkflow = 30
/** Most failed runs per workflow whose jobs are fetched (part of the cap above). */
export const maxFailedRunsPerWorkflow = 20
/** Most rerun runs per workflow whose earlier attempt jobs are fetched. */
export const maxRerunsPerWorkflow = 8
/** First-attempt successful runs per workflow sampled even when failures fill the cap. */
export const minSuccessRunsPerWorkflow = 15
/** Runs whose billable timing is read (spread across workflows). */
export const maxTimingRuns = 12
/** Pull requests whose changed files are read (docs-only detection). */
export const maxPrFileLookups = 30
/** Parallel GitHub requests. */
export const requestConcurrency = 8
/** Most safe-win work cards one week files. */
export const maxWorkCards = 5
/** Most coverage-trade recommendation cards one week files. */
export const maxRecommendCards = 3
/** Weeks of full metrics kept for trends. */
export const weeklyMetricsKept = 12
/** An opportunity posted within this many days is not posted again unless it grew. */
export const repostAfterDays = 21
/** Growth that justifies re-posting a recent opportunity early. */
export const repostGrowth = 1.5
/** Billing multipliers GitHub applies to hosted runner minutes on private repos. */
export const runnerMultipliers: Record<RunnerOs, number> = { linux: 1, windows: 2, macos: 10, other: 1 }
export type RunnerOs = 'linux' | 'windows' | 'macos' | 'other'
/** Classify a job's runner from its labels. */
export function runnerOsOf(labels: ReadonlyArray<string> | null | undefined): RunnerOs {
const text = (labels ?? []).join(' ').toLowerCase()
if (/windows/.test(text)) return 'windows'
if (/macos|mac-|osx/.test(text)) return 'macos'
if (/ubuntu|linux/.test(text)) return 'linux'
return text ? 'other' : 'linux'
}
/** Strip a leading emoji or symbol and collapse whitespace so step names compare. */
export function normalizeName(name: unknown) {
return String(name ?? '')
.replace(/^[^\p{L}\p{N}(]+/u, '')
.replace(/\s+/g, ' ')
.trim()
}
/** Break literal secret placeholders, backticks, and em dashes in text that leaves the package. */
export function sanitizeForPrompt(text: unknown) {
return String(text ?? '')
.replaceAll('`', "'")
.replaceAll('\u2014', ' - ')
.replace(/\{\{(\s*secret\s*:)/gi, '{ {$1')
}
export function truncate(text: unknown, max: number) {
const value = String(text ?? '')
return value.length <= max ? value : `${value.slice(0, Math.max(0, max - 1))}…`
}
export function round(value: number, digits = 1) {
if (!Number.isFinite(value)) return 0
const factor = 10 ** digits
return Math.round(value * factor) / factor
}
/** YYYY-MM-DD in America/Denver. */
export function denverDayKey(now = new Date()) {
return new Intl.DateTimeFormat('en-CA', { timeZone: timezone, year: 'numeric', month: '2-digit', day: '2-digit' }).format(now)
}
/** Monday (YYYY-MM-DD, America/Denver) of the week that contains `now`. */
export function weekKey(now = new Date()) {
const day = denverDayKey(now)
const date = new Date(`${day}T12:00:00Z`)
const weekday = (date.getUTCDay() + 6) % 7
date.setUTCDate(date.getUTCDate() - weekday)
return date.toISOString().slice(0, 10)
}
export function errorMessage(error: unknown) {
return error instanceof Error ? error.message : String(error)
}