DSH 的 PWA 插件:离线支持、Service Worker 缓存,并可作为应用安装。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:RaulLazaro/dsh-pwa-plugin
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
PWA plugin for DeepSeek Harness that adds offline support and install-as-app capability.
Features
- Service Worker with smart caching strategy
- PWA Manifest with proper maskable icons
- Automatic updates — new versions activate silently and reload the page exactly once (a first-ever visit never reloads)
- Versioned caches — cache names carry the package version, so upgrading the plugin purges stale caches automatically
- Offline-first for static assets
- Official DSH whale icon — derived from the upstream SVG favicon
Installation
1. Add as a dependency
From npm (once published):
npm install dsh-pwa-plugin
Or, for a local checkout, in your DSH web profile's package.json:
{
"dependencies": {
"dsh-pwa-plugin": "file:~/workspace/dsh-pwa-plugin"
}
}
2. Register the plugin
In your profile's cordis.patch.yml:
- insert:
- id: dsh-pwa
name: 'dsh-pwa-plugin'
3. Restart DSH
dsh web
Generate PNG Icons
The plugin ships pre-built PNG icons. To regenerate (requires sharp):
cd dsh-pwa-plugin
node scripts/generate-icons.js
This reads the official public/favicon.svg and produces:
| File | Size | Purpose |
|---|---|---|
icon-192.png |
192×192 | Regular (any) |
icon-192-maskable.png |
192×192 | Maskable (20% safe zone) |
icon-512.png |
512×512 | Regular (any) |
icon-512-maskable.png |
512×512 | Maskable (20% safe zone) |
How It Works
- The host plugin serves
/sw.js(stamped with the package version),/manifest.webmanifest, and icon files - It injects a service worker registration script into the HTML
- The service worker pre-caches static assets (one failing URL never aborts the install) and caches them for offline use
- The manifest enables installing the app as a PWA
- Updates are detected automatically and silently activated; the page reloads once per update
- DSH's built-in
/favicon.svgis used as-is (not overridden)
Caching Strategy
| Resource Type | Strategy | Description |
|---|---|---|
| HTML | Network-first | Always fetches the latest version; only storable 200 responses become the offline fallback |
| JS/CSS/Fonts/Images | Cache-first | Kept in a cache named after the package version, so an upgrade invalidates it without a manual version bump |
| Dynamic DSH routes | Not intercepted | /api, /auth-api, /oauth, /open-in-app, /plugins, /ws, /hooks and /dsh-pwa always reach the network |
Cache-Control: no-store |
Never cached | The server's directive wins over the service worker |
| API/WebSocket | Not cached | Always goes to the network |
Limitations
- Requires HTTPS to work (except localhost)
- Service worker cannot cache API calls
- Updates require a page reload (automatic after detection)
Project Structure
dsh-pwa-plugin/
├── src/
│ ├── host/
│ │ └── index.js # Host plugin (Node.js)
│ └── sw.js # Service Worker
├── public/
│ ├── manifest.webmanifest # PWA Manifest
│ ├── favicon.svg # DSH whale icon (same as upstream)
│ └── icons/ # PWA icons (maskable + regular)
├── scripts/
│ ├── generate-icons.js # Icon generator (sharp)
│ ├── install.js # Verification script
│ └── verify.js # Verification
├── cordis.patch.yml # Plugin registration
├── LICENSE
└── package.json
Testing
npm test
Zero-dependency suite on Node's built-in runner (node --test):
test/manifest.test.mjs— manifest required fields, icon densities (regular + maskable at 192/512) and that every icon file exists on disk.test/sw.test.mjs— the service worker evaluated against a fakeself: install/activate cache lifecycle (per-URL resilient pre-cache, versioned cache names, orphan cleanup), the bypass rules (non-GET, non-HTTP schemes,/api,/auth-api,/oauth,/open-in-app,/plugins,/ws,/hooks,/dsh-pwa, websocket upgrades), network-first HTML with its offline fallbacks, cache-first statics with the store guard (200/basic/no-store), and theGET_VERSION/SKIP_WAITINGmessages.test/host.test.mjs— route registration (sw, manifest, 4 icons, version), response headers, the package-version stamping of/sw.js, the index-HTML script injection, the registration script's reload guard (executed in a sandboxed VM), and the effect cleanup used on HMR unmounts.
License
MIT
链接
同类插件
yjh051108/dsh-routing-suite★ 6997
一个仓库三件套:DSH 插件包的运行时注入器(注入、热重载、卸载、开发侧挂区一键转正、路由自愈,外带设置页插件管理:列出、卸载、拖入文件夹内化)、任务感知的思维模式路由 agent 预设(router-standard / router-spec / router-react)、以及分级两级任务协议(commit_star / lock_stage / revise_do / edit_plan / mark_task / redteam_verdict 六个工具,任务状态落盘)。注入器实现直接在库内,安装的是它自己的行为而不是一份依赖清单。
strukto-ai/mirage#dsh★ 3696
把文件系统与 bash 提供者换成 mirage 虚拟工作区:文件工具与 shell 命令作用于挂载的资源(RAM、S3、Redis、Slack、Gmail、Notion、Postgres)而非宿主磁盘,支持按挂载点设置读/写/执行模式、按命令选择沙箱(进程内 monty、pyodide、quickjs;远程 docker、e2b、daytona),并可在虚拟终端中安装 CLI(git、gh、slack、linear、ntn、gws,或自行注册的程序树)作为命令头词。
first-fluke/oh-my-agent#dsh★ 1344
在工具执行前后以及尝试结束当前轮次时运行项目 OMA 检查。随插件安装 OMA CLI 依赖,并在首次使用时初始化未配置的项目。需要 Node.js 22+;首次初始化需要网络连接和项目目录写入权限。
hust-open-atom-club/oh-dsh★ 322
社区发行版:TUI、桌面端与 Web UI 统一体验,分层安装、一步到位。
weijiafu14/pi2dsh★ 217
Pi Host ABI 兼容引擎:装一次之后,npm 上的 Pi 扩展原包经 `dsh plugin add <pi-package>` 直接作为 DSH 原生插件挂载。已在官方 DSH 上端到端验证 pi-mcp-adapter(完整 MCP 管理面:OAuth、resources、prompts、MCP Apps、elicitation、sampling)、@tintinweb/pi-subagents、pi-code、pi-hermes-memory、pi-background-tasks;`pi2dsh inspect` 在安装前报告一个包的兼容情况。
Fishquito7/dsh-skill-mcp-panel★ 207
在 DSH Web 设置中管理技能与 MCP 服务器:技能卡片热启停、工作区作用域、分组、批量迁移与拖拽导入,以及 stdio/HTTP MCP 增删改查、连接测试、密钥脱敏,并附带统一 dsh-panel 命令行。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。