How to Build an AI Knowledge Base Connection Environment from Scratch: A Practical Guide
This guide walks through connecting a local knowledge base to a self-hosted AI agent runtime. It covers runtime version management with Node and pnpm, dependency build approval, installing a knowledge base plugin, layered configuration overrides, and migrating existing skills, along with troubleshooting tips for common integration issues.
1. Background and Overall Approach
As intelligent coding tools become part of everyday development workflows, a common need is to let these tools actually “see” locally stored knowledge assets instead of staying confined to an isolated chat window. The original scenario can be abstracted as follows: a user had already connected a local notes library through an intelligent coding tool, but wanted higher configurability and more runtime freedom. The goal was to replace the original setup with a self-hostable, extensible agent runtime framework (referred to below as the “agent runtime framework”) while reusing the existing knowledge organization and capability plugins.
The technical goals span three layers:
- Runtime layer: a stable script runtime environment with package management support.
- Integration layer: mounting a local notes directory as a readable and writable data source through a plugin mechanism.
- Capability layer: migrating existing “knowledge evolution” skills into the new framework’s skill directory to maintain capability continuity.
The core of this practice is not any specific product, but a general engineering method: environment isolation, explicit dependency authorization, layered configuration overrides, and pluggable capabilities. Once you master this method, you can migrate smoothly between different toolchains.
2. Preparing the Runtime Environment: Version Management First
Installing a script runtime globally can easily cause version conflicts and cross-project contamination. A more reliable approach is to introduce a version manager and bind the runtime version to a specific project.
First, install a Node version manager (on Windows, an installer is usually provided, and you just click through the steps). After installation, open the command prompt and confirm the version manager itself is available:
nvm version
Second, install and switch to a specific LTS version to avoid the uncertainty of “latest”:
nvm install 22.22.3nvm use 22.22.3node -v # verify it took effect
Third, enable the global package management capability and install the package manager:
npm install -g pnpmpnpm -v
Engineering tip: write these version numbers into the project documentation and standardize them across the team. Version drift is the primary source of “works on my machine” problems.
3. Installing the Agent Runtime Framework and Approving Dependencies
Create a separate working directory to avoid interference with existing projects:
mkdir D:\source\agent-knowledge-testcd D:\source\agent-knowledge-testpnpm init
Then install the framework itself. If two lines of red output appear during installation, this is usually not a failure. Instead, the package manager does not automatically run dependency install scripts (postinstall-type scripts) by default due to security policy. This is an industry-standard secure default that prevents malicious packages from executing arbitrary code during installation.
There are two ways to handle this:
- Interactive approval: follow the prompt to select which dependencies to allow:
pnpm approve-builds
Select items as needed in the list (select all and press Enter to continue), and only allow dependencies you have confirmed are trusted;
- Or explicitly declare the list of packages allowed to build in the project configuration,固化ing the authorization into the repository for team reproducibility.
Start the web interface:
pnpm exec dsh web
After the command runs, a browser opens automatically. At this point, the framework has basic conversation and task orchestration capabilities, but is not yet connected to any external data source.
4. Connecting the Local Knowledge Base Plugin
First stop the service (press Ctrl + C in the command line window), then install the knowledge base plugin:
pnpm exec dsh plugin --profile web add dsh-obsidian
After the plugin is installed, the key step is configuration override. The runtime framework generally uses a layered structure of “base configuration + patch override.” User customizations are written into a profile-level patch file to avoid being overwritten during upgrades. The configuration file is usually located in a hidden configuration directory under the user directory:
notepad C:\Users\<your-username>\.dsh\profiles\web\cordis.patch.yml
Replace the plugin placeholder configuration with actual parameters:
id: obsidianconfig:vaultPath: 'D:\source\agent-knowledge-test'useCli: false
Parameter descriptions:
vaultPath: the root directory of the local knowledge base. An absolute path is recommended to avoid resolution failures when the working directory changes;useCli: whether to read and write through an external command line. When disabled, the plugin operates files directly internally, resulting in a shorter path and fewer errors.
After restarting the service, create a test note in a newly opened command line window, then return to the chat interface and use a prompt to verify the reading result. The verification should cover three types of operations: reading an existing note, creating a new note, and answering questions based on note content. If all three pass, the integration layer is working.
It is recommended to keep the directory structure consistent with the original knowledge base so that skills and prompts can be reused without rewriting:
D:\source\agent-knowledge-test\├── 00-Inbox\├── 10-Notes\└── .dsh\└── skills\
5. Skill Migration and Capability Reuse
Create a skill directory in the framework and copy the existing skills over as a whole:
mkdir D:\source\agent-knowledge-test\.dsh\skillsxcopy "C:\Users\<your-username>\.workbuddy\skills\obsidian-knowledge-evolution" ^"D:\source\agent-knowledge-test\.dsh\skills\obsidian-knowledge-evolution\" /E /I /Y
After migration, check three things: whether the skill manifest file is correctly recognized, whether paths referenced inside the skill are still absolute paths, and whether external commands the skill depends on are available in the current environment. If a skill contains hard-coded paths, change them to relative paths or read them from configuration.
6. Common Issues and Best Practices
- Plugin not taking effect: first confirm whether the patch file path matches the profile name and whether the indentation follows YAML conventions;
- No read/write permission: check directory permissions and path casing. On Windows, use drive-letter absolute paths consistently;
- Configuration lost after upgrade: put all customizations into the patch file and do not modify the base configuration;
- Dependency build warnings: only allow trusted dependencies and share the same authorization list within the team;
- Maintainability: write environment preparation, plugin installation, configuration, and verification steps into scripts or documentation and put them under version control.
7. Summary
The entire chain comes down to three things: using a version manager to lock the runtime, using a plugin to turn the local knowledge base into a readable and writable data source, and using the skill directory to carry over existing capabilities. Proceed in the order of environment, installation, configuration, verification, and migration, and any failed step can be located quickly. If stronger retrieval capability is needed later, you can layer general capabilities such as vector retrieval or log monitoring on top of the same framework without replacing the entire runtime environment.
