dsh-hooks 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -178,10 +178,12 @@ dsh-hooks dry-run tool/call --tool ssh_exec --execute # end-to-end: actually r
178
178
 
179
179
  After install, the dsh web settings panel gains a "Hooks" section (beside General and Plugins):
180
180
 
181
- - **Status badges**: plugin version, hook count, history count
182
- - **Manual tester**: pick an event (14 kinds) + reason/tool; "Simulate" shows the per-hook match report, "Execute" really triggers the matching hooks
183
- - **Feishu connect**: scan-to-connect inside the panel the QR code renders inline (with expiry countdown and a cancel button); after the scan the app is created, credentials + hook config are written, and the connected summary offers a one-click test card, an inline truncation-length editor (50–5000 chars, default 300), and a re-connect flow
184
- - **Execution-history timeline**: at the bottom of the card, **collapsed by default** (an "expand" toggle opens the latest 30 triggers: time / event / command / outcome / stderr tail), refreshed every 5s
181
+ - **Status badges**: plugin version, hook count, history count, plus live diagnostics (in-flight runs, recent failures)
182
+ - **Manual tester**: pick an event (14 kinds) + reason/tool; "Simulate" shows the per-hook match report, "Execute" really triggers the matching hooks; the report clears when the inputs change
183
+ - **Notify-channel tests**: fire a test notification at the webhook (optional Slack summary) / desktop channel and show the payload preview
184
+ - **Feishu connect**: scan-to-connect inside the panel the QR code renders inline (with expiry countdown and a cancel button); after the scan the app is created, credentials + hook config are written, and the connected summary offers a one-click test card, an inline truncation-length editor (50–5000 chars, default 300, with a content preview), a re-connect flow, and a disconnect (optionally removing the Feishu hooks)
185
+ - **Hook list / editor**: a read-only list of the current hooks (event/when/match/run/notify + timeout/retry fields) with one-click "copy YAML"; the "edit" mode turns it into a form editor whose changes are validated (regexes, run-notify exclusivity) and written back to `cordis.patch.yml` with an automatic backup
186
+ - **Execution-history timeline**: at the bottom of the card, **collapsed by default** (the toggle state persists in localStorage; "expand" opens the latest 30 triggers: time / event / command / outcome / stderr tail), refreshed every 5s
185
187
 
186
188
  CLI/headless environments are unaffected: the browser half loads only in the web GUI and the core has no UI runtime dependencies.
187
189
 
@@ -191,14 +193,17 @@ In the web profile (when the shared webServer service exists) dsh-hooks register
191
193
 
192
194
  | Route | Method | Purpose |
193
195
  | --- | --- | --- |
194
- | `/dsh-hooks/status` | GET | plugin version, hook count, history count |
196
+ | `/dsh-hooks/status` | GET | plugin version, hook count, history count, the **current hook list**, and live runner stats |
195
197
  | `/dsh-hooks/history?n=50` | GET | the latest N execution records (JSON envelope) |
196
198
  | `/dsh-hooks/test` | POST | simulate an event: `{"event":"tool/call","tool":"ssh_exec","execute":false}` returns a per-hook match report; `execute: true` actually runs the matching hooks |
197
- | `/dsh-hooks/feishu/status` | GET | Feishu connection summary (app id / target masked, secret never leaves the server) + the scan-session snapshot + the truncation length |
199
+ | `/dsh-hooks/notify/test` | POST | fire a test notification at a channel: `{"channel":"webhook","url":…,"slack":true}` or `{"channel":"desktop"}`; returns the payload preview |
200
+ | `/dsh-hooks/hooks/save` | POST | save the hook list: `{"profile":"web","hooks":[…]}` — validates (events, reasons, regexes, run-notify exclusivity), writes back to cordis.patch.yml with an automatic backup |
201
+ | `/dsh-hooks/feishu/status` | GET | Feishu connection summary (app id / target masked, secret never leaves the server) + the scan-session snapshot + the truncation length + a content preview |
198
202
  | `/dsh-hooks/feishu/setup` | POST | start a scan session: `{"profile":"web","resultMaxChars":800}`; returns the QR URL / PNG data URL / expiry (409 while one is pending) |
199
203
  | `/dsh-hooks/feishu/cancel` | POST | cancel the pending scan session (aborts the registerApp wait) |
200
204
  | `/dsh-hooks/feishu/config` | POST | update the card truncation length: `{"resultMaxChars":800}` (50–5000); effective immediately, credentials preserved |
201
205
  | `/dsh-hooks/feishu/test` | POST | send a test card with the stored credentials |
206
+ | `/dsh-hooks/feishu/disconnect` | POST | disconnect: delete the credential file; `removeHooks: true` also drops the hooks referencing notify-feishu.mjs (with a backup) |
202
207
 
203
208
  Security matches dsh-aionui-panel: loopback-only, POSTs require `application/json` (blocks cross-site form CSRF). The web profile also gets a systemPrompt section announcing the plugin to agents.
204
209
 
package/README.zh.md CHANGED
@@ -160,10 +160,12 @@ dsh-hooks dry-run tool/call --tool ssh_exec --execute # 端到端真跑匹配
160
160
 
161
161
  安装后,dsh web 的设置面板里会出现「Hooks」分区(与「通用」「插件」平级):
162
162
 
163
- - **状态徽章**:插件版本、hook 数、历史条数
164
- - **手动测试**:选事件(14 类)+ reason/tool,「模拟」看逐 hook 匹配报告,「执行」真实触发
165
- - **飞书通知**:网页内扫码连接飞书——显示二维码(含有效期倒计时、可取消),扫码后自动创建应用、写入凭据与 hook 配置;已连接后显示应用摘要,可一键发送测试卡片、调整卡片截断长度(50–5000 字符,默认 300)或重新扫码换绑
166
- - **执行历史时间线**:位于分区底部、**默认折叠**(标题旁「展开」查看最近 30 条触发:时间 / 事件 / 命令 / 结果 / stderr 尾部),5 秒自动刷新
163
+ - **状态徽章**:插件版本、hook 数、历史条数,以及运行诊断(正在执行的 hook 数、最近失败数)
164
+ - **手动测试**:选事件(14 类)+ reason/tool,「模拟」看逐 hook 匹配报告,「执行」真实触发;切换输入自动清空旧结果
165
+ - **通知渠道测试**:向 webhook(可选 Slack 摘要)/ desktop 渠道发一条测试通知,显示发送内容预览
166
+ - **飞书通知**:网页内扫码连接飞书——显示二维码(含有效期倒计时、可取消),扫码后自动创建应用、写入凭据与 hook 配置;已连接后显示应用摘要,可一键发送测试卡片、调整卡片截断长度(50–5000 字符,默认 300,带正文预览)、重新扫码换绑或断开连接(可选一并移除飞书 hooks)
167
+ - **当前 hooks**:只读清单(事件/when/match/run/notify + 超时重试参数),一键「复制 YAML」;点「编辑」进入表单编辑器,增删改 hook 后写回 `cordis.patch.yml`(自动备份原文件、写前校验正则与 run/notify 二选一,保存即热加载)
168
+ - **执行历史时间线**:位于分区底部、**默认折叠**(展开状态记忆于 localStorage;标题旁「展开」查看最近 30 条触发:时间 / 事件 / 命令 / 结果 / stderr 尾部),5 秒自动刷新
167
169
 
168
170
  CLI/headless 环境完全不受影响:浏览器半只在 web 加载,核心零 UI 运行时依赖。
169
171
 
@@ -173,14 +175,17 @@ web profile 里(存在共享 webServer 服务时)dsh-hooks 自动注册 loop
173
175
 
174
176
  | 路由 | 方法 | 用途 |
175
177
  | --- | --- | --- |
176
- | `/dsh-hooks/status` | GET | 插件版本、hook 数、历史条数 |
178
+ | `/dsh-hooks/status` | GET | 插件版本、hook 数、历史条数、**当前 hooks 清单**与运行统计 |
177
179
  | `/dsh-hooks/history?n=50` | GET | 最近 N 条执行历史(JSON envelope) |
178
180
  | `/dsh-hooks/test` | POST | 模拟事件评估:`{"event":"tool/call","tool":"ssh_exec","execute":false}` 返回逐 hook 匹配报告;`execute: true` 真跑匹配的 hook |
179
- | `/dsh-hooks/feishu/status` | GET | 飞书连接摘要(app id / 目标均已打码,绝不返回 secret)+ 扫码会话快照 + 截断长度 |
181
+ | `/dsh-hooks/notify/test` | POST | 向指定渠道发测试通知:`{"channel":"webhook","url":…,"slack":true}` `{"channel":"desktop"}`,返回发送内容预览 |
182
+ | `/dsh-hooks/hooks/save` | POST | 保存 hook 列表:`{"profile":"web","hooks":[…]}`——校验(事件/when/正则/run-notify 二选一)后写回 cordis.patch.yml,自动备份原文件 |
183
+ | `/dsh-hooks/feishu/status` | GET | 飞书连接摘要(app id / 目标均已打码,绝不返回 secret)+ 扫码会话快照 + 截断长度 + 正文预览 |
180
184
  | `/dsh-hooks/feishu/setup` | POST | 启动扫码会话:`{"profile":"web","resultMaxChars":800}`,返回二维码 URL / PNG data URL / 有效期;进行中时再次请求返回 409 |
181
185
  | `/dsh-hooks/feishu/cancel` | POST | 取消进行中的扫码会话(中止 registerApp 等待) |
182
186
  | `/dsh-hooks/feishu/config` | POST | 更新卡片截断长度:`{"resultMaxChars":800}`(50–5000),即时生效,保留凭据 |
183
187
  | `/dsh-hooks/feishu/test` | POST | 用已存凭据发送测试卡片 |
188
+ | `/dsh-hooks/feishu/disconnect` | POST | 断开连接:删除凭据文件,`removeHooks: true` 时一并移除 patch 中引用 notify-feishu.mjs 的 hooks(带备份) |
184
189
 
185
190
  安全约定与 dsh-aionui-panel 一致:仅回环地址可达、POST 必须 `application/json`(防跨站表单 CSRF)。同时 web profile 下会向 agent 注入一段 systemPrompt 公告,说明插件存在与协作方式。
186
191