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-test-impact

v0.1.0

Published

Explainable test impact analysis for Python/pytest repositories: map a code change to the tests that statically depend on it, show the dependency path, and say when the analysis is not trustworthy enough to narrow the run.

Readme

dsh-test-impact

English

Python/pytest 项目的静态测试影响分析工具,提供 DeepSeek Harness 插件和独立 CLI。

输入改动文件后,分析器沿反向导入依赖查找相关测试,返回依赖路径、未解析项和扩大验证范围的建议。它不执行被分析项目的代码或测试。推荐列表用于安排验证顺序,不能证明其他测试可以跳过。

环境要求

  • Node.js 24.9 以上
  • Python 3.11 以上
  • Git:用于工作区或版本比较;显式文件列表不依赖 Git

核心仅使用 Python 标准库。解释器依次尝试插件设置 pythonPath、DSH_TEST_IMPACT_PYTHON、python3、Windows 的 py -3、python。自动发现失败时可明确指定解释器。Python 使用隔离模式,禁用 site 启动定制。

安装

在 DSH 的 插件 → 添加插件 中填写:

https://github.com/DengyiGu/dsh-test-impact

或安装指定版本:

dsh plugin --profile web add github:DengyiGu/dsh-test-impact#v0.1.0

独立 CLI:

npm install -g github:DengyiGu/dsh-test-impact#v0.1.0
dsh-test-impact --help

Releases 提供 .tgz。无需编译或执行安装脚本。仅通过包名安装需要另行发布 npm。

DSH 工具

test_impact({ repo: 'C:/work/project', changed: ['src/app/core.py'], depth: 6 })
dep_graph({ repo: 'C:/work/project', module: 'app.core', direction: 'dependents', depth: 3 })

test_impact 支持 repo、可选的 base 或 changed、depth、maxFiles、maxSeconds。省略 base 和 changed 时,与 HEAD 比较当前工作区。显式空 changed 数组表示没有改动,不调用 Git。

dep_graph 接受模块名或相对 Python 路径,direction 为 dependencies 或 dependents。每条边包含导入所在的文件和行号。

插件设置包含 pythonPath、timeoutMs(默认 120000)、maxFiles、maxSeconds(后两者为 0 时使用项目默认值)。

CLI

dsh-test-impact analyze --repo /path/to/repo --json
dsh-test-impact analyze --repo /path/to/repo --base main --json
dsh-test-impact analyze --repo /path/to/repo --changed app/core.py
dsh-test-impact graph app.core --repo /path/to/repo --reverse
dsh-test-impact doctor --repo /path/to/repo --json

源码目录中可将命令替换为 node bin/dsh-test-impact.mjs 或 python python/launch.py。

默认包含暂存、未暂存和未跟踪改动。--base 比较指定提交与当前文件树,并包含未跟踪文件。请传入 Git 仓库根目录。删除、重命名会触发扩大验证,不会完整重建历史依赖图。

退出码:0 分析完成,1 参数或处理错误,2 分析不完整,3 Git 仓库或版本错误。退出码 0 不表示改动一定安全。

输出

  • recommended:推荐测试、证据类型和依赖链。
  • widening:需要扩大验证的范围和原因。
  • unassociated:未发现静态测试关联的改动,不代表没有测试。
  • unresolved:未解析的导入或运行时行为。
  • analysis.complete:扫描及解析是否在支持范围和限制内完成。

推荐依据包括直接/传递导入、测试本身改动、pytest 目录作用范围和配置变化。命名提示单独列出。有改动且存在动态导入、未解析依赖或 pytest hook 时,建议验证完整配置范围,包含跨包情况。包初始化、非 Python 输入、删除、重命名及无效配置也会扩大验证。

配置

读取 pytest.ini、pyproject.toml、tox.ini 或 setup.cfg 的测试发现配置,支持 testpaths、python_files、norecursedirs。不能静态支持的收集选项会报告。

项目选项写入 pyproject.toml:

[tool.test-impact]
source_roots = ["src", "."]
test_roots = ["tests"]
extra_paths = ["vendor"]
always_run = ["tests/test_smoke.py"]
max_files = 20000
max_seconds = 60

默认排除常见虚拟环境、缓存和构建目录。跳过文件/目录链接并标记扫描不完整,拒绝显式传入的仓库外路径。

磁盘缓存默认关闭,使用 --cache-dir /path/to/cache 显式开启,--no-cache 可在本次调用禁用。缓存仅保存解析事实,通过内容哈希和配置判定失效。清理命令为 dsh-test-impact cache --repo /path/to/repo --cache-dir /path/to/cache。小型仓库启用缓存可能更慢。

开发与验证

npm run verify
npm run integration
npm run perf
npm pack

测试使用本项目创建的仓库。集成检查注入已知改动,对照真实 pytest 失败;性能检查使用生成的文件树并比较缓存结果。这些检查不能证明任意仓库都不会漏选。

发布检查通过 83 项 Python 测试、11 项 Node 测试。三个集成场景中,没有失败项落在推荐和扩大验证建议之外;一个动态导入失败依靠扩大验证覆盖。501 文件样例无缓存扫描中位数约 203ms,暖缓存约 210ms,耗时依赖机器。

打包后的适配层已在真实 Cordis/ToolsService 注册器中直接注册、调用并校验输出 Schema;systemPrompt 使用最小回调接收器。完整 DSH 应用启动与对话驱动调用尚未验证。

限制

任意动态加载、原生代码、环境变化及外部数据依赖无法仅凭 Python 导入完整推断。部分 pytest 收集行为和 namespace 布局不支持。大型依赖图或歧义可能导致建议范围较宽。插件不执行测试、不改源码,磁盘缓存只在显式请求时写入。

许可

MIT。