/** Any registered entity type name. Validated at runtime via entity-type-config. */ export type EntityTypeName = string; /** A named link stored in YAML frontmatter to express a labeled relationship. */ export interface EntityLink { target: string; label: string; } /** @deprecated Use EntityTypeName (string) — kept for callers that rely on the union */ export type BuiltInEntityTypeName = 'note' | 'task' | 'event' | 'research' | 'goal' | 'recurrence' | 'person' | 'todont'; export type TaskStatus = 'open' | 'in-progress' | 'done' | 'blocked'; export type TaskPriority = 'low' | 'medium' | 'high' | 'critical'; export type GoalStatus = 'active' | 'completed' | 'paused' | 'abandoned'; export type GoalPriority = 'low' | 'medium' | 'high'; export type ResearchStatus = 'draft' | 'in-progress' | 'complete'; export type EventRecurrence = 'daily' | 'weekly' | 'monthly' | 'yearly'; export type RecurrenceCadence = 'daily' | 'weekly' | 'monthly'; export type RecurrenceTargetType = 'todo' | 'event'; export interface BlackoutWindow { start: string; end: string; reason?: string; } export interface CadenceDetails { dayOfMonth?: number; dayOfWeek?: string; startTime?: string; endTime?: string; location?: string; } export interface EntityMeta { id: string; name: string; entityType: EntityTypeName; created: string; updated?: string; tags: string[]; description?: string; /** @deprecated use name */ title?: string; /** @deprecated use description */ summary?: string; } /** Note — base only, no extra fields */ export interface NoteEntity extends EntityMeta { entityType: 'note'; } /** Task — actionable item with due date */ export interface TaskEntity extends EntityMeta { entityType: 'task'; status: TaskStatus; priority: TaskPriority; dueDate?: string; focusTime?: string; calendarDays?: number; startDate?: string; } /** Event — has start and end datetimes */ export interface EventEntity extends EntityMeta { entityType: 'event'; startDate: string; endDate: string; location?: string; recurring?: EventRecurrence; } /** Research — tracked investigation */ export interface ResearchEntity extends EntityMeta { entityType: 'research'; status: ResearchStatus; sources: string[]; } /** SMART Goal */ export interface SmartFields { specific: string; measurable: string; achievable: string; relevant: string; timeBound: string; } export interface GoalEntity extends EntityMeta { entityType: 'goal'; status: GoalStatus; priority: GoalPriority; smart: Partial; milestones: string[]; } /** Recurrence — template for generating concrete todos or events */ export interface RecurrenceEntity extends EntityMeta { entityType: 'recurrence'; recurrenceType: RecurrenceTargetType; cadence: RecurrenceCadence; cadenceDetails: CadenceDetails; priority?: string; blackoutWindows?: BlackoutWindow[]; } /** Person — contact with company/group/handle info */ export interface PersonEntity extends EntityMeta { entityType: 'person'; company?: string; group?: string; phone?: string; email?: string; handle?: string; } /** Discriminated union of all entity types */ export type Entity = NoteEntity | TaskEntity | EventEntity | ResearchEntity | GoalEntity | RecurrenceEntity | PersonEntity; /** * Generate a unique node id: 8 lowercase alphanumeric characters. * e.g. "a1b2c3d4", "x9y8z7w6" */ export declare function generateNodeId(): string; /** @deprecated Use generateNodeId() */ export declare function generateEntityId(_typeName: string): string; /** * Slugify a title into a URL/filename-safe hyphenated string. * Follows system naming rules: lowercase, alphanumeric, hyphens for spaces. */ export declare function slugify(title: string): string; /** * Build a filename for a context node: `{slug}_{id}.md` * e.g. "Fix the Plumbing" + "a1b2c3d4" → "fix-the-plumbing_a1b2c3d4.md" */ export declare function nodeFilename(title: string, id: string): string; /** @deprecated Use nodeFilename() */ export declare function entityFilename(title: string, id: string): string; /** * Create base entity metadata with defaults. */ export declare function createEntityMeta(entityType: EntityTypeName, title: string, opts?: { tags?: string[]; }): EntityMeta; /** Core identity fields that live in frontmatter — everything else goes to body. */ export declare const CORE_FRONTMATTER_KEYS: Set; /** * Parse domain fields from the body prefix. * Lines at the start matching "key: value" (before the first blank line) are * extracted as domain fields; the rest is the user-written content. */ export declare function parseEntityBody(body: string): { fields: Record; content: string; }; /** * Serialize domain fields into a body prefix block. * Core frontmatter fields are excluded. Returns body string with * fields at the top (if any), blank line separator, then content. */ export declare function serializeEntityBody(domainFields: Record, content: string): string; /** * Resolve the directory for an entity type in the active project. * Reads the entity type config to get the directory name. */ export declare function getEntityDir(entityType: EntityTypeName): Promise; /** * Ensure the entity directory exists, return its path. */ export declare function ensureEntityDir(entityType: EntityTypeName): Promise; /** * Parse a markdown file into an Entity (frontmatter + body content). * Supports both legacy format (all fields in frontmatter) and new format * (core fields only in frontmatter; domain fields in body prefix block). * Always returns a unified meta object with all fields merged. */ export declare function parseEntity(filepath: string, rawContent: string): { meta: Record; content: string; }; /** * Write an entity to a markdown file using the new simplified-frontmatter format. * Core fields (id, name, entityType, description, tags, created, updated) go in * YAML frontmatter. All domain fields (status, dueDate, priority, etc.) are * written as a key:value block at the top of the body. */ export declare function writeEntity(filepath: string, meta: Record, content: string): Promise; /** * Move an entity file to the trash instead of permanently deleting it. * Trash location: /.trash// * If a file with the same name exists in trash, appends a timestamp. */ export declare function trashEntity(filepath: string): Promise; /** * Find an entity by title or filename within a directory. */ export declare function findEntityByTitle(entityType: EntityTypeName, titleOrFilename: string): Promise<{ filepath: string; meta: Record; content: string; } | null>; /** * Full-text search across entities by title, tags, and body content. * Tokenizes query into words and scores matches: title=3pts, tag=2pts, body=1pt per token. * Only returns entities where ALL tokens match at least one field. */ export declare function searchEntities(query: string, entityType?: EntityTypeName, options?: { tags?: string[]; }): Promise<{ filepath: string; meta: Record; content: string; score: number; }[]>; /** * List all entities of a given type in the active project. * When `metaOnly: true` and the index is built, returns metadata from the in-memory * index without reading files from disk — O(1) instead of O(n) file reads. */ export declare function listEntities(entityType: EntityTypeName, options?: { tags?: string[]; metaOnly?: boolean; }): Promise<{ filepath: string; meta: Record; content: string; }[]>; //# sourceMappingURL=entity.d.ts.map