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

Function createMapSlice

core/map/index.js:569–593  ·  view source on GitHub ↗
(index, queryStr, options = {})

Source from the content-addressed store, hash-verified

567}
568
569function createMapSlice(index, queryStr, options = {}) {
570 const maxFiles = options.maxFiles || 15;
571 const results = queryMapIndex(index, queryStr, maxFiles);
572 const lines = [`=== MAP SLICE: ${queryStr} ===`];
573
574 if (detectLikelyStale(index)) {
575 lines.push(`Generated: ${index.generatedAt || index.generated || 'unknown'} (staleness requires --stale check)`);
576 } else {
577 lines.push(`Generated: ${index.generatedAt || index.generated || 'unknown'}`);
578 }
579
580 if (index.verificationCommands && index.verificationCommands.length > 0) {
581 lines.push(`Verification: ${index.verificationCommands.slice(0, 8).join(' | ')}`);
582 }
583
584 for (const result of results) {
585 const exportsStr = result.exports.length > 0 ? ` [${result.exports.slice(0, 5).join(', ')}]` : '';
586 const routesStr = result.routes.length > 0 ? ` routes=${result.routes.slice(0, 3).join(',')}` : '';
587 lines.push(`${String(result.score).padStart(3)} ${String(result.role || '').padEnd(10)} ${result.relPath}${exportsStr}${routesStr} (${result.lines}L)`);
588 }
589
590 if (results.length === 0) lines.push('No matching files.');
591 lines.push('=== END MAP SLICE ===');
592 return lines.join('\n');
593}
594
595function detectLikelyStale(index) {
596 return !index.sourceSignature || !index.sourceHashes;

Callers 3

readMapSliceFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 2

queryMapIndexFunction · 0.85
detectLikelyStaleFunction · 0.85

Tested by

no test coverage detected