oh-langfuse 0.1.36 → 0.1.37

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  `oh-langfuse` 是用于给 Claude Code、OpenCode 和 Codex 配置 Langfuse 追踪的命令行工具。它提供交互式安装向导,也支持 `setup` / `check` 直接命令,方便在用户机器上安装、修复和校验配置。
4
4
 
5
- 当前 npm 版本:`0.1.36`
5
+ 当前 npm 版本:`0.1.37`
6
6
 
7
7
  ## 能做什么
8
8
 
@@ -40,7 +40,7 @@ npx oh-langfuse@latest check codex
40
40
 
41
41
  OpenCode 生成的 `launch-opencode-langfuse.*` 会在启动 agent 前执行一次更新检测:如果 npm 上的 `oh-langfuse@latest` 高于本机 runtime 版本,会提示是否更新;用户确认后才会运行 `npx oh-langfuse@latest update opencode`。Claude Code 和 Codex 也会生成对应 launcher:
42
42
 
43
- OpenCode setup 还会生成 `~/.config/opencode/bin/opencode` / `opencode.cmd` 命令包装器,并把该目录写入用户 PATH。新开终端后直接运行 `opencode`,会先检测 `oh-langfuse` runtime 是否需要更新,再转发到真实 OpenCode CLI。为了避免 Windows 下在 agent 启动链路里嵌套运行 npm installer 导致启动崩溃,`opencode` 命令只做检测和提示;需要更新时请关闭 agent 后运行提示中的 `npx oh-langfuse@latest update opencode`。
43
+ OpenCode setup 还会生成 `~/.config/opencode/bin/opencode` / `opencode.cmd` 命令包装器,并把该目录写入用户 PATH。新开终端后直接运行 `opencode`,会先用轻量脚本检测 `oh-langfuse` runtime 是否需要更新,再转发到真实 OpenCode CLI。为了避免 Windows 下在 agent 启动链路里嵌套运行 Node/npm installer 导致启动崩溃,`opencode` 命令只做检测和提示;需要更新时请关闭 agent 后运行提示中的 `npx oh-langfuse@latest update opencode`。
44
44
 
45
45
  - `~/.claude/launch-claude-langfuse.cmd` / `~/.claude/launch-claude-langfuse.sh`
46
46
  - `~/.codex/launch-codex-langfuse.cmd` / `~/.codex/launch-codex-langfuse.sh`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-langfuse",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Use npm scripts to configure Claude Code / OpenCode / Codex with Langfuse tracing.",
@@ -588,15 +588,13 @@ function syncPluginPackageToLocalPlugins({ pkgDir, pluginDest, pluginsDir }) {
588
588
  function writeWindowsLauncherCmd(opencodeDir, { publicKey, secretKey, baseUrl, userId }) {
589
589
  if (process.platform !== "win32") return null;
590
590
  const p = path.join(opencodeDir, "launch-opencode-langfuse.cmd");
591
- const cmd = ["@echo off", "REM Auto-generated by scripts/opencode-langfuse-setup.mjs"];
591
+ writeWindowsUpdateCheckScript(opencodeDir);
592
+ const cmd = ["@echo off", "REM Auto-generated by scripts/opencode-langfuse-setup.mjs"];
592
593
  cmd.push(`set LANGFUSE_PUBLIC_KEY=${publicKey}`);
593
594
  cmd.push(`set LANGFUSE_SECRET_KEY=${secretKey}`);
594
595
  cmd.push(`set LANGFUSE_BASEURL=${baseUrl}`);
595
596
  if (userId) cmd.push(`set LANGFUSE_USER_ID=${userId}`);
596
- cmd.push("where npx >nul 2>nul");
597
- cmd.push("if %ERRORLEVEL% EQU 0 (");
598
- cmd.push(" call npx -y oh-langfuse@latest auto-update opencode --skip-check --notify-only");
599
- cmd.push(")");
597
+ cmd.push('powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0oh-langfuse-opencode-update-check.ps1"');
600
598
  cmd.push('if exist "%USERPROFILE%\\.opencode\\bin\\opencode.exe" (');
601
599
  cmd.push(' "%USERPROFILE%\\.opencode\\bin\\opencode.exe" %*');
602
600
  cmd.push(" exit /b %ERRORLEVEL%");
@@ -610,21 +608,41 @@ function shQuote(s) {
610
608
  return `'${String(s).replace(/'/g, "'\"'\"'")}'`;
611
609
  }
612
610
 
611
+ function writeWindowsUpdateCheckScript(dir) {
612
+ if (process.platform !== "win32") return null;
613
+ ensureDir(dir);
614
+ const p = path.join(dir, "oh-langfuse-opencode-update-check.ps1");
615
+ const ps = [
616
+ "$ErrorActionPreference = 'SilentlyContinue'",
617
+ "$statePath = Join-Path $env:USERPROFILE '.config\\oh-langfuse\\runtime.json'",
618
+ "if (-not (Test-Path -LiteralPath $statePath)) { exit 0 }",
619
+ "$state = Get-Content -LiteralPath $statePath -Raw | ConvertFrom-Json",
620
+ "$installed = $state.targets.opencode.packageVersion",
621
+ "$meta = Invoke-RestMethod -UseBasicParsing -Uri 'https://registry.npmjs.org/oh-langfuse' -TimeoutSec 3",
622
+ "$latest = $meta.'dist-tags'.latest",
623
+ "if ($installed -and $latest -and ([version]$latest -gt [version]$installed)) {",
624
+ " Write-Host \"[INFO] oh-langfuse opencode runtime update available: $installed -> $latest\"",
625
+ " Write-Host '[INFO] Close OpenCode and run: npx oh-langfuse@latest update opencode'",
626
+ "}",
627
+ ""
628
+ ].join("\r\n");
629
+ fs.writeFileSync(p, ps, "utf8");
630
+ return p;
631
+ }
632
+
613
633
  function writeOpencodeCommandShim(opencodeDir, { publicKey, secretKey, baseUrl, userId, realOpencodeCli }) {
614
634
  const shimDir = path.join(opencodeDir, "bin");
615
635
  ensureDir(shimDir);
616
636
  if (process.platform === "win32") {
617
637
  const shim = path.join(shimDir, "opencode.cmd");
638
+ writeWindowsUpdateCheckScript(shimDir);
618
639
  const cmd = ["@echo off", "REM Auto-generated by scripts/opencode-langfuse-setup.mjs"];
619
640
  cmd.push("set OH_LANGFUSE_OPENCODE_SHIM=1");
620
641
  cmd.push(`set LANGFUSE_PUBLIC_KEY=${publicKey}`);
621
642
  cmd.push(`set LANGFUSE_SECRET_KEY=${secretKey}`);
622
643
  cmd.push(`set LANGFUSE_BASEURL=${baseUrl}`);
623
644
  if (userId) cmd.push(`set LANGFUSE_USER_ID=${userId}`);
624
- cmd.push("where npx >nul 2>nul");
625
- cmd.push("if %ERRORLEVEL% EQU 0 (");
626
- cmd.push(" call npx -y oh-langfuse@latest auto-update opencode --skip-check --notify-only");
627
- cmd.push(")");
645
+ cmd.push('powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0oh-langfuse-opencode-update-check.ps1"');
628
646
  cmd.push(`call ${cmdQuote(realOpencodeCli)} %*`);
629
647
  cmd.push("exit /b %ERRORLEVEL%");
630
648
  fs.writeFileSync(shim, cmd.join("\r\n") + "\r\n", "utf8");