Skip to content

Commit d023ba6

Browse files
committed
feat(theme): 改进主题管理并增强终端背景适配
- 引入 ThemeManager 管理主题状态和事件,替代旧方式统一处理主题切换和预览 - AppContainer 中通过 ThemeManager 实例管理主题状态,订阅主题变更并自动更新 UI - 支持异步初始化主题管理器,检测终端背景并启动轮询动态刷新主题 - 在主题生成时根据终端背景自动反转文字色,提升不同终端背景的可读性 - 优化主题解析逻辑,新增 applyTerminalContrast 函数执行终端背景对比色调整 - 精简并重构主题相关代码和类型引用,去除冗余逻辑和重复状态维护 - 更新文档配置说明,详细介绍主题使用与自定义方案,支持更灵活预设与定制 - README 中新增主题使用快速切换说明和配置指南链接,提升用户体验
1 parent c7b2a49 commit d023ba6

15 files changed

Lines changed: 965 additions & 413 deletions

README-en.md

Lines changed: 23 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -103,129 +103,58 @@ Yes. Deep Code offers a full-featured VSCode extension, available on the [VSCode
103103

104104
Deep Code supports multimodal input — you can paste images from the clipboard with `Ctrl+V`. However, `deepseek-v4` does not support multimodal yet. Some models have multimodal capabilities but impose strict limits on multi-turn dialogue requests. For multimodal input, we recommend using the Volcano Ark `Doubao-Seed-2.0-pro` model, which has the best integration.
105105

106-
### How to automatically send a Slack message after a task completes?
106+
### How to send a Slack message after a task completes?
107107

108-
Write a shell notification script that calls a Slack webhook, then set the `notify` field in `~/.deepcode/settings.json` to the full path of the script. For detailed steps, see [docs/notify_en.md](docs/notify_en.md).
108+
Write a shell notification script that calls a Slack webhook, then set the `notify` field in `~/.deepcode/settings.json` to the full path of the script.
109109

110-
### How do I enable web search?
111-
112-
Deep Code comes with a built-in, free Web Search tool that works well for most use cases. If you prefer to use a custom script for web search, set the `webSearchTool` field in `~/.deepcode/settings.json` to the full path of your script. For detailed steps, refer to: https://github.com/qorzj/web_search_cli
110+
> 📖 See [docs/notify_en.md](docs/notify_en.md) for details.
113111
114-
### Does it support Coding Plan?
112+
### How do I enable web search?
115113

116-
Yes. Just set `env.BASE_URL` in `~/.deepcode/settings.json` to an OpenAI-compatible API endpoint. Take Volcano Ark's Coding Plan as an example:
117-
118-
```json
119-
{
120-
"env": {
121-
"MODEL": "ark-code-latest",
122-
"BASE_URL": "https://ark.cn-beijing.volces.com/api/coding/v3",
123-
"API_KEY": "**************"
124-
},
125-
"thinkingEnabled": true
126-
}
127-
```
114+
Deep Code comes with a built-in, free Web Search tool that works well for most use cases. If you prefer to use a custom script for web search, set the `webSearchTool` field in `~/.deepcode/settings.json` to the full path of your script. For details, refer to: https://github.com/qorzj/web_search_cli
128115

129116
### How do I configure MCP?
130117

131118
Deep Code supports MCP (Model Context Protocol) to connect external services such as GitHub, browsers, databases, and more. Configure the `mcpServers` field in `settings.json` to enable it, then use the `/mcp` command to view MCP server status and available tools.
132119

133-
For detailed setup instructions, see: [docs/mcp.md](docs/mcp.md)
120+
> 📖 See [docs/mcp.md](docs/mcp.md) for details.
134121
135-
### How to configure Deep Code to send notifications after a task completes?
122+
### How to configure notifications after a task completes?
136123

137-
When the AI assistant completes a task, Deep Code can automatically execute a notification script to send the task results to the specified channel (e.g., Slack, system notifications, etc.).
124+
When the AI assistant completes a task, Deep Code can automatically execute a notification script to send the results to your specified channel (e.g., Slack, system notifications, etc.).
138125

139-
For detailed configuration instructions, see: [docs/notify_en.md](docs/notify_en.md)
126+
> 📖 See [docs/notify_en.md](docs/notify_en.md) for details.
140127
141128
### Does Deep Code only support YOLO mode?
142129

143130
No. Deep Code has a built-in fine-grained permission control mechanism that lets you confirm operations before the AI assistant executes shell commands, reads/writes files, accesses the network, and more. You can configure each permission scope's policy — always allow, always ask, or deny — via the `permissions` field in `settings.json`. See [docs/permission.md](docs/permission.md) for details.
144131

145-
### How do I customize the theme?
146-
147-
Deep Code CLI includes multiple built-in preset themes, defaulting to the light theme (`light`). You can switch presets by setting `theme.preset` in `settings.json`, or set it to `"custom"` for full customization.
148-
149-
**Using preset themes**
150-
151-
Set `theme.preset` in `settings.json` to switch:
152-
153-
```json
154-
{
155-
"theme": {
156-
"preset": "dark"
157-
}
158-
}
159-
```
160-
161-
Available presets: `light` (default), `dark`, `github-light`, `github-dark`, `monokai`, `dracula`, `ansi`.
162-
163-
You can also use the `/theme` command at runtime to open the theme picker with live preview.
164-
165-
**Option 1: Partial overrides (preset="custom" + overrides)**
132+
### Does it support Coding Plan?
166133

167-
Override only the colors you want to change; the rest keep their defaults:
134+
Yes. Just set `env.BASE_URL` in `~/.deepcode/settings.json` to an OpenAI-compatible API endpoint. Take Volcano Ark's Coding Plan as an example:
168135

169136
```json
170137
{
171-
"theme": {
172-
"preset": "custom",
173-
"overrides": {
174-
"primary": "#ff6600",
175-
"success": "greenBright"
176-
}
177-
}
138+
"env": {
139+
"MODEL": "ark-code-latest",
140+
"BASE_URL": "https://ark.cn-beijing.volces.com/api/coding/v3",
141+
"API_KEY": "**************"
142+
},
143+
"thinkingEnabled": true
178144
}
179145
```
180146

181-
**Option 2: Full customization (preset="custom" + tokens)**
182-
183-
Provide a complete tokens object, merged on top of the light theme:
184-
185-
```json
186-
{
187-
"theme": {
188-
"preset": "custom",
189-
"tokens": {
190-
"primary": "#229ac3",
191-
"secondary": "#229ac3e6",
192-
"success": "green",
193-
"error": "red",
194-
"warning": "yellow",
195-
"info": "magenta",
196-
"text": "white",
197-
"textDim": "gray",
198-
"textBright": "white",
199-
"code": "cyan",
200-
"border": "gray",
201-
"gradients": ["#229ac3e6", "#229ac3e6"]
202-
}
203-
}
204-
}
205-
```
147+
### How to use and customize themes?
206148

207-
> Note: `overrides` and `tokens` only take effect when `preset` is set to `"custom"`. When `preset` is unset, the `light` theme is used by default.
149+
Deep Code CLI includes 8 built-in preset themes, supports the `/theme` command for live preview and switching, and allows full customization via `settings.json`.
208150

209-
Default light theme (`light`) color values:
151+
**Quick switch:** Run `/theme` to open the picker. Browse with arrow keys, confirm with Enter, cancel with Esc.
210152

211-
| Token | Default | Used For |
212-
|-------|---------|----------|
213-
| `primary` | `#229ac3` | Primary brand: user messages, selected items, status line bullets, Markdown headings |
214-
| `secondary` | `#229ac3e6` | Secondary brand: welcome screen logo text/border, exit panel border |
215-
| `success` | `#1a7f37` | Success: tool execution success, MCP ready, diff additions, low-risk permissions |
216-
| `error` | `#d1242f` | Error: tool execution failure, error lines, diff deletions, high-risk permissions |
217-
| `warning` | `#fa8c16` | Warning/in-progress: busy spinner, permission prompt border, list bullets, MCP starting |
218-
| `info` | `#0969da` | Info: skill loading tips, image attachment status |
219-
| `text` | `#3D4149` | Body text: permission prompt text, question text, ProcessStdout title |
220-
| `textDim` | `#646A71` | Secondary text: status line params, search placeholder, diff context, Markdown blockquotes |
221-
| `textBright` | `#1F2329` | Bright text: emphasized hints |
222-
| `code` | `#787f8a` | Code blocks and inline code |
223-
| `border` | `#999` | All component borders |
224-
| `gradients` | `["#229ac3", "#8250df"]` | Logo and exit panel gradient colors |
153+
**Available presets:** `light` (default), `dark`, `github-light`, `github-dark`, `monokai`, `dracula`, `ansi-light`, `ansi-dark`.
225154

226-
Color values support hex (`"#ff6600"`), hex with alpha (`"#229ac3e6"`), and chalk named colors (`"cyanBright"`, `"green"`).
155+
**Custom themes:** Supports simplified color palette (`colors`), partial overrides (`overrides`), and full customization (`tokens`).
227156

228-
> Note: `tokens` takes priority over `overrides` — if both are specified, only `tokens` is used. Theme settings can be placed in the global `~/.deepcode/settings.json` or the project-root `.deepcode/settings.json`.
157+
> 📖 See [docs/configuration.md](docs/configuration.md) for the full configuration guide.
229158
230159
## Contributing
231160

README-zh_CN.md

Lines changed: 11 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ Deep Code 支持多模态,可使用ctrl+v从剪贴板粘贴图片。但目前
105105

106106
### 怎样在任务完成后自动给 Slack 发消息?
107107

108-
编写一个调用 Slack webhook 的 Shell 通知脚本,然后在 `~/.deepcode/settings.json` 中将 `notify` 字段设为该脚本的完整路径即可。详细步骤请参考 [docs/notify.md](docs/notify.md)
108+
编写一个调用 Slack webhook 的 Shell 通知脚本,然后在 `~/.deepcode/settings.json` 中将 `notify` 字段设为该脚本的完整路径即可。
109+
110+
> 📖 详细配置指南 [docs/notify.md](docs/notify.md)
109111
110112
### 怎样启用联网搜索功能?
111113

@@ -115,13 +117,13 @@ Deep Code自带免费的、且大部分情况够用的Web Search工具。如果
115117

116118
Deep Code 支持 MCP(Model Context Protocol),可以连接 GitHub、浏览器、数据库等外部服务。在 `settings.json` 中配置 `mcpServers` 字段即可启用,启动后使用 `/mcp` 命令查看已配置的 MCP 服务器状态和可用工具。
117119

118-
详细配置指南:[docs/mcp.md](docs/mcp.md)
120+
> 📖 详细配置指南:[docs/mcp.md](docs/mcp.md)
119121
120122
### 如何配置 Deep Code 任务完成后发送通知?
121123

122124
当 AI 助手完成一轮任务后,Deep Code 可以自动执行一个通知脚本,将任务结果发送到你指定的渠道(如 Slack、系统通知等)。
123125

124-
详细配置指南:[docs/notify.md](docs/notify.md)
126+
> 📖 详细配置指南:[docs/notify.md](docs/notify.md)
125127
126128
### Deep Code 只支持 YOLO 模式吗?
127129

@@ -142,90 +144,17 @@ Deep Code 支持 MCP(Model Context Protocol),可以连接 GitHub、浏览
142144
}
143145
```
144146

145-
### 如何自定义主题?
146-
147-
Deep Code CLI 内置多套预设主题,默认使用浅色主题(`light`)。可在 `settings.json` 中设置 `theme.preset` 切换预设,或设为 `"custom"` 自定义颜色。
148-
149-
**使用预设主题**
150-
151-
`settings.json` 中设置 `theme.preset` 即可切换:
152-
153-
```json
154-
{
155-
"theme": {
156-
"preset": "dark"
157-
}
158-
}
159-
```
160-
161-
可用预设:`light`(默认)、`dark``github-light``github-dark``monokai``dracula``ansi`
162-
163-
也可在运行时使用 `/theme` 命令打开主题选择器,实时预览并切换。
164-
165-
**方式一:局部覆盖(preset="custom" + overrides)**
166-
167-
只覆盖需要调整的颜色,其余保持默认值:
168-
169-
```json
170-
{
171-
"theme": {
172-
"preset": "custom",
173-
"overrides": {
174-
"primary": "#ff6600",
175-
"success": "greenBright"
176-
}
177-
}
178-
}
179-
```
180-
181-
**方式二:完全自定义(preset="custom" + tokens)**
182-
183-
提供完整的 tokens 对象,基于浅色主题合并:
184-
185-
```json
186-
{
187-
"theme": {
188-
"preset": "custom",
189-
"tokens": {
190-
"primary": "#229ac3",
191-
"secondary": "#229ac3e6",
192-
"success": "green",
193-
"error": "red",
194-
"warning": "yellow",
195-
"info": "magenta",
196-
"text": "white",
197-
"textDim": "gray",
198-
"textBright": "white",
199-
"code": "cyan",
200-
"border": "gray",
201-
"gradients": ["#229ac3e6", "#229ac3e6"]
202-
}
203-
}
204-
}
205-
```
147+
### 如何使用和自定义主题?
206148

207-
> 注意:`overrides``tokens` 仅在 `preset``"custom"` 时生效。不配置 `preset` 时默认使用 `light` 主题
149+
Deep Code CLI 内置 8 套预设主题,支持 `/theme` 命令实时预览切换,也支持通过 `settings.json` 自定义配色
208150

209-
默认浅色主题(`light`)色值:
151+
**快速切换主题:** 运行 `/theme` 打开选择器,方向键浏览,Enter 确认,Esc 取消。
210152

211-
| Token | 默认值 | 用途 |
212-
|-------|--------|------|
213-
| `primary` | `#229ac3` | 主品牌色:用户消息、选中项、状态行 bullet、Markdown 标题 |
214-
| `secondary` | `#229ac3e6` | 辅助品牌色:欢迎屏 Logo 文字与边框、退出面板边框 |
215-
| `success` | `#1a7f37` | 成功:工具执行成功、MCP ready、diff 新增行、低风险权限色 |
216-
| `error` | `#d1242f` | 失败/错误:工具执行失败、Error 行、diff 删除行、高风险权限色 |
217-
| `warning` | `#fa8c16` | 警告/进行中:忙时 spinner、权限提示边框、列表标记色、MCP 启动中 |
218-
| `info` | `#0969da` | 特殊指示:技能加载提示、图片附件状态 |
219-
| `text` | `#3D4149` | 主文字色:权限提示正文、问题文字、ProcessStdout 标题 |
220-
| `textDim` | `#646A71` | 次要文字:状态行参数、搜索占位符、diff 上下文行、Markdown 引用块 |
221-
| `textBright` | `#1F2329` | 亮色文字:强调提示 |
222-
| `code` | `#787f8a` | 代码块/内联代码 |
223-
| `border` | `#999` | 所有组件的边框色 |
224-
| `gradients` | `["#229ac3", "#8250df"]` | Logo 与退出面板的渐变色数组 |
153+
**可用预设:** `light`(默认)、`dark``github-light``github-dark``monokai``dracula``ansi-light``ansi-dark`
225154

226-
颜色值支持 hex(`"#ff6600"`)、hex 含透明度(`"#229ac3e6"`)、chalk 命名色(`"cyanBright"``"green"`
155+
**自定义主题:** 支持简化色板(`colors`)、部分覆盖(`overrides`)、完全自定义(`tokens`)三种方式
227156

228-
> 注意:`tokens` 优先级高于 `overrides`——如果同时指定两者,仅 `tokens` 生效。主题配置可放在全局 `~/.deepcode/settings.json` 或项目根 `.deepcode/settings.json`
157+
> 📖 详细配置指南见 [docs/configuration.md](docs/configuration.md)
229158
230159
## 贡献
231160

0 commit comments

Comments
 (0)