Introduction¶
When handling structural chemistry drawings in DeepSeek Harness (DSH), a common practice is to manually build structures, reactions, and annotations in ChemDraw, then copy and paste the results back into the workflow. This approach disconnects drawing from the agent, leading to repetitive work and a high risk of losing annotations or formatting through multiple copy-paste cycles. To bridge this gap, DSH needs the ability to directly read and write locally installed ChemDraw .cdx files.
What Is This¶
dsh-chemdraw is a client-side plugin for DSH that invokes ChemDraw via COM automation and integrates chemistry engine parsing capabilities into DSH. The plugin itself does not include ChemDraw or ChemScript—you need to have ChemDraw installed and activated on your machine, and copy CambridgeSoft.ChemScript.dll from the installation directory into the plugin directory. It provides 12 tools that can read structures, stereochemistry, and annotations, as well as safely write back modifications on demand.
Core Features¶
The plugin adopts a three-layer architecture: the ChemDraw native application exposes interfaces via COM automation; ChemBridge.exe serves as a C# bridge responsible for CDX/CDXML/SDF format conversion, geometry calculations, and backups; and dsh-chemdraw’s index.js exposes 12 commands. Below is an overview of the main capabilities.
Read Capabilities¶
chemdraw_inspect: Outputs a structure inventory (SMILES, InChI, molecular formula, MW, IUPAC name), 2D geometry, stereochemistry verification, annotations, reaction arrows, and generates thumbnails for each structure.chemdraw_find: Searches structures by label / id / molecular formula / SMILES fragment, returning id and thumbnail for disambiguation of duplicate labels.chemdraw_render: Outputs a full-page PNG and per-structure cropped images.chemdraw_3d: Performs MM2 conformational calculation on a structure and provides metrics such as planarity RMSD, maximum torsion, and molecular span.
Write Capabilities¶
Write operations default to dry-run (simulated execution) and do not persist to disk. Writing only occurs when dry_run: false is set. Write tools include:
chemdraw_add: Adds a structure by SMILES with automatic layout avoidance and optional annotations.chemdraw_delete: Deletes a structure and its annotations by id or label; duplicate labels can be targeted withnthto specify which one.chemdraw_replace: Replaces a structure in place and recalculatesChemical Formula:/Molecular Weight:annotations.chemdraw_annotate: Adds text annotations with position-based pairing to avoid misinterpretation (e.g., “B1” will not be misread as boron).chemdraw_move: Moves a structure and its associated annotations.chemdraw_add_arrow: Adds a reaction arrow.chemdraw_edit: Batch transaction that allows mixing add / delete / replace / annotate / move / arrow in a single commit.
The write safety model includes: default dry-run, writing to a temporary file first and then verifying the InChI multiset, automatic backup of the last 3 versions, using File.Replace for atomic replacement, and only updating property annotations belonging to that specific structure.
Installation and Enablement¶
Run the following in the DSH terminal:
dsh plugin add github:CGH999/dsh-chemdraw
Or enter the repository URL under Plugins → Add Plugin. After installation, you need to:
- Copy
CambridgeSoft.ChemScript.dllfrom the ChemDraw installation directory into the plugin’sbin/directory. - Set the environment variable
CHEMDRAW_HOMEto point to the ChemDraw installation directory (which should contain bothChemScriptandChemDrawsubdirectories):
setx CHEMDRAW_HOME "C:\Program Files\Revvity\ChemDraw"
Runtime cache is written to the var/ directory (already listed in .gitignore).
Typical Usage¶
The following are example workflows based on the documentation.
1. Check Installation and Licensing¶
chemdraw_doctor
This tool checks installation, licensing, and performs an engine self-test.
2. Read Structure Inventory and Thumbnails¶
chemdraw_inspect path/to/file.cdx
Outputs the structure inventory (SMILES, InChI, molecular formula, MW, IUPAC name), 2D geometry, stereochemistry verification, annotations, reaction arrows, and thumbnails.
3. Find Structures by Fragment¶
chemdraw_find path/to/file.cdx --smiles "CCO"
Returns the id and thumbnail of matching structures.
4. Add a New Structure (Dry-Run)¶
chemdraw_add path/to/file.cdx --smiles "CCO" --label "Ethanol"
Defaults to dry-run; no changes are written to disk.
5. Add a New Structure and Persist¶
chemdraw_add path/to/file.cdx --smiles "CCO" --label "Ethanol" --dry-run false
6. Batch Edit Transaction¶
chemdraw_edit path/to/file.cdx --actions "add:SMILES=CCO,label=Ethanol,delete:label=Benzene,annotate:label=Ethanol,text=2D"
Before writing, it first writes to a temporary file and verifies the InChI multiset; the original file is only replaced after validation passes.
Use Cases and Notes¶
This plugin is suited for scenarios where you need to directly manipulate local ChemDraw drawings within DSH, such as automated synthetic route review, batch annotation updates, and batch structure/reaction search and replacement. Before use, please confirm:
- ChemDraw is installed and activated in a Windows environment.
CHEMDRAW_HOMEpoints to the correct installation directory and contains bothChemScriptandChemDrawsubdirectories.CambridgeSoft.ChemScript.dllhas been copied tobin/.- DSH sandbox permissions allow writing
.cdxfiles within the session workspace.
The plugin is released under the MIT license, but ChemDraw and ChemScript are commercial products of CambridgeSoft / Revvity and are not included in the repository. It is recommended to review the source code and license before installation.
In Short¶
dsh-chemdraw enables DSH to directly read and write ChemDraw .cdx files, providing 12 read/write tools with a built-in safe-write model. It is ideal for developers who need to operate local chemistry drawings directly within an agent workflow.
- Plugin page: https://www.skillhub.cn/plugins/CGH999/dsh-chemdraw
- GitHub: https://github.com/CGH999/dsh-chemdraw