DSH Plugins Marketplace

DSH Plugins

Plugins

/

Tools & Capabilities

/

dsh-context-extract

d

dsh-context-extract

Manifest valid

Registers one `context_extract` tool for DeepSeek Harness: it compresses a long raw document (financial report, contract, ledger) into dense structured Markdown plus JSON — key metrics, tables, number

hasBundlePatch

dsh-context-extract · 上下文萃取与压缩器

把「前置信息萃取与路由 Agent」做成 DSH 插件:agent 直接调用 context_extract 工具,把超长、多模态的原始文件(财报工作簿、长合同、业务台账)压成高密度结构化 Markdown + JSON,过滤冗余、抽取实体、做勾稽校验,供下游 M1–M4 模块用最省 Token 的上下文。

痛点:几十页财报 / 协议原图 / 长文本直接丢给 AI → Token 爆炸、注意力分散、算错数字、漏掉条款。本插件在「读文件」之前先做一层确定性萃取。

原始文件 → context_extract → 类型识别 → 关键指标/表格/条款/实体 + 勾稽 alert → 密集 Markdown + JSON

一、装了之后发生什么

  • 注册一个 agent 工具 context_extract(所有会话可用)。
  • 注入一段系统提示「上下文萃取与压缩器」:当用户丢来超长原始文件时,agent 会先调它,再按「禁止解释 / 按需抽取 / 表格优先 / 条款编号化」四条规则进一步压缩。
  • 纯 host 插件:不新增 GUI、不改 DSH 源码、没有 npm 运行时依赖。

二、调用方式

context_extract(
  path: "/abs/or/relative/财报.xlsx",   # 必填;.xlsx/.xlsm/.csv/.docx/.txt/.md
  targets: ["货币资金","净利润"],        # 可选:只抽指定指标
  outputDir: "..."                       # 可选:报告目录(默认 <输入目录>/.context-extract)
)

返回:type / type_label(财务报表·法律合同·业务台账)、key_items(关键指标交叉表)、tables(台账表格)、clauses(合同条款切分)、entities(公司/日期/金额)、alerts(勾稽 <alert>)、markdown(密集压缩文本)、token_estimate(≈字符/4)、report.markdownPath / jsonPath。

只读输入,从不修改原文件。

三、能力边界(v0.1)

文件处理
.xlsx/.xlsm财务报表 → 关键指标交叉表 + 勾稽;台账 → 表格 dump(前 200 行)
.csv解析为表
.docx抽取段落 + 表格,合同按条款切分
.txt/.md文本直读,识别合同/财务标记
.pdf不支持(运行时 pdfplumber 损坏、无 pymupdf);先经 LibreOffice Kit 转文本或 xlsx

四、勾稽校验(自动,仅在财务报表时)

  • balance-sheet:资产总计 ≠ 负债合计 + 所有者权益合计(容差 0.1%)→ <alert>
  • cash-tieout:BS 货币资金 ≠ CF 期末现金及现金等价物 → <alert>

五、安装(desktop profile)

CLI="/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh"
"$CLI" plugin --profile desktop add link:<plugin-dir>/dsh-context-extract

确认 ~/.dsh/profiles/desktop/package.json 的 dsh.profile.bundles 里有 dsh-context-extract;改完在 GUI 工具列表里确认出现 context_extract(没出现则重启一次 DSH)。

卸载:"$CLI" plugin --profile desktop remove dsh-context-extract(不删报告)。

六、运行环境(自动探测)

依赖来源
Python 3 + openpyxl + python-docx~/.dsh/dsh-runtimes/dsh-primary-runtime/dependencies/python

可用 DSH_CONTEXT_EXTRACT_PYTHON 覆盖 Python 路径。Python 缺失时工具报错并提示用 load_workspace_dependencies 检查。

七、目录

plugins/dsh-context-extract/
├── index.js          # host 插件:注册 context_extract + 系统提示
├── runner.js         # 探测 python,spawn 萃取引擎
├── core/extract.py   # 引擎 CLI(--input/--targets/--out-json/--out-md)
├── test/make_fixture.py   # 生成自测样本
├── cordis.patch.yml
└── package.json

八、自测

PY="$HOME/.dsh/dsh-runtimes/dsh-primary-runtime/dependencies/python/bin/python3"
PY test/make_fixture.py                                   # 生成样本财报/台账/合同
PY core/extract.py --input test/fixtures/sample-financial.xlsx \
  --out-json /tmp/extract.json --out-md /tmp/extract.md

sample-financial.xlsx 应输出 13 个关键指标、2 条 cash-tieout 勾稽提示;sample-contract.txt 切出 3 个条款;sample-ledger.csv 识别为台账。

九、已知限制

  • 关键指标依赖中文行标签(资产总计、负债合计、货币资金……);非中文模板退化为台账/文本。
  • 公式单元格若没有缓存值,按空处理(报告里会标注;需要精确值先用 LibreOffice 重算)。
  • 条款切分是结构性切分,不生成语义摘要——「条款号 + 核心义务/权利」的一句话说由 agent 按系统提示完成。
  • PDF 不支持,需先转换。

十、许可

MIT。

Versions

Latest versionPublishedSize
0.1.0——

Comments

Loading…

Similar plugins

dsh-plugin-context-manager

Context manager for DeepSeek Harness: auto-summarizes every turn into priority-sorted records, injects them plus pinned cross-session notes and custom text into each model request, and folds any-size

Memory & ContextManifest valid

★ 0

dsh plugin --profile web add dsh-plugin-context-manager

by xuzihao66

Cut the input-token cost of long DeepSeek Harness sessions: source-side tool-output compression on tools/post-execute plus per-agent tool-catalogue visibility, with a measurement script.

Tools & CapabilitiesSessions & MessagesManifest valid

★ 1

MIT

JavaScript

Oct 14, 2026

dsh plugin --profile web add dsh-token-frugal

by Hanochhu

Context offloading for DeepSeek Harness: consumed tool calls and their results are replaced in the model-visible history by a short stub, while the originals stay in the session log for replay.

Sessions & MessagesManifest valid

★ 0

MIT

JavaScript

Sep 24, 2026

dsh plugin --profile web add dsh-context-offload

by bowenliang123

The best DeepSeek Harness plugin for context insight and management, with context dashboard / browser / sidebar and context command, for context statistics, composition, breakdown, evolution details,

Tools & CapabilitiesUI & ExperienceTerminal & ClientsManifest valid

★ 3.2k

↓ 43.4k/wk

Apache-2.0

TypeScript

Oct 21, 2026

dsh plugin --profile web add dsh-context

by john-walks-slow

Context compaction for DeepSeek Harness: mind_map and clear_mind agent tools turn selected history into self-written checkpoints, with auditable GUI tombstones and proactive threshold reminders.

Development & InfrastructureMemory & ContextSessions & MessagesManifest valid

★ 7

↓ 180/wk

MIT

TypeScript

Oct 13, 2026

dsh plugin --profile web add dsh-clear-mind

Context fullness bands, the per-session compaction threshold derived from the model window, per-step cost computed from cache read and cache write rates, cache-hit, DeepSeek balance with the peak/off-

Tools & CapabilitiesManifest valid

★ 0

dsh plugin --profile web add dsh-context-governor