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

dsh-predict

v1.2.5

Published

Predicts your next instruction from the current conversation and shows it as the composer placeholder; press Tab to turn it into an editable draft.

Readme

dsh-predict

npm license dsh

基于当前对话预测下一条用户指令,直接呈现在输入框的占位文字中;按 Tab 采纳为可编辑草稿。


效果

会话空闲且输入框为空时,原生提示文字被替换为一条建议:

- 发消息或创建任务, / 调用指令, @ 文件或对话
+ 跑一下测试

Tab 或点击可填入输入框(光标位于末尾),不会自动发送。

建议由当前会话正在使用的模型生成:

| 上下文 | 建议 | | --- | --- | | 刚完成一次代码修改 | 跑一下看看效果 | | 测试报告显示 3 个失败用例 | 先修掉这三个失败用例 |


安装

市场索引

https://raw.githubusercontent.com/Dogtiti/dsh-predict/main/market-index.json

设置 → 插件 → 启用实验性市场 bundle → Discover → 添加上面的地址 → 安装 dsh-predict。

npm

npm i dsh-predict

在 Plugins 页用「添加」填写包名。

本地目录

git clone https://github.com/Dogtiti/dsh-predict

Plugins → 添加 → 选择该目录。


行为

建议仅在以下条件全部满足时请求并显示:

  • 该会话已完成至少一轮对话
  • 会话不在运行中
  • 输入框为空、无待发送附件、无已认领的斜杠命令
  • 非一次性子会话(只读输入框)

不接管的情况:

| 条件 | 行为 | | --- | --- | | 输入框非空 | 不请求、不显示 | | 会话运行中 | 不显示 | | / 或 @ 菜单弹出 | 不显示 |


配置

- insert:
    - id: composer-predict
      name: 'dsh-predict'
      config:
        model: deepseek-chat
        maxSuggestionChars: 24

| 键 | 默认 | 说明 | | --- | --- | --- | | enabled | true | 总开关;关闭后路由返回 503,客户端不再请求 | | provider / model | '' | 指定模型;留空跟随当前会话 | | maxContextMessages | 8 | 送入模型的消息条数(取尾部) | | maxMessageChars | 600 | 单条消息最大字符数(保留头尾) | | maxSuggestionChars | 32 | 建议的目标长度 | | maxTokens | 200 | 输出上限 | | timeoutMs | 20000 | 单次请求超时 | | cacheTtlMs | 60000 | 相同会话事件序号下的缓存时间 | | diagnostics | false | 将客户端判定写入 .diagnostics.jsonl,用于排障 |


实现

插件为标准的 DSH bundle,包含 Host 与 Client 两部分:

┌──────────────── 浏览器 ────────────────┐        ┌───────────── Host ─────────────┐
│ conversation.composer.dock             │        │ POST /api/composer.predict     │
│  · 回合结束时请求(running: true→false) │  HTTP  │  · sessions.get(id)            │
│  · 重绘 [data-composer-placeholder]     │ ─────► │  · session.deriveMessages()    │
│  · 自检:内容包含建议且字号 ≥ 8px        │ ◄───── │  · 当前会话 provider/model      │
│  · Tab → inputActions.setDraft()        │  JSON  │  · 按 seq 缓存 60s             │
└────────────────────────────────────────┘        └────────────────────────────────┘

宿主占位元素已提供定位(inset:4px 8px auto 14px)、字号、行高、省略号与 IME 组合期隐藏,插件只改写其内容:

[data-composer-placeholder] { color: transparent }
[data-composer-placeholder]::after {
  content: "跑一下测试";
  position: absolute; inset: 0;
  font: inherit;
}

不使用 font-size: 0 配合变量恢复字号:变量解析失败时字号会退化为 0,文字存在但不可见。font: inherit 不依赖变量。

挂载后读取 getComputedStyle(target, '::after') 自检,若内容不含建议或字号小于 8px,回退为输入框下方一行并在控制台输出 [composer-predict] 警告。


数据与开销

  • 读取本会话日志尾部(用户与助手文本、工具名、工作目录),发送至会话自身配置的模型服务与凭据。
  • 每轮一次独立小请求,默认上限 200 tokens;enabled: false 可关闭。
  • 结果不落盘,不写入会话日志。

开发

node --test "test/*.test.mjs"

14 项:提示词拼装、模型路由回退、输出清洗、缓存失效、开关、CSS 转义、门禁条件、兜底渲染。

test/render-proof/ 将插件实际生成的 CSS 应用于宿主占位结构,用无头 Chrome 渲染并截图,用于核对重绘结果,包含字号变量非法的边界环境。


兼容性

  • DSH ^0.2.1-0(engines.dsh)。
  • 依赖宿主占位元素的 [data-composer-placeholder] 标记;缺失时走回退路径,不影响输入框本身。

相关插件

| 插件 | 说明 | | --- | --- | | dsh-predict(本仓库) | 预测下一条指令并显示为占位文字,Tab 采纳 | | dsh-input-history | 输入框中按 ↑ / ↓ 回填历史消息 | | dsh-subagent-bridge | 让 Codex 通过本机 MCP 把 DSH 当 subagent 用(spawn / wait / followup),反向也能把任务派给 Codex | | dsh-quota-meter | 在模型选择器旁显示供应商套餐额度余量(目前 GLM Coding Plan),点开是明细浮层 | | dsh-provider-icons | 在模型名旁显示供应商品牌 logo(24 个厂商,支持前缀匹配) |

许可

MIT © Dogtiti

诊断

diagnostics: true 会把每次预测的决策写进包目录下的 .diagnostics.jsonl:

{"event":"predict-request","sessionId":"…","found":true,"transcriptLength":3217}
{"event":"predict-done","sessionId":"…","suggestion":"跑一下测试","raw":"跑一下测试"}
{"event":"predict-error","sessionId":"…","message":"…"}

用来回答"为什么输入框没有预测":found:false = 会话没挂载;transcriptLength 太小 = 可参考的上下文太少;suggestion:null + raw:"NONE" = 模型判定无法预测。

没有就不显示

提示词不再让模型输出 NONE 之类的占位词:有具体任务就给一条,没有就什么都不输出。插件侧再把少数模型"把沉默写成文字"的情况(NONE / 无 / 什么都不输出 / 空回复)统一当成"没有建议",输入框保持原样。

实测同一个真实工作会话:旧提示词返回 NONE,新提示词返回「停止重复调用,改为汇总当前验证结果」;只有问候的对话则保持空白。