oh-langfuse 0.1.49 → 0.1.51

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.49",
3
+ "version": "0.1.51",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Use npm scripts to configure Claude Code / OpenCode / Codex with Langfuse tracing.",
@@ -60,6 +60,19 @@ function npxCommand() {
60
60
  return process.platform === "win32" ? "npx.cmd" : "npx";
61
61
  }
62
62
 
63
+ function runNpx(args, options = {}) {
64
+ if (process.platform === "win32") {
65
+ return spawnSync("cmd.exe", ["/d", "/s", "/c", npxCommand(), ...args], {
66
+ ...options,
67
+ windowsHide: true,
68
+ });
69
+ }
70
+ return spawnSync(npxCommand(), args, {
71
+ ...options,
72
+ windowsHide: true,
73
+ });
74
+ }
75
+
63
76
  function targetLabel(target) {
64
77
  if (target === "claude") return "Claude";
65
78
  if (target === "codex") return "Codex";
@@ -85,19 +98,25 @@ function runUpdate(target, args) {
85
98
  if (args["skip-check"]) updateArgs.push("--skip-check");
86
99
  if (args.npmRegistry) updateArgs.push(`--npmRegistry=${args.npmRegistry}`);
87
100
  if (args.pipIndexUrl) updateArgs.push(`--pipIndexUrl=${args.pipIndexUrl}`);
88
- const command = npxCommand();
89
- const result = spawnSync(command, updateArgs, {
101
+ const result = runNpx(updateArgs, {
90
102
  stdio: "inherit",
91
- shell: process.platform === "win32",
92
- windowsHide: true,
93
103
  timeout: 900000,
94
104
  });
95
105
  return result.status ?? (result.error ? 1 : 0);
96
106
  }
97
107
 
108
+ function autoUpdateMode(args, env = process.env) {
109
+ const raw = String(env.OH_LANGFUSE_AUTO_UPDATE || "").trim().toLowerCase();
110
+ if (/^(0|false|no|off)$/i.test(raw)) return "off";
111
+ if (args.yes || args.y || raw === "auto" || raw === "yes" || raw === "1" || raw === "true") return "auto";
112
+ if (args["notify-only"] || args.notifyOnly || raw === "notify" || raw === "prompt") return "notify";
113
+ return "ask";
114
+ }
115
+
98
116
  async function main() {
99
117
  const args = parseArgs(process.argv.slice(2));
100
- if (/^(0|false|no|off)$/i.test(String(process.env.OH_LANGFUSE_AUTO_UPDATE || ""))) return 0;
118
+ const mode = autoUpdateMode(args);
119
+ if (mode === "off") return 0;
101
120
 
102
121
  const target = String(args._[0] || "").trim().toLowerCase();
103
122
  if (!ALLOWED_TARGETS.has(target)) {
@@ -123,13 +142,13 @@ async function main() {
123
142
  : `oh-langfuse ${target} runtime may need update. Latest package: ${latest}.`;
124
143
  const updateCommand = `npx oh-langfuse@latest update ${target}`;
125
144
 
126
- if (args["notify-only"] || args.notifyOnly) {
145
+ if (mode === "notify") {
127
146
  printUpdateAvailable(target, message, updateCommand);
128
147
  console.log(`[INFO] To update safely, close the agent and run: ${updateCommand}`);
129
148
  return 0;
130
149
  }
131
150
 
132
- if (args.yes || args.y) {
151
+ if (mode === "auto") {
133
152
  printUpdateAvailable(target, message, updateCommand);
134
153
  printUpdateCommand(target, updateCommand);
135
154
  const code = runUpdate(target, args);
@@ -81,12 +81,57 @@ function autoUpdateRuntimePath() {
81
81
  return path.join(packageRoot, "scripts", "auto-update-runtime.mjs");
82
82
  }
83
83
 
84
+ function autoUpdateHelperDir() {
85
+ return path.join(os.homedir(), ".config", "oh-langfuse", "bin");
86
+ }
87
+
88
+ function writeAutoUpdateHelper(target) {
89
+ const helperDir = autoUpdateHelperDir();
90
+ ensureDir(helperDir);
91
+ const runtimePath = autoUpdateRuntimePath();
92
+ const fallbackArgs = ["-y", "oh-langfuse@latest", "auto-update", target, "--skip-check"];
93
+
94
+ if (process.platform === "win32") {
95
+ const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}.cmd`);
96
+ const lines = [
97
+ "@echo off",
98
+ "REM Auto-generated by scripts/codex-langfuse-setup.mjs",
99
+ `if exist ${cmdQuote(runtimePath)} (`,
100
+ ` call ${cmdQuote(process.execPath)} ${cmdQuote(runtimePath)} ${target} --skip-check %*`,
101
+ ") else (",
102
+ ` call npx.cmd ${fallbackArgs.map(cmdQuote).join(" ")} %*`,
103
+ ")",
104
+ "exit /b 0",
105
+ ""
106
+ ];
107
+ fs.writeFileSync(helper, lines.join(os.EOL), "utf8");
108
+ return helper;
109
+ }
110
+
111
+ const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}`);
112
+ const lines = [
113
+ "#!/usr/bin/env sh",
114
+ "# Auto-generated by scripts/codex-langfuse-setup.mjs",
115
+ "set +e",
116
+ `if [ -f ${shQuote(runtimePath)} ]; then`,
117
+ ` ${shQuote(process.execPath)} ${shQuote(runtimePath)} ${shQuote(target)} --skip-check "$@"`,
118
+ "else",
119
+ ` npx ${fallbackArgs.map(shQuote).join(" ")} "$@"`,
120
+ "fi",
121
+ "exit 0",
122
+ ""
123
+ ];
124
+ fs.writeFileSync(helper, lines.join("\n"), "utf8");
125
+ fs.chmodSync(helper, 0o755);
126
+ return helper;
127
+ }
128
+
84
129
  function windowsAutoUpdateCommand(target) {
85
- return `call ${cmdQuote(process.execPath)} ${cmdQuote(autoUpdateRuntimePath())} ${target} --skip-check`;
130
+ return `call ${cmdQuote(writeAutoUpdateHelper(target))}`;
86
131
  }
87
132
 
88
133
  function unixAutoUpdateCommand(target) {
89
- return `${shQuote(process.execPath)} ${shQuote(autoUpdateRuntimePath())} ${target} --skip-check || true`;
134
+ return `${shQuote(writeAutoUpdateHelper(target))} || true`;
90
135
  }
91
136
 
92
137
  function isPathInsideDir(candidate, dir) {
@@ -153,12 +153,57 @@ function autoUpdateRuntimePath() {
153
153
  return path.join(packageRoot, "scripts", "auto-update-runtime.mjs");
154
154
  }
155
155
 
156
+ function autoUpdateHelperDir() {
157
+ return path.join(os.homedir(), ".config", "oh-langfuse", "bin");
158
+ }
159
+
160
+ function writeAutoUpdateHelper(target) {
161
+ const helperDir = autoUpdateHelperDir();
162
+ ensureDir(helperDir);
163
+ const runtimePath = autoUpdateRuntimePath();
164
+ const fallbackArgs = ["-y", "oh-langfuse@latest", "auto-update", target, "--skip-check"];
165
+
166
+ if (process.platform === "win32") {
167
+ const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}.cmd`);
168
+ const lines = [
169
+ "@echo off",
170
+ "REM Auto-generated by scripts/langfuse-setup.mjs",
171
+ `if exist ${cmdQuote(runtimePath)} (`,
172
+ ` call ${cmdQuote(process.execPath)} ${cmdQuote(runtimePath)} ${target} --skip-check %*`,
173
+ ") else (",
174
+ ` call npx.cmd ${fallbackArgs.map(cmdQuote).join(" ")} %*`,
175
+ ")",
176
+ "exit /b 0",
177
+ ""
178
+ ];
179
+ fs.writeFileSync(helper, lines.join(os.EOL), "utf8");
180
+ return helper;
181
+ }
182
+
183
+ const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}`);
184
+ const lines = [
185
+ "#!/usr/bin/env sh",
186
+ "# Auto-generated by scripts/langfuse-setup.mjs",
187
+ "set +e",
188
+ `if [ -f ${shQuote(runtimePath)} ]; then`,
189
+ ` ${shQuote(process.execPath)} ${shQuote(runtimePath)} ${shQuote(target)} --skip-check "$@"`,
190
+ "else",
191
+ ` npx ${fallbackArgs.map(shQuote).join(" ")} "$@"`,
192
+ "fi",
193
+ "exit 0",
194
+ ""
195
+ ];
196
+ fs.writeFileSync(helper, lines.join("\n"), "utf8");
197
+ fs.chmodSync(helper, 0o755);
198
+ return helper;
199
+ }
200
+
156
201
  function windowsAutoUpdateCommand(target) {
157
- return `call ${cmdQuote(process.execPath)} ${cmdQuote(autoUpdateRuntimePath())} ${target} --skip-check`;
202
+ return `call ${cmdQuote(writeAutoUpdateHelper(target))}`;
158
203
  }
159
204
 
160
205
  function unixAutoUpdateCommand(target) {
161
- return `${shQuote(process.execPath)} ${shQuote(autoUpdateRuntimePath())} ${target} --skip-check || true`;
206
+ return `${shQuote(writeAutoUpdateHelper(target))} || true`;
162
207
  }
163
208
 
164
209
  function isPathInsideDir(candidate, dir) {
@@ -700,12 +700,57 @@ function autoUpdateRuntimePath() {
700
700
  return path.join(rootDir, "scripts", "auto-update-runtime.mjs");
701
701
  }
702
702
 
703
+ function autoUpdateHelperDir() {
704
+ return path.join(os.homedir(), ".config", "oh-langfuse", "bin");
705
+ }
706
+
707
+ function writeAutoUpdateHelper(target) {
708
+ const helperDir = autoUpdateHelperDir();
709
+ ensureDir(helperDir);
710
+ const runtimePath = autoUpdateRuntimePath();
711
+ const fallbackArgs = ["-y", "oh-langfuse@latest", "auto-update", target, "--skip-check"];
712
+
713
+ if (process.platform === "win32") {
714
+ const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}.cmd`);
715
+ const lines = [
716
+ "@echo off",
717
+ "REM Auto-generated by scripts/opencode-langfuse-setup.mjs",
718
+ `if exist ${cmdQuote(runtimePath)} (`,
719
+ ` call ${cmdQuote(process.execPath)} ${cmdQuote(runtimePath)} ${target} --skip-check %*`,
720
+ ") else (",
721
+ ` call npx.cmd ${fallbackArgs.map(cmdQuote).join(" ")} %*`,
722
+ ")",
723
+ "exit /b 0",
724
+ ""
725
+ ];
726
+ fs.writeFileSync(helper, lines.join(os.EOL), "utf8");
727
+ return helper;
728
+ }
729
+
730
+ const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}`);
731
+ const lines = [
732
+ "#!/usr/bin/env sh",
733
+ "# Auto-generated by scripts/opencode-langfuse-setup.mjs",
734
+ "set +e",
735
+ `if [ -f ${shQuote(runtimePath)} ]; then`,
736
+ ` ${shQuote(process.execPath)} ${shQuote(runtimePath)} ${shQuote(target)} --skip-check "$@"`,
737
+ "else",
738
+ ` npx ${fallbackArgs.map(shQuote).join(" ")} "$@"`,
739
+ "fi",
740
+ "exit 0",
741
+ ""
742
+ ];
743
+ fs.writeFileSync(helper, lines.join("\n"), "utf8");
744
+ fs.chmodSync(helper, 0o755);
745
+ return helper;
746
+ }
747
+
703
748
  function windowsAutoUpdateCommand(target) {
704
- return `call ${cmdQuote(process.execPath)} ${cmdQuote(autoUpdateRuntimePath())} ${target} --skip-check`;
749
+ return `call ${cmdQuote(writeAutoUpdateHelper(target))}`;
705
750
  }
706
751
 
707
752
  function unixAutoUpdateCommand(target) {
708
- return `${shQuote(process.execPath)} ${shQuote(autoUpdateRuntimePath())} ${target} --skip-check || true`;
753
+ return `${shQuote(writeAutoUpdateHelper(target))} || true`;
709
754
  }
710
755
 
711
756
  function writeWindowsUpdateCheckScript(dir) {