feat(V2-1b): packages/core 추출 — 공유 타입/에러/채널/유틸 분리

packages/core (@d3ro/core) 신규 생성:
- types.ts, errors.ts, ipc-channels.ts, constants.ts (shared에서 이동)
- utils/meeting-markdown.ts, utils/markdown-to-docx.ts (main/utils에서 이동)
- subpath exports 정의 (./types, ./errors, ./ipc-channels, ./constants,
  ./utils/meeting-markdown, ./utils/markdown-to-docx)
- src/index.ts barrel export 추가
- docx를 core 자체 dependency로 선언

apps/desktop 연결:
- package.json에 @d3ro/core: '*' dep 추가
- tsconfig.node/web.json paths에 @d3ro/core/* 추가
- electron.vite.config.ts 3개 섹션 alias 추가 (main/preload/renderer)
- externalizeDepsPlugin exclude에 @d3ro/core (workspace 소스 번들 대상)
- vitest.config.ts alias 추가

일괄 치환 (79 파일, 167건):
- @shared/{types,errors,ipc-channels,constants} → @d3ro/core/*
- static/dynamic import + type expression import 모두 포함
- MeetingModeService.ts의 ../utils/* 상대 경로 → @d3ro/core/utils/*
- @shared/theme-vars는 V2-1c 범위로 남김 (WindowManager만 사용)

M1 수정 포함:
- electron.vite.config.ts의 resolve('src/shared') → resolve(__dirname, ...)
  CWD 독립적으로 동작하도록 견고화

검증:
- typecheck 통과
- build 통과 (main+preload+renderer)
- dev 런타임 → DB/핫키/Ollama 모두 정상, 기존 데이터 연속성 유지
This commit is contained in:
yunchan8804 2026-04-08 14:39:46 +09:00
parent a4cb4c0805
commit 3b0eb3393b
95 changed files with 315 additions and 212 deletions

View file

@ -10,9 +10,9 @@ import type { Readable } from 'stream'
import { getLogger } from './LoggerService'
import { configGet } from './ConfigService'
import { getSoxPath } from '../utils/paths'
import type { AudioDevice } from '@shared/types'
import { AUDIO_FORMAT, TIMING } from '@shared/constants'
import { D3ROError, ErrorCode } from '@shared/errors'
import type { AudioDevice } from '@d3ro/core/types'
import { AUDIO_FORMAT, TIMING } from '@d3ro/core/constants'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
const logger = getLogger('AudioCaptureService')

View file

@ -15,14 +15,14 @@ import {
hideCaptionOverlay,
sendToCaptionOverlay,
} from '../windows/WindowManager'
import { IPC_CHANNELS } from '@shared/ipc-channels'
import { D3ROError, ErrorCode } from '@shared/errors'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type {
CaptionState,
CaptionSegment,
CaptionConfig,
CaptionSessionSummary,
} from '@shared/types'
} from '@d3ro/core/types'
import { getMainWindow } from '../windows/WindowManager'
const logger = getLogger('CaptionService')
@ -139,7 +139,7 @@ class CaptionService extends EventEmitter {
this._totalFrameCount = 0
// ConfigService에서 저장된 오디오 소스 읽기
const savedSource = configGet('captionAudioSource' as keyof import('@shared/types').AppConfig) as unknown as string
const savedSource = configGet('captionAudioSource' as keyof import('@d3ro/core/types').AppConfig) as unknown as string
if (savedSource && (savedSource === 'mic' || savedSource === 'system' || savedSource === 'both')) {
this._config.audioSource = savedSource as 'mic' | 'system' | 'both'
}

View file

@ -8,8 +8,8 @@ import { configGet } from './ConfigService'
import { getCustomInstructionService } from './CustomInstructionService'
import { getLocalLLMService } from './LocalLLMService'
import { getMainWindow } from '../windows/WindowManager'
import { IPC_CHANNELS } from '@shared/ipc-channels'
import { D3ROError, ErrorCode } from '@shared/errors'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type {
LLMChain,
ChainStep,
@ -17,7 +17,7 @@ import type {
UpdateChainParams,
ChainProgress,
ChainExecutionResult
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('chain-service')

View file

@ -2,7 +2,7 @@
// electron-store 기반 설정 관리. 설계서 02의 AppConfig 타입 사용.
import { EventEmitter } from 'events'
import type { AppConfig, ConfigChangedEvent } from '@shared/types'
import type { AppConfig, ConfigChangedEvent } from '@d3ro/core/types'
import { getLogger } from './LoggerService'
const logger = getLogger('ConfigService')

View file

@ -7,8 +7,8 @@ import { nanoid } from 'nanoid'
import Store from 'electron-store'
import { getLogger } from './LoggerService'
import { getMainWindow } from '../windows/WindowManager'
import { IPC_CHANNELS } from '@shared/ipc-channels'
import { D3ROError, ErrorCode } from '@shared/errors'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type {
DictationTemplate,
TemplateField,
@ -18,7 +18,7 @@ import type {
TemplateSessionCompletedEvent,
CreateTemplateParams,
UpdateTemplateParams,
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('DictationTemplateService')

View file

@ -14,7 +14,7 @@ import type {
DictionaryAddParams,
DictionaryUpdateParams,
DictionarySearchParams
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('DictionaryService')

View file

@ -13,15 +13,15 @@ import { getHistoryService } from './HistoryService'
import { configGet } from './ConfigService'
import { getFfmpegPath } from '../utils/paths'
import { getMainWindow } from '../windows/WindowManager'
import { IPC_CHANNELS } from '@shared/ipc-channels'
import { D3ROError, ErrorCode } from '@shared/errors'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type {
FileTranscriptionState,
FileTranscriptionProgress,
FileTranscriptionResult,
FileTranscriptionSegment,
FileTranscriptionStateInfo,
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('FileTranscriptionService')
@ -75,7 +75,7 @@ class FileTranscriptionService extends EventEmitter {
// 라이센스 체크
try {
const { getLicenseService } = await import('./LicenseService')
const { Feature } = await import('@shared/types')
const { Feature } = await import('@d3ro/core/types')
const license = getLicenseService()
const access = license.canUse(Feature.FILE_TRANSCRIPTION)
if (!access.allowed) {

View file

@ -13,7 +13,7 @@ import type {
HistoryPage,
HistorySearchParams,
StatsSummary
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('HistoryService')

View file

@ -7,9 +7,9 @@ import { uIOhook, UiohookKey } from 'uiohook-napi'
import type { UiohookKeyboardEvent } from 'uiohook-napi'
import { getLogger } from './LoggerService'
import { configGet } from './ConfigService'
import { D3ROError, ErrorCode } from '@shared/errors'
import { TIMING } from '@shared/constants'
import type { HotkeyBinding } from '@shared/types'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import { TIMING } from '@d3ro/core/constants'
import type { HotkeyBinding } from '@d3ro/core/types'
const logger = getLogger('HotkeyService')

View file

@ -8,7 +8,7 @@ import { eq, and } from 'drizzle-orm'
import { getLogger } from './LoggerService'
import { getDatabase } from '../db'
import { dailyUsage } from '../db/schema'
import { D3ROError, ErrorCode } from '@shared/errors'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type {
LicenseTier,
LicenseInfo,
@ -17,8 +17,8 @@ import type {
UpgradePromptEvent,
ActivateLicenseResult,
TierComparison,
} from '@shared/types'
import { Feature } from '@shared/types'
} from '@d3ro/core/types'
import { Feature } from '@d3ro/core/types'
const logger = getLogger('license')

View file

@ -8,8 +8,8 @@ import * as fs from 'fs'
import * as path from 'path'
import { getLogger } from './LoggerService'
import { configGet } from './ConfigService'
import { D3ROError, ErrorCode } from '@shared/errors'
import type { LLMStatus, LLMModel, LLMAction, LLMConnectionState } from '@shared/types'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type { LLMStatus, LLMModel, LLMAction, LLMConnectionState } from '@d3ro/core/types'
const logger = getLogger('LocalLLMService')
@ -410,7 +410,7 @@ class LocalLLMService extends EventEmitter {
// Phase 11: LLM 처리 쿼터 체크
try {
const { getLicenseService } = await import('./LicenseService')
const { Feature } = await import('@shared/types')
const { Feature } = await import('@d3ro/core/types')
const license = getLicenseService()
const access = license.canUse(Feature.LLM_PROCESS)
if (!access.allowed) {

View file

@ -8,8 +8,8 @@ import { type ChildProcess, spawn } from 'child_process'
import { getLogger } from './LoggerService'
import { configGet } from './ConfigService'
import { getSidecarCommand } from '../utils/paths'
import { D3ROError, ErrorCode } from '@shared/errors'
import type { STTModel, STTStatus, STTEngineState } from '@shared/types'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type { STTModel, STTStatus, STTEngineState } from '@d3ro/core/types'
// ── 내부 타입 정의 ────────────────────────────────────────

View file

@ -5,13 +5,13 @@ import { EventEmitter } from 'events'
import { nanoid } from 'nanoid'
import Store from 'electron-store'
import { getLogger } from './LoggerService'
import { D3ROError, ErrorCode } from '@shared/errors'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type {
MeetingDocTemplate,
CreateMeetingDocTemplateParams,
UpdateMeetingDocTemplateParams,
MeetingDocTemplateType,
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('MeetingDocTemplateService')

View file

@ -12,8 +12,8 @@ import { configGet, configSet } from './ConfigService'
import { getMainWindow } from '../windows/WindowManager'
import { getDatabase } from '../db'
import { meetingSessions, meetingMemos, meetingDocuments } from '../db/schema'
import { IPC_CHANNELS } from '@shared/ipc-channels'
import { D3ROError, ErrorCode } from '@shared/errors'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import {
parseMinutes,
buildExportMarkdown,
@ -21,8 +21,8 @@ import {
formatTime,
formatDateFile,
formatDateRange,
} from '../utils/meeting-markdown'
import { markdownToDocx } from '../utils/markdown-to-docx'
} from '@d3ro/core/utils/meeting-markdown'
import { markdownToDocx } from '@d3ro/core/utils/markdown-to-docx'
import type {
MeetingModeState,
MeetingMemo,
@ -39,7 +39,7 @@ import type {
MeetingExportFormat,
MeetingDocGeneratingProgress,
CaptionSegment,
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('MeetingModeService')
@ -145,7 +145,7 @@ class MeetingModeService extends EventEmitter {
// 회의 모드는 마이크 캡처 강제 — ConfigService 값도 임시 변경
// (CaptionService.start()가 ConfigService에서 다시 읽기 때문)
type AppConfigKey = keyof import('@shared/types').AppConfig
type AppConfigKey = keyof import('@d3ro/core/types').AppConfig
const prevAudioSource = configGet('captionAudioSource' as AppConfigKey) as unknown as string
configSet('captionAudioSource' as AppConfigKey, 'mic' as never)

View file

@ -12,9 +12,9 @@ import { getLocalLLMService } from './LocalLLMService'
import { getDatabase } from '../db'
import { history } from '../db/schema'
import { getMainWindow } from '../windows/WindowManager'
import { IPC_CHANNELS } from '@shared/ipc-channels'
import { D3ROError, ErrorCode } from '@shared/errors'
import type { MeetingSummaryResult, MeetingSummaryProgress } from '@shared/types'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type { MeetingSummaryResult, MeetingSummaryProgress } from '@d3ro/core/types'
const logger = getLogger('MeetingSummaryService')
@ -41,7 +41,7 @@ class MeetingSummaryService extends EventEmitter {
// 라이센스 체크
try {
const { getLicenseService } = await import('./LicenseService')
const { Feature } = await import('@shared/types')
const { Feature } = await import('@d3ro/core/types')
const license = getLicenseService()
const access = license.canUse(Feature.MEETING_SUMMARY)
if (!access.allowed) {

View file

@ -10,7 +10,7 @@ import { getDatabase } from '../db'
import { memoTags, history } from '../db/schema'
import type { MemoTagRow } from '../db/schema'
import { getLogger } from './LoggerService'
import { D3ROError, ErrorCode } from '@shared/errors'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type {
MemoTag,
TagCount,
@ -18,7 +18,7 @@ import type {
ExportMemoParams,
HistoryEntry,
HistoryPage
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('MemoService')

View file

@ -13,15 +13,15 @@ import { configGet } from './ConfigService'
import { getDatabase } from '../db'
import { ragDocuments, ragChunks } from '../db/schema'
import { getMainWindow } from '../windows/WindowManager'
import { IPC_CHANNELS } from '@shared/ipc-channels'
import { D3ROError, ErrorCode } from '@shared/errors'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type {
RAGDocument,
RAGQueryResult,
RAGState,
RAGStateInfo,
RAGIndexProgress,
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('RAGService')
@ -74,7 +74,7 @@ class RAGService extends EventEmitter {
// 라이센스 체크
try {
const { getLicenseService } = await import('./LicenseService')
const { Feature } = await import('@shared/types')
const { Feature } = await import('@d3ro/core/types')
const license = getLicenseService()
const access = license.canUse(Feature.LOCAL_RAG)
if (!access.allowed) {

View file

@ -5,8 +5,8 @@
import { clipboard } from 'electron'
import { getLogger } from './LoggerService'
import { configGet, configSet } from './ConfigService'
import { D3ROError, ErrorCode } from '@shared/errors'
import type { ScreenContext, CaptureContextResult } from '@shared/types'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type { ScreenContext, CaptureContextResult } from '@d3ro/core/types'
const logger = getLogger('screen-context')

View file

@ -7,7 +7,7 @@ import { EventEmitter } from 'events'
import { spawn, type ChildProcess } from 'child_process'
import { getLogger } from './LoggerService'
import { configGet } from './ConfigService'
import { D3ROError, ErrorCode } from '@shared/errors'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
const logger = getLogger('TTSPlaybackService')

View file

@ -6,7 +6,7 @@
import { EventEmitter } from 'events'
import { clipboard } from 'electron'
import { getLogger } from './LoggerService'
import { D3ROError, ErrorCode } from '@shared/errors'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
const logger = getLogger('TextInsertService')

View file

@ -10,8 +10,8 @@ import { getLogger } from './LoggerService'
import { getLocalLLMService } from './LocalLLMService'
import { configGet } from './ConfigService'
import { getMainWindow } from '../windows/WindowManager'
import { IPC_CHANNELS } from '@shared/ipc-channels'
import { D3ROError, ErrorCode } from '@shared/errors'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type {
VoiceActionPlan,
VoiceActionPreset,
@ -19,7 +19,7 @@ import type {
VoiceActionPlannedEvent,
VoiceActionExecutedEvent,
VoiceActionErrorEvent,
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('VoiceActionService')
@ -112,7 +112,7 @@ class VoiceActionService extends EventEmitter {
// 라이센스 체크
try {
const { getLicenseService } = await import('./LicenseService')
const { Feature } = await import('@shared/types')
const { Feature } = await import('@d3ro/core/types')
const license = getLicenseService()
const access = license.canUse(Feature.OS_AUTOMATION)
if (!access.allowed) {

View file

@ -10,7 +10,7 @@ import type {
VoiceCommandKeyword,
VoiceCommandMatch,
KeywordMatchMode
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('voice-command')

View file

@ -11,8 +11,8 @@ import { getAudioCaptureService } from './AudioCaptureService'
import { getTTSPlaybackService } from './TTSPlaybackService'
import { configGet } from './ConfigService'
import { getMainWindow } from '../windows/WindowManager'
import { IPC_CHANNELS } from '@shared/ipc-channels'
import { D3ROError, ErrorCode } from '@shared/errors'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import type {
ConversationState,
ConversationMessage,
@ -20,7 +20,7 @@ import type {
ConversationAssistantDelta,
ConversationAssistantMessage,
ConversationError,
} from '@shared/types'
} from '@d3ro/core/types'
const logger = getLogger('VoiceConversationService')
@ -67,7 +67,7 @@ class VoiceConversationService extends EventEmitter {
// 라이센스 체크
try {
const { getLicenseService } = await import('./LicenseService')
const { Feature } = await import('@shared/types')
const { Feature } = await import('@d3ro/core/types')
const license = getLicenseService()
const access = license.canUse(Feature.VOICE_CONVERSATION)
if (!access.allowed) {

View file

@ -17,10 +17,10 @@ import type { HotkeyConfig } from './HotkeyService'
import { configGet } from './ConfigService'
import { getTextInsertService } from './TextInsertService'
import { getLocalLLMService } from './LocalLLMService'
import { D3ROError, ErrorCode } from '@shared/errors'
import { TIMING } from '@shared/constants'
import { RecognitionState, AudioState } from '@shared/types'
import type { VoiceMode, VoiceState } from '@shared/types'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import { TIMING } from '@d3ro/core/constants'
import { RecognitionState, AudioState } from '@d3ro/core/types'
import type { VoiceMode, VoiceState } from '@d3ro/core/types'
import {
showRecordingTip,
hideRecordingTip,
@ -28,7 +28,7 @@ import {
sendAudioLevelToTip,
showResultPopup,
} from '../windows/WindowManager'
import type { ScreenContext } from '@shared/types'
import type { ScreenContext } from '@d3ro/core/types'
const logger = getLogger('VoiceModeService')
@ -189,7 +189,7 @@ class VoiceModeService extends EventEmitter {
// Phase 11: 라이센스 쿼터 체크
try {
const { getLicenseService } = await import('./LicenseService')
const { Feature } = await import('@shared/types')
const { Feature } = await import('@d3ro/core/types')
const license = getLicenseService()
const access = license.canUse(Feature.DICTATION)
if (!access.allowed) {
@ -220,7 +220,7 @@ class VoiceModeService extends EventEmitter {
const { getScreenContextService } = await import('./ScreenContextService')
const ctx = getScreenContextService()
if (ctx.isEnabled()) {
const captureSelected = configGet('screenContextEnabled' as keyof import('@shared/types').AppConfig) as unknown as boolean
const captureSelected = configGet('screenContextEnabled' as keyof import('@d3ro/core/types').AppConfig) as unknown as boolean
const result = await ctx.captureContext(captureSelected)
screenContext = result.context
logger.info(`Screen context captured: ${screenContext.appName ?? 'unknown'}`)
@ -555,7 +555,7 @@ class VoiceModeService extends EventEmitter {
if (action === 'chain') {
try {
const { getChainService } = await import('./ChainService')
const activeChainId = configGet('activeChainId' as keyof import('@shared/types').AppConfig) as unknown as string
const activeChainId = configGet('activeChainId' as keyof import('@d3ro/core/types').AppConfig) as unknown as string
if (activeChainId) {
const chainResult = await getChainService().execute(activeChainId, contextPrefix + transcribedText)
if (this._isInTerminalState()) return
@ -572,7 +572,7 @@ class VoiceModeService extends EventEmitter {
// 음성 단축키 오버라이드 또는 활성 명령어
const effectiveInstructionId = overrideInstructionId
?? (configGet('activeInstructionId' as keyof import('@shared/types').AppConfig) as unknown as string)
?? (configGet('activeInstructionId' as keyof import('@d3ro/core/types').AppConfig) as unknown as string)
if (action === 'custom' || overrideInstructionId) {
let customPrompt = contextPrefix + transcribedText