feat(rules): add shared rules-core package

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-18 21:18:56 +09:00
parent 472c293141
commit fb7d47f1b7
16 changed files with 909 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import type { AgentsMdCache, DirectoryScanEntry, RuleFileCandidate, RuleScanCache, RuleScanCacheStats } from "./types";
export function createRuleScanCache(): RuleScanCache {
const candidateCache = new Map<string, readonly RuleFileCandidate[]>();
const directoryCache = new Map<string, readonly DirectoryScanEntry[]>();
return {
get: (key) => candidateCache.get(key),
set: (key, value) => candidateCache.set(key, value),
getDirScan: (dir) => directoryCache.get(dir),
setDirScan: (dir, entries) => directoryCache.set(dir, entries),
stats: (): RuleScanCacheStats => ({ candidateEntries: candidateCache.size, directoryEntries: directoryCache.size }),
clear: () => {
candidateCache.clear();
directoryCache.clear();
},
};
}
export function createAgentsMdCache(): AgentsMdCache {
const cache = new Map<string, readonly string[]>();
return {
get: (key) => cache.get(key),
set: (key, value) => cache.set(key, value),
clear: () => cache.clear(),
};
}