Skip to content

Commit c323f2f

Browse files
merge upstream/main: resolve conflict in session.test.ts
2 parents c081efd + 59523fc commit c323f2f

38 files changed

Lines changed: 2320 additions & 510 deletions

README_en.md renamed to README-en.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
# Deep Code CLI
1+
<div align="center">
2+
<br/>
3+
<br/>
4+
<p align="center">
5+
<a href='https://deepcode.vegamo.cn/'>
6+
<img src='https://avatars.githubusercontent.com/u/118287711?s=200&v=4' width='100' alt="deepcode-cli"/>
7+
</a>
8+
</p>
9+
<h1>Deep Code CLI</h1>
10+
11+
English · [中文](./README.md)
12+
13+
<br/>
14+
</div>
215

316
[Deep Code](https://github.com/lessweb/deepcode-cli) is a terminal AI coding assistant optimized for the `deepseek-v4` model, with support for deep thinking, reasoning effort control, Agent Skills, and MCP (Model Context Protocol) integration.
417

18+
519
## Installation
620

721
```bash
@@ -53,6 +67,7 @@ Deep Code CLI supports agent skills that allow you to extend the assistant's cap
5367
| `/new` | Start a fresh conversation |
5468
| `/resume` | Choose a previous conversation to continue |
5569
| `/model` | Switch model, thinking mode, and reasoning effort |
70+
| `/raw` | Toggle display mode (Normal / Lite / Raw scrollback) |
5671
| `/init` | Initialize an AGENTS.md file (LLM project instructions) |
5772
| `/skills` | List available skills |
5873
| `/mcp` | View MCP server status and available tools |
@@ -84,7 +99,7 @@ Deep Code supports multimodal input — you can paste images from the clipboard
8499

85100
### How to automatically send a Slack message after a task completes?
86101

87-
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, refer to: https://binfer.net/share/jby5xnc-so6g
102+
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).
88103

89104
### How do I enable web search?
90105

README_cn.md renamed to README-zh_CN.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
# Deep Code CLI
1+
<div align="center">
2+
<br/>
3+
<br/>
4+
<p align="center">
5+
<a href='https://deepcode.vegamo.cn/'>
6+
<img src='https://avatars.githubusercontent.com/u/118287711?s=200&v=4' width='100' alt="deepcode-cli"/>
7+
</a>
8+
</p>
9+
<h1>Deep Code CLI</h1>
10+
11+
[English](README-en.md) · 中文
12+
13+
<br/>
14+
</div>
215

316
[Deep Code](https://github.com/lessweb/deepcode-cli) 是专为 `deepseek-v4` 模型优化的终端 AI 编码助手,支持深度思考、推理强度控制、Agent Skills 以及 MCP 集成。
417

@@ -53,6 +66,7 @@ Deep Code CLI 支持 agent skills,允许您扩展助手的能力:
5366
| `/new` | 开始新对话 |
5467
| `/resume` | 选择历史对话继续 |
5568
| `/model` | 切换模型、思考模式和推理强度 |
69+
| `/raw` | 切换显示模式(Normal / Lite / Raw 滚动回溯)|
5670
| `/init` | 初始化 AGENTS.md 文件 |
5771
| `/skills` | 列出可用 skills |
5872
| `/mcp` | 查看 MCP 服务器状态和可用工具 |
@@ -85,7 +99,7 @@ Deep Code 支持多模态,可使用ctrl+v从剪贴板粘贴图片。但目前
8599

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

88-
编写一个调用 Slack webhook 的 Shell 通知脚本,然后在 `~/.deepcode/settings.json` 中将 `notify` 字段设为该脚本的完整路径即可。详细步骤可参考:https://binfer.net/share/jby5xnc-so6g
102+
编写一个调用 Slack webhook 的 Shell 通知脚本,然后在 `~/.deepcode/settings.json` 中将 `notify` 字段设为该脚本的完整路径即可。详细步骤请参考 [docs/notify.md](docs/notify.md)
89103

90104
### 怎样启用联网搜索功能?
91105

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
# Deep Code CLI
1+
<div align="center">
2+
<br/>
3+
<br/>
4+
<p align="center">
5+
<a href='https://deepcode.vegamo.cn/'>
6+
<img src='https://avatars.githubusercontent.com/u/118287711?s=200&v=4' width='100' alt="deepcode-cli"/>
7+
</a>
8+
</p>
9+
<h1>Deep Code CLI</h1>
10+
11+
[English](README-en.md) · 中文
12+
13+
<br/>
14+
</div>
215

316
[Deep Code](https://github.com/lessweb/deepcode-cli) 是专为 `deepseek-v4` 模型优化的终端 AI 编码助手,支持深度思考、推理强度控制、Agent Skills 以及 MCP 集成。
417

@@ -53,6 +66,7 @@ Deep Code CLI 支持 agent skills,允许您扩展助手的能力:
5366
| `/new` | 开始新对话 |
5467
| `/resume` | 选择历史对话继续 |
5568
| `/model` | 切换模型、思考模式和推理强度 |
69+
| `/raw` | 切换显示模式(Normal / Lite / Raw 滚动回溯)|
5670
| `/init` | 初始化 AGENTS.md 文件 |
5771
| `/skills` | 列出可用 skills |
5872
| `/mcp` | 查看 MCP 服务器状态和可用工具 |
@@ -85,7 +99,7 @@ Deep Code 支持多模态,可使用ctrl+v从剪贴板粘贴图片。但目前
8599

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

88-
编写一个调用 Slack webhook 的 Shell 通知脚本,然后在 `~/.deepcode/settings.json` 中将 `notify` 字段设为该脚本的完整路径即可。详细步骤可参考:https://binfer.net/share/jby5xnc-so6g
102+
编写一个调用 Slack webhook 的 Shell 通知脚本,然后在 `~/.deepcode/settings.json` 中将 `notify` 字段设为该脚本的完整路径即可。详细步骤请参考 [docs/notify.md](docs/notify.md)
89103

90104
### 怎样启用联网搜索功能?
91105

docs/configuration.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,24 @@ Deep Code 使用 `settings.json` 设置文件进行持久化配置,支持两
6767

6868
设置一个 Shell 脚本的完整路径。当 AI 助手完成一轮任务后,会自动执行该脚本,可用于发送通知(如 Slack 消息)。
6969

70+
通知脚本执行时,会通过环境变量注入以下上下文信息:
71+
72+
| 环境变量 | 说明 |
73+
|----------|------|
74+
| `DURATION` | 会话耗时,单位秒(整数) |
75+
| `STATUS` | 会话状态:`"completed"``"failed"` |
76+
| `FAIL_REASON` | 失败原因(仅失败时设置) |
77+
| `BODY` | 最后一条 AI 助手回复的文本内容 |
78+
| `TITLE` | 会话标题(对应 resume 列表中的标题) |
79+
7080
```json
7181
{
72-
"notify": "/path/to/slack-notify.sh"
82+
"notify": "/path/to/notify-script.sh"
7383
}
7484
```
7585

86+
> 详细的 Slack、飞书、终端通知、系统通知等配置示例,请参阅 [notify.md](notify.md)
87+
7688
#### `webSearchTool` — 自定义联网搜索
7789

7890
Deep Code 内置免费可用的 Web Search 工具。如果需要自定义搜索逻辑,可将 `webSearchTool` 设为一个可执行脚本的完整路径:

docs/configuration_en.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,24 @@ When thinking mode is enabled, controls the depth of the model’s reasoning:
6767

6868
Set a full path to a shell script. When the AI assistant finishes a round of tasks, the script is executed automatically, which can be used to send notifications (e.g., a Slack message).
6969

70+
The following context is injected as environment variables when the notify script runs:
71+
72+
| Variable | Description |
73+
|----------|-------------|
74+
| `DURATION` | Session duration in seconds (integer) |
75+
| `STATUS` | Session status: `"completed"` or `"failed"` |
76+
| `FAIL_REASON` | Failure reason (only set on failure) |
77+
| `BODY` | The text content of the last AI assistant reply |
78+
| `TITLE` | Session title (matches the resume list title) |
79+
7080
```json
7181
{
72-
"notify": "/path/to/slack-notify.sh"
82+
"notify": "/path/to/notify-script.sh"
7383
}
7484
```
7585

86+
> For detailed configuration examples (Slack, Feishu, terminal notifications, system notifications, etc.), see [notify_en.md](notify_en.md).
87+
7688
#### `webSearchTool` — Custom Web Search
7789

7890
Deep Code has a built-in, free-to-use Web Search tool. If you need custom search logic, set `webSearchTool` to the full path of an executable script:

docs/notify.md

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
# Deep Code 任务完成通知
2+
3+
当 AI 助手完成一轮任务后,Deep Code 可以自动执行一个通知脚本,将任务结果发送到你指定的渠道(如 Slack、系统通知等)。
4+
5+
## 工作原理
6+
7+
`settings.json` 中配置 `notify` 字段,指向一个可执行脚本的完整路径。每次 AI 助手完成任务应答后,Deep Code 会执行该脚本,并通过环境变量注入上下文信息。
8+
9+
## 注入的环境变量
10+
11+
| 环境变量 | 说明 |
12+
|----------|------|
13+
| `DURATION` | 会话耗时,单位秒(整数) |
14+
| `STATUS` | 会话状态:`"completed"``"failed"` |
15+
| `FAIL_REASON` | 失败原因(仅失败时设置) |
16+
| `BODY` | 最后一条 AI 助手回复的文本内容 |
17+
| `TITLE` | 会话标题(对应 resume 列表中的标题) |
18+
19+
## 配置方法
20+
21+
编辑 `~/.deepcode/settings.json`,添加 `notify` 字段:
22+
23+
```json
24+
{
25+
"env": {
26+
"MODEL": "deepseek-v4-pro",
27+
"BASE_URL": "https://api.deepseek.com",
28+
"API_KEY": "sk-..."
29+
},
30+
"thinkingEnabled": true,
31+
"reasoningEffort": "max",
32+
"notify": "/path/to/your-notify-script.sh"
33+
}
34+
```
35+
36+
你也可以在 `env` 中配置通知脚本所需的自定义环境变量,例如 Slack Webhook URL:
37+
38+
```json
39+
{
40+
"env": {
41+
"MODEL": "deepseek-v4-pro",
42+
"BASE_URL": "https://api.deepseek.com",
43+
"API_KEY": "sk-...",
44+
"SLACK_WEBHOOK_URL": "https://hooks.slack.com/services/*****/****/**********"
45+
},
46+
"notify": "/Users/you/.deepcode/notify-slack.sh"
47+
}
48+
```
49+
50+
这些 `env` 中的变量会被注入到脚本的执行环境中。
51+
52+
## Slack 通知
53+
54+
### 1. 获取 Slack Webhook URL
55+
56+
1. 创建 [Slack App](https://api.slack.com/apps)
57+
2. 在 App 页面点击 **Incoming Webhooks****Add New Webhook to Workspace**,生成 Webhook URL
58+
59+
### 2. 创建通知脚本
60+
61+
创建 `~/.deepcode/notify-slack.sh`
62+
63+
```bash
64+
#!/usr/bin/env bash
65+
SLACK_WEBHOOK_URL="${SLACK_WEBHOOK_URL:-}"
66+
CURRENT_DIR=$(pwd)
67+
BRANCH=$(git branch --show-current 2>/dev/null)
68+
curl -X POST "$SLACK_WEBHOOK_URL" \
69+
-H "Content-type: application/json" \
70+
--data "{
71+
\"text\": \"✅ Deep Code 任务已完成\n · cwd: $CURRENT_DIR\n · Branch: $BRANCH\n · Duration: $DURATION\"
72+
}"
73+
```
74+
75+
给脚本添加可执行权限:
76+
77+
```bash
78+
chmod +x ~/.deepcode/notify-slack.sh
79+
```
80+
81+
### 3. 配置 settings.json
82+
83+
```json
84+
{
85+
"env": {
86+
"SLACK_WEBHOOK_URL": "https://hooks.slack.com/services/*****/****/**********"
87+
},
88+
"notify": "/Users/you/.deepcode/notify-slack.sh"
89+
}
90+
```
91+
92+
> Python 版本的脚本同样支持,你可以在 `env` 中传入并引用任意自定义环境变量。
93+
94+
## 飞书 / 企业微信等 Webhook 通知
95+
96+
以下示例使用 `node` 构建 JSON(自动转义特殊字符),`curl` 发送。通过 `env` 传入 `WEBHOOK_URL`
97+
98+
```bash
99+
#!/bin/bash
100+
WEBHOOK_URL="${WEBHOOK_URL:-}"
101+
102+
STATUS="${STATUS:-completed}"
103+
TITLE="${TITLE:-Untitled}"
104+
DURATION="${DURATION:-0}"
105+
BODY="${BODY:-(no output)}"
106+
107+
PAYLOAD=$(node -e "
108+
process.stdout.write(JSON.stringify({
109+
msg_type: 'interactive',
110+
card: {
111+
header: { title: { tag: 'plain_text', content: 'DeepCode: ' + process.env.TITLE + ' ' + process.env.STATUS + ' [' + process.env.DURATION + 's]' } },
112+
elements: [{ tag: 'markdown', content: (process.env.BODY || '').slice(0, 2000) || '(no output)' }]
113+
}
114+
}))
115+
")
116+
117+
curl -s -X POST "$WEBHOOK_URL" \
118+
-H "Content-Type: application/json" \
119+
-d "$PAYLOAD"
120+
```
121+
122+
```json
123+
{
124+
"env": {
125+
"WEBHOOK_URL": "https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxx"
126+
},
127+
"notify": "/Users/you/.deepcode/notify-feishu.sh"
128+
}
129+
```
130+
131+
`WEBHOOK_URL` 替换为你的飞书机器人 Webhook 地址。此模式同样适用于 Slack、企业微信等 webhook 类通知,只需修改 JSON payload 格式。
132+
133+
## 终端通知(iTerm2 / Windows Terminal)
134+
135+
如果你的终端是 iTerm2 或 Windows Terminal,可以直接通过 OSC 9 转义序列弹出终端原生通知,无需额外依赖。
136+
137+
创建 `~/.deepcode/notify.sh`
138+
139+
```bash
140+
#!/bin/bash
141+
# iTerm2 / Windows Terminal OSC 9 通知
142+
printf '\x1b]9;DeepCode: task %s (%ss)\x07' "${STATUS:-completed}" "${DURATION}"
143+
```
144+
145+
```json
146+
{
147+
"notify": "/Users/you/.deepcode/notify.sh"
148+
}
149+
```
150+
151+
Windows 用户如使用 Git Bash,上述脚本同样可用;也可创建 `.bat` 脚本:
152+
153+
```batch
154+
@echo off
155+
REM Windows Terminal OSC 9 通知
156+
echo \x1b]9;DeepCode: task %STATUS% (%DURATION%s)\x07
157+
```
158+
159+
## macOS 系统通知
160+
161+
```bash
162+
#!/bin/bash
163+
# macOS 系统通知
164+
osascript -e "display notification \"任务已${STATUS:-完成},耗时 ${DURATION}s\" with title \"DeepCode\""
165+
```
166+
167+
```json
168+
{
169+
"notify": "/Users/you/.deepcode/notify.sh"
170+
}
171+
```
172+
173+
## Linux 系统通知
174+
175+
需要安装 `libnotify-bin`
176+
177+
```bash
178+
sudo apt install libnotify-bin # Debian/Ubuntu
179+
```
180+
181+
创建 `~/.deepcode/notify.sh`
182+
183+
```bash
184+
#!/bin/bash
185+
# Linux notify-send 通知
186+
notify-send "DeepCode" "任务已${STATUS:-完成},耗时 ${DURATION}s"
187+
```
188+
189+
```json
190+
{
191+
"notify": "/home/you/.deepcode/notify.sh"
192+
}
193+
```
194+
195+
## Windows msg 弹窗通知
196+
197+
```batch
198+
@echo off
199+
REM Windows msg 弹窗通知
200+
msg %USERNAME% "DeepCode: task %STATUS% (%DURATION%s)"
201+
```
202+
203+
```json
204+
{
205+
"notify": "C:\\Users\\you\\.deepcode\\notify.bat"
206+
}
207+
```
208+
209+
## 自定义通知脚本
210+
211+
你可以根据通知脚本注入的环境变量自行编写任意逻辑的通知脚本(Python、Node.js、Ruby 等均可),只要脚本可执行即可。脚本中可通过 `env` 字段传入额外需要的配置变量。

0 commit comments

Comments
 (0)