dsh-enter-using
Codex-style keyboard answers for the pending command-approval panel — 1 allows once, 2 rejects, Enter confirms the highlighted choice, arrow keys move it, and Esc rejects, with the buttons still usable by mouse.
Install
dsh plugin --profile web add dsh-enter-using
Sandbox test
This plugin has not been tested yet. Submit a test →
README
dsh-enter-using
DSH Web 界面插件:命令授权(审批)支持键盘回车 + 数字键,手感类似 Codex。
默认的 DSH 审批面板只认「回车允许 / Esc 拒绝」。装上这个插件后,面板变成带编号选项的键盘面板,不用鼠标也能授权。
按键
按键 · 作用
1 · 允许一次
2 · 拒绝
Enter · 确认当前高亮项(默认第 1 项=允许一次)
Esc · 拒绝
↑ ↓ ← → · 切换高亮项(循环)
鼠标悬停 / 点击 · 同样可用
面板选项顺序固定为 1 允许一次、2 拒绝,与 Codex 一致:默认回车=放行,误按回车也不会拒绝。
实现方式
- 以
priority: 0.5注册到会话编辑器的链式槽位conversation.composer,比官方审批面板(priority: 1)更早被匹配,从而接管审批渲染。 select只匹配kind === "approval"且可作答的待处理交互;其它待处理交互(例如计划评审)仍返回null,继续由官方面板处理,互不干扰。- 键盘监听注册在
document的捕获阶段,命中后preventDefault()+stopPropagation()。下列情况一律让行: - 事件已被处理(
defaultPrevented)、输入框/文本域/contenteditable内、页面上存在[role="dialog"]/[aria-modal="true"]弹窗; - 带
Ctrl/Meta/Alt修饰、输入法组合态(isComposing/keyCode 229)、系统按键重复(repeat)。 - 不调用
ctx.shortcuts.registerFixed:官方审批面板已占用Enter/Escape两个固定快捷键,键位处理放在插件组件内部,避免重复注册冲突。 - 每次审批只作答一次:作答中禁用按钮,Host 拒绝/失败后自动恢复可作答状态,组件卸载后不再更新状态。
- 样式通过
ctx.effect注入一串带data-plugin-css标记的<style>,卸载时移除;类名统一deu_前缀,颜色只引用--dsw-alias-*主题变量并带兜底值。
安装
本仓库本身就是一个 DSH bundle(package.json 里的 dsh.bundle.patch + dsh.client)。
- DSH 内:
plugin_manager→install_bundle,target 填本仓库目录(例如D:\dsh-project)。 - 命令行:
dsh plugin add D:\dsh-project。 - npm / 插件商店:发布到 npm 后,商店会显示版本号与下载量,并可安装预构建包(免
allowBuilds构建授权)。
安装后按提示刷新页面或重启 dsh web 生效;命令授权面板出现时即可用数字键 / 回车 / Esc 作答。
开发
npm test
26 项测试,全部通过。测试在 vm 沙箱中加载 client.js(stub 掉 window.__ModuleLoader__、document 与 react),覆盖:槽位注册契约、locale 词典完整性、样式注入与回收、按键映射与全部守卫条件、作答状态机(重复按键 / 不可作答 / 失败回滚)、以及卸载时监听器清理。
上架 dshmarket(插件商店)
dshmarket 的插件列表来自精选目录 awesome-dsh-plugin,条目不写在本仓库里,而在那边「一个插件一个 YAML 文件」。本仓库保留了一份待提交的条目副本:[market/dshmarket-entry.yml](market/dshmarket-entry.yml)。
收录条件(对照本仓库现状):
条件 · 现状
package.json 声明 dsh.bundle(只有 dsh.client 不算) · ✅ dsh.bundle.patch
仓库有真实可用的代码 · ✅ 26 项测试
仓库创建满 1 天 · ✅ 首个提交 2026-10-08
仓库添加 dsh-plugin topic · ✅ 已设置
提交状态:条目已通过 PR 提交到上游 —— awesome-dsh-plugin#6971(只含 data/plugins/wukiQAQ__dsh-enter-using.yml 一个文件)。合并后目录站点与 dshmarket 会自动收录。
提交方式:把 market/dshmarket-entry.yml 复制到 awesome-dsh-plugin 仓库的 data/plugins/wukiQAQ__dsh-enter-using.yml,提 PR。文件名必须与 url 对应(owner__repo.yml),README 由 CI 生成、不要手改。条目字段已在本地用该仓库的 scripts/lib/entries.mjs 校验:4461 条全量 0 问题。
发布到 npm(版本同步)
商店卡片上的版本号取自 npm 的 dist-tags.latest(见 dshmarket 的 src/registry.ts:只有 GitHub 源码的条目 version 为 null,界面直接不显示版本号)。所以「随版本同步」=把包装到 npm:之后每次 npm version + npm publish,商店会自动显示新版本,不需要再往目录提 PR。
- 收录与 npm 无关:不发 npm 也能从 GitHub 安装,只是没有版本号与下载量(上游
contributing.md原文)。 - npm 映射由上游从 registry 自动采集:目录条目里不需要、也不允许手写
npm:键。 - 发布前提(本仓库已就绪):
repository指回本仓库(上游靠它把 npm 包与目录条目关联起来);官方@deepseek-ai/用peerDependencies声明,且范围带显式预发布分支(否则 node-semver 会静默排除所有-rc.版本,用户npm install时遇到ERESOLVE);private已移除。 - 手动发布:
npm login→npm publish(prepublishOnly会先跑 26 项测试)。 - 自动发布:[.github/workflows/release.yml](.github/workflows/release.yml) 在推送
v*标签时发布,需要在仓库 Secrets 里配置NPM_TOKEN(npm automation token,Publish 权限)。发版流程:改version→ 提交 →git tag v0.1.1 && git push origin v0.1.1。
目录
package.json # dsh.bundle.patch + dsh.client(platform: web, immediately) cordis.patch.yml # bundle 注入声明 index.js # Host 半边(无行为,UI 全在 Client) client.js # Client 半边:审批面板 + 键盘交互 test/client.test.mjs # 测试 market/dshmarket-entry.yml # 待提交到 awesome-dsh-plugin 的商店条目 .github/workflows/release.yml # 打 v* 标签时自动 npm publish(需 NPM_TOKEN)
Rendered from the README published on npm. Formatted only, not edited.
Versions
Published on npm::2,最后更新 2026-10-15