oh-langfuse 0.1.18 → 0.1.19

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.18",
3
+ "version": "0.1.19",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Use npm scripts to configure Claude Code / OpenCode / Codex with Langfuse tracing.",
@@ -1,6 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import os from "node:os";
4
+ import { spawnSync } from "node:child_process";
4
5
  import { parseJsonRelaxed, stripBom } from "./json-utils.mjs";
5
6
 
6
7
  function parseArgs(argv) {
@@ -49,6 +50,24 @@ function addResult(results, item, ok, detail, fix = "") {
49
50
  results.push({ item, ok, detail, fix });
50
51
  }
51
52
 
53
+ function envStatus(publicKey, secretKey, baseUrl) {
54
+ return `publicKey=${publicKey ? "set" : "missing"}, secretKey=${secretKey ? "set" : "missing"}, baseUrl=${
55
+ baseUrl || "missing"
56
+ }`;
57
+ }
58
+
59
+ function windowsUserEnv(name) {
60
+ if (process.platform !== "win32") return "";
61
+ const escapedName = name.replace(/'/g, "''");
62
+ const result = spawnSync(
63
+ "powershell.exe",
64
+ ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", `[Environment]::GetEnvironmentVariable('${escapedName}', 'User')`],
65
+ { encoding: "utf8", windowsHide: true }
66
+ );
67
+ if (result.status !== 0) return "";
68
+ return (result.stdout || "").trim();
69
+ }
70
+
52
71
  function main() {
53
72
  const home = os.homedir();
54
73
  const opencodeDir = path.join(home, ".config", "opencode");
@@ -134,18 +153,36 @@ function main() {
134
153
  "Run setup again and enter userId when prompted."
135
154
  );
136
155
 
137
- const hasPublicKey = !!process.env.LANGFUSE_PUBLIC_KEY;
138
- const hasSecretKey = !!process.env.LANGFUSE_SECRET_KEY;
139
- const hasBaseUrl = !!process.env.LANGFUSE_BASEURL;
156
+ const currentPublicKey = process.env.LANGFUSE_PUBLIC_KEY || "";
157
+ const currentSecretKey = process.env.LANGFUSE_SECRET_KEY || "";
158
+ const currentBaseUrl = process.env.LANGFUSE_BASEURL || "";
159
+ const currentEnvOk = !!(currentPublicKey && currentSecretKey && currentBaseUrl);
160
+ const launcherCmdOk = fs.existsSync(windowsLauncherPath);
161
+
162
+ let envAvailableOk = currentEnvOk;
163
+ let envAvailableDetail = `current terminal: ${envStatus(currentPublicKey, currentSecretKey, currentBaseUrl)}`;
164
+ if (process.platform === "win32") {
165
+ const userPublicKey = windowsUserEnv("LANGFUSE_PUBLIC_KEY");
166
+ const userSecretKey = windowsUserEnv("LANGFUSE_SECRET_KEY");
167
+ const userBaseUrl = windowsUserEnv("LANGFUSE_BASEURL");
168
+ const userEnvOk = !!(userPublicKey && userSecretKey && userBaseUrl);
169
+ envAvailableOk = currentEnvOk || userEnvOk || launcherCmdOk;
170
+ if (currentEnvOk) {
171
+ envAvailableDetail = `current terminal: ${envStatus(currentPublicKey, currentSecretKey, currentBaseUrl)}`;
172
+ } else if (userEnvOk) {
173
+ envAvailableDetail = `current terminal missing; Windows user env is set and will apply to new terminals`;
174
+ } else if (launcherCmdOk) {
175
+ envAvailableDetail = `current terminal missing; launcher cmd exists and will inject LANGFUSE_*`;
176
+ }
177
+ }
178
+
140
179
  addResult(
141
180
  results,
142
- "current terminal LANGFUSE_*",
143
- hasPublicKey && hasSecretKey && hasBaseUrl,
144
- `publicKey=${hasPublicKey ? "set" : "missing"}, secretKey=${hasSecretKey ? "set" : "missing"}, baseUrl=${
145
- hasBaseUrl ? process.env.LANGFUSE_BASEURL : "missing"
146
- }`,
181
+ "OpenCode LANGFUSE_* availability",
182
+ envAvailableOk,
183
+ envAvailableDetail,
147
184
  process.platform === "win32"
148
- ? "Open a new terminal or launch with ~/.config/opencode/launch-opencode-langfuse.cmd."
185
+ ? "Run setup again, open a new terminal, or launch with ~/.config/opencode/launch-opencode-langfuse.cmd."
149
186
  : "Open a new terminal, source your shell rc file, or launch with ~/.config/opencode/launch-opencode-langfuse.sh."
150
187
  );
151
188