Skip to content

feat: include new image opencode #14

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

Merged
merged 2 commits into from
Jun 20, 2025
Merged

feat: include new image opencode #14

merged 2 commits into from
Jun 20, 2025

Conversation

tito
Copy link
Member

@tito tito commented Jun 20, 2025

User description

Summary

This PR add a new image for supporting opencode


PR Type

Enhancement


Description

  • Add Opencode AI integration for Cubbi

  • Configure API keys and model settings

  • Support MCP server integration

  • Provide containerized environment with Node.js


Changes walkthrough 📝

Relevant files
Enhancement
opencode_plugin.py
Implement Opencode plugin for configuration management     

cubbi/images/opencode/opencode_plugin.py

  • Implements Opencode-specific plugin for Cubbi initialization
  • Handles API key configuration for multiple providers (Anthropic,
    Google, OpenAI, OpenRouter)
  • Manages user configuration files and directories with proper
    permissions
  • Integrates with MCP servers through configuration
  • +255/-0 
    Dockerfile
    Create Docker image for Opencode environment                         

    cubbi/images/opencode/Dockerfile

  • Creates Python 3.12 based Docker image for Opencode
  • Installs Node.js v22.16.0 and the opencode-ai npm package
  • Sets up initialization system with cubbi_init.py
  • Configures environment with necessary tools and dependencies
  • +64/-0   
    Documentation
    README.md
    Document Opencode image usage and configuration                   

    cubbi/images/opencode/README.md

  • Documents the Opencode image features and configuration
  • Lists all supported environment variables
  • Provides build and usage instructions
  • Explains MCP integration variables
  • +55/-0   
    Configuration changes
    cubbi_image.yaml
    Define Opencode image configuration                                           

    cubbi/images/opencode/cubbi_image.yaml

  • Defines image metadata including name, description, and version
  • Specifies initialization commands
  • Configures volume mounting for the application directory
  • +18/-0   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @pr-agent-monadical
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 Security concerns

    API key handling:
    The code stores API keys in a JSON file (auth.json). While the code does set proper permissions (0o600) on line 135, there's still a risk if the container is compromised. Consider using a more secure secret management solution or environment variables that don't persist to disk.

    ⚡ Recommended focus areas for review

    Error Handling

    The plugin catches FileExistsError but then has a pass statement, which might hide issues. The error is caught but no action is taken, and the code continues as if directory creation was successful.

    except FileExistsError:
        # Directory already exists, which is fine
        pass
    Path Mismatch

    The Dockerfile copies files to /cubbi/ but the entrypoint references /cubbi/cubbi_init.py, while cubbi_image.yaml references /cubbi-init.sh and /entrypoint.sh which don't appear to exist in the image.

    COPY cubbi_init.py /cubbi/cubbi_init.py
    COPY opencode_plugin.py /cubbi/opencode_plugin.py
    COPY cubbi_image.yaml /cubbi/cubbi_image.yaml
    COPY init-status.sh /cubbi/init-status.sh
    RUN chmod +x /cubbi/cubbi_init.py /cubbi/init-status.sh
    Security Risk

    Using a specific Node.js version (22.16.0) without a mechanism for updates could lead to security vulnerabilities if this version has known security issues in the future.

    curl -fsSL https://nodejs.org/dist/v22.16.0/node-v22.16.0-linux-x64.tar.gz -o node.tar.gz && \
    tar -xf node.tar.gz -C /opt/node --strip-components=1 && \
    rm node.tar.gz

    Comment on lines +8 to +9
    pre_command: /cubbi-init.sh
    command: /entrypoint.sh
    Copy link
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: The init commands in cubbi_image.yaml reference /cubbi-init.sh and /entrypoint.sh, but these files don't appear to be created or copied in the Dockerfile. This will cause initialization failures. [possible issue, importance: 9]

    Suggested change
    pre_command: /cubbi-init.sh
    command: /entrypoint.sh
    init:
    pre_command: /cubbi/cubbi_init.py
    command: tail -f /dev/null

    Comment on lines +51 to +65
    def _ensure_user_config_dir(self) -> Path:
    """Ensure config directory exists with correct ownership"""
    config_dir = self._get_user_config_path()

    # Create the full directory path
    try:
    config_dir.mkdir(parents=True, exist_ok=True)
    except FileExistsError:
    # Directory already exists, which is fine
    pass
    except OSError as e:
    self.status.log(
    f"Failed to create config directory {config_dir}: {e}", "ERROR"
    )
    return config_dir
    Copy link
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: The _ensure_user_config_dir method returns config_dir even after logging an error, which could lead to subsequent operations on a non-existent directory. Consider raising an exception or implementing proper error handling. [possible issue, importance: 7]

    Suggested change
    def _ensure_user_config_dir(self) -> Path:
    """Ensure config directory exists with correct ownership"""
    config_dir = self._get_user_config_path()
    # Create the full directory path
    try:
    config_dir.mkdir(parents=True, exist_ok=True)
    except FileExistsError:
    # Directory already exists, which is fine
    pass
    except OSError as e:
    self.status.log(
    f"Failed to create config directory {config_dir}: {e}", "ERROR"
    )
    return config_dir
    def _ensure_user_config_dir(self) -> Path:
    """Ensure config directory exists with correct ownership"""
    config_dir = self._get_user_config_path()
    # Create the full directory path
    try:
    config_dir.mkdir(parents=True, exist_ok=True)
    except FileExistsError:
    # Directory already exists, which is fine
    pass
    except OSError as e:
    self.status.log(
    f"Failed to create config directory {config_dir}: {e}", "ERROR"
    )
    raise RuntimeError(f"Failed to create config directory: {e}")
    # Set ownership for the directories
    config_parent = config_dir.parent
    if config_parent.exists():
    self._set_ownership(config_parent)
    if config_dir.exists():
    self._set_ownership(config_dir)
    return config_dir

    @tito tito merged commit 5fca51e into main Jun 20, 2025
    5 of 6 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant