claude-statusline 2.1.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.
Files changed (48) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +362 -0
  3. package/bin/claude-statusline +22 -0
  4. package/dist/core/cache.d.ts +67 -0
  5. package/dist/core/cache.js +223 -0
  6. package/dist/core/cache.js.map +1 -0
  7. package/dist/core/config.d.ts +190 -0
  8. package/dist/core/config.js +192 -0
  9. package/dist/core/config.js.map +1 -0
  10. package/dist/core/security.d.ts +27 -0
  11. package/dist/core/security.js +154 -0
  12. package/dist/core/security.js.map +1 -0
  13. package/dist/env/context.d.ts +92 -0
  14. package/dist/env/context.js +295 -0
  15. package/dist/env/context.js.map +1 -0
  16. package/dist/git/native.d.ts +35 -0
  17. package/dist/git/native.js +141 -0
  18. package/dist/git/native.js.map +1 -0
  19. package/dist/git/status.d.ts +65 -0
  20. package/dist/git/status.js +256 -0
  21. package/dist/git/status.js.map +1 -0
  22. package/dist/index.bundle.js +11 -0
  23. package/dist/index.d.ts +9 -0
  24. package/dist/index.js +396 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/metafile.prod.json +473 -0
  27. package/dist/ui/symbols.d.ts +31 -0
  28. package/dist/ui/symbols.js +308 -0
  29. package/dist/ui/symbols.js.map +1 -0
  30. package/dist/ui/width.d.ts +29 -0
  31. package/dist/ui/width.js +261 -0
  32. package/dist/ui/width.js.map +1 -0
  33. package/dist/utils/runtime.d.ts +31 -0
  34. package/dist/utils/runtime.js +82 -0
  35. package/dist/utils/runtime.js.map +1 -0
  36. package/docs/ARCHITECTURE.md +336 -0
  37. package/docs/FEATURE_COMPARISON.md +178 -0
  38. package/docs/MIGRATION.md +354 -0
  39. package/docs/README.md +101 -0
  40. package/docs/eval-01-terminal-widths.md +519 -0
  41. package/docs/guide-01-configuration.md +277 -0
  42. package/docs/guide-02-troubleshooting.md +416 -0
  43. package/docs/guide-03-performance.md +183 -0
  44. package/docs/prd-01-typescript-perf-optimization.md +480 -0
  45. package/docs/research-01-sandbox-detection.md +169 -0
  46. package/docs/research-02-competitive-analysis.md +226 -0
  47. package/docs/research-03-platform-analysis.md +142 -0
  48. package/package.json +89 -0
