opencode-clip
v0.0.4
Published
Copy the last AI response to clipboard
Downloads
18
Readme
opencode-clip
Copy the last AI response to clipboard
An OpenCode plugin created from the bun-module template
Description
This OpenCode plugin provides a /clip command that copies the last AI assistant response to your clipboard with a single command.
Installation
Add following to your opencode configuration JSON file:
{
"plugins": ["opencode-clip@latest"]
}Usage
Once installed, you can use the /clip command in any OpenCode session:
/clipThis will:
- Find the last AI assistant message in the current session
- Copy its text content to your clipboard
- Show a success toast notification with the character count
Example
User: Write a function to calculate factorial
AI: Here's a factorial function in JavaScript...
User: /clip
AI: ✓ CopiedThe AI response is now in your clipboard and ready to paste.
Development
Prerequisites
Setup
bun installTest
mise run testLint
mise run lint
mise run lint:fixFormat
mise run formatRelease
See the RELEASE.md file for instructions on how to release a new version of the plugin.
How It Works
The plugin hooks into OpenCode's command system and:
- Registers a
/clipcommand with a template that tells the AI not to process the command text - Intercepts the command execution via the
command.execute.beforehook - Fetches session messages to find the most recent assistant response
- Copies the text content to clipboard using
clipboardy - Notifies the user with a toast notification (success, warning, or error)
Contributing
Contributions are welcome! Please file issues or submit pull requests on the GitHub repository.
License
See the LICENSE file for details.
Acknowledgments
- Created with the bun-module template
- Built for OpenCode
