vite-plugin-opencode-assistant 1.0.3 → 1.0.4

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 CHANGED
@@ -1,282 +1,287 @@
1
- # vite-plugin-opencode
1
+ # vite-plugin-opencode-assistant
2
2
 
3
- A Vite plugin that embeds OpenCode Web UI in your development environment, enabling real-time code modification through AI chat.
3
+ 一个面向 Vite 开发环境的插件:在页面内注入 OpenCode 对话挂件,自动启动 OpenCode Web,并把当前页面 URL、标题以及选中的页面节点同步给 AI,便于一边聊天一边改代码、立即通过 HMR 看到结果。
4
4
 
5
- ## Features
5
+ ## 它能做什么
6
6
 
7
- - 🚀 **Auto-start OpenCode services** - Automatically starts OpenCode Server and Web UI
8
- - 💬 **Embedded Chat Interface** - Customer support-like chat widget in your app
9
- - 🔄 **Real-time Code Modification** - AI can modify your code and see changes instantly via HMR
10
- - 🎨 **Customizable** - Configurable position, theme, and behavior
11
- - **Zero Configuration** - Works out of the box with sensible defaults
12
- - 🔧 **Framework Agnostic** - Works with React, Vue, Svelte, and more
7
+ - `vite serve` 时自动注入一个悬浮 AI 按钮和对话面板
8
+ - 自动启动本地 OpenCode Web 服务,并为当前项目复用或创建会话
9
+ - 把当前页面 URL、标题同步到 OpenCode 会话上下文
10
+ - 支持把页面上选中的节点信息同步给 AI,帮助它直接定位组件文件与行号
11
+ - 内置会话列表,可在挂件中切换、新建、删除当前项目的 OpenCode 会话
12
+ - 支持快捷键、主题、初始展开状态、悬浮位置等配置
13
+ - 支持启动后预热 Chrome DevTools MCP,减少首次使用浏览器工具时的等待
13
14
 
14
- ## Installation
15
+ ## 工作方式
15
16
 
16
- ```bash
17
- npm install -D vite-plugin-opencode
18
- ```
17
+ 启动 Vite 开发服务器后,插件会做这几件事:
19
18
 
20
- ## Prerequisites
19
+ 1. 在 HTML 中注入浏览器端挂件脚本
20
+ 2. 检查本机是否已安装 `opencode`
21
+ 3. 启动 OpenCode Web 服务,默认使用 `127.0.0.1:4097`
22
+ 4. 在当前项目目录下查找已有会话;如果没有,则创建新会话
23
+ 5. 把页面上下文通过本地接口同步给 OpenCode
24
+ 6. 页面代码被 OpenCode 修改后,由 Vite HMR 立即刷新效果
21
25
 
