AX Agent 메모리 구조 1차 강화: 계층형 메모리 문서 로딩과 프롬프트 주입 추가
Some checks failed
Release Gate / gate (push) Has been cancelled

- AgentMemoryService에 관리형/사용자/프로젝트/로컬 메모리 문서 탐색을 추가해 AXMEMORY.md, AXMEMORY.local.md, .ax/rules/*.md 계층을 로드하도록 확장함

- ChatWindow 시스템 프롬프트 메모리 섹션을 계층형 메모리와 기존 학습 메모리를 함께 조립하는 구조로 재편함

- 작업 폴더 메모리 로드 전에 Count를 먼저 검사하던 경로를 제거해 다른 폴더 메모리 누락 가능성을 줄임

- 검증: dotnet build src/AxCopilot/AxCopilot.csproj -c Release -v minimal -p:OutputPath=bin\\verify\\ -p:IntermediateOutputPath=obj\\verify\\ (경고 0 / 오류 0)
This commit is contained in:
2026-04-06 23:40:35 +09:00
parent c75790f8c2
commit 13cd1e54ed
4 changed files with 168 additions and 18 deletions

View File

@@ -6101,36 +6101,56 @@ public partial class ChatWindow : Window
var app = System.Windows.Application.Current as App;
var memService = app?.MemoryService;
if (memService == null || memService.Count == 0) return "";
if (memService == null) return "";
// 메모리를 로드 (작업 폴더 변경 시 재로드)
memService.Load(workFolder ?? "");
var all = memService.All;
if (all.Count == 0) return "";
var layeredDocs = memService.InstructionDocuments;
if (all.Count == 0 && layeredDocs.Count == 0) return "";
var sb = new System.Text.StringBuilder();
sb.AppendLine("\n## 프로젝트 메모리 (이전 대화에서 학습한 내용)");
sb.AppendLine("아래는 이전 대화에서 학습한 규칙과 선호도입니다. 작업 시 참고하세요.");
sb.AppendLine("새로운 규칙이나 선호도를 발견하면 memory 도구의 save 액션으로 저장하세요.");
sb.AppendLine("사용자가 이전 학습 내용과 다른 지시를 하면 memory 도구의 delete 후 새로 save 하세요.\n");
sb.AppendLine("\n## 메모리 계층");
sb.AppendLine("다음 메모리는 claude-code와 비슷하게 관리형 → 사용자 → 프로젝트 → 로컬 순서로 조립됩니다.");
sb.AppendLine("현재 작업 디렉토리에 가까운 메모리가 더 높은 우선순위를 가집니다.\n");
foreach (var group in all.GroupBy(e => e.Type))
const int maxLayeredDocs = 8;
const int maxDocChars = 1800;
foreach (var doc in layeredDocs.Take(maxLayeredDocs))
{
var label = group.Key switch
{
"rule" => "프로젝트 규칙",
"preference" => "사용자 선호",
"fact" => "프로젝트 사실",
"correction" => "이전 교정",
_ => group.Key,
};
sb.AppendLine($"[{label}]");
foreach (var e in group.OrderByDescending(e => e.UseCount).Take(15))
sb.AppendLine($"- {e.Content}");
sb.AppendLine($"[{doc.Label}] {doc.Path}");
var text = doc.Content;
if (text.Length > maxDocChars)
text = text[..maxDocChars] + "\n...(생략)";
sb.AppendLine(text);
sb.AppendLine();
}
if (all.Count > 0)
{
sb.AppendLine("## 학습 메모리 (이전 대화에서 학습한 내용)");
sb.AppendLine("아래는 이전 대화에서 학습한 규칙과 선호도입니다. 작업 시 참고하세요.");
sb.AppendLine("새로운 규칙이나 선호도를 발견하면 memory 도구의 save 액션으로 저장하세요.");
sb.AppendLine("사용자가 이전 학습 내용과 다른 지시를 하면 memory 도구의 delete 후 새로 save 하세요.\n");
foreach (var group in all.GroupBy(e => e.Type))
{
var label = group.Key switch
{
"rule" => "프로젝트 규칙",
"preference" => "사용자 선호",
"fact" => "프로젝트 사실",
"correction" => "이전 교정",
_ => group.Key,
};
sb.AppendLine($"[{label}]");
foreach (var e in group.OrderByDescending(e => e.UseCount).Take(15))
sb.AppendLine($"- {e.Content}");
sb.AppendLine();
}
}
return sb.ToString();
}