package/LICENSE ADDED
@@ -0,0 +1,203 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity granting the License.
13
+
14
+ "Legal Entity" shall mean the union of the acting entity and all
15
+ other entities that control, are controlled by, or are under common
16
+ control with that entity. For the purposes of this definition,
17
+ "control" means (i) the power, direct or indirect, to cause the
18
+ direction or management of such entity, whether by contract or
19
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity
23
+ exercising permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications,
26
+ including but not limited to software source code, documentation
27
+ source, and configuration files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical
30
+ transformation or translation of a Source form, including but
31
+ not limited to compiled object code, generated documentation,
32
+ and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or
35
+ Object form, made available under the License, as indicated by a
36
+ copyright notice that is included in or attached to the work
37
+ (which shall not include communications that are solely written
38
+ by You).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based upon (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and derivative works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control
57
+ systems, and issue tracking systems that are managed by, or on behalf
58
+ of, the Licensor for the purpose of discussing and improving the Work,
59
+ but excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to use, reproduce, modify, merge, publish,
70
+ distribute, sublicense, and/or sell copies of the Work, and to
71
+ permit persons to whom the Work is furnished to do so, subject to
72
+ the following conditions:
73
+
74
+ The above copyright notice and this permission notice shall be
75
+ included in all copies or substantial portions of the Work.
76
+
77
+ 3. Grant of Patent License. Subject to the terms and conditions of
78
+ this License, each Contributor hereby grants to You a perpetual,
79
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
80
+ (except as stated in this section) patent license to make, have made,
81
+ use, offer to sell, sell, import, and otherwise transfer the Work,
82
+ where such license applies only to those patent claims licensable
83
+ by such Contributor that are necessarily infringed by their
84
+ Contribution(s) alone or by combination of their Contribution(s)
85
+ with the Work to which such Contribution(s) was submitted. If You
86
+ institute patent litigation against any entity (including a
87
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
88
+ or a Contribution incorporated within the Work constitutes direct
89
+ or contributory patent infringement, then any patent licenses
90
+ granted to You under this License for that Work shall terminate
91
+ as of the date such litigation is filed.
92
+
93
+ 4. Redistribution. You may reproduce and distribute copies of the
94
+ Work or Derivative Works thereof in any medium, with or without
95
+ modifications, and in Source or Object form, provided that You
96
+ meet the following conditions:
97
+
98
+ (a) You must give any other recipients of the Work or
99
+ Derivative Works a copy of this License; and
100
+
101
+ (b) You must cause any modified files to carry prominent notices
102
+ stating that You changed the files; and
103
+
104
+ (c) You must retain, in the Source form of any Derivative Works
105
+ that You distribute, all copyright, trademark, patent,
106
+ attribution and other notices from the Source form of the
107
+ Work, excluding those notices that do not pertain to any
108
+ part of the Derivative Works; and
109
+
110
+ (d) If the Work includes a "NOTICE" text file as part of its
111
+ distribution, then any Derivative Works that You distribute must
112
+ include a readable copy of the attribution notices contained
113
+ within such NOTICE file, excluding those notices that do not
114
+ pertain to any part of the Derivative Works, in at least one
115
+ of the following places: within a NOTICE text file distributed
116
+ as part of the Derivative Works; within the Source form or
117
+ documentation, if provided along with the Derivative Works; or,
118
+ within a display generated by the Derivative Works, if and
119
+ wherever such third-party notices normally appear. The contents
120
+ of the NOTICE file are for informational purposes only and
121
+ do not modify the License. You may add Your own attribution
122
+ notices within Derivative Works that You distribute, alongside
123
+ or as an addendum to the NOTICE text from the Work, provided
124
+ that such additional attribution notices cannot be construed
125
+ as modifying the License.
126
+
127
+ You may add Your own copyright notice to Your modifications and
128
+ may provide additional or different license terms and conditions
129
+ for use, reproduction, or distribution of Your modifications, or
130
+ for any such Derivative Works as a whole, provided Your use,
131
+ reproduction, and distribution of the Work otherwise complies with
132
+ the conditions stated in this License.
133
+
134
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
135
+ any Contribution intentionally submitted for inclusion in the Work
136
+ by You to the Licensor shall be under the terms and conditions of
137
+ this License, without any additional terms or conditions.
138
+ Notwithstanding the above, nothing herein shall supersede or modify
139
+ the terms of any separate license agreement you may have executed
140
+ with Licensor regarding such Contributions.
141
+
142
+ 6. Trademarks. This License does not grant permission to use the trade
143
+ names, trademarks, service marks, or product names of the Licensor,
144
+ except as required for reasonable and customary use in describing the
145
+ origin of the Work and reproducing the content of the NOTICE file.
146
+
147
+ 7. Disclaimer of Warranty. Unless required by applicable law or
148
+ agreed to in writing, Licensor provides the Work (and each
149
+ Contributor provides its Contributions) ON AN "AS IS" BASIS,
150
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
151
+ implied, including, without limitation, any warranties or conditions
152
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
153
+ PARTICULAR PURPOSE. You are solely responsible for determining the
154
+ appropriateness of using or redistributing the Work and assume any
155
+ risks associated with Your exercise of permissions under this License.
156
+
157
+ 8. Limitation of Liability. In no event and under no legal theory,
158
+ whether in tort (including negligence), contract, or otherwise,
159
+ unless required by applicable law (such as deliberate and grossly
160
+ negligent acts) or agreed to in writing, shall any Contributor be
161
+ liable to You for damages, including any direct, indirect, special,
162
+ incidental, or consequential damages of any character arising as a
163
+ result of this License or out of the use or inability to use the
164
+ Work (including but not limited to damages for loss of goodwill,
165
+ work stoppage, computer failure or malfunction, or any and all
166
+ other commercial damages or losses), even if such Contributor
167
+ has been advised of the possibility of such damages.
168
+
169
+ 9. Accepting Warranty or Support. You may choose to offer, and to
170
+ charge a fee for, warranty, support, indemnity or other liability
171
+ obligations and/or rights consistent with this License. However, in
172
+ accepting such obligations, You may act only on Your own behalf and
173
+ on Your sole responsibility, not on behalf of any other Contributor,
174
+ and only if You agree to indemnify, defend, and hold each Contributor
175
+ harmless for any liability incurred by, or claims asserted against,
176
+ such Contributor by reason of your accepting any such warranty or support.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright 2025 shrwnsan
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,362 @@
1
+ # Claude Code Statusline
2
+
3
+ Simple statusline for Claude Code with project-branch, git indicators, and context usage. Optimized for speed with bun. Just the essentials, none of the bloat.
4
+
5
+ ![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)
6
+ ![Version](https://img.shields.io/badge/version-2.1.2-green.svg)
7
+ ![TypeScript](https://img.shields.io/badge/language-TypeScript-3178C6.svg)
8
+ ![Node](https://img.shields.io/badge/node-%3E%3D22.6.0-brightgreen.svg)
9
+ ![Bun](https://img.shields.io/badge/runtime-Bun-black.svg)
10
+
11
+ ![Demo](https://github.com/user-attachments/assets/8716dc4e-83da-410b-88f2-c47de7dd5930)
12
+
13
+ ## Quick Start
14
+
15
+ ### Installation
16
+
17
+ ```bash
18
+ # Bun install (recommended - 5x faster than Node.js)
19
+ bun install -g claude-statusline
20
+
21
+ # Or npm install (works well too)
22
+ npm install -g claude-statusline
23
+
24
+ # Or pnpm/yarn
25
+ pnpm add -g claude-statusline
26
+ yarn global add claude-statusline
27
+ ```
28
+
29
+
30
+ ### Claude Code Configuration
31
+
32
+ #### Standard Configuration (Node.js Runtime)
33
+ Add to your `~/.claude/settings.json`:
34
+
35
+ ```json
36
+ {
37
+ "statusLine": {
38
+ "type": "command",
39
+ "command": "claude-statusline"
40
+ }
41
+ }
42
+ ```
43
+
44
+ #### ⚡ Performance-Optimized Configuration (Bun Runtime)
45
+ For maximum performance (~5ms response time), explicitly use the Bun runtime:
46
+
47
+ ```json
48
+ {
49
+ "statusLine": {
50
+ "type": "command",
51
+ "command": "bun claude-statusline"
52
+ }
53
+ }
54
+ ```
55
+
56
+ > **Why specify "bun claude-statusline"?**
57
+ > Even when installed with `bun install -g`, the executable's shebang defaults to Node.js. Using "bun claude-statusline" ensures you get the full Bun performance benefits.
58
+
59
+ ### Usage
60
+
61
+ The statusline automatically displays when Claude Code is active and updates based on your git status and environment.
62
+
63
+ ### Default Configuration
64
+
65
+ claude-statusline works out-of-the-box with these defaults:
66
+ - `envContext`: false (environment versions NOT shown)
67
+ - `truncate`: false (basic truncation at terminal width - 10)
68
+ - `noEmoji`: false (Nerd Font symbols preferred, ASCII fallback)
69
+ - `noGitStatus`: false (git status shown)
70
+ - `noContextWindow`: false (context window usage shown)
71
+ - `noSoftWrap`: false (soft wrapping enabled when truncate=true, set to true to disable)
72
+ - `rightMargin`: 15 (prevents bleeding into Claude Code telemetry)
73
+ - `cacheTTL`: 300 (5-minute cache for environment info)
74
+ - `maxLength`: 1000 (maximum input length for security)
75
+
76
+ To see environment versions in your statusline, create a configuration file with:
77
+ ```json
78
+ {"envContext": true}
79
+ ```
80
+ *See the [🎛️ Configuration](#-configuration) section below for how to create and manage config files*
81
+
82
+ ## ⚡ Performance
83
+
84
+ 🚀 **claude-statusline is lightning fast**
85
+
86
+ - **With Bun runtime**: ~5ms response time (5x faster)
87
+ - **With Node.js runtime**: ~28ms response time (still instant)
88
+ - **Installation**: 19KB (tiny single-file bundle)
89
+
90
+ ### Real-world experience
91
+ ```bash
92
+ # Install instantly
93
+ bun install -g claude-statusline # Downloads 19KB in <1 second
94
+
95
+ # Add to Claude Code settings for maximum performance
96
+ # ~/.claude/settings.json
97
+ {
98
+ "statusLine": {
99
+ "type": "command",
100
+ "command": "bun claude-statusline"
101
+ }
102
+ }
103
+
104
+ # Enjoy instant git status updates! (~5ms with Bun vs ~28ms with Node.js)
105
+ ```
106
+
107
+ **Performance Comparison:**
108
+ - With `bun claude-statusline`: ~5ms ⚡
109
+ - With `claude-statusline` (Node.js): ~28ms ✅
110
+ - Both work perfectly - choose based on your preference
111
+
112
+ ### Why so fast?
113
+ - ✅ Native git commands (no slow libraries)
114
+ - ✅ Optimized for Bun runtime
115
+ - ✅ Smart caching (8-hour environment cache)
116
+ - ✅ Single-file bundle (no module resolution overhead)
117
+
118
+ **Fun fact**: We started with a fast bash script (~60ms), accidentally made it slower with TypeScript (~327ms), then optimized it to be 12x faster than the original (~5ms with Bun)!
119
+
120
+ *See [Performance Guide](docs/guide-03-performance.md) for the full optimization story*
121
+
122
+ ## Features
123
+
124
+ ### Git Status Indicators
125
+
126
+ - **Stashed**: ⚑ (stashed changes)
127
+ - **Deleted**: ✘ (files deleted)
128
+ - **Modified**: ! (unstaged changes)
129
+ - **Staged**: + (added to staging area)
130
+ - **Untracked**: ? (new files not tracked)
131
+ - **Renamed**: » (files moved/renamed)
132
+ - **Conflicts**: × (merge conflicts)
133
+ - **Diverged**: ⇕ (both ahead and behind upstream)
134
+ - **Ahead**: ⇡ (commits ahead of upstream)
135
+ - **Behind**: ⇣ (commits behind upstream)
136
+
137
+ ### Context Window Usage (Beta Feature)
138
+
139
+ **⚠️ Beta Feature:** Context window usage display is currently in beta. The calculation follows the official Claude Code documentation but may show different values compared to Claude Code's built-in `/context` command.
140
+
141
+ Automatically displays context window usage percentage when available (requires Claude Code to send context window data):
142
+
143
+ ```
144
+ claude-statusline @ main [$!] *Opus #27% (ASCII version)
145
+ ```
146
+
147
+ Shows percentage of context window consumed in the current conversation. The symbol varies by mode:
148
+ - **Nerd Font**: ⚡︎ (lightning bolt)
149
+ - **ASCII**: # (hash symbol)
150
+
151
+ **Important Notes:**
152
+ - Calculation follows [official Claude Code documentation](https://code.claude.com/docs/en/statusline#context-window-usage)
153
+ - May differ from `/context` command due to different data sources or calculation methods
154
+ - Only shows when Claude Code provides context window data
155
+ - Can be disabled with `"noContextWindow": true` or `CLAUDE_CODE_STATUSLINE_NO_CONTEXT_WINDOW=1`
156
+
157
+ **Known Discrepancy:**
158
+ Some users have noted differences between the statusline percentage and `/context` command output. This appears to be a difference in how Claude Code internally calculates context usage versus what's provided through the statusline API.
159
+
160
+ ### Environment Context
161
+
162
+ When enabled with `"envContext": true`, shows development tool versions:
163
+
164
+ ```
165
+ claude-statusline @ main [$!A] *Claude Sonnet 4.5 Node22.17.1 Py3.13.5 Docker28.3.3 (ASCII version)
166
+ ```
167
+
168
+ *Example shows ASCII mode for universal compatibility. With Nerd Fonts enabled, ASCII symbols are replaced with icons/emojis.*
169
+
170
+ Supported tools:
171
+ - **Node.js**: `node --version` (cached 5 minutes)
172
+ - **Python**: `python3 --version` or `python --version` (cached 5 minutes)
173
+ - **Docker**: `docker --version` (cached 30 minutes)
174
+
175
+ ### Smart Width Management
176
+
177
+ Two modes available:
178
+
179
+ 1. **Basic Mode** (default):
180
+ - Simple truncation at `terminal width - 10` characters
181
+ - Always single-line
182
+ - Fast and predictable
183
+
184
+ 2. **Smart Truncation Mode** (`CLAUDE_CODE_STATUSLINE_TRUNCATE=1`):
185
+ - 15-character right margin prevents bleeding into Claude Code telemetry
186
+ - Branch prioritization: Branch names preserved over project names
187
+ - Progressive truncation: Project → Branch → Indicators (if absolutely necessary)
188
+ - Optional soft-wrapping: Can wrap model/environment info to preserve more context
189
+ - Responsive design: Adapts to terminal width from 60-200+ characters
190
+ - Disable soft-wrapping with `"noSoftWrap": true` to force single-line
191
+
192
+ ### Width Breakpoints
193
+
194
+ | Width | Experience | Statusline Behavior |
195
+ |-------|------------|-------------------|
196
+ | **< 60** | Poor | Aggressive truncation |
197
+ | **60-79** | Acceptable | Smart truncation, branch preserved |
198
+ | **80-99** | Good | Ideal balance, minimal truncation |
199
+ | **100-119** | Excellent | Usually no truncation needed |
200
+ | **120+** | Perfect | No constraints, optimal UX |
201
+
202
+ ## Icon Reference & Nerd Font Support
203
+
204
+ **Nerd Font Support (Optional):** Automatically detects Nerd Fonts and falls back to ASCII equivalents.
205
+
206
+ For enhanced visual icons, install Nerd Fonts:
207
+ - **macOS:** `font-jetbrains-mono-nerd-font` via Homebrew
208
+ - **Cross-platform:** Download from [nerdfonts.com](https://nerdfonts.com/)
209
+
210
+ ### Icon Comparison
211
+
212
+ ![Icon Comparison Reference](https://github.com/user-attachments/assets/4190fd65-c425-4da7-8659-a7c7a6f15bc0)
213
+
214
+ ### ASCII Mode Display
215
+
216
+ | Use Case | Default Symbol | ASCII Fallback | Notes |
217
+ |----------|---------------|---------------|-------|
218
+ | **Git Repository** | `@` | `@` | Always ASCII |
219
+ | **Stashed Files** | `⚑` | `$` | ASCII when `"noEmoji": true` |
220
+ | **Staged Changes** | `+` | `+` | Always ASCII |
221
+ | **Modified Files** | `!` | `!` | Always ASCII |
222
+ | **Untracked Files** | `?` | `?` | Always ASCII |
223
+ | **Renamed Files** | `»` | `>` | ASCII when `"noEmoji": true` |
224
+ | **Deleted Files** | `✘` | `X` | ASCII when `"noEmoji": true` |
225
+ | **Merge Conflicts** | `×` | `C` | ASCII when `"noEmoji": true` |
226
+ | **Ahead/Behind** | `⇡⇣` | `A/B` | ASCII when `"noEmoji": true` |
227
+ | **Diverged** | `⇕` | `D` | ASCII when `"noEmoji": true` |
228
+ | **Claude Model** | `🤖` | `*` | ASCII when `"noEmoji": true` |
229
+ | **Context Window** | `⚡︎` | `#` | ASCII when `"noEmoji": true` |
230
+
231
+ *Note: Examples show ASCII-compatible symbols. Full statusline with Nerd Fonts shows additional symbols: $X!+?>CADAB*
232
+
233
+ ### 🎛️ Configuration
234
+
235
+ **📖 [Complete Configuration Guide](./docs/guide-01-configuration.md)**
236
+
237
+ Configure with JSON/YAML files:
238
+
239
+ ```bash
240
+ # Quick setup with minimal example
241
+ cp .claude-statusline.json.example.min ~/.claude/claude-statusline.json
242
+
243
+ # Or complete example with all options
244
+ cp .claude-statusline.json.example ~/.claude/claude-statusline.json
245
+
246
+ # Edit your configuration
247
+ nano ~/.claude/claude-statusline.json
248
+ ```
249
+
250
+ **Configuration search order:**
251
+ 1. `./claude-statusline.json` or `./claude-statusline.yaml` (project-level)
252
+ 2. Parent directories (searches up the tree)
253
+ 3. `~/.claude/claude-statusline.{json,yaml}` (global) ← **Recommended**
254
+ 4. Environment variables (legacy v1.0 support)
255
+
256
+ *Only JSON and YAML formats are supported. First configuration file found is used.*
257
+
258
+ ## Examples (ASCII)
259
+
260
+ ### Default Behavior
261
+ ```bash
262
+ # Basic truncation (default) - truncated at terminal width minus 10 chars
263
+ claude-statusline @ main [$!A] *Claude Sonnet 4.5 #27%
264
+
265
+ # With environment context enabled
266
+ # Set "envContext": true in config file
267
+ claude-statusline @ main [$!A] *Claude Sonnet 4.5 Node22.17.1 Py3.13.5 Docker28.3.3 #27%
268
+ ```
269
+
270
+ ### ASCII Mode (Fallback)
271
+ ```bash
272
+ # With "noEmoji": true in config file
273
+ claude-statusline @ main [$!A] *Claude Sonnet 4.5
274
+ ```
275
+
276
+ ## Documentation
277
+
278
+ 📚 **Complete documentation available in the [`docs/`](./docs) directory:**
279
+
280
+ - **[Configuration Guide](./docs/guide-01-configuration.md)** - Complete configuration options and examples
281
+ - **[Migration Guide](./docs/MIGRATION.md)** - Migrating from bash v1.0 to TypeScript v2.0
282
+ - **[Feature Comparison](./docs/FEATURE_COMPARISON.md)** - Detailed comparison between versions
283
+ - **[Documentation Index](./docs/README.md)** - Overview of all documentation
284
+
285
+ ## Security
286
+
287
+ Enhanced security with input validation and type safety:
288
+ - **Input Validation**: Comprehensive validation for all inputs
289
+ - **Command Injection Prevention**: Sanitized shell command execution
290
+ - **Path Traversal Protection**: Comprehensive path validation
291
+ - **Type Safety**: TypeScript compile-time and runtime validation
292
+
293
+ ## Dependencies
294
+
295
+ - **Required**: Node.js >= 22.6.0 or Bun >= 1.0.0, Git (for status parsing)
296
+ - **Runtime**: yaml, zod
297
+ - **Development**: TypeScript, ESLint, Prettier
298
+
299
+ ## Troubleshooting
300
+
301
+ **Common Issues:**
302
+ - **Build failures**: `npm install && npm run build`
303
+ - **Performance issues**: Clear cache `rm -rf /tmp/.claude-statusline-cache/`
304
+ - **Symbol display**: Force ASCII mode with `"noEmoji": true` in config
305
+
306
+ ## ❓ Frequently Asked Questions
307
+
308
+ ### Performance
309
+ **Q: Is it really fast enough for real-time use?**
310
+ A: Yes! With Bun it runs in ~5ms, which is instantaneous for human perception. Even with Node.js it's only ~28ms.
311
+
312
+ **Q: Why do some benchmarks show ~136ms?**
313
+ A: Those include system startup overhead. The actual execution time is much faster (~5ms with Bun). What matters is that it feels instant to users.
314
+
315
+ **Q: Should I use Bun or Node.js?**
316
+ A: Use Bun if you can - it's 5x faster (~5ms vs ~28ms). Configure it as "bun claude-statusline" in your settings.json to get the performance benefits. Node.js is still plenty fast for daily use.
317
+
318
+ ### Installation
319
+ **Q: Why is the download only 19KB?**
320
+ A: We use esbuild to bundle everything into a single optimized file. No downloading 500+ files!
321
+
322
+ **Q: Do I need Node.js installed?**
323
+ A: Yes, or Bun. We recommend Bun for best performance, but Node.js works perfectly fine.
324
+
325
+ ### Configuration
326
+ **Q: How do I see Node/Python versions?**
327
+ A: Create `~/.claude/claude-statusline.json` with `{"envContext": true}`.
328
+
329
+ **Q: Can I customize the symbols?**
330
+ A: Yes! Set `"noEmoji": true` for ASCII mode, or use Nerd Fonts for emoji icons.
331
+
332
+ ## Contributing
333
+
334
+ See our [Contributing Guidelines](./CONTRIBUTING.md) for development setup and pull requests.
335
+
336
+ ## Changelog
337
+
338
+ View [CHANGELOG.md](./CHANGELOG.md) for detailed version history and updates.
339
+
340
+ ## License
341
+
342
+ Apache License 2.0 - see [LICENSE](LICENSE) file for details.
343
+
344
+ ## 📦 Legacy: Bash v1.0
345
+
346
+ > **Note:** Version 2.0 (TypeScript) is recommended for all users. Bash v1.0 is maintained for legacy environments only.
347
+
348
+ For environments where Node.js/npm is not available:
349
+
350
+ ```bash
351
+ curl -L -o claude-statusline.sh https://github.com/shrwnsan/claude-statusline/releases/download/v1.0.0/claude-statusline.sh
352
+ chmod +x claude-statusline.sh
353
+ ```
354
+
355
+ **Limitations of v1.0:**
356
+ - Unix/Linux only (no Windows support)
357
+ - No configuration files
358
+ - No npm distribution
359
+ - Basic width detection only
360
+
361
+ See [Feature Comparison](./docs/FEATURE_COMPARISON.md) for details.
362
+
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Claude Statusline - TypeScript v2.0
5
+ * Executable wrapper for the TypeScript implementation
6
+ */
7
+
8
+ import { fileURLToPath } from 'url';
9
+ import { dirname, join } from 'path';
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = dirname(__filename);
13
+
14
+ // Import the main module (prefer bundled version if it exists)
15
+ try {
16
+ const { main } = await import(join(__dirname, '..', 'dist', 'index.bundle.js'))
17
+ .catch(() => import(join(__dirname, '..', 'dist', 'index.js')));
18
+ await main();
19
+ } catch (error) {
20
+ console.error('[ERROR] Failed to load claude-statusline:', error instanceof Error ? error.message : String(error));
21
+ process.exit(1);
22
+ }
@@ -0,0 +1,67 @@
1
+ import { Config } from './config.js';
2
+ /**
3
+ * Simple caching system with TTL support
4
+ * Ported from bash implementation with Node.js optimizations
5
+ */
6
+ /**
7
+ * Cache wrapper that handles TTL and file operations
8
+ */
9
+ export declare class Cache {
10
+ private config;
11
+ constructor(config: Config);
12
+ /**
13
+ * Ensure cache directory exists
14
+ */
15
+ private ensureCacheDir;
16
+ /**
17
+ * Get cache file path for a given key
18
+ */
19
+ private getCachePath;
20
+ /**
21
+ * Get cache timestamp file path for a given key
22
+ */
23
+ private getTimestampPath;
24
+ /**
25
+ * Read cached data with TTL validation
26
+ */
27
+ get<T = string>(key: string, ttl?: number): Promise<T | null>;
28
+ /**
29
+ * Write data to cache with timestamp
30
+ */
31
+ set<T = string>(key: string, data: T): Promise<boolean>;
32
+ /**
33
+ * Check if cache entry exists and is valid
34
+ */
35
+ has(key: string, ttl?: number): Promise<boolean>;
36
+ /**
37
+ * Delete cache entry
38
+ */
39
+ delete(key: string): Promise<boolean>;
40
+ /**
41
+ * Clear all cache entries
42
+ */
43
+ clear(): Promise<boolean>;
44
+ /**
45
+ * Get cache statistics
46
+ */
47
+ getStats(): Promise<{
48
+ total: number;
49
+ size: number;
50
+ }>;
51
+ }
52
+ /**
53
+ * Cache key generators for common use cases
54
+ */
55
+ export declare const CacheKeys: {
56
+ readonly NODE_VERSION: "node_version";
57
+ readonly PYTHON_VERSION: "python_version";
58
+ readonly PYTHON3_VERSION: "python3_version";
59
+ readonly DOCKER_VERSION: "docker_version";
60
+ readonly GIT_REMOTE_URL: (dir: string) => string;
61
+ readonly GIT_BRANCH: (dir: string) => string;
62
+ };
63
+ /**
64
+ * Cached command execution helper
65
+ * Runs a command and caches the result
66
+ */
67
+ export declare function cachedCommand(cache: Cache, key: string, command: string, args?: string[], ttl?: number): Promise<string | null>;