22
- This plugin requires [OpenCode](https://opencode.ai) to be installed on your system.
26
+ 当前实现只在开发模式生效:
23
27
 
24
- ### Install OpenCode
28
+ - 仅在 `vite serve` 时启用
29
+ - `build` 阶段不会注入挂件
30
+ - `enabled` 默认值是 `false`,需要显式开启
31
+
32
+ ## 安装
25
33
 
26
- **Using Homebrew (macOS):**
27
34
  ```bash
28
- brew install opencode-ai/tap/opencode
35
+ npm install -D vite-plugin-opencode-assistant
29
36
  ```
30
37
 
31
- **Using the install script:**
38
+ ## 前置条件
39
+
40
+ 本插件依赖本机已安装 [OpenCode](https://opencode.ai) CLI。
41
+
42
+ 推荐安装方式:
43
+
32
44
  ```bash
33
- curl -fsSL https://raw.githubusercontent.com/opencode-ai/opencode/main/install | bash
45
+ curl -fsSL https://opencode.ai/install | bash
34
46
  ```
35
47
 
36
- **Using Go:**
48
+ 也可以使用包管理器:
49
+
37
50
  ```bash
38
- go install github.com/opencode-ai/opencode@latest
51
+ npm i -g opencode-ai@latest
52
+ brew install anomalyco/tap/opencode
39
53
  ```
40
54
 
41
- ## Usage
55
+ 如果你保留默认的 `warmupChromeMcp: true`,首次启动时还会通过 `npx` 拉起 `chrome-devtools-mcp` 来预热浏览器工具链。
42
56
 
43
- ### Basic Setup
57
+ ## 快速开始
44
58
 
45
- Add the plugin to your `vite.config.ts`:
59
+ 由于当前实现默认 `enabled: false`,最小可用配置如下:
46
60
 
47
- ```typescript
48
- import { defineConfig } from 'vite'
49
- import opencode from 'vite-plugin-opencode'
61
+ ```ts
62
+ import { defineConfig } from "vite";
63
+ import opencodeAssistant from "vite-plugin-opencode-assistant";
50
64
 
51
65
  export default defineConfig({
52
66
  plugins: [
53
- opencode(),
67
+ opencodeAssistant({
68
+ enabled: true,
69
+ }),
54
70
  ],
55
- })
71
+ });
56
72
  ```
57
73
 
58
- ### With Configuration
74
+ 启动开发服务器:
59
75
 
60
- ```typescript
61
- import { defineConfig } from 'vite'
62
- import opencode from 'vite-plugin-opencode'
76
+ ```bash
77
+ npm run dev
78
+ ```
79
+
80
+ 启动后页面右下角会出现悬浮按钮,点击即可打开 OpenCode 面板。
81
+
82
+ ## 推荐配置示例
83
+
84
+ ```ts
85
+ import { defineConfig } from "vite";
86
+ import vue from "@vitejs/plugin-vue";
87
+ import opencodeAssistant from "vite-plugin-opencode-assistant";
63
88
 
64
89
  export default defineConfig({
65
90
  plugins: [
66
- opencode({
67
- serverPort: 4096, // OpenCode Server port
68
- webPort: 4097, // OpenCode Web UI port
69
- hostname: 'localhost',
70
- position: 'bottom-right',
71
- theme: 'auto',
91
+ vue(),
92
+ opencodeAssistant({
93
+ enabled: true,
94
+ webPort: 4097,
95
+ hostname: "127.0.0.1",
96
+ position: "bottom-right",
97
+ theme: "auto",
72
98
  open: false,
73
99
  autoReload: true,
100
+ verbose: false,
101
+ hotkey: "ctrl+k",
102
+ warmupChromeMcp: true,
74
103
  }),
75
104
  ],
76
- })
105
+ });
77
106
  ```
78
107
 
79
- ### Start Development
108
+ ## 配置项
80
109
 
