Bundle
dsh-getman-panel
An API testing sidebar panel (Getman) for dsh-better-sidebar: method/URL, params, headers, raw body, response viewer, shared history — with a host-side proxy that bypasses CORS.
- Source
- zhangkkkai
- License
- MIT
- Updated
- Updated 2 days ago
Readme
# dsh-getman-panel
API 测试侧边栏面板(Getman),作为 [dsh-better-sidebar](https://github.com/omdsh-dev/DSH-better-sidebar) 的配套插件:
- **请求编辑**:方法(GET/POST/PUT/PATCH/DELETE/HEAD/OPTIONS)+ URL + Params / Headers / Body
- **响应查看**:状态码徽章、耗时、大小、响应体(JSON 自动美化,右上角可一键复制)/ 响应头
- **历史记录**:全局共享最近 100 条请求(所有工作空间共用),点击回填、单项删除、一键清空
- **绕过 CORS**:通过 host 半代理转发,任意 HTTP(S) 接口都能测试
## 前置条件
- DeepSeek Harness web 正常运行(`dsh web`)
- [dsh-better-sidebar](https://github.com/omdsh-dev/DSH-better-sidebar) ≥ 0.12.0(推荐最新,已在 0.16.1 验证)
- Node.js ≥ 20、pnpm ≥ 10
## 安装
### 本地开发(link 方式)
1. 编辑 `~/.dsh/profiles/web/package.json`:
- `dependencies` 增加 `"dsh-getman-panel": "file:/path/to/dsh-getman-panel"`
- `dsh.profile.bundles` 增加 `"dsh-getman-panel"`
2. 在 profile 目录执行 `pnpm install`
3. **重启 `dsh web`**(Ctrl+C 后重新启动)——新增 bundle 与 host 半路由都需要重启
4. 浏览器硬刷新(Cmd/Ctrl+Shift+R),侧边栏 `+` 菜单出现 **Getman** Tab
### 发布后(npm / GitHub 源)
```sh
dsh plugin --profile web add dsh-getman-panel
```
## 使用
1. 点击侧边栏 `+`,选择 **Getman**(⇄)
2. 选择方法、输入 URL,可展开 **Params / Headers / Body** 编辑
3. 点击 **发送**;请求中可点 **取消** 中断
4. 响应显示在下方:状态码、耗时、大小、响应体(JSON 自动格式化)/ 响应头,鼠标移到响应体上可点右上角 `⧉` 复制
5. 每次发送自动记入历史(全局共享,切换工作空间不丢失),点击历史条目回填请求,可删除或清空
> Params 会合并进 URL 查询串;粘贴带 `?` 的 URL 会自动把查询参数解析到 Params 表格;Body 选择 JSON/XML/Form/Text 会自动写入对应 `Content-Type`(你手动添加的 `Content-Type` 优先)。
## 架构
| 平面 | 文件 | 说明 |
|------|------|------|
| Host 半 | `src/index.ts` | 用 `ctx.webServer.register()` 注册 `/dsh-getman/api/proxy` 路由,服务端 `fetch` 转发,返回 `{ ok, status, statusText, headers, body, size, truncated, timeMs }` 或 `{ ok:false, error }` |
| Client 半 | `src/client/index.tsx` | 注册 `getman` Tab;同源 `fetch` 代理路由收发请求;草稿 + 历史持久化到 `localStorage`(key `dsh-getman-panel:global`,所有工作空间共享;首次加载自动迁移旧版数据) |
## 开发
```sh
pnpm install
pnpm run typecheck # 类型检查
pnpm run build # 构建 host ESM + client CJS 双产物
```
构建成功标志:`lib/client.js` 开头包含 `window.__ModuleLoader__.load({ id: "dsh-getman-panel", ...`。
## 常见问题
- **改了 client 不生效**:硬刷新浏览器(Cmd/Ctrl+Shift+R)。
- **改了 host / 新增 bundle 不生效**:重启 `dsh web`。
- **代理路由被占用**:本插件使用精确路径 `/dsh-getman/api/proxy`,与 better-sidebar 的 `/sidebar/*` 不冲突。
## 参考
- [dsh-better-sidebar 外部插件接入指南](https://github.com/omdsh-dev/DSH-better-sidebar/blob/master/docs/external-plugin-guide.md)
- [dsh-todo-panel](https://github.com/zhangkkkai/dsh-todo-panel)(纯 client 参考实现)
Install
dsh plugin --profile web add github:zhangkkkai/dsh-getman-panel#f973bb52c5db134280aba4be071b1c5e77de1854
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-getman-panel from the hub
- This package builds from source on install. pnpm will ask you to allow its build script — that is permission to run the package’s code on your machine, outside the agent sandbox. Only allow sources you trust.