contextbricks-universal 4.2.1 → 4.2.2

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
@@ -1,5 +1,8 @@
1
1
  # ContextBricks Universal
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/contextbricks-universal.svg)](https://www.npmjs.com/package/contextbricks-universal)
4
+ [![license](https://img.shields.io/npm/l/contextbricks-universal.svg)](LICENSE)
5
+
3
6
  > Cross-platform statusline for [Claude Code](https://claude.ai/code) CLI with real-time context brick visualization.
4
7
 
5
8
  **Works on Windows, Linux, and macOS** — pure Node.js, no bash or jq required.
@@ -15,6 +18,7 @@
15
18
 
16
19
  - **Real-time context tracking** — brick visualization of context window usage
17
20
  - **Rate limit tracking** — 5-hour and 7-day utilization with reset timers (Max/Pro subscribers)
21
+ - **Color gradient** — 256-color green-to-red scale based on utilization percentage
18
22
  - **Official percentage fields** (Claude Code 2.1.6+) with fallback calculation (2.0.70+)
19
23
  - **Git integration** — repo, branch, commit hash, message, dirty/ahead/behind indicators
20
24
  - **Session metrics** — model name, lines changed, duration, cost (hidden for Max subscribers)
@@ -26,22 +30,20 @@
26
30
 
27
31
  ```bash
28
32
  npm install -g contextbricks-universal
29
- contextbricks install
30
33
  ```
31
34
 
32
- Or one-liner via npx (installs and runs automatically):
35
+ The postinstall script runs `contextbricks install` automatically.
36
+
37
+ ### One-liner via npx
33
38
 
34
39
  ```bash
35
40
  npx contextbricks-universal
36
41
  ```
37
42
 
38
- Node.js is the only requirement (already present if you use Claude Code).
39
-
40
- ### From GitHub (without npm)
43
+ ### From GitHub
41
44
 
42
45
  ```bash
43
46
  npm install -g github:thebtf/contextbricks-universal
44
- contextbricks install
45
47
  ```
46
48
 
47
49
  ### From Source
@@ -52,12 +54,21 @@ cd contextbricks-universal
52
54
  node bin/cli.js install
53
55
  ```
54
56
 
57
+ Node.js is the only requirement (already present if you use Claude Code).
58
+
55
59
  ### What the Installer Does
56
60
 
57
61
  1. Copies `statusline.js` to `~/.claude/statusline.js`
58
62
  2. Updates `~/.claude/settings.json` with the `statusLine` command
59
63
  3. Backs up existing configuration before any changes
60
64
 
65
+ ### Updating
66
+
67
+ ```bash
68
+ npm update -g contextbricks-universal
69
+ contextbricks install
70
+ ```
71
+
61
72
  ## Display Layout
62
73
 
63
74
  ### Line 1 — Model + Git + Changes
@@ -149,7 +160,7 @@ Line 4 shows your current utilization of Claude's rate limits — useful for Max
149
160
  1. Reads your OAuth token from Claude Code credentials (`~/.claude/.credentials.json`, or macOS keychain)
150
161
  2. Fetches usage data from `api.anthropic.com/api/oauth/usage`
151
162
  3. Caches the response for 5 minutes (`~/.claude/.usage-cache.json`)
152
- 4. Displays utilization percentages with color coding:
163
+ 4. Displays utilization percentages with 256-color gradient:
153
164
  - **Green** (0-49%) — plenty of capacity
154
165
  - **Yellow** (50-79%) — approaching limit
155
166
  - **Red** (80-100%) — near or at limit
@@ -163,7 +174,7 @@ Line 4 shows your current utilization of Claude's rate limits — useful for Max
163
174
 
164
175
  - Your OAuth token is never logged or exposed in command arguments
165
176
  - Token is passed to the HTTPS subprocess via environment variable
166
- - Cache file (`~/.claude/.usage-cache.json`) is stored locally
177
+ - Cache file (`~/.claude/.usage-cache.json`) is stored locally with restricted permissions (0600)
167
178
 
168
179
  ### Troubleshooting
169
180
 
@@ -186,15 +197,15 @@ contextbricks test
186
197
 
187
198
  No bash, jq, bc, sed, cut, or any other Unix tools required.
188
199
 
189
- ## Bash vs Node.js
200
+ ## Comparison with Original
190
201
 
191
- | | Bash (v3.5) | Node.js (v4.x) |
202
+ | | [contextbricks](https://www.npmjs.com/package/contextbricks) (bash) | [contextbricks-universal](https://www.npmjs.com/package/contextbricks-universal) (Node.js) |
192
203
  |---|---|---|
193
204
  | **Platform** | Linux/macOS only | Windows + Linux + macOS |
194
205
  | **Dependencies** | bash, jq, git, bc, sed, cut | Node.js only (git optional) |
195
206
  | **JSON parsing** | External `jq` | Native `JSON.parse()` |
207
+ | **Rate limits** | No | Yes (Line 4) |
196
208
  | **Install** | Shell scripts | `npm i -g contextbricks-universal` |
197
- | **Output** | Identical | Identical |
198
209
 
199
210
  ## Uninstallation
200
211
 
@@ -207,6 +218,11 @@ Or manually:
207
218
  2. Remove the `statusLine` section from `~/.claude/settings.json`
208
219
  3. Restart Claude Code
209
220
 
221
+ To remove the global package:
222
+ ```bash
223
+ npm uninstall -g contextbricks-universal
224
+ ```
225
+
210
226
  ## Acknowledgements
211
227
 
212
228
  This project is a cross-platform Node.js rewrite of [ContextBricks](https://github.com/jezweb/claude-skills/tree/main/tools/statusline) created by [Jeremy Dawes](https://github.com/jezweb) ([jezweb.com.au](https://jezweb.com.au)). The original bash implementation provided the foundation for the statusline format, brick visualization, and git integration.
package/bin/cli.js CHANGED
@@ -76,9 +76,8 @@ function install() {
76
76
  console.log('');
77
77
 
78
78
  // Build the command string for settings.json
79
- // Use forward slashes for cross-platform compatibility
80
- const homedir = os.homedir().replace(/\\/g, '/');
81
- const statuslineCommand = `node ${homedir}/.claude/statusline.js`;
79
+ // Use absolute path to Node.js executable for reliability across environments
80
+ const statuslineCommand = `${process.execPath} ${INSTALL_PATH}`.replace(/\\/g, '/');
82
81
 
83
82
  // Update settings.json
84
83
  const settingsBackup = backupFile(SETTINGS_FILE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contextbricks-universal",
3
- "version": "4.2.1",
3
+ "version": "4.2.2",
4
4
  "description": "Universal cross-platform statusline for Claude Code CLI with context brick visualization. Windows, Linux, macOS. No bash or jq required.",
5
5
  "keywords": [
6
6
  "claude",
@@ -185,7 +185,13 @@ function fetchUsageData(token, input) {
185
185
  };
186
186
  const req = https.request(options, (res) => {
187
187
  let body = '';
188
- res.on('data', (chunk) => body += chunk);
188
+ let totalSize = 0;
189
+ const MAX_BODY_SIZE = 1024 * 1024;
190
+ res.on('data', (chunk) => {
191
+ totalSize += chunk.length;
192
+ if (totalSize > MAX_BODY_SIZE) { req.destroy(); return; }
193
+ body += chunk;
194
+ });
189
195
  res.on('end', () => {
190
196
  if (res.statusCode === 200) {
191
197
  process.stdout.write(body);