← 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
/**
* Export the factory's configuration as a portable JSON document.
* No secrets: credential needs are listed by name only.
*/
import { loadSettings } from '../lib/settings.ts'
import { loadProjects } from '../projects/config.ts'
import { CONFIG_VERSION, type ConfigDocument, type ConfigProject, type ConfigSettings, type ConfigJob } from './schema.ts'
import { loadRules } from '../notifications/store.ts'
const KNOWN_JOBS: Array<{ name: string; schedule: string; description: string }> = [
{ name: 'sweep', schedule: '*/15 * * * *', description: 'Sweep work-item ledger across projects.' },
{ name: 'friction-daily', schedule: '0 5 * * *', description: 'Daily friction sweep.' },
{ name: 'cleanup-legacy-reaper', schedule: '0 2 * * 1', description: 'Weekly legacy reaper cleanup.' },
{ name: 'cleanup-docs-freshness', schedule: '0 3 * * *', description: 'Daily docs freshness pass.' },
{ name: 'cleanup-keep-tests-tight', schedule: '30 3 * * *', description: 'Daily keep-tests-tight pass.' },
{ name: 'cleanup-general-audit', schedule: '0 4 * * 0', description: 'Weekly general audit.' },
]
const CREDENTIAL_NEEDS = ['runner', 'model', 'github']
export async function exportConfig(opts?: { jobToggles?: Record<string, boolean> }): Promise<ConfigDocument> {
const [settings, projectsState, notificationRules] = await Promise.all([loadSettings(), loadProjects(), loadRules()])
const projects: ConfigProject[] = Object.values(projectsState.projects).map((p) => ({
id: p.id,
displayName: p.displayName,
enabled: p.enabled,
defaultRunnerId: p.defaultRunnerId,
repos: p.repos.map((r) => ({ repoRef: r.repoRef, host: r.host, enabled: r.enabled })),
signalSources: p.signalSources,
...(p.sources ? { sources: p.sources } : {}),
...((p as Record<string, unknown>).paused === true ? { paused: true } : {}),
}))
const configSettings: ConfigSettings = {
shadowMode: settings.shadowMode,
maxConcurrentRuns: settings.maxConcurrentRuns,
agentMayMerge: settings.agentMayMerge,
sweepStartLimit: settings.sweepStartLimit,
agentDryRunDefault: settings.agentDryRunDefault,
killSwitch: (settings as Record<string, unknown>).killSwitch === true,
postMergeFixTimeoutMinutes: settings.postMergeFixTimeoutMinutes,
postMergePendingTimeoutMinutes: settings.postMergePendingTimeoutMinutes,
stallHealthEnabled: settings.stallHealthEnabled,
columnTimeLimits: settings.columnTimeLimits as Record<string, number>,
bugbotCursorLogin: settings.bugbotCursorLogin || '',
shipPrSummaryChannelId: settings.shipPrSummaryChannelId || '',
discordNotificationsEnabled: settings.discordNotificationsEnabled,
discordNotificationsChannelId: settings.discordNotificationsChannelId || '',
notificationRules: notificationRules,
}
const toggles = opts?.jobToggles ?? {}
const jobs: ConfigJob[] = KNOWN_JOBS.map((j) => ({
name: j.name,
enabled: toggles[j.name] ?? (j.name === 'sweep'),
schedule: j.schedule,
description: j.description,
}))
return {
version: CONFIG_VERSION,
exportedAt: new Date().toISOString(),
projects,
settings: configSettings,
jobs,
credentialNeeds: CREDENTIAL_NEEDS,
}
}