feat(cli): add --stats flag to show token savings (#51)

* feat(cli): add --stats flag to show token efficiency

- Add --stats boolean flag to display token count comparison
- Calculate approximate tokens using char length / 4 heuristic
- Show JSON vs TOON token counts with savings percentage
- Opt-in feature, default behavior unchanged

* feat: use tokenx for more accurate estimates

---------

Co-authored-by: Johann Schopplich <mail@johannschopplich.com>
This commit is contained in:
SangheeSon
2025-11-01 08:35:54 +09:00
committed by GitHub
parent af068f995d
commit 2b882870f7
4 changed files with 35 additions and 0 deletions

9
pnpm-lock.yaml generated
View File

@@ -95,6 +95,10 @@ importers:
consola:
specifier: ^3.4.2
version: 3.4.2
devDependencies:
tokenx:
specifier: ^1.2.0
version: 1.2.0
packages:
@@ -2200,6 +2204,9 @@ packages:
resolution: {integrity: sha512-41wJyvKep3yT2tyPqX/4blcfybknGB4D+oETKLs7Q76UiPqRpUJK3hr1nxelyYO0PHKVzJwlu0aCeEAsGI6rpw==}
engines: {node: '>=20'}
tokenx@1.2.0:
resolution: {integrity: sha512-x4bRrL23b22H+EqW2pbhIkkt3ouj27ZGmAS1QoIqpocEO4m0sAl2H1M4L1UzKqleikY4U9lz/TbEw4jeG8tm2A==}
toml-eslint-parser@0.10.0:
resolution: {integrity: sha512-khrZo4buq4qVmsGzS5yQjKe/WsFvV8fGfOjDQN0q4iy9FjRfPWRgTFrU8u1R2iu/SfWLhY9WnCi4Jhdrcbtg+g==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -4706,6 +4713,8 @@ snapshots:
'@sindresorhus/base62': 1.0.0
reserved-identifiers: 1.2.0
tokenx@1.2.0: {}
toml-eslint-parser@0.10.0:
dependencies:
eslint-visitor-keys: 3.4.3