trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
88 lines • 2.47 kB
TypeScript
/**
* Semantic Search Integration
*
* Connects the TrellisVcsEngine to the embedding system.
* Provides reindex (full rebuild) and search (query → ranked results).
* The embedder function is pluggable for testing with mock vectors.
*
* @see TRL-20
*/
import type { SearchOptions, SearchResult } from './types.js';
/** Minimal engine interface — avoids importing the full engine for testability */
export interface SearchableEngine {
getRootPath(): string;
trackedFiles(): Array<{
path: string;
contentHash?: string;
}>;
listIssues(filters?: any): Array<{
id: string;
title?: string;
description?: string;
}>;
listMilestones(): Array<{
id: string;
message?: string;
}>;
queryDecisions?(): Array<{
id: string;
toolName: string;
rationale?: string;
context?: string;
outputSummary?: string;
}>;
parseFile?(filePath: string): any;
}
/** Embedder function type — maps text → vector. Pluggable for testing. */
export type Embedder = (text: string) => Promise<Float32Array>;
export declare class EmbeddingManager {
private store;
private embedFn;
private constructor();
static create(dbPath: string, embedFn?: Embedder): Promise<EmbeddingManager>;
/**
* Full reindex: clear store, re-chunk all entities, embed, and insert.
*/
reindex(engine: SearchableEngine): Promise<{
chunks: number;
}>;
/**
* Incrementally index a single file (on file change).
*/
indexFile(filePath: string, content: string, engine?: SearchableEngine): Promise<number>;
/**
* Index an issue (on create/update).
*/
indexIssue(issue: {
id: string;
title?: string;
description?: string;
}): Promise<number>;
/**
* Index a milestone (on create).
*/
indexMilestone(milestone: {
id: string;
message?: string;
}): Promise<number>;
/**
* Semantic search: embed query → vector search → ranked results.
*/
search(query: string, opts?: SearchOptions): Promise<SearchResult[]>;
/**
* Remove all data for a file.
*/
removeFile(filePath: string): void;
/**
* Get store statistics.
*/
stats(): {
total: number;
byType: Record<string, number>;
};
/**
* Close the store.
*/
close(): void;
}
//# sourceMappingURL=search.d.ts.map