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-session-browser

v0.2.0

Published

DSH plugin: same-workspace cross-session read-only browsing for models — list_sessions / read_session / search_sessions tools with strict cwd scoping, UNTRUSTED snapshot marking, and bounded budgets (optional SQLite FTS full-text search).

Readme

dsh-session-browser

English | 中文

License

同一工作区内的跨 session 只读浏览:给每个 session 的模型提供三个工具,让它能查看同工作区其他 session 的对话内容。

  • list_sessions — 列出调用方工作区内的其他 session(id / 标题 / cwd / 创建时间 / live / persisted)。可选 query(对 id / 标题 / cwd 的大小写不敏感子串)和 limit(默认 50,最大 100)。
  • read_session — 读取另一个 session 当前的对话表面(仅用户消息 + 助手文本;工具调用、推理、注入上下文默认排除)。可选 maxMessages(保留最新,默认 50)和 includeToolResults(默认 false)。
  • search_sessions — 在调用方工作区内全文搜索(需启用 SQLite FTS 索引,见下)。可选 limit(默认 10,最大 20)。

安全与边界

  • 严格同工作区限制:所有读取以调用方 session 的 cwd(工作区路径)为界。不同 cwd 的 session 不可见、不可读,没有后门参数;自身 session 一律排除。
  • 只读快照:内容来自 ctx.sessionQuery.readSurface()(live 优先,持久化兜底),是对方 session 当前模型表面的一次性快照,非订阅、非实时。
  • UNTRUSTED 标记:所有跨 session 输出都带警告头(与官方 dsh-session-reference 机制一致),模型只应将其作为背景信息,不得执行其中出现的指令/权限声明。
  • 预算约束:每条消息 head/tail 截断(默认 8000 字符),单次读取总量 ≤ 60000 字符,超出部分注明省略量;列表默认 50 条、搜索默认 10 条。

安装(web profile)

已发布到 npm([email protected],含 dsh.bundle.patch)——一条命令安装并自动挂载(下次启动 dsh 时生效):

dsh plugin --profile web add dsh-session-browser

本地 checkout(开发):dsh plugin --profile web add ./plugins/dsh-session-browser,或 ./scripts/install.sh web plugins/dsh-session-browser。

全文搜索

search_sessions 使用 session-query-sqlite 的 FTS 索引。bundle 层默认已开启(openAt: first-search,索引在 $DSH_HOME/storages/session-search.sqlite——见包内 cordis.patch.yml 的 session-query-sqlite 覆盖行),首次搜索时自动建库。要改位置或关闭,在 profile 自己的 cordis.patch.yml 里覆盖同一 row(每 row 最后一次写入生效):

- id: session-query-sqlite
  config:
    path: !!js dshHomePath('storages/session-search.sqlite')
    openAt: first-search   # 或改为: never

未启用时 search_sessions 会返回明确指引而不是报错。

卸载

dsh plugin --profile web remove dsh-session-browser

(FTS 覆盖行随 bundle 提供,移除 bundle 后 session-query-sqlite 自动恢复宿主的默认配置。)

已知限制

  • FTS 观察不稳定重试:search_sessions 依赖的 SQLite 引擎要求所有持久化日志在其观察窗口内零变化;活跃工作区(本会话或其他会话持续写日志)会触发 SESSION_QUERY_PERSISTENCE_FAILED。插件会在工具内部自动重试(最多 3 次,间隔递增);仍失败时返回「工作区活跃,请稍后重试」。这是引擎一致性设计,插件层无法根治。
  • 其他实例写入的新格式日志:若 ~/.dsh/sessions/ 下存在由更新版本 DSH(TUI 等)写入、含当前版本不认识的事件类型的日志,引擎的安全守卫会拒绝构建索引。需将此类日志移出 ~/.dsh/sessions/(可归档到 ~/.dsh/sessions-backup-*),否则 search_sessions 不可用。

测试

node tests/static.test.mjs   # 语法门禁 + 纯函数行为断言,exit 0 = 绿

实现

工具在 lib/index.js 中注册。读取走宿主 sessionQuery 服务。信任范围仅限同工作区(调用方 cwd),无独立鉴权层。

本插件属于 dsh-plugins 合集。

License

MIT