peterfei/ai-agent-team / .claude/skills/thread-manager
thread-manager
Flaggedsrc/core/vector-search-engine.ts
View on GitHubimport { cosineSimilarity } from './vector-utils';
export interface SearchResult<T> {
id: string;
score: number;
payload?: T;
}
export interface SearchOptions<T> {
topK?: number;
minScore?: number;
filter?: (item: SearchItem<T>) => boolean;
}
export interface SearchItem<T> {
id: string;
vector: number[];
payload?: T;
}
/**
* Vector Search Engine (In-memory implementation for Phase 1)
*/
export class VectorSearchEngine {
/**
* Brute-force search for Top-K similar vectors
*/
search<T>(
query: number[],
corpus: SearchItem<T>[],
options: SearchOptions<T> = {}
): SearchResult<T>[] {
const { topK = 10, minScore = 0, filter } = options;
// 1. Calculate similarities
let scored = corpus.map(item => ({
...item,
score: cosineSimilarity(query, item.vector)
}));
// 2. Apply filter
if (filter) {
scored = scored.filter(filter);
}
// 3. Apply min score threshold
scored = scored.filter(item => item.score >= minScore);
// 4. Sort and take Top-K
scored.sort((a, b) => b.score - a.score);
const topResults = scored.slice(0, topK);
return topResults.map(({ id, score, payload }) => ({
id,
score,
payload
}));
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |