Testfinder

io.github.CloudCorpRecords由 GitHub 账号 CloudCorpRecords 发布v0.1.0更新于 Nov 3, 2026

从导入映射中查找与某个源文件相关的测试,按排名排列,并附上运行命令。

AI 翻译由 AI 模型根据下方的原文描述翻译,可能有误。

原文描述

Find the tests relevant to a source file from an import map, ranked, with the run command.

已验证STDIO仅桌面

概览

Testfinder 的本地 MCP 服务;无需登录;STDIO。

暂无 AI 概览:以下信息来自注册中心条目和服务本身。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Testfinder,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

testfinder

Running the whole test suite after every small edit is a slow loop. testfinder narrows it: give it one source file plus the project's file/import map — every file's path and the paths it imports — and it works out which tests are actually relevant to that file, why each one is relevant, and the exact command that runs just those tests:

  • Direct importers — test files that import the source file themselves, at distance 1.
  • Naming-convention matches — test files whose path is the source path with .test or .spec inserted before the final extension, either beside the source (src/foo.ts → src/foo.test.ts) or in the __tests__ form (src/__tests__/foo.test.ts). A source whose name has no extension gets the suffix appended instead (src/foo → src/foo.test).
  • Transitive importers — test files that reach the source through other files, each at its shortest import distance, so a diamond in the graph resolves to the shorter route.

Every relevant test carries exactly one reason, decided by precedence: self (the source file is itself a test) over direct over convention over transitive. Results are ranked by that reason order, then by distance, then by path, and run_command is the npx tsx --test line that runs them in ranked order — or null when nothing is relevant. The result also reports total_files and test_files_considered, the count of test files in the set whether relevant or not. A file counts as a test when its name carries .test. / .spec. (or ends in .test / .spec), or when it lives under a test, tests, or __tests__ directory.

Imports that name paths outside the supplied set are external: they are ignored, never followed, and never an error. Duplicate import entries are de-duplicated and a file importing itself is ignored for graph purposes, though distances still flow through ordinary non-test files on the way to a test. Malformed input — a missing or unknown source_file, an empty file set, a duplicate file path, a wrongly typed field — is a validation error naming the offending path (for example files[1].imports[0] must be a string), and no partial result is produced. The computation is pure and local, and the tool only finds tests: running them, with the command it returns, is left to your own environment.

CLI

bash
npx @reneturcios/testfinder find --input args.jsonnpx @reneturcios/testfinder --version

args.json contains the full arguments object:

json
{  "source_file": "src/foo.ts",  "files": [    { "path": "src/foo.ts" },    { "path": "src/bar.ts", "imports": ["src/foo.ts"] },    { "path": "src/foo.test.ts" },    { "path": "src/bar.test.ts", "imports": ["src/bar.ts", "react"] }  ]}

imports defaults to [] per file; here react is external to the set and ignored. src/foo.test.ts is a naming-convention match with no import of its own, and src/bar.test.ts reaches the source through src/bar.ts at distance 2. The result is printed as JSON:

json
{  "source_file": "src/foo.ts",  "relevant_tests": [    { "path": "src/foo.test.ts", "reason": "convention", "distance": null },    { "path": "src/bar.test.ts", "reason": "transitive", "distance": 2 }  ],  "total_files": 4,  "test_files_considered": 2,  "run_command": "npx tsx --test src/foo.test.ts src/bar.test.ts"}

Exit codes: 0 on success, 1 on a runtime error (including an unreadable or invalid input file, or invalid input), 2 on a usage error.

MCP server

bash
npx -y @reneturcios/testfinder mcp

MCP client config:

json
{  "mcpServers": {    "testfinder": {      "command": "npx",      "args": ["-y", "@reneturcios/testfinder", "mcp"]    }  }}

Tools

  • find_relevant_tests — Find the tests relevant to one source file from a file/import map.

    • source_file (string, required) — path of the source file; must be one of the supplied files
    • files (array, required, at least one) — files as {path, imports?} objects; path is unique across the set, and each imports entry either names another supplied file or anything else (external, ignored)

    Returns {source_file, relevant_tests, total_files, test_files_considered, run_command}, where each entry of relevant_tests is {path, reason, distance}.

Docker

bash
docker run -i ghcr.io/cloudcorprecords/testfinderdocker run --rm -v "$PWD:/w" ghcr.io/cloudcorprecords/testfinder find --input /w/args.json

Development

bash
npm installnpm run build   # tsc -> dist/npm test        # tsx --test test/*.test.ts (pure local, no network)npm run dev     # run the CLI from source

License

MIT — Copyright (c) 2026 Rene Turcios

来源:README.md,提交 5419b88

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.0最新Nov 3, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分