Skip to content

Commit 479606f

Browse files
committed
docs(notify): replace terminal notification examples with Feishu webhook example
- Remove iTerm2/Windows Terminal OSC 9, macOS osascript, Linux notify-send, and Windows msg examples (OSC 9 is not compatible with current spawn+stdio:ignore architecture) - Add Feishu (Lark) webhook notification example in both Chinese and English docs - Keep the env variable table (DURATION, STATUS, FAIL_REASON, BODY, TITLE) unchanged
1 parent a3ff70e commit 479606f

2 files changed

Lines changed: 44 additions & 80 deletions

File tree

docs/configuration.md

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -83,53 +83,35 @@ Deep Code 使用 `settings.json` 设置文件进行持久化配置,支持两
8383
}
8484
```
8585

86-
**终端内通知示例(支持 iTerm2 / Windows Terminal)**
86+
**飞书 Webhook 通知示例**
8787

88-
如果你的终端是 iTerm2 或 Windows Terminal,可以直接通过 OSC 9 转义序列弹出终端原生通知,无需额外依赖。创建以下脚本(如 `~/.deepcode/notify.sh`
88+
`node` 构建 JSON(自动转义特殊字符),`curl` 发送
8989

9090
```bash
9191
#!/bin/bash
92-
# iTerm2 / Windows Terminal OSC 9 通知
93-
printf '\x1b]9;DeepCode: task %s (%ss)\x07' "${STATUS:-completed}" "${DURATION}"
94-
```
95-
96-
```json
97-
{
98-
"notify": "/Users/you/.deepcode/notify.sh"
99-
}
100-
```
101-
102-
Windows 用户如使用 Git Bash,上述脚本同样可用;也可创建 `.bat` 脚本:
103-
104-
```batch
105-
@echo off
106-
REM Windows Terminal OSC 9 通知
107-
echo \x1b]9;DeepCode: task %STATUS% (%DURATION%s)\x07
108-
```
109-
110-
**macOS 系统通知示例**
111-
112-
```bash
113-
#!/bin/bash
114-
# macOS 系统通知
115-
osascript -e "display notification \"任务已${STATUS:-完成},耗时 ${DURATION}s\" with title \"DeepCode\""
116-
```
117-
118-
**Linux 系统通知示例**(需安装 `libnotify-bin`):
92+
WEBHOOK_URL="https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxx"
93+
94+
STATUS="${STATUS:-completed}"
95+
TITLE="${TITLE:-Untitled}"
96+
DURATION="${DURATION:-0}"
97+
BODY="${BODY:-(no output)}"
98+
99+
PAYLOAD=$(node -e "
100+
process.stdout.write(JSON.stringify({
101+
msg_type: 'interactive',
102+
card: {
103+
header: { title: { tag: 'plain_text', content: 'DeepCode: ' + process.env.TITLE + ' ' + process.env.STATUS + ' [' + process.env.DURATION + 's]' } },
104+
elements: [{ tag: 'markdown', content: (process.env.BODY || '').slice(0, 2000) || '(no output)' }]
105+
}
106+
}))
107+
")
119108

120-
```bash
121-
#!/bin/bash
122-
# Linux notify-send 通知
123-
notify-send "DeepCode" "任务已${STATUS:-完成},耗时 ${DURATION}s"
109+
curl -s -X POST "$WEBHOOK_URL" \
110+
-H "Content-Type: application/json" \
111+
-d "$PAYLOAD"
124112
```
125113

126-
**Windows msg 弹窗通知示例**
127-
128-
```batch
129-
@echo off
130-
REM Windows msg 弹窗通知
131-
msg %USERNAME% "DeepCode: task %STATUS% (%DURATION%s)"
132-
```
114+
`WEBHOOK_URL` 替换为你的飞书机器人 Webhook 地址。更多变量参考上表。同样适用于 Slack、企业微信等 webhook 类通知,只需修改 JSON payload 格式。
133115

134116
#### `webSearchTool` — 自定义联网搜索
135117

docs/configuration_en.md

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -83,53 +83,35 @@ The following context is injected as environment variables when the notify scrip
8383
}
8484
```
8585

86-
**Terminal Notification Example (iTerm2 / Windows Terminal)**:
86+
**Feishu (Lark) Webhook Notification Example**:
8787

88-
On iTerm2 or Windows Terminal you can use the OSC 9 escape sequence for native terminal notifications with zero dependencies. Create a script (e.g., `~/.deepcode/notify.sh`):
88+
`node` builds the JSON (auto-escapes special characters), `curl` sends it:
8989

9090
```bash
9191
#!/bin/bash
92-
# iTerm2 / Windows Terminal OSC 9 notification
93-
printf '\x1b]9;DeepCode: task %s (%ss)\x07' "${STATUS:-completed}" "${DURATION}"
94-
```
95-
96-
```json
97-
{
98-
"notify": "/Users/you/.deepcode/notify.sh"
99-
}
100-
```
101-
102-
Windows users on Git Bash can use the same script; alternatively create a `.bat` script:
103-
104-
```batch
105-
@echo off
106-
REM Windows Terminal OSC 9 notification
107-
echo \x1b]9;DeepCode: task %STATUS% (%DURATION%s)\x07
108-
```
109-
110-
**macOS System Notification Example**:
111-
112-
```bash
113-
#!/bin/bash
114-
# macOS system notification
115-
osascript -e "display notification \"Task ${STATUS:-completed}, took ${DURATION}s\" with title \"DeepCode\""
116-
```
117-
118-
**Linux System Notification Example** (requires `libnotify-bin`):
92+
WEBHOOK_URL="https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxx"
93+
94+
STATUS="${STATUS:-completed}"
95+
TITLE="${TITLE:-Untitled}"
96+
DURATION="${DURATION:-0}"
97+
BODY="${BODY:-(no output)}"
98+
99+
PAYLOAD=$(node -e "
100+
process.stdout.write(JSON.stringify({
101+
msg_type: 'interactive',
102+
card: {
103+
header: { title: { tag: 'plain_text', content: 'DeepCode: ' + process.env.TITLE + ' ' + process.env.STATUS + ' [' + process.env.DURATION + 's]' } },
104+
elements: [{ tag: 'markdown', content: (process.env.BODY || '').slice(0, 2000) || '(no output)' }]
105+
}
106+
}))
107+
")
119108

120-
```bash
121-
#!/bin/bash
122-
# Linux notify-send notification
123-
notify-send "DeepCode" "Task ${STATUS:-completed}, took ${DURATION}s"
109+
curl -s -X POST "$WEBHOOK_URL" \
110+
-H "Content-Type: application/json" \
111+
-d "$PAYLOAD"
124112
```
125113

126-
**Windows msg Popup Notification Example**:
127-
128-
```batch
129-
@echo off
130-
REM Windows msg popup notification
131-
msg %USERNAME% "DeepCode: task %STATUS% (%DURATION%s)"
132-
```
114+
Replace `WEBHOOK_URL` with your Feishu bot webhook URL. See the table above for all available variables. This pattern also works for other webhook-based notifications (Slack, WeCom, etc.) — just adjust the JSON payload format.
133115

134116
#### `webSearchTool` — Custom Web Search
135117

0 commit comments

Comments
 (0)