在文档预览中渲染 Jupyter 笔记本,支持代码语法高亮、离线 KaTeX 行内与块级公式,以及可缩放的图像查看器。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:WuShichao/dsh-ipynb-preview
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。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 只有英文版本。
A DeepSeek Harness plugin that renders Jupyter notebooks in the document preview pane: syntax-highlighted code, real LaTeX, and zoomable figures — instead of raw JSON.
Without it, opening a .ipynb in DSH shows its JSON source. With it, the file
opens as a notebook.
| Feature | Notes |
|---|---|
| Syntax highlighting | Python, JavaScript/TypeScript, JSON, Bash, and INI, with per-language grammars |
| LaTeX math | Vendored KaTeX, so it works offline; inline $…$ and display $$…$$, including inside tables and lists |
| Markdown subset | Headings, lists, tables with column alignment, blockquotes, task lists, fenced code, links, bold and italic, code spans |
| Figure zoom | Click any output figure to open it, then scroll or + / − to zoom continuously, drag to pan, 0 to fit |
| Save figures | Names each figure after the notebook, e.g. sample-notebook-cell3-out1.png |
| Outputs | Streams, display_data, execute_result, and error tracebacks with ANSI escapes stripped |
Everything is self-contained: the KaTeX engine and its web fonts are inlined into the client bundle, so no request leaves your machine.
Install
dsh plugin --profile <your-profile> add dsh-ipynb-preview
Then restart DSH. The plugin is a client-side renderer, so it needs a restart rather than a page refresh: the shell computes its client bundle revision at startup.
To install from a checkout or a git URL instead:
dsh plugin --profile <your-profile> add ./dsh-ipynb-preview
dsh plugin --profile <your-profile> add github:WuShichao/dsh-ipynb-preview
The git form makes pnpm ask for permission to run this package's prepare
script, because pnpm >= 10 refuses a git dependency's install-time script until
it is allowlisted. The built lib/client.js is committed, and the npm package
ships it too, so neither a tarball nor a registry install asks for anything.
How it works
DSH discovers the package through the profile's bundle list, reads dsh.client
from this manifest, and serves lib/client.js to the browser as part of the
client roster. That bundle registers a document-preview renderer for the ipynb
extension:
lib/index.js host half; deliberately empty, the plugin is browser-only
lib/client.template.js the editable client source, with two KaTeX placeholders
lib/client.js the generated artifact the shell serves
cordis.patch.yml the bundle layer that inserts the plugin row
tools/build-client.mjs generates lib/client.js from the template
lib/client.js is generated, not hand-edited. Change lib/client.template.js
and run npm run build.
Development
pnpm install # installs KaTeX (build), React (tests)
pnpm run build # regenerate lib/client.js
pnpm test # build, then the verifier, the bundle lint, and the mount harness
The repository ships a pnpm-lock.yaml, and pnpm is what the DSH CLI itself uses
to install plugins, so CI installs with pnpm install --frozen-lockfile. npm and
yarn also work: every script is a plain node invocation rather than a chained
npm run, so no script depends on which package manager started it.
pnpm test runs three suites, all offline:
tests/verify.mjs— materializes the bundle the way the shell's module loader does, then checks the manifest contract, the registrations, the highlighter, the math renderer, the Markdown subset, the zoom arithmetic, the stylesheet, and a full render of the fixture notebook. Around 170 assertions.tests/lint-bundle.mjs— sweeps both the template and the built bundle for identifiers that are referenced but never declared. A free variable makes the factory throw while the shell materializes it, and the whole client roster then fails to load — a blank window thatnode --checkcannot detect.tests/mount.mjs— mounts the plugin against a DOM stub so effects and event wiring actually run, and asserts the notebook tree survives opening the lightbox.
The fixture notebook is generated by tests/make-fixture.mjs, and the assertions
read their expected counts from that fixture, so the input and the expectation
cannot drift apart.
Interaction testing in a real browser
React's synthetic event system does not work against a hand-written DOM stub, so the controls' click handlers are verified in a real browser instead:
node tests/make-page.mjs # writes test-page.html at the repo root
node tests/make-page.mjs out.html # or choose the output path
Open the page, click Open the lightbox, and press every control; each
interaction, the zoom readout, and any error is written to the log at the top of
the page. Append ?auto=1 to the URL and the page drives itself, which is how a
headless run reads the result back:
msedge --headless=new --virtual-time-budget=15000 --dump-dom \
"file:///path/to/test-page.html?auto=1"
That page also hit-tests every control with document.elementFromPoint, which is
how a stacking-order bug was found: a fixed application header with a higher
z-index than the lightbox covered the middle of the toolbar, so only its edges
responded to a click.
Requirements
- Node 18 or newer to build and test.
- React is not a dependency: the shell supplies it from its own frozen module table. It is a dev dependency only, for the tests.
Notes for plugin authors
Two things this plugin learned the hard way, both now covered by assertions:
- A client bundle is materialized inside the shell's module loader. If the factory throws, the row has no exports and the whole roster fails — which looks like a blank window rather than a plugin error. Keep the factory free of undeclared identifiers.
- A full-screen overlay needs a
z-indexabove every host layer.9999is not enough: application chrome is often a fixed header with its own stacking context, and it will silently swallow clicks aimed at your controls.
License
MIT — see LICENSE. KaTeX is bundled under its own MIT license; see THIRD_PARTY_NOTICES.md.
Published to npm by @nightwingng.
链接
同类插件
tt-a1i/archify#integrations/deepseek-harness★ 99972
从仓库或系统描述生成经过校验的自包含交互式架构图、流程图、时序图、数据流图和生命周期图。
dream-num/dsh-univer-office★ 761
为 DeepSeek Harness 打造一个真正的办公环境。Univer Office 插件将电子表格、文档、幻灯片、画布、多维表格等汇聚到同一个运行时——数据互联、修改经过校验、变更按版本管理,并以隔离工作树支持多 Agent 协作。
ECNU/EduWork#dsh-knowledge-studio★ 410
基于工作区资料的 Studio,复用 DSH 模型与共享成果服务,制作报告、演示文稿、表格、思维导图、测验、闪卡及音视频。Office 生成需 Python 3.12+ 及相关依赖,并配置 DSH_OFFICE_PYTHON;媒体渲染需 Chromium;本地语音转写另需 whisper.cpp 和模型。
Roland0511/dsh-marktext★ 389
基于 MarkText 内核 muya 的右侧栏所见即所得 Markdown 编辑器:打开 .md 按渲染结果编辑,保存走 ctx.fs 并带版本守卫。
PerryLink/dsh-industry-research★ 227
面向 DeepSeek Harness 的确定性行业研究报告:公司与行业研究流程基于分阶段证据产出结构化、可核验的报告。
joeseesun/qiaomu-ui-learn-dsh★ 89
浏览界面设计参考和交互标本,练习设计测验,并导出 Markdown 学习笔记。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。