refactor: extension.ts 모놀리스를 모듈로 분리 (21,836 → 18,910줄, 동작 보존) - #4
Open
vip7612-maker wants to merge 23 commits into
Open
refactor: extension.ts 모놀리스를 모듈로 분리 (21,836 → 18,910줄, 동작 보존)#4vip7612-maker wants to merge 23 commits into
vip7612-maker wants to merge 23 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
git·fs-safe·search·proc·bridge 5개 모듈로 잎 유틸 이동 (동작 보존). extension.ts 21,836 → 21,206줄 (-630). tsc strict + esbuild 번들 그린. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ig.ts getConfig·_isLMStudioEngine·_ensureBrainDir·_loadPrompt·_loadToolSeed + EXCLUDED_DIRS·MAX_CONTEXT_SIZE 이동 (동작 보존). 21,206 → 21,104줄. 그린. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…runtime-state - _safeReadText() 를 core/fs-safe.ts 로 이동 (fs 읽기 잎 헬퍼, 47곳 공유) - _extCtx 싱글톤을 runtime-state.ts 의 holder(runtime.extCtx)로 이전 (25곳 치환). holder 객체라 strict null-narrowing 유지. company/telegram/schedulers/panels 공용. 동작 보존. tsc strict + esbuild 그린. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…pany.ts 11 심볼(_migrate*·get/updateCompanyMetrics·getCompanyDay·is/readCompanyName· _extractCompanyName·COMPANY_INTERNAL_DIRS) 이동. 동작 보존. 21,104 → 20,907줄. 그린. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nts-state.ts 14종(LOCKED/ALWAYS/DEFAULT/OPTIONAL 상수·read/isAgent*·set/markAgent*· _maybeRecommendCoderModel) 이동. awk 바이트추출+perl export로 본문 보존. 20,907→20,685. 그린. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ation.ts agent모델맵(read/write/getAgentModel)·_classifyModel·_autoOrchestrateModelMap· listInstalledModels 이동. ModelTier는 내부전용. system-specs import는 패널서도 써서 잔류. 20,685 → 20,542줄. 그린. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…sync.ts _safeGitAutoSync·_safeGitAutoSyncCompany 이동. 공유 락 _autoSyncRunning → runtime.autoSyncRunning holder(7곳), 회사 락은 git-sync 내부 private. 동작 보존. 20,542 → 20,364줄. 그린. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…c/panels/brain-network.ts buildKnowledgeGraph·_RENDER_GRAPH_HTML(~900줄 HTML)·Brain* 인터페이스 이동. 싱글톤(_activeChatProvider) 참조하는 showBrainNetwork 는 본문 잔류(순수 로직만 분리). 20,364 → 19,286줄 (-1,078). 그린. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…calendar via DI hook) 타입(TrackerTask·TaskPriority)·CRUD(read/write/add/update/listOpen)·trackerToMarkdown· 변경이벤트(onTrackerChanged) 이동. tracker↔calendar 순환 결합은 setTrackerCalendarHooks() IoC 훅으로 차단 — activate 에서 구글 캘린더 함수 주입. tsc strict 가 훅 시그니처 일치 검증. 동작 보존. 19111줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
TaskTreeItem·TaskTreeProvider·우선순위/상태/기한 아이콘 헬퍼 이동. tracker.ts 분리로 해금됨(readTracker·onTrackerChanged·_coercePriority 등 import). 싱글톤·인라인 명령은 본문 잔류. 동작 보존. 19,111 → 18,910줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
WORLD_LAYOUT·CUSTOM_MAP_DESKS·buildWorldDeskPositions + 좌표 인터페이스 5종 이동. 순수 데이터(의존 0), 소비자는 OfficePanel. 동작 보존. 18,910 → 18,797줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CalendarWriteConfig + 14함수(isCalendarWriteConnected·create/update/delete/patchEvent· findCalendarEvents·refreshCalendarCacheViaOAuth·OAuth 위저드/루프백) 이동. tracker 와는 단방향 타입 import만(DI 훅이 순환 차단). 본문 역참조 0. 동작 보존. 18,797 → 18,130줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
AgentTool/ToolField 타입·listAgentTools·writeToolConfig·setToolEnabled·AGENT_TOOLS_CATALOG· 전체 _seed<Tool> Python 도구 시드 함수(32 export) 이동. 순수 시딩 레이어 — 본문 LLM/대화로그/ 스킬저장 역참조 0(검증). 대화로그·saveAgentSkill 등 결합 함수는 본문 잔류. 18,130 → 17,262줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…any/structure.ts ensureCompanyStructure(외부 22곳) + 미션 목표(_GOAL_PREAMBLE·DEFAULT_AGENT_GOALS· read/writeAgentGoal·_seedAgentGoalIfMissing) 이동. 순수 시딩 — 본문 역참조 0. appendAgentMemory는 _copyDirRecursive 결합으로 잔류. http-server 추출 해금. 17,262 → 16,849줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tProviderLike) 38곳 _activeChatProvider → runtime.activeChatProvider. SidebarChatProvider 공개 표면 중 호출되는 11개 메서드를 ChatProviderLike 인터페이스로 고정(순환 방지). tsc strict 가 구조적 대입 가능성 검증. medium 배치(approvals·schedulers·telegram) 해금 인프라. 동작 보존. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
getConversationsDir·appendConversationLog(28곳)·readRecentConversations 이동. 순수 파일IO. approvals·telegram·schedulers·scaffold 공통 의존 해금. 16,848 → 16,795줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…otifier) PendingApproval·createApproval·listPendingApprovals·resolveApproval 등 이동. _approvalsPanelProvider → runtime holder(ApprovalsPanelLike). approvals→telegram 결합은 setApprovalNotifier IoC 훅으로 차단(activate서 sendTelegramReport 주입). pulseAgent·refresh는 holder 경유. 16,795 → 16,619줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
readTelegramConfig·sendTelegramReport(61곳)·sendTelegramLong·sendTelegramTyping·_markdownToTelegram 이동. 순수 axios 발신 — provider/LLM 결합 없음. 폴링·핸들러(provider 양방향)는 본문 잔류. schedulers·approvals·scaffold 의 발신 의존 해금. 16,619 → 16,498줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
할일 nudge·데일리 브리핑·매출 감시·반복(recurrence)·사전알람·날짜유틸 이동(2개 연속 블록). 타이머 5종은 모듈 내부 전용(비export), start/stop 함수로만 제어. LLM 결합 0 — 의존은 전부 이미 분리된 모듈(tracker·telegram-send·conversation-log·calendar·company)+runtime holder. 16,498 → 16,019줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ld.ts scaffoldDeveloperProject(vite-vanilla/react·static 템플릿) 이동. 의존 전부 importable (telegram-send·conversation-log·tracker·core/proc). 함수 본문의 코드 template 문자열 보호 위해 perl 일괄치환 대신 수동 export. 16,019 → 15,852줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
_quickLLMCall(Ollama/LM Studio 공용 경량 호출, 6곳) 이동. 의존 axios+config 뿐. telegram 분류·스킬 증류 등의 공통 LLM 의존 해금. 15,852 → 15,835줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ActiveDispatch·_activeDispatches Map·_start/find/update/endActiveDispatch 이동. 의존 0(순수 Map/TTL). telegram 핸들러와 SidebarChatProvider 가 공유하는 상태를 leaf 로 분리 → telegram 추출의 선행 unlock. 15,835 → 15,778줄. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
무엇을 / 왜
src/extension.ts단일 파일이 21,836줄까지 비대해져 코드 리뷰·충돌·온보딩이 어려운 상태였습니다. 코드 주석에도 "25,000줄에 묻혀있다"는 자조가 남아 있을 정도입니다. 이 PR은 동작을 100% 보존하면서 응집도 높은 모듈로 분리합니다.extension.ts: 21,836 → 18,910줄 (−2,926, 약 −13.4%)원칙 (동작 보존 리팩토링)
export로 옮기고extension.ts는import만.esbuild --bundle단일 번들이라 모듈 분리에 런타임/패키징 변화 0. (out/extension.js1.4MB 동일)tsc --noEmit(strict) +esbuild번들이 둘 다 그린임을 확인 후 커밋(롤백 지점 확보).모듈 구성
core/{git,fs-safe,search,proc,bridge}.tsconfig.tsgetConfig·프롬프트/툴시드 로더·_ensureBrainDirruntime-state.tsextCtx·autoSyncRunning)company/{company,agents-state,orchestration}.tsgit-sync.tstracker.tspanels/{brain-network,task-tree}.ts리뷰어가 알아두면 좋은 점
_extCtx·_autoSyncRunning은 여러 모듈이 공유 →runtime-state.ts의 holder 객체로 노출. getter 함수가 아닌 객체 속성(runtime.extCtx)으로 둔 이유는 strict 모드의 null-narrowing(if (runtime.extCtx) { runtime.extCtx.x })을 보존하기 위함입니다.addTrackerTask/updateTrackerTask가 구글 캘린더 함수를 직접 호출하고 캘린더 함수는TrackerTask타입을 받아 순환이었습니다. DI 훅(setTrackerCalendarHooks)으로 의존성을 역전 —activate()에서 실제 캘린더 함수를 주입합니다. 동작은 동일하며,tscstrict가 훅 시그니처 일치를 검증합니다.showBrainNetwork(싱글톤 의존)·_taskTreeProvider(싱글톤)·tracker 인라인 명령은 의도적으로extension.ts에 남겼습니다.awk바이트 추출 +perlexport 부착으로 옮겨 regex 많은 로직(마이그레이션 등)이 한 글자도 변경되지 않음을 보장했습니다.package-lock.json의 npm 정규화 변경은 리팩토링과 무관해 제외했습니다.검증
매 커밋마다 아래 하네스(
scripts/verify-refactor.sh)가 그린:🤖 Generated with Claude Code