oh-langfuse 0.1.65 → 0.1.66
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
|
@@ -106,10 +106,14 @@ function psQuote(s) {
|
|
|
106
106
|
return `'${String(s).replace(/'/g, "''")}'`;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
function cmdQuote(s) {
|
|
110
|
-
return `"${String(s).replace(/"/g, '""')}"`;
|
|
111
|
-
}
|
|
112
|
-
|
|
109
|
+
function cmdQuote(s) {
|
|
110
|
+
return `"${String(s).replace(/"/g, '""')}"`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function cmdSetValue(s) {
|
|
114
|
+
return String(s).replace(/"/g, '""');
|
|
115
|
+
}
|
|
116
|
+
|
|
113
117
|
function writeLangfusePluginUserConfig({ userId }) {
|
|
114
118
|
const home = os.homedir();
|
|
115
119
|
const dir = path.join(home, ".config", "opencode-plugin-langfuse");
|
|
@@ -943,39 +947,70 @@ function writeWindowsUpdateCheckScript(dir) {
|
|
|
943
947
|
return p;
|
|
944
948
|
}
|
|
945
949
|
|
|
946
|
-
function writeOpencodeCommandShim(opencodeDir, { publicKey, secretKey, baseUrl, userId, realOpencodeCli }) {
|
|
947
|
-
const shimDir = path.join(opencodeDir, "bin");
|
|
948
|
-
ensureDir(shimDir);
|
|
949
|
-
if (process.platform === "win32") {
|
|
950
|
-
const shim = path.join(shimDir, "opencode.cmd");
|
|
950
|
+
function writeOpencodeCommandShim(opencodeDir, { publicKey, secretKey, baseUrl, userId, realOpencodeCli }) {
|
|
951
|
+
const shimDir = path.join(opencodeDir, "bin");
|
|
952
|
+
ensureDir(shimDir);
|
|
953
|
+
if (process.platform === "win32") {
|
|
954
|
+
const shim = path.join(shimDir, "opencode.cmd");
|
|
951
955
|
const cmd = ["@echo off", "REM Auto-generated by scripts/opencode-langfuse-setup.mjs"];
|
|
952
956
|
cmd.push("set OH_LANGFUSE_OPENCODE_SHIM=1");
|
|
953
957
|
cmd.push(`set LANGFUSE_PUBLIC_KEY=${publicKey}`);
|
|
954
958
|
cmd.push(`set LANGFUSE_SECRET_KEY=${secretKey}`);
|
|
955
959
|
cmd.push(`set LANGFUSE_BASEURL=${baseUrl}`);
|
|
956
|
-
if (userId) cmd.push(`set LANGFUSE_USER_ID=${userId}`);
|
|
957
|
-
cmd.push(...windowsGitPathBootstrap());
|
|
958
|
-
cmd.push(windowsAutoUpdateCommand("opencode"));
|
|
959
|
-
cmd.push(`
|
|
960
|
-
cmd.push(
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
"
|
|
968
|
-
|
|
969
|
-
"
|
|
970
|
-
"
|
|
960
|
+
if (userId) cmd.push(`set LANGFUSE_USER_ID=${userId}`);
|
|
961
|
+
cmd.push(...windowsGitPathBootstrap());
|
|
962
|
+
cmd.push(windowsAutoUpdateCommand("opencode"));
|
|
963
|
+
cmd.push(`set "OH_LANGFUSE_REAL_OPENCODE=${cmdSetValue(realOpencodeCli)}"`);
|
|
964
|
+
cmd.push('if exist "%OH_LANGFUSE_REAL_OPENCODE%" (');
|
|
965
|
+
cmd.push(' call "%OH_LANGFUSE_REAL_OPENCODE%" %*');
|
|
966
|
+
cmd.push(" exit /b %ERRORLEVEL%");
|
|
967
|
+
cmd.push(")");
|
|
968
|
+
cmd.push('if exist "%USERPROFILE%\\.opencode\\bin\\opencode.exe" (');
|
|
969
|
+
cmd.push(' call "%USERPROFILE%\\.opencode\\bin\\opencode.exe" %*');
|
|
970
|
+
cmd.push(" exit /b %ERRORLEVEL%");
|
|
971
|
+
cmd.push(")");
|
|
972
|
+
cmd.push('if exist "%USERPROFILE%\\.opencode\\bin\\opencode.cmd" (');
|
|
973
|
+
cmd.push(' call "%USERPROFILE%\\.opencode\\bin\\opencode.cmd" %*');
|
|
974
|
+
cmd.push(" exit /b %ERRORLEVEL%");
|
|
975
|
+
cmd.push(")");
|
|
976
|
+
cmd.push('if exist "%APPDATA%\\npm\\opencode.cmd" (');
|
|
977
|
+
cmd.push(' call "%APPDATA%\\npm\\opencode.cmd" %*');
|
|
978
|
+
cmd.push(" exit /b %ERRORLEVEL%");
|
|
979
|
+
cmd.push(")");
|
|
980
|
+
cmd.push('for /f "delims=" %%O in (\'where.exe opencode 2^>nul\') do (');
|
|
981
|
+
cmd.push(' if /I not "%%~fO"=="%~f0" (');
|
|
982
|
+
cmd.push(' call "%%O" %*');
|
|
983
|
+
cmd.push(" exit /b %ERRORLEVEL%");
|
|
984
|
+
cmd.push(" )");
|
|
985
|
+
cmd.push(")");
|
|
986
|
+
cmd.push("call npx.cmd -y opencode@latest %*");
|
|
987
|
+
cmd.push("exit /b %ERRORLEVEL%");
|
|
988
|
+
fs.writeFileSync(shim, cmd.join("\r\n") + "\r\n", "utf8");
|
|
989
|
+
return { shim, shimDir };
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
const shim = path.join(shimDir, "opencode");
|
|
993
|
+
const quotedRealOpencodeCli = shQuote(realOpencodeCli);
|
|
994
|
+
const lines = [
|
|
995
|
+
"#!/usr/bin/env sh",
|
|
996
|
+
"# Auto-generated by scripts/opencode-langfuse-setup.mjs",
|
|
997
|
+
"set -eu",
|
|
998
|
+
"export OH_LANGFUSE_OPENCODE_SHIM=1",
|
|
971
999
|
`export LANGFUSE_PUBLIC_KEY=${shQuote(publicKey)}`,
|
|
972
|
-
`export LANGFUSE_SECRET_KEY=${shQuote(secretKey)}`,
|
|
973
|
-
`export LANGFUSE_BASEURL=${shQuote(baseUrl)}`,
|
|
974
|
-
userId ? `export LANGFUSE_USER_ID=${shQuote(userId)}` : null,
|
|
975
|
-
unixAutoUpdateCommand("opencode"),
|
|
976
|
-
`
|
|
977
|
-
""
|
|
978
|
-
|
|
1000
|
+
`export LANGFUSE_SECRET_KEY=${shQuote(secretKey)}`,
|
|
1001
|
+
`export LANGFUSE_BASEURL=${shQuote(baseUrl)}`,
|
|
1002
|
+
userId ? `export LANGFUSE_USER_ID=${shQuote(userId)}` : null,
|
|
1003
|
+
unixAutoUpdateCommand("opencode"),
|
|
1004
|
+
`OH_LANGFUSE_REAL_OPENCODE=${quotedRealOpencodeCli}`,
|
|
1005
|
+
'if [ -x "$OH_LANGFUSE_REAL_OPENCODE" ]; then exec "$OH_LANGFUSE_REAL_OPENCODE" "$@"; fi',
|
|
1006
|
+
'if [ -x "$HOME/.opencode/bin/opencode" ]; then exec "$HOME/.opencode/bin/opencode" "$@"; fi',
|
|
1007
|
+
'if command -v opencode >/dev/null 2>&1; then',
|
|
1008
|
+
' resolved="$(command -v opencode)"',
|
|
1009
|
+
' if [ "$resolved" != "$0" ]; then exec "$resolved" "$@"; fi',
|
|
1010
|
+
"fi",
|
|
1011
|
+
'exec npx -y opencode@latest "$@"',
|
|
1012
|
+
""
|
|
1013
|
+
].filter(Boolean);
|
|
979
1014
|
fs.writeFileSync(shim, lines.join("\n"), "utf8");
|
|
980
1015
|
fs.chmodSync(shim, 0o755);
|
|
981
1016
|
return { shim, shimDir };
|