Files
tkmind_go/services/ask-ai-bot/utils/ai/tool-tracker.ts
T
BestCodes 849cc60fbc feat: ask ai discord bot (#6842)
Signed-off-by: The-Best-Codes <bestcodes.official@gmail.com>
2026-02-02 22:11:28 +00:00

40 lines
1.3 KiB
TypeScript

export class ToolTracker {
private searchCalls: number = 0;
private searchResults: Set<string> = new Set();
private viewedPaths: Set<string> = new Set();
recordSearchCall(results: string[]): void {
this.searchCalls++;
results.forEach((result) => this.searchResults.add(result));
}
recordViewCall(filePaths: string | string[]): void {
const paths = Array.isArray(filePaths) ? filePaths : [filePaths];
paths.forEach((path) => this.viewedPaths.add(path));
}
getSummary(): string {
const parts: string[] = [];
if (this.searchCalls > 0) {
const resultCount = this.searchResults.size;
const timesText = this.searchCalls === 1 ? "time" : "times";
const resultsText = resultCount === 1 ? "result" : "results";
parts.push(
`searched ${this.searchCalls} ${timesText} with ${resultCount} ${resultsText}`,
);
}
if (this.viewedPaths.size > 0) {
const pageCount = this.viewedPaths.size;
const pagesText = pageCount === 1 ? "page" : "pages";
parts.push(`viewed ${pageCount} ${pagesText}`);
}
if (parts.length === 0) return "";
const firstPart = parts[0].charAt(0).toUpperCase() + parts[0].slice(1);
return parts.length === 1 ? firstPart : firstPart + ", " + parts[1];
}
}