Bundle
dsh-session-roots
DSH plugin (pure, no core changes): a session may write several project folders declared by a VS Code-style workspace file beside its cwd; the web half adds 'Open Workspace from File' and 'Add Folder to Workspace' to the sidebar.
- Source
- yan4342
- License
- MIT
- Updated
- Updated 8 days ago
Readme
# dsh-session-roots
让一个 DSH 会话**同时可写多个项目文件夹**。项目集由一个**工作区文件**声明——直接复用 VS Code 的多根工作区格式(`*.code-workspace`),支持现有 VS Code 工作区文件拿来即用。
## 特性
- **多根可写**:会话可写文件夹 = 会话目录 + 工作区文件声明的文件夹。fs 工具全平台支持;shell 工具(Windows 上 bash/pwsh)同样支持
- **侧边栏新增两个入口**:
- **从文件打开工作区**:`添加工作区` 按钮菜单里选择任意 `.code-workspace`,其所在目录注册为一个工作区(命名 = 目录名)

- **将文件夹添加到工作区**:工作区行 `…` 菜单里把任意文件夹加进工作区

- **权限自动跟随**:工作区文件增删文件夹、会话结束、卸载插件,shell 写入权限自动同步增删,不留残留
## 安装
任选一种方式,装完**重启 `dsh web` 并硬刷新浏览器**(Ctrl+Shift+R)。安装即用,无需手改任何配置文件。
### 方式一:git clone + 本地安装(当前可用)
```sh
git clone <仓库地址> dsh-session-roots
dsh plugin --profile web add file:D:/你克隆到的路径/dsh-session-roots
```
> `file:` 必须写**绝对路径**(相对路径会被拒绝)。
### 方式二:GitHub 直接安装(推荐)
无需 clone,直接从 GitHub 拉取:
```sh
dsh plugin --profile web add https://github.com/yan4342/dsh-session-roots
```
> 仓库内即完整源码,**无需本地构建**(纯 JS,无编译步骤)。
## 使用
1. **声明工作区文件**:放在会话目录下(优先级从高到低):
- `dsh-workspace.json`(也可写成 `{ "source": "<绝对路径>" }` 指向任意位置的 `.code-workspace`)
- `*.code-workspace`(VS Code 格式,现有文件直接可用)
```json
{
"folders": [
{ "path": "." },
{ "path": "../legado-with-MD3" }
]
}
```
相对路径按**文件所在目录**解析(与 VS Code 一致);缺失或非目录的条目自动跳过。改文件即改项目集,可随仓库提交。
2. **从文件打开工作区**:侧边栏"工作区"标题栏点 **+** → "从文件打开工作区" → 选 `.code-workspace` → 该文件所在目录注册为一个工作区,命名 = 目录名(如 `legado`)
3. **将文件夹添加到工作区**:工作区行 **…** 菜单 → "将文件夹添加到工作区" → 选目录
4. `/workspace` 随时查看
## 卸载
```sh
dsh plugin --profile web remove dsh-session-roots
```
重启 `dsh web` 生效。写入权限会自动清理;会话目录里的 `dsh-workspace.json` 不再生效,可自行保留或删除。
## 常见问题
- **侧边栏插件列表里出现两个条目?** 正常——一个是业务入口,一个是文件系统服务,装好即用,无需分别管理。
- **从工作区文件删掉文件夹后,shell 还能写它吗?** 不会,权限会立即撤销。
- **进程被强杀(taskkill / 断电)后有权限残留?** 极少数情况可能残留,用管理员执行 `icacls <目录> /remove:g <SID>` 清理(SID 见 `icacls <目录>` 输出里的 `S-1-4-*` 条目)。
- **工作区文件放哪?** 会话启动时的目录下。换目录就换项目集。
## 已知限制
- **shell 多根写入仅 Windows**:Linux/macOS 的 shell 仍只认会话目录(fs 工具所有平台支持)
- **"从文件打开工作区"入口定位官方界面文案**:官方改版后该入口可能回退为原生行为,不影响其他功能
- **首次使用时打开文件夹选择器可能很慢**:后续打开会正常。
- **依赖 DSH 的接口**:DSH 大版本升级后可能需要跟进
## License
MIT
Install
dsh plugin --profile web add github:yan4342/dsh-session-roots
Profile: web
With the hub plugin installed, ask your agent to install it by name — it resolves the same plan shown here.
dsh plugin --profile web add github:stvlynn/dsh.fish#path:packages/dsh-plugin-hub
install dsh-session-roots from the hub
- This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.