claude-contextline 1.0.0 → 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -22
  3. package/dist/index.js +60 -11
  4. package/package.json +1 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Stephan Fitzpatrick
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,33 +2,13 @@
2
2
 
3
3
  A powerline-style statusline for Claude Code showing context window usage.
4
4
 
5
- ## Installation
5
+ <img width="677" height="38" alt="image" src="https://github.com/user-attachments/assets/070d99fe-290d-4897-88b0-04247bf27866" />
6
6
 
7
- ```bash
8
- npm install -g claude-contextline
9
- ```
10
-
11
- Or use with npx:
12
-
13
- ```bash
14
- npx claude-contextline
15
- ```
16
7
 
17
- ## Configuration
8
+ ## Usage
18
9
 
19
10
  Add to your Claude Code settings (`~/.claude/settings.json`):
20
11
 
21
- ```json
22
- {
23
- "statusLine": {
24
- "type": "command",
25
- "command": "claude-contextline"
26
- }
27
- }
28
- ```
29
-
30
- Or with npx:
31
-
32
12
  ```json
33
13
  {
34
14
  "statusLine": {
@@ -57,6 +37,20 @@ Or with npx:
57
37
  - **Warning** (≥80%): White text on orange background
58
38
  - **Critical** (≥100%): White text on red background
59
39
 
40
+ ## Options
41
+
42
+ - `--theme <name>` - Use a named color theme (e.g. `--theme fulcrum` for purple-accented Fulcrum branding)
43
+ - `--no-arrows` - Disable powerline arrow separators
44
+
45
+ ```json
46
+ {
47
+ "statusLine": {
48
+ "type": "command",
49
+ "command": "npx claude-contextline --theme fulcrum"
50
+ }
51
+ }
52
+ ```
53
+
60
54
  ## Requirements
61
55
 
62
56
  - Node.js 18+
@@ -69,3 +63,4 @@ Styling based on [claude-limitline](https://github.com/tylergraydev/claude-limit
69
63
  ## License
70
64
 
71
65
  MIT
66
+
package/dist/index.js CHANGED
@@ -110,6 +110,13 @@ var SYMBOLS = {
110
110
  dirty: "\u25CF"
111
111
  // Dirty indicator
112
112
  };
113
+ var TEXT_SYMBOLS = {
114
+ arrow: "",
115
+ branch: "",
116
+ model: "",
117
+ context: "",
118
+ dirty: "*"
119
+ };
113
120
 
114
121
  // src/themes/index.ts
115
122
  var darkTheme = {
@@ -126,6 +133,24 @@ var darkTheme = {
126
133
  critical: { bg: "#af0000", fg: "#ffffff" }
127
134
  // Red, white (100%+)
128
135
  };
136
+ var fulcrumTheme = {
137
+ directory: { bg: "#0064f4", fg: "#ffffff" },
138
+ // Accent blue, white
139
+ git: { bg: "#121212", fg: "#81aefa" },
140
+ // Secondary, light blue
141
+ model: { bg: "#090909", fg: "#659dfb" },
142
+ // Card, medium blue
143
+ context: { bg: "#161616", fg: "#81aefa" },
144
+ // Muted, light blue
145
+ warning: { bg: "#f84331", fg: "#ffffff" },
146
+ // Warning red-orange, white (80%+)
147
+ critical: { bg: "#f90013", fg: "#ffffff" }
148
+ // Destructive red, white (100%+)
149
+ };
150
+ function getTheme(name) {
151
+ if (name === "fulcrum") return fulcrumTheme;
152
+ return darkTheme;
153
+ }
129
154
  function hexToAnsi256(hex) {
130
155
  const r = parseInt(hex.slice(1, 3), 16);
131
156
  const g = parseInt(hex.slice(3, 5), 16);
@@ -145,18 +170,38 @@ var ansi = {
145
170
  bg: (hex) => `\x1B[48;5;${hexToAnsi256(hex)}m`,
146
171
  reset: "\x1B[0m"
147
172
  };
148
- function getContextColors(percent) {
173
+ function getContextColors(percent, theme) {
149
174
  if (percent >= 100) {
150
- return darkTheme.critical;
175
+ return theme.critical;
151
176
  } else if (percent >= 80) {
152
- return darkTheme.warning;
177
+ return theme.warning;
153
178
  }
154
- return darkTheme.context;
179
+ return theme.context;
155
180
  }
156
181
 
157
182
  // src/renderer.ts
183
+ function detectNerdFontSupport() {
184
+ if (process.env.NERD_FONTS === "1") return true;
185
+ if (process.env.NERD_FONTS === "0") return false;
186
+ const termProgram = process.env.TERM_PROGRAM?.toLowerCase() ?? "";
187
+ const nerdFontTerminals = [
188
+ "warp",
189
+ "iterm",
190
+ "hyper",
191
+ "kitty",
192
+ "alacritty",
193
+ "ghostty"
194
+ ];
195
+ return nerdFontTerminals.some((t) => termProgram.includes(t));
196
+ }
158
197
  var Renderer = class {
159
- symbols = SYMBOLS;
198
+ symbols = detectNerdFontSupport() ? SYMBOLS : TEXT_SYMBOLS;
199
+ noArrows;
200
+ theme;
201
+ constructor(options = {}) {
202
+ this.noArrows = options.noArrows ?? false;
203
+ this.theme = getTheme(options.themeName);
204
+ }
160
205
  /**
161
206
  * Render the complete statusline
162
207
  */
@@ -174,20 +219,20 @@ var Renderer = class {
174
219
  const segments = [];
175
220
  segments.push({
176
221
  text: ` ${envInfo.directory} `,
177
- colors: darkTheme.directory
222
+ colors: this.theme.directory
178
223
  });
179
224
  if (envInfo.gitBranch) {
180
225
  const dirty = envInfo.gitDirty ? ` ${this.symbols.dirty}` : "";
181
226
  segments.push({
182
227
  text: ` ${this.symbols.branch} ${envInfo.gitBranch}${dirty} `,
183
- colors: darkTheme.git
228
+ colors: this.theme.git
184
229
  });
185
230
  }
186
231
  segments.push({
187
232
  text: ` ${this.symbols.model} ${envInfo.model} `,
188
- colors: darkTheme.model
233
+ colors: this.theme.model
189
234
  });
190
- const contextColors = getContextColors(envInfo.contextPercent);
235
+ const contextColors = getContextColors(envInfo.contextPercent, this.theme);
191
236
  segments.push({
192
237
  text: ` ${this.symbols.context} ${envInfo.contextPercent}% `,
193
238
  colors: contextColors
@@ -204,7 +249,8 @@ var Renderer = class {
204
249
  const nextColors = i < segments.length - 1 ? segments[i + 1].colors : null;
205
250
  output += ansi.bg(seg.colors.bg) + ansi.fg(seg.colors.fg) + seg.text;
206
251
  output += ansi.reset;
207
- if (nextColors) {
252
+ if (this.noArrows) {
253
+ } else if (nextColors) {
208
254
  output += ansi.fg(seg.colors.bg) + ansi.bg(nextColors.bg) + this.symbols.arrow;
209
255
  } else {
210
256
  output += ansi.fg(seg.colors.bg) + this.symbols.arrow;
@@ -218,9 +264,12 @@ var Renderer = class {
218
264
  // src/index.ts
219
265
  async function main() {
220
266
  try {
267
+ const noArrows = process.argv.includes("--no-arrows");
268
+ const themeIndex = process.argv.indexOf("--theme");
269
+ const themeName = themeIndex !== -1 ? process.argv[themeIndex + 1] : void 0;
221
270
  const hookData = await readHookData();
222
271
  const envInfo = getEnvironmentInfo(hookData);
223
- const renderer = new Renderer();
272
+ const renderer = new Renderer({ noArrows, themeName });
224
273
  const output = renderer.render(envInfo);
225
274
  process.stdout.write(output);
226
275
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-contextline",
3
- "version": "1.0.0",
3
+ "version": "1.3.0",
4
4
  "description": "Powerline statusline for Claude Code showing context window usage",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",