dsh-ima-kb-panel: Move IMA knowledge base to DSH sidebar, add pagination for large notes.

Introduction

In DSH, using the ima knowledge base usually involves the model calling MCP’s get_doc_content. This note is often tens of thousands of words long, but get_doc_content in ima’s OpenAPI has no pagination parameters—it returns the whole thing at once, consuming the context. Another issue is browsing: wanting to flip through what notes are in the library or what a specific note discusses, you have to feed both the directory and the body to the model, which is equivalent to paying the context cost just to glance at the table of contents.

dsh-ima-kb-panel handles these two things: moving browsing to the left sidebar (without consuming context), changing body reading to “retrieval + character offset pagination”, and doing it all on-demand with limits. The plugin is maintained by how8088, is a client-side plugin, and is listed in the SkillHub community directory.

Below is an explanation of what it is, how to install it, how to use it, and what to watch out for.

I. What is this

A knowledge base plugin for ima used by DeepSeek Harness (DSH), package name dsh-ima-kb-panel, current version 2.7.0, license MIT, requires Node >= 18. It does three things:

  1. Places an entry in the DSH left sidebar, with two tabs “Notes” and “Knowledge Base”; browsing, searching, and scrolling reading are all completed on the browser side;
  2. Registers a set of read-only tools in the conversation, allowing the AI to fetch notes and personal knowledge base contents on-demand, with a character limit on returned content;
  3. Caches note body text and personal knowledge bases on the Host side locally, and after a restart, only supplements new or modified content.

The plugin has no hard-coded ima account credentials; it lists all notes visible by the current credentials. So “switching knowledge bases” equals switching credentials or adding filters, no code change needed.

II. Core Features

Left sidebar entry, two tabs:

  • Notes: Collapsible browsing by category (course original / student summary / in-trading record / WeChat articles…), full-text search, scrolling reading. Categories are auto-grouped by the plugin based on titles. The list has badges for note count and word count, and can be expanded/collapsed with categories.
  • Knowledge Base: After selecting a knowledge base, you see breadcrumbs + folder tree + filename search. Entering file details allows “Download Original”, download goes through Host proxy to get signed Word/PDF.

If literal search in the panel has no hits, the plugin automatically does a round of fuzzy search, and results can be clicked directly.

Conversation Tools

Tool Purpose Limit
kb_list(query?) Lists all notes: title, note_id, word count, start preview; when notes are many, use query to only list titles containing that word Bounded
kb_search(query, note_id?, limit?) Full library substring search, one note can return multiple segments, with character offsets Fragment ≤ 600 chars, default 8 segments
kb_read(note_id, offset?, limit?) Read body by offset pagination Default 6000 chars, max 30k chars
kb_find(query, start?) ima official tokenized search: find it by rephrasing, returns list of matching notes 20 notes per page
kb_space_list() Lists visible knowledge bases (kb_id, file count, description, role) Bounded
kb_space_browse(kb_id, folder_id?, limit?) List directory: folders / files (media_id, type) ≤ 50 items per page
kb_space_search(kb_id, query, limit?) Search by filename/folder name, does not search body content ≤ 50 items

kb_search and kb_find are complementary: the former is local literal matching with offsets, the latter uses ima’s official tokenized recall. If you are unsure of the original wording, use kb_find first to find candidate notes, then use kb_read to read them.

Search is literal matching, not semantic search: searching for “stop loss” will find it, but searching for “what to do if I lost money” may not find “stop loss”.

Cache & Performance

  • Body Disk Storage: The body is cached in ~/.dsh/cache/ima-kb-panel/. After restarting DSH, it no longer does a full re-fetch, only supplements notes where modify_time has changed, usually just a few notes and completed in seconds.
  • Default No Auto Warmup: autoWarm is default off. After the first installation, you must click “Cache All Body” in the panel’s “⋯” menu to start fetching the body; progress is displayed in the panel header. For a library of 70+ notes and about 2 million words, fetching one by one in a single request requires waiting a bit.
  • Host-side Concurrency Control: To avoid ima rate limit code=200001, concurrency and pacing are controlled when fetching body, with exponential backoff retry.
  • Personal Knowledge Base Local Cache (from v2.4.0): Only caches notes and libraries where base_type is “Personal Knowledge Base”. Cached to kb-<hash>.json (list + directory tree + md/docx/txt body) and optional pdf/<mediaId>.bin. Subscribed / joined shared knowledge bases (e.g., “Macro Research Selection”, “SZSE Announcement Library”) are not written to disk and still use online reading. When offline, directory, body, filename search, and PDF viewing can all be done from local storage.

