Skip to content

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

Package listing

@kody/morning-briefing

src/sources/home.ts

30 lines · 862 B · TypeScript
import { skippedSection } from '../format.ts'
import type { BriefingInput, BriefingSection } from '../types.ts'

export async function homeSection(input: BriefingInput): Promise<BriefingSection> {
	const items = Array.isArray(input.home?.items) ? input.home.items : []
	const usable = items
		.filter((item) => item && typeof item.title === 'string' && item.title.trim())
		.map((item) => ({
			title: item.title.trim(),
			detail: item.detail,
			severity: item.severity,
			href: item.href,
			label: item.label || 'home',
		}))

	if (!usable.length) {
		return skippedSection(
			'home',
			'Pass home.items from your own home package. This official briefing does not call a personal home MCP.',
		)
	}

	return {
		id: 'home',
		title: 'Home',
		status: 'ok',
		summary: `${usable.length} home signal${usable.length === 1 ? '' : 's'}`,
		items: usable,
	}
}