feat: display savings in tokens instead of KB/MB (v1.3.1)#15
Merged
Conversation
Fix/build progress patterns
Add 3 missing progress line detection patterns to _is_progress_line(): - Yarn Berry (v2+) step progress (Resolution/Fetch/Link step) - pnpm resolution progress counter (Progress: resolved N, ...) - pnpm content-addressable store messages (packages are hard linked) Includes 2 new unit tests verifying these patterns are correctly stripped.
- Yarn berry: match ➤ YN0000: ┌ prefix before Resolution/Fetch/Link step - pnpm: handle both Packages (capital P) and packages (lowercase) - Tests now use actual output format from yarn 4.x and pnpm
- Tighten yarn berry pattern to require YN prefix, preventing false positives on error lines containing step keywords - Add precision test verifying errors mentioning "Resolution step" or "Fetch step" are never stripped from output
Add yarn berry and pnpm progress line patterns to BuildOutputProcessor
The actual source file is src/platforms.py (plural) but three references used the singular form, causing a "Source file missing" warning during installation.
Fix platform.py → platforms.py filename references
…tterns Commands like `git -C <path> status`, `kubectl -n <ns> get pods`, and `docker --context <ctx> ps` were not matched by hook_patterns because the regex expected the subcommand to immediately follow the command name. This meant AI CLI tools that avoid `cd` (using `git -C` instead) would never get their git output compressed — a significant gap in practice. Changes: - git: allow -C, --no-pager, -c, --git-dir, --work-tree before subcommand - kubectl: allow -n, --namespace, --context, --kubeconfig, -A before subcommand - docker: allow --context, -H, --host before subcommand - Refactor process() routing to use _get_subcmd() helper (DRY) - Add comprehensive tests for all three processors
…k-patterns fix: support global options in hook patterns (git -C, kubectl -n, etc.)
Create LICENSE
- Single source of truth for version in src/__init__.py (v1.0.1) - GitHub API update check at session start (fail-open, 3s timeout) - CLI command: token-saver version|stats|update - bin/token-saver executable + Windows .cmd wrapper - Installer stamps version into plugin.json/gemini-extension.json - install_cli/uninstall_cli for PATH integration (~/.local/bin)
Bump version to 1.0.1. Update all GitHub URLs, descriptions, and comments to use token-saver consistently.
The project was renamed from "token-saving" to "token-saver" with the introduction of the CLI (v1.0.1). The installer now detects and removes old "token-saving" directories and hooks before installing, so nothing is left behind under the former name.
- bin/token-saver: find src/ in plugin install dirs when repo is deleted - cli.py: git merge --ff-only instead of checkout (no detached HEAD) - cli.py: detect installed targets instead of hardcoding --target both - cli.py: tarball overlay only known dirs (preserve .git, local config) - cli.py: clear HTTP 404 message when no GitHub releases exist - version_check.py: guard empty tag_name, reduce timeout to 2s - install.py: run legacy migration on uninstall too - Add tests/test_installers.py (15 tests: migration, stamping, CLI) - Add edge case tests for empty/None version strings
Install core files to ~/.token-saver/ so the CLI and update command work independently of which platform target was chosen. This ensures token-saver continues to function after the repo/zip is deleted. - Add install_core()/uninstall_core() and CORE_FILES to installers/common.py - Update bin/token-saver to search repo -> ~/.token-saver/ -> plugin dirs - Make _detect_installed_targets() Windows-aware with %APPDATA% paths - Update install.py to call install_core() and uninstall_core() - Update README with CLI docs, project structure, and test counts - Add 3 new tests for core install/uninstall behavior
- Fix uninstall_core leaving empty parent dirs (os.walk stale dirnames) - Fix _parse_version crash on pre-release tags (e.g. "1.0.0-beta") - Fix migrate_from_legacy crash on malformed settings.json hooks - Reduce version check HTTP timeout from 2s to 1s for safer hook margin - Add error handling around version comparison in cmd_update - Add tests for pre-release parsing, dir cleanup, malformed settings
- Quote hook command paths for directories with spaces (Claude + Gemini) - Fix install_files/install_cli overwriting through existing symlinks when switching from --link to copy mode (corrupted source files) - Try both v-prefixed and bare tag names in tarball download URL - Use 10s HTTP timeout for interactive CLI update (vs 1s for hooks) - Add test for symlink-to-copy transition safety
- Add data_dir() to src/__init__.py as single source of truth for the data directory path (%APPDATA%/token-saver on Windows, ~/.token-saver on Unix) - Update config.py, tracker.py, hook_pretool.py, and wrap.py to use data_dir() instead of hardcoding ~/.token-saver - Fix hook_pretool.py using python3 on Windows where only python exists - Fix test_default_values failing when TOKEN_SAVER_DEBUG is set in env
feat: add version management, update notification and token-saver CLI
…ntation Expand processor coverage with 20+ new command handlers: - Git: blame, cherry-pick, rebase, merge, stash list, diff --name-only/--name-status, conflict markers - Docker: inspect, stats, compose up/down/build, Dead container status - Kubectl: apply, delete, create with multi-container ready detection fix - Terraform: init, output, state list/show with proper subcommand extraction - Network: httpie (http/https), JSON response compression - Test: dotnet test, swift test, mix test, pnpm routing, traceback truncation - Lint: shellcheck, hadolint, biome parsers, clippy false positive fix - Search: fd/fdfind grouping - File listing: exa/eza support Add engine generic fallback when specialized processor doesn't compress enough. Externalize 9 new config thresholds. Add .gitignore, remove .DS_Store from tracking. Add docs/processors/ with per-processor documentation. Update README with doc links. 336 tests (was 267), all passing.
Combine if/elif branches (SIM114), fix line length (E501), rename ambiguous variable (E741), collapse nested ifs (SIM102), replace 0.0.0.0 with 127.0.0.1 in tests (S104).
Feat/enhanced processors
When token-saver update runs from ~/.token-saver/ (tarball mode), install_core copies files from ~/.token-saver/ to ~/.token-saver/. The old code deleted dst before copying, but src and dst were the same file, causing FileNotFoundError on the subsequent copy. Uses realpath (symlinks) + normcase (Windows case-insensitivity) for robust cross-platform same-file detection.
fix: prevent self-delete during core install when src == dst
Main to Production
3 new processors (15 → 18): - gh: compress gh pr/issue/run list/view/diff/checks output - db_query: compress psql/mysql/sqlite3 table results (head+tail) - cloud_cli: compress aws/gcloud/az JSON/table/text output Audit fixes on existing processors: - git: add remote subcommand handler, typechange status prefix - env: add set to hook_patterns - system_info: fix hook pattern to match bare df/du/wc - file_listing/file_content: simplify can_handle regex Tests: 336 → 372, ruff lint clean.
feat: add gh, db_query, cloud_cli processors + audit fixes (v1.2.0)
Replace byte-based display (KB/MB) with token-based display using a configurable chars_per_token ratio (default: 4). The DB still stores character counts; conversion happens at display time so existing data remains valid.
ppgranger
added a commit
that referenced
this pull request
Feb 21, 2026
feat: display savings in tokens instead of KB/MB (v1.3.1)
ppgranger
added a commit
that referenced
this pull request
Mar 10, 2026
feat: display savings in tokens instead of KB/MB (v1.3.1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Token-Saver previously displayed savings in KB/MB based on raw character counts, which didn't reflect the metric that actually matters to LLM users. Savings are now displayed in tokens (estimated at ~4 characters per token), giving a direct view of the real savings on the context window.
_format_bytes()with_format_tokens()and_chars_to_tokens()intracker.pyandstats.pywrap.pynow displays tokensaudit_compression.py) reports in tokenschars_per_tokenratio (default: 4) viaconfig.jsonorTOKEN_SAVER_CHARS_PER_TOKEN.claude/to.gitignoreChanged files
src/config.pychars_per_tokensettingsrc/tracker.py_format_bytes->_format_tokens+_chars_to_tokenssrc/stats.pyclaude/wrap.pyaudit_compression.pytests/test_tracker.pyREADME.mdsrc/__init__.pyBefore / After
Test plan
wrap.py --dry-run)chars_per_tokenvia env var