@chongdashu/cc-statusline 1.2.7 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,111 +1,158 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [1.2.7] - 2025-08-28
9
-
10
- ### Fixed
11
- - 🐛 **ccusage Integration Fix** - Fixed ccusage stats not displaying in statusline
12
- - Moved `input=$(cat)` before logging to ensure proper input capture
13
- - Simplified ccusage execution by removing complex locking mechanism
14
- - Now properly calls `ccusage blocks --json` directly with internal caching
15
- - Fixed cost display, burn rate, token stats, and session time display
16
-
17
- ## [1.2.6] - 2025-08-27
18
-
19
- ### Fixed
20
- - 🐛 **Installation Prompt Fix** - Fixed spinner blocking the overwrite confirmation prompt during installation
21
- - Removed ora spinner during installation phase to ensure prompts are visible
22
- - Replaced spinner with simple console messages for better UX
23
- - Users can now properly see and respond to overwrite confirmations
24
-
25
- ## [1.2.5] - 2025-08-27
26
-
27
- ### Fixed
28
- - 🐛 **Cost Display Fix** - Fixed incorrect cost values (e.g., $48.00) caused by improper quoting in printf statements
29
- - Removed unnecessary escaped quotes around `$cost_usd` in bash generator
30
- - Cost values now display correctly with proper decimal formatting
31
-
32
- ## [1.2.4] - 2025-08-26
33
-
34
- ### Added
35
- - 🆕 **Installation Location Choice** - Choose between global (`~/.claude`) or project-level (`./.claude`) installation
36
- - 🔒 **Safe Installation** - Confirmation prompts before overwriting existing statusline.sh files
37
- - 🛡️ **Settings Protection** - Smart settings.json updates that preserve existing configurations
38
- - ⚠️ **Conflict Detection** - Warns when other statuslines are already configured
39
- - ✅ **Better Error Handling** - Clear messages for cancelled installations and conflicts
40
-
41
- ### Changed
42
- - Installation prompt now includes location selection (global vs project)
43
- - Default installation is project-level for safety
44
- - Improved settings.json update logic to prevent accidental overwrites
45
-
46
- ## [1.2.3] - 2025-08-20
47
-
48
- ### Fixed
49
- - 🔒 **Critical Process Spawning Fix** - Added file-based locking mechanism to prevent infinite ccusage process spawning
50
- - **Performance** - Implemented 3-second timeout for ccusage calls to prevent hanging
51
- - 🛡️ **Stability** - Added PID tracking for stale lock detection and cleanup
52
- - 🔧 **Cross-platform** - Multiple timeout strategies for Linux, macOS, and BSD compatibility
53
-
54
- ### Contributors
55
- - 🙏 **Special thanks to [Jonathan Borgwing (@DevVig)](https://github.com/DevVig)** for identifying and implementing the critical process spawning fix ([#4](https://github.com/chongdashu/cc-statusline/pull/4))
56
-
57
- ### Technical Details
58
- - **File-based locking**: Uses `/tmp/ccusage_statusline.lock` directory as a mutex to ensure single execution
59
- - **PID tracking**: Stores process ID in `/tmp/ccusage_statusline.pid` for stale lock detection
60
- - **Graceful degradation**: Skips execution when locked instead of queuing (prevents pile-up)
61
- - **Automatic cleanup**: Detects and removes stale locks from crashed processes using `kill -0`
62
- - **Cross-platform timeouts**: Multiple timeout strategies (timeout/gtimeout/fallback) for all systems
63
- - **Testing included**: Comprehensive test suite in `test/` directory to verify locking behavior
64
-
65
- ## [1.0.1] - 2025-08-13
66
-
67
- ### Added
68
- - CONTRIBUTING.md with comprehensive contribution guidelines
69
- - Development workflow documentation
70
- - Code standards and testing guidelines
71
-
72
- ### Changed
73
- - Updated package name to unscoped `cc-statusline`
74
- - Enhanced README contributing section with better guidance
75
-
76
- ## [1.0.0] - 2025-08-13
77
-
78
- ### Added
79
- - Initial release of cc-statusline
80
- - Interactive configuration wizard with 2 simple prompts
81
- - Bash script generation with optimized performance
82
- - Real-time ccusage integration for usage statistics
83
- - Preview mode for testing statusline scripts with mock data
84
- - Auto-installation with settings.json configuration
85
- - Support for directory, git, model, usage, session, token, and burn rate features
86
- - TTY-aware color support with NO_COLOR environment variable respect
87
- - Manual configuration instructions when auto-update fails
88
- - Comprehensive documentation and examples
89
- - Performance analysis and validation in preview mode
90
- - Timestamp and npm URL in generated script headers
91
-
92
- ### Features
93
- - 📁 Working Directory display with `~` abbreviation
94
- - 🌿 Git Branch integration
95
- - 🤖 Model Name & Version display
96
- - 💵 Real-time Usage & Cost tracking
97
- - Session Time Remaining with progress bars
98
- - 📊 Token Statistics (optional)
99
- - Burn Rate monitoring (optional)
100
-
101
- ### Technical
102
- - TypeScript with strict type checking
103
- - ESM module support
104
- - Commander.js for CLI interface
105
- - Inquirer.js for interactive prompts
106
- - Chalk for colorized output
107
- - Ora for loading spinners
108
- - Comprehensive error handling and validation
109
- - Modular architecture for easy maintenance
110
-
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.3.2] - 2025-08-28
9
+
10
+ ### Fixed
11
+ - 🪟 **Windows Bash Compatibility** - Fixed JSON extraction in bash fallback mode for Windows Git Bash/MinGW
12
+ - Improved nested JSON field extraction for `workspace.current_dir` and `model.display_name`
13
+ - Added Windows path conversion from backslashes to forward slashes
14
+ - Fixed cost data extraction without jq
15
+ - Generator now uses `bash .claude/statusline.sh` command in settings.json for Windows
16
+
17
+ ## [1.3.1] - 2025-08-28
18
+
19
+ ### Fixed
20
+ - 🐛 **Critical: Bash JSON Fallback Parser** - Fixed syntax error in fallback JSON parser for systems without jq
21
+ - Fixed malformed grep patterns with incorrect quote escaping in `bash-generator.ts`
22
+ - Statusline now works correctly on systems without jq installed
23
+ - Properly escapes quotes in generated bash script (`\"${field}\"` instead of `"${field}"`)
24
+
25
+ ### Added
26
+ - ✨ **jq Detection and Installation Guide** - Added automatic jq detection during init
27
+ - Checks if jq is installed and warns about limited functionality without it
28
+ - Provides platform-specific installation instructions (macOS, Linux, Windows)
29
+ - Asks users if they want to continue without jq
30
+ - Clear documentation in README about which features require jq
31
+
32
+ ### Changed
33
+ - 📚 **Enhanced Windows Documentation** - Clarified jq installation for Windows users
34
+ - Specific file names for download (`jq-windows-amd64.exe` for 64-bit)
35
+ - Step-by-step PATH configuration instructions
36
+ - Clear options between package managers and manual installation
37
+
38
+ ## [1.3.0] - 2025-08-28
39
+
40
+ ### Changed
41
+ - 🔥 **Cost Burn Rate Calculation** - Now calculates burn rate ($/hour) directly from Claude Code's cost and duration data
42
+ - No longer relies on ccusage for burn rate calculation
43
+ - Uses `cost.total_cost_usd` and `cost.total_duration_ms` from Claude Code's input
44
+ - More accurate and reliable burn rate display
45
+ - 📁 **Project-Relative Logging** - Statusline logs are now created relative to where the statusline script is installed
46
+ - Logs go to `.claude/statusline.log` in the project directory when installed locally
47
+ - Previously always logged to `~/.claude/statusline.log` regardless of installation location
48
+ ### Fixed
49
+ - 🐛 Fixed version drift between CLI and package.json
50
+ - 🐛 Fixed logging directory to respect project-level installations
51
+
52
+ ### Added
53
+ - ✨ Version number now included in generated statusline headers (e.g., `# Generated by cc-statusline v1.3.0`)
54
+
55
+ ## [1.2.7] - 2025-08-28
56
+
57
+ ### Fixed
58
+ - 🐛 **ccusage Integration Fix** - Fixed ccusage stats not displaying in statusline
59
+ - Moved `input=$(cat)` before logging to ensure proper input capture
60
+ - Simplified ccusage execution by removing complex locking mechanism
61
+ - Now properly calls `ccusage blocks --json` directly with internal caching
62
+ - Fixed cost display, burn rate, token stats, and session time display
63
+
64
+ ## [1.2.6] - 2025-08-27
65
+
66
+ ### Fixed
67
+ - 🐛 **Installation Prompt Fix** - Fixed spinner blocking the overwrite confirmation prompt during installation
68
+ - Removed ora spinner during installation phase to ensure prompts are visible
69
+ - Replaced spinner with simple console messages for better UX
70
+ - Users can now properly see and respond to overwrite confirmations
71
+
72
+ ## [1.2.5] - 2025-08-27
73
+
74
+ ### Fixed
75
+ - 🐛 **Cost Display Fix** - Fixed incorrect cost values (e.g., $48.00) caused by improper quoting in printf statements
76
+ - Removed unnecessary escaped quotes around `$cost_usd` in bash generator
77
+ - Cost values now display correctly with proper decimal formatting
78
+
79
+ ## [1.2.4] - 2025-08-26
80
+
81
+ ### Added
82
+ - 🆕 **Installation Location Choice** - Choose between global (`~/.claude`) or project-level (`./.claude`) installation
83
+ - 🔒 **Safe Installation** - Confirmation prompts before overwriting existing statusline.sh files
84
+ - 🛡️ **Settings Protection** - Smart settings.json updates that preserve existing configurations
85
+ - ⚠️ **Conflict Detection** - Warns when other statuslines are already configured
86
+ - ✅ **Better Error Handling** - Clear messages for cancelled installations and conflicts
87
+
88
+ ### Changed
89
+ - Installation prompt now includes location selection (global vs project)
90
+ - Default installation is project-level for safety
91
+ - Improved settings.json update logic to prevent accidental overwrites
92
+
93
+ ## [1.2.3] - 2025-08-20
94
+
95
+ ### Fixed
96
+ - 🔒 **Critical Process Spawning Fix** - Added file-based locking mechanism to prevent infinite ccusage process spawning
97
+ - **Performance** - Implemented 3-second timeout for ccusage calls to prevent hanging
98
+ - 🛡️ **Stability** - Added PID tracking for stale lock detection and cleanup
99
+ - 🔧 **Cross-platform** - Multiple timeout strategies for Linux, macOS, and BSD compatibility
100
+
101
+ ### Contributors
102
+ - 🙏 **Special thanks to [Jonathan Borgwing (@DevVig)](https://github.com/DevVig)** for identifying and implementing the critical process spawning fix ([#4](https://github.com/chongdashu/cc-statusline/pull/4))
103
+
104
+ ### Technical Details
105
+ - **File-based locking**: Uses `/tmp/ccusage_statusline.lock` directory as a mutex to ensure single execution
106
+ - **PID tracking**: Stores process ID in `/tmp/ccusage_statusline.pid` for stale lock detection
107
+ - **Graceful degradation**: Skips execution when locked instead of queuing (prevents pile-up)
108
+ - **Automatic cleanup**: Detects and removes stale locks from crashed processes using `kill -0`
109
+ - **Cross-platform timeouts**: Multiple timeout strategies (timeout/gtimeout/fallback) for all systems
110
+ - **Testing included**: Comprehensive test suite in `test/` directory to verify locking behavior
111
+
112
+ ## [1.0.1] - 2025-08-13
113
+
114
+ ### Added
115
+ - CONTRIBUTING.md with comprehensive contribution guidelines
116
+ - Development workflow documentation
117
+ - Code standards and testing guidelines
118
+
119
+ ### Changed
120
+ - Updated package name to unscoped `cc-statusline`
121
+ - Enhanced README contributing section with better guidance
122
+
123
+ ## [1.0.0] - 2025-08-13
124
+
125
+ ### Added
126
+ - Initial release of cc-statusline
127
+ - Interactive configuration wizard with 2 simple prompts
128
+ - Bash script generation with optimized performance
129
+ - Real-time ccusage integration for usage statistics
130
+ - Preview mode for testing statusline scripts with mock data
131
+ - Auto-installation with settings.json configuration
132
+ - Support for directory, git, model, usage, session, token, and burn rate features
133
+ - TTY-aware color support with NO_COLOR environment variable respect
134
+ - Manual configuration instructions when auto-update fails
135
+ - Comprehensive documentation and examples
136
+ - Performance analysis and validation in preview mode
137
+ - Timestamp and npm URL in generated script headers
138
+
139
+ ### Features
140
+ - 📁 Working Directory display with `~` abbreviation
141
+ - 🌿 Git Branch integration
142
+ - 🤖 Model Name & Version display
143
+ - 💵 Real-time Usage & Cost tracking
144
+ - ⌛ Session Time Remaining with progress bars
145
+ - 📊 Token Statistics (optional)
146
+ - ⚡ Burn Rate monitoring (optional)
147
+
148
+ ### Technical
149
+ - TypeScript with strict type checking
150
+ - ESM module support
151
+ - Commander.js for CLI interface
152
+ - Inquirer.js for interactive prompts
153
+ - Chalk for colorized output
154
+ - Ora for loading spinners
155
+ - Comprehensive error handling and validation
156
+ - Modular architecture for easy maintenance
157
+
111
158
  [1.0.0]: https://github.com/chongdashu/cc-statusline/releases/tag/v1.0.0
package/CLAUDE.md CHANGED
@@ -1,62 +1,77 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
-
7
- cc-statusline is a TypeScript CLI tool that generates custom statuslines for Claude Code. It creates optimized bash scripts that display directory, git info, model name, usage costs, and session time in the terminal.
8
-
9
- ## Development Commands
10
-
11
- ```bash
12
- # Install dependencies
13
- npm install
14
-
15
- # Build the project (required before testing)
16
- npm run build
17
-
18
- # Watch mode for development
19
- npm run dev
20
-
21
- # Test the CLI locally
22
- ./dist/index.js init --no-install
23
- ./dist/index.js preview ./test-statusline.sh
24
-
25
- # Test as if installed globally
26
- npx . init
27
- ```
28
-
29
- ## Architecture
30
-
31
- The codebase follows a modular ESM TypeScript architecture:
32
-
33
- - **CLI Layer** (`src/cli/`): Commander.js-based CLI with interactive prompts using Inquirer
34
- - **Generator Layer** (`src/generators/`): Creates optimized bash scripts based on user configuration
35
- - **Feature Modules** (`src/features/`): Isolated implementations for git, usage tracking, and colors
36
- - **Utility Layer** (`src/utils/`): Installation, validation, and testing utilities
37
-
38
- Key design patterns:
39
- - Feature flags determine which bash code blocks are included in generated scripts
40
- - All bash generation is template-based with conditional sections
41
- - Mock testing simulates Claude Code's JSON input for preview functionality
42
-
43
- ## Key Implementation Details
44
-
45
- **Build System**: Uses tsup for ESM bundling with Node 16+ target. The `#!/usr/bin/env node` shebang is automatically added during build.
46
-
47
- **Generated Scripts**: The bash statuslines are self-contained with graceful fallbacks when dependencies (jq, git, ccusage) are missing. Scripts execute in <100ms with minimal resource usage.
48
-
49
- **Installation Flow**:
50
- 1. Collects user preferences via inquirer prompts
51
- 2. Generates optimized bash script with only selected features
52
- 3. Writes to `.claude/statusline.sh` with execute permissions
53
- 4. Updates `.claude/settings.json` to register the statusline command
54
-
55
- **Testing Approach**: Preview command uses mock Claude Code JSON data to test statuslines before installation. Real testing requires manual verification with Claude Code running.
56
-
57
- ## Important Conventions
58
-
59
- - Use ESM imports with `.js` extensions (even for `.ts` files)
60
- - Maintain 2-space indentation without semicolons
61
- - Follow conventional commits format for commit messages
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ cc-statusline is a TypeScript CLI tool that generates custom statuslines for Claude Code. It creates optimized bash scripts that display directory, git info, model name, usage costs, and session time in the terminal.
8
+
9
+ ## Development Commands
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ npm install
14
+
15
+ # Build the project (required before testing)
16
+ npm run build
17
+
18
+ # Watch mode for development
19
+ npm run dev
20
+
21
+ # Test the CLI locally
22
+ ./dist/index.js init --no-install
23
+ ./dist/index.js preview ./test-statusline.sh
24
+
25
+ # Test as if installed globally
26
+ npx . init
27
+
28
+ # Test the generated statusline with mock data
29
+ ./test_debug.sh
30
+
31
+ # Run installation tests
32
+ ./test/test-installation.sh
33
+ ```
34
+
35
+ ## Architecture
36
+
37
+ The codebase follows a modular ESM TypeScript architecture:
38
+
39
+ - **CLI Layer** (`src/cli/`): Commander.js-based CLI with interactive prompts using Inquirer
40
+ - **Generator Layer** (`src/generators/`): Creates optimized bash scripts based on user configuration
41
+ - **Feature Modules** (`src/features/`): Isolated implementations for git, usage tracking, and colors
42
+ - **Utility Layer** (`src/utils/`): Installation, validation, and testing utilities
43
+
44
+ Key design patterns:
45
+ - Feature flags determine which bash code blocks are included in generated scripts
46
+ - All bash generation is template-based with conditional sections
47
+ - Mock testing simulates Claude Code's JSON input for preview functionality
48
+
49
+ ## Key Implementation Details
50
+
51
+ **Build System**: Uses tsup for ESM bundling with Node 16+ target. The `#!/usr/bin/env node` shebang is automatically added during build.
52
+
53
+ **Generated Scripts**: The bash statuslines are self-contained with graceful fallbacks when dependencies (jq, git, ccusage) are missing. Scripts execute in <100ms with minimal resource usage.
54
+
55
+ **Installation Flow**:
56
+ 1. Collects user preferences via inquirer prompts
57
+ 2. Generates optimized bash script with only selected features
58
+ 3. Writes to `.claude/statusline.sh` with execute permissions
59
+ 4. Updates `.claude/settings.json` to register the statusline command
60
+
61
+ **Testing Approach**: Preview command uses mock Claude Code JSON data to test statuslines before installation. Real testing requires manual verification with Claude Code running.
62
+
63
+ ## Critical Bug-Prone Areas
64
+
65
+ **JSON Parsing in Bash**: The `bash-generator.ts` file contains a fallback JSON parser for systems without `jq`. This uses complex grep/sed patterns with careful quote escaping. The quotes in the grep patterns must be escaped as `\\"` in the TypeScript template strings to generate valid bash code.
66
+
67
+ **Quote Escaping in bash-generator.ts**: Lines 100-105 contain grep patterns that require double escaping:
68
+ - TypeScript template literal needs `\\` for a single backslash
69
+ - Bash needs `\"` for escaped quotes
70
+ - Combined: `\\"\\${field}\\"` to produce `"${field}"` in the final bash script
71
+
72
+ ## Important Conventions
73
+
74
+ - Use ESM imports with `.js` extensions (even for `.ts` files)
75
+ - Maintain 2-space indentation without semicolons
76
+ - Follow conventional commits format for commit messages
62
77
  - Generated bash scripts must be POSIX-compliant with fallbacks