-
Notifications
You must be signed in to change notification settings - Fork 397
Opencode support #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opencode support #390
Conversation
- Implemented OpenCode CLI installation and authentication status check. - Added new route for OpenCode status in setup routes. - Updated HttpApiClient to include method for fetching OpenCode status. - Enhanced system paths to include OpenCode's default installation directories. This commit introduces functionality to check the installation and authentication status of the OpenCode CLI, improving integration with the overall system.
- Added OpenCode model selection to AddFeatureDialog and EditFeatureDialog. - Introduced ProfileTypeahead component for improved profile selection. - Updated model constants to include OpenCode models and integrated them into the PhaseModelSelector. - Enhanced planning mode options with new UI elements for OpenCode. - Refactored existing components to streamline model handling and improve user experience. This commit expands the functionality of the feature dialogs, allowing users to select and manage OpenCode models effectively.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @webdevcody, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the application's AI capabilities by integrating OpenCode as a new provider. This integration allows users to leverage a broader spectrum of AI models, including free-tier options and advanced models from AWS Bedrock, through a unified interface. The changes span across backend services for CLI interaction, new API endpoints for status checks, and a refactored, more intuitive user interface for model selection and configuration. The addition of a guided setup process and dedicated settings ensures a smooth onboarding and management experience for OpenCode users. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for the OpenCode provider, which is a significant addition enabling access to a wide range of models. The implementation is comprehensive, covering the backend provider, UI components for setup and configuration, and extensive unit tests. I've identified a critical issue in the opencode-status route that will cause incorrect authentication status to be reported. Additionally, there are a couple of high-severity issues in the provider implementation related to potential concurrency problems and error handling that should be addressed. The UI refactoring in the feature dialogs is a great improvement to the user experience. Overall, this is a solid contribution with a few key fixes needed.
| const status = await provider.detectInstallation(); | ||
|
|
||
| // Derive auth method from authenticated status and API key presence | ||
| let authMethod = 'none'; | ||
| if (status.authenticated) { | ||
| authMethod = status.hasApiKey ? 'api_key_env' : 'cli_authenticated'; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The detectInstallation() method on OpencodeProvider does not return authenticated or hasApiKey properties. Accessing status.authenticated and status.hasApiKey will result in undefined, leading to incorrect authentication status being reported to the UI.
The detectInstallation method in OpencodeProvider should be updated to gather and return this information, likely by inspecting the opencode auth files or environment variables, similar to how other providers handle authentication status checks.
| let toolUseIdCounter = 0; | ||
|
|
||
| /** | ||
| * Generate a unique tool use ID for tool calls without explicit IDs | ||
| */ | ||
| function generateToolUseId(): string { | ||
| toolUseIdCounter += 1; | ||
| return `opencode-tool-${toolUseIdCounter}`; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The toolUseIdCounter is a module-level global variable. If multiple executeQuery calls run concurrently, they will share this counter. This could lead to tool_use_id collisions if multiple concurrent tool calls are generated without an explicit call_id from the CLI, as the counter is not reset between queries.
To prevent this, the counter should be scoped to each individual executeQuery call. A good approach would be to make toolUseIdCounter an instance property of the OpencodeProvider class and reset it to 0 at the beginning of each executeQuery call.
| case 'tool-result': { | ||
| const resultEvent = openCodeEvent as OpenCodeToolResultEvent; | ||
|
|
||
| const content: ContentBlock[] = [ | ||
| { | ||
| type: 'tool_result', | ||
| tool_use_id: resultEvent.call_id, | ||
| content: resultEvent.output, | ||
| }, | ||
| ]; | ||
|
|
||
| return { | ||
| type: 'assistant', | ||
| session_id: resultEvent.session_id, | ||
| message: { | ||
| role: 'assistant', | ||
| content, | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool-result event handler assumes resultEvent.call_id will always be present. However, the OpenCodeToolResultEvent interface defines call_id as optional. If the opencode CLI emits a tool-result without a call_id, the resulting tool_result content block will have an undefined tool_use_id. This can break the tool use flow, especially if the corresponding tool-call had a generated ID.
The provider should handle this case, perhaps by maintaining a queue of expected tool results if the CLI doesn't guarantee a call_id on results.
| * | ||
| * Extends CliProvider with OpenCode-specific configuration: | ||
| * - Event normalization for OpenCode's stream-json format | ||
| * - Model definitions for anthropic, openai, and google models |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation comment here is outdated. It mentions support for "anthropic, openai, and google models", but the getAvailableModels implementation lists models from Anthropic, DeepSeek, Amazon, Meta, and Qwen via AWS Bedrock. Please update the comment to accurately reflect the models provided.
| * - Model definitions for anthropic, openai, and google models | |
| * - Model definitions for various providers like Anthropic, DeepSeek, etc. via AWS Bedrock | |
- Added OpenCode authentication status check to the OpencodeProvider class. - Introduced OpenCodeAuthStatus interface to manage authentication states. - Updated detectInstallation method to include authentication status in the response. - Created ProvidersSetupStep component to consolidate provider setup UI, including Claude, Cursor, Codex, and OpenCode. - Refactored setup view to streamline navigation and improve user experience. - Enhanced OpenCode CLI integration with updated installation paths and authentication checks. This commit enhances the setup process by allowing users to configure and authenticate multiple AI providers, improving overall functionality and user experience.
- Updated unit tests for OpenCode provider to include new authentication indicators. - Refactored ProvidersSetupStep component by removing unnecessary UI elements for better clarity. - Improved board background persistence tests by utilizing a setup function for initializing app state. - Enhanced settings synchronization tests to ensure proper handling of login and app state. These changes improve the testing framework and user interface for OpenCode integration, ensuring a smoother setup and authentication process.
- Refactored ProvidersSetupStep component to improve the UI and streamline provider status checks for Claude, Cursor, Codex, and OpenCode. - Introduced auto-verification for CLI authentication and improved error handling for authentication states. - Added loading indicators for provider status checks and enhanced user feedback for installation and authentication processes. - Updated setup store to manage verification states and ensure accurate representation of provider statuses. These changes enhance the user experience by providing clearer feedback and a more efficient setup process for AI providers.
No description provided.