Commit Graph

8 Commits

Author SHA1 Message Date
f1b1f1604c [Phase 17-E] 계층 메모리/컨텍스트 고도화 — AgentLoopService 통합
AgentLoopService.Memory.cs (신규, 105줄):
- InjectHierarchicalMemoryAsync(): 세션 시작 시 4-layer 계층 메모리 수집
  (Managed→User→Project→Local AX.md + rules/*.md)
  AxMdIncludeResolver.ResolveAsync()로 @include 지시어 최대 5단계 재귀 해석
  40,000자 초과 시 크기 경고, 마커 기반 in-place 교체(중복 방지)
- InjectPathScopedRulesAsync(): 파일 도구 실행 후 .ax/rules/*.md paths: 프론트매터
  기반 경로 범위 규칙 주입. workFolder별 PathScopedRuleInjector 캐시 적용

AgentLoopService.cs (편집):
- Phase 17-A(Reflexion) 이후 await InjectHierarchicalMemoryAsync() 호출 추가

AgentLoopService.Execution.cs (편집):
- InjectPathBasedSkills() 이후 InjectPathScopedRulesAsync() fire-and-forget 추가

AppSettings.LlmSettings.cs (편집):
- EnableMemorySystem 설정 추가 (기본 true, json: "enableMemorySystem")

docs/AGENT_ROADMAP.md:
- Group E 완료 표시 + 구현 내역 기록 (17-E1/E2 완료, 17-E3 차기)

빌드: 경고 0, 오류 0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 00:56:49 +09:00
1313c65e5e [Phase 17-D] 스킬 시스템 고도화 — paths:glob 자동주입 + context:fork 격리 실행
AgentLoopService.Skills.cs (신규, 95줄):
- InjectPathBasedSkills(): 파일 도구 성공 후 filePath로 GlobMatcher 매칭
  → 매칭 스킬 시스템 프롬프트를 시스템 메시지에 in-place 주입
  → SkillActivated JSONL 이벤트 로그 기록
- RunSkillInForkAsync(): context:fork 스킬 격리 LLM 실행 (도구 없음)
  → SkillCompleted JSONL 이벤트 로그 기록

SkillManagerTool.cs:
- SetForkRunner(Func<SkillDefinition, string, CancellationToken, Task<string>>) 추가
- exec 액션 + arguments 파라미터 추가
- ExecSkillAsync(): PrepareSkillBodyAsync 인자 치환
  → IsForkContext=true: fork runner 호출 → [Fork 스킬 결과] 반환
  → 일반 스킬: 시스템 프롬프트 + 준비된 본문 반환

AgentLoopService.cs:
- 생성자: SkillManagerTool.SetForkRunner(RunSkillInForkAsync) 주입

AgentLoopService.Execution.cs:
- 도구 성공 직후 InjectPathBasedSkills(result.FilePath, messages) 호출

빌드: 경고 0, 오류 0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 00:39:25 +09:00
0a58419c8a [Phase 17-C] 훅 시스템 고도화 — 11종 이벤트 연결 + Prompt 모드 구현
AppSettings.AgentConfig.cs:
- ExtendedHooksConfig에 4개 이벤트 추가:
  preToolUse, postToolUse, postToolUseFailure, agentStop

AgentLoopService.ExtendedHooks.cs (신규, 150줄):
- RunExtendedEventAsync(): 이벤트 훅 실행, 결과(additionalContext) 시스템 메시지 주입, HookFired 이벤트 로그
- GetExtendedHooks(): 설정에서 HookEventKind별 런타임 엔트리 조회
- ConvertToRuntimeEntries(): ExtendedHookEntryConfig → ExtendedHookEntry 변환
- ApplyExtendedHookResult(): additionalContext in-place 주입 (marker 기반 교체)

ExtendedHookRunner.cs:
- RunEventAsync() / ExecuteSingleAsync()에 LlmService? llm 파라미터 추가
- RunPromptHookAsync() 신규: {{tool_name/input/output/user_message/event/session_id}} 치환
  → LLM 호출 → block/deny/차단 감지 시 Block=true 반환
- using AxCopilot.Models 추가

AgentLoopService.cs:
- SessionStart 훅 (fire-and-forget, TaskState init 직후)
- UserPromptSubmit 훅 (동기, Block=true 시 즉시 반환 "⚠ 훅 정책에 의해 차단")
- PreCompact 훅 (적극적 압축 직전, 동기)
- PostCompact 훅 × 2 (기본/적극적 압축 완료 후, fire-and-forget)
- SessionEnd + AgentStop 훅 (finally 블록, fire-and-forget)

AgentLoopService.Execution.cs:
- RunToolHooksAsync() 개선: 레거시 AgentHookRunner 유지
  + ExtendedHookRunner PreToolUse/PostToolUse/PostToolUseFailure 추가
이벤트 커버리지: 11종 완전 연결. Agent 모드는 Phase 18-A 예정.
빌드: 경고 0, 오류 0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 00:14:19 +09:00
2383b1e220 [Phase 17-B] TaskState Working Memory + 이벤트 로그 완전 통합
AgentLoopService.TaskState.cs (신규, 96줄):
- InitTaskStateAsync(): 세션 시작 시 TaskStateService 초기화, 현재 작업 기록
- TrackToolFile(): 도구 성공 시 파일 경로 참조 목록 추가 (fire-and-forget)
- InjectTaskStateContext(): 압축 전 Working Memory를 시스템 메시지에 in-place 주입
  (## 현재 작업 상태 마커로 기존 섹션 탐지·교체 → 중복 방지)
- UpdateTaskStateSummaryAsync(): 압축 완료 후 컨텍스트 요약 갱신 (fire-and-forget)

AgentLoopService.cs:
- userQuery 선언 후 UserMessage 이벤트 기록 + InitTaskStateAsync() 호출
- 압축 블록: InjectTaskStateContext() 호출 (압축 전 Working Memory 주입)
- 기본 압축 완료 시: CompactionCompleted 이벤트 + UpdateTaskStateSummaryAsync()
- 적극적 압축 트리거 시: CompactionTriggered 이벤트 (usagePct 포함)
- LLM 텍스트 응답 후: AssistantMessage 이벤트 기록 (length, hasToolCalls)

AgentLoopService.Execution.cs:
- 도구 성공(state.ConsecutiveErrors = 0) 직후 TrackToolFile(result.FilePath) 호출

이벤트 커버리지: SessionStart/End·UserMessage·AssistantMessage·
ToolRequest·ToolResult·CompactionTriggered·CompactionCompleted 전 구간 기록
저장: %APPDATA%\AxCopilot\sessions\{sessionId}\{task_state.json, events.jsonl}
빌드: 경고 0, 오류 0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 23:22:40 +09:00
90d5943327 [Phase 17-A] Reflexion 자기성찰 메모리 시스템 구현
ReflexionEvaluatorService 신규 구현 (ReflexionService.cs):
- LLM 기반 자기평가: 완성도 점수(0~1), 강점/약점/교훈 추출
- $$raw string 평가 프롬프트로 JSON 포맷 안전하게 삽입
- JSON 블록 추출 + 역직렬화, LLM 실패 시 규칙 기반 폴백 엔트리
- ReflexionRepository.BuildContextPromptAsync() maxEntries 파라미터 추가

AgentLoopService.Reflexion.cs (신규, 82줄):
- InjectReflexionContextAsync(): 세션 시작 전 과거 교훈→시스템 메시지 주입
- FireAndForgetReflexionEval(): 세션 완료 후 Task.Run 비동기 자기평가 저장
- 지연 초기화(_reflexionRepo, _reflexionEval): 사용 시점에 생성

AgentLoopService.cs 통합 포인트 2개 추가:
- RunAsync() 루프 시작 전: await InjectReflexionContextAsync()
- finally 블록 통계 섹션: FireAndForgetReflexionEval() 호출

AgentSettingsPanel — 자기성찰 메모리 섹션 추가:
- 활성화 토글(ChkReflexionEnabled)
- 성공 세션만 평가 토글(ChkReflexionSuccessOnly)
- 최대 참고 교훈 수 슬라이더(1~20, 기본값 5)
- LoadFromSettings() 초기화 + 3개 이벤트 핸들러

빌드: 경고 0, 오류 0
2026-04-03 23:07:59 +09:00
aa907d7b79 [Phase46] 대형 파일 분할 리팩터링 2차 — 19개 신규 파셜 파일 생성
## 분할 대상 및 결과

### AgentLoopService.cs (1,334줄 → 846줄)
- AgentLoopService.HtmlReport.cs (151줄): AutoSaveAsHtml, ConvertTextToHtml, EscapeHtml
- AgentLoopService.Verification.cs (349줄): 도구 분류 판별 + RunPostToolVerificationAsync + EmitEvent + CheckDecisionRequired + FormatToolCallSummary

### ChatWindow 분할 (8개 신규 파셜 파일)
- ChatWindow.PlanViewer.cs (474줄): 계획 뷰어 — AddPlanningCard, AddDecisionButtons, CollapseDecisionButtons, ShowPlanButton 등 8개 메서드
- ChatWindow.EventBanner.cs (411줄): AddAgentEventBanner, BuildFileQuickActions
- ChatWindow.TaskDecomposition.cs (1,170줄 → 307줄): RenderSuggestActionChips, BuildFeedbackContext, UpdateProgressBar, BuildDiffView 잔류
- ChatWindow.BottomBar.cs (345줄): BuildBottomBar, BuildCodeBottomBar, ShowLogLevelMenu, ShowLanguageMenu 등
- ChatWindow.MoodMenu.cs (456줄): ShowFormatMenu, ShowMoodMenu, ShowCustomMoodDialog 등
- ChatWindow.CustomPresets.cs (978줄 → 203줄): ShowCustomPresetDialog, SelectTopic 잔류
- ChatWindow.ConversationMenu.cs (255줄): ShowConversationMenu (카테고리/삭제/즐겨찾기 팝업)
- ChatWindow.ConversationTitleEdit.cs (108줄): EnterTitleEditMode

### SettingsViewModel 분할
- SettingsViewModel.LlmProperties.cs (417줄): LLM·에이전트 관련 바인딩 프로퍼티
- SettingsViewModel.Properties.cs (837줄 → 427줄): 기능 토글·테마·스니펫 등 앱 수준 프로퍼티

### TemplateService 분할
- TemplateService.Css.cs (559줄): 11종 CSS 테마 문자열 상수
- TemplateService.cs (734줄 → 179줄): 메서드 로직만 잔류

### PlanViewerWindow 분할
- PlanViewerWindow.StepRenderer.cs (616줄): RenderSteps + SwapSteps + EditStep + 버튼 빌더 9개
- PlanViewerWindow.cs (931줄 → 324줄): Win32/생성자/공개 API 잔류

### App.xaml.cs 분할 (776줄 → 452줄)
- App.Settings.cs (252줄): SetupTrayIcon, OpenSettings, ToggleDockBar, RefreshDockBar, OpenAiChat
- App.Helpers.cs (92줄): LoadAppIcon, IsAutoStartEnabled, SetAutoStart, OnExit

### LlmService.ToolUse.cs 분할 (719줄 → 115줄)
- LlmService.ClaudeTools.cs (180줄): SendClaudeWithToolsAsync, BuildClaudeToolBody
- LlmService.GeminiTools.cs (175줄): SendGeminiWithToolsAsync, BuildGeminiToolBody
- LlmService.OpenAiTools.cs (215줄): SendOpenAiWithToolsAsync, BuildOpenAiToolBody

### SettingsWindow.UI.cs 분할 (802줄 → 310줄)
- SettingsWindow.Storage.cs (167줄): RefreshStorageInfo, BtnStorageCleanup_Click 등
- SettingsWindow.HotkeyUI.cs (127줄): RefreshHotkeyBadges, EnsureHotkeyInCombo, GetKeyName 등
- SettingsWindow.DevMode.cs (90줄): DevModeCheckBox_Checked, UpdateDevModeContentVisibility

## 빌드 결과: 경고 0, 오류 0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 20:51:26 +09:00
c9a6e6442f [Phase 41] SettingsViewModel·AgentLoopService 파셜 클래스 분할
SettingsViewModel (1,855줄 → 320줄, 82.7% 감소):
- SettingsViewModel.Properties.cs (837줄): 바인딩 프로퍼티 전체
- SettingsViewModel.Methods.cs (469줄): Save/Browse/Add 등 메서드
- SettingsViewModelModels.cs (265줄): 6개 모델 클래스 분리

AgentLoopService (1,823줄 → 1,334줄, 26.8% 감소):
- AgentLoopService.Execution.cs (498줄): 병렬 도구 실행, ToolExecutionState
- 빌드: 경고 0, 오류 0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 19:37:24 +09:00
deffb33cf9 Initial commit to new repository 2026-04-03 18:23:52 +09:00