@neatlogs/claude-code 0.1.0

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.
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "@neatlogs/claude-code",
3
+ "version": "0.1.0",
4
+ "description": "Neatlogs observability for Claude Code — ships OTLP traces from hook lifecycle events",
5
+ "hooks": "../hooks/hooks.json"
6
+ }
@@ -0,0 +1,47 @@
1
+ // src/config.ts
2
+ import { existsSync, readFileSync, mkdirSync, writeFileSync } from "fs";
3
+ import { homedir, userInfo } from "os";
4
+ import { dirname, join } from "path";
5
+ var CONFIG_PATH = join(homedir(), ".config", "neatlogs", "config.json");
6
+ function loadConfig() {
7
+ let file = {};
8
+ try {
9
+ if (existsSync(CONFIG_PATH)) {
10
+ file = JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
11
+ }
12
+ } catch (err) {
13
+ console.warn(`[neatlogs/claude-code] Failed to read config: ${err.message}`);
14
+ }
15
+ const systemUser = (() => {
16
+ try {
17
+ return userInfo().username;
18
+ } catch (err) {
19
+ console.warn(`[neatlogs/claude-code] Could not resolve OS username: ${err.message}`);
20
+ return "unknown";
21
+ }
22
+ })();
23
+ return {
24
+ apiKey: process.env["NEATLOGS_API_KEY"] ?? file.api_key ?? "",
25
+ endpoint: process.env["NEATLOGS_ENDPOINT"] ?? file.endpoint ?? "https://staging-cloud.neatlogs.com",
26
+ userId: process.env["NEATLOGS_USER_ID"] ?? file.user_id ?? systemUser,
27
+ debug: process.env["NEATLOGS_DEBUG"] === "true" ? true : file.debug ?? false
28
+ };
29
+ }
30
+ function updateConfig(patch) {
31
+ const dir = dirname(CONFIG_PATH);
32
+ mkdirSync(dir, { recursive: true });
33
+ let existing = {};
34
+ try {
35
+ if (existsSync(CONFIG_PATH)) {
36
+ existing = JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
37
+ }
38
+ } catch (err) {
39
+ console.warn(`[neatlogs/claude-code] Failed to read existing config: ${err.message}`);
40
+ }
41
+ writeFileSync(CONFIG_PATH, JSON.stringify({ ...existing, ...patch }, null, 2) + "\n", "utf-8");
42
+ }
43
+
44
+ export {
45
+ loadConfig,
46
+ updateConfig
47
+ };