Preface¶
The DeepSeek Harness (DSH) ecosystem emphasizes “everything is a plugin.” In development scenarios, an Agent needs context to perform actions. If the context consists only of conversation history, the Agent often struggles to accurately locate the code fragment the user is currently focused on. The dsh-editor-selection plugin solves this problem: instead of sending file content, it captures the editor’s primary selection (absolute path + line range) and injects an environment notice before each Agent step, letting the Agent clearly know the user’s current operational focus.
Feature Overview¶
The plugin is maintained by yingzaicc and uses the MIT license. Core capabilities include:
- Selection capture: Captures the primary selection’s absolute path + line range (1-based).
- Environment notice: Injects a one-line environment notice (such as
@absolute-path:10-25) before each Agent step, instead of stuffing file content into the context. - Pairing and approval: The DSH sidebar provides pairing approval and supports device revocation.
- Privacy control: An environment chip below the input box includes an “eye” toggle for pausing or resuming sharing.
- Interaction enhancement: Supports “focus on selection”, “right-click to explain code”, and multi-window support.
Installation and Enablement¶
Installation is performed via a PowerShell script. After completion, restart DSH Web to apply the configuration.
powershell -ExecutionPolicy Bypass -File scripts\install.ps1
Core Mechanisms and Usage¶
The plugin communicates with DSH over WebSocket. The architecture consists of the VS Code extension side and the browser side (DSH Web).
1. Focus on Selection¶
When you select code in the editor, the plugin captures the selection. DSH automatically starts explaining that code segment in the most recently active session, without manual input required.
The selection is injected as an environment notice:
* Real selection exists: Injects @absolute-path:start-end.
* Cursor is placed with no selection: Injects @absolute-path (the entire file is the focus).
* Cursor is not inside any file: The focus is cleared.
If the buffer is not saved, it is annotated with “(buffer not saved)” after the path.
2. Environment Notice and Explanation¶
After the selection is sent to DSH, the Agent receives a message containing path information. This protocol is independent of client type; currently, VS Code is the first client to integrate.
3. Privacy Control¶
There is an “eye” toggle on the environment chip below the input box:
* Off: Pause sharing. The plugin injects a one-time “paused” notice to the Agent, and the Agent remains silent.
* On: Resume sharing.
4. Right-Click Explanation¶
After selecting code in the VS Code editor, click “Explain Code” in the right-click menu. The selection is sent to DSH and triggers automatic explanation.
Security and Permissions¶
The plugin follows locality and least-privilege principles:
- Communication: All communication goes through the local loopback and does not involve any cloud service.
- Authentication: Pairing requests have a 60s TTL; requests with the same instanceId are deduplicated.
- Data: Tokens are stored only as SHA-256 hashes; plaintext is not stored.
- Permissions: Path readability is decided by the DSH permission system at read time, and the plugin does not impose a workspace mapping gate. Files outside the workspace request access through the existing DSH permission flow when the Agent reads them.
- Close codes: The close semantics include 4401 (unauthorized), 4403 (pairing expired or rejected), and 4408 (rate limited, 20 frames/s).
Configuration and Troubleshooting¶
The plugin provides two escape hatch configuration items:
- Master switch: Set
dshEditorSelection.enabled=falsein the DSH configuration to completely disable it. - Relocate state directory: Relocate the state directory via the environment variable
DSH_EDITORSEL_ROOT.
Summary¶
By converting editor selections into structured environment notices, the dsh-editor-selection plugin achieves precise alignment between the Agent and the user’s code actions. It does not modify file content and only transfers path context via the protocol. Combined with local loopback and hash storage, it improves development efficiency while maintaining a high level of security.
- GitHub repository: https://github.com/yingzaicc/dsh-editor-selection
- Directory page: https://www.skillhub.cn/plugins/yingzaicc/dsh-editor-selection