oh-langfuse 0.1.48 → 0.1.50

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.48",
3
+ "version": "0.1.50",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Use npm scripts to configure Claude Code / OpenCode / Codex with Langfuse tracing.",
@@ -95,9 +95,18 @@ function runUpdate(target, args) {
95
95
  return result.status ?? (result.error ? 1 : 0);
96
96
  }
97
97
 
98
+ function autoUpdateMode(args, env = process.env) {
99
+ const raw = String(env.OH_LANGFUSE_AUTO_UPDATE || "").trim().toLowerCase();
100
+ if (/^(0|false|no|off)$/i.test(raw)) return "off";
101
+ if (args.yes || args.y || raw === "auto" || raw === "yes" || raw === "1" || raw === "true") return "auto";
102
+ if (args["notify-only"] || args.notifyOnly || raw === "notify" || raw === "prompt") return "notify";
103
+ return "ask";
104
+ }
105
+
98
106
  async function main() {
99
107
  const args = parseArgs(process.argv.slice(2));
100
- if (/^(0|false|no|off)$/i.test(String(process.env.OH_LANGFUSE_AUTO_UPDATE || ""))) return 0;
108
+ const mode = autoUpdateMode(args);
109
+ if (mode === "off") return 0;
101
110
 
102
111
  const target = String(args._[0] || "").trim().toLowerCase();
103
112
  if (!ALLOWED_TARGETS.has(target)) {
@@ -123,13 +132,13 @@ async function main() {
123
132
  : `oh-langfuse ${target} runtime may need update. Latest package: ${latest}.`;
124
133
  const updateCommand = `npx oh-langfuse@latest update ${target}`;
125
134
 
126
- if (args["notify-only"] || args.notifyOnly) {
135
+ if (mode === "notify") {
127
136
  printUpdateAvailable(target, message, updateCommand);
128
137
  console.log(`[INFO] To update safely, close the agent and run: ${updateCommand}`);
129
138
  return 0;
130
139
  }
131
140
 
132
- if (args.yes || args.y) {
141
+ if (mode === "auto") {
133
142
  printUpdateAvailable(target, message, updateCommand);
134
143
  printUpdateCommand(target, updateCommand);
135
144
  const code = runUpdate(target, args);
@@ -55,8 +55,8 @@ function configHasNotify(configText) {
55
55
  return /^\s*notify\s*=.*codex_langfuse_notify\.py/m.test(topLevel);
56
56
  }
57
57
 
58
- function addResult(results, item, ok, detail, fix = "") {
59
- results.push({ item, ok, detail, fix });
58
+ function addResult(results, item, ok, detail, fix = "", options = {}) {
59
+ results.push({ item, ok, detail, fix, required: options.required !== false });
60
60
  }
61
61
 
62
62
  function main() {
@@ -95,8 +95,22 @@ function main() {
95
95
  langfuseConfig?.publicKey ? "configured" : "missing",
96
96
  "Provide publicKey/secretKey or use the defaults from the installer."
97
97
  );
98
- addResult(results, "sessions directory", fs.existsSync(sessionsDir), sessionsDir, "Start Codex once so session JSONL files are created.");
99
- addResult(results, "latest session JSONL", !!latestSession, latestSession || "not found", "Start a Codex conversation, then check again.");
98
+ addResult(
99
+ results,
100
+ "sessions directory",
101
+ fs.existsSync(sessionsDir),
102
+ fs.existsSync(sessionsDir) ? sessionsDir : `${sessionsDir} (not created yet)`,
103
+ "Start Codex once so session JSONL files are created.",
104
+ { required: false }
105
+ );
106
+ addResult(
107
+ results,
108
+ "latest session JSONL",
109
+ !!latestSession,
110
+ latestSession || "not found yet",
111
+ "Start a Codex conversation, then check again.",
112
+ { required: false }
113
+ );
100
114
  addResult(results, "Python", python.ok, python.detail || "not found", "Install Python and pip, then rerun setup.");
101
115
  addResult(results, "Langfuse venv Python", fs.existsSync(hookPython), hookPython, "Run setup again; on Linux install python3-venv if venv creation fails.");
102
116
  addResult(
@@ -118,9 +132,9 @@ function main() {
118
132
  const pad = (s, n) => (s.length >= n ? s : s + " ".repeat(n - s.length));
119
133
  const failed = [];
120
134
  for (const r of results) {
121
- const status = r.ok ? "OK " : "BAD";
135
+ const status = r.ok ? "OK " : r.required ? "BAD" : "INFO";
122
136
  console.log(`${status} ${pad(r.item, w)} ${r.detail}`);
123
- if (!r.ok) failed.push(r);
137
+ if (!r.ok && r.required) failed.push(r);
124
138
  }
125
139
 
126
140
  if (failed.length) {
@@ -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) {