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
43 changes: 43 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Bug
description: Report a problem / 报告一个问题
title: "[BUG] "
labels:
- bug
body:
- type: markdown
attributes:
value: |
Remember: DeepChat is an open source gift, not a product you bought from a vendor.

Use English or Chinese. You may keep only one language when filling.
可以只使用其中一种语言填写,保留一种语言即可。

- type: input
id: system-details
attributes:
label: System details / 系统信息
description: CPU, GPU, OS and DeepChat version / CPU、GPU、操作系统与 DeepChat 版本
placeholder: e.g. M3 Max, macOS 15.0, DeepChat 0.10.0
validations:
required: true

- type: textarea
id: steps
attributes:
label: What's wrong? / 出了什么问题?
description: |
Briefly describe the problem and how to reproduce it (steps, expected vs actual).
简要描述问题及其复现步骤(步骤、预期与实际结果)。
placeholder: |
1. Go to ...
2. Click ...
Expected: ...
Actual: ...

1. 前往 ...
2. 点击 ...
预期:...
实际:...
validations:
required: true

63 changes: 0 additions & 63 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Enhancement
description: Feature or change / 功能或改动
title: "[Feature] "
labels:
- enhancement
body:
- type: markdown
attributes:
value: |
Remember: DeepChat is an open source gift, not a product you bought from a vendor.

Use English or Chinese. You may keep only one language when filling.
可以只使用其中一种语言填写,保留一种语言即可。

- type: textarea
id: request
attributes:
label: What do you need? / 你需要什么?
description: Describe the feature or change you want / 描述你希望的功能或改动
placeholder: |
English: I need ... because ...
中文:我需要……,因为……
validations:
required: true

33 changes: 0 additions & 33 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

45 changes: 0 additions & 45 deletions .github/pull_request_template.md

This file was deleted.

