dsh-composer-autopair: Automatic pairing of brackets and quotes in the DSH chat input box

Preface

When writing prompts, pasting code snippets, or including JSON within DSH (DeepSeek Harness), paired brackets, square brackets, and quotes are the norm. However, the editor itself might not auto-complete the right half and place the cursor in the middle like an IDE. Manually adding symbols and moving the cursor repeatedly breaks the flow of thought in frequent conversation scenarios. The community plugin dsh-composer-autopair (maintainer lov0vo) specifically targets the DSH chat input box ([data-composer-input]). It automatically completes the right half when the left half is typed and places the cursor in between; it also handles edge cases such as deleting pairs via backspace, wrapping selected text, and submitting via Chinese Input Method Editors (IME). The following section introduces its capabilities, installation methods, and usage notes.

What is this

dsh-composer-autopair is a client-side plugin for DSH (dsh.client + dsh.bundle.patch), with the current package version 0.5.1 (MIT). It is categorized as a client-side enhancement and does not modify server-side logic.

In short: it provides automatic pairing for 17 groups of half-width and full-width brackets and quotes within the DeepSeek Harness chat composer. It does not apply to the settings page input boxes, terminals, right-sidebar editors, or file trees. The plugin does not intervene while the Input Method is composing (during composition).

Core Features

Auto-pairing and Cursor

When the left half of a symbol is typed, the corresponding right half is automatically inserted, with the cursor placed between the two symbols. The pairing table is as follows (from the original source):

( )   [ ]   { }   " "   ' '   ` `
( )  [ ]  { }  【 】  《 》  〈 〉  「 」  『 』  〔 〕  “ ”  ‘ ’

Common Interactions (README Behavior Table)

Scenario Behavior
Pressing ) again when the cursor is already between () Jumps over the right half; does not turn into ())
Pressing a quote again when the cursor is between empty quotes “” Nests another pair → ““”” (Adapts to cases where Chinese IMEs only provide the closing quote ”)
Pressing a quote to close when there is already content inside Jumps over the closing quote to finish normally
Pressing ( after selecting text Turns into (selected text), keeping the original text selected
Pressing Backspace between () Deletes both the left and right halves together
Submitting ( via Chinese IME Also completes with the right half )
Submitting the right half ) via IME when a ) already exists to the right Jumps over; does not turn into ())

Implementation Points (For Troubleshooting)

The plugin listens for beforeinput during the document capture phase, primarily utilizing the Lexical model layer (obtaining the instance from [data-composer-input].__lexicalEditor). If the editor cannot be retrieved or if the selection contains decorated nodes like @ reference chips, it falls back to a DOM-based approach. It does not include / slash commands or @ reference capabilities—those are native DSH behaviors that the plugin does not override.

Installation and Activation

The repository includes the build artifact lib/client.js. The official README installation process involves cloning the repo and running deploy.mjs (build + install, with automatic selection of the Loader mounting method):

git clone https://github.com/lov0vo/dsh-composer-autopair
cd dsh-composer-autopair

node deploy.mjs            # Build + Install (auto-select mounting method)
node deploy.mjs --check    # Preview what will be done, do not write to disk
node deploy.mjs --remove   # Uninstall (reversible)

deploy.mjs will: generate lib/client.js from src/autopair.mjs; copy the package to <DSH_HOME>/plugins/dsh-composer-autopair/ and the profile’s node_modules; register a file: dependency in the profile’s package.json; and select either the bundle route or the user-patch route to mount the Loader entry based on whether the package is already registered in dsh.profile.bundles. (Inserting both would result in a duplicate composer-autopair id, which might cause the dshmarket static check to roll back the entire update).

Environment variables: DSH_HOME (default ~/.dsh), DSH_PROFILE_DIR (default $DSH_HOME/profiles/desktop).

  • Bundle Route (Package already registered in profile): Requires a DSH restart for the bundle list to take effect.
  • User-Patch Route (Package not registered in profile): If the profile declares patchReload: live, the managed block can take effect hot-reload after insertion.

Please read the repository source code and the MIT license before installing. Client plugins run within the current DSH desktop process with the same permissions as the host. You must assess the risks yourself when installing unauditable third-party packages.

Typical Usage and Switches

Temporary Disable (No Uninstall Needed)

In the DevTools console:

__dshComposerAutoPair.setEnabled(false);   // Disable
__dshComposerAutoPair.setEnabled(true);    // Enable
localStorage.setItem('dsh-composer-autopair:enabled', 'off');  // Remains disabled after restart

Self-Check and Diagnostics

The plugin writes a self-check report to localStorage approximately every 3 seconds. Common keys: dsh-composer-autopair-report (capabilities, stats, logs, event traces), dsh-composer-autopair:probe (load probe), dsh-composer-autopair:error, dsh-composer-autopair:enabled (on / off).

To read the report from disk (default DSH Desktop Local Storage path):

node tools/read-report.mjs
node tools/read-report.mjs "<leveldb dir>"

In a normal situation, viaEditor should increase in the statistics while viaDom remains 0; a persistent imeNotSettled greater than 0 may indicate a mismatch between the DSH input chain and the plugin’s assumptions. Since LevelDB disk writes have a delay, you may need to wait 1-2 minutes after operating before reading, or execute JSON.parse(localStorage['dsh-composer-autopair-report']) in the console.

If caps.composerReady is true after installation, the chat input box anchor is aligned. As this relies on Lexical internal fields, if it fails after a DSH upgrade, caps.lexicalEditor / caps.editorError in the report can assist in judgment, and it will fall back to the DOM method.

Applicable Scenarios and Notes

Who it is for: Users who frequently write code blocks, structured prompts, or converse with Chinese punctuation in the DSH chat box, and wish for bracket and quote behavior to approach the auto-pairing habits of common editors.

Boundaries (README Known Limitations):

  • Only for the chat input box; does not process during text composition.
  • Relies on several internal Lexical APIs; may require waiting for plugin updates after major version upgrades.
  • Tested on the DSH Desktop profile desktop (Windows); theoretically applicable to other versions using the same Lexical composer, subject to the self-check report.

The DSH ecosystem emphasizes “Everything is a plugin”; the community directory SkillHub Plugin Page is an independent site with no official affiliation with DeepSeek or High-Flyer. The installation source depends on the directory or GitHub repository you trust.

Conclusion

dsh-composer-autopair brings common IDE bracket and quote auto-pairing to the DSH chat composer, while specifically handling details like Chinese Input Methods and empty quote nesting. If you are already using DSH to write prompts, you can follow the README to run node deploy.mjs to install, use node deploy.mjs --check to preview changes, and use the report script or localStorage to confirm if it is working.

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

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

Xiaoye