AlperenCK/CodeLensAI

GitHub: AlperenCK/CodeLensAI

一款 Visual Studio 2022 扩展,通过连接本地 LLM 让开发者在 IDE 内即时分析代码,全程保障代码隐私不离开本机。

Stars: 0 | Forks: 0

# 🤖 CodeLens AI [![构建状态](https://github.com/your-org/CodeLensAI/actions/workflows/build.yml/badge.svg)](https://github.com/your-org/CodeLensAI/actions) [![VS Marketplace](https://img.shields.io/badge/VS%20Marketplace-CodeLens%20AI-blue)](https://marketplace.visualstudio.com/) [![许可证: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.txt) 将 Visual Studio 2022 连接到您的**本地 LLM**(Ollama、LM Studio、llama.cpp 或任何兼容 OpenAI 的 API),选择代码,描述您的问题,即可获得即时的 AI 驱动分析——无需离开 IDE,且**无需将您的代码发送到云端**。 ## ✨ 功能 | 功能 | 描述 | |---|---| | 🔌 **本地 LLM 支持** | 兼容 Ollama、LM Studio 或任何兼容 OpenAI 的 endpoint | | 📝 **编辑器集成** | 选择代码 → 右键点击 → “Analyze with CodeLens AI” | | 💬 **聊天面板** | 带有代码和问题输入的专用工具窗口 | | ⚙️ **持久化设置** | Endpoint URL、模型名称、API key 保存至 VS Settings Store | | 🔒 **隐私至上** | 您的代码永远不会离开您的机器 | | ⚡ **速度快** | 非阻塞的 async 调用;可随时取消 | ## 🚀 快速开始 ### 前置条件 - Visual Studio 2022(v17.0 或更高版本) - .NET Framework 4.7.2+ - 正在运行的本地 LLM 服务器: - [Ollama](https://ollama.ai) — `ollama serve`(默认:`http://localhost:11434`) - [LM Studio](https://lmstudio.ai) — 启用本地服务器(默认:`http://localhost:1234`) - 任何兼容 OpenAI 的 API ### 安装 1. 从 [Releases](https://github.com/your-org/CodeLensAI/releases) 下载 `CodeLensAI.vsix` 2. 关闭 Visual Studio 3. 双击 `.vsix` 文件并按照安装程序提示操作 4. 重新打开 Visual Studio 2022 ### 配置 1. 转到 **Tools → Options → CodeLens AI → LLM Connection** 2. 设置您的 **Endpoint URL**(例如 `http://localhost:11434/v1`) 3. 设置您的 **Model Name**(例如 `codellama`、`deepseek-coder:6.7b`) 4. 点击 **OK** ### 使用说明 1. 在 Visual Studio 中**打开任何代码文件** 2. **选择**您想要分析的**代码** 3. 转到 **Tools → Analyze with CodeLens AI**(或使用编辑器上下文菜单) 4. **CodeLens AI** 面板将打开,并预填您选中的代码 5. **输入您的问题**(例如“What does this do?”、“Fix the bug”、“Add unit tests”) 6. 按 **▶ Analyze** 或 `Ctrl+Enter` ## 🏗️ 架构 ``` CodeLensAI/ ├── VSPackage.cs # AsyncPackage entry point ├── Commands/ │ └── AnalyzeCommand.cs # Editor command (grabs selected text) ├── ToolWindows/ │ ├── ChatWindow.cs # ToolWindowPane host │ ├── ChatWindowControl.xaml # WPF UI │ └── ChatWindowControl.xaml.cs # UI logic + LLM call orchestration ├── Options/ │ └── LlmOptions.cs # DialogPage (VS Settings Store) ├── Services/ │ └── LlmService.cs # HttpClient → OpenAI-compat /v1/chat/completions └── Models/ └── ChatMessage.cs # Request/response models (Newtonsoft.Json) ``` ### 支持的 LLM 模型(已测试) | 模型 | 提供商 | 推荐用途 | |---|---|---| | `codellama` | Ollama | 通用代码分析 | | `deepseek-coder:6.7b` | Ollama | 代码生成与修复 | | `qwen2.5-coder:7b` | Ollama | 多语言支持 | | `mistral` | Ollama | 解释与文档 | | 任何兼容 OpenAI 的模型 | LM Studio | 灵活 | ## 🔧 从源码构建 ``` git clone https://github.com/your-org/CodeLensAI.git cd CodeLensAI nuget restore CodeLensAI.sln msbuild CodeLensAI.sln /p:Configuration=Release # VSIX 输出:CodeLensAI/bin/Release/CodeLensAI.vsix ``` ### CI/CD 推送到 `main` → GitHub Actions 会进行构建,运行 Roslyn 代码质量分析,并上传 VSIX artifact。 打上 `v*.*.*` 标签 → 额外创建一个 GitHub Release 并附带 VSIX。 ## 📜 许可证 MIT © 2026 CodeLensAI Team
标签:LLM评估, Ollama, SOC Prime, Visual Studio 扩展, 代码分析, 凭证管理, 大语言模型 (LLM), 开发工具, 本地 AI