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
@@ -0,0 +1,519 @@
1
+ # Terminal Width Management
2
+
3
+ This document provides comprehensive analysis of terminal width behavior and optimization strategies for Claude Statusline.
4
+
5
+ **Implementation Status**: ✅ Smart truncation is implemented via `CLAUDE_CODE_STATUSLINE_TRUNCATE=1` (available in both bash and TypeScript v2.0)
6
+
7
+ ## Width Breakpoint Analysis
8
+
9
+ ### Responsive Design Strategy
10
+
11
+ Claude Statusline implements intelligent width management with three key principles:
12
+
13
+ 1. **15-character right margin** - Prevents bleeding into Claude Code telemetry
14
+ 2. **Branch prioritization** - Preserves branch names over project names when truncating
15
+ 3. **Progressive truncation** - Project → Branch → Indicators (only if absolutely necessary)
16
+
17
+ ### Terminal Width Categories
18
+
19
+ | Width Range | Experience Level | Typical Use Case | Statusline Behavior |
20
+ |-------------|------------------|------------------|-------------------|
21
+ | **< 60** | ❌ Poor | Mobile/Split screen | Aggressive truncation, branch prioritized |
22
+ | **60-79** | ⚠️ Acceptable | Minimum viable | Smart truncation, critical context preserved |
23
+ | **80-99** | ✅ Good | Common laptops | Ideal balance, minimal truncation |
24
+ | **100-119** | ✅ Excellent | Desktop/IDE | Usually no truncation needed |
25
+ | **120+** | ✅ Perfect | Power users | No constraints, optimal UX |
26
+
27
+ ## Real-World Examples
28
+
29
+ ### Test Case: Long Project + Branch Names
30
+
31
+ **Test Data**:
32
+ - Project: `vibekit-claude-plugins`
33
+ - Branch: `feature/issue-20-search-fallback-behavior`
34
+ - Indicators: `[+?]`
35
+ - Model Info: `Sonnet 4.5`
36
+
37
+ ## Mode Comparison: Basic vs Smart Truncation
38
+
39
+ ### Quick Reference
40
+
41
+ | Feature | Basic Mode (default) | Smart Truncation Mode |
42
+ |---------|---------------------|----------------------|
43
+ | **Trigger** | Always active | `CLAUDE_CODE_STATUSLINE_TRUNCATE=1` |
44
+ | **Truncation point** | `terminal width - 10` | `terminal width - 15` (right margin) |
45
+ | **Priority** | Simple cut-off | Branch > Project > Model |
46
+ | **Multi-line** | Never (always single-line) | Yes, with soft-wrapping when needed |
47
+ | **Git indicators** | May be cut off | Preserved until last moment |
48
+ | **Use case** | Fast, predictable | Maximum information preservation |
49
+
50
+ ## Test Results (Real Data)
51
+
52
+ *Test data: Project=`claude-statusline`, Branch=`feature/typescript-rewrite-v2.0`, Model=`Test Model`*
53
+
54
+ ### 40 Columns (Extreme Constraint)
55
+
56
+ **Basic Mode**:
57
+ ```
58
+ ----------------------------------------
59
+ claude-statusline  feature/..
60
+ ----------------------------------------
61
+ ```
62
+ *Length: 30 chars - Only project and partial branch*
63
+
64
+ **Smart Truncation**:
65
+ ```
66
+ ----------------------------------------
67
+ clau..  feature/typescri.. [!+?]
68
+ ----------------------------------------
69
+ ```
70
+ *Length: 33 chars - Preserves git indicators*
71
+
72
+ ### 50 Columns (Very Narrow)
73
+
74
+ **Basic Mode**:
75
+ ```
76
+ --------------------------------------------------
77
+ claude-statusline  feature/typescript..
78
+ --------------------------------------------------
79
+ ```
80
+ *Length: 40 chars - Model lost, branch partially shown*
81
+
82
+ **Smart Truncation**:
83
+ ```
84
+ --------------------------------------------------
85
+ clau..  feature/typescript-re.. [!+?]
86
+ --------------------------------------------------
87
+ ```
88
+ *Length: 38 chars - Git indicators preserved*
89
+
90
+ ### 60 Columns (Minimum Viable)
91
+
92
+ **Basic Mode**:
93
+ ```
94
+ ------------------------------------------------------------
95
+ claude-statusline  feature/typescript-rewrite-v..
96
+ ------------------------------------------------------------
97
+ ```
98
+ *Length: 50 chars - Model and indicators lost*
99
+
100
+ **Smart Truncation**:
101
+ ```
102
+ ------------------------------------------------------------
103
+ clau..  feature/typescript-rewrite-v2.0.. [!+?]
104
+ ------------------------------------------------------------
105
+ ```
106
+ *Length: 48 chars - Preserves git indicators*
107
+
108
+ ### 70 Columns (Tight but Usable)
109
+
110
+ **Basic Mode**:
111
+ ```
112
+ ----------------------------------------------------------------------
113
+ claude-statusline  feature/typescript-rewrite-v2.0 [!+?] ..
114
+ ----------------------------------------------------------------------
115
+ ```
116
+ *Length: 60 chars - Model truncated with ".."*
117
+
118
+ **Smart Truncation**:
119
+ ```
120
+ ----------------------------------------------------------------------
121
+ claude-status..  feature/typescript-rewrite-v2.0 [!+?]
122
+ ----------------------------------------------------------------------
123
+ ```
124
+ *Length: 55 chars - Project truncated, model preserved*
125
+
126
+ ### 80 Columns (Standard Terminal)
127
+
128
+ **Basic Mode**:
129
+ ```
130
+ --------------------------------------------------------------------------------
131
+ claude-statusline  feature/typescript-rewrite-v2.0 [!+?] 󰚩Test Model
132
+ --------------------------------------------------------------------------------
133
+ ```
134
+ *Length: 69 chars - Everything fits*
135
+
136
+ **Smart Truncation**:
137
+ ```
138
+ --------------------------------------------------------------------------------
139
+ claude-statusline  feature/typescript-rewrite-v2.0 [!+?] 󰚩Test
140
+ Model
141
+ --------------------------------------------------------------------------------
142
+ ```
143
+ *Length: 69 chars - Soft-wrapping occurs when model is long*
144
+
145
+ ### 90+ Columns (Comfortable)
146
+
147
+ **Both modes** (identical output):
148
+ ```
149
+ ------------------------------------------------------------------------------------------
150
+ claude-statusline  feature/typescript-rewrite-v2.0 [!+?] 󰚩Test Model
151
+ ------------------------------------------------------------------------------------------
152
+ ```
153
+ *Length: 69 chars - No truncation needed*
154
+
155
+ ## Key Findings from Testing
156
+
157
+ ### Soft-Wrapping Behavior
158
+
159
+ Soft-wrapping in Smart Truncation Mode only occurs when:
160
+ 1. **Project + git fits** within the terminal width (minus 15-char margin)
161
+ 2. **Model exceeds** the remaining space
162
+ 3. **There's a natural break point** (space) in the model string
163
+
164
+ *Test evidence*: At 80 columns with "Test Model", the project+git fits but the model needs to wrap, resulting in:
165
+ ```
166
+ --------------------------------------------------------------------------------
167
+ claude-statusline  feature/typescript-rewrite-v2.0 [!+?] 󰚩Test
168
+ Model
169
+ --------------------------------------------------------------------------------
170
+ ```
171
+
172
+ The model wraps at the space between "Test" and "Model", maintaining readability without duplicating the icon.
173
+
174
+ ### Mode Comparison Summary
175
+
176
+ | Terminal Width | Basic Mode Behavior | Smart Truncation Behavior | Winner |
177
+ |----------------|-------------------|---------------------------|---------|
178
+ | **< 50** | Aggressive truncation, loses most context | Preserves git indicators | Smart |
179
+ | **50-70** | Loses model info, may cut git indicators | Preserves git indicators, shorter output | Smart |
180
+ | **80** | Everything fits in single line | May soft-wrap long model names | Tie* |
181
+ | **90+** | No truncation needed | No truncation needed | Tie |
182
+
183
+ *\*At 80 columns: Basic Mode keeps everything on one line, Smart Truncation may soft-wrap to preserve full model text*
184
+
185
+ ### Practical Recommendations
186
+
187
+ 1. **Use Basic Mode** if you:
188
+ - Prefer predictable single-line output
189
+ - Don't need to preserve model information in narrow terminals
190
+ - Want maximum performance
191
+
192
+ 2. **Use Smart Truncation** if you:
193
+ - Want to preserve git indicators at all costs
194
+ - Don't mind multi-line output when necessary
195
+ - Need to see model information even in narrow terminals
196
+
197
+ ## Additional Testing Information
198
+
199
+ To reproduce these test results:
200
+ ```bash
201
+ cd tests
202
+ ./test_width.sh
203
+ ```
204
+
205
+ The test script provides:
206
+ - Visual terminal width guides (dashed lines) like those shown above
207
+ - Side-by-side comparison of both modes
208
+ - Exact character lengths for each output
209
+ - Clear indication when modes differ or match
210
+
211
+ Example of test output with visual guides:
212
+ ```
213
+ === 80 columns (Standard terminal) ===
214
+ --------------------------------------------------------------------------------
215
+ Basic Mode:
216
+ claude-statusline  feature/typescript-rewrite-v2.0 [!+?] 󰚩Test Model
217
+ --------------------------------------------------------------------------------
218
+ Smart Truncation Mode (CLAUDE_CODE_STATUSLINE_TRUNCATE=1):
219
+ claude-statusline  feature/typescript-rewrite-v2.0 [!+?] 󰚩Test
220
+ Model
221
+ --------------------------------------------------------------------------------
222
+ ```
223
+
224
+ ## Width Detection Algorithm
225
+
226
+ ### Detection Methods (in order of preference)
227
+
228
+ #### TypeScript v2.0 Implementation
229
+ 1. **Manual width override** - `CLAUDE_CODE_STATUSLINE_FORCE_WIDTH` (for testing)
230
+ 2. **COLUMNS environment variable** - Standard terminal width setting
231
+ 3. **Node.js process.stdout.columns** - Most reliable for Node.js processes
232
+ 4. **tput cols command** - Unix/Linux/macOS fallback
233
+ 5. **stty size command** - Secondary Unix/Linux/macOS fallback
234
+ 6. **Claude Code specific** - `CLAUDE_CODE_TERMINAL_WIDTH` environment variable
235
+ 7. **Terminal detection** - Defaults based on `TERM_PROGRAM` and `TERM`
236
+ - VS Code: 120 columns
237
+ - Modern terminals (Ghostty, WezTerm, iTerm): 120 columns
238
+ - Windows Terminal: 120 columns
239
+ 8. **Hard-coded fallback** - 80 columns (conservative default)
240
+
241
+ #### Bash Implementation
242
+ 1. **tput cols** - Most reliable method
243
+ ```bash
244
+ width=$(tput cols 2>/dev/null)
245
+ ```
246
+
247
+ 2. **stty size** - Fallback for systems without tput
248
+ ```bash
249
+ width=$(stty size 2>/dev/null | awk '{print $2}')
250
+ ```
251
+
252
+ 3. **COLUMNS variable** - Environment variable
253
+ ```bash
254
+ width=${COLUMNS:-}
255
+ ```
256
+
257
+ 4. **Hard-coded fallback** - Last resort
258
+ ```bash
259
+ width=80
260
+ ```
261
+
262
+ ### Width Validation
263
+
264
+ ```bash
265
+ # Validate detected width
266
+ if [[ -n "$width" && "$width" -gt 0 ]]; then
267
+ echo "$width"
268
+ else
269
+ echo "80" # Default fallback
270
+ fi
271
+ ```
272
+
273
+ ## Truncation Algorithm
274
+
275
+ ### Smart Truncation Strategy
276
+
277
+ ```bash
278
+ # Pseudo-code for truncation logic
279
+ function smart_truncate(project_name, git_info, available_width) {
280
+ # Step 1: Check if everything fits
281
+ total_length = length(project_name + git_info)
282
+ if total_length <= available_width:
283
+ return project_name + git_info
284
+
285
+ # Step 2: Try truncating project name only
286
+ max_project_length = available_width - length(git_info) - 2 # -2 for ".."
287
+ if max_project_length >= 5:
288
+ truncated_project = substring(project_name, 0, max_project_length) + ".."
289
+ if length(truncated_project + git_info) <= available_width:
290
+ return truncated_project + git_info
291
+
292
+ # Step 3: Truncate both project and branch
293
+ # Extract branch from git_info (format: " branch [indicators]")
294
+ branch_part = extract_branch_from_git_info(git_info)
295
+ indicators_part = extract_indicators_from_git_info(git_info)
296
+
297
+ # Aggressive truncation as last resort
298
+ max_branch_length = available_width - 10 - length(indicators_part) # -10 for "..project.."
299
+ return project_name[..] + branch[..] + indicators_part
300
+ }
301
+ ```
302
+
303
+ ### Branch Preservation Priority
304
+
305
+ 1. **Always preserve branch name** when possible
306
+ 2. **Truncate project name first** (most visible at a glance)
307
+ 3. **Truncate branch name** only when absolutely necessary
308
+ 4. **Preserve git indicators** to last possible moment
309
+
310
+ ## Width Optimization Recommendations
311
+
312
+ ### By Use Case
313
+
314
+ ### Laptop Users (13-15 inch screens)
315
+ - **Target**: 100+ columns when possible
316
+ - **Minimum**: 80 columns for acceptable experience
317
+ - **Strategy**: Use fullscreen terminal or side-by-side with 60+ columns
318
+
319
+ ### Desktop Users (24+ inch monitors)
320
+ - **Target**: 120+ columns for optimal experience
321
+ - **Minimum**: 100 columns for comfortable viewing
322
+ - **Strategy**: Maximize terminal real estate
323
+
324
+ ### SSH/Terminal Users
325
+ - **Target**: 80 columns (standard terminal width)
326
+ - **Minimum**: 60 columns for basic functionality
327
+ - **Strategy**: Accept some truncation for portability
328
+
329
+ ### Split-Screen Workflows
330
+ - **Target**: 60+ columns per panel
331
+ - **Minimum**: 50 columns for essential information
332
+ - **Strategy**: Prioritize branch information over project name
333
+
334
+ ## Terminal Configuration Tips
335
+
336
+ ### Optimizing Terminal Width
337
+
338
+ **iTerm2 (macOS)**:
339
+ ```bash
340
+ # Profiles → Window → Columns
341
+ # Set to 120+ for optimal experience
342
+ # Enable "character spacing" adjustments if needed
343
+ ```
344
+
345
+ **Terminal.app (macOS)**:
346
+ ```bash
347
+ # Shell → New Window → Columns
348
+ # Set to 120+ for development work
349
+ # Save as default profile
350
+ ```
351
+
352
+ **VS Code Integrated Terminal**:
353
+ ```json
354
+ // settings.json
355
+ {
356
+ "terminal.integrated.fontSize": 14,
357
+ "terminal.integrated.fontFamily": "JetBrains Mono",
358
+ "terminal.integrated.scrollback": 10000
359
+ }
360
+ ```
361
+
362
+ **Alacritty**:
363
+ ```yaml
364
+ # alacritty.yml
365
+ window:
366
+ columns: 120
367
+ lines: 30
368
+ padding:
369
+ x: 10
370
+ y: 10
371
+ ```
372
+
373
+ ### Font Recommendations
374
+
375
+ **Monospaced Fonts for Coding**:
376
+ - **JetBrains Mono** - Excellent for readability
377
+ - **Fira Code** - Good ligature support
378
+ - **Source Code Pro** - Clean, professional
379
+ - **IBM Plex Mono** - Excellent character distinction
380
+
381
+ **Font Sizes by Screen Size**:
382
+ - **13-inch laptops**: 12-14pt
383
+ - **15-inch laptops**: 14-16pt
384
+ - **24-inch monitors**: 16-18pt
385
+ - **27+ inch monitors**: 18-20pt
386
+
387
+ ## Testing Width Behavior
388
+
389
+ ### Manual Testing Script
390
+
391
+ ```bash
392
+ #!/bin/bash
393
+ # Test statusline across different widths
394
+
395
+ test_width() {
396
+ local width=$1
397
+ local test_input='{"workspace":{"current_dir":"/Users/karma/Developer/personal/claude-statusline"},"model":{"display_name":"Test Model"}}'
398
+
399
+ echo "Testing width: $width columns"
400
+ echo "COLUMNS=$width echo '$test_input' | /path/to/claude-statusline"
401
+ echo "---"
402
+
403
+ COLUMNS=$width echo "$test_input" | /path/to/claude-statusline
404
+ echo ""
405
+ echo "Length: $(COLUMNS=$width echo "$test_input" | /path/to/claude-statusline | wc -c)"
406
+ echo ""
407
+ }
408
+
409
+ # Test common widths
410
+ for width in 50 60 70 80 90 100 120 150; do
411
+ test_width $width
412
+ done
413
+
414
+ Note: Test scripts are available in the tests/ directory:
415
+ - `test_width.sh` - Standard width testing across common terminal sizes
416
+ - `test_width_long.sh` - Testing with long project/branch names
417
+ ```
418
+
419
+ ### Visual Width Testing
420
+
421
+ ```bash
422
+ # Create visual reference
423
+ create_width_reference() {
424
+ local width=$1
425
+
426
+ echo "=== $width columns ==="
427
+ printf "%.${width}s\n" "vibekit-claude-plugins-super-long-project-name  feature/branch-name-that-is-very-long [!?✘]"
428
+ echo ""
429
+ }
430
+
431
+ for width in 60 80 100 120; do
432
+ create_width_reference $width
433
+ done
434
+ ```
435
+
436
+ ## Performance Impact
437
+
438
+ ### Width Detection Performance
439
+
440
+ #### TypeScript v2.0 Implementation
441
+ | Method | Time | Reliability | Notes |
442
+ |--------|------|-------------|-------|
443
+ | `process.stdout.columns` | <1ms | ✅ High | Most reliable for Node.js |
444
+ | `tput cols` | ~2ms | ✅ High | Unix/Linux/macOS fallback |
445
+ | `stty size` | ~3ms | ✅ High | Secondary Unix fallback |
446
+ | `$COLUMNS` | <1ms | ⚠️ Medium | Environment dependent |
447
+ | Terminal detection | <1ms | ✅ High | Smart defaults |
448
+ | Hard-coded | <1ms | ✅ High | No detection overhead |
449
+
450
+ #### Bash Implementation
451
+ | Method | Time | Reliability | Notes |
452
+ |--------|------|-------------|-------|
453
+ | `tput cols` | ~2ms | ✅ High | Most reliable, preferred |
454
+ | `stty size` | ~3ms | ✅ High | Good fallback |
455
+ | `$COLUMNS` | <1ms | ⚠️ Medium | Environment dependent |
456
+ | Hard-coded | <1ms | ✅ High | No detection overhead |
457
+
458
+ ### Truncation Performance
459
+
460
+ - **No truncation**: ~0ms overhead
461
+ - **Project truncation**: ~1ms overhead
462
+ - **Branch truncation**: ~2ms overhead
463
+ - **Complex truncation**: ~3ms overhead
464
+
465
+ Overall impact is negligible (< 5ms) compared to total execution time:
466
+ - **TypeScript v2.0**: ~30-45ms (with parallel async operations and native optimizations)
467
+ - **Bash v1.0**: ~99ms (original implementation)
468
+
469
+ ## Troubleshooting Width Issues
470
+
471
+ ### Common Problems
472
+
473
+ **Wrong width detection**:
474
+ ```bash
475
+ # Check terminal width reporting
476
+ echo "COLUMNS: $COLUMNS"
477
+ echo "tput cols: $(tput cols)"
478
+ echo "stty size: $(stty size | awk '{print $2}')"
479
+ ```
480
+
481
+ **Truncation not working**:
482
+ ```bash
483
+ # Test with different widths
484
+ for width in 60 80 100; do
485
+ echo "=== $width columns ==="
486
+ COLUMNS=$width echo '{"workspace":{"current_dir":"'$PWD'"},"model":{"display_name":"Test"}}' | /path/to/claude-statusline
487
+ done
488
+ ```
489
+
490
+ **Force specific width for testing**:
491
+ ```bash
492
+ # Override width detection
493
+ export COLUMNS=80
494
+ echo '{"workspace":{"current_dir":"'$PWD'"},"model":{"display_name":"Test"}}' | /path/to/claude-statusline
495
+ ```
496
+
497
+ ### Debug Mode for Width Issues
498
+
499
+ ```bash
500
+ # Enable debug logging
501
+ export CLAUDE_STATUSLINE_LOG_LEVEL=DEBUG
502
+
503
+ # Test with debug output
504
+ echo '{"workspace":{"current_dir":"'$PWD'"},"model":{"display_name":"Test"}}' | /path/to/claude-statusline
505
+ ```
506
+
507
+ ---
508
+
509
+ ## Summary
510
+
511
+ Claude Statusline's width management provides:
512
+
513
+ ✅ **Responsive design** adapting to any terminal width
514
+ ✅ **Smart truncation** preserving critical context
515
+ ✅ **Branch prioritization** maintaining development workflow
516
+ ✅ **Performance optimization** with minimal overhead
517
+ ✅ **Cross-platform compatibility** across terminal types
518
+
519
+ The 15-character right margin ensures compatibility with Claude Code's telemetry, while the intelligent truncation algorithm maintains readability across all terminal sizes.