Skip to content
← 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.

FollowFork

Files

registry.ts

25 lines · 1.1 KB · TypeScript
/**
 * Optional observation adapters. Each is off until a project enables it in
 * `sources`. Remove an adapter by deleting its line here (plus its files).
 */
import type { ProjectConfig } from '../projects/model.ts'

export type ObservationAdapterId = 'github-release'

export const OBSERVATION_ADAPTERS: ReadonlyArray<{ id: ObservationAdapterId; displayName: string }> = [
	{ id: 'github-release', displayName: 'GitHub releases' },
]

export function isAdapterRegistered(id: ObservationAdapterId): boolean {
	return OBSERVATION_ADAPTERS.some((a) => a.id === id)
}

/** Enabled GitHub repos a project observes releases for (empty = off). */
export function releaseReposFor(project: ProjectConfig): string[] {
	const cfg = project.sources?.githubRelease
	if (!isAdapterRegistered('github-release') || !project.enabled || cfg?.enabled !== true) return []
	const enabled = project.repos.filter((r) => r.enabled && r.host === 'github').map((r) => r.repoRef)
	if (!cfg.repos?.length) return enabled
	const want = new Set(cfg.repos.map((r) => r.toLowerCase()))
	return enabled.filter((r) => want.has(r.toLowerCase()))
}