refactor: restructure LLM module with provider registry pattern#36
Merged
refactor: restructure LLM module with provider registry pattern#36
Conversation
- EngineConfig, Registration 구조체 추가 - Register(), GetAllRegistrations() 함수 구현
- llm/openai/engine.go 생성 - llm/openai/register.go 생성 (init 자동 등록)
- llm/claudecode/engine.go 생성 - llm/claudecode/register.go 생성
- llm/geminicli/engine.go 생성 - llm/geminicli/register.go 생성
- llm/mcp/engine.go 생성 - llm/mcp/register.go 생성
- registry를 engine 패키지로 이동 - 모든 provider가 engine 패키지만 import하도록 수정 - client.go가 engine.GetAllRegistrations() 사용
- engine/api.go, cli.go, mcp.go, cliprovider/ 삭제 - cli_detect.go 추가 (CLI 감지 유틸리티) - config.go, cmd/llm.go 참조 수정 - client_test.go 테스트 기대값 수정
- bootstrap/providers.go 생성 - llm/client.go에서 side-effect imports 제거
- Move interface and types from llm/engine/ to llm/ - Delete llm/engine/ subdirectory (no longer needed) - Update all providers to import llm directly - Fix cmd/llm.go to use llm.Mode instead of engine.Mode - Update tests with mock engine registration This change follows the same pattern as adapter/ package: - Interface in llm/engine.go - Registry in llm/registry.go - Providers in llm/<provider>/ - Side-effect imports in bootstrap/providers.go
MCP sampling provider was designed for future llm-validator feature but is currently unused (no llm-validator rules exist). Removed: - internal/llm/mcp/ directory - ModeMCP constant and related code - WithMCPSession option - MCP mode from CLI setup menu Following YAGNI principle - can be re-implemented if needed.
- Add ConversionResult struct with per-rule success/failure tracking - Update all adapter converters to return ConversionResult - Update main converter to fallback failed rules to llm-validator - Failed rules now get engine: "llm-validator" in code-policy.json
- Add ModelInfo, APIKeyConfig types to ProviderInfo - Add registry helper functions for dynamic provider/model queries - Remove hardcoded provider options from cmd/llm.go - Add compile-time RawProvider interface checks to all providers - Update README.md with new registration examples
- Replace emoji outputs with ui package functions - Use ui.PrintOK, ui.PrintError, ui.PrintWarn, ui.PrintTitle consistently - Affected files: init, my_role, policy, convert, mcp, mcp_register, validate, dashboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.env에서config.json으로 마이그레이션Changes
LLM Provider Registry 패턴 적용
Provider인터페이스 도입 (llm/llm.go)RawProvider+Wrapper패턴으로 공통 로직 분리 (llm/wrapper.go)llm/registry.go)llm/claudecode/- Claude Code CLIllm/geminicli/- Gemini CLIllm/openaiapi/- OpenAI APILegacy 코드 제거
llm/engine/패키지 전체 삭제 (api.go, cli.go, mcp.go, cliprovider/)llm/client.go삭제cmd/api_key.go삭제 (deprecated)llm/mcp/삭제 (YAGNI - 미사용 MCP sampling provider)설정 마이그레이션
.env→config.json마이그레이션internal/config/project.go추가Converter/Validator 개선
llm-validatorfallback 추가ConversionResult구조체로 규칙별 성공/실패 추적