Skip to content
dsh.fish
Bundle

dsh-open-in-code

DeepSeek Harness plugin: open the current session's workspace directory in Visual Studio Code from the session header.

Source
abbno
License
Apache-2.0
Updated
Updated 6 days ago

Readme

# dsh-open-in-code

DeepSeek Harness 插件:在 Web GUI 会话头部一键用 **Visual Studio Code** 打开当前会话所属的工作区目录。

## 功能

- 在会话头部右侧工具区显示 **"在 VSCode 打开"** 按钮(位于 "Session log" 下载按钮左侧)。
- 点击后自动解析当前会话的工作区目录,并在 VS Code 中打开。
- 已运行 VS Code 时:转发到现有实例并立即返回;未运行时:启动新窗口。

## 安装(分发给其他人)

### 方式一:通过 Git 仓库(推荐)

接收方执行:

```sh
dsh plugin --profile web add git+https://github.com/abbno/dsh-open-in-code.git
```

安装后 `dsh` 会自动把包加入 profile 的 `dsh.profile.bundles` 层列表并生效,重启 `dsh web` 即可看到按钮。

> 若 pnpm 要求先放行构建脚本,按其提示在
> `$DSH_HOME/profiles/web/pnpm-workspace.yaml` 的 `allowBuilds` 中添加该包即可
> (本插件纯 JS、无构建步骤,通常无需此操作)。

### 方式二:本地目录 / tarball

```sh
# 本地目录
dsh plugin --profile web add file:D:/path/to/dsh-open-in-code
# 或打完的 tarball
dsh plugin --profile web add ./dsh-open-in-code-0.1.0.tgz
```

### 手动编辑 profile(等价方式)

把以下内容加入 `$DSH_HOME/profiles/web/package.json` 的 `dependencies` 与
`dsh.profile.bundles`(或直接 `pnpm add` 后重新运行 `dsh`,让其自动 reconcile):

```jsonc
{
  "dependencies": {
    "dsh-open-in-code": "git+https://github.com/abbno/dsh-open-in-code.git"
  },
  "dsh": {
    "profile": {
      "bundles": [/* ... */, "dsh-open-in-code"]
    }
  }
}
```

## 工作原理

- `cordis.patch.yml`:profile bundle patch,`insert` 一行挂载本插件的 Loader 条目。
- `lib/index.js`(Host):Cordis 插件 `apply(ctx)`,注册 DSH 内置命令 `open-in-vscode`——
  1. 从 `invocation.agent.session.header.cwd` 读取会话的工作区目录(回退:注册表中按 session 归属找工作区路径);
  2. 定位 VS Code `Code.exe`(`%LOCALAPPDATA%\Programs\Microsoft VS Code` → Program Files → PATH 上的 `code` shim 回溯);
  3. `subprocess.spawn(['Code.exe', cwd])` 打开目录,不等待退出即返回成功。
- `lib/client.js`(Client):`window.__ModuleLoader__.load(...)` 注册到
  `conversation.session.header.utilities` 插槽(`id: open-in-vscode`,`order: -10`,排在 Session log 前),
  按钮点击后经 DSH 预置的 `ctx.remote.commands.execute(sessionId, '/open-in-vscode')`
  调用 Host 命令(无需自定义 RPC / typert)。

## 开发

```
dsh-open-in-code/
├── package.json       # dsh.bundle.patch + dsh.client(platform: web)
├── cordis.patch.yml   # 挂载行
├── lib/
│   ├── index.js       # Host 插件(纯 JS,无构建)
│   └── client.js      # Client 插件(__ModuleLoader__ 格式)
├── README.md
└── LICENSE (Apache-2.0)
```

纯 JavaScript、零构建、零运行时依赖(仅依赖 DSH 内置服务 `commands` / `agents` / `subprocess` / `slots` / `remote`)。

## License

Apache License 2.0

Install

dsh plugin --profile web add github:abbno/dsh-open-in-code

Profile: web

  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source