81
- ```bash
82
- npm run dev
110
+ ```ts
111
+ interface OpenCodeOptions {
112
+ enabled?: boolean;
113
+ webPort?: number;
114
+ hostname?: string;
115
+ position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
116
+ theme?: "light" | "dark" | "auto";
117
+ open?: boolean;
118
+ autoReload?: boolean;
119
+ verbose?: boolean;
120
+ hotkey?: string;
121
+ warmupChromeMcp?: boolean;
122
+ }
83
123
  ```
84
124
 
85
- You'll see a floating button in the bottom-right corner of your app. Click it to open the AI chat interface!
125
+ 配置说明:
86
126
 
87
- ## How It Works
127
+ | 配置项 | 默认值 | 说明 |
128
+ | ----------------- | ---------------- | ------------------------------------------------------------------- |
129
+ | `enabled` | `false` | 是否启用插件。当前版本必须手动设为 `true` 才会生效 |
130
+ | `webPort` | `4097` | OpenCode Web 端口。如果端口被占用,会从当前端口开始向后寻找可用端口 |
131
+ | `hostname` | `127.0.0.1` | OpenCode Web 绑定地址 |
132
+ | `position` | `"bottom-right"` | 悬浮挂件位置 |
133
+ | `theme` | `"auto"` | 挂件主题,`auto` 会跟随系统明暗色 |
134
+ | `open` | `false` | 页面初始化后是否自动展开挂件 |
135
+ | `autoReload` | `true` | 控制挂件侧的自动重载提示行为 |
136
+ | `verbose` | `false` | 是否输出更详细的插件日志 |
137
+ | `hotkey` | `"ctrl+k"` | 切换挂件的快捷键,macOS 下同样支持 `cmd+k` |
138
+ | `warmupChromeMcp` | `true` | 启动后是否预热 Chrome DevTools MCP |
88
139
 
89
- ```
90
- ┌─────────────────────────────────────────────────┐
91
- │ Vite Dev Server (5173) │
92
- │ │
93
- │ ┌───────────────────────────────────────────┐ │
94
- │ │ Your App (with HMR) │ │
95
- │ │ - Embedded OpenCode Widget │ │
96
- │ └───────────────────────────────────────────┘ │
97
- │ │
98
- │ ┌───────────────────────────────────────────┐ │
99
- │ │ vite-plugin-opencode │ │
100
- │ │ - OpenCode Server (4096) │ │
101
- │ │ - OpenCode Web (4097) │ │
102
- │ └───────────────────────────────────────────┘ │
103
- └─────────────────────────────────────────────────┘
104
- ```
140
+ ## 使用说明
105
141
 
106
- ### Workflow
142
+ ### 1. 打开对话挂件
107
143
 
108
- 1. **User** asks AI to modify code (e.g., "Change button color to red")
109
- 2. **OpenCode Web** sends request to OpenCode Server
110
- 3. **OpenCode Server** reads and modifies the file
111
- 4. **Vite HMR** detects file change and hot-reloads the page
112
- 5. **User** sees the change instantly!
144
+ - 点击页面右下角悬浮按钮
145
+ - 或使用默认快捷键 `Ctrl/Cmd + K`
113
146
 
114
- ## Configuration Options
147
+ ### 2. 切换会话
115
148
 
116
- ```typescript
117
- interface OpenCodeOptions {
118
- // Enable/disable the plugin (default: true)
119
- enabled?: boolean
120
-
121
- // OpenCode Server port (default: 4096)
122
- serverPort?: number
123
-
124
- // OpenCode Web UI port (default: 4097)
125
- webPort?: number
126
-
127
- // Hostname (default: 'localhost')
128
- hostname?: string
129
-
130
- // Widget position (default: 'bottom-right')
131
- position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'
132
-
133
- // Theme (default: 'auto')
134
- theme?: 'light' | 'dark' | 'auto'
135
-
136
- // Auto-open chat window (default: false)
137
- open?: boolean
138
-
139
- // Enable auto-reload notifications (default: true)
140
- autoReload?: boolean
141
- }
142
- ```
149
+ 挂件左侧带有当前项目的会话列表,支持:
143
150
 
144
- ## Examples
151
+ - 查看当前项目下已有会话
152
+ - 新建会话
153
+ - 切换会话
154
+ - 删除会话
145
155
 
146
- ### React
156
+ ### 3. 同步页面上下文
147
157
 
148
- ```typescript
149
- // vite.config.ts
150
- import { defineConfig } from 'vite'
151
- import react from '@vitejs/plugin-react'
152
- import opencode from 'vite-plugin-opencode'
158
+ 挂件会自动同步以下信息:
153
159
 
154
- export default defineConfig({
155
- plugins: [
156
- react(),
157
- opencode(),
158
- ],
159
- })
160
- ```
160
+ - 当前页面 URL
161
+ - 当前页面标题
162
+ - 当前选中的页面节点
161
163
 
162
- ### Vue
164
+ 它会监听:
163
165
 
164
- ```typescript
165
- // vite.config.ts
166
- import { defineConfig } from 'vite'
167
- import vue from '@vitejs/plugin-vue'
168
- import opencode from 'vite-plugin-opencode'
166
+ - `history.pushState`
167
+ - `history.replaceState`
168
+ - `popstate`
169
+ - `hashchange`
170
+ - `document.title` 变化
169
171
 
