@vite-plugin-opencode-assistant/opencode 1.0.15 → 1.0.16

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.
@@ -1,14 +1,14 @@
1
- const T = "[vite-plugin-opencode]";
2
- const w = "[元素上下文]";
3
- var C = Object.defineProperty, S = Object.defineProperties, N = Object.getOwnPropertyDescriptors, x = Object.getOwnPropertySymbols, L = Object.prototype.hasOwnProperty, M = Object.prototype.propertyIsEnumerable, b = (e, t, r) => t in e ? C(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, g = (e, t) => {
4
- for (var r in t || (t = {}))
5
- L.call(t, r) && b(e, r, t[r]);
6
- if (x)
7
- for (var r of x(t))
8
- M.call(t, r) && b(e, r, t[r]);
9
- return e;
10
- }, m = (e, t) => S(e, N(t)), O = (e, t, r) => b(e, typeof t != "symbol" ? t + "" : t, r);
11
- const c = {
1
+ const x = "[vite-plugin-opencode]";
2
+ const T = "[元素上下文]";
3
+ var w = Object.defineProperty, C = Object.defineProperties, S = Object.getOwnPropertyDescriptors, y = Object.getOwnPropertySymbols, N = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable, P = (t, e, r) => e in t ? w(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, g = (t, e) => {
4
+ for (var r in e || (e = {}))
5
+ N.call(e, r) && P(t, r, e[r]);
6
+ if (y)
7
+ for (var r of y(e))
8
+ L.call(e, r) && P(t, r, e[r]);
9
+ return t;
10
+ }, m = (t, e) => C(t, S(e)), O = (t, e, r) => P(t, typeof e != "symbol" ? e + "" : e, r);
11
+ const u = {
12
12
  reset: "\x1B[0m",
13
13
  dim: "\x1B[2m",
14
14
  bright: "\x1B[1m",
@@ -18,11 +18,11 @@ const c = {
18
18
  magenta: "\x1B[35m",
19
19
  cyan: "\x1B[36m"
20
20
  }, j = {
21
- 0: c.cyan,
22
- 1: c.green,
23
- 2: c.yellow,
24
- 3: c.red,
25
- 4: c.reset
21
+ 0: u.cyan,
22
+ 1: u.green,
23
+ 2: u.yellow,
24
+ 3: u.red,
25
+ 4: u.reset
26
26
  }, A = {
27
27
  0: "DEBUG",
28
28
  1: "INFO",
@@ -30,190 +30,173 @@ const c = {
30
30
  3: "ERROR",
31
31
  4: "NONE"
32
32
  };
33
- let R = {
33
+ let M = {
34
34
  level: 1
35
35
  /* INFO */
36
36
  };
37
- function B() {
38
- const e = /* @__PURE__ */ new Date(), t = String(e.getHours()).padStart(2, "0"), r = String(e.getMinutes()).padStart(2, "0"), o = String(e.getSeconds()).padStart(2, "0"), i = String(e.getMilliseconds()).padStart(3, "0");
39
- return `${t}:${r}:${o}.${i}`;
37
+ function R() {
38
+ const t = /* @__PURE__ */ new Date(), e = String(t.getHours()).padStart(2, "0"), r = String(t.getMinutes()).padStart(2, "0"), o = String(t.getSeconds()).padStart(2, "0"), i = String(t.getMilliseconds()).padStart(3, "0");
39
+ return `${e}:${r}:${o}.${i}`;
40
40
  }
41
- function I(e = 3) {
42
- const t = new Error().stack;
43
- if (!t) return "";
44
- const o = t.split(`
45
- `)[e];
41
+ function I(t = 3) {
42
+ const e = new Error().stack;
43
+ if (!e) return "";
44
+ const o = e.split(`
45
+ `)[t];
46
46
  if (!o) return "";
47
47
  const i = o.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?/);
48
48
  if (!i) return "";
49
- const [, p, n, a] = i;
50
- return `${n.split("/").pop() || n}:${a} ${p || "<anonymous>"}`;
49
+ const [, n, a, s] = i;
50
+ return `${a.split("/").pop() || a}:${s} ${n || "<anonymous>"}`;
51
51
  }
52
- function h(e, t = 0) {
53
- if (t > 3) return "...";
54
- if (e === null) return "null";
55
- if (e === void 0) return "undefined";
56
- if (typeof e == "string") return t > 0 ? `"${e}"` : e;
57
- if (typeof e == "number" || typeof e == "boolean") return String(e);
58
- if (e instanceof Error)
59
- return `${e.name}: ${e.message}${e.stack ? `
60
- ${e.stack}` : ""}`;
61
- if (Array.isArray(e))
62
- return e.length === 0 ? "[]" : e.length > 5 ? `[${e.slice(0, 3).map((i) => h(i, t + 1)).join(", ")}, ... ${e.length - 3} more items]` : `[${e.map((o) => h(o, t + 1)).join(", ")}]`;
63
- if (typeof e == "object") {
64
- const r = Object.entries(e);
65
- return r.length === 0 ? "{}" : r.length > 5 ? `{${r.slice(0, 3).map(([p, n]) => `${p}: ${h(n, t + 1)}`).join(", ")}, ... ${r.length - 3} more keys}` : `{${r.map(([i, p]) => `${i}: ${h(p, t + 1)}`).join(", ")}}`;
52
+ function h(t, e = 0) {
53
+ if (e > 3) return "...";
54
+ if (t === null) return "null";
55
+ if (t === void 0) return "undefined";
56
+ if (typeof t == "string") return e > 0 ? `"${t}"` : t;
57
+ if (typeof t == "number" || typeof t == "boolean") return String(t);
58
+ if (t instanceof Error)
59
+ return `${t.name}: ${t.message}${t.stack ? `
60
+ ${t.stack}` : ""}`;
61
+ if (Array.isArray(t))
62
+ return t.length === 0 ? "[]" : t.length > 5 ? `[${t.slice(0, 3).map((i) => h(i, e + 1)).join(", ")}, ... ${t.length - 3} more items]` : `[${t.map((o) => h(o, e + 1)).join(", ")}]`;
63
+ if (typeof t == "object") {
64
+ const r = Object.entries(t);
65
+ return r.length === 0 ? "{}" : r.length > 5 ? `{${r.slice(0, 3).map(([n, a]) => `${n}: ${h(a, e + 1)}`).join(", ")}, ... ${r.length - 3} more keys}` : `{${r.map(([i, n]) => `${i}: ${h(n, e + 1)}`).join(", ")}}`;
66
66
  }
67
- return String(e);
67
+ return String(t);
68
68
  }
69
- function U(e) {
70
- if (!e || Object.keys(e).length === 0) return "";
71
- const t = [];
72
- e.module && t.push(`[${e.module}]`), e.operation && t.push(`(${e.operation})`), e.traceId && t.push(`trace:${e.traceId}`), e.duration !== void 0 && t.push(`${e.duration}ms`);
73
- const r = Object.keys(e).filter(
69
+ function B(t) {
70
+ if (!t || Object.keys(t).length === 0) return "";
71
+ const e = [];
72
+ t.module && e.push(`[${t.module}]`), t.operation && e.push(`(${t.operation})`), t.traceId && e.push(`trace:${t.traceId}`), t.duration !== void 0 && e.push(`${t.duration}ms`);
73
+ const r = Object.keys(t).filter(
74
74
  (o) => !["module", "operation", "traceId", "duration", "error"].includes(o)
75
75
  );
76
76
  if (r.length > 0) {
77
77
  const o = {};
78
- r.forEach((i) => o[i] = e[i]), t.push(h(o));
78
+ r.forEach((i) => o[i] = t[i]), e.push(h(o));
79
79
  }
80
- return t.join(" ");
80
+ return e.join(" ");
81
81
  }
82
- function P(e, t, r, ...o) {
83
- if (e < R.level) return;
82
+ function _(t, e, r, ...o) {
83
+ if (t < M.level) return;
84
84
  const i = [];
85
- i.push(`${c.dim}[${process.pid}]${c.reset}`), i.push(`${c.dim}${B()}${c.reset}`);
86
- const p = j[e], n = A[e].padEnd(5);
87
- i.push(`${p}${n}${c.reset}`), i.push(`${c.bright}${T}${c.reset}`);
88
- const a = U(r);
89
- if (a && i.push(`${c.magenta}${a}${c.reset}`), i.push(t), e >= 2) {
90
- const u = I(4);
91
- u && i.push(`${c.dim}(${u})${c.reset}`);
85
+ i.push(`${u.dim}[${process.pid}]${u.reset}`), i.push(`${u.dim}${R()}${u.reset}`);
86
+ const n = j[t], a = A[t].padEnd(5);
87
+ i.push(`${n}${a}${u.reset}`), i.push(`${u.bright}${x}${u.reset}`);
88
+ const s = B(r);
89
+ if (s && i.push(`${u.magenta}${s}${u.reset}`), i.push(e), t >= 2) {
90
+ const f = I(4);
91
+ f && i.push(`${u.dim}(${f})${u.reset}`);
92
92
  }
93
- const s = o.map((u) => h(u)).join(" ");
94
- if (s && i.push(s), r != null && r.error) {
95
- const u = r.error;
96
- u instanceof Error ? i.push(`${c.red}Error: ${u.message}${c.reset}`) : i.push(`${c.red}Error: ${h(u)}${c.reset}`);
93
+ const l = o.map((f) => h(f)).join(" ");
94
+ if (l && i.push(l), r != null && r.error) {
95
+ const f = r.error;
96
+ f instanceof Error ? i.push(`${u.red}Error: ${f.message}${u.reset}`) : i.push(`${u.red}Error: ${h(f)}${u.reset}`);
97
97
  }
98
- const f = i.join(" ");
99
- e >= 3 ? console.error(f) : e === 2 ? console.warn(f) : console.log(f);
98
+ const c = i.join(" ");
99
+ t >= 3 ? console.error(c) : t === 2 ? console.warn(c) : console.log(c);
100
100
  }
101
101
  const $ = {
102
- debug(e, t, ...r) {
103
- P(0, e, t, ...r);
102
+ debug(t, e, ...r) {
103
+ _(0, t, e, ...r);
104
104
  },
105
- info(e, t, ...r) {
106
- P(1, e, t, ...r);
105
+ info(t, e, ...r) {
106
+ _(1, t, e, ...r);
107
107
  },
108
- warn(e, t, ...r) {
109
- P(2, e, t, ...r);
108
+ warn(t, e, ...r) {
109
+ _(2, t, e, ...r);
110
110
  },
111
- error(e, t, ...r) {
112
- P(3, e, t, ...r);
111
+ error(t, e, ...r) {
112
+ _(3, t, e, ...r);
113
113
  },
114
- group(e, t) {
114
+ group(t, e) {
115
115
  },
116
116
  groupEnd() {
117
117
  }
118
118
  };
119
- class D {
120
- constructor(t, r) {
121
- O(this, "startTime"), O(this, "context"), O(this, "operation"), this.operation = t, this.context = r || {}, this.startTime = performance.now(), $.debug(`⏱️ Starting: ${t}`, this.context);
119
+ class U {
120
+ constructor(e, r) {
121
+ O(this, "startTime"), O(this, "context"), O(this, "operation"), this.operation = e, this.context = r || {}, this.startTime = performance.now(), $.debug(`⏱️ Starting: ${e}`, this.context);
122
122
  }
123
- end(t) {
124
- const r = Math.round(performance.now() - this.startTime), o = t || `✓ Completed: ${this.operation}`;
123
+ end(e) {
124
+ const r = Math.round(performance.now() - this.startTime), o = e || `✓ Completed: ${this.operation}`;
125
125
  return $.debug(o, m(g({}, this.context), { duration: r })), r;
126
126
  }
127
- checkpoint(t) {
127
+ checkpoint(e) {
128
128
  const r = Math.round(performance.now() - this.startTime);
129
- return $.debug(` ↳ ${t}`, m(g({}, this.context), { duration: r })), r;
129
+ return $.debug(` ↳ ${e}`, m(g({}, this.context), { duration: r })), r;
130
130
  }
131
131
  }
132
- function k(e) {
132
+ function D(t) {
133
133
  return {
134
- debug(t, r, ...o) {
135
- $.debug(t, m(g({}, r), { module: e }), ...o);
134
+ debug(e, r, ...o) {
135
+ $.debug(e, m(g({}, r), { module: t }), ...o);
136
136
  },
137
- info(t, r, ...o) {
138
- $.info(t, m(g({}, r), { module: e }), ...o);
137
+ info(e, r, ...o) {
138
+ $.info(e, m(g({}, r), { module: t }), ...o);
139
139
  },
140
- warn(t, r, ...o) {
141
- $.warn(t, m(g({}, r), { module: e }), ...o);
140
+ warn(e, r, ...o) {
141
+ $.warn(e, m(g({}, r), { module: t }), ...o);
142
142
  },
143
- error(t, r, ...o) {
144
- $.error(t, m(g({}, r), { module: e }), ...o);
143
+ error(e, r, ...o) {
144
+ $.error(e, m(g({}, r), { module: t }), ...o);
145
145
  },
146
- timer(t, r) {
147
- return new D(t, m(g({}, r), { module: e }));
146
+ timer(e, r) {
147
+ return new U(e, m(g({}, r), { module: t }));
148
148
  }
149
149
  };
150
150
  }
151
- const l = k("OpenCodePluginPageContext"), X = async () => {
152
- l.info("PageContextPlugin loading...");
153
- const e = process.env.OPENCODE_CONTEXT_API_URL;
154
- if (l.debug("Context API URL:", { contextApiUrl: e }), !e)
155
- return l.warn("OPENCODE_CONTEXT_API_URL is not set, page context plugin will not work"), {};
156
- const t = e;
157
- l.info("Plugin initialized successfully");
151
+ const p = D("OpenCodePluginPageContext"), X = async () => {
152
+ p.info("PageContextPlugin loading...");
153
+ const t = process.env.OPENCODE_CONTEXT_API_URL;
154
+ if (p.debug("Context API URL:", { contextApiUrl: t }), !t)
155
+ return p.warn("OPENCODE_CONTEXT_API_URL is not set, page context plugin will not work"), {};
156
+ const e = t;
157
+ p.info("Plugin initialized successfully");
158
158
  async function r() {
159
159
  try {
160
- l.debug("Fetching context...", { apiUrl: t });
161
- const n = await fetch(t);
160
+ p.debug("Fetching context...", { apiUrl: e });
161
+ const n = await fetch(e);
162
162
  if (!n.ok)
163
- return l.error("Context API returned error status", {
163
+ return p.error("Context API returned error status", {
164
164
  status: n.status,
165
165
  statusText: n.statusText,
166
- apiUrl: t
166
+ apiUrl: e
167
167
  }), null;
168
168
  const a = await n.json();
169
- return l.debug("Context received", { url: a.url, title: a.title }), {
169
+ return p.debug("Context received", { url: a.url, title: a.title }), {
170
170
  url: a.url || "",
171
171
  title: a.title || "",
172
172
  selectedElements: a.selectedElements
173
173
  };
174
174
  } catch (n) {
175
175
  const a = n instanceof Error ? n.message : String(n), s = n instanceof Error ? n.name : "UnknownError";
176
- return l.error("Failed to get context", {
176
+ return p.error("Failed to get context", {
177
177
  error: a,
178
178
  errorType: s,
179
- apiUrl: t
179
+ apiUrl: e
180
180
  }), null;
181
181
  }
182
182
  }
183
- async function o() {
184
- try {
185
- l.debug("Clearing selected elements", { apiUrl: t });
186
- const n = await fetch(t, { method: "DELETE" });
187
- l.debug("Clear response", { status: n.status });
188
- } catch (n) {
189
- const a = n instanceof Error ? n.message : String(n), s = n instanceof Error ? n.name : "UnknownError";
190
- l.error("Failed to clear selected elements", {
191
- error: a,
192
- errorType: s,
193
- apiUrl: t
194
- });
195
- }
196
- }
197
- function i(n, a) {
198
- var f, u;
183
+ function o(n, a) {
184
+ var l, c;
199
185
  const s = [];
200
- if (s.push(`### 选中节点 ${a + 1}`), n.filePath)
186
+ if (s.push(`### 用户选中节点 ${a + 1}`), n.filePath)
201
187
  if (n.filePath.includes("node_modules")) {
202
- if (s.push(`- **元素描述**: \`${n.description}\``), (f = n.innerText) != null && f.trim()) {
188
+ if (s.push(`- **元素选择器**: \`${n.description}\``), (l = n.innerText) != null && l.trim()) {
203
189
  const d = n.innerText.trim().substring(0, 100);
204
190
  s.push(`- **节点文本**: \`${d}${n.innerText.length > 100 ? "..." : ""}\``);
205
191
  }
206
- s.push(
207
- `- **分析建议**: 请使用 Chrome DevTools MCP 获取当前页面快照,结合 CSS 选择器 \`${n.description}\` 来获取更多的页面上下文`
208
- );
209
192
  } else {
210
193
  let d = n.filePath;
211
- if (n.line && (d += `:${n.line}`, n.column && (d += `:${n.column}`)), s.push(`- **文件位置**: \`${d}\``), (u = n.innerText) != null && u.trim()) {
212
- const y = n.innerText.trim().substring(0, 100), E = n.innerText.length > 100 ? `
194
+ if (n.line && (d += `:${n.line}`, n.column && (d += `:${n.column}`)), s.push(`- **文件位置**: \`${d}\``), (c = n.innerText) != null && c.trim()) {
195
+ const E = n.innerText.trim().substring(0, 100), b = n.innerText.length > 100 ? `
213
196
  ... (已省略部分内容)` : "";
214
197
  s.push(`- **节点文本**:
215
198
  \`\`\`text
216
- ${y}${E}
199
+ ${E}${b}
217
200
  \`\`\``);
218
201
  }
219
202
  }
@@ -221,18 +204,18 @@ ${y}${E}
221
204
  `) + `
222
205
  `;
223
206
  }
224
- function p(n) {
225
- var f;
207
+ function i(n) {
208
+ var l;
226
209
  const a = n.title ? `[${n.title}](${n.url})` : n.url;
227
210
  let s = `【系统提示:以下是用户当前正在浏览的页面上下文,请将其作为最高优先级的背景信息来理解和响应用户的请求。】
228
211
 
229
212
  `;
230
213
  return s += `用户现在正在浏览项目中的这个页面:${a}
231
214
 
232
- `, (f = n.selectedElements) != null && f.length && (s += `用户选中了以下节点:
215
+ `, (l = n.selectedElements) != null && l.length && (s += `用户选中了以下节点:
233
216
 
234
- `, n.selectedElements.forEach((u, _) => {
235
- s += i(u, _) + `
217
+ `, n.selectedElements.forEach((c, f) => {
218
+ s += o(c, f) + `
236
219
  `;
237
220
  })), s += `---
238
221
  **用户的请求**:
@@ -241,7 +224,7 @@ ${y}${E}
241
224
  }
242
225
  return {
243
226
  "experimental.chat.system.transform": async (n, a) => {
244
- l.debug("System transform hook called");
227
+ p.debug("System transform hook called");
245
228
  const s = `
246
229
  你是一个专业的前端开发助手,运行在 **OpenCode** 平台中,并通过 **vite-plugin-opencode-assistant** 插件集成到用户的 Vite 开发环境。
247
230
 
@@ -271,25 +254,12 @@ ${y}${E}
271
254
 
272
255
  1. **页面信息**:用户当前浏览的页面 URL 和标题
273
256
  2. **选中元素**:用户在页面上选中的 DOM 元素信息,包括:
274
- - 源码文件路径(如 \`src/components/Button.tsx\`)
275
- - 行号和列号(精确定位到代码位置)
257
+ - 元素的选择器
276
258
  - 元素的文本内容
259
+ - 源码文件路径(如果有)
277
260
 
278
261
  这些信息由 Vite 插件通过内部 API 收集,并在用户发送消息时自动附加到消息前缀中。
279
262
 
280
- ## 上下文处理规则
281
-
282
- 当你在对话中看到类似以下格式的上下文信息时:
283
-
284
- \`\`\`
285
- 【系统提示:以下是用户当前正在浏览的页面上下文...】
286
- 用户现在正在浏览项目中的这个页面:[页面标题](URL)
287
- 用户选中了以下节点:
288
- ### 选中节点 1
289
- - **文件位置**: \`src/components/Button.tsx:42:10\`
290
- - **节点文本**: ...
291
- \`\`\`
292
-
293
263
  请遵循以下规则:
294
264
 
295
265
  1. **前置要求:定位节点位置**(强制)
@@ -305,19 +275,19 @@ ${y}${E}
305
275
  a.system.push(s);
306
276
  },
307
277
  "experimental.chat.messages.transform": async (n, a) => {
308
- var d, y;
309
- l.debug("Message transform hook called");
278
+ var d;
279
+ p.debug("Message transform hook called");
310
280
  const s = await r();
311
- if (l.debug("Context data", {
281
+ if (p.debug("Context data", {
312
282
  hasUrl: !!(s != null && s.url),
313
283
  hasElements: !!((d = s == null ? void 0 : s.selectedElements) != null && d.length)
314
284
  }), !(s != null && s.url)) return;
315
- const f = [...a.messages].reverse().find((E) => E.info.role === "user");
316
- if (!f) return;
317
- const u = f.parts.find((E) => E.type === "text");
318
- if (!u || !("text" in u) || u.text.includes(w)) return;
319
- const _ = p(s);
320
- u.text = _ + u.text, (y = s.selectedElements) != null && y.length && (l.debug("Selected elements found, clearing..."), await o());
285
+ const l = [...a.messages].reverse().find((E) => E.info.role === "user");
286
+ if (!l) return;
287
+ const c = l.parts.find((E) => E.type === "text");
288
+ if (!c || !("text" in c) || c.text.includes(T)) return;
289
+ const f = i(s);
290
+ c.text = f + c.text;
321
291
  }
322
292
  };
323
293
  };
@@ -85,38 +85,18 @@ const PageContextPlugin = () => __async(null, null, function* () {
85
85
  }
86
86
  });
87
87
  }
88
- function clearSelectedElements() {
89
- return __async(this, null, function* () {
90
- try {
91
- log.debug("Clearing selected elements", { apiUrl });
92
- const response = yield fetch(apiUrl, { method: "DELETE" });
93
- log.debug("Clear response", { status: response.status });
94
- } catch (error) {
95
- const errorMessage = error instanceof Error ? error.message : String(error);
96
- const errorName = error instanceof Error ? error.name : "UnknownError";
97
- log.error("Failed to clear selected elements", {
98
- error: errorMessage,
99
- errorType: errorName,
100
- apiUrl
101
- });
102
- }
103
- });
104
- }
105
88
  function formatSelectedElement(element, index) {
106
89
  var _a, _b;
107
90
  const parts = [];
108
- parts.push(`### \u9009\u4E2D\u8282\u70B9 ${index + 1}`);
91
+ parts.push(`### \u7528\u6237\u9009\u4E2D\u8282\u70B9 ${index + 1}`);
109
92
  if (element.filePath) {
110
93
  const isNodeModule = element.filePath.includes("node_modules");
111
94
  if (isNodeModule) {
112
- parts.push(`- **\u5143\u7D20\u63CF\u8FF0**: \`${element.description}\``);
95
+ parts.push(`- **\u5143\u7D20\u9009\u62E9\u5668**: \`${element.description}\``);
113
96
  if ((_a = element.innerText) == null ? void 0 : _a.trim()) {
114
97
  const text = element.innerText.trim().substring(0, 100);
115
98
  parts.push(`- **\u8282\u70B9\u6587\u672C**: \`${text}${element.innerText.length > 100 ? "..." : ""}\``);
116
99
  }
117
- parts.push(
118
- `- **\u5206\u6790\u5EFA\u8BAE**: \u8BF7\u4F7F\u7528 Chrome DevTools MCP \u83B7\u53D6\u5F53\u524D\u9875\u9762\u5FEB\u7167\uFF0C\u7ED3\u5408 CSS \u9009\u62E9\u5668 \`${element.description}\` \u6765\u83B7\u53D6\u66F4\u591A\u7684\u9875\u9762\u4E0A\u4E0B\u6587`
119
- );
120
100
  } else {
121
101
  let location = element.filePath;
122
102
  if (element.line) {
@@ -193,25 +173,12 @@ ${text}${suffix}
193
173
 
194
174
  1. **\u9875\u9762\u4FE1\u606F**\uFF1A\u7528\u6237\u5F53\u524D\u6D4F\u89C8\u7684\u9875\u9762 URL \u548C\u6807\u9898
195
175
  2. **\u9009\u4E2D\u5143\u7D20**\uFF1A\u7528\u6237\u5728\u9875\u9762\u4E0A\u9009\u4E2D\u7684 DOM \u5143\u7D20\u4FE1\u606F\uFF0C\u5305\u62EC\uFF1A
196
- - \u6E90\u7801\u6587\u4EF6\u8DEF\u5F84\uFF08\u5982 \`src/components/Button.tsx\`\uFF09
197
- - \u884C\u53F7\u548C\u5217\u53F7\uFF08\u7CBE\u786E\u5B9A\u4F4D\u5230\u4EE3\u7801\u4F4D\u7F6E\uFF09
176
+ - \u5143\u7D20\u7684\u9009\u62E9\u5668
198
177
  - \u5143\u7D20\u7684\u6587\u672C\u5185\u5BB9
178
+ - \u6E90\u7801\u6587\u4EF6\u8DEF\u5F84\uFF08\u5982\u679C\u6709\uFF09
199
179
 
200
180
  \u8FD9\u4E9B\u4FE1\u606F\u7531 Vite \u63D2\u4EF6\u901A\u8FC7\u5185\u90E8 API \u6536\u96C6\uFF0C\u5E76\u5728\u7528\u6237\u53D1\u9001\u6D88\u606F\u65F6\u81EA\u52A8\u9644\u52A0\u5230\u6D88\u606F\u524D\u7F00\u4E2D\u3002
201
181
 
202
- ## \u4E0A\u4E0B\u6587\u5904\u7406\u89C4\u5219
203
-
204
- \u5F53\u4F60\u5728\u5BF9\u8BDD\u4E2D\u770B\u5230\u7C7B\u4F3C\u4EE5\u4E0B\u683C\u5F0F\u7684\u4E0A\u4E0B\u6587\u4FE1\u606F\u65F6\uFF1A
205
-
206
- \`\`\`
207
- \u3010\u7CFB\u7EDF\u63D0\u793A\uFF1A\u4EE5\u4E0B\u662F\u7528\u6237\u5F53\u524D\u6B63\u5728\u6D4F\u89C8\u7684\u9875\u9762\u4E0A\u4E0B\u6587...\u3011
208
- \u7528\u6237\u73B0\u5728\u6B63\u5728\u6D4F\u89C8\u9879\u76EE\u4E2D\u7684\u8FD9\u4E2A\u9875\u9762\uFF1A[\u9875\u9762\u6807\u9898](URL)
209
- \u7528\u6237\u9009\u4E2D\u4E86\u4EE5\u4E0B\u8282\u70B9\uFF1A
210
- ### \u9009\u4E2D\u8282\u70B9 1
211
- - **\u6587\u4EF6\u4F4D\u7F6E**: \`src/components/Button.tsx:42:10\`
212
- - **\u8282\u70B9\u6587\u672C**: ...
213
- \`\`\`
214
-
215
182
  \u8BF7\u9075\u5FAA\u4EE5\u4E0B\u89C4\u5219\uFF1A
216
183
 
217
184
  1. **\u524D\u7F6E\u8981\u6C42\uFF1A\u5B9A\u4F4D\u8282\u70B9\u4F4D\u7F6E**\uFF08\u5F3A\u5236\uFF09
@@ -227,7 +194,7 @@ ${text}${suffix}
227
194
  output.system.push(systemPrompt);
228
195
  }),
229
196
  "experimental.chat.messages.transform": (_input, output) => __async(null, null, function* () {
230
- var _a, _b;
197
+ var _a;
231
198
  log.debug("Message transform hook called");
232
199
  const context = yield getPageContext();
233
200
  log.debug("Context data", {
@@ -242,10 +209,6 @@ ${text}${suffix}
242
209
  if (textPart.text.includes(import_shared.CONTEXT_MARKER)) return;
243
210
  const prefix = buildContextPrefix(context);
244
211
  textPart.text = prefix + textPart.text;
245
- if ((_b = context.selectedElements) == null ? void 0 : _b.length) {
246
- log.debug("Selected elements found, clearing...");
247
- yield clearSelectedElements();
248
- }
249
212
  })
250
213
  };
251
214
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-plugin-opencode-assistant/opencode",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "execa": "^9.6.1",
25
- "@vite-plugin-opencode-assistant/shared": "1.0.15"
25
+ "@vite-plugin-opencode-assistant/shared": "1.0.16"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@opencode-ai/plugin": "^1.3.15",