Commit Graph
609 Commits
Author SHA1 Message Date
digua 4053b7c77f refactor(dev): reorganize dev scripts and port assignments
- dev: Electron only (renderer port 3400, unchanged)
- dev:app: Web frontend only (port 3100)
- dev:serve: Backend only (chatlab serve, default port 3110)
- dev:web: Web frontend + backend auto-start (3100 + 3110)
- Revert electron.vite.config.ts to original (no extra plugins)
- chatlabServePlugin gated by CHATLAB_AUTO_SERVE env var
2026-05-13 21:25:57 +08:00
digua 6695181759 fix(web): resolve runtime errors in web mode
- Fix streamImport error handling: close db before deleting files on failure
- Add POST /_web/sessions/:id/query endpoint for parameterized readonly SQL
- Expose PreparedStatement.readonly property in DatabaseAdapter interface
- Fix Fastify error handler to respect statusCode on non-ApiError errors
- Implement FetchAdapter.pluginQuery via HTTP endpoint
- Add web-api-shim.ts: window.chatApi/aiApi polyfills for chart-* and
  MessageList (pluginQuery, pluginCompute, getMemberActivity,
  getAvailableYears, message browsing methods)
- Fix Sidebar: navigate to home after deleting the currently viewed session
2026-05-13 21:25:50 +08:00
digua d14931bf1b fix: guard Electron-specific calls in BasicSettingsTab for web mode
Add IS_ELECTRON guards around window.api.setThemeSource,
window.api.app.getOpenAtLogin, and window.api.app.setOpenAtLogin
to prevent crashes when opening settings in web mode.
2026-05-13 20:39:46 +08:00
digua a1a6bdbb10 fix: auto-start chatlab serve backend when running dev:web
Add chatlabServePlugin to vite.web.config.mts that automatically spawns
chatlab serve on port 3400 when Vite dev server starts, so the web UI
works without manually starting the backend in a separate terminal.
2026-05-13 20:35:40 +08:00
digua a7f7f8706b fix: move multipart plugin registration to server startup
Register @fastify/multipart in startHttpServer before route registration
instead of inside registerWebRoutes, fixing 500 errors on /_web/ routes
caused by async plugin registration within route functions.
2026-05-13 20:30:31 +08:00
digua 3363640e75 feat: add web import support with adapter pattern and ImportArea refactor
- Extend QueryAdapter with importFile, detectFormat, scanMultiChatFile,
  and getSupportedFormats methods
- Implement FetchAdapter import methods with FormData upload and SSE
  progress stream parsing
- Implement ElectronAdapter import methods wrapping existing IPC calls
- Refactor ImportArea.vue to handle both Electron (native dialog + paths)
  and Web (FileDropZone + File objects) import flows
- Add 'indexing' stage to ImportProgress type
- Revert CLI-only import UI, restore drag-and-drop for web mode
2026-05-13 20:28:46 +08:00
digua 008094710c feat(server): add HTTP file upload + SSE progress API for web import
Add /_web/import (multipart upload + SSE progress stream),
/_web/detect-format, /_web/scan-multi-chat, and /_web/supported-formats
endpoints. Register @fastify/multipart for file upload handling.
Files are saved to temp directory for parsing then cleaned up.
2026-05-13 20:23:08 +08:00
digua 93c736a3b9 feat(server): upgrade import pipeline to support all 14+ formats
Replace ChatLab-only reader with @openchatlab/parser in the server
import pipeline. Add streamImport() function for full-format streaming
parse + database write. Update CLI import command to use new pipeline
and add 'chatlab formats' command to list supported formats.
2026-05-13 20:21:32 +08:00
digua 4e1f03e252 refactor: extract parser to @openchatlab/parser shared package
Move all 14+ format parsers (QQ, WeChat, Telegram, WhatsApp, LINE,
Discord, Instagram, etc.) from electron/main/parser/ to packages/parser/
as a standalone shared package. Electron's parser module becomes a thin
re-export wrapper. This enables the server to use the same parser for
CLI serve Web import functionality.
2026-05-13 20:19:13 +08:00
digua b1fbeb6f1d feat(server): add static file hosting to chatlab serve
Phase 3A.3: Enable chatlab serve to host the Web SPA frontend
alongside the HTTP API, creating a complete local web experience.

