oh-langfuse 0.1.15 → 0.1.16

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.15",
3
+ "version": "0.1.16",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Use npm scripts to configure Claude Code / OpenCode / Codex with Langfuse tracing.",
@@ -30,13 +30,34 @@ function readJsonIfExists(p) {
30
30
  return parseJsonRelaxed(txt, p);
31
31
  }
32
32
 
33
- function writeJsonPretty(p, obj) {
34
- fs.writeFileSync(p, JSON.stringify(obj, null, 2) + os.EOL, "utf8");
35
- }
36
-
37
- function isObject(x) {
38
- return x && typeof x === "object" && !Array.isArray(x);
39
- }
33
+ function writeJsonPretty(p, obj) {
34
+ fs.writeFileSync(p, JSON.stringify(obj, null, 2) + os.EOL, "utf8");
35
+ }
36
+
37
+ const colorEnabled = process.stdout.isTTY && process.env.NO_COLOR !== "1";
38
+ const ansi = (code) => (colorEnabled ? `\x1b[${code}m` : "");
39
+ const colors = {
40
+ reset: ansi(0),
41
+ bold: ansi(1),
42
+ cyan: ansi(36),
43
+ green: ansi(32),
44
+ yellow: ansi(33),
45
+ dim: ansi(2)
46
+ };
47
+
48
+ function paint(text, ...styles) {
49
+ if (!colorEnabled) return String(text);
50
+ return `${styles.join("")}${text}${colors.reset}`;
51
+ }
52
+
53
+ function printCommandHint(label, command) {
54
+ console.log(paint(label, colors.yellow, colors.bold));
55
+ console.log(`${paint(">", colors.green, colors.bold)} ${paint(command, colors.cyan, colors.bold)}`);
56
+ }
57
+
58
+ function isObject(x) {
59
+ return x && typeof x === "object" && !Array.isArray(x);
60
+ }
40
61
 
41
62
  function deepMerge(target, src) {
42
63
  if (!isObject(target) || !isObject(src)) return src;
@@ -522,7 +543,7 @@ async function main() {
522
543
  const unixLauncher = writeUnixLauncherSh(opencodeDir, { publicKey, secretKey, baseUrl, userId });
523
544
  if (unixLauncher) {
524
545
  console.log(`已生成启动脚本(含 LANGFUSE 环境变量):${unixLauncher}`);
525
- console.log(`如果新终端仍读不到环境变量,可运行:${unixLauncher}`);
546
+ printCommandHint("如果新终端仍读不到环境变量,可运行:", unixLauncher);
526
547
  }
527
548
 
528
549
  if (setEnv) {
@@ -551,14 +572,14 @@ async function main() {
551
572
  if (r.status === 0) {
552
573
  console.log("环境变量已生效:");
553
574
  console.log(r.stdout);
554
- } else {
555
- console.log("提示:环境变量已写入配置文件,请运行以下命令使其生效:");
556
- console.log(`source ${configPath}`);
557
- }
558
- }
559
- }
560
-
561
- console.log("完成。可运行:`npx oh-langfuse@latest check opencode` 校验。");
575
+ } else {
576
+ printCommandHint("提示:环境变量已写入配置文件,请运行以下命令使其生效:", `source ${configPath}`);
577
+ }
578
+ }
579
+ }
580
+
581
+ console.log(paint("完成。", colors.green, colors.bold));
582
+ printCommandHint("可运行以下命令校验:", "npx oh-langfuse@latest check opencode");
562
583
  }
563
584
 
564
585
  try {