# OpenCodeGUI-Visual-Studio **Repository Path**: DLGCY_Clone/OpenCodeGUI-Visual-Studio ## Basic Information - **Project Name**: OpenCodeGUI-Visual-Studio - **Description**: 适用于 Visual Studio 的开源 AI 编码助手,具有流式聊天、Roslyn 支持的项目上下文、多提供商支持、智能代码工具、差异预览和一键代码应用程序。(克隆自:https://github.com/NatanaelNunez/OpenCodeGUI-Visual-Studio) - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: https://github.com/NatanaelNunez/OpenCodeGUI-Visual-Studio - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-09 - **Last Updated**: 2026-06-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # OpenCode AI Assistant for Visual Studio OpenCode AI Assistant is an AI-powered coding extension for Visual Studio that brings modern AI workflows directly into the IDE. Built for developers working with .NET solutions, AI-assisted refactoring, debugging, code generation, and intelligent project-aware assistance. image --- ## Features ### AI Chat + Streaming - Real-time token-by-token streaming responses - Multi-session chat history with save/load - Dark-themed modern UI - Copy actions on any message ### Multi-Provider Support Supports multiple AI providers and OpenAI-compatible APIs: - OpenAI - Anthropic - OpenRouter - Ollama (local) - Google Gemini - Azure OpenAI - OpenCode Go / Zen - Custom OpenAI-compatible endpoints ### Project-Aware Context Integrated Visual Studio context awareness: - Active document content and selection - Current solution and project detection - Attached files and images as context - Roslyn-powered C# symbol parsing - SQLite solution-wide symbol index ### AI Tool System Built-in tool system for agent workflows: - `read_file` — Read any file from disk - `list_files` — List directory contents - `search_text` — Search text across files - `get_symbols` — Roslyn-based symbol analysis - `search_symbols` — SQLite-powered symbol search - `run_command` — Execute terminal commands - `git_status` — Git working tree status - `get_diagnostics` — VS Error List diagnostics - `build_index` — Index solution symbols into SQLite - `get_dependencies` — Class dependency graph ### Intelligent Code Editing - One-click apply generated code to files - File creation and modification with DTE integration - Multi-strategy apply engine (ProjectItems, Solution, Fallback) - HTML diff preview (LCS-based) - Undo/Redo snapshot system (100 backups, auto-cleanup) ### Roslyn + SQLite Indexing - Real C# semantic parsing via Microsoft.CodeAnalysis - Class, method, property, field, interface, enum discovery - Solution-wide symbol indexing in SQLite - Fast contextual symbol search - Dependency analysis (imports, inheritance, method calls) --- ## Requirements - Visual Studio 2022+ (17.14 or newer, Community/Professional/Enterprise) - .NET Framework 4.7.2 targeting pack - Internet connection for cloud AI providers - API key for your selected provider --- ## Installation ### From Visual Studio Marketplace Install directly from the Visual Studio Marketplace (coming soon). ### Manual VSIX Installation 1. Download the latest `.vsix` release 2. Double-click the `.vsix` file, or run: ``` VSIXInstaller.exe OpenCodeGUI.vsix ``` 3. Restart Visual Studio ### Build from Source ```bash dotnet build OpenCodeGUI.slnx -c Release ``` The VSIX will be generated at: ``` OpenCodeGUI\bin\Release\net472\OpenCodeGUI.vsix ``` --- ## Quick Start 1. Open any solution in Visual Studio — the OpenCode panel opens automatically 2. Click the gear icon (⚙) to open Settings 3. Configure your API endpoint URL and API key 4. Click **Test** to verify the connection, then **Save** 5. Start typing in the chat input and press `Ctrl+Enter` to send ### Agent Actions When the AI responds with code blocks, you'll see action buttons: | Format | Button | Action | |---|---|---| | ```` ```lang:path\to\file.cs ```` | [Apply] | Writes code to the specified file | | ```` ```tool:toolname ```` | Auto | Executes the tool and returns results | | ```` ```shell command ```` | [Run] | Executes a terminal command | --- ## Configuration Available settings accessible via the gear icon: - **API Endpoint URL** — Base URL for your AI provider - **API Key** — Encrypted and stored securely via DPAPI - **Model** — Select from available models - **Build/Plan mode** — Switch between direct code and planning-first workflows ### Supported Providers | Provider | Base URL | Models | |---|---|---| | OpenCode Go | `https://opencode.ai/zen/go` | deepseek-v4-pro, kimi-k2.5, qwen3.5-plus, glm-5 | | OpenCode Zen | `https://opencode.ai/zen` | qwen-3-coder-480b, kimi-k2, glm-4 | | OpenAI | `https://api.openai.com` | gpt-4o, gpt-4o-mini, o3, o4-mini | | Anthropic | `https://api.anthropic.com` | claude-sonnet-4, claude-haiku-3-5 | | OpenRouter | `https://openrouter.ai/api/v1` | Multiple models | | Google Gemini | `https://generativelanguage.googleapis.com/v1beta` | gemini-2.5-pro, gemini-2.5-flash | | Azure OpenAI | `https://YOUR_RESOURCE.openai.azure.com` | gpt-4o, gpt-4o-mini | | Ollama | `http://localhost:11434` | llama3, codellama, deepseek-coder | --- ## Architecture ### Core Components - **Visual Studio VSIX extension** — ToolWindow, DTE integration, command registration - **Roslyn semantic parser** — C# syntax tree analysis via Microsoft.CodeAnalysis - **SQLite symbol indexer** — Fast code symbol search across solutions - **AI provider abstraction layer** — OpenAI-compatible HTTP client with streaming - **Streaming chat engine** — Token-by-token response with 80ms throttled UI updates - **Diff engine** — LCS-based line diff with HTML preview - **Undo/Redo snapshot system** — File-level rollback with temp backups - **Tool orchestration system** — 10+ tools for file, search, git, shell operations ### Project Structure ``` OpenCodeGUI/ ├── OpenCodeGUIPackage.cs — VS Package entry point, DTE, command registration ├── OpenCodeToolWindow.cs — ToolWindowPane host ├── OpenCodeToolWindowControl.* — Main UI (XAML + code-behind) ├── Services/ │ ├── OpenCodeApiService.cs — HTTP client for OpenAI-compatible APIs │ ├── SettingsService.cs — Encrypted settings persistence │ ├── SessionManager.cs — Chat session save/load │ ├── ToolSystem.cs — Agent tool execution engine │ ├── RoslynParser.cs — C# semantic code analysis │ ├── CodeIndexer.cs — SQLite-based symbol index │ ├── DiffEngine.cs — LCS text diff │ ├── UndoManager.cs — File snapshot rollback │ └── DeepContextService.cs — VS solution/project context ├── Dialogs/ │ ├── SettingsDialog.* — API configuration dialog │ └── SessionHistoryDialog.* — Session browser └── Models/ ├── ChatMessage.cs └── OpenCodeModel.cs ``` --- ## Current Status ### Stable Features - Chat + streaming (throttled, non-blocking) - One-click apply code changes to solution files - HTML diff preview - Undo/Redo snapshots - Roslyn C# symbol parsing - SQLite symbol indexing and search - Multi-provider support (9 providers) - Session persistence (save/load/delete) - File and image attachments - Tool system (10+ tools) - Plan/Build mode switch - Visual Studio DTE integration (active file, solution, project) - Dark-themed modern UI --- ## Known Issues - Some VSTHRD010 threading warnings in `DeepContextService` — safe to ignore (DTE access is already on UI thread) - DispatcherTimer (500ms) startup delay may need tuning on slower VS environments - SQLite index stores symbol metadata only (not embeddings) - Diagnostics tool is a stub — full Error List integration requires IVsErrorList API --- ## Roadmap Planned features for future releases: - Semantic retrieval engine (code embeddings) - Incremental file watcher indexing - Advanced multi-step agent workflows - Inline ghost text completions via IVsTextView - Context ranking and prioritization - Multi-file transactional apply - Diagnostics-aware auto-fixes via Error List - Terminal-aware agent execution - Persistent agent memory - MCP (Model Context Protocol) support --- ## Contributing Contributions, bug reports, and feature requests are welcome. --- ## License MIT License — see [LICENSE.md](LICENSE.md) --- ## Disclaimer OpenCode AI Assistant does not host or provide AI models. All requests are sent only to the provider configured by the user. API keys are encrypted and stored locally via Windows DPAPI.