oh-langfuse 0.1.10 → 0.1.11
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/package.json
CHANGED
|
@@ -53,23 +53,24 @@ function main() {
|
|
|
53
53
|
detail: JSON.stringify(settings?.plugin ?? null)
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
results.push({
|
|
57
|
-
item: "npm 包目录 node_modules/opencode-plugin-langfuse",
|
|
58
|
-
ok: fs.existsSync(pkgDir),
|
|
59
|
-
detail: pkgDir
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
56
|
+
results.push({
|
|
57
|
+
item: "npm 包目录 node_modules/opencode-plugin-langfuse",
|
|
58
|
+
ok: fs.existsSync(pkgDir),
|
|
59
|
+
detail: pkgDir
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
results.push({
|
|
63
|
+
item: "plugins 目录本地插件",
|
|
64
|
+
ok: fs.existsSync(path.join(pluginDest, "package.json")),
|
|
65
|
+
detail: pluginDest
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const launcherPath = path.join(opencodeDir, "launch-opencode-langfuse.cmd");
|
|
69
|
+
if (process.platform === "win32") {
|
|
70
|
+
results.push({
|
|
71
|
+
item: "启动脚本 launch-opencode-langfuse.cmd",
|
|
72
|
+
ok: fs.existsSync(launcherPath),
|
|
73
|
+
detail: launcherPath
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -188,11 +188,19 @@ function getPatchedLangfuseDistIndexJs() {
|
|
|
188
188
|
].join(os.EOL);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
function patchDistIndexJs(distIndexPath) {
|
|
192
|
-
const code = getPatchedLangfuseDistIndexJs();
|
|
193
|
-
ensureDir(path.dirname(distIndexPath));
|
|
194
|
-
fs.writeFileSync(distIndexPath, code + os.EOL, "utf8");
|
|
195
|
-
}
|
|
191
|
+
function patchDistIndexJs(distIndexPath) {
|
|
192
|
+
const code = getPatchedLangfuseDistIndexJs();
|
|
193
|
+
ensureDir(path.dirname(distIndexPath));
|
|
194
|
+
fs.writeFileSync(distIndexPath, code + os.EOL, "utf8");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function syncPluginPackageToLocalPlugins({ pkgDir, pluginDest, pluginsDir }) {
|
|
198
|
+
ensureDir(pluginsDir);
|
|
199
|
+
if (fs.existsSync(pluginDest)) {
|
|
200
|
+
fs.rmSync(pluginDest, { recursive: true, force: true });
|
|
201
|
+
}
|
|
202
|
+
fs.cpSync(pkgDir, pluginDest, { recursive: true });
|
|
203
|
+
}
|
|
196
204
|
|
|
197
205
|
function writeWindowsLauncherCmd(opencodeDir, { publicKey, secretKey, baseUrl, userId }) {
|
|
198
206
|
if (process.platform !== "win32") return null;
|
|
@@ -383,28 +391,21 @@ function main() {
|
|
|
383
391
|
);
|
|
384
392
|
}
|
|
385
393
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
if (process.platform === "win32") {
|
|
403
|
-
const distIndexInPlugins = path.join(pluginDest, "dist", "index.js");
|
|
404
|
-
if (fs.existsSync(distIndexInPlugins)) {
|
|
405
|
-
patchDistIndexJs(distIndexInPlugins);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
394
|
+
const existing = readJsonIfExists(opencodeJsonPath) ?? {};
|
|
395
|
+
// Patch the official plugin to inject userId and make behavior consistent.
|
|
396
|
+
const distIndexInNodeModules = path.join(pkgDir, "dist", "index.js");
|
|
397
|
+
if (fs.existsSync(distIndexInNodeModules)) {
|
|
398
|
+
patchDistIndexJs(distIndexInNodeModules);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
console.log("Syncing plugin into ~/.config/opencode/plugins/ ...");
|
|
402
|
+
syncPluginPackageToLocalPlugins({ pkgDir, pluginDest, pluginsDir });
|
|
403
|
+
console.log(`Plugin ready at: ${pluginDest}`);
|
|
404
|
+
|
|
405
|
+
const distIndexInPlugins = path.join(pluginDest, "dist", "index.js");
|
|
406
|
+
if (fs.existsSync(distIndexInPlugins)) {
|
|
407
|
+
patchDistIndexJs(distIndexInPlugins);
|
|
408
|
+
}
|
|
408
409
|
|
|
409
410
|
// Write plugin user config to support userId injection.
|
|
410
411
|
if (userId) {
|