메모리 적용 근거 표시와 감사/명령 UX 마무리

- Cowork와 Code 진행 표시 줄에 메모리 규칙 및 학습 메모리 적용 근거를 함께 노출
- include 감사 로그 최근 3일 필터와 보관 시점 판정을 정리해 메모리 감사 상태를 더 정확히 표시
- /memory list 및 search 출력 형식을 우선순위·레이어·설명·paths·tags 중심으로 재구성하고 Release 빌드 경고/오류 0 검증
This commit is contained in:
2026-04-07 06:40:18 +09:00
parent fe843fb314
commit a35c47ed32
7 changed files with 88 additions and 20 deletions

View File

@@ -106,13 +106,7 @@ public class MemoryTool : IAgentTool
{
sb.AppendLine($"계층형 메모리 {docs.Count}개:");
foreach (var doc in docs)
{
var priority = doc.Priority > 0 ? $" (우선순위 {doc.Priority})" : "";
var suffix = string.IsNullOrWhiteSpace(doc.Description) ? "" : $" — {doc.Description}";
var scopeHint = doc.Paths.Count > 0 ? $" (paths: {string.Join(", ", doc.Paths)})" : "";
var tags = doc.Tags.Count > 0 ? $" (tags: {string.Join(", ", doc.Tags)})" : "";
sb.AppendLine($" [{doc.Label}] {doc.Path}{priority}{suffix}{scopeHint}{tags}");
}
sb.AppendLine(FormatInstructionDocument(doc));
sb.AppendLine();
}
@@ -137,13 +131,7 @@ public class MemoryTool : IAgentTool
{
sb.AppendLine($"계층형 메모리 파일 {docs.Count}개:");
foreach (var doc in docs)
{
var priority = doc.Priority > 0 ? $" (우선순위 {doc.Priority})" : "";
var suffix = string.IsNullOrWhiteSpace(doc.Description) ? "" : $" — {doc.Description}";
var scopeHint = doc.Paths.Count > 0 ? $" (paths: {string.Join(", ", doc.Paths)})" : "";
var tags = doc.Tags.Count > 0 ? $" (tags: {string.Join(", ", doc.Tags)})" : "";
sb.AppendLine($" • [{doc.Label}] {doc.Path}{priority}{suffix}{scopeHint}{tags}");
}
sb.AppendLine(FormatInstructionDocument(doc));
sb.AppendLine();
}
@@ -217,4 +205,21 @@ public class MemoryTool : IAgentTool
return ToolResult.Ok($"메모리 파일 경로: {path}\n\n{content}");
}
private static string FormatInstructionDocument(MemoryInstructionDocument doc)
{
var meta = new List<string>
{
doc.Priority > 0 ? $"우선순위 {doc.Priority}" : "우선순위 미정",
$"layer: {doc.Layer}"
};
if (!string.IsNullOrWhiteSpace(doc.Description))
meta.Add(doc.Description);
if (doc.Paths.Count > 0)
meta.Add($"paths: {string.Join(", ", doc.Paths)}");
if (doc.Tags.Count > 0)
meta.Add($"tags: {string.Join(", ", doc.Tags)}");
return $" • [{doc.Label}] {doc.Path}\n {string.Join(" · ", meta)}";
}
}

View File

@@ -87,6 +87,24 @@ public static class AuditLogService
return LoadFile(Path.Combine(AuditDir, fileName));
}
/// <summary>최근 N일 내 특정 액션 감사 로그를 최신순으로 읽습니다.</summary>
public static List<AuditEntry> LoadRecent(string action, int maxCount = 20, int daysBack = 3)
{
var since = DateTime.Now.Date.AddDays(-Math.Max(0, daysBack - 1));
var entries = new List<AuditEntry>();
for (var day = DateTime.Now.Date; day >= since; day = day.AddDays(-1))
{
entries.AddRange(LoadDate(day)
.Where(x => string.Equals(x.Action, action, StringComparison.OrdinalIgnoreCase)));
}
return entries
.OrderByDescending(x => x.Timestamp)
.Take(Math.Max(1, maxCount))
.ToList();
}
private static List<AuditEntry> LoadFile(string filePath)
{
var entries = new List<AuditEntry>();
@@ -112,7 +130,7 @@ public static class AuditLogService
var cutoff = DateTime.Now.AddDays(-retentionDays);
foreach (var f in Directory.GetFiles(AuditDir, "*.json"))
{
if (File.GetCreationTime(f) < cutoff)
if (File.GetLastWriteTime(f) < cutoff)
File.Delete(f);
}
}

View File

@@ -188,6 +188,15 @@ public partial class ChatWindow
stack.Children.Add(bodyBlock);
}
var memoryEvidence = BuildMemoryContextEvidenceText();
if (!string.IsNullOrWhiteSpace(memoryEvidence))
{
var memoryBlock = CreateProcessFeedBody(memoryEvidence, secondaryText);
memoryBlock.Margin = new Thickness(28, 2, 12, 8);
memoryBlock.Opacity = 0.92;
stack.Children.Add(memoryBlock);
}
if (!string.IsNullOrWhiteSpace(evt.FilePath))
{
var compactPathRow = new StackPanel

View File

@@ -381,6 +381,27 @@ public partial class ChatWindow
};
}
private string? BuildMemoryContextEvidenceText()
{
if (_activeTab == "Chat")
return null;
var app = System.Windows.Application.Current as App;
var memory = app?.MemoryService;
if (memory == null || !_settings.Settings.Llm.EnableAgentMemory)
return null;
memory.Load(GetCurrentWorkFolder());
var docs = memory.InstructionDocuments;
var learned = memory.All.Count;
if (docs.Count == 0 && learned == 0)
return null;
var labels = docs.Take(2).Select(x => x.Label).ToList();
var labelText = labels.Count == 0 ? "" : $" · {string.Join(", ", labels)}";
return $"메모리 규칙 {docs.Count}개 · 학습 {learned}개 적용 중{labelText}";
}
private void UpdateSelectedPresetGuide(ChatConversation? conversation = null)
{
if (SelectedPresetGuide == null || SelectedPresetGuideTitle == null || SelectedPresetGuideDesc == null)

View File

@@ -3240,9 +3240,7 @@ public partial class SettingsWindow : Window
TxtMemoryOverviewScopes.Text = string.Join("\n", lines);
}
var includeEntries = AuditLogService.LoadToday()
.Where(x => string.Equals(x.Action, "MemoryInclude", StringComparison.OrdinalIgnoreCase))
.OrderByDescending(x => x.Timestamp)
var includeEntries = AuditLogService.LoadRecent("MemoryInclude", maxCount: 3, daysBack: 3)
.Take(3)
.Select(x =>
{
@@ -3252,8 +3250,8 @@ public partial class SettingsWindow : Window
.ToList();
TxtMemoryOverviewAudit.Text = includeEntries.Count == 0
? "최근 include 감사 기록이 없습니다."
: "최근 include 감사\n" + string.Join("\n", includeEntries);
? "최근 3일 include 감사 기록이 없습니다."
: "최근 3일 include 감사\n" + string.Join("\n", includeEntries);
}
// ─── 에이전트 훅 관리 ─────────────────────────────────────────────────