MCPcopy Create free account
hub / github.com/SethGammon/Citadel / loadMemoryBlocks

Function loadMemoryBlocks

core/memory/blocks.js:263–278  ·  view source on GitHub ↗
(projectRoot, filters = {})

Source from the content-addressed store, hash-verified

261}
262
263function loadMemoryBlocks(projectRoot, filters = {}) {
264 const dir = blocksDir(projectRoot);
265 if (!fs.existsSync(dir)) return [];
266 const query = filters.query
267 ? String(filters.query).toLowerCase().split(/\s+/).map((term) => term.trim()).filter(Boolean)
268 : null;
269 const scope = filters.scope ? String(filters.scope).toLowerCase() : null;
270 const type = filters.type ? String(filters.type).toLowerCase() : null;
271 return fs.readdirSync(dir)
272 .filter((entry) => entry.endsWith('.json'))
273 .map((entry) => readBlockFile(path.join(dir, entry)))
274 .filter((entry) => !type || entry.type === type)
275 .filter((entry) => !scope || entry.scope.some((item) => String(item).toLowerCase().includes(scope)))
276 .filter((entry) => !query || query.every((term) => JSON.stringify(entry).toLowerCase().includes(term)))
277 .sort((a, b) => a.id.localeCompare(b.id));
278}
279
280function isOlderThan(dateString, days, now = new Date()) {
281 const time = Date.parse(dateString);

Callers 3

lintMemoryBlocksFunction · 0.85
mainFunction · 0.85

Calls 2

blocksDirFunction · 0.85
readBlockFileFunction · 0.85

Tested by

no test coverage detected