170
- export default defineConfig({
171
- plugins: [
172
- vue(),
173
- opencode(),
174
- ],
175
- })
176
- ```
177
-
178
- ## Use Cases
172
+ 这意味着在 SPA 场景下切页后,上下文也会自动更新。
179
173
 
180
- ### 1. Style Modifications
181
- ```
182
- User: "Change the button color to red"
183
- AI: Modifies App.css
184
- Result: Button turns red instantly
185
- ```
174
+ ### 4. 选择页面节点
186
175
 
187
- ### 2. Component Creation
188
- ```
189
- User: "Add a login form"
190
- AI: Creates LoginForm.jsx
191
- Result: Login form appears on page
192
- ```
176
+ 当前实现支持把页面节点作为上下文传给 AI,节点信息包括:
193
177
 
194
- ### 3. Bug Fixes
195
- ```
196
- User: "Fix the counter not working"
197
- AI: Modifies App.jsx
198
- Result: Counter works correctly
199
- ```
178
+ - 源文件路径
179
+ - 行号和列号
180
+ - 节点文本
181
+ - 节点描述
200
182
 
201
- ## API
183
+ 默认通过 `Ctrl/Cmd + P` 进入选择模式。
202
184
 
203
- The plugin exposes a global API that you can use in your code:
185
+ 需要注意:
204
186
 
205
- ```javascript
206
- // Open the chat widget
207
- window.OpenCodeWidget.open()
187
+ - 这项能力依赖页面中可用的 Vue Inspector 钩子
188
+ - 如果页面中没有可用的 Inspector,挂件会提示“Vue Inspector 未加载,无法使用元素选择功能”
189
+ - 选中的节点会暂存在 `sessionStorage` 中
208
190
 
209
- // Close the chat widget
210
- window.OpenCodeWidget.close()
191
+ ## 浏览器端全局 API
211
192
 
212
- // Toggle the chat widget
213
- window.OpenCodeWidget.toggle()
193
+ 挂件会暴露一个全局对象:
214
194
 
215
- // Show a notification
216
- window.OpenCodeWidget.showNotification('Code updated!')
195
+ ```js
196
+ window.OpenCodeWidget.open();
197
+ window.OpenCodeWidget.close();
198
+ window.OpenCodeWidget.toggle();
199
+ window.OpenCodeWidget.showNotification("Code updated!");
200
+ window.OpenCodeWidget.updateContext();
217
201
  ```
218
202
 
219
- ## Keyboard Shortcuts
203
+ 适用场景:
220
204
 
221
- - `Ctrl/Cmd + K` - Toggle chat widget
205
+ - 从你自己的调试面板中主动打开挂件
206
+ - 在页面状态发生重要变化后手动触发一次上下文同步
207
+ - 在自定义流程中复用现有的通知能力
222
208
 
223
- ## Troubleshooting
209
+ ## 本地接口
210
+
211
+ 插件会在 Vite 开发服务器上挂出几个内部接口,供挂件与 OpenCode 协作使用:
212
+
213
+ | 路径 | 说明 |
214
+ | ------------------------- | ------------------------------------------ |
215
+ | `/__opencode_widget__.js` | 浏览器端挂件脚本 |
216
+ | `/__opencode_start__` | 返回当前服务启动状态与会话地址 |
217
+ | `/__opencode_context__` | 读写页面上下文、清空已选节点 |
218
+ | `/__opencode_sessions__` | 查询、创建、删除 OpenCode 会话 |
219
+ | `/__opencode_events__` | SSE 事件流,用于同步会话就绪和节点清空事件 |
220
+
221
+ 这些接口是插件内部实现细节,通常不需要业务代码直接调用。
222
+
223
+ ## 常见问题
224
224
 
225
225
  ### OpenCode not installed
226
226
 
227
- If you see an error message about OpenCode not being installed, follow the installation instructions above.
227
+ 如果控制台提示未安装 OpenCode,先确认命令行里可以正常执行:
228
+
229
+ ```bash
230
+ opencode --version
231
+ ```
232
+
233
+ 若无法执行,请先完成 OpenCode CLI 安装。
228
234
 
229
- ### Port conflicts
235
+ ### 端口冲突
230
236
 
231
- If ports 4096 or 4097 are already in use, you can configure different ports:
237
+ 当前实现只开放了 `webPort` 配置项,没有单独暴露 server 端口配置。
232
238
 
