代码知识工具
一种使用向量嵌入的代码库知识管理工具。此工具使用高级嵌入技术帮助维护和查询有关代码库的知识。
建造和安装
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/目录中创建两个文件:
- code_knowledge_tool-0.1.0-py3-none-any.whl(用于安装的轮文件)
- code_knowledge_tool-0.1.0.tar.gz(源代码分发)
2.安装软件包
先决条件
- 确保Ollama已安装并运行:
# Install Ollama (if not already installed)
curl https://ollama.ai/install.sh | sh
# Start Ollama service
ollama serve- 安装软件包:
选项1:从车轮文件安装(建议使用)
# 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]"与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}"
}
}
}
}房间代码:
# 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。
特性
- 代码知识的本地向量存储
- 使用Olama高效生成嵌入物
- 支持多种文件类型
- 上下文感知代码理解
- 通过MCP与RooCode和Cline集成
- 基于RAG的上下文增强
- 持久知识存储
需求
- Python 3.8或更高版本
- Ollama服务在本地运行
- 用于矢量运算的chromadb
发展
运行测试
该项目遵循集成优先的测试方法,重点关注端到端功能和MCP合同合规性。测试套件包括:
- 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
- 安装绳线:
pip install twine - 上传您的分发:
twine upload dist/*
但是,目前请使用上述本地构建和安装方法。
许可证
MIT许可证
