Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/skills

src/backend.ts

18 lines · 631 B · TypeScript
import { ensureSchema, getMeta } from './db.ts'

export type RegistryBackend = 'legacy' | 'repo'

export async function getBackend(): Promise<RegistryBackend> {
	await ensureSchema()
	const value = await getMeta('backend')
	return value === 'repo' ? 'repo' : 'legacy'
}

export async function assertRepoBackend(): Promise<void> {
	const backend = await getBackend()
	if (backend !== 'repo') {
		throw new Error(
			'Skills registry backend is still `legacy` (SQLite package storage). Import migrateToRepo from "kody:@kody/skills/migrate-to-repo" after the plain-repo copy is verified, or set registry_meta.backend=repo.',
		)
	}
}