From 5a5fae880a4fc1fa03372908dab631d50bb773ff Mon Sep 17 00:00:00 2001 From: digua Date: Thu, 16 Jul 2026 12:01:09 +0800 Subject: [PATCH] refactor: remove redundant re-export proxies --- apps/cli/src/ai/remote-api.ts | 12 ------ apps/cli/src/http/routes/web/index.ts | 2 +- apps/cli/src/merger/merge-cache.ts | 1 - apps/cli/src/sync/index.ts | 4 +- apps/cli/src/sync/routes.ts | 1 - .../desktop/main/ai/assistant/builtinTools.ts | 14 ------ apps/desktop/main/ai/assistant/index.ts | 1 - apps/desktop/main/ipc/chat.ts | 11 +++-- apps/desktop/main/network/index.ts | 6 --- apps/desktop/main/parser/index.ts | 43 ------------------- apps/desktop/main/paths.ts | 16 +++---- apps/desktop/main/utils/dataDirSwitch.ts | 8 ---- apps/desktop/main/worker/import/utils.ts | 2 +- .../main/worker/query/session/index.ts | 7 ++- .../main/worker/query/session/types.ts | 11 ----- apps/desktop/main/worker/workerManager.ts | 2 +- .../ai/__tests__/builtin-chart-skill.test.ts | 2 +- .../src/ai/builtin-chart-skill.ts | 5 --- packages/tools/src/sql/types.ts | 5 --- 19 files changed, 25 insertions(+), 128 deletions(-) delete mode 100644 apps/cli/src/ai/remote-api.ts delete mode 100644 apps/cli/src/merger/merge-cache.ts delete mode 100644 apps/cli/src/sync/routes.ts delete mode 100644 apps/desktop/main/ai/assistant/builtinTools.ts delete mode 100644 apps/desktop/main/network/index.ts delete mode 100644 apps/desktop/main/parser/index.ts delete mode 100644 apps/desktop/main/utils/dataDirSwitch.ts delete mode 100644 apps/desktop/main/worker/query/session/types.ts delete mode 100644 packages/node-runtime/src/ai/builtin-chart-skill.ts delete mode 100644 packages/tools/src/sql/types.ts diff --git a/apps/cli/src/ai/remote-api.ts b/apps/cli/src/ai/remote-api.ts deleted file mode 100644 index 90b64484..00000000 --- a/apps/cli/src/ai/remote-api.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Server-side remote LLM API operations. - * Thin wrapper over @openchatlab/node-runtime shared implementation. - */ - -export { - fetchRemoteModels, - validateApiKey, - type RemoteModel, - type FetchRemoteModelsResult, - type RemoteApiOptions, -} from '@openchatlab/node-runtime' diff --git a/apps/cli/src/http/routes/web/index.ts b/apps/cli/src/http/routes/web/index.ts index d28b41d4..a4f16f7f 100644 --- a/apps/cli/src/http/routes/web/index.ts +++ b/apps/cli/src/http/routes/web/index.ts @@ -38,11 +38,11 @@ import { getDefaultNodeUserDataDir, getPendingNodeDataDirMigration, AnalyticsService, + MergeSessionCache, type SemanticIndexRuntime, } from '@openchatlab/node-runtime' import { registerSharedRoutes } from '@openchatlab/http-routes' import type { HttpRouteContext } from '@openchatlab/http-routes' -import { MergeSessionCache } from '../../../merger/merge-cache' import { registerImportRoutes } from './import' import { openDirectoryPath, showPathInFolder } from './cache' import { getVersion } from '../../../version' diff --git a/apps/cli/src/merger/merge-cache.ts b/apps/cli/src/merger/merge-cache.ts deleted file mode 100644 index cdee8d28..00000000 --- a/apps/cli/src/merger/merge-cache.ts +++ /dev/null @@ -1 +0,0 @@ -export { MergeSessionCache } from '@openchatlab/node-runtime' diff --git a/apps/cli/src/sync/index.ts b/apps/cli/src/sync/index.ts index eef6c627..806f8e6b 100644 --- a/apps/cli/src/sync/index.ts +++ b/apps/cli/src/sync/index.ts @@ -10,9 +10,9 @@ import { PreferencesManager, createDatabaseManagerAdapter, ownerProfileService } import type { PathProvider } from '@openchatlab/core' import { DataSourceManager, PullEngine, initScheduler, stopAllTimers, reloadTimer, stopTimer } from '@openchatlab/sync' import type { SyncLogger } from '@openchatlab/sync' -import { NodeFetcher, DirectImporter, NoopNotifier } from './adapters' -import { registerAutomationRoutes } from './routes' +import { registerAutomationRoutes } from '@openchatlab/http-routes' import type { AutomationRouteContext } from '@openchatlab/http-routes' +import { NodeFetcher, DirectImporter, NoopNotifier } from './adapters' export interface SyncRouteContext { automation: AutomationRouteContext diff --git a/apps/cli/src/sync/routes.ts b/apps/cli/src/sync/routes.ts deleted file mode 100644 index 9851fbb6..00000000 --- a/apps/cli/src/sync/routes.ts +++ /dev/null @@ -1 +0,0 @@ -export { registerAutomationRoutes } from '@openchatlab/http-routes' diff --git a/apps/desktop/main/ai/assistant/builtinTools.ts b/apps/desktop/main/ai/assistant/builtinTools.ts deleted file mode 100644 index acbe9e42..00000000 --- a/apps/desktop/main/ai/assistant/builtinTools.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * 内置工具目录查询 — 从 @openchatlab/core 重导出 - */ - -import { BUILTIN_TOOL_CATALOG as _CATALOG } from '@openchatlab/core' - -export type { BuiltinToolCatalogEntry } from '@openchatlab/core' - -/** - * 获取所有内置工具的目录(含分类),供前端展示 - */ -export function getBuiltinToolCatalog() { - return _CATALOG -} diff --git a/apps/desktop/main/ai/assistant/index.ts b/apps/desktop/main/ai/assistant/index.ts index 0dedb6d0..868543b7 100644 --- a/apps/desktop/main/ai/assistant/index.ts +++ b/apps/desktop/main/ai/assistant/index.ts @@ -19,4 +19,3 @@ export { isGeneralAssistant, } from './manager' export { parseAssistantFile, serializeAssistant } from '@openchatlab/node-runtime' -export { getBuiltinToolCatalog, type BuiltinToolCatalogEntry } from './builtinTools' diff --git a/apps/desktop/main/ipc/chat.ts b/apps/desktop/main/ipc/chat.ts index ef344ade..3dce47ca 100644 --- a/apps/desktop/main/ipc/chat.ts +++ b/apps/desktop/main/ipc/chat.ts @@ -9,8 +9,13 @@ import { ipcMain, app, dialog } from 'electron' import * as databaseCore from '../database/core' import * as worker from '../worker/workerManager' -import { detectFormat, findEntryFileInDirectory, scanMultiChatFile, type ParseProgress } from '../parser' -import * as parser from '../parser' +import { + detectFormat, + findEntryFileInDirectory, + getSupportedFormats, + scanMultiChatFile, + type ParseProgress, +} from '@openchatlab/parser' import type { IpcContext } from './types' import { CURRENT_SCHEMA_VERSION, getPendingMigrationInfos } from '../database/migrations' import { t } from '../i18n' @@ -121,7 +126,7 @@ export function registerChatHandlers(ctx: IpcContext): void { }) ipcMain.handle('chat:getSupportedFormats', async () => { - return parser.getSupportedFormats() + return getSupportedFormats() }) ipcMain.handle('chat:prepareImportSource', async (_, filePath: string) => { diff --git a/apps/desktop/main/network/index.ts b/apps/desktop/main/network/index.ts deleted file mode 100644 index 20b1af3f..00000000 --- a/apps/desktop/main/network/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 网络模块入口 - * 导出代理配置功能 - */ - -export * from './proxy' diff --git a/apps/desktop/main/parser/index.ts b/apps/desktop/main/parser/index.ts deleted file mode 100644 index ee340c74..00000000 --- a/apps/desktop/main/parser/index.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Parser V2 - 模块入口(薄封装) - * 实际实现已迁移到 @openchatlab/parser 共享包 - */ -export { - detectFormat, - detectAllFormats, - getParser, - getSupportedFormats, - getFormatFeatureById, - getPreprocessor, - scanMultiChatFile, - needsPreprocess, - parseFile, - parseFileWithFormat, - parseFileSync, - parseFileInfo, - streamParseFile, - findEntryFileInDirectory, - FormatSniffer, - createSniffer, - getFileSize, - formatFileSize, - parseTimestamp, - isValidYear, - createProgress, - readFileHeadBytes, -} from '@openchatlab/parser' - -export type { - ParseOptions, - ParseEvent, - ParseResult, - ParseProgress, - FormatFeature, - Parser, - ParsedMeta, - ParsedMember, - ParsedMessage, - MultiChatInfo, - StreamParseCallbacks, - StreamParseOptions, -} from '@openchatlab/parser' diff --git a/apps/desktop/main/paths.ts b/apps/desktop/main/paths.ts index 089f03fd..1845d786 100644 --- a/apps/desktop/main/paths.ts +++ b/apps/desktop/main/paths.ts @@ -26,6 +26,14 @@ import * as fs from 'fs' import * as os from 'os' import * as path from 'path' import { loadConfig, writeConfigField } from '@openchatlab/config' +import { + createPendingDataDirMigration, + isDirectoryEmptyOrMissing, + isExistingUserDataDir, + isUserDataDirSafeToUse, + runPendingDataDirMigration, + type PendingDataDirMigration, +} from '@openchatlab/node-runtime' import { copyDirMerge, copyDirRecursive, @@ -36,14 +44,6 @@ import { writeMigrationLog, } from './utils/pathUtils' import { shouldMarkUnifiedDirMigrationDone } from './utils/unifiedDirMigration' -import { - createPendingDataDirMigration, - isDirectoryEmptyOrMissing, - isExistingUserDataDir, - isUserDataDirSafeToUse, - runPendingDataDirMigration, - type PendingDataDirMigration, -} from './utils/dataDirSwitch' // 缓存路径,避免重复计算 let _systemDataDir: string | null = null diff --git a/apps/desktop/main/utils/dataDirSwitch.ts b/apps/desktop/main/utils/dataDirSwitch.ts deleted file mode 100644 index 41b69d6e..00000000 --- a/apps/desktop/main/utils/dataDirSwitch.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { - createPendingDataDirMigration, - isDirectoryEmptyOrMissing, - isExistingUserDataDir, - isUserDataDirSafeToUse, - runPendingDataDirMigration, -} from '@openchatlab/node-runtime' -export type { PendingDataDirMigration } from '@openchatlab/node-runtime' diff --git a/apps/desktop/main/worker/import/utils.ts b/apps/desktop/main/worker/import/utils.ts index 7adf22e8..43a40db6 100644 --- a/apps/desktop/main/worker/import/utils.ts +++ b/apps/desktop/main/worker/import/utils.ts @@ -8,7 +8,7 @@ import * as path from 'path' import { parentPort } from 'worker_threads' import { getDbDir, openRawDatabase } from '../core' import { CHAT_DB_TABLES, CHAT_DB_INDEXES } from '@openchatlab/core' -import type { ParseProgress } from '../../parser' +import type { ParseProgress } from '@openchatlab/parser' export function sendProgress(requestId: string, progress: ParseProgress): void { parentPort?.postMessage({ diff --git a/apps/desktop/main/worker/query/session/index.ts b/apps/desktop/main/worker/query/session/index.ts index db5b733c..eea8965b 100644 --- a/apps/desktop/main/worker/query/session/index.ts +++ b/apps/desktop/main/worker/query/session/index.ts @@ -3,10 +3,9 @@ * 提供会话索引管理、AI 工具查询、自定义筛选和导出等功能 */ -// Types — core types re-exported via ./types, Electron-only types kept there -export type { ChatSessionItem, SessionIndexStats, SessionMessagesResult } from './types' - -export { DEFAULT_SESSION_GAP_THRESHOLD } from './types' +export type { ChatSessionItem, SessionIndexStats } from './sessionIndex' +export type { SessionMessagesResult } from './aiTools' +export { DEFAULT_SESSION_GAP_THRESHOLD } from '@openchatlab/core' // 会话索引管理 export { diff --git a/apps/desktop/main/worker/query/session/types.ts b/apps/desktop/main/worker/query/session/types.ts deleted file mode 100644 index 14c982ed..00000000 --- a/apps/desktop/main/worker/query/session/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Session module type definitions. - * Core types (ChatSessionItem, DEFAULT_SESSION_GAP_THRESHOLD) are re-exported - * from @openchatlab/core; Electron-only types remain here. - */ - -export { DEFAULT_SESSION_GAP_THRESHOLD } from '@openchatlab/core' -export type { ChatSessionItem, SessionIndexStats } from '@openchatlab/core' - -// AI tool types — re-exported from core via aiTools.ts -export type { SessionMessagesResult } from './aiTools' diff --git a/apps/desktop/main/worker/workerManager.ts b/apps/desktop/main/worker/workerManager.ts index 136ef419..1e163e92 100644 --- a/apps/desktop/main/worker/workerManager.ts +++ b/apps/desktop/main/worker/workerManager.ts @@ -7,7 +7,7 @@ import { Worker } from 'worker_threads' import { app } from 'electron' import * as path from 'path' import * as fs from 'fs' -import type { ParseProgress } from '../parser' +import type { ParseProgress } from '@openchatlab/parser' import type { AutoImportResult, StreamImportResult } from './import' import { getDatabaseDir, getCacheDir, getTempDir, getLogsDir, ensureDir } from '../paths' diff --git a/packages/node-runtime/src/ai/__tests__/builtin-chart-skill.test.ts b/packages/node-runtime/src/ai/__tests__/builtin-chart-skill.test.ts index 0bd802c0..bfc2b4ad 100644 --- a/packages/node-runtime/src/ai/__tests__/builtin-chart-skill.test.ts +++ b/packages/node-runtime/src/ai/__tests__/builtin-chart-skill.test.ts @@ -2,7 +2,7 @@ import { describe, it } from 'node:test' import assert from 'node:assert/strict' import { CHART_CAPABILITY_SKILL_ID } from '@openchatlab/core' -import { buildSkillMenuWithBuiltinChart, getSkillConfigWithBuiltinChart } from '../builtin-chart-skill' +import { buildSkillMenuWithBuiltinChart, getSkillConfigWithBuiltinChart } from '../chart-runtime' import { buildSkillMenuText, formatSkillMenuLine } from '../skill-menu' function requireMenu(menu: string | null): string { diff --git a/packages/node-runtime/src/ai/builtin-chart-skill.ts b/packages/node-runtime/src/ai/builtin-chart-skill.ts deleted file mode 100644 index a24dc3a8..00000000 --- a/packages/node-runtime/src/ai/builtin-chart-skill.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { - buildSkillMenuWithBuiltinChart, - getChartCapabilitySkill as getBuiltinChartSkill, - getSkillConfigWithBuiltinChart, -} from './chart-runtime' diff --git a/packages/tools/src/sql/types.ts b/packages/tools/src/sql/types.ts deleted file mode 100644 index d0411bcc..00000000 --- a/packages/tools/src/sql/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * 声明式 SQL 工具类型定义 - */ - -export { type SqlToolDef, type SqlToolExecution, type JsonSchema } from '../types'