- Add --web [dir] option to chatlab serve (defaults to dist-web/)
- Use @fastify/static for efficient static file serving
- SPA history fallback via setNotFoundHandler -> index.html
- Skip web hosting gracefully if dist-web/ doesn't exist
- Add webRoot option to HttpServerOptions / startHttpServer
2026-05-13 19:57:25 +08:00
digua 17855858d7 feat(web): add standalone Web Vite build configuration
Phase 3A.2: Create vite.web.config.mts for building the CLI serve
Web SPA independently from the Electron build pipeline.

- __IS_ELECTRON__ = false, __IS_BROWSER_STANDALONE__ = false
- Output to dist-web/ (gitignored)
- Dev proxy: /_web and /api -> localhost:3400 (chatlab serve)
- Resolve aliases for @electron/shared and @electron/preload
  (type-only imports, erased at build time)
- npm scripts: dev:web, build:web
- Same manualChunks strategy as Electron renderer build
2026-05-13 19:56:14 +08:00
digua 086bd882a7 feat(web): implement FetchAdapter and /_web/ internal API routes
Phase 3A.1: Create the HTTP bridge between the Vue SPA frontend
and chatlab serve backend for the CLI serve Web version.

Server side (packages/server):
- Add /_web/ route group (routes/web.ts) with no auth requirement,
  covering: sessions CRUD, time range, member-activity/hourly/daily/
  weekday/message-type stats, members CRUD+pagination+merge+history,
  SQL Lab execute+schema.
- Skip auth hook for /_web/ prefix (same-origin internal API).
- Add getTimeRange() to @openchatlab/core basic queries.

Client side (src/adapters):
- FetchAdapter wrapping all /_web/ endpoints with proper HTTP verbs,
  TimeFilter query param serialization, and error handling.
- Unimplemented analysis methods (catchphrase, mention, cluster, etc.)
  throw descriptive errors for progressive enhancement.
- Wire FetchAdapter into adapter factory (non-Electron, non-browser).
2026-05-13 19:53:01 +08:00
digua 9ac4276465 refactor(adapters): replace window.chatApi calls with QueryAdapter
Phase 3.0.3: Systematically replace all data-query window.chatApi
calls across 24 files with getAdapter() from the new adapter layer.

Replaced categories:
- Session CRUD (getSessions, getSession, deleteSession, renameSession)
- Statistics (getMemberActivity, getHourlyActivity, getDailyActivity,
  getWeekdayActivity, getMessageTypeDistribution, getAvailableYears)
- Member management (getMembers, getMembersPaginated, updateMemberAliases,
  mergeMembers, deleteMember, getMemberNameHistory)
- Social analysis (getMentionAnalysis, getLaughAnalysis,
  getCatchphraseAnalysis, getLanguagePreferenceAnalysis,
  getRelationshipStats)
- SQL Lab (executeSQL, getSchema)

Remaining window.chatApi calls are Electron-specific operations
(import, migration, file dialog, demo, export) that will be handled
separately with IS_ELECTRON guards in future phases.

Also adds initAdapter() call in App.vue onMounted to bootstrap the
adapter before any data loading occurs.
2026-05-13 19:46:41 +08:00
digua f6b3dabc31 feat(adapters): define QueryAdapter interface and ElectronAdapter
Phase 3.0.1 + 3.0.2: Introduce the adapter abstraction layer for
multi-platform support (Electron / CLI serve Web / Online Web).

- src/adapters/types.ts: QueryAdapter interface with 30+ methods
  covering sessions, statistics, members, social analysis, SQL Lab,
  and plugin system. AdapterCapabilities for feature flags.
- src/adapters/electron.ts: ElectronAdapter wrapping window.chatApi
  with full capability support, zero behavior change for desktop.
- src/adapters/index.ts: async factory with compile-time adapter
  selection via __IS_ELECTRON__ / __IS_BROWSER_STANDALONE__.
- src/utils/platform.ts: add IS_BROWSER_STANDALONE detection.
- src/env.d.ts: declare __IS_BROWSER_STANDALONE__ global.
2026-05-13 19:37:57 +08:00
digua 847d75e4b6 feat(server): add chatlab import command with ChatLab JSON/JSONL parser
Implement self-contained ChatLab format reader (JSON and JSONL) and
database importer in packages/server/src/import/. Supports full import
(new session) and incremental import (dedup via platform_message_id or
content hash). Includes FTS index creation and member upsert.

