vite-plugin-opencode-assistant 1.0.36 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -47
- package/es/core/api.js +2 -7
- package/lib/core/api.js +2 -7
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
## 它能做什么
|
|
6
6
|
|
|
7
|
-
- **悬浮 AI 面板** -
|
|
7
|
+
- **悬浮 AI 面板** - 在页面右下角注入悬浮按钮,支持拖拽定位和边缘磁吸
|
|
8
8
|
- **自动启动服务** - 自动启动本地 OpenCode Web 服务,无需手动操作
|
|
9
|
-
- **智能会话管理** -
|
|
9
|
+
- **智能会话管理** - 自动复用当前项目的会话,支持创建、切换、删除会话
|
|
10
|
+
- **实时状态显示** - 会话列表显示思考状态指示器,了解 AI 当前工作状态
|
|
10
11
|
- **页面上下文同步** - 自动同步当前页面 URL、标题给 AI,SPA 路由切换时实时更新
|
|
11
12
|
- **元素选择器** - 通过快捷键在页面上点选元素,将组件源码位置信息传给 AI
|
|
12
13
|
- **主题同步** - 挂件主题与 OpenCode Web 主题实时同步
|
|
13
14
|
- **代理服务** - 内置代理服务器解决 iframe 跨域限制,确保 OpenCode Web 功能完整
|
|
14
15
|
- **Chrome DevTools 预热** - 启动时自动预热浏览器工具链,减少首次使用等待
|
|
16
|
+
- **日志查看** - 提供日志接口,方便 Agent 获取开发服务器输出
|
|
15
17
|
|
|
16
18
|
## 效果演示
|
|
17
19
|
|
|
@@ -77,10 +79,8 @@ export default defineConfig({
|
|
|
77
79
|
webPort: 5097, // OpenCode Web 服务端口
|
|
78
80
|
proxyPort: 6097, // 代理服务端口
|
|
79
81
|
hostname: "127.0.0.1", // 服务绑定地址
|
|
80
|
-
position: "bottom-right", // 悬浮按钮位置
|
|
81
82
|
theme: "auto", // 主题: light | dark | auto
|
|
82
83
|
open: false, // 是否自动展开面板
|
|
83
|
-
autoReload: true, // 是否启用自动重载提示
|
|
84
84
|
verbose: false, // 是否输出详细日志
|
|
85
85
|
hotkey: "ctrl+k", // 切换面板的快捷键
|
|
86
86
|
warmupChromeMcp: true, // 是否预热 Chrome DevTools MCP
|
|
@@ -111,21 +111,19 @@ npm run dev
|
|
|
111
111
|
|
|
112
112
|
## 配置项
|
|
113
113
|
|
|
114
|
-
| 配置项 | 类型 | 默认值
|
|
115
|
-
| ----------------- | --------- |
|
|
116
|
-
| `enabled` | `boolean` | `true`
|
|
117
|
-
| `webPort` | `number` | `5097`
|
|
118
|
-
| `proxyPort` | `number` | `6097`
|
|
119
|
-
| `hostname` | `string` | `"127.0.0.1"`
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `language` | `string` | - | OpenCode 界面语言,如 `zh`、`en`、`ja` 等 |
|
|
128
|
-
| `settings` | `object` | - | OpenCode 内部设置,详见下方说明 |
|
|
114
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
115
|
+
| ----------------- | --------- | ------------- | --------------------------------------------------- |
|
|
116
|
+
| `enabled` | `boolean` | `true` | 是否启用插件 |
|
|
117
|
+
| `webPort` | `number` | `5097` | OpenCode Web 服务端口,被占用时自动向后寻找可用端口 |
|
|
118
|
+
| `proxyPort` | `number` | `6097` | 代理服务端口,用于解决 iframe 跨域限制 |
|
|
119
|
+
| `hostname` | `string` | `"127.0.0.1"` | 服务绑定地址 |
|
|
120
|
+
| `theme` | `string` | `"auto"` | 挂件主题:`light` \| `dark` \| `auto`(跟随系统) |
|
|
121
|
+
| `open` | `boolean` | `false` | 页面加载后是否自动展开面板 |
|
|
122
|
+
| `verbose` | `boolean` | `false` | 是否输出详细调试日志 |
|
|
123
|
+
| `hotkey` | `string` | `"ctrl+k"` | 切换面板的快捷键,macOS 支持 `cmd+k` |
|
|
124
|
+
| `warmupChromeMcp` | `boolean` | `true` | 启动后是否预热 Chrome DevTools MCP |
|
|
125
|
+
| `language` | `string` | - | OpenCode 界面语言,如 `zh`、`en`、`ja` 等 |
|
|
126
|
+
| `settings` | `object` | - | OpenCode 内部设置,详见下方说明 |
|
|
129
127
|
|
|
130
128
|
### OpenCode 设置
|
|
131
129
|
|
|
@@ -205,38 +203,18 @@ npm run dev
|
|
|
205
203
|
|
|
206
204
|
**注意**:元素选择依赖 Vue Inspector,如果页面中没有可用的 Inspector,会提示无法使用该功能。
|
|
207
205
|
|
|
208
|
-
## 浏览器端 API
|
|
209
|
-
|
|
210
|
-
挂件在全局暴露 `window.OpenCodeWidget` 对象:
|
|
211
|
-
|
|
212
|
-
```js
|
|
213
|
-
// 打开面板
|
|
214
|
-
window.OpenCodeWidget.open();
|
|
215
|
-
|
|
216
|
-
// 关闭面板
|
|
217
|
-
window.OpenCodeWidget.close();
|
|
218
|
-
|
|
219
|
-
// 切换面板
|
|
220
|
-
window.OpenCodeWidget.toggle();
|
|
221
|
-
|
|
222
|
-
// 显示通知
|
|
223
|
-
window.OpenCodeWidget.showNotification("代码已更新!");
|
|
224
|
-
|
|
225
|
-
// 手动同步上下文
|
|
226
|
-
window.OpenCodeWidget.updateContext();
|
|
227
|
-
```
|
|
228
|
-
|
|
229
206
|
## 内部接口
|
|
230
207
|
|
|
231
208
|
插件在 Vite 开发服务器上注册以下内部接口:
|
|
232
209
|
|
|
233
|
-
| 路径 | 说明
|
|
234
|
-
| ------------------------- |
|
|
235
|
-
| `/__opencode_widget__.js` | 浏览器端挂件脚本
|
|
236
|
-
| `/__opencode_start__` | 服务启动状态与会话地址
|
|
237
|
-
| `/__opencode_context__` | 页面上下文读写
|
|
238
|
-
| `/__opencode_sessions__` | 会话查询、创建、删除
|
|
239
|
-
| `/__opencode_events__` | SSE 事件流(会话就绪、节点清空等)
|
|
210
|
+
| 路径 | 说明 |
|
|
211
|
+
| ------------------------- | ------------------------------------------ |
|
|
212
|
+
| `/__opencode_widget__.js` | 浏览器端挂件脚本 |
|
|
213
|
+
| `/__opencode_start__` | 服务启动状态与会话地址 |
|
|
214
|
+
| `/__opencode_context__` | 页面上下文读写 |
|
|
215
|
+
| `/__opencode_sessions__` | 会话查询、创建、删除 |
|
|
216
|
+
| `/__opencode_events__` | SSE 事件流(会话就绪、节点清空等) |
|
|
217
|
+
| `/__opencode_logs__` | 日志查询(OpenCode 进程输出、Vite 日志等) |
|
|
240
218
|
|
|
241
219
|
## 常见问题
|
|
242
220
|
|
package/es/core/api.js
CHANGED
|
@@ -119,10 +119,7 @@ class OpenCodeAPI {
|
|
|
119
119
|
const sessions = yield this.createHttpRequest({
|
|
120
120
|
hostname: this.hostname,
|
|
121
121
|
port: this.getPort(),
|
|
122
|
-
path:
|
|
123
|
-
headers: {
|
|
124
|
-
"x-opencode-directory": encodeURIComponent(projectDir)
|
|
125
|
-
}
|
|
122
|
+
path: `/session?directory=${encodeURIComponent(projectDir)}`
|
|
126
123
|
});
|
|
127
124
|
const sessionsWithUrl = sessions.map((s) => __spreadProps(__spreadValues({}, s), {
|
|
128
125
|
url: `http://${this.hostname}:${this.getProxyPort()}/${base64Encode(s.directory)}/session/${s.id}`
|
|
@@ -164,9 +161,7 @@ class OpenCodeAPI {
|
|
|
164
161
|
port: this.getPort(),
|
|
165
162
|
path: "/session",
|
|
166
163
|
method: "POST",
|
|
167
|
-
headers:
|
|
168
|
-
"x-opencode-directory": encodeURIComponent(projectDir)
|
|
169
|
-
})
|
|
164
|
+
headers: __spreadValues({}, requestBody ? { "Content-Type": "application/json" } : {})
|
|
170
165
|
},
|
|
171
166
|
requestBody
|
|
172
167
|
);
|
package/lib/core/api.js
CHANGED
|
@@ -137,10 +137,7 @@ class OpenCodeAPI {
|
|
|
137
137
|
const sessions = yield this.createHttpRequest({
|
|
138
138
|
hostname: this.hostname,
|
|
139
139
|
port: this.getPort(),
|
|
140
|
-
path:
|
|
141
|
-
headers: {
|
|
142
|
-
"x-opencode-directory": encodeURIComponent(projectDir)
|
|
143
|
-
}
|
|
140
|
+
path: `/session?directory=${encodeURIComponent(projectDir)}`
|
|
144
141
|
});
|
|
145
142
|
const sessionsWithUrl = sessions.map((s) => __spreadProps(__spreadValues({}, s), {
|
|
146
143
|
url: `http://${this.hostname}:${this.getProxyPort()}/${(0, import_shared.base64Encode)(s.directory)}/session/${s.id}`
|
|
@@ -182,9 +179,7 @@ class OpenCodeAPI {
|
|
|
182
179
|
port: this.getPort(),
|
|
183
180
|
path: "/session",
|
|
184
181
|
method: "POST",
|
|
185
|
-
headers:
|
|
186
|
-
"x-opencode-directory": encodeURIComponent(projectDir)
|
|
187
|
-
})
|
|
182
|
+
headers: __spreadValues({}, requestBody ? { "Content-Type": "application/json" } : {})
|
|
188
183
|
},
|
|
189
184
|
requestBody
|
|
190
185
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-opencode-assistant",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.37",
|
|
4
4
|
"description": "Embed OpenCode Web UI in your Vite dev server for real-time code modification and preview",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"unplugin-vue-inspector": "^2.4.0",
|
|
39
|
-
"@vite-plugin-opencode-assistant/components": "1.0.
|
|
40
|
-
"@vite-plugin-opencode-assistant/opencode": "1.0.
|
|
41
|
-
"@vite-plugin-opencode-assistant/shared": "1.0.
|
|
39
|
+
"@vite-plugin-opencode-assistant/components": "1.0.37",
|
|
40
|
+
"@vite-plugin-opencode-assistant/opencode": "1.0.37",
|
|
41
|
+
"@vite-plugin-opencode-assistant/shared": "1.0.37"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"vite": ">=4.0.0"
|