/** * Project Memory Types * * Types for project-level instruction loading from markdown files. * Supports various LLM-specific naming conventions (CLAUDE.md, GEMINI.md, etc.) * as well as generic names (PROJECT.md, INSTRUCTIONS.md, AI.md). */ /** * LLM provider name for memory file discovery. * * Common values: 'claude', 'gemini', 'openai', 'gpt', 'copilot', 'cursor', 'codeium', 'anthropic' * * Can be any string to support custom providers - patterns will be generated * automatically (e.g., 'myai' -> MYAI.md, .myai.md, .myai/instructions.md) */ export type LLMProviderName = string; /** * A loaded memory file with its content and metadata */ export interface MemoryFile { /** Absolute path to the file */ path: string; /** File content */ content: string; /** Relative path from the search root */ relativePath: string; /** The pattern that matched this file */ matchedPattern: string; /** File size in bytes */ size: number; /** Last modified timestamp */ modifiedAt: Date; } /** * Result of loading project memory */ export interface ProjectMemory { /** All loaded memory files */ files: MemoryFile[]; /** Combined content from all files */ content: string; /** The root directory where search started */ rootDir: string; /** Total token estimate (tiktoken cl100k_base) */ estimatedTokens: number; } /** * File pattern configuration for discovery */ export interface FilePattern { /** Glob pattern or exact filename */ pattern: string; /** Priority (lower = higher priority, loaded first) */ priority: number; /** Description of what this pattern matches */ description?: string; } /** * Strategy for combining multiple memory files */ export type CombineStrategy = 'concat' | 'priority' | 'dedupe'; /** * Options for ProjectMemoryLoader */ export interface ProjectMemoryOptions { /** * LLM provider name(s) to search for * E.g., 'claude' will search for CLAUDE.md, .claude.md, .claude/instructions.md * Can be a single provider or array for multi-provider support * @default 'claude' */ providers?: LLMProviderName | LLMProviderName[]; /** * Whether to include generic memory files (PROJECT.md, INSTRUCTIONS.md, AI.md) * @default true */ includeGeneric?: boolean; /** * Additional custom file patterns to search for */ customPatterns?: FilePattern[]; /** * Whether to search parent directories up to the root * @default true */ searchParents?: boolean; /** * Maximum number of parent directories to traverse * @default 10 */ maxParentDepth?: number; /** * Stop searching parents when finding a git root (.git directory) * @default true */ stopAtGitRoot?: boolean; /** * Strategy for combining multiple memory files * @default 'concat' */ combineStrategy?: CombineStrategy; /** * Separator to use between files when combining * @default '\n\n---\n\n' */ separator?: string; /** * Maximum total content size in characters * Files are loaded in priority order until limit is reached * @default 100000 (100KB) */ maxContentSize?: number; /** * Whether to include file path headers in combined content * @default true */ includeHeaders?: boolean; /** * Header format template. Use {path} for file path, {relativePath} for relative path * @default '# From: {relativePath}\n\n' */ headerFormat?: string; /** * File encoding * @default 'utf-8' */ encoding?: BufferEncoding; } /** * Event types for ProjectMemoryLoader */ export type ProjectMemoryEventType = 'memory:search_start' | 'memory:file_found' | 'memory:file_loaded' | 'memory:file_skipped' | 'memory:search_complete' | 'memory:error'; /** * Events emitted during memory loading */ export type ProjectMemoryEvent = { type: 'memory:search_start'; rootDir: string; patterns: string[]; } | { type: 'memory:file_found'; path: string; pattern: string; } | { type: 'memory:file_loaded'; file: MemoryFile; } | { type: 'memory:file_skipped'; path: string; reason: string; } | { type: 'memory:search_complete'; memory: ProjectMemory; } | { type: 'memory:error'; error: Error; path?: string; }; /** * Event handler for project memory events */ export type ProjectMemoryEventHandler = (event: ProjectMemoryEvent) => void; /** * Result of checking for memory files without loading content */ export interface MemoryDiscoveryResult { /** Paths to discovered memory files */ paths: string[]; /** Whether any memory files were found */ found: boolean; /** The patterns that matched */ matchedPatterns: string[]; } /** * Built-in provider patterns */ export interface ProviderPatterns { /** Provider name */ provider: LLMProviderName; /** File patterns for this provider (ordered by priority) */ patterns: FilePattern[]; }