Introduction to the dsh-plugin-debugging Plugin

Preface

In DSH development, modifications to configurations, host code, or frontend assets typically require a restart to take effect. This situation—where “changes don’t reflect” or “a restart is mandatory”—often disrupts the development flow, and diagnosing the cause usually requires manual intervention. This article introduces the dsh-plugin-debugging plugin. It provides DSH agents with the capability for runtime diagnosis and in-place repair, allowing the agent to autonomously check the environment state and execute repair operations.

Plugin Overview

dsh-plugin-debugging is a plugin maintained by dsh-plugin-lab. It is designed to address runtime debugging issues in DSH plugin development, enabling the agent to self-check and self-repair the runtime environment it resides in.

Core Features

Upon installation, the agent gains access to a set of tools and skill documentation. These tools are categorized into two types: read-only diagnostics and state-changing operations:

  • dsh_list_instances
    Lists DSH hosts running on the current machine. Only detects local ports.
  • dsh_check_auth
    Distinguishes between “service not running” and “not authenticated” states.
  • dsh_diagnose_plugin_load
    Checks if plugins have been successfully loaded, including bundle members, mount forms, and loader trees.
  • dsh_check_effect_mode
    Detects the current running profile to determine whether a modification takes effect immediately, requires a restart, or needs a hot reload.
  • dsh_dump_config
    Displays the resolved configuration tree and diagnostic information for the profile.
  • dsh_sign_cookie
    Signs browser session cookies, enabling scripts or CLI clients to access the DSH instance.
  • dsh_hot_reload
    Swaps mounted entries with the latest code on disk, automatically rolling back upon failure, without requiring a restart.
  • dsh_restart
    Restarts the host when a restart is truly necessary. (Note: This feature is disabled by default).

Installation and Activation

The plugin supports installation via npm or source code.

  1. Install via npm
    Use the official plugin management command to add the plugin:
    dsh plugin --profile web add dsh-plugin-debugging
  1. Install from Source
    If you need to modify or debug the plugin source code:
    git clone https://github.com/dsh-plugin-lab/dsh-plugin-debugging.git
    cd dsh-plugin-debugging
    pnpm install && pnpm run build
    dsh plugin --profile web add "$PWD"

Prerequisites:
* Node.js version >= 20
* DSH version must satisfy the version range defined in package.json

Notes:
* Do not skip pnpm install, otherwise it may lead to missing dependencies.
* A restart of dsh --profile web is required for the changes to take effect after installation.

Typical Usage

Once installed, the agent can invoke skills via slash commands. Below are common operational scenarios:

  1. Check Effect Mode
    After modifying configurations or code, use dsh_check_effect_mode to inspect the current environment and determine whether to use hot reload or restart.
  2. Hot Reload Code
    Use dsh_hot_reload to swap code, avoiding process interruption.
  3. Force Restart
    When a restart is confirmed to be necessary, use dsh_restart (ensure this feature has been enabled).

Use Cases and Safety Boundaries

This plugin is suitable for development scenarios requiring frequent adjustments to configurations, plugin logic, or frontend assets. Please observe the following safety and behavioral boundaries when using it:

  • Permission Limits: Except for dsh_restart, no other tool restarts processes, overwrites config files, or writes content to the host data directory. The only exception is the plugin’s own namespace.
  • Default Behavior: The dsh_restart feature is disabled by default; please verify configuration before use.
  • Authentication Status: dsh_check_auth returning 401 does not always imply the session has expired. Requests without cookies will be rejected; you should verify service status in a browser.
  • Hot Reload Limitations: dsh_hot_reload may cause resource leaks (such as untracked timers or sockets).

Summary

dsh-plugin-debugging reduces the debugging overhead of DSH plugin development by providing runtime diagnostic and repair tools. It equips the agent with self-inspection and self-repair capabilities, serving as an effective means to improve development efficiency.

  • GitHub Repository: https://github.com/dsh-plugin-lab/dsh-plugin-debugging
羽毛球分组比赛记分
小程序二维码

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

Xiaoye