Preface¶
DeepSeek Harness (DSH) uses a plugin-based architecture. When using the dsh-ocr plugin, there are three details in the official adapter that require manual repair, and these repairs are outside the profile. During a global upgrade (npm i -g @deepseek-ai/dsh) or plugin reinstallation, these patches will be overwritten. dsh-ocr-seam-guard is designed to address this issue by acting as a daemon to automatically detect and restore these patches.
What Is This¶
dsh-ocr-seam-guard is a management and security plugin maintained by DosterBool. It serves as a self-repairing guard for the dsh-ocr plugin, automatically checking and reapplying local patches that were removed by upgrades at startup, ensuring service environment consistency.
Core Features¶
- Automatic Repair of Removed Patches: Monitors three critical locations required by the dsh-ocr plugin and automatically reapplies local patches removed by
npm i -g @deepseek-ai/dshupgrades or plugin reinstallation. - Checks Three Critical Locations:
* Adapter seam (located in@deepseek-ai/dsh-llm-deepseeklib/index.js).
* UTF-8 stdout enforcement for the Python OCR subprocess.
* rapidocr API interface corrections (such astext_det→text_detectorin version 1.2.3). - Anchored String Replacement: Uses precise anchored strings for replacement to ensure the integrity of patch contents.
- Module Validation and Rollback: Validates that patched modules load correctly through a child
nodeprocess; if validation fails, it automatically rolls back files and reports the error. - Anchor Drift Tolerance: If upstream code anchors have drifted, the plugin skips the patch and records a log to prevent incorrect application.
Installation and Activation¶
- Run the installation command:
dsh plugin --profile web add github:YOURNAME/dsh-ocr-seam-guard
- Restart dsh after installation to activate the patches.
Configuration¶
| Environment Variable | Default Value | Purpose |
|---|---|---|
DSH_OCR_ADAPTER_FILE |
Auto-detected | Overrides the adapter file path. Only supports DSH environments installed globally via npm. |
Applicable Scenarios and Notes¶
- Environment Limitations: Only supports DeepSeek Harness installed globally via npm.
- Activation Timing: dsh must be restarted before the patches become active.
- Exception Handling: If upstream code anchors have drifted, the patch will be skipped and requires manual inspection.
- Permissions and Security: The plugin runs with the permissions of the current dsh process. Please review the source code and license (MIT) before use.
Conclusion¶
This plugin solves the patch volatility issue in plugin maintenance through automation, ensuring the stability of OCR services. For more details, please refer to the plugin directory or the GitHub repository.