feat(notify): pass STATUS, FAIL_REASON, BODY, TITLE as env vars to notify hook#90
Merged
Merged
Conversation
Contributor
Author
- Add NotifyContext type with status, failReason, body fields - buildNotifyEnv injects STATUS, FAIL_REASON, BODY when provided - maybeNotifyTaskCompletion extracts last assistant message as BODY - launchNotifyScript accepts optional context parameter - Add unit tests for new context env var injection - Update docs with env variable table and iTerm2/macOS notify examples
… examples; add edge-case tests - Expand OSC 9 example to cover both iTerm2 and Windows Terminal - Add .bat example for Windows Terminal users - Add Linux notify-send example - Add Windows msg popup notification example - Add tests for empty-string rejection and special character preservation
…ook 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
30a7394 to
479606f
Compare
- Add docs/notify.md and docs/notify_en.md with Slack, Feishu, terminal, macOS, Linux, Windows msg, and custom notification examples - Simplify notify section in configuration.md / configuration_en.md to field description + env table + reference to notify docs - Replace external binfer.net link with docs/notify.md in README FAQ across README.md, README-zh_CN.md, README-en.md
Collaborator
|
我做了一些文档的修改,把通知的内容都提取到notify.md中,configuration.md聚焦在配置上。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

变更内容
src/common/notify.ts:新增NotifyContext类型(status/failReason/body/title);buildNotifyEnv条件注入STATUS、FAIL_REASON、BODY、TITLE环境变量;launchNotifyScript新增可选的context参数;buildNotifyEnv不再将process.env全量透传给 notify 脚本,仅暴露显式配置的变量src/session.ts:maybeNotifyTaskCompletion从会话中提取最后一条 assistant 消息作为BODY,并传入session.status、session.failReason、session.summary作为 contextsrc/tests/settings-and-notify.test.ts:新增 5 个测试用例,覆盖无 context、全量 context、部分 context、空字符串拒绝、特殊字符保留src/tests/session.test.ts:新增 2 个集成测试用例(成功/失败场景),验证 notify hook 接收到的STATUS、FAIL_REASON、BODY、TITLE、DURATION上下文docs/configuration.md/docs/configuration_en.md:新增 notify 环境变量表格;新增飞书 Webhook 通知示例注入的环境变量
DURATIONSTATUS"completed"或"failed"FAIL_REASONBODYTITLE背景
当前 notify hook 仅注入
DURATION和用户自定义的settings.env变量,通知脚本无法判断任务成功/失败,也无法获取会话标题或 AI 回复内容。同时原有实现将process.env全量透传给 notify 子进程,存在 API Key 等敏感信息泄露风险。本次改动补齐了这些关键上下文,并收紧了环境变量暴露。验证
npm run check(typecheck + lint + format)✅npm test(248 tests, 0 fail)✅