vite-plugin-opencode-assistant 1.0.69 → 1.0.71
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/es/core/opencode-web.d.ts +4 -0
- package/es/core/opencode-web.mjs +186 -0
- package/es/core/service.mjs +1 -1
- package/lib/core/opencode-web.cjs +218 -0
- package/lib/core/opencode-web.d.ts +4 -0
- package/lib/core/service.cjs +3 -3
- package/package.json +4 -4
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { execa } from "execa";
|
|
21
|
+
import fs from "fs";
|
|
22
|
+
import { createRequire } from "module";
|
|
23
|
+
import path from "path";
|
|
24
|
+
import { createLogger, getProcessLogBuffer } from "@vite-plugin-opencode-assistant/shared";
|
|
25
|
+
const require2 = createRequire(path.join(process.cwd(), "package.json"));
|
|
26
|
+
const packageDir = resolvePackageDir();
|
|
27
|
+
const log = createLogger("OpenCodeWeb");
|
|
28
|
+
function prepareOpenCodeRuntime(cwd) {
|
|
29
|
+
const cacheDir = path.join(cwd, "node_modules", ".cache", "opencode");
|
|
30
|
+
const pluginsDir = path.join(cacheDir, "plugins");
|
|
31
|
+
log.debug("Setting up OpenCode runtime", { cacheDir, pluginsDir });
|
|
32
|
+
if (!fs.existsSync(pluginsDir)) {
|
|
33
|
+
fs.mkdirSync(pluginsDir, { recursive: true });
|
|
34
|
+
}
|
|
35
|
+
const sourcePluginsDir = resolveSourcePluginsDir();
|
|
36
|
+
copyPluginFiles(sourcePluginsDir, pluginsDir);
|
|
37
|
+
const mcpConfigPath = path.join(cacheDir, "opencode.json");
|
|
38
|
+
fs.writeFileSync(
|
|
39
|
+
mcpConfigPath,
|
|
40
|
+
JSON.stringify(
|
|
41
|
+
{
|
|
42
|
+
mcp: {
|
|
43
|
+
"chrome-devtools": {
|
|
44
|
+
type: "local",
|
|
45
|
+
command: ["npx", "-y", "chrome-devtools-mcp@latest", "--autoConnect"],
|
|
46
|
+
enabled: true
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
null,
|
|
51
|
+
2
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
log.debug("OpenCode runtime ready", {
|
|
55
|
+
cacheDir,
|
|
56
|
+
pluginsDir,
|
|
57
|
+
mcpConfigPath
|
|
58
|
+
});
|
|
59
|
+
return cacheDir;
|
|
60
|
+
}
|
|
61
|
+
function startOpenCodeWeb(options) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const { port, hostname, cwd, configDir, corsOrigins, contextApiUrl, logsApiUrl, logFilesJson } = options;
|
|
64
|
+
const stateDir = createStateDirectory(cwd);
|
|
65
|
+
const pluginsDir = path.join(stateDir, "plugins");
|
|
66
|
+
const pluginPaths = [
|
|
67
|
+
path.join(pluginsDir, "page-context.js"),
|
|
68
|
+
path.join(pluginsDir, "vite-logs.js")
|
|
69
|
+
];
|
|
70
|
+
if (logFilesJson) {
|
|
71
|
+
pluginPaths.push(path.join(pluginsDir, "service-logs.js"));
|
|
72
|
+
}
|
|
73
|
+
const pluginPathsStr = pluginPaths.join(",");
|
|
74
|
+
log.debug("Building process environment", {
|
|
75
|
+
stateDir,
|
|
76
|
+
configDir,
|
|
77
|
+
contextApiUrl,
|
|
78
|
+
logsApiUrl,
|
|
79
|
+
logFilesJson,
|
|
80
|
+
pluginPathsStr
|
|
81
|
+
});
|
|
82
|
+
const env = buildProcessEnv(
|
|
83
|
+
stateDir,
|
|
84
|
+
configDir,
|
|
85
|
+
contextApiUrl,
|
|
86
|
+
logsApiUrl,
|
|
87
|
+
pluginPathsStr,
|
|
88
|
+
logFilesJson
|
|
89
|
+
);
|
|
90
|
+
const args = ["serve", "--port", String(port), "--hostname", hostname];
|
|
91
|
+
if (corsOrigins && corsOrigins.length > 0) {
|
|
92
|
+
corsOrigins.forEach((origin) => {
|
|
93
|
+
args.push("--cors", origin);
|
|
94
|
+
});
|
|
95
|
+
log.debug("CORS origins added", { origins: corsOrigins });
|
|
96
|
+
}
|
|
97
|
+
log.debug("Spawning OpenCode process", {
|
|
98
|
+
command: "opencode",
|
|
99
|
+
args: args.join(" "),
|
|
100
|
+
cwd
|
|
101
|
+
});
|
|
102
|
+
const proc = execa("opencode", args, {
|
|
103
|
+
cwd,
|
|
104
|
+
env,
|
|
105
|
+
reject: false,
|
|
106
|
+
cleanup: true
|
|
107
|
+
});
|
|
108
|
+
(_a = proc.stdout) == null ? void 0 : _a.on("data", (data) => {
|
|
109
|
+
const output = data.toString().trim();
|
|
110
|
+
if (output) {
|
|
111
|
+
log.debug("[OpenCode stdout]", { output });
|
|
112
|
+
getProcessLogBuffer().addOpenCodeStdout(output);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
(_b = proc.stderr) == null ? void 0 : _b.on("data", (data) => {
|
|
116
|
+
const output = data.toString().trim();
|
|
117
|
+
if (output) {
|
|
118
|
+
log.warn("[OpenCode stderr]", { output });
|
|
119
|
+
getProcessLogBuffer().addOpenCodeStderr(output);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return proc;
|
|
123
|
+
}
|
|
124
|
+
function createStateDirectory(cwd) {
|
|
125
|
+
const stateDir = path.join(cwd, "node_modules", ".cache", "opencode");
|
|
126
|
+
if (!fs.existsSync(stateDir)) {
|
|
127
|
+
fs.mkdirSync(stateDir, { recursive: true });
|
|
128
|
+
log.debug("Created state directory", { stateDir });
|
|
129
|
+
}
|
|
130
|
+
return stateDir;
|
|
131
|
+
}
|
|
132
|
+
function resolvePackageDir() {
|
|
133
|
+
const entryPath = require2.resolve("@vite-plugin-opencode-assistant/opencode");
|
|
134
|
+
return path.dirname(path.dirname(entryPath));
|
|
135
|
+
}
|
|
136
|
+
function resolveSourcePluginsDir() {
|
|
137
|
+
const candidatePaths = [path.join(packageDir, "es", "plugins")];
|
|
138
|
+
for (const candidatePath of candidatePaths) {
|
|
139
|
+
if (fs.existsSync(candidatePath)) {
|
|
140
|
+
return candidatePath;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return candidatePaths[0];
|
|
144
|
+
}
|
|
145
|
+
function copyPluginFiles(sourceDir, targetDir) {
|
|
146
|
+
const files = fs.readdirSync(sourceDir).filter((f) => f.endsWith(".js") || f.endsWith(".d.ts"));
|
|
147
|
+
for (const file of files) {
|
|
148
|
+
const sourcePath = path.join(sourceDir, file);
|
|
149
|
+
const targetPath = path.join(targetDir, file);
|
|
150
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
151
|
+
log.debug("Plugin file copied", { source: sourcePath, target: targetPath });
|
|
152
|
+
}
|
|
153
|
+
log.debug("All plugin files copied", { count: files.length, files });
|
|
154
|
+
}
|
|
155
|
+
function buildProcessEnv(stateDir, configDir, contextApiUrl, logsApiUrl, pluginPaths, logFilesJson) {
|
|
156
|
+
const env = __spreadProps(__spreadValues({}, Object.fromEntries(
|
|
157
|
+
Object.entries(process.env).filter(([, v]) => v !== void 0)
|
|
158
|
+
)), {
|
|
159
|
+
XDG_STATE_HOME: stateDir
|
|
160
|
+
});
|
|
161
|
+
if (configDir) {
|
|
162
|
+
env.OPENCODE_CONFIG_DIR = configDir;
|
|
163
|
+
log.debug("Set OPENCODE_CONFIG_DIR", { configDir });
|
|
164
|
+
}
|
|
165
|
+
if (contextApiUrl) {
|
|
166
|
+
env.OPENCODE_CONTEXT_API_URL = contextApiUrl;
|
|
167
|
+
log.debug("Set OPENCODE_CONTEXT_API_URL", { contextApiUrl });
|
|
168
|
+
}
|
|
169
|
+
if (logsApiUrl) {
|
|
170
|
+
env.OPENCODE_VITE_LOGS_API_URL = logsApiUrl;
|
|
171
|
+
log.debug("Set OPENCODE_VITE_LOGS_API_URL", { logsApiUrl });
|
|
172
|
+
}
|
|
173
|
+
if (pluginPaths) {
|
|
174
|
+
env.OPENCODE_PLUGINS = pluginPaths;
|
|
175
|
+
log.debug("Set OPENCODE_PLUGINS", { pluginPaths });
|
|
176
|
+
}
|
|
177
|
+
if (logFilesJson) {
|
|
178
|
+
env.OPENCODE_LOG_FILES_JSON = logFilesJson;
|
|
179
|
+
log.debug("Set OPENCODE_LOG_FILES_JSON", { logFilesJson });
|
|
180
|
+
}
|
|
181
|
+
return env;
|
|
182
|
+
}
|
|
183
|
+
export {
|
|
184
|
+
prepareOpenCodeRuntime,
|
|
185
|
+
startOpenCodeWeb
|
|
186
|
+
};
|
package/es/core/service.mjs
CHANGED
|
@@ -35,7 +35,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
35
35
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
|
-
import { prepareOpenCodeRuntime, startOpenCodeWeb } from "
|
|
38
|
+
import { prepareOpenCodeRuntime, startOpenCodeWeb } from "./opencode-web.mjs";
|
|
39
39
|
import {
|
|
40
40
|
DEFAULT_PROXY_PORT,
|
|
41
41
|
SERVER_START_TIMEOUT,
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
41
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
42
|
+
mod
|
|
43
|
+
));
|
|
44
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
|
+
var opencode_web_exports = {};
|
|
46
|
+
__export(opencode_web_exports, {
|
|
47
|
+
prepareOpenCodeRuntime: () => prepareOpenCodeRuntime,
|
|
48
|
+
startOpenCodeWeb: () => startOpenCodeWeb
|
|
49
|
+
});
|
|
50
|
+
module.exports = __toCommonJS(opencode_web_exports);
|
|
51
|
+
var import_execa = require("execa");
|
|
52
|
+
var import_fs = __toESM(require("fs"));
|
|
53
|
+
var import_module = require("module");
|
|
54
|
+
var import_path = __toESM(require("path"));
|
|
55
|
+
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
56
|
+
const require2 = (0, import_module.createRequire)(import_path.default.join(process.cwd(), "package.json"));
|
|
57
|
+
const packageDir = resolvePackageDir();
|
|
58
|
+
const log = (0, import_shared.createLogger)("OpenCodeWeb");
|
|
59
|
+
function prepareOpenCodeRuntime(cwd) {
|
|
60
|
+
const cacheDir = import_path.default.join(cwd, "node_modules", ".cache", "opencode");
|
|
61
|
+
const pluginsDir = import_path.default.join(cacheDir, "plugins");
|
|
62
|
+
log.debug("Setting up OpenCode runtime", { cacheDir, pluginsDir });
|
|
63
|
+
if (!import_fs.default.existsSync(pluginsDir)) {
|
|
64
|
+
import_fs.default.mkdirSync(pluginsDir, { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
const sourcePluginsDir = resolveSourcePluginsDir();
|
|
67
|
+
copyPluginFiles(sourcePluginsDir, pluginsDir);
|
|
68
|
+
const mcpConfigPath = import_path.default.join(cacheDir, "opencode.json");
|
|
69
|
+
import_fs.default.writeFileSync(
|
|
70
|
+
mcpConfigPath,
|
|
71
|
+
JSON.stringify(
|
|
72
|
+
{
|
|
73
|
+
mcp: {
|
|
74
|
+
"chrome-devtools": {
|
|
75
|
+
type: "local",
|
|
76
|
+
command: ["npx", "-y", "chrome-devtools-mcp@latest", "--autoConnect"],
|
|
77
|
+
enabled: true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
null,
|
|
82
|
+
2
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
log.debug("OpenCode runtime ready", {
|
|
86
|
+
cacheDir,
|
|
87
|
+
pluginsDir,
|
|
88
|
+
mcpConfigPath
|
|
89
|
+
});
|
|
90
|
+
return cacheDir;
|
|
91
|
+
}
|
|
92
|
+
function startOpenCodeWeb(options) {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
const { port, hostname, cwd, configDir, corsOrigins, contextApiUrl, logsApiUrl, logFilesJson } = options;
|
|
95
|
+
const stateDir = createStateDirectory(cwd);
|
|
96
|
+
const pluginsDir = import_path.default.join(stateDir, "plugins");
|
|
97
|
+
const pluginPaths = [
|
|
98
|
+
import_path.default.join(pluginsDir, "page-context.js"),
|
|
99
|
+
import_path.default.join(pluginsDir, "vite-logs.js")
|
|
100
|
+
];
|
|
101
|
+
if (logFilesJson) {
|
|
102
|
+
pluginPaths.push(import_path.default.join(pluginsDir, "service-logs.js"));
|
|
103
|
+
}
|
|
104
|
+
const pluginPathsStr = pluginPaths.join(",");
|
|
105
|
+
log.debug("Building process environment", {
|
|
106
|
+
stateDir,
|
|
107
|
+
configDir,
|
|
108
|
+
contextApiUrl,
|
|
109
|
+
logsApiUrl,
|
|
110
|
+
logFilesJson,
|
|
111
|
+
pluginPathsStr
|
|
112
|
+
});
|
|
113
|
+
const env = buildProcessEnv(
|
|
114
|
+
stateDir,
|
|
115
|
+
configDir,
|
|
116
|
+
contextApiUrl,
|
|
117
|
+
logsApiUrl,
|
|
118
|
+
pluginPathsStr,
|
|
119
|
+
logFilesJson
|
|
120
|
+
);
|
|
121
|
+
const args = ["serve", "--port", String(port), "--hostname", hostname];
|
|
122
|
+
if (corsOrigins && corsOrigins.length > 0) {
|
|
123
|
+
corsOrigins.forEach((origin) => {
|
|
124
|
+
args.push("--cors", origin);
|
|
125
|
+
});
|
|
126
|
+
log.debug("CORS origins added", { origins: corsOrigins });
|
|
127
|
+
}
|
|
128
|
+
log.debug("Spawning OpenCode process", {
|
|
129
|
+
command: "opencode",
|
|
130
|
+
args: args.join(" "),
|
|
131
|
+
cwd
|
|
132
|
+
});
|
|
133
|
+
const proc = (0, import_execa.execa)("opencode", args, {
|
|
134
|
+
cwd,
|
|
135
|
+
env,
|
|
136
|
+
reject: false,
|
|
137
|
+
cleanup: true
|
|
138
|
+
});
|
|
139
|
+
(_a = proc.stdout) == null ? void 0 : _a.on("data", (data) => {
|
|
140
|
+
const output = data.toString().trim();
|
|
141
|
+
if (output) {
|
|
142
|
+
log.debug("[OpenCode stdout]", { output });
|
|
143
|
+
(0, import_shared.getProcessLogBuffer)().addOpenCodeStdout(output);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
(_b = proc.stderr) == null ? void 0 : _b.on("data", (data) => {
|
|
147
|
+
const output = data.toString().trim();
|
|
148
|
+
if (output) {
|
|
149
|
+
log.warn("[OpenCode stderr]", { output });
|
|
150
|
+
(0, import_shared.getProcessLogBuffer)().addOpenCodeStderr(output);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return proc;
|
|
154
|
+
}
|
|
155
|
+
function createStateDirectory(cwd) {
|
|
156
|
+
const stateDir = import_path.default.join(cwd, "node_modules", ".cache", "opencode");
|
|
157
|
+
if (!import_fs.default.existsSync(stateDir)) {
|
|
158
|
+
import_fs.default.mkdirSync(stateDir, { recursive: true });
|
|
159
|
+
log.debug("Created state directory", { stateDir });
|
|
160
|
+
}
|
|
161
|
+
return stateDir;
|
|
162
|
+
}
|
|
163
|
+
function resolvePackageDir() {
|
|
164
|
+
const entryPath = require2.resolve("@vite-plugin-opencode-assistant/opencode");
|
|
165
|
+
return import_path.default.dirname(import_path.default.dirname(entryPath));
|
|
166
|
+
}
|
|
167
|
+
function resolveSourcePluginsDir() {
|
|
168
|
+
const candidatePaths = [import_path.default.join(packageDir, "es", "plugins")];
|
|
169
|
+
for (const candidatePath of candidatePaths) {
|
|
170
|
+
if (import_fs.default.existsSync(candidatePath)) {
|
|
171
|
+
return candidatePath;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return candidatePaths[0];
|
|
175
|
+
}
|
|
176
|
+
function copyPluginFiles(sourceDir, targetDir) {
|
|
177
|
+
const files = import_fs.default.readdirSync(sourceDir).filter((f) => f.endsWith(".js") || f.endsWith(".d.ts"));
|
|
178
|
+
for (const file of files) {
|
|
179
|
+
const sourcePath = import_path.default.join(sourceDir, file);
|
|
180
|
+
const targetPath = import_path.default.join(targetDir, file);
|
|
181
|
+
import_fs.default.copyFileSync(sourcePath, targetPath);
|
|
182
|
+
log.debug("Plugin file copied", { source: sourcePath, target: targetPath });
|
|
183
|
+
}
|
|
184
|
+
log.debug("All plugin files copied", { count: files.length, files });
|
|
185
|
+
}
|
|
186
|
+
function buildProcessEnv(stateDir, configDir, contextApiUrl, logsApiUrl, pluginPaths, logFilesJson) {
|
|
187
|
+
const env = __spreadProps(__spreadValues({}, Object.fromEntries(
|
|
188
|
+
Object.entries(process.env).filter(([, v]) => v !== void 0)
|
|
189
|
+
)), {
|
|
190
|
+
XDG_STATE_HOME: stateDir
|
|
191
|
+
});
|
|
192
|
+
if (configDir) {
|
|
193
|
+
env.OPENCODE_CONFIG_DIR = configDir;
|
|
194
|
+
log.debug("Set OPENCODE_CONFIG_DIR", { configDir });
|
|
195
|
+
}
|
|
196
|
+
if (contextApiUrl) {
|
|
197
|
+
env.OPENCODE_CONTEXT_API_URL = contextApiUrl;
|
|
198
|
+
log.debug("Set OPENCODE_CONTEXT_API_URL", { contextApiUrl });
|
|
199
|
+
}
|
|
200
|
+
if (logsApiUrl) {
|
|
201
|
+
env.OPENCODE_VITE_LOGS_API_URL = logsApiUrl;
|
|
202
|
+
log.debug("Set OPENCODE_VITE_LOGS_API_URL", { logsApiUrl });
|
|
203
|
+
}
|
|
204
|
+
if (pluginPaths) {
|
|
205
|
+
env.OPENCODE_PLUGINS = pluginPaths;
|
|
206
|
+
log.debug("Set OPENCODE_PLUGINS", { pluginPaths });
|
|
207
|
+
}
|
|
208
|
+
if (logFilesJson) {
|
|
209
|
+
env.OPENCODE_LOG_FILES_JSON = logFilesJson;
|
|
210
|
+
log.debug("Set OPENCODE_LOG_FILES_JSON", { logFilesJson });
|
|
211
|
+
}
|
|
212
|
+
return env;
|
|
213
|
+
}
|
|
214
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
215
|
+
0 && (module.exports = {
|
|
216
|
+
prepareOpenCodeRuntime,
|
|
217
|
+
startOpenCodeWeb
|
|
218
|
+
});
|
package/lib/core/service.cjs
CHANGED
|
@@ -55,7 +55,7 @@ __export(service_exports, {
|
|
|
55
55
|
OpenCodeService: () => OpenCodeService
|
|
56
56
|
});
|
|
57
57
|
module.exports = __toCommonJS(service_exports);
|
|
58
|
-
var
|
|
58
|
+
var import_opencode_web = require("./opencode-web.cjs");
|
|
59
59
|
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
60
60
|
var import_system = require("../utils/system.cjs");
|
|
61
61
|
var import_proxy_server = require("./proxy-server.cjs");
|
|
@@ -155,7 +155,7 @@ Please install OpenCode first:
|
|
|
155
155
|
this.workspaceRoot = (0, import_system.findGitRoot)(process.cwd());
|
|
156
156
|
log.debug(`Using workspace root: ${this.workspaceRoot}`);
|
|
157
157
|
this.sendTaskUpdate("preparing_runtime");
|
|
158
|
-
const configDir = (0,
|
|
158
|
+
const configDir = (0, import_opencode_web.prepareOpenCodeRuntime)(this.workspaceRoot);
|
|
159
159
|
timer.checkpoint("Plugin setup complete");
|
|
160
160
|
this.sendTaskUpdate("starting_web");
|
|
161
161
|
log.debug("Starting OpenCode Web process...", {
|
|
@@ -163,7 +163,7 @@ Please install OpenCode first:
|
|
|
163
163
|
hostname: this.config.hostname,
|
|
164
164
|
configDir
|
|
165
165
|
});
|
|
166
|
-
this.webProcess = (0,
|
|
166
|
+
this.webProcess = (0, import_opencode_web.startOpenCodeWeb)({
|
|
167
167
|
port: this.actualWebPort,
|
|
168
168
|
hostname: this.config.hostname,
|
|
169
169
|
serverUrl: "",
|
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.71",
|
|
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.cjs",
|
|
@@ -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.71",
|
|
40
|
+
"@vite-plugin-opencode-assistant/opencode": "1.0.71",
|
|
41
|
+
"@vite-plugin-opencode-assistant/shared": "1.0.71"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"vite": ">=4.0.0"
|