Preface¶
In DeepSeek Harness (DSH) plugin development, when displaying or editing large blocks of text, there is usually no built-in UI component. dsh-scratchpad provides a solution: it is a shared floating text surface that plugins can open through the client service scratchpad, for reading or in-place editing.
Plugin Overview¶
dsh-scratchpad is a DSH plugin maintained by joao-paulo-santos.
It does not include a user interface itself and primarily exists as an underlying service. Other plugins inject the scratchpad service to call it, enabling text display and editing. The plugin has no persistent storage; the lifetime of text is limited to the current DSH session.
Installation and Enablement¶
Before installing, make sure you have a checkout of DeepSeek Harness and have configured the corresponding profile (the example uses web).
- Install the plugin and add it to the current profile:
pnpm dsh plugin --profile web add ~/dsh-plugins/dsh-scratchpad
- After installation, verify that the profile configuration is correct:
pnpm dsh --profile web --dump-config
- After restarting Harness, plugins that have injected the
scratchpadservice can use this feature.
Core Features¶
The plugin provides two modes, switched via the editable parameter.
Read Mode (default)¶
- Behavior: The text is read-only and cannot be edited.
- Interaction: Scrolling, selection, and copying are supported. Only the close action is available.
- How to close: Click the background overlay or the close button.
Edit Mode¶
- Behavior: The text is editable and provides save and cancel options.
- Interaction:
- Save: Calls the
onSavecallback, returns the edited text to the caller, then closes the Pad. - Cancel: Discards the edited content and closes the Pad.
- Close: Pressing the
Escapekey closes it directly and discards the edited content.
- Save: Calls the
- Shortcut key:
Ctrl/Cmd + Entercan save the edited content directly. - Note: Clicking the background overlay in Edit mode does not close the Pad, preventing accidental data loss.
Typical Usage¶
Other plugins inject the scratchpad service in client code and then call the open method.
// consumer client half, inject: ['scratchpad', 'slots', …]
ctx.scratchpad.open({
title: 'Section preview', // 可选的头部文本
text: bigText, // 必需的字符串
editable: true, // false (默认): 只读查看器
onSave: (text) => { … } // 编辑模式:唯一的返回通道
})
Dependencies and Notes¶
Functional Limitations¶
- Storage limit: Text size is limited to up to 2 MB of string content.
- No persistence: Pad state persists across session switches (module scope), but is lost after a page refresh.
- Validation: The
onSavecallback is required wheneditable: true; otherwise an exception is thrown.
Dependencies¶
- dsh-diff-view: If you want to render
mode: 'diff'content in the Pad, this plugin must be installed; otherwise Diff mode falls back to a plain before/after comparison view. - dsh-granular-prompt: This is an example plugin that depends on this one. It uses
scratchpadto implement full-text viewing, segmented replacement, and Diff review.
Ecosystem Note¶
As a plugin in the DSH ecosystem, it is provided under the MIT License. It is recommended to inspect the source code and license before installation to ensure compliance with project standards.