oh-langfuse 0.1.12 → 0.1.13

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.12",
3
+ "version": "0.1.13",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Use npm scripts to configure Claude Code / OpenCode / Codex with Langfuse tracing.",
@@ -50,7 +50,9 @@ function venvPython(codexHome) {
50
50
  }
51
51
 
52
52
  function configHasNotify(configText) {
53
- return /^\s*notify\s*=.*codex_langfuse_notify\.py/m.test(configText);
53
+ const firstSection = configText.search(/^\s*\[/m);
54
+ const topLevel = firstSection === -1 ? configText : configText.slice(0, firstSection);
55
+ return /^\s*notify\s*=.*codex_langfuse_notify\.py/m.test(topLevel);
54
56
  }
55
57
 
56
58
  function addResult(results, item, ok, detail, fix = "") {
@@ -81,34 +81,42 @@ function createOrUpdateLangfuseVenv({ baseDir, pipIndexUrl = "https://pypi.tuna.
81
81
  return venvPython;
82
82
  }
83
83
 
84
- function updateCodexNotify(configPath, notifyCommand) {
85
- let content = fs.existsSync(configPath) ? fs.readFileSync(configPath, "utf8") : "";
86
- content = stripBom(content);
84
+ function updateCodexNotify(configPath, notifyCommand) {
85
+ let content = fs.existsSync(configPath) ? fs.readFileSync(configPath, "utf8") : "";
86
+ content = stripBom(content);
87
87
  if (fs.existsSync(configPath)) {
88
88
  const backupPath = `${configPath}.bak-${Date.now()}`;
89
89
  fs.copyFileSync(configPath, backupPath);
90
90
  console.log(`Backed up existing Codex config: ${backupPath}`);
91
- }
92
- const lines = content.split(/\r?\n/);
93
- const notifyLine = `notify = ${tomlArray(notifyCommand)}`;
94
- let inTopLevel = true;
95
- let replaced = false;
96
- const next = [];
97
-
98
- for (const line of lines) {
99
- if (/^\s*\[/.test(line)) inTopLevel = false;
100
- if (inTopLevel && /^\s*notify\s*=/.test(line)) {
101
- if (!replaced) next.push(notifyLine);
102
- replaced = true;
103
- continue;
104
- }
91
+ }
92
+ const lines = content.split(/\r?\n/);
93
+ const notifyLine = `notify = ${tomlArray(notifyCommand)}`;
94
+ let inTopLevel = true;
95
+ let replaced = false;
96
+ let inserted = false;
97
+ const next = [];
98
+
99
+ for (const line of lines) {
100
+ if (/^\s*\[/.test(line)) {
101
+ if (!replaced && !inserted) {
102
+ while (next.length && next[next.length - 1].trim() === "") next.pop();
103
+ next.push(notifyLine, "");
104
+ inserted = true;
105
+ }
106
+ inTopLevel = false;
107
+ }
108
+ if (inTopLevel && /^\s*notify\s*=/.test(line)) {
109
+ if (!replaced) next.push(notifyLine);
110
+ replaced = true;
111
+ continue;
112
+ }
105
113
  next.push(line);
106
- }
107
-
108
- if (!replaced) {
109
- while (next.length && next[next.length - 1].trim() === "") next.pop();
110
- next.push(notifyLine, "");
111
- }
114
+ }
115
+
116
+ if (!replaced && !inserted) {
117
+ while (next.length && next[next.length - 1].trim() === "") next.pop();
118
+ next.push(notifyLine, "");
119
+ }
112
120
 
113
121
  fs.writeFileSync(configPath, next.join(os.EOL), "utf8");
114
122
  }