CLI: chatlab import <file> [--session-id <id>] [--dry-run]
2026-05-11 20:37:39 +08:00
digua 95e4a1b5ee feat(server): add chatlab serve command for standalone HTTP API
Implement 'chatlab serve' CLI command with --port, --host, --token options.
Auto-generates and persists Bearer token on first run. Supports graceful
shutdown via SIGINT/SIGTERM. Verified: auth rejection, status endpoint,
session listing all working.
2026-05-11 20:29:27 +08:00
digua 9afabedca8 feat(server): extract standalone HTTP API from Electron
Create packages/server/src/http/ with platform-agnostic HTTP API:
- errors.ts: error codes and response helpers
- auth.ts: Bearer token auth using @openchatlab/config
- server.ts: Fastify factory with auth hook and error handler
- routes/system.ts: status and schema endpoints
- routes/sessions.ts: 7 session endpoints using DatabaseManager + core
- index.ts: server lifecycle (startHttpServer/stopHttpServer)

Add token field to @openchatlab/config apiConfigSchema.
Add fastify dependency to packages/server.
2026-05-11 20:28:26 +08:00
digua b66ac5d287 feat(core): add queryMessages and getMembersDetailed query functions
queryMessages supports keyword, time range, senderId filtering with
full pagination (total, page, totalPages). getMembersDetailed returns
accountName and groupNickname fields for HTTP API export compatibility.
2026-05-11 20:25:39 +08:00
digua d040aaaa98 feat(server): isolate better-sqlite3 native binary for Electron/Node coexistence
Add rebuild-native.sh script that compiles better-sqlite3 in an isolated
temp directory for system Node.js, storing the binary at packages/server/native/.
DatabaseManager and openBetterSqliteDatabase now accept nativeBinding option.
CLI auto-detects non-Electron environment and uses the isolated binary.
2026-05-11 20:24:39 +08:00
digua 0d0dbdb6ce feat(server): implement MCP Server with stdio transport
Phase 2.2: add chatlab mcp command that starts an MCP stdio server.
Registers 8 tools from @openchatlab/tools and 3 resources (sessions
list, session meta, session schema). Compatible with Claude Desktop
and Cursor MCP client configuration.
2026-05-11 20:09:15 +08:00
digua 814ac8a56b feat(tools): create @openchatlab/tools with platform-agnostic AI tools
Phase 2.1: extract tool definitions from electron/main/ai/tools/ into
a shared package. Tools use DatabaseAdapter directly instead of
workerManager. Includes: sessions, session_info, search, member_stats,
time_stats, recent_messages, sql, schema (8 tools total).
2026-05-11 20:06:50 +08:00
digua 540b0d0c55 fix(server): add rebuild-sqlite script for Node.js compatibility
The root project's electron-rebuild compiles better-sqlite3 for
Electron's Node ABI, making it incompatible with system Node.js.
Add a convenience script to rebuild for the current Node version.
2026-05-11 20:04:33 +08:00
digua c09f304304 feat(server): create chatlab CLI skeleton with core commands
Phase 1.8: create the chatlab npm package with commander-based CLI
providing sessions, stats, search, members, query, and config commands.

Commands implemented:
- chatlab sessions: list all imported chat sessions
- chatlab stats <id>: session statistics overview
- chatlab search <id> <keyword>: search messages by keyword
- chatlab members <id>: list chat members
- chatlab query <id> --sql "...": execute readonly SQL
- chatlab config path/show: configuration management
2026-05-11 20:01:44 +08:00
digua 7535f77eaa feat(node-runtime): add DatabaseManager for session DB lifecycle
Phase 1.7: add DatabaseManager to @openchatlab/node-runtime that handles
opening, caching, listing, and closing chat session databases using the
DatabaseAdapter and PathProvider interfaces from core.
2026-05-11 19:56:14 +08:00
digua e49f2fbbe8 feat(config): create @openchatlab/config package
Phase 1.6: configuration management with TOML/JSON file support,
CHATLAB_* environment variable overrides, and Zod schema validation.
Config file location: ~/.chatlab/config.toml
2026-05-11 19:55:33 +08:00
digua 6d1408ec56 feat(core): extract schema definitions and migration framework
Phase 1.5: extract CHAT_DB_SCHEMA DDL (6 tables + FTS5 + indexes) and
a platform-agnostic migration framework (version detection, migration
runner) into @openchatlab/core. Platform-specific migration scripts
(e.g. FTS tokenization) remain in the runtime layer.
2026-05-11 19:54:05 +08:00
digua 0e034e7e84 feat(core): extract SQL query logic into platform-agnostic core
Phase 1.4: extract session, basic stats, and message query functions
from electron/main/worker/query/ into @openchatlab/core. All functions
accept DatabaseAdapter parameter instead of relying on global state.

