dsh-plugin-genshin-launch: Zero-config Detection and Auto-start for Genshin Impact

Preface

DeepSeek Harness (DSH) is an agent development platform where developers often need to conduct testing or demonstrations using game scenarios. Manually searching for the game binary path or launcher installer disrupts the workflow. The dsh-plugin-genshin-launch plugin employs a zero-configuration detection mechanism to solve the problem of “detecting local Genshin Impact installation status when opening DSH.”

Core Features

The plugin primarily provides two automation schemes:

  1. Scheme 2: Launch Genshin upon opening DSH

    • Zero-config Detection: The detection order is config → registry → paths → scan. The fastest tier takes about 400ms, and the entire fast track takes approximately 0.5 seconds.
    • Trigger Timing: When the browser interface is rendered (based on patchReload: live), rather than when the host process starts.
    • Launch Strategy: Detection results are classified into three states: ready (binary exists), incomplete (installing/updating), and Not Found. If ready, launch the binary directly; if incomplete, launch the HoYoVerse Launcher; if Not Found, proceed to Scheme 1.
    • Process Control: Launches occur only once per DSH process; refreshing the page or hot reloading will not trigger repeated launches.
  2. Scheme 1: Download installer to Desktop if not installed

    • Auto Download: If the game is not detected, download the HoYoVerse Launcher installer to the Desktop.
    • Size Safety Gate: The installer is approximately 224 MiB. The download validates the file size; if the deviation exceeds 15 MiB (default value), the download is rejected to prevent downloading incorrect files by mistake.
    • Resumable Download: Supports breakpoint continuation.

Detection Mechanism

The detection process is entirely local and read-only, requiring no network connection. It employs a five-tier ladder strategy, stopping upon a match:

  1. config: Reads gameExe or gamePath from the configuration file (highest priority).
  2. registry: Reads the HoYoPlay HYP tree (e.g., HYP\1_1\hk4e_cn), calibrating encoding before searching for the path.
  3. paths: Iterates through common top-level directories (e.g., drive root directories).
  4. scan: Executes only if all previous tiers are empty. Performs a full scan of uninstall records (3 roots × 4 key names) and a bounded directory scan (default depth ≤ 4).

State Determination:
* ready: YuanShen.exe or GenshinImpact.exe exists.
* incomplete: Structural fingerprints such as YuanShen_Data, pkg_version, or mhypbase.dll exist.
* Not Found: None of the above conditions are met.

Installation & Configuration

Installing the plugin requires a pnpm environment and network access to GitHub.

Installation Command:

dsh plugin --profile web add github:Link258QAQ/dsh-plugin-genshin-launch

Configuration Example:
Add configuration to $DSH_HOME/profiles/web/cordis.patch.yml:

- id: genshin-launch
  name: dsh-plugin-genshin-launch
  config:
    launchGame: true
    launchTrigger: gui
    launchMethod: spawn
    retryShellOnElevation: true
    launchWatchMs: 3000
    fallbackToLauncher: true
    launchOncePerSession: true
    detectSources: ['config', 'registry', 'paths', 'scan']
    download: true
    downloadDir: 'C:\Users\You\Desktop'
    expectedInstallerBytes: 234881024
    sizeToleranceBytes: 52428800

Notes:
* Windows Only: Detection relies on the registry, DPAPI encryption, and UAC elevation mechanisms.
* Permission Prompts: The plugin does not silently elevate privileges. If the game or launcher manifest requires admin rights, spawn mode will fail with EACCES. In this case, the plugin automatically falls back to shell mode (double-click semantics), triggering a system UAC request.
* Privacy Protection: When launching the game, environment variables containing keywords like *KEY* or *PASSWORD* are stripped; paths are masked or stored via DPAPI encryption in logs and configuration.

Self-check & Debugging

The plugin includes a self-check tool that does not depend on DSH, used to verify the detection and launch chain:

# Detection-only mode
node tools/selfcheck.mjs

# Verify launch chain (specify program, auto cleanup)
node tools/selfcheck.mjs --exe "D:\path\to\YuanShen.exe" --launch --kill
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye