import type { Capability } from '@feltdb/core'; import { auditEvents, projects, type AuditEvent, type Project } from '../src/feltdb'; export interface ProjectSummary { title: string; summary: string; activityCount: number } export const projectSummary: Capability = { id: 'project-summary', name: 'Project summary', async execute(projectId: string): Promise { const project = await projects.get(projectId) as Project | null; if (!project) throw new Error('Project is unavailable in the current authorization context.'); const activity = (await auditEvents.all() as AuditEvent[]).filter(event => event.resource_id === project.id); return { title: project.name, summary: project.description || `${project.name} is active and ready for its next state transition.`, activityCount: activity.length }; }, };