原始内容
OpenCode
Table of Contents
About
OpenCode is an intelligent coding assistant plugin for JetBrains IDEs that integrates AI-powered development tools directly into your IDE. It provides a seamless terminal-like interface for interacting with AI models, managing coding sessions, and enhancing your development workflow.
Why OpenCode?
- Native Integration: Works seamlessly within your JetBrains IDE
- Session Management: Organize your AI interactions with multiple sessions
- Context-Aware: Automatically includes file paths and project context
- Flexible Interface: Choose between tool window or editor tab views
- Keyboard-First: Designed for efficiency with comprehensive keyboard shortcuts
Features
- AI Terminal Interface: Interactive terminal-like interface for AI coding assistance
- Multi-Session Support: Create and manage multiple coding sessions
- File Context Integration: Quickly add file paths to your AI conversations with keyboard shortcuts
- Flexible Views: Open OpenCode in a tool window or as an editor tab
- Custom File System: Virtual file system for managing AI conversation files
- Smart Editor: Specialized editor for
.opencodefiles - Cross-Platform: Works on Windows, macOS, and Linux
Getting Started
Prerequisites
- JetBrains IntelliJ IDEA 2025.3 or compatible IDE
- Java 21 or higher
Installation
From JetBrains Marketplace (Coming Soon)
- Open your JetBrains IDE
- Go to
Settings/Preferences→Plugins→Marketplace - Search for "OpenCode"
- Click
Installand restart your IDE
Manual Installation
- Download the latest release from Releases
- Open your IDE and go to
Settings/Preferences→Plugins→⚙️→Install Plugin from Disk - Select the downloaded
.zipfile - Restart your IDE
Building from Source
# Clone the repository
git clone https://github.com/yourusername/opencode-jb.git
cd opencode-jb
# Build the plugin
./gradlew build
# The plugin will be available in build/distributions/
Usage
Quick Start
Open OpenCode Terminal:
- Press
Ctrl+Esc(Windows/Linux) or⌘+Esc(macOS) - Or go to
Tools→OpenCode→Open OpenCode
- Press
Add File Context:
- Right-click in any file editor
- Select
Add Filepath to OpenCode - Or press
Ctrl+Alt+K(Windows/Linux) or⌘+⌥+K(macOS)
Manage Sessions:
- Press
Ctrl+Shift+O(Windows/Linux) or⌘+⇧+O(macOS) to list sessions - Press
Ctrl+Shift+N(Windows/Linux) or⌘+⇧+N(macOS) to create a new session
- Press
Keyboard Shortcuts
| Action | Windows/Linux | macOS |
|---|---|---|
| Open OpenCode | Ctrl+Esc |
⌘+Esc |
| Add File to Context | Ctrl+Alt+K |
⌘+⌥+K |
| New Session | Ctrl+Shift+N |
⌘+⇧+N |
| List Sessions | Ctrl+Shift+O |
⌘+⇧+O |
| Toggle Tool Window | Alt+Shift+W |
⌥+⇧+W |
Session Management
OpenCode supports multiple sessions to help organize your AI interactions:
- Create Session: Use the "New Session" action to start a fresh conversation
- Switch Sessions: Use "List Sessions" to view and switch between active sessions
- Session Persistence: All sessions are automatically saved and restored
Development
Project Structure
opencode-jb/
├── src/
│ ├── main/
│ │ ├── kotlin/com/opencode/
│ │ │ ├── actions/ # IDE actions
│ │ │ ├── api/ # API clients
│ │ │ ├── editor/ # Custom editors
│ │ │ ├── icons/ # Icon resources
│ │ │ ├── model/ # Data models
│ │ │ ├── services/ # Core services
│ │ │ ├── toolwindow/ # Tool window UI
│ │ │ ├── ui/ # UI components
│ │ │ ├── utils/ # Utilities
│ │ │ └── vfs/ # Virtual file system
│ │ └── resources/
│ │ ├── icons/
│ │ └── META-INF/
│ └── test/
│ ├── kotlin/ # Unit tests
│ └── resources/ # Test resources
├── build.gradle.kts # Build configuration
└── gradle.properties # Project properties
Testing
Run all tests:
./gradlew test
Run a specific test class:
./gradlew test --tests 'com.opencode.YourTestClass'
Code Coverage
The project uses Kover for code coverage analysis.
# Generate coverage report
./gradlew koverHtmlReport
# View report at: build/reports/kover/html/index.html
Current coverage threshold: 35% (see build.gradle.kts for configuration)
Contributing
We welcome contributions! Please see our Contributing Guidelines for details on:
- Code style and conventions
- Testing requirements
- Pull request process
- Development setup
Quick Contribution Steps
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
Made with ❤️ by the OpenCode team