233
- ```typescript
234
- opencode({
235
- serverPort: 5000,
239
+ 如果默认端口被占用,可以改成:
240
+
241
+ ```ts
242
+ opencodeAssistant({
243
+ enabled: true,
236
244
  webPort: 5001,
237
- })
245
+ });
238
246
  ```
239
247
 
240
- ### CORS issues
248
+ 如果你不改配置,插件也会从 `webPort` 开始继续向后寻找可用端口。
241
249
 
242
- The plugin automatically configures CORS for local development. If you encounter CORS issues, make sure you're using the correct hostname and ports.
250
+ ### 页面里没有节点选择能力
243
251
 
244
- ## Development
252
+ 这通常意味着当前页面里没有可用的 Vue Inspector 钩子。挂件仍然可以正常聊天和同步 URL/标题,只是无法通过页面点选节点来辅助定位代码。
245
253
 
246
- ### Build the plugin
254
+ ### 构建产物里为什么没有挂件
247
255
 
248
- ```bash
249
- npm run build
250
- ```
256
+ 这是当前实现的预期行为。插件只在开发服务器模式下工作,不会影响生产构建结果。
251
257
 
252
- ### Run tests
258
+ ## 示例项目
253
259
 
254
- ```bash
255
- npm test
256
- ```
260
+ 仓库自带了一个 `example` 工作区用于本地联调。
257
261
 
258
- ### Run the example
262
+ 由于示例直接引用 `../dist/vite/index`,请先在仓库根目录构建插件:
259
263
 
260
264
  ```bash
265
+ npm install
266
+ npm run build
261
267
  cd example
262
268
  npm install
263
269
  npm run dev
