# dsh-open-in-vscode

中文 | [English](README.en.md)

[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)（dsh）Web 插件：把浏览器 GUI 与 VSCode 打通。

[![Listed on dsh-plugin.org](https://dsh-plugin.org/badges/listed.svg)](https://dsh-plugin.org/plugins/zhili-wang/dsh-open-in-vscode)

## 功能

### 工作区一键打开

侧边栏工作区行的 `...` 菜单新增「在 VSCode 中打开」：

- VSCode 已打开该项目 → 直接唤起（聚焦）对应窗口；
- 未打开 → 新开窗口打开项目。

### 对话内文件跳转

对话中 DSH 输出的文件路径，点击即在 VSCode 中打开：

- 支持收尾正文的行内文件引用、产物文件 chip、工具行打开按钮；
- 所属项目未在 VSCode 打开时，先打开项目窗口，再定位到文件；
- 支持 `文件:行:列` 精确跳转；
- 找不到 VSCode 或打开失败时，自动回退为系统默认打开方式，点击永不失效。

## 安装

```bash
dsh plugin --profile web add @alex-dsh-plugin/open-in-vscode
```

也可以直接从 GitHub 安装：

```bash
dsh plugin --profile web add zhili-wang/dsh-open-in-vscode
```

重启 `dsh web` 生效。插件自带 bundle 层，安装即激活，无需手动编辑配置。

如需覆盖默认配置（如指定编辑器路径），在 `~/.dsh/profiles/web/cordis.patch.yml` 追加：

```yaml
- id: vscode
  config:
    command: /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code
```

## 编辑器探测顺序

1. 配置 `command`（显式覆盖）；
2. macOS：`/Applications/Visual Studio Code.app/.../bin/code`（含 `~/Applications`）；
3. PATH 中的 `code`——指向其他编辑器（如 Cursor）的同名 shim 会被跳过。

均失败时所有手势回退为系统默认打开行为。

## 配置

| 键 | 默认值 | 说明 |
|---|---|---|
| `command` | 自动探测 | VSCode `code` CLI 的绝对路径 |
| `rerouteOpenPath` | `true` | 是否把对话内文件打开改走 VSCode |

## 已知限制

- 菜单注入依赖当前侧边栏 DOM 结构；上游改版会让菜单项静默失效（不影响其他功能）。
- 可点击的文件引用沿用官方词表：本轮产出文件（精确路径或唯一 basename），外加工具行打开按钮。
- 两个工作区标题完全相同时无法区分，不注入菜单项。
- 仅面向本机部署（浏览器与 host 同机）。

## 开源协议

[MIT](LICENSE) © Alex