Includes: session meta/overview, member activity, hourly/daily/weekday
stats, message type stats, LIKE search, recent messages, member list,
and readonly SQL execution.
2026-05-11 19:48:59 +08:00
digua ebf941b53f feat(node-runtime): add NodePathProvider for standalone Node.js
Phase 1.3: implement PathProvider for CLI/service mode using
~/.chatlab/data/ as default data directory with CHATLAB_DATA_DIR
environment variable override support.
2026-05-11 19:46:27 +08:00
digua 7c99ae2d26 feat(node-runtime): add BetterSqliteAdapter implementing DatabaseAdapter
Phase 1.2: create @openchatlab/node-runtime package with better-sqlite3
adapter that implements the DatabaseAdapter interface from core. Also add
pragma() method to the DatabaseAdapter interface.
2026-05-11 19:45:45 +08:00
digua d1e160fe23 feat(core): init @openchatlab/core package with abstract interfaces
Phase 1.1 of CLI/Web transformation: create the platform-agnostic core
package with DatabaseAdapter, PathProvider, NotificationBus interfaces
and query filter utilities extracted from worker/core/dbCore.ts.
2026-05-11 19:44:24 +08:00
digua 24bdcc0a0e docs: update 2026-05-09 00:28:41 +08:00
diguaandClaude Sonnet 4.6 6035ad2bcc chore: simplify Linux download links in release notes to AppImage only
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-09 00:27:04 +08:00
digua 3e26e5b41b feat: 使用新Icon 2026-05-09 00:27:04 +08:00
digua 4e7ba91409 release: v0.19.0 v0.19.0 2026-05-07 00:02:51 +08:00
digua 63af381f27 fix: 修复部分BUG 2026-05-06 23:56:45 +08:00
digua 0f9f21db83 feat: 迁移到pnpm-workspace 2026-05-06 23:56:45 +08:00
digua f181c70402 feat: 新用户支持查看Demo示例 2026-05-06 23:56:45 +08:00
digua 50da84fe38 feat: 移除向量模型配置逻辑 2026-05-06 23:56:45 +08:00
digua f6cc5c8fb8 feat: 优化设置和展示逻辑 2026-05-06 23:56:45 +08:00
digua 99b4d3e275 feat: debug_context 记录完整 LLM 上下文 2026-05-06 23:56:45 +08:00
digua df0b2a36d2 feat: 上下文压缩行为优化 2026-05-06 23:56:45 +08:00
digua 0c3bbcb37a feat: 优化AI模型配置文案和UI 2026-05-06 23:56:45 +08:00
digua 47ef10f780 feat: 上下文压缩逻辑优化 2026-05-06 23:56:45 +08:00
digua 59f1548258 feat: 重构debug模式,新增原始数据查看 2026-05-06 23:56:45 +08:00
digua b290a85499 feat: 优化上下文窗口配置逻辑 2026-05-06 23:56:45 +08:00
digua 5fc7b5670c feat: 支持上下文自动压缩和新增相关配置 2026-05-06 23:56:45 +08:00
digua ecdb699579 feat: 支持模型上下文窗口预设和配置 2026-05-06 23:56:45 +08:00
digua 70a164502e release: v0.18.4 v0.18.4 2026-04-29 00:06:34 +08:00
digua 78689b2650 fix: 修复部分逻辑漏洞 2026-04-28 23:18:35 +08:00
digua dd1fdfe923 chore: 同步日志技能逻辑优化 2026-04-28 23:18:35 +08:00