cc-context-stats 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/context-stats.md +17 -0
- package/.claude/settings.local.json +85 -0
- package/.editorconfig +60 -0
- package/.eslintrc.json +35 -0
- package/.github/dependabot.yml +44 -0
- package/.github/workflows/ci.yml +255 -0
- package/.github/workflows/release.yml +149 -0
- package/.pre-commit-config.yaml +74 -0
- package/.prettierrc +33 -0
- package/.shellcheckrc +10 -0
- package/CHANGELOG.md +100 -0
- package/CONTRIBUTING.md +240 -0
- package/PUBLISHING_GUIDE.md +69 -0
- package/README.md +179 -0
- package/config/settings-example.json +7 -0
- package/config/settings-node.json +7 -0
- package/config/settings-python.json +7 -0
- package/docs/configuration.md +83 -0
- package/docs/context-stats.md +132 -0
- package/docs/installation.md +195 -0
- package/docs/scripts.md +116 -0
- package/docs/troubleshooting.md +189 -0
- 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/install +344 -0
- package/install.sh +272 -0
- package/jest.config.js +11 -0
- package/npm-publish.sh +33 -0
- package/package.json +36 -0
- package/publish.sh +24 -0
- package/pyproject.toml +113 -0
- package/requirements-dev.txt +12 -0
- package/scripts/context-stats.sh +970 -0
- package/scripts/statusline-full.sh +241 -0
- package/scripts/statusline-git.sh +32 -0
- package/scripts/statusline-minimal.sh +11 -0
- package/scripts/statusline.js +350 -0
- package/scripts/statusline.py +312 -0
- package/show_raw_claude_code_api.js +11 -0
- package/src/claude_statusline/__init__.py +11 -0
- package/src/claude_statusline/__main__.py +6 -0
- package/src/claude_statusline/cli/__init__.py +1 -0
- package/src/claude_statusline/cli/context_stats.py +379 -0
- package/src/claude_statusline/cli/statusline.py +172 -0
- package/src/claude_statusline/core/__init__.py +1 -0
- package/src/claude_statusline/core/colors.py +55 -0
- package/src/claude_statusline/core/config.py +98 -0
- package/src/claude_statusline/core/git.py +67 -0
- package/src/claude_statusline/core/state.py +266 -0
- package/src/claude_statusline/formatters/__init__.py +1 -0
- package/src/claude_statusline/formatters/time.py +50 -0
- package/src/claude_statusline/formatters/tokens.py +70 -0
- package/src/claude_statusline/graphs/__init__.py +1 -0
- package/src/claude_statusline/graphs/renderer.py +346 -0
- package/src/claude_statusline/graphs/statistics.py +58 -0
- package/tests/bash/test_install.bats +29 -0
- package/tests/bash/test_statusline_full.bats +109 -0
- package/tests/bash/test_statusline_git.bats +42 -0
- package/tests/bash/test_statusline_minimal.bats +37 -0
- package/tests/fixtures/json/high_usage.json +17 -0
- package/tests/fixtures/json/low_usage.json +17 -0
- package/tests/fixtures/json/medium_usage.json +17 -0
- package/tests/fixtures/json/valid_full.json +30 -0
- package/tests/fixtures/json/valid_minimal.json +9 -0
- package/tests/node/statusline.test.js +199 -0
- package/tests/python/conftest.py +84 -0
- package/tests/python/test_statusline.py +154 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Pre-commit hooks for claude-statusline project
|
|
2
|
+
# Install: pip install pre-commit && pre-commit install
|
|
3
|
+
# Run all: pre-commit run --all-files
|
|
4
|
+
|
|
5
|
+
default_language_version:
|
|
6
|
+
python: python3
|
|
7
|
+
|
|
8
|
+
repos:
|
|
9
|
+
# General file checks
|
|
10
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
11
|
+
rev: v4.5.0
|
|
12
|
+
hooks:
|
|
13
|
+
- id: check-yaml
|
|
14
|
+
- id: check-json
|
|
15
|
+
- id: check-toml
|
|
16
|
+
- id: end-of-file-fixer
|
|
17
|
+
- id: trailing-whitespace
|
|
18
|
+
- id: mixed-line-ending
|
|
19
|
+
args: ['--fix=lf']
|
|
20
|
+
- id: check-executables-have-shebangs
|
|
21
|
+
- id: check-shebang-scripts-are-executable
|
|
22
|
+
- id: detect-private-key
|
|
23
|
+
- id: check-merge-conflict
|
|
24
|
+
- id: check-added-large-files
|
|
25
|
+
args: ['--maxkb=500']
|
|
26
|
+
|
|
27
|
+
# ShellCheck for bash scripts
|
|
28
|
+
- repo: https://github.com/shellcheck-py/shellcheck-py
|
|
29
|
+
rev: v0.9.0.6
|
|
30
|
+
hooks:
|
|
31
|
+
- id: shellcheck
|
|
32
|
+
args: ['--severity=warning']
|
|
33
|
+
files: \.(sh|bash)$
|
|
34
|
+
|
|
35
|
+
# Python: Ruff linter and formatter
|
|
36
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
37
|
+
rev: v0.1.14
|
|
38
|
+
hooks:
|
|
39
|
+
- id: ruff
|
|
40
|
+
args: ['--fix']
|
|
41
|
+
files: \.py$
|
|
42
|
+
- id: ruff-format
|
|
43
|
+
files: \.py$
|
|
44
|
+
|
|
45
|
+
# JavaScript: ESLint
|
|
46
|
+
- repo: https://github.com/pre-commit/mirrors-eslint
|
|
47
|
+
rev: v8.56.0
|
|
48
|
+
hooks:
|
|
49
|
+
- id: eslint
|
|
50
|
+
files: \.js$
|
|
51
|
+
types: [javascript]
|
|
52
|
+
additional_dependencies:
|
|
53
|
+
- eslint@8.56.0
|
|
54
|
+
|
|
55
|
+
# Prettier for JS, JSON, MD
|
|
56
|
+
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
57
|
+
rev: v4.0.0-alpha.8
|
|
58
|
+
hooks:
|
|
59
|
+
- id: prettier
|
|
60
|
+
types_or: [javascript, json, markdown]
|
|
61
|
+
additional_dependencies:
|
|
62
|
+
- prettier@3.2.5
|
|
63
|
+
|
|
64
|
+
# Markdown lint
|
|
65
|
+
- repo: https://github.com/igorshubovych/markdownlint-cli
|
|
66
|
+
rev: v0.39.0
|
|
67
|
+
hooks:
|
|
68
|
+
- id: markdownlint
|
|
69
|
+
args: ['--fix', '--disable', 'MD013', 'MD024', 'MD033', 'MD040', 'MD041', '--']
|
|
70
|
+
|
|
71
|
+
ci:
|
|
72
|
+
autofix_prs: true
|
|
73
|
+
autofix_commit_msg: 'style: auto-fix pre-commit issues'
|
|
74
|
+
autoupdate_schedule: monthly
|
package/.prettierrc
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"printWidth": 100,
|
|
3
|
+
"tabWidth": 4,
|
|
4
|
+
"useTabs": false,
|
|
5
|
+
"semi": true,
|
|
6
|
+
"singleQuote": true,
|
|
7
|
+
"quoteProps": "as-needed",
|
|
8
|
+
"trailingComma": "es5",
|
|
9
|
+
"bracketSpacing": true,
|
|
10
|
+
"arrowParens": "avoid",
|
|
11
|
+
"endOfLine": "lf",
|
|
12
|
+
"overrides": [
|
|
13
|
+
{
|
|
14
|
+
"files": "*.json",
|
|
15
|
+
"options": {
|
|
16
|
+
"tabWidth": 2
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"files": "*.md",
|
|
21
|
+
"options": {
|
|
22
|
+
"tabWidth": 2,
|
|
23
|
+
"proseWrap": "preserve"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"files": "*.{yml,yaml}",
|
|
28
|
+
"options": {
|
|
29
|
+
"tabWidth": 2
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
package/.shellcheckrc
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
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.2.0] - 2025-01-08
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Context Zones** - Status indicator based on context usage:
|
|
15
|
+
- 🟢 Smart Zone (< 40%): "You are in the smart zone"
|
|
16
|
+
- 🟡 Dumb Zone (40-80%): "You are in the dumb zone - Dex Horthy says so"
|
|
17
|
+
- 🔴 Wrap Up Zone (> 80%): "Better to wrap up and start a new session"
|
|
18
|
+
- **Project name display** - Header now shows "Context Stats (project-name • session-id)"
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **Watch mode enabled by default** - `context-stats` now runs in live monitoring mode (2s refresh)
|
|
23
|
+
- **Delta graph by default** - Shows "Context Growth Per Interaction" instead of both graphs
|
|
24
|
+
- Added `--no-watch` flag to show graphs once and exit
|
|
25
|
+
- Simplified installer - no script selection, auto-overwrite existing files
|
|
26
|
+
- Renamed graph labels to focus on context (e.g., "Context Usage Over Time")
|
|
27
|
+
- Cleaned up session summary - removed clutter, highlighted status
|
|
28
|
+
|
|
29
|
+
## [1.1.0] - 2025-01-08
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- **BREAKING**: Renamed package from `cc-statusline` to `cc-context-stats`
|
|
34
|
+
- **BREAKING**: Renamed `token-graph` CLI command to `context-stats`
|
|
35
|
+
- Pivoted project focus to real-time token monitoring and context tracking
|
|
36
|
+
- Updated tagline: "Never run out of context unexpectedly"
|
|
37
|
+
|
|
38
|
+
### Migration
|
|
39
|
+
|
|
40
|
+
If upgrading from `cc-statusline`:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip uninstall cc-statusline
|
|
44
|
+
pip install cc-context-stats
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The `claude-statusline` command still works. Replace `token-graph` with `context-stats`.
|
|
48
|
+
|
|
49
|
+
## [1.0.2] - 2025-01-08
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- Fixed remaining context showing negative values in context-stats by using `current_used_tokens` instead of cumulative `total_input_tokens + total_output_tokens`
|
|
54
|
+
- Fixed ANSI escape codes not rendering properly in watch mode by using `sys.stdout.write()` instead of `print()` for cursor control sequences
|
|
55
|
+
- Fixed color codes in summary statistics using ColorManager instead of raw ANSI constants
|
|
56
|
+
|
|
57
|
+
## [1.0.1] - 2025-01-07
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
|
|
61
|
+
- pip/uv installable Python package (`cc-statusline` on PyPI)
|
|
62
|
+
- `context_window_size` field to state file for tracking remaining context
|
|
63
|
+
- Remaining context display in context-stats summary
|
|
64
|
+
|
|
65
|
+
### Fixed
|
|
66
|
+
|
|
67
|
+
- Restored executable permissions on script files
|
|
68
|
+
- Fixed stdin detection in pipe mode using INTERACTIVE flag
|
|
69
|
+
|
|
70
|
+
### Changed
|
|
71
|
+
|
|
72
|
+
- Cleaned up unused `show_io_tokens` option
|
|
73
|
+
- Fixed shellcheck warnings in shell scripts
|
|
74
|
+
|
|
75
|
+
## [1.0.0] - 2025-01-06
|
|
76
|
+
|
|
77
|
+
### Added
|
|
78
|
+
|
|
79
|
+
- Comprehensive test suite with Bats (Bash), pytest (Python), and Jest (Node.js)
|
|
80
|
+
- GitHub Actions CI/CD pipeline with multi-platform testing
|
|
81
|
+
- Code quality tools: ShellCheck, Ruff, ESLint, Prettier
|
|
82
|
+
- Pre-commit hooks for automated code quality checks
|
|
83
|
+
- EditorConfig for consistent formatting across editors
|
|
84
|
+
- CONTRIBUTING.md with development setup instructions
|
|
85
|
+
- Dependabot configuration for automated dependency updates
|
|
86
|
+
- Release automation workflow
|
|
87
|
+
- Full-featured status line script (`statusline-full.sh`)
|
|
88
|
+
- Git-aware status line script (`statusline-git.sh`)
|
|
89
|
+
- Minimal status line script (`statusline-minimal.sh`)
|
|
90
|
+
- Cross-platform Python implementation (`statusline.py`)
|
|
91
|
+
- Cross-platform Node.js implementation (`statusline.js`)
|
|
92
|
+
- Interactive installer script (`install.sh`)
|
|
93
|
+
- Configuration examples for Claude Code
|
|
94
|
+
- Autocompact (AC) buffer indicator
|
|
95
|
+
- Context window usage with color-coded percentages
|
|
96
|
+
- Git branch and uncommitted changes display
|
|
97
|
+
|
|
98
|
+
## [0.x] - Pre-release
|
|
99
|
+
|
|
100
|
+
Initial development versions with basic status line functionality.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
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!
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# npm Package Publishing Guide
|
|
2
|
+
|
|
3
|
+
## Step 1: Access Your npm Account with Recovery Code
|
|
4
|
+
|
|
5
|
+
1. Go to https://www.npmjs.com/login
|
|
6
|
+
2. Enter your credentials (luong.nguyen + password)
|
|
7
|
+
3. When prompted for 2FA, click "Use a recovery code or request a reset"
|
|
8
|
+
4. Enter one of your 8-character recovery codes
|
|
9
|
+
5. You should now be logged into your npm account
|
|
10
|
+
|
|
11
|
+
## Step 2: Set Up Microsoft Authenticator
|
|
12
|
+
|
|
13
|
+
1. Once logged in, click your profile picture (top right)
|
|
14
|
+
2. Go to "Account"
|
|
15
|
+
3. Under "Two-Factor Authentication", click "Modify 2FA"
|
|
16
|
+
4. Choose to add an "Authenticator app"
|
|
17
|
+
5. npm will show you a QR code
|
|
18
|
+
|
|
19
|
+
### In Microsoft Authenticator:
|
|
20
|
+
|
|
21
|
+
1. Open Microsoft Authenticator app
|
|
22
|
+
2. Tap the `+` button (top right)
|
|
23
|
+
3. Choose "Personal account" or "Work/school account"
|
|
24
|
+
4. Tap "Scan QR code"
|
|
25
|
+
5. Scan the QR code from npm website
|
|
26
|
+
6. The app will now show "npm" with a 6-digit code
|
|
27
|
+
|
|
28
|
+
## Step 3: Publish Your Package
|
|
29
|
+
|
|
30
|
+
1. Get the current 6-digit code from Microsoft Authenticator
|
|
31
|
+
2. Run this command in your terminal:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cd /Users/montimage/buildspace/luongnv89/cc-context-stats
|
|
35
|
+
./publish.sh YOUR_6_DIGIT_CODE
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
For example:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
./publish.sh 123456
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Step 4: Verify Publication
|
|
45
|
+
|
|
46
|
+
After successful publishing, you can verify with:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm view cc-context-stats
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Important Notes:
|
|
53
|
+
|
|
54
|
+
- Recovery codes are single-use - once you use one, it's gone
|
|
55
|
+
- Keep your remaining recovery codes safe
|
|
56
|
+
- Microsoft Authenticator will provide new codes every 30 seconds
|
|
57
|
+
- The package will be published as "cc-context-stats@1.3.0"
|
|
58
|
+
|
|
59
|
+
## Troubleshooting:
|
|
60
|
+
|
|
61
|
+
If you get "Invalid OTP" error:
|
|
62
|
+
|
|
63
|
+
- Wait for a new code to generate in Microsoft Authenticator (codes change every 30 seconds)
|
|
64
|
+
- Make sure you're typing the code correctly
|
|
65
|
+
|
|
66
|
+
If you can't log into the website:
|
|
67
|
+
|
|
68
|
+
- Try a different recovery code
|
|
69
|
+
- Make sure you're typing the 8-character code correctly (no spaces)
|
package/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Claude Code Context Stats
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/cc-context-stats/)
|
|
4
|
+
[](https://pypi.org/project/cc-context-stats/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
**Never run out of context unexpectedly** - monitor your session context in real-time.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Why Context Stats?
|
|
12
|
+
|
|
13
|
+
When working with Claude Code on complex tasks, you can easily burn through your context window without realizing it. As your context fills up, Claude's performance degrades - this is what Dex Horthy calls the "dumb zone". Context Stats helps you:
|
|
14
|
+
|
|
15
|
+
- **Know your zone** - See if you're in the Smart Zone, Dumb Zone, or Wrap Up Zone
|
|
16
|
+
- **Track context usage** - Real-time monitoring with live-updating graphs
|
|
17
|
+
- **Get early warnings** - Color-coded status alerts you before performance degrades
|
|
18
|
+
- **Make informed decisions** - Know when to start a fresh session
|
|
19
|
+
|
|
20
|
+
## Context Zones
|
|
21
|
+
|
|
22
|
+
| Zone | Context Used | Status | What It Means |
|
|
23
|
+
| ------------------- | ------------ | -------- | --------------------------------------------- |
|
|
24
|
+
| 🟢 **Smart Zone** | < 40% | Optimal | Claude is performing at its best |
|
|
25
|
+
| 🟡 **Dumb Zone** | 40-80% | Degraded | Context getting full, Claude may miss details |
|
|
26
|
+
| 🔴 **Wrap Up Zone** | > 80% | Critical | Better to wrap up and start a new session |
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install cc-context-stats
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or with uv:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
uv pip install cc-context-stats
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
### Real-Time Monitoring
|
|
43
|
+
|
|
44
|
+
Get your session ID from the status line (the last part after the pipe `|`), then run:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
context-stats <session_id>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For example:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
context-stats abc123def-456-789
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This opens a live dashboard that refreshes every 2 seconds, showing:
|
|
57
|
+
|
|
58
|
+
- Your current project and session
|
|
59
|
+
- Context growth per interaction graph
|
|
60
|
+
- Your current zone status
|
|
61
|
+
- Remaining context percentage
|
|
62
|
+
|
|
63
|
+
Press `Ctrl+C` to exit.
|
|
64
|
+
|
|
65
|
+
### Status Line Integration
|
|
66
|
+
|
|
67
|
+
Add to `~/.claude/settings.json`:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"statusLine": {
|
|
72
|
+
"type": "command",
|
|
73
|
+
"command": "claude-statusline"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Restart Claude Code to see real-time token stats in your status bar.
|
|
79
|
+
|
|
80
|
+
## Context Stats CLI
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
context-stats # Live monitoring (default)
|
|
84
|
+
context-stats -w 5 # Custom refresh interval (5 seconds)
|
|
85
|
+
context-stats --no-watch # Show once and exit
|
|
86
|
+
context-stats --type cumulative # Show cumulative context usage
|
|
87
|
+
context-stats --type both # Show both graphs
|
|
88
|
+
context-stats --type all # Show all graphs including I/O
|
|
89
|
+
context-stats <session_id> # View specific session
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Output Example
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
Context Stats (my-project • abc123def)
|
|
96
|
+
|
|
97
|
+
Context Growth Per Interaction
|
|
98
|
+
Max: 4,787 Min: 0 Points: 254
|
|
99
|
+
...graph...
|
|
100
|
+
|
|
101
|
+
Session Summary
|
|
102
|
+
----------------------------------------------------------------------------
|
|
103
|
+
Context Remaining: 43,038/200,000 (21%)
|
|
104
|
+
>>> DUMB ZONE <<< (You are in the dumb zone - Dex Horthy says so)
|
|
105
|
+
|
|
106
|
+
Last Growth: +2,500
|
|
107
|
+
Input Tokens: 1,234
|
|
108
|
+
Output Tokens: 567
|
|
109
|
+
Lines Changed: +45 / -12
|
|
110
|
+
Total Cost: $0.1234
|
|
111
|
+
Model: claude-sonnet-4-20250514
|
|
112
|
+
Session Duration: 2h 29m
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Status Line
|
|
116
|
+
|
|
117
|
+

|
|
118
|
+
|
|
119
|
+
The status line shows at-a-glance metrics in your Claude Code interface:
|
|
120
|
+
|
|
121
|
+
| Component | Description |
|
|
122
|
+
| --------- | ----------------------------------------- |
|
|
123
|
+
| Model | Current Claude model |
|
|
124
|
+
| Context | Tokens used / remaining with color coding |
|
|
125
|
+
| Delta | Token change since last update |
|
|
126
|
+
| Git | Branch name and uncommitted changes |
|
|
127
|
+
| Session | Session ID for correlation |
|
|
128
|
+
|
|
129
|
+
## Configuration
|
|
130
|
+
|
|
131
|
+
Create `~/.claude/statusline.conf`:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
token_detail=true # Show exact token counts (vs abbreviated like "12.5k")
|
|
135
|
+
show_delta=true # Show token delta in status line
|
|
136
|
+
show_session=true # Show session ID
|
|
137
|
+
autocompact=true # Show autocompact buffer indicator
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Shell Script Installation
|
|
141
|
+
|
|
142
|
+
For users who prefer shell scripts:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
curl -fsSL https://raw.githubusercontent.com/luongnv89/cc-context-stats/main/install.sh | bash
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## How It Works
|
|
149
|
+
|
|
150
|
+
Context Stats hooks into Claude Code's state files to track token usage across your sessions. Data is stored locally in `~/.claude/statusline/` and never sent anywhere.
|
|
151
|
+
|
|
152
|
+
## Documentation
|
|
153
|
+
|
|
154
|
+
- [Context Stats Guide](docs/context-stats.md) - Detailed usage guide
|
|
155
|
+
- [Configuration Options](docs/configuration.md) - All settings explained
|
|
156
|
+
- [Installation Guide](docs/installation.md) - Platform-specific setup
|
|
157
|
+
- [Troubleshooting](docs/troubleshooting.md) - Common issues
|
|
158
|
+
- [Changelog](CHANGELOG.md) - Version history
|
|
159
|
+
|
|
160
|
+
## Migration from cc-statusline
|
|
161
|
+
|
|
162
|
+
If you were using the previous `cc-statusline` package:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
pip uninstall cc-statusline
|
|
166
|
+
pip install cc-context-stats
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The `claude-statusline` command still works. The main change is `token-graph` is now `context-stats`.
|
|
170
|
+
|
|
171
|
+
## Related
|
|
172
|
+
|
|
173
|
+
- [Claude Code Documentation](https://docs.anthropic.com/en/docs/claude-code)
|
|
174
|
+
- [Dex Horthy on Context Windows](https://twitter.com/daborhty) - The "dumb zone" concept
|
|
175
|
+
- [Blog: Building this project](https://medium.com/@luongnv89/closing-the-gap-between-mvp-and-production-with-feature-dev-an-official-plugin-from-anthropic-444e2f00a0ad)
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
MIT
|