cc-context-stats 1.7.0 → 1.8.1
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/package.json +9 -1
- package/scripts/context-stats.sh +1 -1
- package/scripts/statusline.js +128 -18
- package/.editorconfig +0 -60
- package/.eslintrc.json +0 -35
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -49
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -31
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -33
- package/.github/dependabot.yml +0 -44
- package/.github/workflows/ci.yml +0 -294
- package/.github/workflows/release.yml +0 -151
- package/.pre-commit-config.yaml +0 -74
- package/.prettierrc +0 -33
- package/.shellcheckrc +0 -10
- package/CHANGELOG.md +0 -163
- package/CLAUDE.md +0 -66
- package/CODE_OF_CONDUCT.md +0 -59
- package/CONTRIBUTING.md +0 -240
- package/RELEASE_NOTES.md +0 -19
- package/SECURITY.md +0 -44
- package/TODOS.md +0 -72
- package/assets/logo/favicon.svg +0 -19
- package/assets/logo/logo-black.svg +0 -24
- package/assets/logo/logo-full.svg +0 -40
- package/assets/logo/logo-icon.svg +0 -27
- package/assets/logo/logo-mark.svg +0 -28
- package/assets/logo/logo-white.svg +0 -24
- package/assets/logo/logo-wordmark.svg +0 -6
- package/config/settings-example.json +0 -7
- package/config/settings-node.json +0 -7
- package/config/settings-python.json +0 -7
- package/docs/ARCHITECTURE.md +0 -128
- package/docs/CSV_FORMAT.md +0 -42
- package/docs/DEPLOYMENT.md +0 -71
- package/docs/DEVELOPMENT.md +0 -161
- package/docs/configuration.md +0 -118
- package/docs/context-stats.md +0 -143
- package/docs/installation.md +0 -255
- package/docs/scripts.md +0 -140
- package/docs/troubleshooting.md +0 -278
- package/images/claude-statusline-token-graph.gif +0 -0
- package/images/claude-statusline.png +0 -0
- package/images/context-status-dumbzone.png +0 -0
- package/images/context-status.png +0 -0
- package/images/statusline-detail.png +0 -0
- package/images/token-graph.jpeg +0 -0
- package/images/token-graph.png +0 -0
- package/images/v1.6.1.png +0 -0
- package/install +0 -351
- package/install.sh +0 -298
- package/jest.config.js +0 -11
- package/pyproject.toml +0 -115
- package/requirements-dev.txt +0 -12
- package/scripts/statusline-full.sh +0 -304
- package/scripts/statusline-git.sh +0 -88
- package/scripts/statusline-minimal.sh +0 -67
- package/scripts/statusline.py +0 -485
- package/src/claude_statusline/__init__.py +0 -11
- package/src/claude_statusline/__main__.py +0 -6
- package/src/claude_statusline/cli/__init__.py +0 -1
- package/src/claude_statusline/cli/context_stats.py +0 -512
- package/src/claude_statusline/cli/explain.py +0 -228
- package/src/claude_statusline/cli/statusline.py +0 -169
- package/src/claude_statusline/core/__init__.py +0 -1
- package/src/claude_statusline/core/colors.py +0 -124
- package/src/claude_statusline/core/config.py +0 -148
- package/src/claude_statusline/core/git.py +0 -78
- package/src/claude_statusline/core/state.py +0 -323
- package/src/claude_statusline/formatters/__init__.py +0 -1
- package/src/claude_statusline/formatters/layout.py +0 -67
- package/src/claude_statusline/formatters/time.py +0 -50
- package/src/claude_statusline/formatters/tokens.py +0 -70
- package/src/claude_statusline/graphs/__init__.py +0 -1
- package/src/claude_statusline/graphs/renderer.py +0 -366
- package/src/claude_statusline/graphs/statistics.py +0 -92
- package/src/claude_statusline/ui/__init__.py +0 -1
- package/src/claude_statusline/ui/icons.py +0 -93
- package/src/claude_statusline/ui/waiting.py +0 -62
- package/tests/bash/test_delta_parity.bats +0 -199
- package/tests/bash/test_install.bats +0 -29
- package/tests/bash/test_parity.bats +0 -315
- package/tests/bash/test_statusline_full.bats +0 -139
- package/tests/bash/test_statusline_git.bats +0 -42
- package/tests/bash/test_statusline_minimal.bats +0 -37
- package/tests/fixtures/json/comma_in_path.json +0 -31
- package/tests/fixtures/json/high_usage.json +0 -17
- package/tests/fixtures/json/low_usage.json +0 -17
- package/tests/fixtures/json/medium_usage.json +0 -17
- package/tests/fixtures/json/valid_full.json +0 -30
- package/tests/fixtures/json/valid_minimal.json +0 -9
- package/tests/node/rotation.test.js +0 -89
- package/tests/node/statusline.test.js +0 -240
- package/tests/python/conftest.py +0 -84
- package/tests/python/test_colors.py +0 -105
- package/tests/python/test_config_colors.py +0 -78
- package/tests/python/test_data_pipeline.py +0 -446
- package/tests/python/test_explain.py +0 -177
- package/tests/python/test_icons.py +0 -152
- package/tests/python/test_layout.py +0 -127
- package/tests/python/test_state_rotation_validation.py +0 -232
- package/tests/python/test_statusline.py +0 -215
- package/tests/python/test_waiting.py +0 -127
package/CHANGELOG.md
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
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.1.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [Unreleased]
|
|
9
|
-
|
|
10
|
-
## [1.7.0] - 2026-03-14
|
|
11
|
-
|
|
12
|
-
### Added
|
|
13
|
-
|
|
14
|
-
- **Configurable colors** - Custom color themes via `~/.claude/statusline.conf` using named colors (`bright_cyan`) or hex codes (`#7dcfff`). Six configurable slots: `color_green`, `color_yellow`, `color_red`, `color_blue`, `color_magenta`, `color_cyan`
|
|
15
|
-
- **`context-stats explain` command** - Diagnostic dump that pretty-prints Claude Code's JSON context with derived values (free tokens, autocompact buffer, effective free), active config, vim/agent/output_style extensions, and raw JSON. Supports `--no-color` flag
|
|
16
|
-
- **24-bit true color support** - Hex color codes (`#rrggbb`) are converted to ANSI 24-bit escape sequences for full RGB color customization
|
|
17
|
-
- **Cross-implementation sync documentation** - Added sync points table to CLAUDE.md documenting triplicated logic across Python, Node.js, and Bash implementations
|
|
18
|
-
|
|
19
|
-
### Changed
|
|
20
|
-
|
|
21
|
-
- **ColorManager accepts overrides** - `ColorManager` now takes an optional `overrides` dict, allowing config-driven color customization throughout the package
|
|
22
|
-
- **Git info uses configurable colors** - Branch and change count colors now respect user color overrides in all three implementations
|
|
23
|
-
- **Config parsing preserves raw values** - Config reader now preserves case for color values while lowercasing only for boolean comparison
|
|
24
|
-
|
|
25
|
-
## [1.6.2] - 2026-03-13
|
|
26
|
-
|
|
27
|
-
### Fixed
|
|
28
|
-
|
|
29
|
-
- **Delta calculation parity** - Python statusline now reads correct CSV indices (3+5+6) for context usage delta, matching Node.js behavior
|
|
30
|
-
- **Missing duplicate-entry guard** - Python statusline now skips state file writes when token count is unchanged, preventing file bloat
|
|
31
|
-
- **Missing state file rotation** - Python statusline now calls rotation after writes (10k/5k threshold), matching Node.js
|
|
32
|
-
- **Missing git timeout** - Added 5-second timeout to git subprocess calls in standalone Python statusline script
|
|
33
|
-
- **Broad exception handling** - Narrowed `except Exception` to `(OSError, ValueError)` for state reads and `OSError` for writes
|
|
34
|
-
- **Stale CSV format comments** - Added missing `context_window_size` field to header comments in both Python and Node.js scripts
|
|
35
|
-
|
|
36
|
-
### Added
|
|
37
|
-
|
|
38
|
-
- **Delta parity tests** - 4 new bats tests verifying Python/Node.js produce identical deltas, handle first-run/decrease/dedup correctly
|
|
39
|
-
|
|
40
|
-
## [1.6.1] - 2026-03-13
|
|
41
|
-
|
|
42
|
-
### Fixed
|
|
43
|
-
|
|
44
|
-
- **Footer version drift** - Corrected stale version `1.2.3` in bash script and `1.0.0` default in Python renderer to match actual release version
|
|
45
|
-
- **Footer project name** - Renamed `claude-statusline` to `cc-context-stats` in the footer display across bash and Python implementations
|
|
46
|
-
- **Install version embedding** - Install scripts now read version from `package.json` and embed it into the installed script, preventing future version drift
|
|
47
|
-
|
|
48
|
-
## [1.6.0] - 2026-03-13
|
|
49
|
-
|
|
50
|
-
### Added
|
|
51
|
-
|
|
52
|
-
- **CLI `--version` flag** - `context-stats --version` / `-V` now prints the current version
|
|
53
|
-
- **State file rotation** - Automatic rotation at 10,000 lines (keeps most recent 5,000) to prevent unbounded file growth
|
|
54
|
-
- **Session ID validation** - Rejects path-traversal characters (`/`, `\`, `..`, null bytes) for security
|
|
55
|
-
- **Git command timeout** - 5-second timeout on git operations in both Python and Node.js implementations
|
|
56
|
-
- **Core data pipeline unit tests** - 51 tests across 6 classes covering config, state, formatters, graph, and CLI
|
|
57
|
-
- **Cross-implementation parity test** - Ensures Python and Node.js statusline scripts produce consistent output
|
|
58
|
-
- **Stderr warnings** - Critical error paths now emit warnings to stderr for debugging
|
|
59
|
-
- **CSV format documentation** - Formal specification of the 14-field state file format
|
|
60
|
-
- **Comma guard for workspace paths** - Commas in `workspace_project_dir` are replaced with underscores before CSV write
|
|
61
|
-
- **Open-source standard files** - Added CODE_OF_CONDUCT.md, CONTRIBUTING.md, SECURITY.md, and GitHub issue/PR templates
|
|
62
|
-
- **NPM Package** - `cc-context-stats` now available on npm for JavaScript/Node.js environments
|
|
63
|
-
|
|
64
|
-
### Changed
|
|
65
|
-
|
|
66
|
-
- **Package Metadata** - Synchronized package descriptions across npm and PyPI for consistency
|
|
67
|
-
- **Installation Section** - Moved shell script installation to the top of README as the recommended method
|
|
68
|
-
|
|
69
|
-
### Dependencies
|
|
70
|
-
|
|
71
|
-
- Bumped prettier from 3.7.4 to 3.8.0
|
|
72
|
-
|
|
73
|
-
## [1.2.0] - 2025-01-08
|
|
74
|
-
|
|
75
|
-
### Added
|
|
76
|
-
|
|
77
|
-
- **Context Zones** - Status indicator based on context usage:
|
|
78
|
-
- 🟢 Smart Zone (< 40%): "You are in the smart zone"
|
|
79
|
-
- 🟡 Dumb Zone (40-80%): "You are in the dumb zone - Dex Horthy says so"
|
|
80
|
-
- 🔴 Wrap Up Zone (> 80%): "Better to wrap up and start a new session"
|
|
81
|
-
- **Project name display** - Header now shows "Context Stats (project-name • session-id)"
|
|
82
|
-
|
|
83
|
-
### Changed
|
|
84
|
-
|
|
85
|
-
- **Watch mode enabled by default** - `context-stats` now runs in live monitoring mode (2s refresh)
|
|
86
|
-
- **Delta graph by default** - Shows "Context Growth Per Interaction" instead of both graphs
|
|
87
|
-
- Added `--no-watch` flag to show graphs once and exit
|
|
88
|
-
- Simplified installer - no script selection, auto-overwrite existing files
|
|
89
|
-
- Renamed graph labels to focus on context (e.g., "Context Usage Over Time")
|
|
90
|
-
- Cleaned up session summary - removed clutter, highlighted status
|
|
91
|
-
|
|
92
|
-
## [1.1.0] - 2025-01-08
|
|
93
|
-
|
|
94
|
-
### Changed
|
|
95
|
-
|
|
96
|
-
- **BREAKING**: Renamed package from `cc-statusline` to `cc-context-stats`
|
|
97
|
-
- **BREAKING**: Renamed `token-graph` CLI command to `context-stats`
|
|
98
|
-
- Pivoted project focus to real-time token monitoring and context tracking
|
|
99
|
-
- Updated tagline: "Never run out of context unexpectedly"
|
|
100
|
-
|
|
101
|
-
### Migration
|
|
102
|
-
|
|
103
|
-
If upgrading from `cc-statusline`:
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
pip uninstall cc-statusline
|
|
107
|
-
pip install cc-context-stats
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
The `claude-statusline` command still works. Replace `token-graph` with `context-stats`.
|
|
111
|
-
|
|
112
|
-
## [1.0.2] - 2025-01-08
|
|
113
|
-
|
|
114
|
-
### Fixed
|
|
115
|
-
|
|
116
|
-
- Fixed remaining context showing negative values in context-stats by using `current_used_tokens` instead of cumulative `total_input_tokens + total_output_tokens`
|
|
117
|
-
- Fixed ANSI escape codes not rendering properly in watch mode by using `sys.stdout.write()` instead of `print()` for cursor control sequences
|
|
118
|
-
- Fixed color codes in summary statistics using ColorManager instead of raw ANSI constants
|
|
119
|
-
|
|
120
|
-
## [1.0.1] - 2025-01-07
|
|
121
|
-
|
|
122
|
-
### Added
|
|
123
|
-
|
|
124
|
-
- pip/uv installable Python package (`cc-statusline` on PyPI)
|
|
125
|
-
- `context_window_size` field to state file for tracking remaining context
|
|
126
|
-
- Remaining context display in context-stats summary
|
|
127
|
-
|
|
128
|
-
### Fixed
|
|
129
|
-
|
|
130
|
-
- Restored executable permissions on script files
|
|
131
|
-
- Fixed stdin detection in pipe mode using INTERACTIVE flag
|
|
132
|
-
|
|
133
|
-
### Changed
|
|
134
|
-
|
|
135
|
-
- Cleaned up unused `show_io_tokens` option
|
|
136
|
-
- Fixed shellcheck warnings in shell scripts
|
|
137
|
-
|
|
138
|
-
## [1.0.0] - 2025-01-06
|
|
139
|
-
|
|
140
|
-
### Added
|
|
141
|
-
|
|
142
|
-
- Comprehensive test suite with Bats (Bash), pytest (Python), and Jest (Node.js)
|
|
143
|
-
- GitHub Actions CI/CD pipeline with multi-platform testing
|
|
144
|
-
- Code quality tools: ShellCheck, Ruff, ESLint, Prettier
|
|
145
|
-
- Pre-commit hooks for automated code quality checks
|
|
146
|
-
- EditorConfig for consistent formatting across editors
|
|
147
|
-
- CONTRIBUTING.md with development setup instructions
|
|
148
|
-
- Dependabot configuration for automated dependency updates
|
|
149
|
-
- Release automation workflow
|
|
150
|
-
- Full-featured status line script (`statusline-full.sh`)
|
|
151
|
-
- Git-aware status line script (`statusline-git.sh`)
|
|
152
|
-
- Minimal status line script (`statusline-minimal.sh`)
|
|
153
|
-
- Cross-platform Python implementation (`statusline.py`)
|
|
154
|
-
- Cross-platform Node.js implementation (`statusline.js`)
|
|
155
|
-
- Interactive installer script (`install.sh`)
|
|
156
|
-
- Configuration examples for Claude Code
|
|
157
|
-
- Autocompact (AC) buffer indicator
|
|
158
|
-
- Context window usage with color-coded percentages
|
|
159
|
-
- Git branch and uncommitted changes display
|
|
160
|
-
|
|
161
|
-
## [0.x] - Pre-release
|
|
162
|
-
|
|
163
|
-
Initial development versions with basic status line functionality.
|
package/CLAUDE.md
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
## Project Purpose
|
|
4
|
-
|
|
5
|
-
cc-context-stats provides real-time context window monitoring for Claude Code sessions. It tracks token consumption over time and displays live ASCII graphs so users can see how much context remains.
|
|
6
|
-
|
|
7
|
-
## Dual-Implementation Rationale
|
|
8
|
-
|
|
9
|
-
The statusline is implemented in three languages (Bash, Python, Node.js) so users can choose whichever runtime they have available. Claude Code invokes the statusline script via stdin JSON pipe — any implementation that reads JSON from stdin and writes formatted text to stdout works. The Python and Node.js implementations also persist state to CSV files read by the `context-stats` CLI.
|
|
10
|
-
|
|
11
|
-
## CSV Format Contract
|
|
12
|
-
|
|
13
|
-
State files are append-only CSV at `~/.claude/statusline/statusline.<session_id>.state` with 14 comma-separated fields. See [docs/CSV_FORMAT.md](docs/CSV_FORMAT.md) for the full field specification. Key constraint: `workspace_project_dir` has commas replaced with underscores before writing.
|
|
14
|
-
|
|
15
|
-
## Statusline Script Landscape
|
|
16
|
-
|
|
17
|
-
| Script | Language | State writes | Notes |
|
|
18
|
-
|---|---|---|---|
|
|
19
|
-
| `scripts/statusline-full.sh` | Bash | No | Full display, requires `jq` |
|
|
20
|
-
| `scripts/statusline-git.sh` | Bash | No | Git-focused variant |
|
|
21
|
-
| `scripts/statusline-minimal.sh` | Bash | No | Minimal variant |
|
|
22
|
-
| `scripts/statusline.py` | Python 3 | Yes | Pip-installable via package |
|
|
23
|
-
| `scripts/statusline.js` | Node.js | Yes | Standalone script |
|
|
24
|
-
|
|
25
|
-
## Test Commands
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
# Python tests
|
|
29
|
-
source venv/bin/activate
|
|
30
|
-
pytest tests/python/ -v
|
|
31
|
-
|
|
32
|
-
# Node.js tests
|
|
33
|
-
npm test
|
|
34
|
-
|
|
35
|
-
# Bash integration tests
|
|
36
|
-
bats tests/bash/*.bats
|
|
37
|
-
|
|
38
|
-
# All tests
|
|
39
|
-
pytest && npm test && bats tests/bash/*.bats
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Key Architectural Decisions
|
|
43
|
-
|
|
44
|
-
- **Append-only CSV state files** with rotation at 10,000 lines (keeps most recent 5,000)
|
|
45
|
-
- **No network requests** — all data stays local in `~/.claude/statusline/`
|
|
46
|
-
- **Session ID validation** — rejects `/`, `\`, `..`, and null bytes for path-traversal defense
|
|
47
|
-
- **5-second git command timeout** in both Python and Node.js implementations
|
|
48
|
-
- **Config via `~/.claude/statusline.conf`** — simple key=value pairs
|
|
49
|
-
|
|
50
|
-
## Cross-Implementation Sync Points
|
|
51
|
-
|
|
52
|
-
The following logic is duplicated across three implementations and **must be kept in sync** when modified:
|
|
53
|
-
|
|
54
|
-
| Logic | Package (`src/`) | Standalone Python (`scripts/statusline.py`) | Node.js (`scripts/statusline.js`) |
|
|
55
|
-
|---|---|---|---|
|
|
56
|
-
| Config parsing | `core/config.py` | `read_config()` | `readConfig()` |
|
|
57
|
-
| Color name map | `core/colors.py:COLOR_NAMES` | `_COLOR_NAMES` | `COLOR_NAMES` |
|
|
58
|
-
| Color parser | `core/colors.py:parse_color()` | `_parse_color()` | `parseColor()` |
|
|
59
|
-
| Git info | `core/git.py:get_git_info()` | `get_git_info()` | `getGitInfo()` |
|
|
60
|
-
| State rotation | `core/state.py` | `maybe_rotate_state_file()` | `maybeRotateStateFile()` |
|
|
61
|
-
|
|
62
|
-
## Cross-References
|
|
63
|
-
|
|
64
|
-
- [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) — system architecture and data flow
|
|
65
|
-
- [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) — setup, testing, and contribution guide
|
|
66
|
-
- [docs/CSV_FORMAT.md](docs/CSV_FORMAT.md) — state file field specification
|
package/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
-
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
-
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
-
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
-
and orientation.
|
|
11
|
-
|
|
12
|
-
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
-
diverse, inclusive, and healthy community.
|
|
14
|
-
|
|
15
|
-
## Our Standards
|
|
16
|
-
|
|
17
|
-
Examples of behavior that contributes to a positive environment:
|
|
18
|
-
|
|
19
|
-
* Demonstrating empathy and kindness toward other people
|
|
20
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
|
21
|
-
* Giving and gracefully accepting constructive feedback
|
|
22
|
-
* Accepting responsibility and apologizing to those affected by our mistakes
|
|
23
|
-
* Focusing on what is best for the overall community
|
|
24
|
-
|
|
25
|
-
Examples of unacceptable behavior:
|
|
26
|
-
|
|
27
|
-
* The use of sexualized language or imagery, and sexual attention or advances
|
|
28
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
29
|
-
* Public or private harassment
|
|
30
|
-
* Publishing others' private information without explicit permission
|
|
31
|
-
* Other conduct which could reasonably be considered inappropriate
|
|
32
|
-
|
|
33
|
-
## Enforcement Responsibilities
|
|
34
|
-
|
|
35
|
-
Community leaders are responsible for clarifying and enforcing our standards of
|
|
36
|
-
acceptable behavior and will take appropriate and fair corrective action in
|
|
37
|
-
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
38
|
-
or harmful.
|
|
39
|
-
|
|
40
|
-
## Scope
|
|
41
|
-
|
|
42
|
-
This Code of Conduct applies within all community spaces, and also applies when
|
|
43
|
-
an individual is officially representing the community in public spaces.
|
|
44
|
-
|
|
45
|
-
## Enforcement
|
|
46
|
-
|
|
47
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
48
|
-
reported to the community leaders responsible for enforcement at
|
|
49
|
-
luongnv89@gmail.com.
|
|
50
|
-
|
|
51
|
-
All complaints will be reviewed and investigated promptly and fairly.
|
|
52
|
-
|
|
53
|
-
## Attribution
|
|
54
|
-
|
|
55
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
56
|
-
version 2.0, available at
|
|
57
|
-
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
58
|
-
|
|
59
|
-
[homepage]: https://www.contributor-covenant.org
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
# Contributing to Claude Code Status Line
|
|
2
|
-
|
|
3
|
-
Thank you for your interest in contributing to Claude Code Status Line! This document provides guidelines and instructions for contributing.
|
|
4
|
-
|
|
5
|
-
## Development Setup
|
|
6
|
-
|
|
7
|
-
### Prerequisites
|
|
8
|
-
|
|
9
|
-
- **Git** - Version control
|
|
10
|
-
- **jq** - JSON processor (for bash scripts)
|
|
11
|
-
- **Python 3.9+** - For Python script and testing
|
|
12
|
-
- **Node.js 18+** - For Node.js script and testing
|
|
13
|
-
- **Bats** - Bash Automated Testing System
|
|
14
|
-
|
|
15
|
-
### Installing Dependencies
|
|
16
|
-
|
|
17
|
-
#### macOS
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
# Install system dependencies
|
|
21
|
-
brew install jq bats-core
|
|
22
|
-
|
|
23
|
-
# Clone the repository
|
|
24
|
-
git clone https://github.com/luongnv89/cc-context-stats.git
|
|
25
|
-
cd claude-statusline
|
|
26
|
-
|
|
27
|
-
# Install Python dependencies
|
|
28
|
-
python3 -m venv venv
|
|
29
|
-
source venv/bin/activate
|
|
30
|
-
pip install -r requirements-dev.txt
|
|
31
|
-
|
|
32
|
-
# Install Node.js dependencies
|
|
33
|
-
npm install
|
|
34
|
-
|
|
35
|
-
# Install pre-commit hooks
|
|
36
|
-
pre-commit install
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
#### Linux (Ubuntu/Debian)
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
# Install system dependencies
|
|
43
|
-
sudo apt-get update
|
|
44
|
-
sudo apt-get install -y jq bats
|
|
45
|
-
|
|
46
|
-
# Clone the repository
|
|
47
|
-
git clone https://github.com/luongnv89/cc-context-stats.git
|
|
48
|
-
cd claude-statusline
|
|
49
|
-
|
|
50
|
-
# Install Python dependencies
|
|
51
|
-
python3 -m venv venv
|
|
52
|
-
source venv/bin/activate
|
|
53
|
-
pip install -r requirements-dev.txt
|
|
54
|
-
|
|
55
|
-
# Install Node.js dependencies
|
|
56
|
-
npm install
|
|
57
|
-
|
|
58
|
-
# Install pre-commit hooks
|
|
59
|
-
pre-commit install
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Project Structure
|
|
63
|
-
|
|
64
|
-
```text
|
|
65
|
-
claude-statusline/
|
|
66
|
-
├── scripts/ # Main scripts
|
|
67
|
-
│ ├── statusline-full.sh # Full-featured bash script
|
|
68
|
-
│ ├── statusline-git.sh # Git-aware bash script
|
|
69
|
-
│ ├── statusline-minimal.sh # Minimal bash script
|
|
70
|
-
│ ├── statusline.py # Python cross-platform script
|
|
71
|
-
│ └── statusline.js # Node.js cross-platform script
|
|
72
|
-
├── config/ # Configuration examples
|
|
73
|
-
├── tests/ # Test suites
|
|
74
|
-
│ ├── fixtures/json/ # Test fixtures
|
|
75
|
-
│ ├── bash/ # Bats tests
|
|
76
|
-
│ ├── python/ # Pytest tests
|
|
77
|
-
│ └── node/ # Jest tests
|
|
78
|
-
├── .github/workflows/ # CI/CD workflows
|
|
79
|
-
├── install.sh # Installation script
|
|
80
|
-
└── README.md # Documentation
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Running Tests
|
|
84
|
-
|
|
85
|
-
### All Tests
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
# Run all tests
|
|
89
|
-
npm test && pytest && bats tests/bash/*.bats
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Individual Test Suites
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
# Bash tests (requires bats)
|
|
96
|
-
bats tests/bash/*.bats
|
|
97
|
-
|
|
98
|
-
# Python tests
|
|
99
|
-
pytest tests/python/ -v
|
|
100
|
-
|
|
101
|
-
# Python tests with coverage
|
|
102
|
-
pytest tests/python/ -v --cov=scripts --cov-report=html
|
|
103
|
-
|
|
104
|
-
# Node.js tests
|
|
105
|
-
npm test
|
|
106
|
-
|
|
107
|
-
# Node.js tests with coverage
|
|
108
|
-
npm run test:coverage
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
## Code Quality
|
|
112
|
-
|
|
113
|
-
### Linting
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
# Run all linters
|
|
117
|
-
pre-commit run --all-files
|
|
118
|
-
|
|
119
|
-
# Individual linters
|
|
120
|
-
ruff check scripts/statusline.py # Python
|
|
121
|
-
npx eslint scripts/statusline.js # JavaScript
|
|
122
|
-
shellcheck scripts/*.sh install.sh # Bash
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Formatting
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
# Auto-format Python
|
|
129
|
-
ruff format scripts/statusline.py
|
|
130
|
-
|
|
131
|
-
# Auto-format JavaScript
|
|
132
|
-
npx prettier --write scripts/statusline.js
|
|
133
|
-
|
|
134
|
-
# Check formatting without modifying
|
|
135
|
-
ruff format --check scripts/statusline.py
|
|
136
|
-
npx prettier --check scripts/statusline.js
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## Making Changes
|
|
140
|
-
|
|
141
|
-
### 1. Create a Branch
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
git checkout -b feature/your-feature-name
|
|
145
|
-
# or
|
|
146
|
-
git checkout -b fix/your-bug-fix
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### 2. Make Changes
|
|
150
|
-
|
|
151
|
-
- Follow the existing code style
|
|
152
|
-
- Add tests for new functionality
|
|
153
|
-
- Update documentation if needed
|
|
154
|
-
- Ensure all scripts produce consistent output
|
|
155
|
-
|
|
156
|
-
### 3. Test Your Changes
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
# Run pre-commit hooks
|
|
160
|
-
pre-commit run --all-files
|
|
161
|
-
|
|
162
|
-
# Run all tests
|
|
163
|
-
bats tests/bash/*.bats
|
|
164
|
-
pytest tests/python/ -v
|
|
165
|
-
npm test
|
|
166
|
-
|
|
167
|
-
# Test scripts manually
|
|
168
|
-
echo '{"model":{"display_name":"Test"}}' | ./scripts/statusline-full.sh
|
|
169
|
-
echo '{"model":{"display_name":"Test"}}' | python3 ./scripts/statusline.py
|
|
170
|
-
echo '{"model":{"display_name":"Test"}}' | node ./scripts/statusline.js
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### 4. Commit Your Changes
|
|
174
|
-
|
|
175
|
-
Use conventional commit messages:
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
git commit -m "feat: add new feature description"
|
|
179
|
-
git commit -m "fix: fix bug description"
|
|
180
|
-
git commit -m "docs: update documentation"
|
|
181
|
-
git commit -m "test: add tests for feature"
|
|
182
|
-
git commit -m "refactor: refactor code description"
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### 5. Push and Create PR
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
git push origin feature/your-feature-name
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
Then create a Pull Request on GitHub.
|
|
192
|
-
|
|
193
|
-
## Script Guidelines
|
|
194
|
-
|
|
195
|
-
### Cross-Script Consistency
|
|
196
|
-
|
|
197
|
-
All three implementations (bash, Python, Node.js) should produce identical output for the same input. When making changes:
|
|
198
|
-
|
|
199
|
-
1. Update all three scripts consistently
|
|
200
|
-
2. Run integration tests to verify parity
|
|
201
|
-
3. Test on multiple platforms if possible
|
|
202
|
-
|
|
203
|
-
### Output Format
|
|
204
|
-
|
|
205
|
-
The status line output should follow this format:
|
|
206
|
-
|
|
207
|
-
```text
|
|
208
|
-
[Model] directory | branch [changes] | XXk free (XX%) [AC:XXk]
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
Components:
|
|
212
|
-
|
|
213
|
-
- `[Model]` - AI model name (dim)
|
|
214
|
-
- `directory` - Current directory name (blue)
|
|
215
|
-
- `branch` - Git branch name (magenta)
|
|
216
|
-
- `[changes]` - Uncommitted changes count (cyan)
|
|
217
|
-
- `XXk free (XX%)` - Available context tokens (green/yellow/red)
|
|
218
|
-
- `[AC:XXk]` - Autocompact buffer (dim)
|
|
219
|
-
|
|
220
|
-
### Color Codes
|
|
221
|
-
|
|
222
|
-
Use ANSI color codes consistently:
|
|
223
|
-
|
|
224
|
-
- Blue: `\033[0;34m`
|
|
225
|
-
- Magenta: `\033[0;35m`
|
|
226
|
-
- Cyan: `\033[0;36m`
|
|
227
|
-
- Green: `\033[0;32m`
|
|
228
|
-
- Yellow: `\033[0;33m`
|
|
229
|
-
- Red: `\033[0;31m`
|
|
230
|
-
- Dim: `\033[2m`
|
|
231
|
-
- Reset: `\033[0m`
|
|
232
|
-
|
|
233
|
-
## Questions?
|
|
234
|
-
|
|
235
|
-
If you have questions, feel free to:
|
|
236
|
-
|
|
237
|
-
- Open an issue on GitHub
|
|
238
|
-
- Check existing issues for similar questions
|
|
239
|
-
|
|
240
|
-
Thank you for contributing!
|
package/RELEASE_NOTES.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
## v1.6.0 — 2026-03-13
|
|
2
|
-
|
|
3
|
-
### Features
|
|
4
|
-
- **CLI `--version` flag** — `context-stats --version` / `-V` now prints the current version
|
|
5
|
-
- **State file rotation** — Automatic rotation at 10,000 lines (keeps most recent 5,000) to prevent unbounded file growth
|
|
6
|
-
- **Session ID validation** — Rejects path-traversal characters (`/`, `\`, `..`, null bytes) for security
|
|
7
|
-
- **Git command timeout** — 5-second timeout on git operations in both Python and Node.js implementations
|
|
8
|
-
- **Core data pipeline unit tests** — 51 tests across 6 classes covering config, state, formatters, graph, and CLI
|
|
9
|
-
- **Cross-implementation parity test** — Ensures Python and Node.js statusline scripts produce consistent output
|
|
10
|
-
- **Stderr warnings** — Critical error paths now emit warnings to stderr for debugging
|
|
11
|
-
- **CSV format documentation** — Formal specification of the 14-field state file format
|
|
12
|
-
- **Comma guard for workspace paths** — Commas in `workspace_project_dir` are replaced with underscores before CSV write
|
|
13
|
-
- **Open-source standard files** — Added CODE_OF_CONDUCT.md, CONTRIBUTING.md, SECURITY.md, and GitHub issue/PR templates
|
|
14
|
-
- **NPM Package** — `cc-context-stats` now available on npm for JavaScript/Node.js environments
|
|
15
|
-
|
|
16
|
-
### Dependencies
|
|
17
|
-
- Bumped prettier from 3.7.4 to 3.8.0
|
|
18
|
-
|
|
19
|
-
**Full Changelog**: https://github.com/luongnv89/cc-context-stats/compare/v1.5.1...v1.6.0
|
package/SECURITY.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# Security Policy
|
|
2
|
-
|
|
3
|
-
## Supported Versions
|
|
4
|
-
|
|
5
|
-
| Version | Supported |
|
|
6
|
-
| ------- | ------------------ |
|
|
7
|
-
| 1.5.x | :white_check_mark: |
|
|
8
|
-
| < 1.5 | :x: |
|
|
9
|
-
|
|
10
|
-
## Reporting a Vulnerability
|
|
11
|
-
|
|
12
|
-
We take security vulnerabilities seriously. If you discover a security issue, please report it responsibly.
|
|
13
|
-
|
|
14
|
-
### How to Report
|
|
15
|
-
|
|
16
|
-
1. **Do NOT** open a public GitHub issue for security vulnerabilities
|
|
17
|
-
2. Email your findings to luongnv89@gmail.com
|
|
18
|
-
3. Include detailed steps to reproduce the vulnerability
|
|
19
|
-
4. Allow up to 48 hours for an initial response
|
|
20
|
-
|
|
21
|
-
### What to Include
|
|
22
|
-
|
|
23
|
-
- Type of vulnerability
|
|
24
|
-
- Full paths of affected source files
|
|
25
|
-
- Location of the affected source code (tag/branch/commit or direct URL)
|
|
26
|
-
- Step-by-step instructions to reproduce
|
|
27
|
-
- Proof-of-concept or exploit code (if possible)
|
|
28
|
-
- Impact of the issue
|
|
29
|
-
|
|
30
|
-
### What to Expect
|
|
31
|
-
|
|
32
|
-
- Acknowledgment of your report within 48 hours
|
|
33
|
-
- Regular updates on our progress
|
|
34
|
-
- Credit in the security advisory (if desired)
|
|
35
|
-
- Notification when the issue is fixed
|
|
36
|
-
|
|
37
|
-
## Security Best Practices
|
|
38
|
-
|
|
39
|
-
When contributing to this project:
|
|
40
|
-
|
|
41
|
-
- Never commit secrets, API keys, or credentials
|
|
42
|
-
- Use environment variables for sensitive configuration
|
|
43
|
-
- Follow secure coding practices
|
|
44
|
-
- Report any security concerns immediately
|
package/TODOS.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# TODOs
|
|
2
|
-
|
|
3
|
-
Items identified from the HOLD SCOPE mega review (2026-03-12).
|
|
4
|
-
|
|
5
|
-
## P1 — High Priority
|
|
6
|
-
|
|
7
|
-
### ~~1. Cross-implementation parity test~~ ✅ Done
|
|
8
|
-
**What:** Add a CI integration test that feeds identical JSON to both Python (`statusline.py`) and Node.js (`statusline.js`) scripts and asserts they write identical CSV state lines and produce equivalent stdout.
|
|
9
|
-
**Why:** The two implementations share no code or schema contract. Drift has occurred before and will occur again. This catches it automatically.
|
|
10
|
-
**Effort:** S
|
|
11
|
-
**Depends on:** None
|
|
12
|
-
**Status:** Implemented in `tests/bash/test_parity.bats` with CI job in `.github/workflows/ci.yml`. Archived as `openspec/changes/archive/2026-03-12-cross-impl-parity-test/`.
|
|
13
|
-
|
|
14
|
-
### ~~2. Document CSV state file format + comma guard~~ ✅ Done
|
|
15
|
-
**What:** Create `docs/CSV_FORMAT.md` documenting all 14 fields with types and examples. Fix `docs/ARCHITECTURE.md` which incorrectly states "each line is a JSON record." Sanitize `workspace_project_dir` to strip/escape commas before CSV serialization (in both Python and Node.js).
|
|
16
|
-
**Why:** The CSV format is an implicit contract across 5 writer implementations with zero documentation. Commas in directory paths silently corrupt rows.
|
|
17
|
-
**Effort:** S
|
|
18
|
-
**Depends on:** None
|
|
19
|
-
**Status:** Created `docs/CSV_FORMAT.md`, fixed ARCHITECTURE.md JSON→CSV, added comma→underscore guard in Python (`state.py`, `statusline.py`), Node.js (`statusline.js`), and bash (`statusline-full.sh`). Parity test with comma fixture passes. Archived as `openspec/changes/archive/2026-03-12-csv-format-doc-comma-guard/`.
|
|
20
|
-
|
|
21
|
-
### ~~3. Stderr logging for critical error paths~~ ✅ Done
|
|
22
|
-
**What:** Replace `except OSError: pass` with `sys.stderr.write()` warnings in: `StateFile.append_entry()`, `Config._create_default()`, `Config._read_config()`. Add `UnicodeDecodeError` to config read exception handling. Apply equivalent changes in `statusline.js`.
|
|
23
|
-
**Why:** State write failures cause silent data loss — users see stale dashboards with no indication of why. Statusline output goes to stdout (consumed by Claude Code), so stderr is safe for diagnostics.
|
|
24
|
-
**Effort:** S
|
|
25
|
-
**Depends on:** None
|
|
26
|
-
**Status:** Added `[statusline] warning:` stderr messages to all critical data pipeline error handlers in `config.py`, `state.py`, `statusline.py`, and `statusline.js`. Added `UnicodeDecodeError` to config read exception handling in both Python files. Non-critical handlers (git info, file migration) left silent.
|
|
27
|
-
|
|
28
|
-
### ~~4. Core data pipeline unit tests~~ ✅ Done
|
|
29
|
-
**What:** Add test files covering: (1) `StateEntry.from_csv_line` ↔ `to_csv_line` round-trip, (2) `calculate_deltas` and `detect_spike`, (3) zone threshold logic in `render_summary`. Cover edge cases: empty data, single entry, negative deltas, boundary percentages (39%/40%/79%/80%).
|
|
30
|
-
**Why:** The primary user-facing feature (`context-stats` CLI) has zero unit tests on its core logic — CSV parsing, statistics, and zone detection are all untested.
|
|
31
|
-
**Effort:** M
|
|
32
|
-
**Depends on:** None
|
|
33
|
-
**Status:** Implemented in `tests/python/test_data_pipeline.py` with 51 tests across 6 classes: TestStateEntryRoundTrip (14), TestStateEntryProperties (3), TestCalculateDeltas (8), TestCalculateStats (6), TestDetectSpike (10), TestZoneThresholds (10). Covers CSV round-trip with old/new formats, comma sanitization, boundary spike detection (exact 15%/3x thresholds), and zone boundaries at 39/40% and 79/80%.
|
|
34
|
-
|
|
35
|
-
## P2 — Medium Priority
|
|
36
|
-
|
|
37
|
-
### ~~5. State file cap + rotate~~ ✅ Done
|
|
38
|
-
**What:** After `StateFile.append_entry()`, check line count. If >10,000 lines, truncate to the most recent 5,000. Apply in both Python and Node.js writers.
|
|
39
|
-
**Why:** State files are append-only with no rotation. `read_history()` loads entire files into memory. Heavy users could accumulate 50k+ lines across long sessions.
|
|
40
|
-
**Effort:** S
|
|
41
|
-
**Depends on:** None
|
|
42
|
-
**Status:** Added `_maybe_rotate()` to Python `StateFile` and `maybeRotateStateFile()` to Node.js `statusline.js`. Both use atomic temp-file + rename. Threshold: 10,000 lines, retain: 5,000 lines. Unit tests in `tests/python/test_state_rotation_validation.py` and `tests/node/rotation.test.js`.
|
|
43
|
-
|
|
44
|
-
### ~~6. Sanitize session_id input~~ ✅ Done
|
|
45
|
-
**What:** Reject session IDs containing `/`, `\`, or `..` at the CLI entry point (`parse_args`) and in `StateFile.__init__()`. Print a clear error message and exit.
|
|
46
|
-
**Why:** Defense-in-depth against path traversal via `context-stats ../../etc/passwd`. Claude Code generates safe UUIDs, but the CLI accepts arbitrary user input.
|
|
47
|
-
**Effort:** XS
|
|
48
|
-
**Depends on:** None
|
|
49
|
-
**Status:** Added `_validate_session_id()` helper in `state.py`, called in `StateFile.__init__()` and `parse_args()` in `context_stats.py`. Rejects `/`, `\`, `..`, and null bytes. Unit tests and CLI subprocess tests in `tests/python/test_state_rotation_validation.py`.
|
|
50
|
-
|
|
51
|
-
### ~~7. Node.js git command timeout~~ ✅ Done
|
|
52
|
-
**What:** Add `timeout: 5000` to both `execSync` calls in `statusline.js` `getGitInfo()`.
|
|
53
|
-
**Why:** Python's `get_git_info()` has `timeout=5`. Node.js has none — git hangs (network FS, large repo) would block the statusline process indefinitely.
|
|
54
|
-
**Effort:** XS
|
|
55
|
-
**Depends on:** None
|
|
56
|
-
**Status:** Added `timeout: 5000` to both `execSync` calls (`git rev-parse` and `git status`) in `getGitInfo()` in `scripts/statusline.js`.
|
|
57
|
-
|
|
58
|
-
### ~~8. Repo-level CLAUDE.md~~ ✅ Done
|
|
59
|
-
**What:** Create `CLAUDE.md` at repo root documenting: project purpose, dual-implementation rationale, CSV format contract, test running instructions (`pytest`, `npm test`, `bats`), key architectural decisions, and the 5-script statusline landscape.
|
|
60
|
-
**Why:** Helps AI assistants and new contributors understand the project quickly. Currently the only CLAUDE.md is the user's personal global one.
|
|
61
|
-
**Effort:** S
|
|
62
|
-
**Depends on:** TODO 2 (CSV format doc) for cross-reference
|
|
63
|
-
**Status:** Created `CLAUDE.md` at repo root with all required sections. Cross-references `docs/ARCHITECTURE.md`, `docs/DEVELOPMENT.md`, and `docs/CSV_FORMAT.md`.
|
|
64
|
-
|
|
65
|
-
## P3 — Low Priority
|
|
66
|
-
|
|
67
|
-
### ~~9. Add --version flag to context-stats CLI~~ ✅ Done
|
|
68
|
-
**What:** Add `--version` argument to `parse_args()` that prints `cc-context-stats {version}` and exits.
|
|
69
|
-
**Why:** Users can't determine installed version without running the full tool. The footer shows version but only on successful render.
|
|
70
|
-
**Effort:** XS
|
|
71
|
-
**Depends on:** None
|
|
72
|
-
**Status:** Added `--version` / `-V` flag to `parse_args()` in `context_stats.py`. Prints `cc-context-stats {__version__}` and exits. Updated help text and module docstring.
|