DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

zhanghui6666 /

zhanghui6666/paste-as-text-attachment

Verified

将 DSH 聊天输入框中的长文本粘贴转为 .txt 附件。支持设置字符阈值和启用/关闭;普通输入与短文本粘贴不受影响。

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@f906dee2

Paste as Text Attachment for DSH

Turn oversized text pasted into a DSH chat composer into a .txt attachment—without changing normal typing or short pastes.

**中文简介:**这是一个 DeepSeek Harness(DSH)Web 插件,可将聊天输入框中超过设定字符数的粘贴内容转成 .txt 附件。可在插件详情页开启或关闭功能并设置字符阈值。

Features

  • Watches paste events only in the focused DSH chat composer.
  • Converts only text whose JavaScript string length is greater than the configured threshold.
  • Uses DSH's native file-intake path, preserving the built-in attachment rail and upload UI.
  • Leaves short pastes, ordinary typing, and pastes outside the focused composer unchanged.
  • Creates the text file in memory; it does not write the pasted content to disk.
  • Includes a Chinese/English configuration page in DSH's Plugins view.

Configuration

Open Plugins → Installed → paste-as-text-attachment in DSH. The bundle detail page provides:

Setting Default Range / behavior
Automatic conversion On Turn long-paste conversion on or off.
Character threshold 10,000 Integer from 1 to 10,000,000. Only pastes longer than this value are converted.

The threshold uses JavaScript String.length (UTF-16 code units), not UTF-8 bytes. Settings are stored in the current DSH Web GUI's browser localStorage; they persist across reloads in that GUI, but are not synchronized between profiles, browsers, or devices.

Install

Install it from DSH's Plugins → Add plugin page using this repository's Git address:

https://github.com/zhanghui6666/paste-as-text-attachment.git

DSH may ask you to enable the bundle after installation.

How it works

The plugin observes the conversation.input.overlay list slot rather than replacing conversation.input.attachments, which is a single-occupant slot used by DSH's built-in attachment rail. When a qualifying paste occurs, it creates an in-memory text File and dispatches a file-only synthetic ClipboardEvent to the focused editor. DSH's own paste handler then runs its normal attachment intake. The original text paste is canceled only if the host handles that file event.

Compatibility and privacy

  • Requires a DSH Web Client that provides the conversation.input.overlay slot and handles file items in the composer's paste event.
  • Requires browser support for File, DataTransfer, ClipboardEvent, and localStorage.
  • Pasted text is not retained by this plugin and is not written to disk. Once accepted, the file is handled by DSH's normal attachment/upload pipeline.
  • The test suite mocks the host editor's file-paste handler. Validate the behavior in your target DSH version before relying on it for important logs.

Development and tests

No external test dependencies are needed; tests use Node's built-in test runner.

node --test client.test.js

The tests cover slot registration, configuration controls and persistence, threshold behavior, disabled mode, and fall-through when the host editor does not claim the synthetic file event.

Project files

File Purpose
client.js Paste watcher, configuration page, and browser-side settings.
index.js Host bundle entry point.
cordis.patch.yml Registers the bundle's plugin row with DSH.
package.json DSH bundle and Web Client metadata.
client.test.js Local unit tests with a mocked DSH editor.

License

This project is licensed under the MIT License. See LICENSE for the full text.


中文说明

功能

  • 只监听 DSH 聊天输入框中的粘贴事件,不拦截手动输入。
  • 仅当文本长度大于字符阈值时,才转为 .txt 附件。
  • 走 DSH 编辑器原生附件接收流程,保留内置附件栏和上传状态展示。
  • 短文本粘贴、输入框外粘贴,以及普通打字均不受影响。
  • 文件在内存中创建;插件本身不会把粘贴内容写入本地磁盘。

配置

在 DSH 中打开 插件 → 已安装 → paste-as-text-attachment,可启用/关闭自动转换并设置字符阈值。默认开启,阈值为 10,000,可设为 1–10,000,000 的整数。仅超过阈值的粘贴内容会转换。

长度按 JavaScript String.length 计算(UTF-16 代码单元),不是 UTF-8 字节数。设置保存在当前 DSH Web GUI 的浏览器 localStorage 中,可跨页面刷新保留,但不会在不同 profile、浏览器或设备之间同步。

安装

在 DSH 的 插件 → 添加插件 页面填入本仓库的 Git 地址:

https://github.com/zhanghui6666/paste-as-text-attachment.git

安装后如有提示,再启用该组合包。

兼容性与验证

插件通过 conversation.input.overlay 列表插槽观察粘贴,不会替换 DSH 自带附件栏所使用的单占位 conversation.input.attachments 插槽。检测到符合条件的粘贴后,插件会创建内存中的文本文件,并向当前编辑器派发仅含文件的合成粘贴事件;只有 DSH 编辑器接收该事件后,原始文本粘贴才会被取消。

需要 DSH Web Client 提供上述插槽并支持编辑器粘贴接收文件。当前自动化测试对 DSH 编辑器接收文件的行为使用了模拟实现;正式使用重要日志前,请先在目标 DSH 版本中完成端到端验证。

本地测试

使用 Node.js 内置测试运行器,无需额外测试依赖:

node --test client.test.js
—/ 5

No ratings yet

Verified DSH bundle

Commit f906dee29bff

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout