feat(V2-1a): Monorepo 구조 전환 — apps/desktop으로 V1 이동
- npm workspaces 루트 (apps/*, packages/*) 세팅 - V1 전체를 apps/desktop/으로 git mv (src, resources, tests, sidecar, scripts, electron.vite.config.ts, electron-builder.yml, vitest.config.ts, tsconfig.node.json, tsconfig.web.json) - apps/desktop/package.json 신규 (name=@d3ro/desktop) - productName: 'd3ro-voice' 명시 — app.getName()을 고정하여 userData 경로 %APPDATA%\d3ro-voice\ 그대로 유지 (기존 DB/설정 연속성 보장) - 루트 package.json을 workspace 루트로 재구성, 공통 devDep만 유지 (typescript, eslint, prettier) - turbo.json, tsconfig.base.json 추가 (Turborepo 자체 설치는 별도 sub-phase) - memory/project_status.md 생성 (규칙 13) 검증: - npm run typecheck 통과 - npm run build 통과 (electron-vite main+preload+renderer) - npm run dev 실제 실행 → DB/핫키/Ollama 자동 실행 모두 정상
This commit is contained in:
parent
3a160b9032
commit
45a580878a
178 changed files with 214 additions and 0 deletions
84
apps/desktop/src/main/ipc/rag-handlers.ts
Normal file
84
apps/desktop/src/main/ipc/rag-handlers.ts
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
// src/main/ipc/rag-handlers.ts
|
||||
// Phase 13.2: 로컬 RAG IPC 핸들러
|
||||
|
||||
import { ipcMain, dialog } from 'electron'
|
||||
import { IPC_CHANNELS } from '@shared/ipc-channels'
|
||||
import { ErrorCode, ipcSuccess, ipcError } from '@shared/errors'
|
||||
import { getRAGService } from '../services/RAGService'
|
||||
import { getLogger } from '../services/LoggerService'
|
||||
import type { RAGQueryParams, RAGRemoveDocumentParams } from '@shared/types'
|
||||
|
||||
const logger = getLogger('rag-handlers')
|
||||
|
||||
export function registerRAGHandlers(): void {
|
||||
ipcMain.handle(IPC_CHANNELS.RAG.ADD_DOCUMENT, async (_event, params: { filePath?: string }) => {
|
||||
try {
|
||||
let filePath = params?.filePath
|
||||
if (!filePath) {
|
||||
const result = await dialog.showOpenDialog({
|
||||
properties: ['openFile'],
|
||||
filters: [{ name: 'Documents', extensions: ['txt', 'md', 'pdf', 'docx'] }],
|
||||
})
|
||||
if (result.canceled || result.filePaths.length === 0) {
|
||||
return ipcError(ErrorCode.RAGDocumentNotFound, 'File selection cancelled')
|
||||
}
|
||||
filePath = result.filePaths[0]
|
||||
}
|
||||
const doc = await getRAGService().addDocument(filePath)
|
||||
return ipcSuccess(doc)
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
logger.error('RAG add document failed:', msg)
|
||||
return ipcError(ErrorCode.RAGIndexingFailed, msg)
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.RAG.REMOVE_DOCUMENT, async (_event, params: RAGRemoveDocumentParams) => {
|
||||
try {
|
||||
getRAGService().removeDocument(params.documentId)
|
||||
return ipcSuccess(undefined)
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
return ipcError(ErrorCode.RAGDocumentNotFound, msg)
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.RAG.GET_DOCUMENTS, async () => {
|
||||
try {
|
||||
return ipcSuccess(getRAGService().getDocuments())
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
return ipcError(ErrorCode.UnknownError, msg)
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.RAG.QUERY, async (_event, params: RAGQueryParams) => {
|
||||
try {
|
||||
const result = await getRAGService().query(params.query, params.topK)
|
||||
return ipcSuccess(result)
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
logger.error('RAG query failed:', msg)
|
||||
return ipcError(ErrorCode.RAGQueryFailed, msg)
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.RAG.GET_STATE, async () => {
|
||||
try {
|
||||
return ipcSuccess(getRAGService().getStateInfo())
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
return ipcError(ErrorCode.UnknownError, msg)
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.RAG.REINDEX, async (_event, params: { documentId: string }) => {
|
||||
try {
|
||||
await getRAGService().reindex(params.documentId)
|
||||
return ipcSuccess(undefined)
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
return ipcError(ErrorCode.RAGIndexingFailed, msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue