rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:thatgfsj-dsh/dsh-emotion-analyzer
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
DSH(DeepSeek Harness)情绪分析器插件:对主模型的每条回复做本地情绪打分,把累积情绪状态投影进 Session,并在 DSH 网站注入一个可拖拽的悬浮情绪监测框。
▶ 45 秒横版宣传片(竖版 30 秒 × 3 个开场钩子见 Release)· 数据口径与发布建议见 docs/promo.md

legacy-11、go-emotions-28、zh-8 三套 profile;阈值过滤 + 衰减 + 步长 + 封顶,参数集中在 src/mapping.ts。详见 模型与映射。plugin:emotion-analyzer/turn(ignorable)写入会话日志,由 emotion projection 单元纯同步 fold;重启、fork 自动恢复。| 折叠徽章 | 暗色主题 | 等待态 |
|---|---|---|
![]() |
![]() |
![]() |
agent/turn-stopping { agent, turn, signal } ← 真实事件名(不是 turn-stopping)
→ 最后一条 assistant 的 text block
→ EmotionScorer.score(text) ← onnxruntime-node + INT8,惰性加载
→ appendPluginRecord(session, 'plugin:emotion-analyzer/turn', data)
→ ctx.sessionProjections.register({ key:'emotion', ... }) ← 纯同步 fold
→ Web 客户端 useProjection('emotion') → 模块 store
→ shell.overlay(root slot)→ React portal → <emotion-monitor>(Shadow DOM)
提示词里的
turn-stopping/ctx.session.projection/ev.getLastMessage()与真实宿主不一致,完整校准表见 docs/calibration.md。
dsh plugin --profile web add /path/to/dsh-emotion-analyzer
# 必做:验证插件真的进了 profile 的 bundle 层
bash scripts/check-install.sh web
# 输出 OK 才算安装成功;若提示 bundle missing:
# dsh plugin --profile web remove dsh-emotion-analyzer
# dsh plugin --profile web add .
装好后默认尝试使用 horizon-small;如果模型尚未下载,会自动回退到 assets/ 里的 legacy 模型(需按 模型导出与量化 生成),两者都没有时插件静默降级、不影响聊天。
在设置页(或调用 Host API)下载并选择模型后,下一轮生效:
curl -X POST http://127.0.0.1:<port>/api/emotion-analyzer/v1/model/download \
-H 'content-type: application/json' -d '{"id":"horizon-small"}'
curl -X POST http://127.0.0.1:<port>/api/emotion-analyzer/v1/model/select \
-H 'content-type: application/json' -d '{"id":"horizon-small"}'
curl http://127.0.0.1:<port>/api/emotion-analyzer/v1/state
onnxruntime-node / tokenizers 是原生模块,Windows/macOS 的安装脚本批准与二进制下载需在目标机验证(本机只验证了 Linux + Node 24)。appendPluginRecord 会做 Session 品牌检查,插件运行时从运行中的 dsh 安装解析 @deepseek-ai/dsh-session(src/host-modules.ts),link: 安装无需额外处理;非 dsh 进程内调用才回退插件本地副本(仅开发/单测)。| 预设 | 许可 | 体积 | 语言 | 标签 | 说明 |
|---|---|---|---|---|---|
horizon-small(默认) |
Apache-2.0 | 268 MB | 36 | 28 | 官方 INT8,可在线下载 |
horizon-base |
Apache-2.0 | 641 MB | 36 | 28 | 更准但更慢/更大 |
legacy-tabularisai(回退默认) |
CC-BY-NC-4.0 | 279 MB | 23 | 11 | 包内 assets,回退用,不可删除 |
zh-johnson-small |
MIT | 待导出 | zh | 8 | needsExport(暂无官方 ONNX) |
$DSH_HOME/emotion-analyzer/config.json;模型下载到同目录 models/<id>/,不进仓库。/api/emotion-analyzer/v1/*(鉴权由 DSH Connection 负责)。| 通道 | 默认 | 数据去向 | 计费 | 失败行为 |
|---|---|---|---|---|
| 本地 ONNX | ✅ | 仅本机进程 | 无 | 回退 legacy / 本轮跳过 |
| 自定义 OpenAI-compatible API | 需手动开启 | 助手回复文本 → 用户配置的端点 | 按对方价格 | 超时/HTTP/JSON 失败 → 回退本地 ONNX |
# 切到自定义 API(密钥只从环境变量读取,配置文件只存变量名)
curl -X POST http://127.0.0.1:<port>/api/emotion-analyzer/v1/provider \
-H 'content-type: application/json' \
-d '{"type":"api","baseUrl":"https://api.example.com/v1","model":"gpt-4o-mini","apiKeyEnv":"EMOTION_API_KEY"}'
# 切回本地
curl -X POST http://127.0.0.1:<port>/api/emotion-analyzer/v1/provider \
-H 'content-type: application/json' -d '{"type":"local"}'
unified-7 profile;切换通道不影响历史轮次重放。local(安全默认)。都集中在 src/mapping.ts 顶部:
| 常量 | 值 | 说明 |
|---|---|---|
THRESHOLD |
0.2 | 聚合分低于该值视为噪声:整轮跳过,不积累也不衰减。校准记录:模型对“难过”常给 sadness≈0.27,0.3 会丢真实悲伤;中性句其余标签 <0.05,降到 0.2 不误报(#30) |
DECAY |
0.85 | 每轮回落系数。校准记录:提示词给 0.9,但 0.9^10=0.349 无法满足"5 轮伤心 + 10 轮中性后 sad<0.2",故取 0.85(见 #13) |
STEP_MAX |
0.25 | 单轮命中最大步长,避免一次爆表 |
CAP |
1.0 | 统一维度封顶 |
模型原始标签 → 统一维度映射见 EMOTION_MAP(sad = sadness、angry = max(anger, contempt, frustration)、anxious = fear、unwell = max(disgust, 0.5·fear)、confused = max(surprise, doubt),doubt 为文本启发式)。
| 项 | 结果 |
|---|---|
| 20 中文 + 20 英文 top-1(legacy) | 40/40 = 100%(Node 复算同一 40 条 CASES) |
| 20 中文 + 20 英文 top-1(Horizon small) | 38/40 = 95%(≥90% 验收线) |
| CPU INT8 单条推理 | legacy 中位 8.6ms;Horizon small 中位 19.3ms(Node 含分词,< 200ms) |
| tokenizer 与 Python fast 对齐 | 4/4 case 逐 token 一致 |
| 5 轮 sad 累积 / 10 轮 neutral 回落 | 单测通过(≤ CAP、< 0.2) |
| 重启 projection 恢复 | 日志重放回归测试通过 |
| 真实 DSH 页面悬浮框 | 展开/折叠/预览截图,0 console error |
| 0.2.2-rc.1 真实模型完整 turn | ✅ headless 实测:horizon-small 20ms,v2 record 写入 + projection 折叠(pleasant 0.356) |
| 自定义 API 通道(0.2.5) | ✅ 本机回环 server 实测:成功/超时/HTTP 错误/非法 JSON/密钥缺失 5 类路径 |
完整矩阵与未验证项见 docs/e2e.md。
apiKeyEnv 指向的环境变量读取,不写入配置文件。CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。