Introduction¶
When operating interactive terminal programs with agents in DeepSeek Harness (DSH), the common approach is to read the raw byte stream of escape sequences from the PTY output. Programs like vim, htop, lazygit, less, and various installation wizard TUIs constantly refresh the screen. For models, this raw byte stream is difficult to interpret stably to “understand the current interface,” and keystrokes are prone to being sent in bursts before the interface is ready, resulting in blind operations.
The following introduces the community plugin dsh-terminal-vision (maintained by fdfdfdfgbfdgfdg-star). It continuously parses each persistent PTY session into a structured screen model (visible text lines, cursor position, active line) using @xterm/headless, and then registers a set of terminal_* tools with DSH. This allows agents to drive TUIs using a “read screen → send keys → read screen” loop, rather than wrestling with raw byte streams. The plugin is categorized as a client and can be found in the SkillHub directory. In the ecosystem, DSH emphasizes “everything is a plugin”; this directory is an independent community site and has no official affiliation with DeepSeek or 幻方.
What is this¶
dsh-terminal-vision is a terminal semantic vision plugin for DSH: it manages persistent sessions with node-pty on the host side and builds a screen model within Node using @xterm/headless (Variant A in the README). It requires no Python, no long-running bridge processes, and can work offline. The license is MIT (see the repository’s package.json); the version number in current materials is 0.1.0. The runtime environment requires Node.js >= 22.19 (consistent with the DSH host).
Tools Registered with DSH¶
The plugin registers 6 tools with ctx.tools in Cordis’s apply(ctx), with names and purposes as follows (consistent with the README):
| Tool | Function |
|---|---|
terminal_open(session_name, shell?, cwd?, cols?, rows?) |
Opens a persistent PTY and returns a session_id; shell can be bash / pwsh / cmd, or a TUI program name directly (e.g., htop, vim file.txt). |
terminal_get_screen(session_id) |
Returns a structured screen: lines[], cursor {x, y}, active_line, and terminal title. |
terminal_send_keys(session_id, keys, wait_ms?) |
Sends a key sequence, waits approximately 500 ms by default until the screen revision changes (ready waiting), and then returns the new screen; supports plain text, Enter / Esc / arrow keys, Ctrl+C, Alt+b, and space-separated sequences (e.g., ":wq Enter"). |
terminal_read_output(session_id, lines?) |
Reads the last N lines from the scrollback area above the viewport. |
terminal_close(session_id) |
Closes the session and releases the PTY. |
terminal_list_sessions() |
Lists active sessions’ id, name, shell, cwd, and survival status. |
If the session_id is unknown, the tools return an explicit error rather than crashing the host; all return values are JSON-serializable objects.
Architecture Highlights¶
- Host Side (TypeScript,
src/): A Cordis plugin that manages sessions using node-pty; on Windows, it uses a pre-compiled ConPTY binary, and the README states no local compiler is needed. - Semantic Parsing (
src/screen-model.ts): PTY output is written into a headless xtermTerminal, and text lines are read frombuffer.activeas needed; keystrokes are converted to terminal bytes viaencodeKeys(). - Packaging & Integration: The package declares
dsh.bundle.patch(cordis.patch.yml), which automatically writes to the profile when executingdsh plugin add, eliminating the need to manually modify patch files.
Compiled artifacts lib/ are committed to the repository, so a standard installation does not require a local npm run build; the package deliberately avoids setting a prepare script to prevent issues with pnpm blocking prepare scripts for git dependencies.
Installation and Activation¶
Given that the DSH CLI is already installed, you can install from GitHub to the web profile using the command from the README:
dsh plugin --profile web add github:fdfdfdfgbfdgfdg-star/dsh-terminal-vision
If you have already cloned the plugin directory locally, you can also use:
dsh plugin --profile web add file:./dsh-terminal-vision
Windows Note: pnpm may ignore installation scripts for native modules by default. If add fails with ERR_PNPM_IGNORED_BUILDS: node-pty, manually rebuild node-pty in the profile directory (copying the postinstall steps for conpty.dll):
cd ~/.dsh/profiles/web
pnpm rebuild node-pty
Then restart DSH (reopen the DeepSeek Harness application or re-run dsh --profile web). In the startup logs, you should see something similar to:
[terminal-vision] loaded: tools=6
You can ask the agent in the conversation to list terminal-related tools to confirm the six terminal_* tools are loaded. The plugin runs within the DSH host process and has the same permissions as the current DSH process; it is recommended to review the source code and MIT license at the GitHub repository before installation.
Typical Usage¶
The htop example from the README (tool calls are illustrative; the agent actually executes them via the DSH tool interface):
terminal_open(session_name="htop", shell="htop") → session_id
terminal_get_screen(session_id) → lines[] and cursor of the htop interface
terminal_send_keys(session_id, "F10") → exits htop, returns new screen
terminal_close(session_id)
Executing commands in the shell and reading the screen or scroll history:
terminal_open(session_name="work", shell="bash")
terminal_send_keys(session_id, "ls -la\n")
terminal_get_screen(session_id) → ls output
terminal_read_output(session_id, lines=200) → content scrolled out of the viewport
Following these steps, agents can apply the same perception-action loop to programs like vim or lazygit, simply by launching the corresponding program directly via the shell parameter in terminal_open.
Use Cases and Known Limitations¶
Suitable for: Scenarios requiring agents to operate full-screen TUIs, interactive installers, or terminal workflows requiring “look at the screen, then press keys” within DSH conversations; teams wishing to rely on pure JS screen parsing without introducing long-running Python side processes.
Limitations (Excerpted from README):
- The screen model only exposes text; colors and attributes are parsed by the emulator but are not included in the snapshot.
cursorHiddenis for reference; xterm.js does not expose DECTCEM status.Alt+<letter>sends ESC prefix bytes; application keypad modes are not negotiated individually per program.- Sessions are bound to the DSH host process; restarting DSH closes all sessions.
- The default shell on Windows is
cmd.exe;bashcan be chosen if Git Bash / WSLbashis available in the PATH.
Conclusion¶
dsh-terminal-vision upgrades interactive terminals from byte streams to a readable screen model and uses ready-waiting to reduce the risk of blind keystrokes. It fills a specific gap in TUI semantic vision within DSH’s “client” class plugins. Directory page: https://www.skillhub.cn/plugins/fdfdfdfgbfdgfdg-star/dsh-terminal-vision; Source code and full documentation: https://github.com/fdfdfdfgbfdgfdg-star/dsh-terminal-vision.