Introduction¶
When processing chapters, technical documentation, study notes, or Agent execution traces within a DSH session, a common problem is distributing the original text, conclusions, evidence, and relationships throughout the text stream. cwbcheng/dsh-knowledge-graph is a DSH Cordis plugin that splits arbitrary materials’ body text, images, or AI session execution traces into knowledge graphs. It provides bidirectional positioning between the knowledge graph and the original text, along with capabilities for evidence verification, questioning, and refinement. Below is an introduction to its capabilities, installation method, and typical usage.
What is it¶
dsh-knowledge-graph is maintained by cwbcheng with an MIT license.
The README states that it is a DSH dynamic Cordis plugin: one Host code runs in a Node process, and one Client code runs in the browser; overall, it is pure JS, zero dependencies, and requires no build.
package.json also declares the following dependencies and injection information:
peerDependencies:@deepseek-ai/cordis ^4.0.1dsh.client.inject:@deepseek-ai/dsh-client-runtimedsh.client.platform:web
package.json also contains scripts such as build, build:lib, build:viewer, pack:extension, kg, etc.
Prerequisites¶
First, confirm that the environment meets the following conditions:
- DSH Web is started and you enter any session:
dsh web
-
The AI model provider is configured in the environment. The plugin defaults to the system’s current model; if not configured, it will provide a clear Chinese error message.
-
Image splitting requires a multimodal model that supports
imageinput. If the provider refuses the image, it will fail explicitly withmodel_image_unsupported. -
The plugin runs with the current DSH process permissions and will read the repository source code and call the model. You should verify the source code and the
MITlicense before installing.
Core Features¶
Asynchronous Text Splitting¶
After inputting body text such as chapters, technical documentation, or study notes, the plugin calls the LLM in background task mode, returning a knowledge graph in approximately 15–40 seconds. It supports body text up to about 1 million characters.
Direct Image to Knowledge Graph¶
Supports uploading 1–4 images of PNG / JPEG / WebP / GIF, with a maximum of 6 MiB per image and a total maximum of 16 MiB.
The images that can be processed include text screenshots, diagrams, flowcharts, architecture charts, statistical charts, formulas, and tables.
Image extraction first uses a multimodal model to generate a canonical visual transcription with image ranges, and then splits arrows/connections, grouping/inclusion, object correspondence, order, and legends into relationship units.
Note: Visual transcription is a model output, not pixel-level deterministic OCR. Key text, values, table cells, and connection relationships should still be verified against the original image. Current image input is for creating new knowledge graphs; incremental appending for existing graphs still uses text.
8 Node Types and 12 Relationship Types¶
The plugin generates 8 types of nodes:
factclaiminferenceconceptdefinitionexamplecounter_examplerule
The plugin generates 12 types of relationships:
supportsexamplecounter_exampledefinesinferscausesis_acontainsdriven_bynot_isanalogyaims_at
Bidirectional Positioning¶
When clicking a node in the graph, a detail card can be popped up, and it will smoothly scroll and highlight to the corresponding content unit in the original text.
When clicking a content unit in the original text, the graph will center on the corresponding node and blink it.
Graph Rendering¶
Graph rendering supports 4 switchable layout types:
- Force-directed
- Circular
- Radial
- Hierarchical
Graph rendering supports drag-to-pan, Ctrl+Scroll zoom, toolbar zoom, and keyboard accessibility.
Verification, Questioning, and Refinement¶
After generating the knowledge graph, the following operations can be performed:
- Quick health check: Local rule checking.
- AI deep review.
- Manual closed-loop: Adopt fix, ignore, or one-click fix for issues, and write to audit records.
- Active questioning: Question nodes, relationships, or the entire graph.
External Fact Checking¶
The following nodes can be converted to verifiable assertions:
factclaiminferenceruledefinitioncounter_example
External fact checking can use external evidence like Wikipedia, or paste domain rule sources to participate in the ruling.
Each conclusion binds an evidence link and citation; citations must be locatable in search results, and fabricated citations will be automatically downgraded.
Append Splitting and History¶
After having split results, you can append the next paragraph or the next piece of material. AI only extracts new content and establishes cross-paragraph relationship edges with the existing graph; the same concept does not create duplicate nodes.
Each successful split is automatically recorded:
- Maximum of 20 entries
- Deduplication by text
- Single delete or clear all
The browser only saves lightweight indices such as documentId, title, count; when reviewing, it reloads the body and canonical graph from Host/SQLite.
Chapter Filtering and Candidate Review¶
The result area can filter graph nodes and original text paragraphs by chapter.
Candidate entities or candidate claims can be marked as:
- Pending Review
- Accepted
- Rejected
Status is synced to SQLite via Host; it falls back to browser localStorage on failure.
Knowledge Graph Consumption Layer¶
Supports bounded structured retrieval by the following conditions:
- Keyword
- Node type
- Chapter
grounding/entailmentstatus
It also supports evidence-based Q&A using only the server-side canonical graph and authenticated original text.
Export¶
You can export the current rendered graph as HD PNG, or export:
- Full JSON
- Nodes CSV
- Relations CSV
Data export is the full graph, unaffected by current chapter filtering.
Workspace and Model Selection¶
The floating workspace window can be dragged and resized.
The width ratio of the original text and knowledge graph, and the height of the result area can be dragged and adjusted, and the settings are remembered.
The top of the workspace and the “Trace Knowledge Graph” provide a model dropdown box where you can manually specify the model to be used for the following operations:
- Split
- Append
- AI Review
- Questioning
- External Checking
Model selection is saved locally in the browser.
Trace Knowledge Graph¶
A new “Trace Knowledge Graph” tab is added to the conversation area.
It can split the current session’s user messages, tool calls, tool results, and AI replies into a knowledge graph. It supports bidirectional positioning between the graph and trace events, and also supports incremental merging for new events.
Persistent Entry¶
A “Knowledge Graph” button stays permanently on the right of each conversation title. The running card also has a start bar.
Installation and Enablement¶
First, get the source code:
git clone https://github.com/cwbcheng/dsh-knowledge-graph.git
cd dsh-knowledge-graph
Then, enter any DSH Web session and send the following message to the Agent:
请读取 dsh-knowledge-graph 仓库的 src/index.host.js 和 src/index.client.js,把这两个文件定义为 Cordis 插件的 Host 半和 Client 半,然后运行它。
The Agent will call cordis_define (define) and cordis_run (run) sequentially, and a running approval card will pop up on the interface.
After the above steps, you can open the workspace from the “Knowledge Graph” button on the right side of each conversation title or the start bar in the running card.
Typical Usage¶
- Text to Graph: Input body text such as chapters, technical documentation, or study notes in the workspace; the background will asynchronously split and generate a knowledge graph.
- Image to Graph: Upload 1–4 images of
PNG/JPEG/WebP/GIFto generate a knowledge graph; clicking an image will locate the corresponding visual transcription paragraph. - Bidirectional Positioning: Click a node in the graph to view full content, original text excerpts, and positioning buttons; click a content unit in the original text to center and blink the corresponding node in the graph.
- Append Splitting: After having split results, click “Append Split” to paste the next paragraph or the next material. AI extracts the new content and automatically establishes cross-paragraph relationship edges with the existing graph.
- Highlight Splitting: Select any text in a chat message and click the “Split into Knowledge Graph” button to automatically open the workspace and split the selected text.
- Verification and Refinement: Use quick health check, AI deep review, question this node, question this relationship, or external fact check the original text, and perform adopt fix, ignore, or one-click fix on issues.
- Retrieval and Q&A: Use the knowledge graph consumption layer to search by keyword, node type, chapter,
grounding/entailmentstatus, and perform evidence-based Q&A. - Trace Graph: Open the “Trace Knowledge Graph” tab in the conversation area to decompose the complete execution trace of the current session with one click; you can also click “Append New Event” to only decompose the new part and incrementally merge it on the same revisioned document.
- Export: Export the current rendered graph as HD PNG, or export Full JSON, Nodes CSV, or Relations CSV.
Applicable Scenarios and Notes¶
Suitable for those who need to organize materials’ body text, images, and Agent session traces into retrievable knowledge graphs, and who want the graph and original text to be mutually locatable and the conclusions to be verifiable.
Note the following items:
- The plugin runs with the current
dshprocess permissions and will read the repository source code and call the model; you should verify the source code and theMITlicense before installing. - Requires a DSH Web session and an AI model provider; the plugin defaults to the system’s current model, and will provide a clear Chinese error message if not configured.
- Image extraction requires a multimodal model that supports
imageinput; if the provider refuses the image, it will fail explicitly withmodel_image_unsupported. - Visual transcription is a model output, not pixel-level deterministic OCR; key text, values, table cells, and connection relationships should still be verified against the original image.
- Current image input is for creating new knowledge graphs; incremental appending for existing graphs still uses text.
- The persistent mode saves the full text, canonical graph, and lossless checkpoint in SQLite; after refreshing, the browser only restores based on
documentId/runId. - Only tasks left by a Host restart that have a
runningstatus are allowed to continue from the checkpoint; explicitlyfailed/cancelledtasks will never retry automatically. - Candidate entity/claim status is synced to SQLite via Host; it falls back to browser
localStorageon failure. - In external fact checking, each conclusion binds an evidence link and citation; fabricated citations will be automatically downgraded.
Conclusion¶
The value of dsh-knowledge-graph lies in converting materials, images, and traces in DSH sessions into locatable, verifiable, and repairable knowledge graphs.
GitHub repository address:
https://github.com/cwbcheng/dsh-knowledge-graph
Directory entry:
https://www.skillhub.cn/plugins/cwbcheng/dsh-knowledge-graph
This directory entry comes from the plugin entry and has not been verified in the scraped material body text.