bujue600-arch/dsh-testgen3

dsh-testgen

Automated unit-test generation for DeepSeek Harness: a /testgen command and generate_tests tool that scaffold, run, and fix tests until they pass.

AI 分析

核心用途是实现代码单元测试的闭环自动生成与纠错。适合需要快速为现有代码补齐单测的开发者。要求 Node >= 22,支持 Jest、Vitest 等主流测试框架。

パッケージ
dsh-testgen
バージョン
1.0.0
ライセンス
MIT
最終更新
2026/08/14

インストール

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:bujue600-arch/dsh-testgen

ドキュメント

README 全文を読む ↗

Usage

Slash command

/testgen [options]  [more targets…]

Options:
  --runner   framework (default: auto)
  --generator               generator (default: auto)
  --iterations                              fix-loop bound (default: 3)
  --model 
                     generation model override
  --no-run                                     generate only, do not run
  --json                                       machine-readable report
  -h, --help                                   show this help
/testgen src/utils/math.ts
/testgen --runner vitest "src/**/*.ts"
/testgen --generator template --no-run src/app.ts
/testgen --model deepseek-official/deepseek-chat src/parser.ts

Model tool

The agent can call it directly — same pipeline, structured result:

generate_tests({ target: "src/utils/math.ts", runner: "vitest", maxIterations: 3 })

What gets written

For src/utils/math.ts, tests land in src/utils/__tests__/math.test.ts (framework-dependent; node:test uses .test.mts). Existing test files are never overwritten — a target that already has a test file is skipped with a warning.

Configuration

All settings live under the testgen: key of your harness settings document ($DSH_HOME/settings.yaml) and are hot-reloaded — edit, save, done. Layering: schema defaults → composition entry (cordis.patch.yml) → your settings section.

testgen:
  runner: auto            # auto | vitest | jest | node-test | mocha
  generator: auto         # auto | llm | template
  maxIterations: 3        # generate → run → fix loop bound (0 disables fixing)
  timeoutSec: 120         # per-run wall-clock timeout
  autoRun: true           # run the suite after generation
  includeGlobs:
    - '**/*.{ts,tsx,js,jsx}'
  excludeGlobs:
    - '**/node_modules/**'
    - '**/dist/**'
    - '**/*.test.*'
    - '**/*.spec.*'
    - '**/__tests__/**'
  testDir: __tests__      # generated tests land here, next to the target
  model:                  # optional provider/model override
    provider: deepseek-official
    model: deepseek-chat
  maxSourceChars: 60000   # source characters fed to the LLM per target

You can also override any of these per profile by patching the testgen row in the profile's cordis.patch.yml (a patch replaces the row's whole config). See docs/config.md for the full reference.