Skip to content

trry-hub/opencode-cline-mode

Repository files navigation

opencode-cline-mode

Cline-style plan and act workflow for OpenCode - Now with official Cline prompts!

npm version License: MIT

A plugin for OpenCode that brings authentic Cline experience to your AI coding sessions by dynamically fetching prompts from the official Cline repository. Separate planning from execution for more controlled and predictable development.

✨ Features

  • 🎯 Official Cline Prompts - Dynamically fetches the latest prompts from cline/cline repository
  • πŸ“¦ Plan Mode - Analyze and create detailed implementation plans without making changes (pure read-only)
  • ⚑ Act Mode - Execute approved plans step by step with progress tracking
  • πŸ”„ Automatic Tool Mapping - Seamlessly converts Cline tool names to OpenCode equivalents
  • πŸ›‘οΈ Smart Adaptation - Removes unsupported features and provides alternatives
  • πŸš€ Zero Config - Works out of the box with sensible defaults
  • πŸ”’ Strict Permission Control - Plan mode is truly read-only

What's New in v5.0

  • 🎯 Full Official Prompts: Now includes system-prompt/index.ts for complete official Cline prompt structure
  • πŸ“ Improved Plan Accuracy: Removed custom mode intros to let official Cline planning methodology work exactly as intended
  • πŸ”§ Minimal Overrides: Only adds OpenCode integration notes without overriding official prompt logic
  • βœ… Native Experience: Plan mode now matches native Cline behavior exactly
  • 🎯 YOLO Mode: Auto-approve plans and automatically switch to ACT MODE
  • πŸ“ Enhanced Plan Mode: Added needs_more_exploration parameter for iterative planning
  • πŸ”§ Better Tool Mapping: Fixed ask_followup_question mapping and improved tool organization
  • πŸ“Š State Management: Session-based state tracking for better workflow control

What's New in v4.0

  • πŸ”„ Simplified Workflow: Removed plan approval mechanism - switch directly from plan to act mode
  • πŸ“‹ Native Cline Behavior: No longer requires /approve-plan - just switch agents
  • 🧹 Code Cleanup: Removed unused plan status management

What's New in v3.0

  • Dynamic Prompt Fetching: Automatically fetches the latest prompts from Cline's official GitHub repository on startup
  • Tool Name Mapping: Intelligent conversion of Cline tool names (e.g., read_file β†’ read)
  • MCP Removal: Automatically removes MCP-related content not supported by OpenCode
  • Alternative Suggestions: Provides OpenCode alternatives for unsupported Cline features
  • Startup Validation: Ensures prompts are fetched successfully before plugin initialization

πŸ“¦ Installation

From npm (Recommended)

npm install -g opencode-cline-mode

Then add to your OpenCode config (~/.config/opencode/opencode.json):

{
  "plugin": ["opencode-cline-mode"]
}

From local files

Clone this repository and symlink to your OpenCode plugins directory:

git clone https://github.com/trry-hub/opencode-cline-mode.git
cd opencode-cline-mode
npm install
npm run build
ln -s $(pwd) ~/.config/opencode/plugins/opencode-cline-mode

Important: When using local installation via symlink, do NOT add "opencode-cline-mode" to the plugin array.

πŸš€ Usage

This plugin registers two independent agents in OpenCode:

1. cline-plan Agent - Planning Mode

Start a new session with the plan agent:

opencode --agent cline-plan

Or switch to it in TUI by pressing Tab and selecting cline-plan.

In plan mode, the AI will:

  • βœ… Analyze your codebase
  • βœ… Create detailed step-by-step plans
  • βœ… Assess risks and suggest alternatives
  • ❌ NOT make any code changes
  • ❌ NOT execute any commands

2. cline-act Agent - Execution Mode

Start a new session with the act agent:

opencode --agent cline-act

Or switch to it in TUI by pressing Tab and selecting cline-act.

In act mode, the AI will:

  • βœ… Execute plans step by step
  • βœ… Make code changes as specified
  • βœ… Run verification commands
  • βœ… Report progress after each step

Typical Workflow

  1. Start with Planning (cline-plan):

    • Describe what you want to build
    • Review the detailed plan created by the AI
    • Ask for modifications if needed
  2. Switch to Execution (cline-act):

    • Press Tab and select cline-act
    • The AI implements the plan step by step
    • Watch as changes are made to your codebase

βš™οΈ Configuration

Optional Configuration File

Create ~/.config/opencode/opencode-cline-mode.json or .opencode/opencode-cline-mode.json in your project:

{
  "replace_default_agents": true,
  "default_agent": "cline-plan",
  "plan_model": null,
  "act_model": null,
  "plan_temperature": 0.1,
  "act_temperature": 0.3,
  "enable_execute_command": true,
  "yolo_mode": false,
  "enable_task_progress": false
}

