@vite-plugin-opencode-assistant/opencode 1.0.58 → 1.0.60

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.
@@ -45,7 +45,6 @@ var import_plugin = require("@opencode-ai/plugin");
45
45
  var import_shared = require("@vite-plugin-opencode-assistant/shared");
46
46
  const log = (0, import_shared.createLogger)("ServiceLogsPlugin");
47
47
  const ServiceLogsPlugin = () => __async(null, null, function* () {
48
- var _a;
49
48
  log.debug("ServiceLogsPlugin loading...");
50
49
  const logFilesJson = process.env.OPENCODE_LOG_FILES_JSON;
51
50
  log.debug("Log files JSON from env:", { logFilesJson: logFilesJson ? "set" : "not set" });
@@ -65,20 +64,9 @@ const ServiceLogsPlugin = () => __async(null, null, function* () {
65
64
  log.debug("No log files configured, plugin will not register any tools");
66
65
  return {};
67
66
  }
68
- const watcher = (0, import_shared.getServiceLogWatcher)();
69
- watcher.setProjectRoot(process.cwd());
70
- for (const logFileConfig of logFiles) {
71
- watcher.addLogFile({
72
- name: logFileConfig.name,
73
- filePath: logFileConfig.path,
74
- maxBufferSize: logFileConfig.maxBufferSize,
75
- watchExisting: logFileConfig.watchExisting
76
- });
77
- log.debug(`Added log file watcher: ${logFileConfig.name} -> ${logFileConfig.path}`);
78
- }
79
67
  const tools = {};
80
68
  for (const logFileConfig of logFiles) {
81
- let _b;
69
+ let _a;
82
70
  const toolName = `get_${logFileConfig.name}_logs`;
83
71
  const description = `\u83B7\u53D6 ${logFileConfig.name} \u7684\u65E5\u5FD7\u3002
84
72
 
@@ -87,7 +75,7 @@ ${logFileConfig.description}
87
75
 
88
76
  **\u65E5\u5FD7\u5185\u5BB9**\uFF1A
89
77
  - \u6765\u81EA\u65E5\u5FD7\u6587\u4EF6 ${logFileConfig.path} \u7684\u5B9E\u65F6\u65E5\u5FD7
90
- - \u6700\u591A\u4FDD\u7559 ${(_a = logFileConfig.maxBufferSize) != null ? _a : 200} \u6761\u65E5\u5FD7`;
78
+ - \u9ED8\u8BA4\u8FD4\u56DE\u6700\u8FD1 200 \u884C\u65E5\u5FD7`;
91
79
  const getLogsTool = (0, import_plugin.tool)({
92
80
  description,
93
81
  args: {
@@ -105,28 +93,28 @@ ${logFileConfig.description}
105
93
  sessionID: context.sessionID,
106
94
  directory: context.directory
107
95
  });
108
- const buffer = watcher.getBuffer(logFileConfig.name);
109
- if (!buffer) {
110
- return `\u65E5\u5FD7\u6587\u4EF6 "${logFileConfig.name}" \u672A\u627E\u5230\u3002\u8BF7\u68C0\u67E5\u914D\u7F6E\u3002`;
111
- }
112
- const logs = buffer.getLogs({
96
+ const entries = yield (0, import_shared.readLogFileTail)({
97
+ name: logFileConfig.name,
98
+ filePath: logFileConfig.path,
99
+ projectRoot: process.cwd(),
100
+ lines: limit ? Math.max(limit, 200) : 200,
113
101
  level: level ? level.split(",").map((l) => l.trim()) : void 0,
114
- limit,
115
102
  since
116
103
  });
117
- if (logs.length === 0) {
118
- return `\u5F53\u524D\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u65E5\u5FD7\uFF08\u7F13\u51B2\u533A\u5171 ${buffer.size()} \u6761\uFF09\u3002
104
+ const filteredEntries = entries.slice(0, limit != null ? limit : 50);
105
+ if (filteredEntries.length === 0) {
106
+ return `\u5F53\u524D\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u65E5\u5FD7\u3002
119
107
 
120
108
  \u5EFA\u8BAE\uFF1A
121
109
  - \u4E0D\u6307\u5B9A\u53C2\u6570\u83B7\u53D6\u6240\u6709\u65E5\u5FD7
122
110
  - \u4F7F\u7528 level=error,warn \u83B7\u53D6\u9519\u8BEF\u548C\u8B66\u544A`;
123
111
  }
124
- const formattedLogs = logs.map((entry) => {
112
+ const formattedLogs = filteredEntries.map((entry) => {
125
113
  const time = new Date(entry.timestamp).toLocaleTimeString();
126
114
  const levelIcon = entry.level === "error" ? "\u274C" : entry.level === "warn" ? "\u26A0\uFE0F" : "\u2139\uFE0F";
127
115
  return `${time} ${levelIcon} ${entry.message}`;
128
116
  }).join("\n");
129
- return `${logFileConfig.name} \u65E5\u5FD7\uFF08${logs.length}/${buffer.size()} \u6761\uFF09\uFF1A
117
+ return `${logFileConfig.name} \u65E5\u5FD7\uFF08${filteredEntries.length} \u6761\uFF09\uFF1A
130
118
 
131
119
  ${formattedLogs}`;
132
120
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-plugin-opencode-assistant/opencode",
3
- "version": "1.0.58",
3
+ "version": "1.0.60",
4
4
  "type": "module",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "es/index.mjs",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "execa": "^9.6.1",
25
- "@vite-plugin-opencode-assistant/shared": "1.0.58"
25
+ "@vite-plugin-opencode-assistant/shared": "1.0.60"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@opencode-ai/plugin": "^1.3.15",