trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
55 lines • 1.9 kB
TypeScript
/**
* Bidirectional Reference Index
*
* Builds and maintains a bidirectional index of [[...]] references:
* - outgoing: source file → EntityRefs it contains
* - incoming: target entity ID → RefSources that reference it
*
* Supports incremental updates when files change.
*
* @see TRL-13
*/
import type { EntityRef, RefIndex, RefSource } from './types.js';
import type { ResolverContext } from './resolver.js';
/**
* Build a complete RefIndex by scanning all provided file contents.
*/
export declare function buildRefIndex(files: Array<{
path: string;
content: string;
}>, ctx: ResolverContext): RefIndex;
/**
* Update the index for a single file that was added or modified.
* Removes old entries for the file, then re-parses and re-indexes.
*/
export declare function updateFileInIndex(index: RefIndex, filePath: string, content: string, ctx: ResolverContext): void;
/**
* Remove all refs originating from a file (e.g. when the file is deleted).
*/
export declare function removeFileFromIndex(index: RefIndex, filePath: string): void;
/**
* Get all outgoing refs from a file.
*/
export declare function getOutgoingRefs(index: RefIndex, filePath: string): EntityRef[];
/**
* Get all incoming refs (backlinks) for an entity.
* Accepts either a raw entity ID (e.g. "issue:TRL-5") or a target string.
*/
export declare function getBacklinks(index: RefIndex, entityId: string): RefSource[];
/**
* Get all entity IDs that have at least one backlink.
*/
export declare function getReferencedEntities(index: RefIndex): string[];
/**
* Get all files that contain at least one ref.
*/
export declare function getFilesWithRefs(index: RefIndex): string[];
/**
* Get total counts for the index.
*/
export declare function getIndexStats(index: RefIndex): {
totalFiles: number;
totalRefs: number;
totalEntities: number;
};
//# sourceMappingURL=ref-index.d.ts.map