npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@little_monkey/dsh-selection-actions

v1.0.1

Published

Selection actions for the DSH Web conversation: comment on selected text or add a quoted reference to the composer.

Readme

dsh-selection-actions

2026-10-26 由 dsh-kimi-ui 改名而来:插件对 Kimi 没有任何依赖,只是交互观感参考过 Kimi Code。

DSH Web 的“选中文本操作”插件:在对话里选中一段文字后,可以

  • 添加到对话:把选中文字作为 Markdown 引用块加入当前会话的输入框草稿(不发送)。
  • 评论:写一句评论,提交后把“引用块 + 评论”加入输入框草稿(不发送,按 Enter 发送)。

交互参考 Kimi Code 的消息选区菜单;插件只有一个 client 半,Host 半为空 apply()。

使用

  1. 在会话里拖选一段文字(用户消息、助手回答、代码块均可)。
  2. 选区旁出现浮动条:添加到对话 | 评论。
  3. 点「添加到对话」后,输入框里出现一个引用 chip(借 DSH 原生 reference chip,显示截断的选中文字);点「评论」打开小气泡,写完提交后输入框里是引用 chip + 评论文字。
  4. 鼠标悬停或点击这个引用 chip,会弹出「引用」卡片显示完整选中内容(带小尾巴,跟随主题:深色主题下是浅色卡片,与 Kimi 一致)。
  5. 输入框获得焦点后按 Enter 发送;发送时插件通过自定义引用 source 的 codec 把完整引用文本交给模型。

行为细节:

  • 引用 chip 的显示标签会截断到约 28 字;完整原文保存在 chip 的 ref 里,模型收到的是完整 Markdown 引用块 + 明确分隔:

    > 选中的原文
    > 第二行
    
    评论:<评论内容>

    即使用户在 chip 后直接打字,codec 也会在引用块后补空行,保证用户文本不和引用混在同一行。

  • 评论默认只进草稿、不自动发送。

  • 选区包含公式时,取文不是 Selection#toString(),而是克隆选区后把每个 KaTeX 公式用其 annotation 还原成 $…$(display 公式为 $$…$$);否则 KaTeX 的隐藏 MathML 层 + 可见字形层会被同时选中,公式变成「一个 token 一行 + 重复两份」(2026-10-29 修复)。

  • 引用超过 6000 字时按行截断,并保证不会截断在 $…$ 中间。

  • 如果当前 DSH 组合没有 inputTriggers 服务,或引用 chip 写入失败,会自动降级为旧的纯文本引用块(> … + 评论:…),功能不丢。

  • 选区为空、位于输入框/可编辑区、或位于对话区域之外(侧栏、设置等)时不弹浮层。

  • Esc、滚动页面、点击浮层外部都会关闭浮层;评论框支持 Ctrl/Cmd+Enter 提交。

  • 浮层颜色只使用 --dsw-alias-* / --dsw-radius-* 主题 token,跟随明暗主题;引用预览卡在深色主题下固定为浅色(Kimi 风格)。

  • 文案有中英文。

实现位置

  • 槽位:conversation.input.overlay(session 作用域,replaceRisk: none),occupant id selection-actions。
  • 草稿写入:InputActions.setDraft({ text, references }) 把引用作为原生 ReferenceChipNode 写入;发送时由注册到 inputTriggers 的自定义 quote source 的 codec 序列化为完整引用文本。
  • 引用 chip 点击:走 input-trigger 的 openReference 原生分支;悬停预览通过监听 chip 的 title 标签实现(chip 没有公开 hover 事件)。
  • 选区定位:window.getSelection() + 选区 Range 的 getBoundingClientRect();只用 data-slot^="conversation." / data-conversation-scroll 做“是否在对话区域”的轻量作用域判断,不抓取消息行内部结构。
  • 弹层:react-dom 的 createPortal(document.body),与官方 feedback 弹窗同款位置策略;不依赖 @deepseek-ai/dsh-client-ui-primitives。
  • 插件为 profile 级安装,对所有会话生效。

已知限制

  • DSH 没有「任意文本引用」这种原生引用类型;chip 的 appearance 只能是 session / file / folder,所以引用 chip 借用的是 session 气泡图标,不是 Kimi 的引号图标。
  • 发送后的用户气泡里,引用会退化为纯文本 > …(DSH 的用户消息渲染由宿主拥有,插件不能注册新的消息引用节点);输入框阶段的 chip + 预览卡是接近 Kimi 的部分。
  • 选区检测依赖浏览器的 Selection API;DSH 目前没有“消息选区”原生槽位。作用域判断只用槽位锚点,不依赖消息 DOM 的 data-chat-* 私有字段。
  • 评论是普通用户消息,不是独立批注存储。
  • 不做“撤回消息”(DSH 会话日志 append-only,没有原地删除 API;如需请另做分支撤回方案)。

安装 / 卸载

  • 安装:plugin_manager action=install_bundle target=<本目录绝对路径>(profile 级)。
  • 卸载:plugin_manager action=remove_bundle target=@little_monkey/dsh-selection-actions。
  • 修改 client.js 后,开发期 HMR 会轮询 bundle 变更并重载;若页面仍用旧代码,刷新一次页面即可。