feat(#37-41): Add domains, ideas, relationships, agents, widgets schema

Schema additions for issues #37-41:

New models:
- Domain (#37): Life domains (work, marriage, homelab, etc.)
- Idea (#38): Brain dumps with pgvector embeddings
- Relationship (#39): Generic entity linking (blocks, depends_on)
- Agent (#40): ClawdBot agent tracking with metrics
- AgentSession (#40): Conversation session tracking
- WidgetDefinition (#41): HUD widget registry
- UserLayout (#41): Per-user dashboard configuration

Updated models:
- Task, Event, Project: Added domainId foreign key
- User, Workspace: Added new relations

New enums:
- IdeaStatus: CAPTURED, PROCESSING, ACTIONABLE, ARCHIVED, DISCARDED
- RelationshipType: BLOCKS, BLOCKED_BY, DEPENDS_ON, etc.
- AgentStatus: IDLE, WORKING, WAITING, ERROR, TERMINATED
- EntityType: Added IDEA, DOMAIN

Migration: 20260129182803_add_domains_ideas_agents_widgets
This commit is contained in:
Jason Woltje
2026-01-29 12:29:21 -06:00
parent a220c2dc0a
commit 973502f26e
308 changed files with 18374 additions and 113 deletions

View File

@@ -0,0 +1,69 @@
/**
* Date formatting utilities
* Provides PDA-friendly date formatting and grouping
*/
import { format, isToday, isTomorrow, differenceInDays, isBefore } from "date-fns";
/**
* Format a date in a readable format
*/
export function formatDate(date: Date): string {
try {
return format(date, "MMM d, yyyy");
} catch (error) {
return "Invalid Date";
}
}
/**
* Format time in 12-hour format
*/
export function formatTime(date: Date): string {
try {
return format(date, "h:mm a");
} catch (error) {
return "Invalid Time";
}
}
/**
* Get a PDA-friendly label for date grouping
* Returns: "Today", "Tomorrow", "This Week", "Next Week", "Later"
*/
export function getDateGroupLabel(date: Date, referenceDate: Date = new Date()): string {
if (isToday(date)) {
return "Today";
}
if (isTomorrow(date)) {
return "Tomorrow";
}
const daysUntil = differenceInDays(date, referenceDate);
if (daysUntil >= 0 && daysUntil <= 7) {
return "This Week";
}
if (daysUntil > 7 && daysUntil <= 14) {
return "Next Week";
}
return "Later";
}
/**
* Check if a date has passed (PDA-friendly: "target passed" instead of "overdue")
*/
export function isPastTarget(targetDate: Date, now: Date = new Date()): boolean {
return isBefore(targetDate, now);
}
/**
* Check if a date is approaching (within 24 hours)
*/
export function isApproachingTarget(targetDate: Date, now: Date = new Date()): boolean {
const hoursUntil = differenceInDays(targetDate, now);
return hoursUntil >= 0 && hoursUntil <= 1;
}