[RAG] Implement visual conflict and density metadata tags for enhanced context intelligence
This commit is contained in:
@@ -116,7 +116,12 @@ export function assembleContext(chunks: RetrievalChunk[]): string {
|
||||
for (const [source, groupChunks] of groups) {
|
||||
const label = sourceLabels[source] || source;
|
||||
const items = groupChunks
|
||||
.map((c) => `- ${c.title}: ${c.content}`)
|
||||
.map((c) => {
|
||||
const metadata = c.metadata;
|
||||
const conflictTag = metadata.conflictDetected ? ` [⚠️ CONFLICT: ${metadata.conflictSeverity}]` : '';
|
||||
const densityTag = metadata.informationDensity !== undefined ? ` (Density: ${metadata.informationDensity.toFixed(2)})` : '';
|
||||
return `- ${c.title}${conflictTag}${densityTag}: ${c.content}`;
|
||||
})
|
||||
.join('\n');
|
||||
sections.push(`### ${label}\n${items}`);
|
||||
}
|
||||
|
||||
@@ -138,21 +138,25 @@ export class RetrievalOrchestrator {
|
||||
.filter((s) => s.score > 0)
|
||||
.sort((a, b) => b.score - a.score)
|
||||
.slice(0, limit)
|
||||
.map((scored) => {
|
||||
const doc = documents[scored.index];
|
||||
.map((s) => {
|
||||
const doc = documents[s.index];
|
||||
const excerpt = extractBestExcerpt(doc.content, expandedTokens, 400);
|
||||
return {
|
||||
id: `brain-${scored.index}`,
|
||||
id: `brain-${s.index}`,
|
||||
source: 'brain-memory' as const,
|
||||
title: doc.relativePath,
|
||||
content: summarizeText(excerpt, 400),
|
||||
score: scored.score,
|
||||
score: s.score,
|
||||
tokenEstimate: estimateTokens(excerpt),
|
||||
metadata: {
|
||||
filePath: doc.filePath,
|
||||
category: this.inferCategory(doc.relativePath),
|
||||
isProjectEvidence: this.isProjectEvidence(doc.relativePath, doc.content),
|
||||
lastUpdated: doc.lastModified
|
||||
lastUpdated: doc.lastModified,
|
||||
// Phase 5: Scoring Intelligence Integration
|
||||
conflictDetected: s.conflictDetected,
|
||||
conflictSeverity: s.conflictSeverity,
|
||||
informationDensity: s.informationDensity
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user