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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-langfuse",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Use npm scripts to configure Claude Code / OpenCode / Codex with Langfuse tracing.",
@@ -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
- const launcherPath = path.join(opencodeDir, "launch-opencode-langfuse.cmd");
63
- if (process.platform === "win32") {
64
- results.push({
65
- item: "plugins 目录(Windows 要求)",
66
- ok: fs.existsSync(path.join(pluginDest, "package.json")),
67
- detail: pluginDest
68
- });
69
- results.push({
70
- item: "启动脚本 launch-opencode-langfuse.cmd",
71
- ok: fs.existsSync(launcherPath),
72
- detail: launcherPath
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
- if (process.platform === "win32") {
387
- console.log("Windows:将插件复制到 ~/.config/opencode/plugins/ …");
388
- ensureDir(pluginsDir);
389
- if (fs.existsSync(pluginDest)) {
390
- fs.rmSync(pluginDest, { recursive: true, force: true });
391
- }
392
- fs.cpSync(pkgDir, pluginDest, { recursive: true });
393
- console.log(`已复制到:${pluginDest}`);
394
- }
395
-
396
- const existing = readJsonIfExists(opencodeJsonPath) ?? {};
397
- // Patch the official plugin to inject userId and make behavior consistent.
398
- const distIndexInNodeModules = path.join(pkgDir, "dist", "index.js");
399
- if (fs.existsSync(distIndexInNodeModules)) {
400
- patchDistIndexJs(distIndexInNodeModules);
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) {