264
270
  ```
265
271
 
266
- ## Contributing
272
+ ## 开发
267
273
 
268
- Contributions are welcome! Please feel free to submit a Pull Request.
274
+ ```bash
275
+ npm run build
276
+ npm test
277
+ ```
269
278
 
270
279
  ## License
271
280
 
272
281
  MIT
273
282
 
274
- ## Links
283
+ ## 相关链接
275
284
 
276
- - [OpenCode Documentation](https://opencode.ai/docs)
285
+ - [OpenCode](https://opencode.ai)
277
286
  - [OpenCode GitHub](https://github.com/opencode-ai/opencode)
278
287
  - [Vite Plugin API](https://vite.dev/guide/api-plugin.html)
279
-
280
- ## Acknowledgments
281
-
282
- This plugin is built on top of [OpenCode](https://opencode.ai), an open-source AI coding assistant.
@@ -7,7 +7,7 @@ export declare const DEFAULT_HOSTNAME = "127.0.0.1";
7
7
  /** 默认 Web 服务端口 */
8
8
  export declare const DEFAULT_WEB_PORT = 4097;
9
9
  /** 服务器启动超时时间(毫秒) */
10
- export declare const SERVER_START_TIMEOUT = 15000;
10
+ export declare const SERVER_START_TIMEOUT = 300000;
11
11
  /** 服务器检查间隔(毫秒) */
12
12
  export declare const SERVER_CHECK_INTERVAL = 100;
13
13
  /** ==================== 重试相关 ==================== */
@@ -70,4 +70,5 @@ export declare const DEFAULT_CONFIG: {
70
70
  autoReload: boolean;
71
71
  verbose: boolean;
72
72
  hotkey: string;
73
+ warmupChromeMcp: boolean;
73
74
  };
package/dist/constants.js CHANGED
@@ -3,11 +3,11 @@
3
3
  */
4
4
  /** ==================== 网络相关 ==================== */
5
5
  /** 默认主机名 */
6
- export const DEFAULT_HOSTNAME = '127.0.0.1';
6
+ export const DEFAULT_HOSTNAME = "127.0.0.1";
7
7
  /** 默认 Web 服务端口 */
8
8
  export const DEFAULT_WEB_PORT = 4097;
9
9
  /** 服务器启动超时时间(毫秒) */
10
- export const SERVER_START_TIMEOUT = 15000;
10
+ export const SERVER_START_TIMEOUT = 300000;
11
11
  /** 服务器检查间隔(毫秒) */
12
12
  export const SERVER_CHECK_INTERVAL = 100;
13
13
  /** ==================== 重试相关 ==================== */
@@ -20,24 +20,24 @@ export const RETRY_DELAY = 500;
20
20
  export const MAX_PORT_TRIES = 10;
21
21
  /** ==================== 日志相关 ==================== */
22
22
  /** 插件日志前缀 */
23
- export const LOG_PREFIX = '[vite-plugin-opencode]';
23
+ export const LOG_PREFIX = "[vite-plugin-opencode]";
24
24
  /** OpenCode Web 日志前缀 */
25
- export const WEB_LOG_PREFIX = '[OpenCode Web]';
25
+ export const WEB_LOG_PREFIX = "[OpenCode Web]";
26
26
  /** OpenCode Web 错误日志前缀 */
27
- export const WEB_ERROR_PREFIX = '[OpenCode Web Error]';
27
+ export const WEB_ERROR_PREFIX = "[OpenCode Web Error]";
28
28
  /** ==================== 挂件相关 ==================== */
29
29
  /** 挂件脚本路径 */
30
- export const WIDGET_SCRIPT_PATH = '/__opencode_widget__.js';
30
+ export const WIDGET_SCRIPT_PATH = "/__opencode_widget__.js";
31
31
  /** 配置数据属性名 */
32
- export const CONFIG_DATA_ATTR = 'data-opencode-config';
32
+ export const CONFIG_DATA_ATTR = "data-opencode-config";
33
33
  /** 上下文 API 路径 */
34
- export const CONTEXT_API_PATH = '/__opencode_context__';
34
+ export const CONTEXT_API_PATH = "/__opencode_context__";
35
35
  /** 启动 API 路径 */
36
- export const START_API_PATH = '/__opencode_start__';
36
+ export const START_API_PATH = "/__opencode_start__";
37
37
  /** 会话列表 API 路径 */
38
- export const SESSIONS_API_PATH = '/__opencode_sessions__';
38
+ export const SESSIONS_API_PATH = "/__opencode_sessions__";
39
39
  /** SSE 事件流路径 */
40
- export const SSE_EVENTS_PATH = '/__opencode_events__';
40
+ export const SSE_EVENTS_PATH = "/__opencode_events__";
41
41
  /** 上下文更新间隔(毫秒) */
42
42
  export const CONTEXT_UPDATE_INTERVAL = 500;
43
43
  /** 服务器同步间隔(毫秒) */
@@ -50,25 +50,26 @@ export const AUTO_OPEN_DELAY = 1000;
50
50
  export const NOTIFICATION_DURATION = 3000;
51
51
  /** ==================== 存储相关 ==================== */
52
52
  /** 初始化标记 */
53
- export const INIT_MARKER = '__OPENCODE_INITIALIZED__';
53
+ export const INIT_MARKER = "__OPENCODE_INITIALIZED__";
54
54
  /** 选中元素存储键 */
55
- export const SELECTED_ELEMENTS_KEY = '__opencode_selected_elements__';
55
+ export const SELECTED_ELEMENTS_KEY = "__opencode_selected_elements__";
56
56
  /** ==================== 文本处理 ==================== */
57
57
  /** 元素文本最大显示长度 */
58
58
  export const MAX_TEXT_LENGTH = 100;
59
59
  /** 元素上下文标记 */
60
- export const CONTEXT_MARKER = '[元素上下文]';
60
+ export const CONTEXT_MARKER = "[元素上下文]";
61
61
  /** ==================== 默认配置 ==================== */
62
62
  /** 默认插件配置 */
63
63
  export const DEFAULT_CONFIG = {
64
- enabled: true,
64
+ enabled: false,
65
65
  webPort: DEFAULT_WEB_PORT,
66
66
  hostname: DEFAULT_HOSTNAME,
67
- position: 'bottom-right',
68
- theme: 'auto',
67
+ position: "bottom-right",
68
+ theme: "auto",
69
69
  open: false,
70
70
  autoReload: true,
71
71
  verbose: false,
72
- hotkey: 'ctrl+k',
72
+ hotkey: "ctrl+k",
73
+ warmupChromeMcp: true,
73
74
  };
74
75
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qDAAqD;AAErD,YAAY;AACZ,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAA;AAE3C,kBAAkB;AAClB,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAA;AAEpC,oBAAoB;AACpB,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAA;AAEzC,kBAAkB;AAClB,MAAM,CAAC,MAAM,qBAAqB,GAAG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GAAG,0BAA0B,CAAA;AAErD,cAAc;AACd,MAAM,CAAC,MAAM,qBAAqB,GAAG,gCAAgC,CAAA;AAErE,qDAAqD;AAErD,iBAAiB;AACjB,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;AAElC,cAAc;AACd,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAA;AAEvC,qDAAqD;AAErD,aAAa;AACb,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,gBAAgB;IACzB,QAAQ,EAAE,gBAAgB;IAC1B,QAAQ,EAAE,cAAuB;IACjC,KAAK,EAAE,MAAe;IACtB,IAAI,EAAE,KAAK;IACX,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,QAAQ;CACjB,CAAA","sourcesContent":["/**\n * @fileoverview OpenCode 插件常量定义\n */\n\n/** ==================== 网络相关 ==================== */\n\n/** 默认主机名 */\nexport const DEFAULT_HOSTNAME = '127.0.0.1'\n\n/** 默认 Web 服务端口 */\nexport const DEFAULT_WEB_PORT = 4097\n\n/** 服务器启动超时时间(毫秒) */\nexport const SERVER_START_TIMEOUT = 15000\n\n/** 服务器检查间隔(毫秒) */\nexport const SERVER_CHECK_INTERVAL = 100\n\n/** ==================== 重试相关 ==================== */\n\n/** 默认重试次数 */\nexport const DEFAULT_RETRIES = 5\n\n/** 重试延迟(毫秒) */\nexport const RETRY_DELAY = 500\n\n/** ==================== 端口查找 ==================== */\n\n/** 最大端口尝试次数 */\nexport const MAX_PORT_TRIES = 10\n\n/** ==================== 日志相关 ==================== */\n\n/** 插件日志前缀 */\nexport const LOG_PREFIX = '[vite-plugin-opencode]'\n\n/** OpenCode Web 日志前缀 */\nexport const WEB_LOG_PREFIX = '[OpenCode Web]'\n\n/** OpenCode Web 错误日志前缀 */\nexport const WEB_ERROR_PREFIX = '[OpenCode Web Error]'\n\n/** ==================== 挂件相关 ==================== */\n\n/** 挂件脚本路径 */\nexport const WIDGET_SCRIPT_PATH = '/__opencode_widget__.js'\n\n/** 配置数据属性名 */\nexport const CONFIG_DATA_ATTR = 'data-opencode-config'\n\n/** 上下文 API 路径 */\nexport const CONTEXT_API_PATH = '/__opencode_context__'\n\n/** 启动 API 路径 */\nexport const START_API_PATH = '/__opencode_start__'\n\n/** 会话列表 API 路径 */\nexport const SESSIONS_API_PATH = '/__opencode_sessions__'\n\n/** SSE 事件流路径 */\nexport const SSE_EVENTS_PATH = '/__opencode_events__'\n\n/** 上下文更新间隔(毫秒) */\nexport const CONTEXT_UPDATE_INTERVAL = 500\n\n/** 服务器同步间隔(毫秒) */\nexport const SERVER_SYNC_INTERVAL = 2000\n\n/** Vue Inspector 检查间隔(毫秒) */\nexport const INSPECTOR_CHECK_INTERVAL = 500\n\n/** 自动打开延迟(毫秒) */\nexport const AUTO_OPEN_DELAY = 1000\n\n/** 通知显示时间(毫秒) */\nexport const NOTIFICATION_DURATION = 3000\n\n/** ==================== 存储相关 ==================== */\n\n/** 初始化标记 */\nexport const INIT_MARKER = '__OPENCODE_INITIALIZED__'\n\n/** 选中元素存储键 */\nexport const SELECTED_ELEMENTS_KEY = '__opencode_selected_elements__'\n\n/** ==================== 文本处理 ==================== */\n\n/** 元素文本最大显示长度 */\nexport const MAX_TEXT_LENGTH = 100\n\n/** 元素上下文标记 */\nexport const CONTEXT_MARKER = '[元素上下文]'\n\n/** ==================== 默认配置 ==================== */\n\n/** 默认插件配置 */\nexport const DEFAULT_CONFIG = {\n enabled: true,\n webPort: DEFAULT_WEB_PORT,\n hostname: DEFAULT_HOSTNAME,\n position: 'bottom-right' as const,\n theme: 'auto' as const,\n open: false,\n autoReload: true,\n verbose: false,\n hotkey: 'ctrl+k',\n}\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qDAAqD;AAErD,YAAY;AACZ,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,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CAAC;AAE5C,iBAAiB;AACjB,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,iBAAiB;AACjB,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAE1C,qDAAqD;AAErD,YAAY;AACZ,MAAM,CAAC,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAEtD,cAAc;AACd,MAAM,CAAC,MAAM,qBAAqB,GAAG,gCAAgC,CAAC;AAEtE,qDAAqD;AAErD,iBAAiB;AACjB,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAEnC,cAAc;AACd,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AAExC,qDAAqD;AAErD,aAAa;AACb,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,gBAAgB;IACzB,QAAQ,EAAE,gBAAgB;IAC1B,QAAQ,EAAE,cAAuB;IACjC,KAAK,EAAE,MAAe;IACtB,IAAI,EAAE,KAAK;IACX,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,QAAQ;IAChB,eAAe,EAAE,IAAI;CACtB,CAAC","sourcesContent":["/**\n * @fileoverview OpenCode 插件常量定义\n */\n\n/** ==================== 网络相关 ==================== */\n\n/** 默认主机名 */\nexport const DEFAULT_HOSTNAME = \"127.0.0.1\";\n\n/** 默认 Web 服务端口 */\nexport const DEFAULT_WEB_PORT = 4097;\n\n/** 服务器启动超时时间(毫秒) */\nexport const SERVER_START_TIMEOUT = 300000;\n\n/** 服务器检查间隔(毫秒) */\nexport const SERVER_CHECK_INTERVAL = 100;\n\n/** ==================== 重试相关 ==================== */\n\n/** 默认重试次数 */\nexport const DEFAULT_RETRIES = 5;\n\n/** 重试延迟(毫秒) */\nexport const RETRY_DELAY = 500;\n\n/** ==================== 端口查找 ==================== */\n\n/** 最大端口尝试次数 */\nexport const MAX_PORT_TRIES = 10;\n\n/** ==================== 日志相关 ==================== */\n\n/** 插件日志前缀 */\nexport const LOG_PREFIX = \"[vite-plugin-opencode]\";\n\n/** OpenCode Web 日志前缀 */\nexport const WEB_LOG_PREFIX = \"[OpenCode Web]\";\n\n/** OpenCode Web 错误日志前缀 */\nexport const WEB_ERROR_PREFIX = \"[OpenCode Web Error]\";\n\n/** ==================== 挂件相关 ==================== */\n\n/** 挂件脚本路径 */\nexport const WIDGET_SCRIPT_PATH = \"/__opencode_widget__.js\";\n\n/** 配置数据属性名 */\nexport const CONFIG_DATA_ATTR = \"data-opencode-config\";\n\n/** 上下文 API 路径 */\nexport const CONTEXT_API_PATH = \"/__opencode_context__\";\n\n/** 启动 API 路径 */\nexport const START_API_PATH = \"/__opencode_start__\";\n\n/** 会话列表 API 路径 */\nexport const SESSIONS_API_PATH = \"/__opencode_sessions__\";\n\n/** SSE 事件流路径 */\nexport const SSE_EVENTS_PATH = \"/__opencode_events__\";\n\n/** 上下文更新间隔(毫秒) */\nexport const CONTEXT_UPDATE_INTERVAL = 500;\n\n/** 服务器同步间隔(毫秒) */\nexport const SERVER_SYNC_INTERVAL = 2000;\n\n/** Vue Inspector 检查间隔(毫秒) */\nexport const INSPECTOR_CHECK_INTERVAL = 500;\n\n/** 自动打开延迟(毫秒) */\nexport const AUTO_OPEN_DELAY = 1000;\n\n/** 通知显示时间(毫秒) */\nexport const NOTIFICATION_DURATION = 3000;\n\n/** ==================== 存储相关 ==================== */\n\n/** 初始化标记 */\nexport const INIT_MARKER = \"__OPENCODE_INITIALIZED__\";\n\n/** 选中元素存储键 */\nexport const SELECTED_ELEMENTS_KEY = \"__opencode_selected_elements__\";\n\n/** ==================== 文本处理 ==================== */\n\n/** 元素文本最大显示长度 */\nexport const MAX_TEXT_LENGTH = 100;\n\n/** 元素上下文标记 */\nexport const CONTEXT_MARKER = \"[元素上下文]\";\n\n/** ==================== 默认配置 ==================== */\n\n/** 默认插件配置 */\nexport const DEFAULT_CONFIG = {\n enabled: false,\n webPort: DEFAULT_WEB_PORT,\n hostname: DEFAULT_HOSTNAME,\n position: \"bottom-right\" as const,\n theme: \"auto\" as const,\n open: false,\n autoReload: true,\n verbose: false,\n hotkey: \"ctrl+k\",\n warmupChromeMcp: true,\n};\n"]}