Configuration Options

Option Type Default Description
replace_default_agents boolean true If true, removes OpenCode's default agents
default_agent string "cline-plan" Which agent to use by default
plan_model string null Model for cline-plan agent
act_model string null Model for cline-act agent
plan_temperature number 0.1 Temperature for plan mode (0-1)
act_temperature number 0.3 Temperature for act mode (0-1)
enable_execute_command boolean true Enable /start-act command
show_completion_toast boolean true Show toast notification when plan completes
yolo_mode boolean false Enable YOLO mode (auto-approve and auto-switch to act mode)
enable_task_progress boolean false Enable task progress tracking

πŸ”§ How It Works

Startup Process

  1. Fetch Prompts: On plugin initialization, fetches the latest prompt files from cline/cline repository
  2. Adapt Content: Extracts prompt content from TypeScript files and adapts them for OpenCode
  3. Map Tools: Converts Cline tool names to OpenCode equivalents using config/tool-mapping.json
  4. Remove Unsupported: Removes MCP and other unsupported features
  5. Build Agents: Creates cline-plan and cline-act agents with adapted prompts

Tool Mapping

The plugin automatically maps Cline tool names to OpenCode equivalents:

Cline Tool OpenCode Tool
read_file read
write_to_file write
list_files glob
search_files grep
list_code_definitions grep
replace_in_file edit
execute_command bash

Unsupported Features

Some Cline features are not available in OpenCode. The plugin provides alternatives:

Cline Feature Alternative
browser_action Use remote-browser or browser-use skill

Note: ask_followup_question and plan_mode_respond are natively supported as custom tools.

πŸ›‘οΈ Error Handling

If the plugin cannot fetch prompts from GitHub (network issues, rate limits, etc.), it will:

  1. Display a clear error message with the specific issue
  2. Provide troubleshooting steps
  3. Fail to start - ensuring you're aware of the problem

This strict approach ensures you always use the latest official Cline prompts.

πŸ“– Example Error Message

╔═══════════════════════════════════════════════════════════════╗
β•‘  Cline Mode Plugin - Failed to Fetch Prompts                  β•‘
╠═══════════════════════════════════════════════════════════════╣
β•‘  The plugin could not fetch prompts from Cline's official     β•‘
β•‘  GitHub repository.                                           β•‘
β•‘                                                               β•‘
β•‘  Error: Network timeout                                       β•‘
β•‘                                                               β•‘
β•‘  Solutions:                                                   β•‘
β•‘  1. Check your internet connection                            β•‘
β•‘  2. Try again in a few minutes                                β•‘
β•‘  3. If rate limited, wait until the reset time                β•‘
β•‘  4. Check GitHub's status: https://status.github.com          β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

πŸ”§ Development

Prerequisites

  • Node.js >= 18.0.0
  • npm >= 9.0.0
  • Internet connection (for fetching prompts)

Setup

git clone https://github.com/trry-hub/opencode-cline-mode.git
cd opencode-cline-mode
npm install

Build

npm run build

Test

npm test                 # Run tests
npm run typecheck        # Type checking
npm run lint             # Linting
npm run validate         # Full validation

Project Structure

opencode-cline-mode/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts              # Main plugin entry
β”‚   β”œβ”€β”€ types.ts              # TypeScript definitions
β”‚   β”œβ”€β”€ logger.ts             # Unified logging
β”‚   β”œβ”€β”€ config-validator.ts   # Config validation
β”‚   β”œβ”€β”€ config-loader.ts      # Config loading
β”‚   β”œβ”€β”€ path-resolver.ts      # Path resolution
β”‚   β”œβ”€β”€ agent-builder.ts      # Agent configuration
β”‚   β”œβ”€β”€ prompt-fetcher.ts     # GitHub prompt fetcher
β”‚   β”œβ”€β”€ prompt-adapter.ts     # Prompt adaptation
β”‚   β”œβ”€β”€ tool-mapper.ts        # Tool name mapping
β”‚   └── utils/
β”‚       β”œβ”€β”€ github-api.ts     # GitHub API client
β”‚       └── cache.ts          # Prompt caching
β”œβ”€β”€ config/
β”‚   └── tool-mapping.json     # Tool mapping configuration
β”œβ”€β”€ dist/                     # Compiled output
└── package.json

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

MIT Β© trry

πŸ™ Acknowledgments

  • Prompts from Cline - The official Cline VS Code extension
  • Built for OpenCode - The open source AI coding agent
  • Thanks to the OpenCode and Cline communities

πŸ“š Related Projects

πŸ› Issues

Found a bug? Have a feature request? Please open an issue.


Made with ❀️ for the OpenCode community

About

Cline-style plan and act workflow for OpenCode

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors