claude-contextline 1.0.0 → 1.2.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/LICENSE +21 -0
- package/README.md +3 -22
- package/dist/index.js +30 -3
- 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
|
-
|
|
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
|
-
##
|
|
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": {
|
|
@@ -69,3 +49,4 @@ Styling based on [claude-limitline](https://github.com/tylergraydev/claude-limit
|
|
|
69
49
|
## License
|
|
70
50
|
|
|
71
51
|
MIT
|
|
52
|
+
|
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 = {
|
|
@@ -155,8 +162,26 @@ function getContextColors(percent) {
|
|
|
155
162
|
}
|
|
156
163
|
|
|
157
164
|
// src/renderer.ts
|
|
165
|
+
function detectNerdFontSupport() {
|
|
166
|
+
if (process.env.NERD_FONTS === "1") return true;
|
|
167
|
+
if (process.env.NERD_FONTS === "0") return false;
|
|
168
|
+
const termProgram = process.env.TERM_PROGRAM?.toLowerCase() ?? "";
|
|
169
|
+
const nerdFontTerminals = [
|
|
170
|
+
"warp",
|
|
171
|
+
"iterm",
|
|
172
|
+
"hyper",
|
|
173
|
+
"kitty",
|
|
174
|
+
"alacritty",
|
|
175
|
+
"ghostty"
|
|
176
|
+
];
|
|
177
|
+
return nerdFontTerminals.some((t) => termProgram.includes(t));
|
|
178
|
+
}
|
|
158
179
|
var Renderer = class {
|
|
159
|
-
symbols = SYMBOLS;
|
|
180
|
+
symbols = detectNerdFontSupport() ? SYMBOLS : TEXT_SYMBOLS;
|
|
181
|
+
noArrows;
|
|
182
|
+
constructor(options = {}) {
|
|
183
|
+
this.noArrows = options.noArrows ?? false;
|
|
184
|
+
}
|
|
160
185
|
/**
|
|
161
186
|
* Render the complete statusline
|
|
162
187
|
*/
|
|
@@ -204,7 +229,8 @@ var Renderer = class {
|
|
|
204
229
|
const nextColors = i < segments.length - 1 ? segments[i + 1].colors : null;
|
|
205
230
|
output += ansi.bg(seg.colors.bg) + ansi.fg(seg.colors.fg) + seg.text;
|
|
206
231
|
output += ansi.reset;
|
|
207
|
-
if (
|
|
232
|
+
if (this.noArrows) {
|
|
233
|
+
} else if (nextColors) {
|
|
208
234
|
output += ansi.fg(seg.colors.bg) + ansi.bg(nextColors.bg) + this.symbols.arrow;
|
|
209
235
|
} else {
|
|
210
236
|
output += ansi.fg(seg.colors.bg) + this.symbols.arrow;
|
|
@@ -218,9 +244,10 @@ var Renderer = class {
|
|
|
218
244
|
// src/index.ts
|
|
219
245
|
async function main() {
|
|
220
246
|
try {
|
|
247
|
+
const noArrows = process.argv.includes("--no-arrows");
|
|
221
248
|
const hookData = await readHookData();
|
|
222
249
|
const envInfo = getEnvironmentInfo(hookData);
|
|
223
|
-
const renderer = new Renderer();
|
|
250
|
+
const renderer = new Renderer({ noArrows });
|
|
224
251
|
const output = renderer.render(envInfo);
|
|
225
252
|
process.stdout.write(output);
|
|
226
253
|
} catch {
|