DSH developers often encounter context overflow or messy message structures when entering long text (code snippets, long logs, documentation). Manually truncating or simply concatenating text is inefficient and can easily interrupt the conversational flow. The dsh-paste-collapse plugin intercepts paste operations in the browser, automatically converts large blocks of text into compact tags, and restores the full context when a message is sent.
Plugin Positioning¶
This is a DSH Static Plugin (Static Cordis Plugin). It is a true static package that includes a Host (backend logic) and a browser Client (frontend interaction). The plugin is maintained by huenjie and licensed under MIT.
After installing this plugin, load it into the dsh web profile and restart dsh web; it will be loaded automatically without dynamic rebuilding or re-authorization.
Core Features¶
This plugin mainly addresses the display and transmission issues of pasting large blocks of text:
- Automatic collapse
When text is pasted into the AI input box, the system first trims leading and trailing whitespace. If the content still spans multiple lines, or if a single line exceeds 100 characters, it is automatically collapsed into a[Paste #N +M lines]tag. - Local cache persistence
The browser side useslocalStorageto store paste records, up to 32 entries, each up to 50,000 characters. On the Host side, only the most recent 8 entries are kept in process memory as a fallback; nothing is written to disk. - Interactive operations
- 👁 Preview: Click the icon to open a full-content card. Click outside the card or the close button to dismiss it.
- ✎ Rename: Give a paste block a name; the tag is synchronously updated to
[Paste #N | Name +M lines]. - ↺ Restore original text: Click the icon to replace the tag with the plain original text.
- Delete: There is no separate delete button; delete the tag text directly in the input box to remove the chip.
- Automatic expansion on send
When a message is sent, the tag is automatically expanded into the full original text. The expanded format includes plain marker lines at the beginning and end (for example,[End #N]), with the numbering consistent with the input box tag. The model receives the original text directly and does not need to call a tool. - Compatibility
- Slash commands: Slash commands with arguments (for example,
/agent-teams [long text]) expand the arguments before submission but do not add block decoration, avoiding breaking command parsing. - Legacy compatibility: Older tags such as
[Pasted text #N +M lines]are still recognized and expanded.
- Slash commands: Slash commands with arguments (for example,
Installation and Activation¶
Use the following command to install:
dsh plugin --profile web add dsh-paste-collapse
After installation, restart dsh web to activate it.
Typical Usage¶
- Paste multi-line text or single-line content exceeding 100 characters; the input box immediately displays a
[Paste #1 +34 lines]marker. - Click the 👁 icon to preview the full content.
- Click the ✎ icon to name the paste block, for example
Version A; the tag becomes[Paste #1 | Version A +34 lines]. - Click the ↺ icon to replace the tag with the plain original text and continue editing.
- Delete the tag text directly in the input box; the chip naturally disappears.
- When submitting the conversation, the tag is automatically restored to the original text before sending.
Technical Details¶
- Detection logic: A standalone
\r(char 13) does not produce a visible line break on the webpage and does not trigger collapse. Collapse occurs only after trimming leading and trailing whitespace if the content still spans multiple lines or a single line is >= 100 characters. - Directory structure: The plugin package includes
package.json,cordis.patch.yml, Host logic (lib/index.js), and browser logic (lib/client.js). - Fallback mechanism: Only when the original text cannot be retrieved during expansion (browser cache has been cleared and the Host process has restarted) is the tag sent as-is. In this case, the agent can call the
myds_read_capturedtool to read back the full text by ID.
Applicable Scenarios and Notes¶
This plugin is suitable for scenarios in agent development where code or long documents need to be pasted frequently. Note that this plugin runs with the current dsh process permissions; it is recommended to review the source code and license before installing.
Summary¶
This plugin reduces deployment complexity by using a static package and solves context management problems for pasting large blocks of text. For more details and source code, visit: GitHub.