Read-only Constraints

No writing notes, uploading, or deleting, except for local body cache files. The plugin performs no operations that modify content on the ima side.

III. Installation and Enablement

Prerequisites

Requirement Description
DSH Desktop or Web version works, plugin is installed at the profile level
ima Credentials Client ID + API Key, generated at https://ima.qq.com/agent-interface
Network Must be able to access https://ima.qq.com

What gets installed

After installation, DSH must be restarted to load the new plugin. The plugin is installed via plugin_manager’s install_bundle. The source is the .tgz package in the release or the local source code directory.

Method A, give the .tgz in the release to the AI in DSH (easiest):

请帮我安装本地插件:<路径>\dsh-ima-kb-panel-2.7.0.tgz
用 plugin_manager 的 install_bundle 安装,装完告诉我是否需要重启。

Method B, call the tool yourself:

plugin_manager(action="install_bundle", target="<tgz 的绝对路径>")

Method C, install from source code directory (only when changing code):

plugin_manager(action="install_bundle", target="<本仓库目录的绝对路径>")

Installing from a directory is a soft link (link:), DSH will report restart-required; installing with .tgz is a real copy, making hot-reload smoother. After changing code, re-run pnpm pack then install.

Method D, upgrade from GitHub (recommended when switching computers or upgrading versions): Each v* tag is automatically packaged and released by Actions. The download address is github.com/how8088/dsh-ima-kb-panel/releases. Download the latest dsh-ima-kb-panel-<version>.tgz, then in DSH start a new chat:

请用 plugin_manager 安装本地插件:<tgz 完整路径>

Restart DSH (or refresh the page) to finish. The repository is public, no login required.

Two things to do on first run

Besides the plugin itself, when switching to a new computer, there are two things to handle once:

Item How to do it
ima Credentials Copy ~/.config/ima/client_id and api_key to the same path on the new computer, do not enter the repository
AGENTS.md linkage segment Append the content of docs/AGENTS-联动段.md to ~/.dsh/AGENTS.md (from v2.3.0, this document is installed with the package, located in docs/ under the plugin directory)

The two skills (market-research / ima-kb) have been automatically installed to ~/.dsh/skills/ since v2.2.0; if they exist, they won’t be overwritten, no manual copying needed. The desktop version (Electron) has not required manual import changes since v2.3.0: when the plugin starts, it first parses @deepseek-ai/dsh-tools / @deepseek-ai/schemastery by bare package name, and if that fails, it reads from app.asar by inferring the installation directory from process.execPath. Changing the installation path also requires no code modification.

Where to put credentials

Default two files:

~/.config/ima/client_id     ← Client ID
~/.config/ima/api_key       ← API Key

On Windows it is C:\Users\<你>\.config\ima\. One line per file, no quotes, no extra spaces. You can also use environment variables IMA_CLIENT_ID / IMA_API_KEY, which have higher priority than files. The “First Run” interface in the panel will directly display these two absolute paths.

Verify usability

  1. Restart DSH, the left icon bar should appear with a book + magnifying glass icon;
  2. Click it, the left side should list all notes (not just 20), the header displays N notes · M chars; if the body is still loading in the background, it shows “Loading body N/M” with a progress bar;
  3. Ask in the conversation: “Check my knowledge base: how did I explain position management?” The AI should call kb_search and reference the original text.

If the panel shows “ima account not connected yet”, it means the credentials are not set up correctly; go back to the previous section and check the paths.

IV. Configuration

Change in Settings → Plugins → ima Knowledge Base Panel, or directly modify the profile’s cordis.patch.yml:

- id: ima-kb-panel
  name: 'dsh-ima-kb-panel'
  config:
    credentialsDir: 'D:/ima-creds'      # 凭证目录换地方
    titleFilter: '雪球,宏观'             # 只纳入标题含这些词的笔记
    maxNotes: 200
    contentTtlMinutes: 360
