@vite-plugin-opencode-assistant/opencode 1.0.26 → 1.0.28

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,12 +1,12 @@
1
1
  const _ = "[vite-plugin-opencode]";
2
- var b = Object.defineProperty, w = Object.defineProperties, E = Object.getOwnPropertyDescriptors, P = Object.getOwnPropertySymbols, C = Object.prototype.hasOwnProperty, S = Object.prototype.propertyIsEnumerable, y = (e, t, r) => t in e ? b(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, u = (e, t) => {
2
+ var b = Object.defineProperty, w = Object.defineProperties, E = Object.getOwnPropertyDescriptors, y = Object.getOwnPropertySymbols, C = Object.prototype.hasOwnProperty, S = Object.prototype.propertyIsEnumerable, O = (e, t, r) => t in e ? b(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, u = (e, t) => {
3
3
  for (var r in t || (t = {}))
4
- C.call(t, r) && y(e, r, t[r]);
5
- if (P)
6
- for (var r of P(t))
7
- S.call(t, r) && y(e, r, t[r]);
4
+ C.call(t, r) && O(e, r, t[r]);
5
+ if (y)
6
+ for (var r of y(t))
7
+ S.call(t, r) && O(e, r, t[r]);
8
8
  return e;
9
- }, p = (e, t) => w(e, E(t)), O = (e, t, r) => y(e, typeof t != "symbol" ? t + "" : t, r);
9
+ }, p = (e, t) => w(e, E(t)), P = (e, t, r) => O(e, typeof t != "symbol" ? t + "" : t, r);
10
10
  const s = {
11
11
  reset: "\x1B[0m",
12
12
  dim: "\x1B[2m",
@@ -16,28 +16,28 @@ const s = {
16
16
  yellow: "\x1B[33m",
17
17
  magenta: "\x1B[35m",
18
18
  cyan: "\x1B[36m"
19
- }, j = {
19
+ }, T = {
20
20
  0: s.cyan,
21
21
  1: s.green,
22
22
  2: s.yellow,
23
23
  3: s.red,
24
24
  4: s.reset
25
- }, x = {
25
+ }, j = {
26
26
  0: "DEBUG",
27
27
  1: "INFO",
28
28
  2: "WARN",
29
29
  3: "ERROR",
30
30
  4: "NONE"
31
31
  };
32
- let L = {
32
+ let x = {
33
33
  level: 1
34
34
  /* INFO */
35
35
  };
36
- function N() {
36
+ function L() {
37
37
  const e = /* @__PURE__ */ new Date(), t = String(e.getHours()).padStart(2, "0"), r = String(e.getMinutes()).padStart(2, "0"), n = String(e.getSeconds()).padStart(2, "0"), o = String(e.getMilliseconds()).padStart(3, "0");
38
38
  return `${t}:${r}:${n}.${o}`;
39
39
  }
40
- function R(e = 3) {
40
+ function N(e = 3) {
41
41
  const t = new Error().stack;
42
42
  if (!t) return "";
43
43
  const n = t.split(`
@@ -65,7 +65,7 @@ ${e.stack}` : ""}`;
65
65
  }
66
66
  return String(e);
67
67
  }
68
- function T(e) {
68
+ function R(e) {
69
69
  if (!e || Object.keys(e).length === 0) return "";
70
70
  const t = [];
71
71
  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`);
@@ -79,14 +79,14 @@ function T(e) {
79
79
  return t.join(" ");
80
80
  }
81
81
  function h(e, t, r, ...n) {
82
- if (e < L.level) return;
82
+ if (e < x.level) return;
83
83
  const o = [];
84
- o.push(`${s.dim}[${process.pid}]${s.reset}`), o.push(`${s.dim}${N()}${s.reset}`);
85
- const i = j[e], m = x[e].padEnd(5);
84
+ o.push(`${s.dim}[${process.pid}]${s.reset}`), o.push(`${s.dim}${L()}${s.reset}`);
85
+ const i = T[e], m = j[e].padEnd(5);
86
86
  o.push(`${i}${m}${s.reset}`), o.push(`${s.bright}${_}${s.reset}`);
87
- const l = T(r);
87
+ const l = R(r);
88
88
  if (l && o.push(`${s.magenta}${l}${s.reset}`), o.push(t), e >= 2) {
89
- const a = R(4);
89
+ const a = N(4);
90
90
  a && o.push(`${s.dim}(${a})${s.reset}`);
91
91
  }
92
92
  const $ = n.map((a) => f(a)).join(" ");
@@ -115,9 +115,9 @@ const g = {
115
115
  groupEnd() {
116
116
  }
117
117
  };
118
- class I {
118
+ class A {
119
119
  constructor(t, r) {
120
- O(this, "startTime"), O(this, "context"), O(this, "operation"), this.operation = t, this.context = r || {}, this.startTime = performance.now(), g.debug(`⏱️ Starting: ${t}`, this.context);
120
+ P(this, "startTime"), P(this, "context"), P(this, "operation"), this.operation = t, this.context = r || {}, this.startTime = performance.now(), g.debug(`⏱️ Starting: ${t}`, this.context);
121
121
  }
122
122
  end(t) {
123
123
  const r = Math.round(performance.now() - this.startTime), n = t || `✓ Completed: ${this.operation}`;
@@ -128,7 +128,7 @@ class I {
128
128
  return g.debug(` ↳ ${t}`, p(u({}, this.context), { duration: r })), r;
129
129
  }
130
130
  }
131
- function B(e) {
131
+ function I(e) {
132
132
  return {
133
133
  debug(t, r, ...n) {
134
134
  g.debug(t, p(u({}, r), { module: e }), ...n);
@@ -143,12 +143,12 @@ function B(e) {
143
143
  g.error(t, p(u({}, r), { module: e }), ...n);
144
144
  },
145
145
  timer(t, r) {
146
- return new I(t, p(u({}, r), { module: e }));
146
+ return new A(t, p(u({}, r), { module: e }));
147
147
  }
148
148
  };
149
149
  }
150
- const c = B("OpenCodePluginPageContext");
151
- async function D(e) {
150
+ const c = I("OpenCodePluginPageContext");
151
+ async function B(e) {
152
152
  try {
153
153
  const t = await fetch(e, {
154
154
  method: "GET",
@@ -159,13 +159,13 @@ async function D(e) {
159
159
  return c.debug("Error fetching page context", { error: t }), null;
160
160
  }
161
161
  }
162
- const A = async () => {
162
+ const D = async () => {
163
163
  c.info("PageContextPlugin loading...");
164
164
  const e = process.env.OPENCODE_CONTEXT_API_URL;
165
165
  return c.debug("Context API URL:", { contextApiUrl: e }), e ? (c.info("Plugin initialized successfully"), {
166
166
  "experimental.chat.system.transform": async (t, r) => {
167
167
  c.debug("System transform hook called");
168
- const n = await D(e);
168
+ const n = await B(e);
169
169
  c.debug("Page context fetched", { pageContext: n });
170
170
  let o = "";
171
171
  n && (o = `
@@ -228,12 +228,18 @@ ${o}
228
228
 
229
229
  2. **快照获取**
230
230
  在没有获取到需要的节点信息时,使用 verbose 参数来获取更详细的节点信息。如果设置了 verbose 参数还是没有获取到节点信息,再尝试考虑其他方案。
231
+
232
+ 3. **单页应用(SPA)特性**
233
+ 如果用户开发的是单页应用(SPA),执行任务大部分情况下不需要刷新页面。
234
+
235
+ 4. **HTTP 请求成功判断(强制)**
236
+ 判断请求成功时,不要只看 HTTP 状态码!HTTP 状态码 200 并不代表业务逻辑成功。必须获取接口的详细响应内容,检查响应体中的业务状态码或错误信息。在确认请求成功之前,始终解析并检查响应体的完整内容
231
237
  `.trim();
232
238
  r.system.push(i);
233
239
  }
234
240
  }) : (c.warn("OPENCODE_CONTEXT_API_URL is not set, page context plugin will not work"), {});
235
241
  };
236
242
  export {
237
- A as PageContextPlugin,
238
- A as default
243
+ D as PageContextPlugin,
244
+ D as default
239
245
  };
@@ -138,6 +138,12 @@ ${currentPageSection}
138
138
 
139
139
  2. **\u5FEB\u7167\u83B7\u53D6**
140
140
  \u5728\u6CA1\u6709\u83B7\u53D6\u5230\u9700\u8981\u7684\u8282\u70B9\u4FE1\u606F\u65F6\uFF0C\u4F7F\u7528 verbose \u53C2\u6570\u6765\u83B7\u53D6\u66F4\u8BE6\u7EC6\u7684\u8282\u70B9\u4FE1\u606F\u3002\u5982\u679C\u8BBE\u7F6E\u4E86 verbose \u53C2\u6570\u8FD8\u662F\u6CA1\u6709\u83B7\u53D6\u5230\u8282\u70B9\u4FE1\u606F\uFF0C\u518D\u5C1D\u8BD5\u8003\u8651\u5176\u4ED6\u65B9\u6848\u3002
141
+
142
+ 3. **\u5355\u9875\u5E94\u7528\uFF08SPA\uFF09\u7279\u6027**
143
+ \u5982\u679C\u7528\u6237\u5F00\u53D1\u7684\u662F\u5355\u9875\u5E94\u7528\uFF08SPA\uFF09\uFF0C\u6267\u884C\u4EFB\u52A1\u5927\u90E8\u5206\u60C5\u51B5\u4E0B\u4E0D\u9700\u8981\u5237\u65B0\u9875\u9762\u3002
144
+
145
+ 4. **HTTP \u8BF7\u6C42\u6210\u529F\u5224\u65AD\uFF08\u5F3A\u5236\uFF09**
146
+ \u5224\u65AD\u8BF7\u6C42\u6210\u529F\u65F6\uFF0C\u4E0D\u8981\u53EA\u770B HTTP \u72B6\u6001\u7801\uFF01HTTP \u72B6\u6001\u7801 200 \u5E76\u4E0D\u4EE3\u8868\u4E1A\u52A1\u903B\u8F91\u6210\u529F\u3002\u5FC5\u987B\u83B7\u53D6\u63A5\u53E3\u7684\u8BE6\u7EC6\u54CD\u5E94\u5185\u5BB9\uFF0C\u68C0\u67E5\u54CD\u5E94\u4F53\u4E2D\u7684\u4E1A\u52A1\u72B6\u6001\u7801\u6216\u9519\u8BEF\u4FE1\u606F\u3002\u5728\u786E\u8BA4\u8BF7\u6C42\u6210\u529F\u4E4B\u524D\uFF0C\u59CB\u7EC8\u89E3\u6790\u5E76\u68C0\u67E5\u54CD\u5E94\u4F53\u7684\u5B8C\u6574\u5185\u5BB9
141
147
  `.trim();
142
148
  output.system.push(systemPrompt);
143
149
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-plugin-opencode-assistant/opencode",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
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.26"
25
+ "@vite-plugin-opencode-assistant/shared": "1.0.28"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@opencode-ai/plugin": "^1.3.15",