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-session-history-search

v0.1.1

Published

Search the messages of every past conversation from a sidebar entry.

Readme

搜索历史对话(dsh-session-history-search)

在 DSH 左侧栏新增一个入口,打开一个居中面板,按关键词搜索本机所有历史会话的消息内容,点击命中项直接跳到对应对话。

组成

| 半边 | 位置 | 作用 | | --- | --- | --- | | Host | index.js | 自建内存索引 + 同源路由 POST /dsh-session-history-search/search | | Client | client.js | sidebar.panellist 入口 session-history-search;main 同名 key 的面板 |

为什么不用内置搜索

本部署把会话语义索引关掉了(session-query-sqlite 的 openAt: "never"),所以 ctx.sessions.search() / sessionQuery.searchSessions() 会直接抛 SESSION_QUERY_SEARCH_DISABLED。插件没有改动这个全局开关,而是改用同一服务的 精确读取接口:

  • sessionQuery.listSessions() → 全部会话(含持久化会话)的 header;
  • sessionQuery.readSurface(id) → 当前消息面(user / assistant 文本)。

只保留 user / assistant 的 text 块(每条 ≤3000 字、每会话 ≤60000 字),在 Host 内存里 建小索引;首次搜索触发构建,插件激活 4 秒后也会后台预热,页面按 1.2s 轮询显示 「正在建立索引 done/total」并自动补全结果。索引不落盘,重启 DSH 后首次需要重建。

接口

POST /dsh-session-history-search/search
{ "query": "WebBridge", "limit": 40 }

200 { "ok": true,
      "items": [{ "sessionId", "snippet", "time", "fallbackTitle", "role" }],
      "indexing": { "building": true, "done": 33, "total": 711 },
      "indexed": 33, "buildError": null }

标题由 Client 用会话列表快照(useSessions(s => s.byId[id]).title)解析, 快照里没有的会话用 Host 给的首条用户消息 fallbackTitle;打开会话走 ctx.uiWorkspace.openSession(sessionId) + ctx.layout.selectPanel('conversation')。

交互

  • 默认按最近消息时间倒序;结果栏右上角可切「最新 / 相关度」,选择写入 localStorage(dsh.session-history-search.sort)并在下次打开沿用。
  • 输入即搜(220ms 防抖;新查询会中止上一次请求并清空旧结果)。
  • 索引构建期间轮询刷新,但保留当前列表与选中项,不清空、不跳滚动位置。
  • Enter 打开当前项,↑ ↓ 切换,Esc 清空;同一会话只出现一次。

索引与性能

  • 只保留每个会话最近的消息(每条 ≤3000 字、每会话 ≤40000 字),长会话的开头不会被索引。
  • 单会话读取 20s 超时;超时的会话标记后 10 分钟再以 90s 预算重试,绝不会拖死整轮构建。
  • 构建结束把索引 gzip 到 ~/.dsh/cache/session-history-search/index.v1.json.gz(约 2.3MB,647 个会话)。
  • 下次启动先加载缓存;只有 live: true 的会话和新增会话需要重读,因此冷启动后首次搜索是秒开。
  • 缓存只在内容变化时重写(dirty 标记),并先写临时文件再 rename,避免半截文件。

样式

只使用 --dsw-alias-* 主题 token,跟随明暗主题;图标为原创 SVG(放大镜 + 时钟指针)。