feat: v2.62.0 - Astra Autonomous Loop (AAL) foundation & enhanced file analysis

This commit is contained in:
g1nation
2026-05-04 12:58:43 +09:00
parent 445d530b63
commit 215c5f9457
23 changed files with 2964 additions and 62 deletions
+18 -3
View File
@@ -95,7 +95,15 @@ export function buildSecondBrainTrace(userQuery: string, brainRoot: string, opti
const slotSelections = knowledgeSlots.map((slot) => {
const slotTerms = tokenize(slot.retrievalQuery);
const slotCandidates = files
.map((file) => scoreFile(file, brainRoot, slotTerms, queryIntent, targetProject))
.map((file) => {
const doc = scoreFile(file, brainRoot, slotTerms, queryIntent, targetProject);
// 슬롯 ID와 문서 디렉토리명 매칭 보너스 (e.g. ontology 슬롯 → Ontology/ 디렉토리)
const dirName = path.dirname(doc.path).toLowerCase();
if (dirName.includes(slot.id.toLowerCase())) {
doc.score = Number((doc.score + 0.5).toFixed(2));
}
return doc;
})
.filter((doc) => doc.score >= 0.25)
.sort((a, b) => b.score - a.score);
const materialCandidates = slotCandidates.filter((doc) => doc.knowledgeRole !== 'routing-hint');
@@ -581,7 +589,9 @@ function scoreFile(file: string, brainRoot: string, terms: string[], intent: Sec
score += projectRelevanceScore(relative, lower, targetProject, documentProject);
}
const expandedTerms = expandQuery(terms);
const scoredTfIdf = scoreTfIdf(expandedTerms, [{ title, content, lastModified: Date.now() }])[0];
// 디렉토리 경로를 title에 포함하여 카테고리 키워드 매칭 향상 (e.g. Ontology/ → 'ontology' 토큰)
const titleWithPath = `${relative.replace(/[\\/]/g, ' ')} ${title}`;
const scoredTfIdf = scoreTfIdf(expandedTerms, [{ title: titleWithPath, content, lastModified: Date.now() }])[0];
score += scoredTfIdf.score;
@@ -595,7 +605,8 @@ function scoreFile(file: string, brainRoot: string, terms: string[], intent: Sec
title,
path: relative,
absolutePath: file,
score: Number((Math.max(score, 0) / Math.max(expandedTerms.length, 1)).toFixed(2)),
// sqrt 정규화: 동의어 확장으로 분모가 과도하게 커지는 것을 방지
score: Number((Math.max(score, 0) / Math.max(Math.sqrt(expandedTerms.length), 1)).toFixed(2)),
excerpt: summarizeText(finalExcerpt, 420),
sourceType,
knowledgeRole,
@@ -679,6 +690,10 @@ function pathPriority(relativePath: string, intent: SecondBrainQueryIntent): num
if (/adr-\d+|decision|설계|원칙|principle|mvp|dependency|schema|documentation/i.test(normalized)) {
score += 1.5;
}
// 지식 카테고리 디렉토리 보너스 (knowledge slot 매칭 지원)
if (/(^|[\\/])(strategy|ontology|writing|technical|evidence|insight|information|domain)([\\/]|$)/i.test(normalized)) {
score += 1.5;
}
if (/(^|[\\/])(00_raw|raw-data|conversations?|transcripts?)([\\/]|$)/i.test(normalized)) {
score -= 4;
}