Introduction¶
DeepSeek Harness (DSH) follows the principle of “everything is a plugin.” When developing agent applications, testing WeChat Mini Programs requires driving an actual runtime environment. Traditional UI testing can be sensitive to environment changes, and pure text models often struggle to determine screen state accurately. The dsh-mp-automator plugin uses mechanisms such as selector addressing, build freshness gates, and geometry assertions to provide agents with a discipline layer, ensuring the accuracy and reliability of test actions.
Prerequisites¶
Before using this plugin, make sure the following environment requirements are met:
- Operating system: macOS only.
- WeChat Developer Tools: Enable the service port in settings (Path: Settings → Security Settings).
- Dependency versions:
- Node.js >= 20
- dsh >= 0.1.0-rc.5
- vince-mp-cli >= 0.2.0 < 0.3.0
Installation¶
Run the following command in your terminal to install the plugin into your dsh profile:
dsh plugin --profile web add dsh-mp-automator
After installation, start a dsh session inside a WeChat Mini Program project directory (the directory containing project.config.json).
Core Capabilities¶
This plugin provides eight mp_* tools for driving a running Mini Program in a real runtime environment:
mp_session: Maintains a persistent DevTools session and supports operations such as restart and reconnection.mp_doctor: Performs project health checks, including CLI checks and build output freshness.mp_inspect: Retrieves the page stack, data, element fact table, system information, and more.mp_query: Uses selector addressing and returns a geometry fact table (fully visible, partially visible, invisible, etc.).mp_act: Performs actions such as click, input, long press, navigation, camera-free QR code scanning, and so on.mp_screenshot: Saves a screenshot to disk and generates a geometry fact table. Visual routing additionally returns the actual screenshot.mp_console: Retrieves error logs and the latest logs.mp_eval: Executes JavaScript code in the page VM.
Key Mechanisms¶
To address common silent failure issues in agent testing, the plugin includes the following mechanisms:
- Selector addressing: Element UIDs can change after reconnection or page navigation. The plugin enforces the use of selectors as operation handles to prevent interacting with the wrong element.
- Build freshness gate: Before each execution, the plugin checks whether build output is up to date, preventing tests from running against stale code.
- Fail-closed mechanism: Only
ok === trueis treated as success. Any parsing error or failed check causes the test to fail, preventing misleading green results. - Dual-path screenshots:
- Geometry fact table: Available to all models, including element coordinates and visibility flags.
- Actual screenshot: Returned additionally by visual routing as a real PNG image, allowing pure text models to perform geometry assertions.
Configuration¶
Add the following configuration to cordis.patch.yml in your dsh profile:
- id: mp-automator
config:
freshnessMode: block # block(默认) | warn | off
enableEval: true # mp_eval 开关
imageBudget: 3 # 视觉路由每会话最多附加截图数
screenshotDir: captures # 截图落盘目录
binPath: vince-mp # CLI 可执行文件路径
| Configuration Item | Default Value | Description |
|---|---|---|
freshnessMode |
block |
Whether to block execution or only warn when build output is stale |
enableEval |
true |
Whether to allow using mp_eval to execute JS |
imageBudget |
3 |
Image budget for visual routing. 0 fully disables attached images |
screenshotDir |
captures |
Relative path where screenshots are saved |
binPath |
vince-mp |
Path to the vince-mp CLI |
Typical Usage¶
- Testing page navigation: Use
mp_queryto confirm that a button is visible, usemp_actto click it, then usemp_queryto verify elements on the new page, and finally usemp_consoleto confirm there are no errors. - Camera-free QR code scanning: Use the camera-free
scaninjection capability ofmp_actto simulate QR code scanning. - Geometry assertions: In a pure text model, use the geometry fact table returned by
mp_screenshot(such as thefully-visibleflag) to determine whether an element exists, rather than relying on text recognition.
Notes¶
- Byte limits: All tool output is constrained by a byte limit, keeping long test sessions readable even after context compression.
- Native overlays: Native overlays such as
wx.showLoadingdo not appear in screenshots, so they should not be asserted based on screenshots. - Version window: The dependency
vince-mp-climust be within>=0.2.0 <0.3.0; otherwise, execution is rejected and an upgrade suggestion is shown.
Summary¶
dsh-mp-automator enables agents to safely and reliably drive WeChat Mini Programs for automated testing through a structured toolset and strict gating mechanisms. It embeds test discipline inside the tools themselves rather than relying on natural language instructions from the model, making it a necessary component for building highly reliable Mini Program testing workflows.