dsh-test-runner
DSH plugin: structured test runner tool (test_run) — auto-detect vitest/jest/pytest/node:test, run tests, parse failure summaries for the model.
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:suimi8/dsh-test-runner说明文档
阅读完整 README ↗dsh-test-runner
DeepSeek Harness 插件:结构化测试运行工具 test_run。
让 agent 用一次工具调用完成「改代码 → 跑测试 → 修」闭环:自动探测测试框架、执行测试、只返回结构化摘要(通过/失败统计 + 失败用例名称与错误信息 + 输出尾部),避免模型阅读整段原始测试输出(省 token、少一轮)。
功能
| 能力 | 说明 |
|---|---|
| 框架自动探测 | package.json 的 vitest/jest 依赖 → vitest/jest;scripts.test → npm-test;pyproject.toml/pytest.ini/conftest.py → pytest;test/ 目录或 *.test.* 文件 → node(node:test) |
| 目标过滤 | target 指定文件/目录/用例模式(如 tests/test_api.py::test_login),多个目标空格分隔 |
| 失败摘要 | 每个失败用例提取名称 + 错误信息(vitest ×/→、jest ●、pytest FAILED、node:test TAP not ok + error: 块) |
| 只重跑失败 | last_failed → vitest --lastFailed / jest --onlyFailures / pytest --lf |
| 自定义命令 | command 完全覆盖默认命令(如 pnpm vitest run、python -m pytest -x -q) |
| 超时与取消 | timeout_ms 默认 120s;工具取消信号转发给子进程 |
| 沙箱合规 | 按调用会话解析 sandboxPolicy(会话覆盖 > 部署默认),与 bash 工具同一策略 |
安装
dsh plugin --profile web add ./dsh-test-runner # 本地目录
# 或从 GitHub(需要 prepare 脚本 + allowBuilds 放行)
dsh plugin --profile web add github:you/dsh-test-runner
重启 dsh --profile web 后生效。管理面板:设置 → 插件。
使用示例
模型侧直接调用:
test_run(自动探测,跑全部)test_run(target="src/utils.test.ts")(跑单文件)test_run(framework="pytest", target="tests/test_api.py::test_login")test_run(last_failed=true)(只重跑上次失败)test_run(command="pnpm vitest run --coverage")
返回结构:
{
"ok": false,
"framework": "node",
"command": "node --test",
"exitCode": 1,
"durationMs": 800,
"summary": { "total": 6, "passed": 5, "failed": 1, "skipped": 0 },
"failures": [
{ "name": "string: broken case (intentional failure)",
"message": "Expected values to be strictly equal: | 'WORLD' !== 'WRLD' | ..." }
],
"outputTail": ""
}