中文EN

dsh-matlab-runner

devnpmMIT

侧栏里的 MATLAB IDE:类 VS Code 的 .m 编辑器,背后是常驻 MATLAB 会话(首次启动约 6–9 秒,默认 session 模式下单次运行 12–84 毫秒,figure 真的会弹窗),可查看并编辑的实时工作区变量、.mlx 预览、多文件夹挂载,以及给 agent 用的 matlab_run 工具。需要本机安装 MATLAB。

下载量 / Downloads
686

安装

dsh plugin --profile web add dsh-matlab-runner

沙箱测试

这个插件还没测过。提交测试 →

README

dsh-matlab-runner

![npm](https://www.npmjs.com/package/dsh-matlab-runner)

![license: MIT](LICENSE)

![dsh-plugin](https://awesome-dsh-plugin.com/)

A DeepSeek Harness plugin that puts a VS Code–shaped MATLAB panel in the right

sidebar: edit .m code, press ⌘/Ctrl+Enter, watch the console, open figures

inline, keep a warm MATLAB session between runs, browse several folders like

MATLAB's add-to-path list, and inspect/assign workspace variables.

dsh-matlab-runner is a UI plugin: the host half spawns MATLAB with the

system user's permissions (not the agent's sandbox) and the browser half gives

you an editor + runner + workspace inspector. Unlike the MCP-based MATLAB

plugins, it is not an agent tool wrapper — the agent does get a matlab_run

tool, but the panel is the product.

Two halves in one package:

Half · File · What it does

Host · lib/index.js, lib/runner.js · Owns the persistent MATLAB session and the run registry, serves /matlab/api/*, and registers the matlab_run agent tool.

Browser · lib/client.js · A page-type sidebar tab (editor, gutter, script picker, Run/Stop/Save, live console, figure previews, settings) plus a guide card and the matlab-runner.open shortcut.

*A real run: file tree + variables on the left, editor in the middle, live console

below, exported figures as thumbnails. Dividers resize the tree, the variables pane

and the console; settings are one click away.*

Settings · Narrow sidebar

![Settings](docs/settings.png) · ![Narrow](docs/narrow.png)

Two run modes

  • session (default) — one long-lived matlab -nodesktop -nosplash process

fed through stdin. After the first boot (≈6–9 s) a run costs ~10–30 ms, the

prompt keeps your variables between runs, and figure windows **really open on

the desktop** while the panel also shows the exported PNG. Output is streamed

into the console while the script is still running.

  • batch — matlab -batch per run, headless, exits with the script

(15–20 s per call, no windows). Kept for CI-ish, leave-nothing-behind work.

The session is shared between the sidebar and the agent tool, so what the model

runs and what you type land in the same MATLAB workspace.

Why this runs when the agent's shell cannot

MATLAB needs to write ~/Library/Application Support/MathWorks before it will

start. A sandboxed shell (workspace-write) makes matlab -batch exit 1 with

an empty console, and a PTY tab owned by the agent is subject to the same

sandbox. The host half spawns MATLAB with node:child_process from the host

process, i.e. with the system user's permissions, independently of the agent's

sandbox mode — so this panel runs MATLAB without switching the session to Full

access.

Install

From npm (once published):

dsh plugin --profile web add dsh-matlab-runner

For the desktop app, whose profile is owned by the Electron application, use the

bundled script — it copies the payload into the profile, wires the dependency and

the dsh.profile.bundles row, seeds the config, and re-composes the plugin:

node bin/install-local.sh        # or: plugins/dsh-matlab-runner/bin/install-local.sh

The official desktop app owns its profile, so the script copies the payload

into ~/.dsh/profiles/desktop/node_modules/dsh-matlab-runner, adds the

dependency and the dsh.profile.bundles row, seeds the config, and re-composes

the plugin's Loader entry.

About that last step: the app watches ~/.dsh/profiles/desktop/package.json, so

dropping the bundle row and putting it back reloads the plugin from disk —

no app restart, no lost session. bin/reload-host.sh does exactly that:

plugins/dsh-matlab-runner/bin/reload-host.sh   # host half picked up new files

Then reload the page (⌘/Ctrl+R) so the browser half updates too. A full app

restart is only needed if the tab still shows the old panel.

Open it

Right sidebar → the add control (+) → the MATLAB 运行器 / MATLAB runner

card. After the first visit the tab is in the strip; ⌘/Ctrl+Shift+M opens it

from anywhere (web builds: ⌘/Ctrl+Shift+Alt+M).

What the panel does

  • File tree (⌸ 文件) — browse workdir from the panel, expand folders

lazily, click any text file to open it in the editor (↑ 上一级 walks up,

刷新 re-reads). Only files with a text extension are editable; anything else

reports binary.

  • Editor with a line-number gutter, MATLAB syntax highlighting (keywords,

strings, numbers, comments), no autocorrect, Tab = two spaces.

  • Run (⌘/Ctrl+Enter) writes the buffer to

<workdir>/.dsh-matlab-runner/<stem>.m and runs it in the persistent session.

  • Script picker — every .m in scriptDir plus every unsaved draft.

Picking one loads it into the editor. + New starts a blank buffer, and

every buffer is remembered (per file path, plus each draft) so switching

files or tabs never throws typed code away.

  • Multiple folders — the tree header has a folder picker plus a + button.

+ mounts any absolute path (~ works) as an extra tree root, exactly like

MATLAB's "add to path" list; mounts are persisted in matlab-runner.json as

extraRoots and can be removed again from the same row. Mounted folders are

browsable and editable, but a run's working directory still follows the

workspace (relative paths stay anchored to the script being run).

  • Variable editor — double-click any row in the variables panel to open the

value; edit the literal and 写回工作区 / Write back assigns it with

evalin('base', '<name> = <literal>;'), so it really replaces the MATLAB

variable (the panel refreshes right after). Numerics are shown with

mat2str, anything else through evalc('disp(x)').

  • Stop / ■ aborts the curre

…(truncated)

以上内容来自 npm 上的 README,我们只做格式化,不改内容。

版本

npm 上共发布:4,最后更新 2026-10-30

链接

GitHub · Homepage · npm

同类插件