cdxiaodong/dsh-llm-inspector

插件Plugin 原生Native ⭐ 3 开发工具Developer Tools

一个插件收编四类能力,全部通过配置开关:reasoning 控制、外部思考(think)导出、流量/包分析、会话落盘审计。

catalog 简介 / catalog descriptioncatalog description:—

项目介绍Project Overview

dsh-llm-inspector 是 DeepSeek Harness 插件,统一提供四项 LLM 检查能力:通过 reasoningEffort 控制推理开关与预算;通过 think 工具将外部思考导出;通过 llm/stream 拦截做流量与包分析;通过订阅 session 事件将流式块落盘为 audit.jsonl,并暴露 inspectorTrafficinspectorAudit 两个服务供其他插件调用。适合调试推理行为、统计 token 与工具调用、复盘会话。需注意:因 DSH 核心裁剪了 tool_choice,think 触发为系统提示词软强制,触发率依赖模型遵循度,上架前应实测验证;开启 persistSession 时可能落盘推理、代码甚至凭证,请仅在可信环境使用并审阅约 200 行源码。

dsh-llm-inspector is a DeepSeek Harness plugin that bundles four LLM inspection capabilities: reasoning control via reasoningEffort to disable or budget thinking, external thinking export through a registered think tool, traffic and chunk analysis by intercepting llm/stream, and session auditing by writing streamed chunks to audit.jsonl. It also exposes inspectorTraffic and inspectorAudit services for other plugins to inject. Use it to debug reasoning, tally tokens and tool calls, and review sessions. Caveat: DSH trims tool_choice, so think invocation is a soft system-prompt enforcement whose rate depends on model compliance, and enabling persistSession may persist reasoning, code, or credentials, so review the ~200-line source and run only in trusted environments.

或使用命令行安装(适合开发者)Or use CLI install (for developers)

命令行安装CLI Install

dsh plugin --profile web add github:cdxiaodong/dsh-llm-inspector

cdxiaodong/dsh-llm-inspector 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-llm-inspector

统一 LLM 请求/响应检查器 —— DeepSeek Harness 插件

一个插件收编四类能力,全部通过配置开关:reasoning 控制、外部思考(think)导出、流量/包分析、会话落盘审计。

功能

功能 实现机制 配置项
reasoning 控制 agent/request waterfall,改写 LlmCallConfig.reasoningEffort(关推理 / 调 budget) reasoningEffort
外部思考导出 注册 think 工具(schema 自动流入请求体)+ systemPrompt 注入"先调 think"指令,再从 llm/stream 抓回 thoughts 参数 externalThinking
流量/包分析 llm/stream waterfall 拦截每个 chunk,按类型统计 token/字符、捕获 reasoning 与 tool-call 块 trafficAnalysis
会话落盘审计 订阅 session/event + 命中的流式块,写入 audit.jsonl persistSession

外部思考(external thinking)说明

明文返回 reasoning 的模型(DeepSeek 等开源模型),本插件直接从 llm/streamreasoning 块,零侵入。

加密推理的模型(OpenAI / Anthropic / Gemini),原生推理被厂商加密藏起。本插件复刻 oh-my-pi 的 externalThinking 思路:

  1. reasoningEffort: 'none' 关掉原生隐藏推理;
  2. 注册一个 think 工具(description 为 "private scratchpad; not shown to user"),其 schema 经 ctx.tools.register() 自动进入发往 LLM 的请求体;
  3. 通过 systemPrompt.section() 注入"回答任何问题前必须先调用 think"的指令;
  4. 模型把推理写进 thinkthoughts 参数,本插件在 llm/stream 拦截该 tool-call 块并抓回、落盘。

⚠️ 与 omp 的差异:DSH 核心 LlmCallConfig 刻意裁剪了 tool_choice,因此本插件用 system prompt 强制 替代 omp 的 API 层 tool_choice 强制。这意味着 think 触发是"软强制",触发率取决于模型遵循度,不保证 100%。这是上架前需实测验证的已知边界。

安装

dsh plugin --profile <你的profile> add github:cdxiaodong/dsh-llm-inspector

配置

plugins:
  dsh-llm-inspector:
    reasoningEffort: 'none'      # 可选:'none' 关推理,或 adapter 支持的 'low'/'medium'/'high'
    externalThinking: true       # 是否启用 think 导出
    trafficAnalysis: true        # 是否做流量/包分析
    persistSession: true         # 是否落盘审计
    logDir: '.dsh-inspector'     # 落盘目录
    # thinkPrompt: '...'         # 可选,覆盖默认强制提示

服务

插件对外提供两个 Service(可被其他插件 inject):

  • inspectorTraffic —— 流量统计:snapshot() 返回 { calls, chunks, reasoningChars, thinkCalls, thinkChars, byKind }
  • inspectorAudit —— 审计:log(tag, payload) / flush()

开发

npm install
npm run build    # tsc 产出 lib/(已提交进 git,DSH 可直接从 Git 安装)
npm test         # node --test,7 个零依赖测试

安全与信任声明

按 DSH 社区约定:GitHub topics 不是安全审核,也不是官方背书。本插件会拦截并(在开启 persistSession 时)落盘你的模型请求/响应内容,其中可能包含推理过程、代码、甚至凭证。请:

  • 仅在可信环境开启 persistSession
  • 注意 audit.jsonl 的存储位置与访问权限;
  • 安装前自审源码(src/index.ts,约 200 行)。

License

MIT

上一个 Prev dsh-pomodoro 下一个 Next DeepSeek-Harness-Desktop