opencode-opointerOpenCode plugin for DOM editing via browser extension. Enables AI-powered DOM editing through a WebSocket bridge.
1
17
近 7 天 5
25.8
生态多维模型
2 个月前
2026-05-28
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-opointer@1.0.2"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-opointer@1.0.2"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-opointeropencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
https://github.com/user-attachments/assets/be8eb8fb-35a5-4143-8d85-5810542e3b4f
A browser extension that enables DOM editing via OpenCode. Select any DOM element on a webpage, and OpenCode will implement changes to your local project files based on your natural language instructions.
Overview
Opointer consists of two components:
- Browser Extension - DOM element selection tool (NOT PUBLISHED YET - Firefox/Chrome)
- OpenCode Plugin (
opencode-opointer) - WebSocket bridge server
┌─────────────────────────────────────────────────────────────────┐
│ Browser Extension │
│ - Project selector (popup) │
│ - Element selection via Cmd+Shift+E │
│ - DOM context capture │
└────────────────────────────┬────────────────────────────────────┘
│ WebSocket (ws://localhost:51861)
▼
┌─────────────────────────────────────────────────────────────────┐
│ opencode-opointer Plugin │
│ - WebSocket Server (port 51861) │
│ - Routes element context to OpenCode SDK │
└────────────────────────────┬────────────────────────────────────┘
│ Internal
▼
┌─────────────────────────────────────────────────────────────────┐
│ OpenCode │
│ - Receives DOM context + user prompt │
│ - Implements file changes in local project │
└─────────────────────────────────────────────────────────────────┘
Prerequisites
- OpenCode running locally
- Node.js 18+ (for building extension if needed)
Installation
1. Install OpenCode Plugin
Add to your OpenCode config (opencode.json):
{
"plugin": ["opencode-opointer"]
}
OpenCode will automatically install the plugin on startup.
2. Install Browser Extension
Firefox:
- [`Install firefox addon through firefox addon store"](https://addons.mozilla.org/en-US/firefox/addon/opencode-element-pointer/)
Chrome (idk if its working - im not using chrome, so you can test it and send feedback through issues):
Quick Start
- Open OpenCode - Plugin starts WebSocket server on port 51861
- Click extension icon - Select a project from dropdown, click Save
- Navigate to webpage - Open the site you want to edit
- Press Cmd+Shift+E (Mac) / Ctrl+Shift+E (Windows/Linux) - Enter selection mode
- Click on element - Element context sent to OpenCode
- Type prompt in OpenCode - Describe the change you want
How It Works
Element Selection Flow
- User presses shortcut -
Cmd+Shift+Etriggers selection mode - Overlay appears - Semi-transparent overlay with crosshair cursor
- User hovers - Elements are highlighted with outlines
- User clicks element - DOM context is captured:
- Tag name, attributes, styles
- XPath selector
- Source file location (if available via
element-source) - Parent hierarchy, children
- Context sent to OpenCode - Via WebSocket to
opencode-opointerplugin - User edits in OpenCode - Natural language prompt in OpenCode TUI
What Happens in OpenCode
The plugin appends element context to OpenCode's TUI:
## Element Source Information
**Source File**: src/App.svelte:24
## DOM Element Details
- Tag: button
- Attributes: {"class":"btn","data-id":"submit"}
- Text: Submit
The user wants to make changes to this element.
Ask the user what changes they want to make and then implement them.
OpenCode then uses this context to implement the user's requested changes.
Configuration
Extension Popup
- Click the extension icon in browser toolbar
- Select a project from the dropdown (fetches from OpenCode)
- Click "Save"
OpenCode Plugin
No additional configuration needed. The plugin uses port 51861 by default.
Project Structure
opointer/
├── packages/
│ ├── extension/ # Browser extension
│ │ ├── src/
│ │ │ ├── content.ts # DOM selection, overlay, capture
│ │ │ ├── background.ts # WebSocket client, message routing
│ │ │ ├── popup.ts # Project selector UI
│ │ │ └── types.ts # TypeScript interfaces
│ │ └── dist/ # Built extension (chrome/, firefox/)
│ │
│ └── opencode-plugin/ # OpenCode plugin (published as npm)
│ ├── src/
│ │ ├── index.ts # Plugin entry point
│ │ ├── wsbridge.ts # WebSocket server
│ │ ├── types.ts # Type definitions
│ │ └── elementSource.ts # Source code detection
│ └── dist/ # Built plugin
│
└── dist/ # Distribution files
└── opointer-extension-firefox.xpi
Building
# Build extension for both browsers
npm run build --workspace=@opointer/extension
# Build plugin
npm run build --workspace=@opointer/opencode-plugin
# Build everything
npm run build
Extension
- Vanilla JS with esbuild
element-sourcefor source code detectionbrowser.storage.localfor project persistence
Plugin
@opencode-ai/plugin- OpenCode plugin APIws- WebSocket serverelement-source- Source code detection
License
MIT