/** * KnowledgeGraph — The unified knowledge layer for Eddie's Brain * * Composes ComponentIndex, TokenTaxonomy, RelationshipMap, and LearningHistory * into a single queryable knowledge base about the Eddie Design System. */ import type { AntiPattern, ComponentEntry, CompositionRecipe, LearningEntry, TokenEntry } from '../types.js'; import { ComponentIndex } from './component-index.js'; import { LearningHistory } from './learning-history.js'; import { RelationshipMap } from './relationship-map.js'; import { TokenTaxonomy } from './token-taxonomy.js'; import { UtilityIndex, type UtilityEntry } from './utility-index.js'; export interface KnowledgeGraphData { components: Record; tokens: Record; recipes: Record; learnings: LearningEntry[]; metadata: { builtAt: string; version: string; }; } export declare class KnowledgeGraph { readonly componentIndex: ComponentIndex; readonly tokenTaxonomy: TokenTaxonomy; readonly relationshipMap: RelationshipMap; readonly learningHistory: LearningHistory; /** The ed-u-* utility classes, searchable since #936/#1647. */ readonly utilityIndex: UtilityIndex; private initialized; constructor(componentIndex?: ComponentIndex, tokenTaxonomy?: TokenTaxonomy, relationshipMap?: RelationshipMap, learningHistory?: LearningHistory); /** * Initialize the knowledge graph by building all indexes. * * **The component index is NOT built here.** Pass a populated one to the * constructor — `new KnowledgeGraph(await new ComponentIndexBuilder().build(rootDir))` * — as `cli/brain.ts` does. * * That is deliberate and load-bearing (#1736). Parsing components requires * the TypeScript compiler, and the serverless MCP bundle is produced by * walking the STATIC import graph: if this module referenced the builder, * every consumer of `KnowledgeGraph` would drag 12.26 MB of compiler into * the deployed function. That is what happened, and #1732 is what it cost. * The MCP only ever calls `KnowledgeGraph.fromJSON`, so it must never reach * a parser. * * Called with a default-constructed graph, this leaves the component index * empty rather than populating it. */ init(rootDir: string): Promise; /** * Check if the graph is initialized */ isInitialized(): boolean; /** * Get a quick summary of what the knowledge graph contains */ getSummary(): { components: { total: number; byAtomicLevel: { atoms: number; molecules: number; organisms: number; recipes: number; pages: number; }; }; tokens: { total: number; themes: string[]; /** * Variant themes and the parent they inherit from. A variant's source * carries colors and nothing else — change a non-color token in the * parent, never the variant. */ themeParents: Record; byTier: { definition: number; usage: number; component: number; }; }; recipes: { total: number; canonical: number; candidate: number; deprecated: number; }; learning: { total: number; stats: { totalSuggestions: number; acceptanceRate: number; rejectionRate: number; modificationRate: number; acceptedCount: number; rejectedCount: number; modifiedCount: number; accuracyTrend: { week: string; accuracy: number; }[]; mostRejectedType: string; mostAcceptedType: string; }; }; }; /** * Find components that use a specific token */ findComponentsUsingToken(tokenName: string): ComponentEntry[]; /** * Search across all indexes (components, recipes, and boilerplates) */ search(query: string, brainDir?: string): { components: ComponentEntry[]; recipes: CompositionRecipe[]; boilerplates: Array<{ name: string; slug: string; description: string; stack: string; useCase: string; }>; utilities: UtilityEntry[]; }; /** * Serialize the entire knowledge graph to JSON */ /** * Every anti-pattern in the graph (#1888), aggregated from the components * that author them, sorted by id. Two components declaring the same * selector is a build failure: the dataset needs one owner per rule. */ get antiPatterns(): AntiPattern[]; toJSON(): KnowledgeGraphData; /** * Deserialize from JSON */ static fromJSON(data: KnowledgeGraphData): KnowledgeGraph; /** * Save the knowledge graph to disk. * * Idempotent on content: a file is only rewritten if its new serialized * content differs from what's already on disk. For `metadata.json`, the * `builtAt` timestamp is preserved when no other file changed — so * repeated `brain init` runs on unchanged sources produce zero git diff * rather than a 2-line timestamp churn on every build. * * If any of the content-bearing files (components, tokens, recipes, * learning) did change, `builtAt` is updated to the fresh timestamp * from `toJSON()`. */ save(dir: string): Promise; /** * Load the knowledge graph from disk */ static load(dir: string): Promise; } //# sourceMappingURL=index.d.ts.map