dsh-exec: One-Line DSH Invocation from Terminal, with Session Synced to Desktop Sidebar

Introduction

In DeepSeek Harness (DSH), a common practice for automation is dsh --profile headless: the task completes, and the final answer can be retrieved from stdout, but the sidebar often doesn’t show this session. The reason is that headless writes valid session files, while the desktop sidebar reads the memory index of ctx.workspaceRegistry. Only sessions created via sessionController.create within the same process will attach to the workspace; modifying workspace.json externally will be overwritten by the memory copy.

If you want “one-line in, one-line out” like codex exec, while still having the session appear in the locally opened DSH desktop app where you can click to continue the conversation, and select the desktop-side Agent presets (standard / ptc / minimal / cordis), the community plugin dsh-exec (maintainer Eray114514, GitHub: Eray114514/dsh-exec) registers its control surface inside the desktop host and uses a bridge to connect the CLI and GUI.

What is this

dsh-exec is classified as a client plugin. In one sentence: invoke DeepSeek Harness from the terminal, script, or CI with a single line, and the final answer is printed to stdout, while the session updates in real-time in the desktop sidebar from the first token. It reuses your locally configured models, plugins, skills, and permissions, rather than setting up a separate isolated environment.

The cost needs to be upfront: the desktop app must remain running. If it is not started, the CLI will explicitly report that the bridge file cannot be found and will not silently downgrade to headless.

Core Features

Essential Difference from Headless

The plugin creates sessions via sessionController.create({ workspaceId, agentPreset }): the workspace row is upserted, the session attaches within the process, and the UI updates via streaming. The official dsh --profile headless uses the @deepseek-ai/dsh-headless bundle, which does not include agent-preset-registry; whereas dsh-exec creates sessions inside the desktop process, allowing it to borrow the host’s four built-in Agent presets for command-line use.

CLI Capabilities Overview

The default behavior is “pipe-friendly”: stdout only contains the final answer, and stderr is silent by default; exit code 0 on completion, 1 otherwise. Execution records and detailed traces are opt-in (--verbose, --log, etc.).

Capability Description
Specify Working Directory --cwd determines sidebar grouping
Resume Session --session ID
Preset Mode --mode standard\|ptc\|minimal\|cordis
Override Model / Permissions for Single Run --model, --provider, --effort, --permission, --approval
Long Task Input --task-file (Required for multi-line tasks on Windows)
Machine Consumption --json outputs NDJSON event stream
Operations --status / --runs / --stop RUN_ID

Four Agent Presets

The host comes with four plugin manifests, all selectable via --mode or the settings page:

Mode Suitable for
standard Most coding tasks (default)
ptc Complex multi-step; includes Code Mode SDK orchestration
minimal Benchmarking, controlling variables
cordis Writing plugins, custom presets

HTTP API and Heartbeat

The bridge service listens on the loopback address. Aside from the endpoints marked, it requires Authorization: Bearer <token> (token located at <DSH_HOME>/storages/dsh-exec.json, permissions 0600). It provides routes for status, run lists, initiating/canceling runs, NDJSON event streams, and reading/writing effective configurations. For providers like Gemini that are prone to 429 errors, the bridge sends progress frames with alive: true based on heartbeatMs (default 15 seconds) to avoid interpreting long waits as a hung process.

Default Values Design

Out-of-the-box defaults do not bind to the maintainer’s personal preferences: the model is not fixed (leaving it empty inherits the desktop app’s current model); permissions default to workspace-write, and approval to never, making it suitable for unattended scripts. Local defaults can be saved in “Settings → Command Line Execution” and written to <DSH_HOME>/plugin-data/dsh-exec/config.json.

Installation and Activation

DSH ecosystem plugins are released independently; the community directory page is skillhub.cn/plugins/Eray114514/dsh-exec, which has no official affiliation with DeepSeek or Quantum (Fangyuan). Before installing, it is recommended to check the repository source code and MIT license, and confirm that the plugin executes with the current DSH desktop process permissions.

According to the official command in the README, install under the desktop profile:

dsh plugin --profile desktop add dsh-exec

With the client side of the plugin installed, you should completely exit the App and reopen it after installation or update (hot updates showing applied do not guarantee loading on the next startup).

After installation, a “Command Line Execution” page will appear in settings. There are two names for the command-line entry: dsh-exec and dshx (the same script). If you have globally installed @why913/dshx on your machine (MCP/Skill management, non-overlapping functions), you can use dsh-exec to avoid command name conflicts.

package.json declares engines.dsh as >=0.2.0-rc.1 <0.3.0-0, and the current package version is 0.1.2; the service is only activated when the desktop profile is present.

Typical Usage

The following examples are taken from the project README and can be reproduced directly.

One-line task, result to file:

dshx "fix all lint errors in this repository"

Specify directory and preset, redirect stdout:

dshx --cwd D:/repo --mode ptc "investigate the cause of scroll flicker" > answer.txt

Get final text from program using NDJSON:

dshx --json "run tests" | jq -r 'select(.type=="final") | .text'

On Windows, cmd.exe truncates the command line at the first newline. For long prompts, it is better to write to a file and pass it:

$path = Join-Path $env:TEMP 'task.txt'
[System.IO.File]::WriteAllText($path, $task, [System.Text.UTF8Encoding]::new($false))
dshx --cwd 'D:/repo' --task-file $path

View bridge status and last host exit classification (including lastExit):

dshx --status

Suitable Scenarios and Notes

Suitable for: Local development scripts, small CI (runner and desktop on the same machine with DSH always open), hybrid workflows requiring “command line output + GUI continuation”, and scenarios where the four desktop presets are needed instead of the headless combination.

Not suitable or not covered: Pure headless servers, environments unwilling to keep the desktop App running; the plugin will remain inactive on web / headless / acp profiles. There is a memory limit for the event stream, so timely reconnection with since is required; stop is a request to cancel, and steps already in flight may still complete.

Compared to codex exec and claude -p, the difference lies not in “whether it can be invoked with a single line”, but in whether the session enters the same DSH desktop GUI and whether DSH’s Agent presets are selectable—README provides a comparison table, so it is not repeated here.

Known boundaries: APIs like sessionController are not documented plugin APIs and may change across versions; there is no headless fallback when the desktop app is closed.

Conclusion

dsh-exec binds “shell one-line execution” with “desktop real sessions”: stdout gets the final answer, and the sidebar runs from the start, reusing local configuration and the four types of Agent presets. Remember that the desktop App must be online before using it.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye