dsh-plugin-modern-web-guidance:让智能体编写现代 Web 代码

前言

DeepSeek Harness(dsh)的设计理念是「一切皆插件」。当智能体被要求编写前端代码时,它往往直接复用训练数据中的旧有模式(如旧版 HTML/CSS/JS 写法),而不是使用当前浏览器原生、更高效 API。这会导致代码不兼容现代浏览器特性,维护成本增加。dsh-plugin-modern-web-guidance 通过集成 Google Chrome 的 Modern Web Guidance,为智能体提供一份经过筛选、Token 高效的 Web 平台 API 指南,使其在动手写代码前先查阅当前最佳实践。

插件简介

dsh-plugin-modern-web-guidance 是一个 DeepSeek Harness 插件,它将 Google Chrome 的 Modern Web Guidance 指南打包进 npm 包 modern-web-guidance,并在 dsh 中暴露三个工具:modern_web_search、modern_web_retrieve 和 modern_web_list。

该插件由社区开发者 korosu 维护,是开源项目,遵循 MIT 许可证。它不隶属于 Google 或 DeepSeek。

核心功能

插件提供三个命令行工具,用于检索 Web 平台 API 的现代用法:

  1. modern_web_search
    - 接受一个简短的英文查询
    - 返回匹配的指南 ID 及描述

  2. modern_web_retrieve
    - 接受一个或多个指南 ID
    - 返回完整指南文本,包含代码模式、注意事项和降级方案

  3. modern_web_list
    - 列出所有可用的指南
    - 用于搜索无结果时的兜底方案

所有搜索操作在本地进行,依赖的 modern-web-guidance npm 包内置在插件中,无需额外下载或联网即可使用。

安装与启用

安装插件需要指定一个 profile,示例中使用 web:

dsh plugin --profile web add dsh-plugin-modern-web-guidance

安装完成后重启 dsh。可通过以下命令确认插件已注册:

dsh plugin --profile web list

如果需要从发布页面的 tarball 安装,先下载 dsh-plugin-modern-web-guidance-<version>.tgz,然后:

dsh plugin --profile web add ./dsh-plugin-modern-web-guidance-<version>.tgz

使用方式

插件无需额外配置。当智能体被要求编写 HTML/CSS 或客户端 JS 时,应按顺序调用工具:

  1. 使用 modern_web_search 查询目标功能的现代实现方式
  2. 使用 modern_web_retrieve 获取完整指南
  3. 根据指南编写代码

示例提示词:

“Make a modal dialog that closes on outside click and Esc, with a smooth open/close animation.”

如果模型不主动调用这些工具,可以在项目根目录的 AGENTS.md 中添加说明:

Before any HTML/CSS/client-side JS task, call modern_web_search, then modern_web_retrieve.

更新与移除

指南内容来自 modern-web-guidance npm 包,版本在安装时固定。获取新指南需要更新插件:

dsh plugin --profile web remove dsh-plugin-modern-web-guidance
dsh plugin --profile web add dsh-plugin-modern-web-guidance

然后重启 dsh。

禁用插件而不卸载,可在 profile 的 cordis.patch.yml 中添加:

- id: modern-web-guidance
  disabled: true

完全卸载:

dsh plugin --profile web remove dsh-plugin-modern-web-guidance

注意事项

  • 插件依赖 Node.js >= 22.19
  • 需要满足 peer 依赖版本要求:@deepseek-ai/cordis 和 @deepseek-ai/dsh-tools 的特定版本范围
  • 默认关闭遥测,如需启用可在环境变量中设置 DISABLE_TELEMETRY=0
  • 搜索使用的是英文查询,返回的指南内容为英文
  • 插件安装前建议查看源码与许可证

总结

dsh-plugin-modern-web-guidance 为 DeepSeek Harness 提供了一套轻量级的 Web 平台最佳实践检索能力。它通过本地化的搜索与检索,让智能体在编码前优先使用现代浏览器 API,避免生成过时的代码模式。对于需要编写前端代码的 dsh 项目,这个插件能降低维护成本,提升代码质量。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