@superbased/observer 1.3.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.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # @superbased/observer
2
+
3
+ [![npm](https://img.shields.io/npm/v/@superbased/observer.svg)](https://www.npmjs.com/package/@superbased/observer)
4
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
5
+
6
+ SuperBased Observer — capture, normalize, compress, and analyze AI
7
+ coding tool activity across **Claude Code**, **Codex**, **Cursor**,
8
+ **Cline/Roo Code**, and **GitHub Copilot**.
9
+
10
+ Single binary. Local-only (no network calls from the observer
11
+ itself). Pure-Go, no CGO.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install -g @superbased/observer
17
+ observer --version
18
+ ```
19
+
20
+ The package ships pre-built binaries for:
21
+
22
+ | Platform | Architecture |
23
+ | --------------------- | ------------ |
24
+ | Linux | x64, arm64 |
25
+ | macOS (Intel) | x64 |
26
+ | macOS (Apple Silicon) | arm64 |
27
+ | Windows | x64 |
28
+
29
+ If you're on a platform that isn't listed, file an issue or build the
30
+ binary from source — see the
31
+ [main repo](https://github.com/marmutapp/superbased-observer).
32
+
33
+ ## Quick start
34
+
35
+ ```bash
36
+ # 1. Install the package + register hooks with the AI clients you use.
37
+ npm install -g @superbased/observer
38
+ observer init
39
+
40
+ # 2. Start the long-running watcher + dashboard + proxy in one process.
41
+ observer start &
42
+
43
+ # 3. Engage the proxy by pointing your AI client at the local URL.
44
+ # Claude Code / Cursor (Anthropic mode):
45
+ export ANTHROPIC_BASE_URL=http://127.0.0.1:8820
46
+ # Codex / Cursor (OpenAI mode):
47
+ export OPENAI_BASE_URL=http://127.0.0.1:8820/v1
48
+
49
+ # 4. Open the dashboard.
50
+ open http://127.0.0.1:8081/
51
+ ```
52
+
53
+ ## What you get
54
+
55
+ - **Real-time dashboard** at `http://127.0.0.1:8081/` — cost over
56
+ time, tool activity, compression savings, stale rereads, patterns,
57
+ per-tool action breakdowns, and full-workbook Excel export.
58
+ - **Conversation compression** — pre-forward trimming of API request
59
+ bodies. Per-mechanism breakdown (json / code / logs / text / diff /
60
+ html / drop) so you can see exactly what saved how many tokens.
61
+ - **MCP server** with 12 tools every connected AI client can use to
62
+ query each other's recorded work — `get_last_test_result`,
63
+ `check_file_freshness`, `get_failure_context`, etc.
64
+ - **Patterns engine** — `observer patterns` derives repeatable
65
+ behaviours from session history; `observer suggest` writes them
66
+ into `CLAUDE.md` / `AGENTS.md` / `.cursorrules` so new sessions
67
+ inherit them.
68
+
69
+ Full feature reference + walkthrough:
70
+ [main repo README](https://github.com/marmutapp/superbased-observer).
71
+
72
+ ## How the npm package works
73
+
74
+ This package is a thin Node.js shim that locates the right pre-built
75
+ binary (shipped via `optionalDependencies`) and spawns it. Same shape
76
+ as `esbuild` / `swc` / `@biomejs/biome`. No postinstall network calls,
77
+ no compile step at install time.
78
+
79
+ ## License
80
+
81
+ Apache 2.0 — see
82
+ [LICENSE](https://github.com/marmutapp/superbased-observer/blob/main/LICENSE).
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ // @superbased/observer — Node shim that locates the platform-specific
3
+ // binary shipped via an optional dependency and spawns it with
4
+ // arguments, stdio, and exit code forwarded.
5
+ //
6
+ // Why this shape: each per-platform binary is published as its own
7
+ // optional npm package (`@superbased/observer-<platform>-<arch>`) tagged
8
+ // with `os` and `cpu` in its package.json. npm only installs the one
9
+ // that matches the user's machine, so installs are fast and small.
10
+ // Same pattern used by esbuild, swc, biome.
11
+ 'use strict';
12
+
13
+ const { spawn } = require('child_process');
14
+ const path = require('path');
15
+
16
+ const PLATFORM_PACKAGES = {
17
+ 'linux-x64': '@superbased/observer-linux-x64',
18
+ 'linux-arm64': '@superbased/observer-linux-arm64',
19
+ 'darwin-x64': '@superbased/observer-darwin-x64',
20
+ 'darwin-arm64': '@superbased/observer-darwin-arm64',
21
+ 'win32-x64': '@superbased/observer-win32-x64',
22
+ };
23
+
24
+ function reportUnsupported(key) {
25
+ process.stderr.write(
26
+ '@superbased/observer: no prebuilt binary for ' + key + '.\n' +
27
+ 'Supported: ' + Object.keys(PLATFORM_PACKAGES).join(', ') + '.\n' +
28
+ 'If you need a different platform, file an issue at\n' +
29
+ ' https://github.com/marmutapp/superbased-observer/issues\n'
30
+ );
31
+ process.exit(1);
32
+ }
33
+
34
+ function reportMissingPackage(pkg) {
35
+ process.stderr.write(
36
+ '@superbased/observer: optional dependency ' + pkg + ' is not installed.\n' +
37
+ 'This usually means npm skipped optional dependencies during install.\n' +
38
+ 'Retry with:\n' +
39
+ ' npm install --include=optional @superbased/observer\n' +
40
+ 'or, if installed globally:\n' +
41
+ ' npm install -g --include=optional @superbased/observer\n'
42
+ );
43
+ process.exit(1);
44
+ }
45
+
46
+ function resolveBinary() {
47
+ const key = process.platform + '-' + process.arch;
48
+ const pkg = PLATFORM_PACKAGES[key];
49
+ if (!pkg) reportUnsupported(key);
50
+
51
+ // Node's resolver looks in node_modules of the calling package +
52
+ // ancestors. Both the global-install and local-install layouts work
53
+ // because the optional dep lives next to (or one level up from) this
54
+ // shim's containing package.
55
+ const exe = process.platform === 'win32' ? 'observer.exe' : 'observer';
56
+ let resolved;
57
+ try {
58
+ resolved = require.resolve(pkg + '/bin/' + exe);
59
+ } catch (err) {
60
+ reportMissingPackage(pkg);
61
+ }
62
+ return resolved;
63
+ }
64
+
65
+ function main() {
66
+ const binary = resolveBinary();
67
+ const child = spawn(binary, process.argv.slice(2), {
68
+ stdio: 'inherit',
69
+ windowsHide: true,
70
+ });
71
+ child.on('error', (err) => {
72
+ process.stderr.write('@superbased/observer: failed to spawn ' + binary + '\n' + err.message + '\n');
73
+ process.exit(127);
74
+ });
75
+ // Forward signals so Ctrl-C / SIGTERM reach the underlying observer
76
+ // (long-running daemons rely on graceful shutdown).
77
+ for (const sig of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
78
+ process.on(sig, () => {
79
+ if (!child.killed) child.kill(sig);
80
+ });
81
+ }
82
+ child.on('exit', (code, signal) => {
83
+ if (signal) {
84
+ // Re-raise the same signal on this process so the parent shell
85
+ // sees the standard exit-by-signal status.
86
+ process.kill(process.pid, signal);
87
+ } else {
88
+ process.exit(code === null ? 0 : code);
89
+ }
90
+ });
91
+ }
92
+
93
+ main();
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@superbased/observer",
3
+ "version": "1.3.0",
4
+ "description": "SuperBased Observer — capture, normalize, compress, and analyze AI coding tool activity across Claude Code, Codex, Cursor, Cline/Roo, and Copilot.",
5
+ "keywords": [
6
+ "ai",
7
+ "observability",
8
+ "anthropic",
9
+ "openai",
10
+ "claude-code",
11
+ "codex",
12
+ "cursor",
13
+ "mcp",
14
+ "tokens",
15
+ "cost"
16
+ ],
17
+ "homepage": "https://github.com/marmutapp/superbased-observer",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/marmutapp/superbased-observer.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/marmutapp/superbased-observer/issues"
24
+ },
25
+ "license": "Apache-2.0",
26
+ "author": "Santosh Kathira <contact@marmut.app>",
27
+ "engines": {
28
+ "node": ">=18"
29
+ },
30
+ "bin": {
31
+ "observer": "bin/observer.js"
32
+ },
33
+ "files": [
34
+ "bin",
35
+ "README.md",
36
+ "LICENSE"
37
+ ],
38
+ "optionalDependencies": {
39
+ "@superbased/observer-linux-x64": "1.3.0",
40
+ "@superbased/observer-linux-arm64": "1.3.0",
41
+ "@superbased/observer-darwin-x64": "1.3.0",
42
+ "@superbased/observer-darwin-arm64": "1.3.0",
43
+ "@superbased/observer-win32-x64": "1.3.0"
44
+ },
45
+ "scripts": {
46
+ "test": "node bin/observer.js --version"
47
+ }
48
+ }