跳到正文
dsh-market 浏览插件 GitHub EN

RaulLazaro/dsh-pwa-plugin

DSH 的 PWA 插件:离线支持、Service Worker 缓存,并可作为应用安装。

Star 数 ★ 2 分类 开发与运行时 收录于 2026-09-03

安装

在 DeepSeek Harness 里通过 dsh-market 安装

dsh plugin --profile web add dshmarket

或使用命令行

dsh plugin --profile web add github:RaulLazaro/dsh-pwa-plugin

装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络。请先审阅源码,并尽量锁定 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 — silently activates new versions
  • Offline-first for static assets
  • Official DSH whale icon — derived from the upstream SVG favicon

Installation

1. Add as a dependency

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

  1. The host plugin serves /sw.js, /manifest.webmanifest, and icon files
  2. It injects a service worker registration script into the HTML
  3. The service worker caches static assets (including icons) for offline use
  4. The manifest enables installing the app as a PWA
  5. Updates are detected automatically and silently activated
  6. DSH's built-in /favicon.svg is used as-is (not overridden)

Caching Strategy

Resource Type Strategy Description
HTML Network-first Always tries to fetch the latest version
JS/CSS/Fonts/Images Cache-first Serves from cache if available
API calls 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

License

MIT

内容来自项目 README(GitHub)↗

评论

评论存放在 GitHub Discussions。用 GitHub 账号登录后可发表评论或点表情。