代码知识工具
一个使用向量嵌入的代码库知识管理工具。此工具使用高级嵌入技术,帮助您维护和查询代码库知识。
构建和安装
1. 构建包
首先,您需要构建分发文件:
# Clone the repository
git clone https://github.com/yourusername/code-knowledge-tool.git
cd code-knowledge-tool
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate
# Install build tools
python -m pip install --upgrade pip build
# Build the package
python -m build
这将在 dist/ 目录中创建两个文件:
2.安装软件包
先决条件
确保 Ollama 已安装并正在运行:
# Install Ollama (if not already installed)
curl https://ollama.ai/install.sh | sh
# Start Ollama service
ollama serve
安装软件包:
选项 1:从 wheel 文件安装(推荐使用)
# Navigate to where you built the package
cd /path/to/code_knowledge_tool
# Install from the wheel file
pip install dist/code_knowledge_tool-0.1.0-py3-none-any.whl
选项 2:以可编辑模式安装(推荐用于开发)
如果您想修改该工具或为其开发做出贡献,那么此选项是最好的:
# Assuming you're already in the code-knowledge-tool directory
# and have activated your virtual environment
# Install in editable mode with development dependencies
pip install -e ".[dev]"
Related MCP server: LanceDB MCP Server
与 RooCode/Cline 集成
将 MCP 配置复制到您的设置中:
对于 Cline (VSCode):
# Open the settings file
open ~/Library/Application\ Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
添加此配置:
{
"mcpServers": {
"code_knowledge": {
"command": "python",
"args": ["-m", "code_knowledge_tool.mcp_tool"],
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
}
}
}
对于 RooCode:
# Open the settings file
open ~/Library/Application\ Support/RooCode/roocode_config.json
添加与上面相同的配置。
重新启动 RooCode/Cline 以加载新工具。
用作记忆库和 RAG 上下文提供程序
此工具可用作项目的记忆库和 RAG 上下文提供程序。设置方法如下:
将提供的模板复制到您的项目中:
cp clinerules_template.md /path/to/your/project/.clinerules
根据项目需求定制 .clinerules 中的规则和模式
该模板包含以下方面的全面说明:
知识库管理
基于 RAG 的开发工作流程
代码质量指南
内存管理实践
有关完整配置和使用详情,请参阅 clinerules_template.md。
特征
要求
Python 3.8 或更高版本
Ollama 服务在本地运行
用于向量运算的 chromadb
发展
运行测试
该项目采用集成优先的测试方法,重点关注端到端功能和 MCP 合同合规性。测试套件包括:
MCP 合同测试
包构建测试
运行测试:
# Install test dependencies
pip install -e ".[dev]"
# Run all tests
pytest
# Run specific test suites
pytest tests/integration/test_mcp_contract.py -v # MCP functionality
pytest tests/integration/test_package_build.py -v # Installation verification
测试环境要求:
# Ensure Ollama is running
ollama serve
测试使用临时目录(test_knowledge_store),该目录会在测试运行之间自动清理。
有关测试策略和模式的更多详细信息,请参阅docs/中的文档。
未来分布
如果您想通过 pip 使用这个包(即pip install code-knowledge-tool ),您需要:
在PyPI上注册一个账户
安装 twine: pip install twine
上传你的发行版: twine upload dist/*
但是,目前请使用上面描述的本地构建和安装方法。
执照
MIT 许可证