Preface¶
If you have run longer conversations with DeepSeek Harness, you have likely seen the GFM tables output by the assistant: uneven column widths, especially hard to read when mixed with Chinese, and the model reads this unaligned raw text in the next round. Manual organization is time-consuming and unreproducible. Another common need is to clear the conversation history visible to the model and start over, without losing the original logs persisted to disk.
DSH’s philosophy is “everything is a plugin”; this kind of patch to the conversation stream is perfect for a plugin. The dsh-md-table-formatter introduced below covers both problems.
What is it¶
dsh-md-table-formatter is a DeepSeek Harness plugin maintained by Hyna-hla, current version 1.0.0, MIT license. One-sentence positioning: Automatically aligns Markdown tables in assistant replies after each turn (surface-replace, replay-safe), and provides a /clear-history command to clear the conversation history visible to the model.
Both functions are built on the session surface-replace mechanism, same as the built-in compaction, allowing for safe replay. The porting idea comes from @franlol/opencode-md-table-formatter: changing the OpenCode experimental.text.complete hook idea to a DSH turn/end + surface-replace implementation.
Core Features¶
Auto-aligning Markdown Tables¶
After each turn, the plugin replaces the unaligned GFM tables in the assistant’s reply on the “model-visible surface” with an aligned version, while keeping the original output intact in the append-only session log. Specific behaviors:
- Supports
:---(left-aligned),---:(right-aligned),:---:(centered) alignment markers; - Widths are calculated based on Unicode code points, CJK / full-width characters count as 2 columns;
- Tables inside code fences (``` inside) are not moved, and consecutive tables do not swallow rows from each other.
The /clear-history Command¶
Replaces the entire conversation history visible to the model with a placeholder message. The original logs are retained, and the conversation can continue; execution is rejected if called during a turn.
Installation and Activation¶
First, build and run tests in the repository root directory:
pnpm install
pnpm build
pnpm test
After tests pass, run the installation script to install the plugin into the profile (copy node_modules and register cordis.patch.yml):
.\scripts\install-to-profile.ps1 -Name dsh-md-table-formatter -SourceDir .
After the above steps, restart DeepSeek Harness for the plugin to take effect.
Configuration¶
The plugin is registered via cordis.patch.yml, and configuration items can be overridden:
- insert:
- id: dsh-md-table-formatter
name: dsh-md-table-formatter
config:
autoFormat: true # Whether to auto-format after each turn
minColumns: 2 # Tables with fewer columns than this are ignored
clearMarker: '(对话记录已清除)' # Placeholder text for /clear-history
The meaning of the three items: autoFormat controls whether to automatically format tables after each turn; minColumns sets the minimum number of columns for table processing; tables with fewer than this number of columns are not processed; clearMarker is the placeholder text inserted by /clear-history.
Implementation Highlights¶
For developers who want to create similar plugins, the mechanisms in this repository are worth referencing.
The format of the replacement event is identical to that of dsh-compaction-tool-result-pruner:
assistant/message + { surfaceOp: { op: 'replace', start: seq, end: seq }, sourceEventSeqs: [seq] }
The replacement copy preserves the original message ID (freezeMessage), and usage is only retained on the original event to avoid double counting.
The formatting pass is triggered by turn/end in the session/event observer. It uses queueMicrotask to escape the acceptance boundary of the just-submitted append, and then writes the replacement.
Regarding package structure, package.json declares type: module, the main entry point is lib/index.js, and it exports the ./format subpath. Dependencies include only @deepseek-ai/schemastery ^3.18.1; peerDependencies are @deepseek-ai/cordis, dsh-session, dsh-llm, dsh-agent, dsh-commands, all marked as optional.
Use Cases and Notes¶
Suitable for two types of users:
- Frequently ask the model to output GFM tables containing Chinese, hoping the next round of model reads the aligned version instead of the uneven raw text;
- Want to clear the model’s visible history in long conversations while retaining original logs for tracing.
Notes before use:
- The plugin runs with the permissions of the current DSH process; check source code and license before installing third-party plugins. This plugin is MIT-licensed;
minColumnsdefaults to 2; tables with insufficient columns will not be processed;- After installing to a profile, restart DeepSeek Harness for it to take effect.
Conclusion¶
dsh-md-table-formatter uses the same surface-replace mechanism as built-in compaction to turn the two small tasks of “table alignment” and “clearing model-visible history” into replayable, non-destructive automated steps. For DSH users who often handle table outputs, installing this reduces the need for manual organization.
- Community Plugin Directory: https://www.skillhub.cn/plugins/Hyna-hla/dsh-md-table-formatter
- GitHub Repository: https://github.com/Hyna-hla/dsh-md-table-formatter