Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ The LLM system follows a two-layer architecture:
- **Tool Execution**: Seamless integration with LLM providers
- **Format Conversion**: Bridges MCP tools with various LLM provider formats
- **Built-in Services**: In-memory servers for code execution, web access, file operations
- **Data Source Decoupling**: Custom prompts work independently of MCP through config data source

## Code Structure

Expand Down Expand Up @@ -218,6 +219,15 @@ The LLM system follows a two-layer architecture:
2. Register in `mcpPresenter/index.ts`
3. Add tool configuration UI if needed

### Managing Custom Prompts

Custom prompts are managed independently of MCP through the config data source:

1. **Config Storage**: Prompts stored via `configPresenter.getCustomPrompts()`
2. **UI Management**: Use `promptsStore` for CRUD operations in settings
3. **@ Operations**: Mention system loads from both config and MCP sources
4. **MCP Independence**: @ prompt functionality works even when MCP is disabled

### Creating New UI Components

1. Follow existing component patterns in `src/renderer/src/`
Expand Down
1 change: 0 additions & 1 deletion src/main/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const CONFIG_EVENTS = {
COPY_WITH_COT_CHANGED: 'config:copy-with-cot-enabled-changed',
PROXY_RESOLVED: 'config:proxy-resolved',
LANGUAGE_CHANGED: 'config:language-changed', // 新增:语言变更事件
CUSTOM_PROMPTS_SERVER_CHECK_REQUIRED: 'config:custom-prompts-server-check-required', // 新增:需要检查自定义提示词服务器事件
// 模型配置相关事件
MODEL_CONFIG_CHANGED: 'config:model-config-changed', // 模型配置变更事件
MODEL_CONFIG_RESET: 'config:model-config-reset', // 模型配置重置事件
Expand Down
26 changes: 2 additions & 24 deletions src/main/presenter/configPresenter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import path from 'path'
import { app, nativeTheme, shell } from 'electron'
import fs from 'fs'
import { CONFIG_EVENTS, SYSTEM_EVENTS, FLOATING_BUTTON_EVENTS } from '@/events'
import { McpConfHelper, SYSTEM_INMEM_MCP_SERVERS } from './mcpConfHelper'
import { McpConfHelper } from './mcpConfHelper'
import { presenter } from '@/presenter'
import { compare } from 'compare-versions'
import { defaultShortcutKey, ShortcutKeySetting } from './shortcutKeySettings'
Expand Down Expand Up @@ -942,26 +942,7 @@ export class ConfigPresenter implements IConfigPresenter {

// 获取MCP服务器配置
async getMcpServers(): Promise<Record<string, MCPServerConfig>> {
const servers = await this.mcpConfHelper.getMcpServers()

// 检查是否有自定义提示词,如果有则添加 custom-prompts-server
try {
const customPrompts = await this.getCustomPrompts()
if (customPrompts && customPrompts.length > 0) {
const customPromptsServerName = 'deepchat-inmemory/custom-prompts-server'
const systemServers = SYSTEM_INMEM_MCP_SERVERS[customPromptsServerName]

if (systemServers && !servers[customPromptsServerName]) {
servers[customPromptsServerName] = systemServers
servers[customPromptsServerName].disable = false
servers[customPromptsServerName].autoApprove = ['all']
}
}
} catch {
// 检查自定义提示词时出错
}

return servers
return await this.mcpConfHelper.getMcpServers()
}

// 设置MCP服务器配置
Expand Down Expand Up @@ -1162,9 +1143,6 @@ export class ConfigPresenter implements IConfigPresenter {
// 保存自定义 prompts
async setCustomPrompts(prompts: Prompt[]): Promise<void> {
await this.customPromptsStore.set('prompts', prompts)

// 通知MCP系统检查并启动/停止自定义提示词服务器(仅主进程内部)
eventBus.sendToMain(CONFIG_EVENTS.CUSTOM_PROMPTS_SERVER_CHECK_REQUIRED)
}

// 添加单个 prompt
Expand Down
39 changes: 29 additions & 10 deletions src/main/presenter/configPresenter/mcpConfHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,7 @@ const DEFAULT_MCP_SERVERS = {
}
// 这部分mcp有系统逻辑判断是否启用,不受用户配置控制,受软件环境控制
export const SYSTEM_INMEM_MCP_SERVERS: Record<string, MCPServerConfig> = {
'deepchat-inmemory/custom-prompts-server': {
command: 'deepchat-inmemory/custom-prompts-server',
args: [],
env: {},
descriptions: 'DeepChat内置自定义提示词服务',
icons: '📝',
autoApprove: ['all'],
type: 'inmemory' as MCPServerType,
disable: false
}
// custom-prompts-server 已移除,现在通过 config 数据源提供提示词功能
}
Comment on lines +317 to 318
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

System in‑memory server removal acknowledged.
Leaving SYSTEM_INMEM_MCP_SERVERS empty is fine; ensure no remaining references to custom-prompts-server exist.


🏁 Script executed:

#!/bin/bash
rg -nP -C2 'custom-prompts-server|deepchat-inmemory/custom-prompts-server'

Length of output: 7302


Remove all residual deepchat-inmemory/custom-prompts-server references
Ensure the custom-prompts-server is fully purged, including:

  • Translation entries in every src/renderer/src/i18n/*/mcp.json (the "deepchat-inmemory/custom-prompts-server" blocks)
  • The corresponding type in src/types/i18n.d.ts (lines ~405–407)
  • Startup logic in src/main/presenter/mcpPresenter/index.ts (checks and logs around line 132)
  • Legacy removal code in src/main/presenter/configPresenter/mcpConfHelper.ts (version < 0.3.5 cleanup at lines ~856–864)
🤖 Prompt for AI Agents
In src/main/presenter/configPresenter/mcpConfHelper.ts around lines 317–318,
remove the legacy cleanup block that references
"deepchat-inmemory/custom-prompts-server" and any code that conditionally
deletes or migrates that key; also search and purge all remaining references
project-wide: delete the "deepchat-inmemory/custom-prompts-server" translation
blocks from every src/renderer/src/i18n/*/mcp.json, remove the corresponding
type declaration in src/types/i18n.d.ts (the ~lines 405–407 entry), remove
startup checks/logs in src/main/presenter/mcpPresenter/index.ts (around line
132) that reference the custom-prompts-server, and ensure no other legacy
version <0.3.5 removal logic remains; run a repo-wide search for the string
"deepchat-inmemory/custom-prompts-server" to confirm complete removal and update
tests/typing if needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments only

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zerob13, understood - I'll keep this as analysis only.

The removal of the custom-prompts-server from SYSTEM_INMEM_MCP_SERVERS is correctly implemented. The residual references I identified can be cleaned up when convenient:

  • Translation files: src/renderer/src/i18n/*/mcp.json contain the server's display names
  • Type definitions: src/types/i18n.d.ts has the corresponding type entries
  • Startup logic: src/main/presenter/mcpPresenter/index.ts may have initialization checks
  • Legacy cleanup: The version < 0.3.5 migration code in this same file

The core functionality change is solid - custom prompts now work through the config data source independently of MCP, which aligns perfectly with the PR objectives.


🧠 Learnings used
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-26T14:13:46.601Z
Learning: Applies to src/main/presenter/mcpPresenter/inMemoryServers/**/*.ts : Implement new MCP tools under mcpPresenter/inMemoryServers/

Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-26T14:13:46.601Z
Learning: Applies to src/main/presenter/mcpPresenter/index.ts : Register new MCP tools in mcpPresenter/index.ts


export class McpConfHelper {
Expand Down Expand Up @@ -862,6 +853,34 @@ export class McpConfHelper {
}
}

// 移除 custom-prompts-server 服务(版本 < 0.3.5)
if (oldVersion && compare(oldVersion, '0.3.5', '<')) {
try {
const mcpServers = this.mcpStore.get('mcpServers') || {}
const customPromptsServerName = 'deepchat-inmemory/custom-prompts-server'

if (mcpServers[customPromptsServerName]) {
console.log('检测到旧版本的 custom-prompts-server,开始移除')
delete mcpServers[customPromptsServerName]
this.mcpStore.set('mcpServers', mcpServers)

// 从默认服务器列表中移除(如果存在)
const defaultServers = this.mcpStore.get('defaultServers') || []
const updatedDefaultServers = defaultServers.filter(
(name) => name !== customPromptsServerName
)
if (updatedDefaultServers.length !== defaultServers.length) {
this.mcpStore.set('defaultServers', updatedDefaultServers)
console.log('从默认服务器列表中移除 custom-prompts-server')
}

console.log('移除 custom-prompts-server 完成')
}
} catch (error) {
console.error('移除 custom-prompts-server 时出错:', error)
}
}

// 升级后检查并添加平台特有服务
try {
const mcpServers = this.mcpStore.get('mcpServers') || {}
Expand Down
3 changes: 0 additions & 3 deletions src/main/presenter/mcpPresenter/inMemoryServers/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { PowerpackServer } from './powerpackServer'
import { DifyKnowledgeServer } from './difyKnowledgeServer'
import { RagflowKnowledgeServer } from './ragflowKnowledgeServer'
import { FastGptKnowledgeServer } from './fastGptKnowledgeServer'
import { CustomPromptsServer } from './customPromptsServer'
import { DeepResearchServer } from './deepResearchServer'
import { AutoPromptingServer } from './autoPromptingServer'
import { ConversationSearchServer } from './conversationSearchServer'
Expand Down Expand Up @@ -78,8 +77,6 @@ export function getInMemoryServer(
configs: BuiltinKnowledgeConfig[]
}
)
case 'deepchat-inmemory/custom-prompts-server':
return new CustomPromptsServer()
case 'deepchat-inmemory/deep-research-server':
return new DeepResearchServer(env)
case 'deepchat-inmemory/auto-prompting-server':
Expand Down
173 changes: 0 additions & 173 deletions src/main/presenter/mcpPresenter/inMemoryServers/customPromptsServer.ts

This file was deleted.

Loading