dsh-cntokenworld-kb
weber-pan/dsh-cntokenworld-kb
把 DeepSeek Harness 接到 CntokenWorld 知识库:侧边栏提供文档、Wiki、图谱与画廊的工作台,模型侧提供检索、读原文与带引用问答四个只读工具。
安装
dsh plugin --profile web add github:weber-pan/dsh-cntokenworld-kbREADME
dsh-cntokenworld-kb
Connect DeepSeek Harness to a CntokenWorld knowledge base: a sidebar workbench for the documents, the wiki, the link graph and the gallery, plus four read-only retrieval tools for the agent.
Features
- 📚 Knowledge base workbench — the Knowledge base entry in the left sidebar opens a full panel: the first screen lists the knowledge bases as folders, and a click opens one of them.
- 📄 Original file preview — documents carry an icon for their extension and open in their own format: images directly, PDFs in the built-in reader, Word documents rendered into laid-out text, plain text as text, and the remaining formats fall back to the content parsed by the service.
- ⬆️ Four ways to add documents — upload files, upload a whole folder, import a web page, or edit Markdown online; the bytes travel through the host bridge, so the API key never reaches the browser.
- 🔍 Hybrid retrieval — vector and keyword search inside one knowledge base, with the score, the match type and the passage itself.
- 📚 Wiki editing — browse the generated articles, search them, and write them too: new pages, edits guarded by a version check, the version history with a restore, the link check and the auto fix.
- 🕸️ Link graph — the wiki link graph drawn with a d3-force simulation: the nodes settle, can be dragged, zoomed and panned, and a node opens its article.
- 🎨 Gallery — the image assets of a knowledge base, with a keyword filter and a lightbox.
- 🧭 Knowledge base picker under the composer — every conversation picks the bases it may read: all of them, a single one, or several of them.
- ⚙️ Its own section in the settings window — Knowledge base settings sits next to the general and model settings, and holds the service address, the API key and the tool switches.
- 🌗 Follows the host theme — every colour comes from the host design system's semantic tokens, so the panel and the settings section follow the light and dark theme.
Install
From GitHub
git clone https://github.com/weber-pan/dsh-cntokenworld-kb.git
dsh plugin --profile desktop add /absolute/path/dsh-cntokenworld-kb
From npm (once published)
dsh plugin --profile desktop add dsh-cntokenworld-kb
The plugin needs a running CntokenWorld knowledge base service. It ships without any service address: fill in your own in the settings, next to the API key.
Restart the Harness after the install, so the new module generation takes effect.
Quick start
- Open Settings → Knowledge base settings.
- Fill in the service address (the plugin appends
/api/v1itself) and paste the API key the service issued. The key is write-only: it is never shown again after it is saved. - Save. The tools are registered right away; no restart is needed.
- Open the Knowledge base entry in the left sidebar to browse, upload and edit documents.
- Under the composer, pick the knowledge bases the conversation may read.
Configuration
Everything is configured in Settings → Knowledge base settings, next to the general and the model settings. The plugin's own page in the Plugin Manager shows the same form.
| Setting | Meaning | Default |
|---|---|---|
| Service address | The root of your knowledge base service; the plugin appends /api/v1. | none, you have to fill it in |
| API key | The key the service issued; write-only, never shown again. | none |
| Tenant ID | Optional, sent as X-Tenant-ID. | none |
| Knowledge base IDs | Comma separated; empty means every base the credential can read. | all |
| Agent ID | When set, ask uses the server-side agent pipeline instead of the plain RAG flow. | none |
| Tool name prefix | Decides the tool names the model sees. | cntokenworld_kb |
| Tool switches | Turn list_knowledge_bases, search, read_document and ask off one by one. | all on |
| Retrieval count | The largest number of passages one search returns. | 8 |
| Passage length | The largest number of characters kept per passage. | 1200 |
| Request timeout | The timeout of one REST call, in milliseconds. | 30000 |
| Answer timeout | The timeout of the streaming answer, in milliseconds. | 300000 |
| Resource links | handle keeps the private handles, public asks for public links. | handle |
The knowledge base scope of a conversation
The picker under the composer decides which bases a conversation may read:
- all — every base the credential can see;
- one — a single base;
- several — the bases you tick.
The choice is kept by the host, per conversation, and the search and ask
tools work inside it from the next call on: the model may still narrow the
scope down, but it cannot leave it. Restore the default hands the scope back
to the knowledge base IDs of the settings.
The service itself does not remember this choice: a CntokenWorld session only
has a title and a description, so every request has to carry the
knowledge_base_ids array again. The plugin therefore stores the scope of each
conversation in the host and translates it into that array on every call.
Tools
| Tool | What it does |
|---|---|
cntokenworld_kb_list_knowledge_bases | Lists the knowledge bases the credential can read. |
cntokenworld_kb_search | Hybrid vector and keyword retrieval, returning source passages with their document ids and scores. |
cntokenworld_kb_read_document | Reassembles the passages of one document in order, with paging. |
cntokenworld_kb_ask | Delegates to the server-side RAG or agent pipeline and returns an answer with references. |
The scope of the retrieval tools follows the scope of the conversation → the
knowledge base IDs of the settings → everything the credential can see. The
knowledge_base_ids a model writes in its arguments can only narrow that
scope, never widen it.
Limitations
- The tools are read-only:
list_knowledge_bases,search,read_documentandasknever upload, change or delete a document. Writing only happens in the Add document menu of the panel. - The API key needs the
retrievecapability on the service side,askadditionally needschat, and uploading needsingest. - The credential is read from the configuration, it is not an interactive login.
- Importing a web page is limited by the service's SSRF allow list.
Directory
dsh-cntokenworld-kb/
├── cordis.patch.yml # the plugin row (its id is the settings namespace)
├── dist/
│ ├── index.js # host entry: registers the tools, declares the settings, mounts the bridge
│ ├── schema.js # the settings fields (schemastery, volatile)
│ ├── config.js # defaults and validation
│ ├── client.js # the host-side HTTP client
│ ├── bridge.js # the host-side bridge routes (the browser panel reads through them)
│ ├── scope.js # the host-side scope store (the picker and the tools share it)
│ ├── tools.js # the four tool definitions
│ ├── render.js # the tool output
│ └── web.js # the browser half: the sidebar panel, the settings section, the picker (built by scripts/build-client.mjs)
├── src/client/ # the browser sources (00-shared / 01-styles / 15-docs / 20-panel / 25-kb / 30-wiki / 30-settings / 40-scope / 90-entry)
│ └── vendor/ # bundled dependencies: d3-force.js (the force simulation), docx-preview.js (the Word renderer)
├── scripts/
│ └── build-client.mjs # concatenates src/client/*.js into dist/web.js
├── locale/ # en.json / zh.json
├── docs/ # DETAIL.md / DETAIL.zh.md / PUBLISHING.md / preview.svg
├── assets/ # the icon and the screenshots
├── screenshots.json # the screenshots the marketplace shows
└── icon.svg
License
MIT © 2026 weber-pan