tokenlens-cli 1.0.0 → 1.0.1

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 CHANGED
@@ -35,6 +35,9 @@ tl quickstart
35
35
 
36
36
  Legacy `tg` still works as a compatibility alias.
37
37
 
38
+ The package applies its own small `http-mitm-proxy` compatibility patch during
39
+ install. No separate global tooling is required.
40
+
38
41
  ## What it measures
39
42
 
40
43
  - Codex session logs from `~/.codex/sessions`
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "tokenlens-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "AI token usage monitor that captures, analyzes, and reduces token consumption across coding agents and model providers.",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
8
8
  "README.md",
9
- "patches"
9
+ "scripts"
10
10
  ],
11
11
  "bin": {
12
12
  "tokenlens": "dist/cli/commands.js",
@@ -22,7 +22,7 @@
22
22
  "start": "node dist/cli/commands.js start",
23
23
  "prepare": "npm run build",
24
24
  "prepack": "npm run build",
25
- "postinstall": "patch-package"
25
+ "postinstall": "node scripts/postinstall.cjs"
26
26
  },
27
27
  "keywords": [
28
28
  "ai",
@@ -44,7 +44,6 @@
44
44
  "@types/better-sqlite3": "^7.6.12",
45
45
  "@types/express": "^5.0.0",
46
46
  "@types/node": "^22.10.0",
47
- "patch-package": "^8.0.1",
48
47
  "tsx": "^4.19.0",
49
48
  "typescript": "^5.7.0"
50
49
  }
@@ -0,0 +1,35 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const target = path.join(
5
+ __dirname,
6
+ "..",
7
+ "node_modules",
8
+ "http-mitm-proxy",
9
+ "dist",
10
+ "lib",
11
+ "proxy.js"
12
+ );
13
+
14
+ const before = 'host: "0.0.0.0"';
15
+ const after = 'host: "127.0.0.1"';
16
+
17
+ try {
18
+ if (!fs.existsSync(target)) {
19
+ process.exit(0);
20
+ }
21
+
22
+ const source = fs.readFileSync(target, "utf8");
23
+ if (source.includes(after)) {
24
+ process.exit(0);
25
+ }
26
+ if (!source.includes(before)) {
27
+ console.warn("[tokenlens] postinstall: expected http-mitm-proxy pattern not found");
28
+ process.exit(0);
29
+ }
30
+
31
+ fs.writeFileSync(target, source.replace(before, after), "utf8");
32
+ console.log("[tokenlens] postinstall: patched http-mitm-proxy host binding");
33
+ } catch (error) {
34
+ console.warn(`[tokenlens] postinstall: patch skipped (${error && error.message ? error.message : String(error)})`);
35
+ }
@@ -1,13 +0,0 @@
1
- diff --git a/node_modules/http-mitm-proxy/dist/lib/proxy.js b/node_modules/http-mitm-proxy/dist/lib/proxy.js
2
- index e896595..e94934d 100644
3
- --- a/node_modules/http-mitm-proxy/dist/lib/proxy.js
4
- +++ b/node_modules/http-mitm-proxy/dist/lib/proxy.js
5
- @@ -361,7 +361,7 @@ class Proxy {
6
- function makeConnection(port) {
7
- const conn = net_1.default.connect({
8
- port,
9
- - host: "0.0.0.0",
10
- + host: "127.0.0.1",
11
- allowHalfOpen: true,
12
- }, () => {
13
- const connectKey = `${conn.localPort}:${conn.remotePort}`;