66 changes: 52 additions & 14 deletions src/main/presenter/configPresenter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export class ConfigPresenter implements IConfigPresenter {
private knowledgeConfHelper: KnowledgeConfHelper // Knowledge configuration helper
// Model status memory cache for high-frequency read/write operations
private modelStatusCache: Map<string, boolean> = new Map()
// Custom prompts cache for high-frequency read operations
private customPromptsCache: Prompt[] | null = null

constructor() {
this.userDataPath = app.getPath('userData')
Expand Down Expand Up @@ -1194,45 +1196,81 @@ export class ConfigPresenter implements IConfigPresenter {
return nativeTheme.shouldUseDarkColors ? 'dark' : 'light'
}

// 获取所有自定义 prompts
// 获取所有自定义 prompts (with cache)
async getCustomPrompts(): Promise<Prompt[]> {
// Check cache first
if (this.customPromptsCache !== null) {
return this.customPromptsCache
}

// Load from store and cache it
try {
return this.customPromptsStore.get('prompts') || []
} catch {
const prompts = this.customPromptsStore.get('prompts') || []
this.customPromptsCache = prompts
console.log(`[Config] Custom prompts cache loaded: ${prompts.length} prompts`)
return prompts
} catch (error) {
console.error('[Config] Failed to load custom prompts:', error)
this.customPromptsCache = []
return []
}
}
Comment on lines +1199 to 1217
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Do not cache failure results; also use English comments per guidelines

Caching [] on error locks out future reads until an external invalidation. Prefer leaving cache null after failures. Also, comments must be in English (see coding guidelines).

Apply this diff:

-  // 获取所有自定义 prompts (with cache)
+  // Get all custom prompts (with cache)
   async getCustomPrompts(): Promise<Prompt[]> {
     // Check cache first
     if (this.customPromptsCache !== null) {
       return this.customPromptsCache
     }

     // Load from store and cache it
     try {
       const prompts = this.customPromptsStore.get('prompts') || []
       this.customPromptsCache = prompts
       console.log(`[Config] Custom prompts cache loaded: ${prompts.length} prompts`)
       return prompts
     } catch (error) {
       console.error('[Config] Failed to load custom prompts:', error)
-      this.customPromptsCache = []
+      this.customPromptsCache = null
       return []
     }
   }
🤖 Prompt for AI Agents
In src/main/presenter/configPresenter/index.ts around lines 1199 to 1217, change
the Chinese comment to English and stop caching failure results: update the
comment to "Get all custom prompts (with cache)"; when an error occurs, do not
set this.customPromptsCache = [] — leave this.customPromptsCache as null so
future reads can retry; keep logging the error but remove the cache assignment
in the catch block so failures aren't persisted.


// 保存自定义 prompts
// 保存自定义 prompts (with cache update)
async setCustomPrompts(prompts: Prompt[]): Promise<void> {
await this.customPromptsStore.set('prompts', prompts)
this.clearCustomPromptsCache()
console.log(`[Config] Custom prompts cache updated: ${prompts.length} prompts`)
}

// 添加单个 prompt
// 添加单个 prompt (optimized with cache)
async addCustomPrompt(prompt: Prompt): Promise<void> {
const prompts = await this.getCustomPrompts()
prompts.push(prompt)
await this.setCustomPrompts(prompts)
// 事件会在 setCustomPrompts 中触发
const updatedPrompts = [...prompts, prompt] // Create new array
await this.setCustomPrompts(updatedPrompts)
this.clearCustomPromptsCache()
console.log(`[Config] Added custom prompt: ${prompt.name}`)
}

// 更新单个 prompt
// 更新单个 prompt (optimized with cache)
async updateCustomPrompt(promptId: string, updates: Partial<Prompt>): Promise<void> {
const prompts = await this.getCustomPrompts()
const index = prompts.findIndex((p) => p.id === promptId)
if (index !== -1) {
prompts[index] = { ...prompts[index], ...updates }
await this.setCustomPrompts(prompts)
// 事件会在 setCustomPrompts 中触发
const updatedPrompts = [...prompts] // Create new array
updatedPrompts[index] = { ...updatedPrompts[index], ...updates }
await this.setCustomPrompts(updatedPrompts)
// remove cache
this.clearCustomPromptsCache()
console.log(`[Config] Updated custom prompt: ${promptId}`)
} else {
console.warn(`[Config] Custom prompt not found for update: ${promptId}`)
}
}

// 删除单个 prompt
// 删除单个 prompt (optimized with cache)
async deleteCustomPrompt(promptId: string): Promise<void> {
const prompts = await this.getCustomPrompts()
const initialCount = prompts.length
const filteredPrompts = prompts.filter((p) => p.id !== promptId)

if (filteredPrompts.length === initialCount) {
console.warn(`[Config] Custom prompt not found for deletion: ${promptId}`)
return
}

await this.setCustomPrompts(filteredPrompts)
// 事件会在 setCustomPrompts 中触发
this.clearCustomPromptsCache()
console.log(`[Config] Deleted custom prompt: ${promptId}`)
}

/**
* 清除自定义 prompts 缓存
* 这将强制下次访问时重新加载
*/
clearCustomPromptsCache(): void {
console.log('[Config] Clearing custom prompts cache')
this.customPromptsCache = null
}
Comment on lines +1267 to 1274
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Comments must be in English

Align with repository guidelines.

Apply this diff:

-  /**
-   * 清除自定义 prompts 缓存
-   * 这将强制下次访问时重新加载
-   */
+  /**
+   * Clear custom prompts cache
+   * Forces reload on next access
+   */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* 清除自定义 prompts 缓存
* 这将强制下次访问时重新加载
*/
clearCustomPromptsCache(): void {
console.log('[Config] Clearing custom prompts cache')
this.customPromptsCache = null
}
/**
* Clear custom prompts cache
* Forces reload on next access
*/
clearCustomPromptsCache(): void {
console.log('[Config] Clearing custom prompts cache')
this.customPromptsCache = null
}
🤖 Prompt for AI Agents
In src/main/presenter/configPresenter/index.ts around lines 1267 to 1274, the
block comment above clearCustomPromptsCache is written in Chinese; update the
comment to English to match repository guidelines—replace the existing Chinese
comment with a concise English JSDoc or single-line comment describing that the
method clears the custom prompts cache and forces reload on next access, keeping
the implementation unchanged.


// 获取默认系统提示词
Expand Down
26 changes: 26 additions & 0 deletions src/main/presenter/mcpPresenter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,32 @@ export class McpPresenter implements IMCPPresenter {
* @returns Prompt template content
*/
async getPrompt(prompt: PromptListEntry, args?: Record<string, unknown>): Promise<unknown> {
// Check if this is a custom prompt from deepchat/custom-prompts-server
if (prompt.client.name === 'deepchat/custom-prompts-server') {
console.log(`[MCP] Getting custom prompt: ${prompt.name}`)
try {
const customPrompts = await this.configPresenter.getCustomPrompts()
const foundPrompt = customPrompts.find((p) => p.name === prompt.name)

if (foundPrompt) {
// Return the prompt in the expected format
return {
name: foundPrompt.name,
description: foundPrompt.description,
content: foundPrompt.content || '',
messages: foundPrompt.messages || [],
arguments: foundPrompt.parameters || []
}
} else {
throw new Error(`Custom prompt "${prompt.name}" not found`)
}
} catch (error) {
console.error(`[MCP] Failed to get custom prompt "${prompt.name}":`, error)
throw error
}
}

// For MCP server prompts, check if MCP is enabled
const enabled = await this.configPresenter.getMcpEnabled()
if (!enabled) {
throw new Error('MCP functionality is disabled')
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/stores/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export const useMcpStore = defineStore('mcp', () => {
arguments: prompt.parameters || [],
files: prompt.files || [],
client: {
name: 'config',
name: 'deepchat/custom-prompts-server',
icon: '⚙️'
}
}))
Expand Down