此插件定位DeepSeek Harness代理会话失败的根本原因,并生成可共享的诊断报告。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:jiel521125/dsh-anlayzer
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
天枢 (TianShu, "Celestial Pivot") — the pivot star of the Big Dipper, used to locate the North Star. This plugin locates the root cause of a failed DeepSeek Harness agent session and produces a shareable diagnostic report.
TianShu combines a zero-cost rule engine (10 failure modes, no LLM calls) with an optional LLM deep-diagnosis layer that reuses the session's own model route — no extra API key required.
Features
- Rule engine (10 failure modes) — tool-error loops, identical-call dead loops, max-tokens truncation, sandbox denials, approval blocks, LLM errors/aborts, prompt-injection signals, token burn, no-progress stalls.
- LLM deep diagnosis — asks the session's own model "why did this fail?" with the rule
findings as structured context. Reuses the route from
assistant/messageprovenance. - Agent tool —
diagnose_sessionlets the agent self-diagnose a failed task and retry smarter. - Auto-trigger — subscribes to
turn/endand runs analysis automatically onerror/blocked/interrupted/abortedoutcomes. - Markdown reports — persisted to
~/.dsh/tianshu-reports/, ready to paste into a GitHub Issue. - Web UI panel — injects a "⚕︎ Diagnose" button into the session header; opens a panel showing findings, tool-call heat map, fork points, and the LLM diagnosis.
Quick Start
Prerequisites
- Node.js ≥ 20
- pnpm ≥ 9
- DeepSeek Harness (the
dshCLI, or a local clone of the harness repo)
1. Install
git clone <this-repo-url> tianshu-analyzer
cd tianshu-analyzer
pnpm install
pnpm build # produces lib/ (host ESM + browser CJS bundle)
2. Load into DSH
TianShu ships with a Cordis patch overlay that inserts it into an active DSH profile:
dsh web --patch ./cordis.patch.yml
That's it — open http://127.0.0.1:3080, pick any session, and click the ⚕︎ Diagnose button in the session header.
3. (Optional) Tune thresholds
Edit cordis.patch.yml — every config key is documented inline. See the Configuration table below for the full reference.
Usage
TianShu can be triggered in four ways. They all share the same engine and produce the same
DiagnosisReport.
A. Web UI panel (interactive)
- Open DSH Web (
dsh web). - Open any session.
- Click ⚕︎ Diagnose in the session header utilities slot.
- The panel opens. Toggle "LLM deep diagnosis" if you want the LLM layer, then click Analyze.
- Findings, heat map, fork points, and the Markdown report render inline.
B. Auto-trigger (hands-off)
Enabled by default. Whenever a turn/end event arrives with reason error / blocked /
interrupted / aborted, TianShu runs the analysis in the background and:
- Writes a Markdown report to
~/.dsh/tianshu-reports/<sessionId>-<timestamp>.md - Caches the report in memory (the Web UI reads it via the
/tianshuRPC channel) - Emits a
tianshu/reportevent other plugins can subscribe to
To disable auto-trigger, set autoTrigger: false in cordis.patch.yml.
C. Agent tool (self-diagnosis)
The agent itself can call the diagnose_session tool:
diagnose_session(sessionId: "<session-id>", useLlm?: boolean)
Returns a structured summary the agent can use to retry smarter (e.g., avoid the tool it was looping on, or request a model route change). The agent does not need an LLM call to use this — the rule engine runs synchronously and is free.
D. Programmatic (host-side)
Other DSH host plugins can read the in-process service directly:
// In any host plugin that declares `inject: ['tianshu']`
const report = await ctx.tianshu.analyze(sessionId, { useLlm: true })
const cached = await ctx.tianshu.getReport(sessionId)
const all = await ctx.tianshu.listReports()
const markdown = await ctx.tianshu.readMarkdown(sessionId)
Note:
ctx.tianshuis host-process only. Browser client code must call the host via the generic Connection RPC channel — see Architecture below.
Configuration
All config lives in cordis.patch.yml. A patch replaces the targeted row's
whole config, so every key below is authoritative when the patch is active.
| Key | Default | Description |
|---|---|---|
autoTrigger |
true |
Auto-run analysis on failed turn/end events |
autoTriggerReasons |
[error, blocked, interrupted, aborted] |
Which turn/end reasons trigger |
llmDiagnose |
true |
Enable LLM deep diagnosis (needs ctx.llm) |
llmMaxTokens |
2048 |
Output cap for the diagnostic LLM call |
llmTimeoutMs |
30000 |
Per-call deadline (ms) |
provider |
(unset) | Override the model provider; omit to reuse the session's |
model |
(unset) | Override the model id; omit to reuse the session's |
reportDir |
~/.dsh/tianshu-reports |
Where Markdown reports are saved |
keepReports |
50 |
Max report files retained (oldest pruned) |
rules.<id>.enabled |
true |
Toggle individual rules |
rules.<id>.threshold |
rule-specific | Loop detection thresholds (see below) |
Rule thresholds
| Rule | Key | Default | Meaning |
|---|---|---|---|
toolErrorLoop |
threshold |
3 |
Same tool errored N times → finding |
toolResultLoop |
threshold |
3 |
Same tool + identical args called N times → dead loop |
tokenBurn |
inputThreshold / outputThreshold |
50000 / 100 |
Single call: >50k input, <100 output → burn |
noProgress |
windowSteps |
5 |
N consecutive steps with shrinking assistant output → stall |
Failure Modes
| id | severity | What it detects |
|---|---|---|
tool-error-loop |
major → critical | Same tool errored ≥ threshold times |
tool-result-loop |
critical | Same tool + identical args called ≥ threshold times (dead loop) |
max-tokens-truncated |
major | turn/end.reason.kind === 'max-tokens' |
sandbox-denied |
major | Tool result contains permission/sandbox denial |
approval-blocked |
major | turn/end.reason.kind === 'blocked' |
llm-error |
critical | turn/end.reason.kind === 'error' with failure code |
llm-aborted |
critical | turn/end.reason.kind === 'aborted' |
prompt-injection-signal |
major | User message contains injection patterns |
token-burn |
minor | Single call: >50k input tokens, <100 output |
no-progress |
major | N consecutive steps with shrinking assistant output |
How It Works
turn/end (reason=error|blocked|interrupted|aborted)
│ auto-trigger (or: Web UI click, or: agent tool call)
▼
ctx.sessionQuery.readSession(id) → events[]
│
├─► [Rule engine] → findings[] (failure mode + evidence + fix)
│ (no LLM call — free, synchronous)
│
└─► [LLM diagnose] (optional)
│ reuses the session's own model route (no extra API key)
│ ctx.llm.stream({ purpose: 'session-title', ... })
▼
DiagnosisReport
│
├─► Markdown file (~/.dsh/tianshu-reports/<sid>-<timestamp>.md)
├─► In-memory cache (Web UI reads via /tianshu RPC channel)
├─► Tool result (agent receives a structured summary)
└─► tianshu/report event (other plugins can subscribe)
Architecture
src/
├── index.ts # Host entry: tool + auto-trigger + server API + /tianshu RPC channel
├── config.ts # Config schema + validation
├── types.ts # Shared types (Finding, DiagnosisReport, …)
├── analyzer/
│ ├── session-loader.ts # Load events from ctx.sessionQuery (live + persisted)
│ ├── rule-engine.ts # 10 rules + heat map + fork-point recommender
│ └── llm-diagnoser.ts # Reuse ctx.llm + session route for deep diagnosis
└── report/
├── markdown.ts # Render DiagnosisReport → Markdown
└── store.ts # Persist to disk + in-memory cache for the UI
client/
├── index.ts # Browser entry: locale + slot injection + RPC client
├── HeaderAction.tsx # The "⚕︎ Diagnose" button in the session header
├── Panel.tsx # The diagnosis panel (findings, heatmap, forks, LLM)
└── locales.ts # en / zh strings
Host ↔ Browser bridge
DSH has no automatic host→client service bridge. ctx.provide('tianshu', api) is
process-local (host-only). TianShu bridges the browser to the host via the generic
Connection RPC channel /tianshu:
- Host (src/index.ts) registers
ctx.connection.rpc.handle('/tianshu', …)withauthority: 'trusted-host'and dispatchesanalyze/getReport/listReports/readMarkdownendpoints. - Browser (client/index.ts) declares
inject: ['connection']and callsctx.connection.rpc.call('/tianshu', endpoint, payload), unwrapping theRpcResultenvelope.
No separate API key or proxy is needed — the channel rides DSH's existing trust fence.
Build
pnpm build # one-shot build (host ESM + browser CJS bundle)
pnpm watch # rebuild on change (dev)
pnpm typecheck # tsc --noEmit
The build produces two artifacts under lib/:
| Output | Format | Loaded by |
|---|---|---|
lib/index.mjs + *.d.mts |
ESM | DSH host (Node) |
lib/client.js |
CJS factory | DSH browser shell via window.__ModuleLoader__.load({ id, factory }) |
Troubleshooting
"loaded without registering via ModuleLoader.load"
The browser bundle must be a CJS factory wrapped in window.__ModuleLoader__.load({ id, factory }).
This is handled by tsdown.config.ts — if you fork the build config, keep the
banner / intro / footer that emit the wrapper.
"cannot get property 'tianshu' without inject"
The browser client must declare inject: ['connection'] (it reads ctx.connection.rpc, not
ctx.tianshu). The host-side ctx.tianshu is process-local and never crosses to the browser.
"cannot get property 'sessionQuery' without inject"
The host plugin must declare inject: ['tools', 'llm', 'sessionQuery', 'sessions']. Missing any of
these raises this error at the first access.
"⚕︎ Diagnose button not visible"
- Confirm the patch is active:
dsh web --patch ./cordis.patch.yml - Hard-reload the browser tab (the client bundle is revision-tagged; stale tabs may cache the old
client.js). - Check the browser console — the slot error boundary retries once on connection-ready.
Author
Zhou Long (Tianshu Intelligent / 天枢智能)
- WeChat:
longling1031 - Email:
1033085514@qq.com - Location: Pinghu, Jiaxing, Zhejiang, China
- Blog: https://www.zhihu.com/people/tianshu_cn
License
MIT © Zhou Long (Tianshu Intelligent / 天枢智能)
链接
同类插件
Tencent/WeKnora#dsh-weknora★ 21359
把 WeKnora 知识库接入 dsh 的四个只读工具:列出知识库、混合检索原文片段、按顺序还原单篇文档,以及直接取用 WeKnora 自己带引用的 RAG 或 ReAct agent 回答(含可续聊的 session id)。
superdesigndev/treg★ 1189
给 Agent 的工具目录:按「要做的事」检索约 2,600 个外部接口(SEO 与 SERP、外链、社交、人物与公司信息补全、广告库、抓取),查看参数与单次调用价格后直接调用,凭据由服务端注入。附带技能,MCP 行在未设置 TREG_TOKEN 前保持禁用。
anysearch-team/anysearch-dsh★ 399
基于 AnySearch 的实时网页与垂直搜索插件,为 DeepSeek Harness 提供搜索工具。
EthanYoQ/Invoice-Downloader#dsh-invoice-downloader★ 379
面向 DeepSeek Harness 的本地 IMAP 发票下载、OCR 识别、归档与 Excel 报销汇总。
omdsh-dev/dsh-data-agent★ 184
让 AI 帮你连数据库、写 SQL。
zhaoolee/notes#dsh-plugin★ 158
将 DSH 对话导出为锤子便签风格 PNG,或在配置的账号工作区中新建和更新 Markdown 便签。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。