feat(cli): Add token counts for CLI outputs #39
Merged
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.
This PR adds support for token counting and CLI display using the
tiktoken
library. Provides token counts for individual files and the entire repository, which is useful for working within context limits.Currently set to use
cl100k_base
as the encoder (used for GPT-4, etc.). Could add an option for customizing which encoder to use, but felt like thecl100k_base
is "good enough" (getting >95% token count accuracy has very limited value IMO) and limits option scope.Decided on the
tiktoken
library based on high-level benchmarks, higher NPM weekly downloads, and fairly decent commit activity.Changes
tiktoken
as a dependencysrc/core/packager.ts
to include token countingsrc/cli/cliOutput.ts
to display token information in the summary and top files listsrc/cli/index.ts
to use the new token informationtests/core/tokenCounter.test.ts
for token counting functionalityREADME.md