Config Item Default Effect
credentialsDir Empty (= ~/.config/ima) Credentials directory
baseUrl https://ima.qq.com Interface root address, generally no need to change
clientIdEnv IMA_CLIENT_ID Which environment variable to read client_id from
apiKeyEnv IMA_API_KEY Which environment variable to read api_key from
maxNotes 500 Maximum number of notes to include (1–500, plugin auto-paginates; list_note has a single-page limit of 20, plugin will paginate until is_end)
contentTtlMinutes 10080 Maximum retention period for body text on disk (minutes); whether to re-fetch depends on modify_time
cacheDir Empty (= ~/.dsh/cache/ima-kb-panel) Body cache directory, fill - to disable writing to disk
titleFilter Empty Only show notes containing these words in the title, comma-separated
skillsDir Empty (= ~/.dsh/skills) Where to install bundled skills
autoInstallSkills on Automatically install bundled skills at startup (skip if already exist); fill off to disable
autoWarm off Whether to automatically pull all note body text locally. Default off: only fetch when manually clicking “⋯ → Cache All Body”; fill on to restore background auto-warmup at startup/search

V. Typical Usage

Browse

Click the left book icon, switch to the “Notes” tab to browse by category, use the top search box to search for content; switch to the “Knowledge Base” tab to select a library, enter the directory, find files by filename, and download the original text after entering file details. The entire browsing process stays out of the panel and does not enter the context.

Fetching content in conversation

If you are unsure of the original wording, use tokenized search to find candidate notes first:

kb_find(query="减仓的理由", start=0)

After getting the candidate note_id, read the body by offset:

kb_read(note_id="xxx", offset=0, limit=6000)

When literal positioning is needed, use substring search, which returns segments with character offsets, and you can directly take the offset to continue reading:

kb_search(query="止损", limit=8)

Directory and filename search for personal knowledge bases:

kb_space_list()
kb_space_browse(kb_id="xxx", folder_id=null, limit=50)
kb_space_search(kb_id="xxx", query="年报", limit=50)

Pulling the entire library body locally

After the first installation, click “⋯ → Cache All Body” in the panel header, and the progress is displayed in the panel header. After the warmup completes, it writes to disk cache; subsequent restarts of DSH are instant, only needing to supplement the few notes where modify_time changed. For the personal knowledge base, the entire tree cache goes via GET /ima-kb/api/kb-warm?kb=<kb_id>, blocking until complete; progress snapshots can be seen via GET /ima-kb/api/kb-warm-status.

Local HTTP Interface

All interfaces used by the panel require the browser’s same-origin session; unauthorized requests return 401/403. Common ones: GET /ima-kb/api/state to see connection diagnostics (whether configured, credentials source, paths, filter words, note count, warmup progress); GET /ima-kb/api/notes to fetch all notes list; GET /ima-kb/api/search?q=&limit= to search; GET /ima-kb/api/kb-files?kb=&folder=&cursor= to fetch directory content with breadcrumbs; GET /ima-kb/api/kb-raw?media_id=&title= to proxy download signed originals. When errors occur in the panel, the real HTTP status and server message are displayed, rather than a generic “No permission”.

VI. Applicable Scenarios and Notes

Suitable for those who use ima as a personal repository with a large amount of notes (dozens to hundreds of notes, hundreds of thousands of words) and do not want to burn context every time they browse. Also suitable for scenarios where the AI needs to reference knowledge base content from raw fragments, because the tools return fragments with offsets, allowing the model to decide whether to read or which segment to read.

A few notes:

  • The plugin does not modify any content on the ima side, but runs with the permissions of the current DSH process, so you should check the source code and license before installing (this repository is MIT).
  • Do not use MCP’s mcp__ima-kb__get_note_content to read large notes: no pagination, returns the whole thing at once, longest observed was 548,000 characters.
  • Shared knowledge bases are not cached: subscribed / joined library file counts can reach tens or hundreds of thousands; the plugin reads them all online, so do not expect offline availability.
  • Files in the body cache directory are local temporary data; changing cacheDir to - means no writing to disk.
  • Star count is currently 0, the ecosystem is relatively new; if encountering version differences, refer to README and package.json.

Conclusion

The value of this plugin is not in having many features, but in filling two specific gaps: the pagination missing from get_doc_content, and the act of paying the context cost just to glance at a table of contents. The former is filled by the offset pagination of kb_search + kb_read, and the latter is solved by the sidebar panel and local cache. If your note volume is large and the body needs to be frequently referenced, it is worth installing and trying it out following the steps above.

Directory page: https://www.skillhub.cn/plugins/how8088/dsh-ima-kb-panel
Repository: https://github.com/how8088/dsh-ima-kb-panel

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye