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-tool-router

v0.1.0

Published

DSH Tool Router — deterministically shrink model-visible tool schemas per step with a safe fallback

Readme

dsh-tool-router

DSH Tool Router — 每个 Agent step 动态缩小模型可见的工具 schema,同时保留安全 fallback。

自带 benchmark 里 33 条 prompt 跑下来,工具 schema 从 15609 token 降到 4006,省了 74.3%。 数字可以自己复现:npm run benchmark。

它不是权限系统,不删除工具,也不让任何工具“永久不可用”。它只做一件事:

这一轮只向模型展示大概率相关的工具集合;如果猜错,模型可以用 request_tools 把需要的类别加回来。

现状

  • 默认 observe:不改任何工具,只记录“如果路由会保留什么”。
  • 本地统计写入 ~/.dsh/dsh-tool-router/stats.json。
  • 无外部依赖、无 LLM 二次调用、无网络。

官方 seam

DSH 本身提供了 per-step tool assembly 的官方扩展点:

  • system-prompt/assemble waterfall:每个 step 的 assembly.tools 可以在这里被过滤。
  • agent/inbox/claimed:在组装前捕获当前用户 prompt。
  • agent/pre-step / agent/request:后续 dsh-model-router 会用到的官方模型路由 seam。

实现没有 monkey patch,也不改 DSH 源码。

一个已知缺口:ToolSchema 没有 tool 的注册来源(source)字段,因此分类使用 name / description / parameters + 内置已知工具名映射来推断。

安装

dsh plugin add dsh-tool-router

装完默认是 observe,不改任何工具,只记录“如果真的路由会省下多少”。 看几天统计觉得靠谱,再把 mode 调成 adaptive。

配置

插件配置使用 schemastery schema,字段:

mode: observe            # off | observe | suggest | adaptive
alwaysVisible: []        # 用户额外配置的始终可见工具名
minimumSafeTools:        # 最小安全集,缺省如下
  - bash
  - read
  - search
fallbackToolName: request_tools
fallbackTtlSteps: 3
storePromptPreview: true
suggestPromptSection: true

Modes

| mode | 行为 | | --- | --- | | off | 完全不路由 | | observe | 不改变任何工具,只记录统计 | | suggest | 不过滤,但向 system prompt 加一行轻量建议 | | adaptive | 真正过滤工具可见集,并启用 request_tools fallback |

Fallback

adaptive 模式下模型看到 request_tools 工具,可以请求:

{ "enable": ["web", "database"] }

下一步会在 system-prompt/assemble 里把对应类别加回。TTL 默认 3 步,防呆。

分类

内置 13 类:

filesystem / search / shell / git / lsp / web / browser / database / mcp / image / workflow / subagent / misc

安全边界

  • 只缩小 assembly.tools。
  • 不碰 permissions / sandbox / guards / approval。
  • run_code(Code Mode 保留 transport)永远不会被隐藏。
  • 无路由信号时 fail-open,保留全部工具,避免猜错直接无解。

统计

~/.dsh/dsh-tool-router/stats.json 记录:

  • prompt category
  • selected / requested / enabled categories
  • actual tools used
  • unused visible tools
  • before / after / saved schema bytes(token 为估算)

开发

pnpm install
pnpm typecheck
pnpm build
pnpm test
pnpm benchmark

Core benchmark 使用 33 条 synthetic + real prompts,结果见 pnpm benchmark 输出。