toks 0.1.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -0
  3. package/dist/cli.js +2008 -0
  4. package/package.json +41 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Luigi Acerbi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # toks
2
+
3
+ Count tokens in files, like `wc` for LLMs.
4
+
5
+ ## Installation
6
+
7
+ Requires Node.js 22+.
8
+
9
+ ```bash
10
+ npm install -g toks
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ # Count tokens in files
17
+ toks file1.txt file2.txt
18
+
19
+ # With line ranges
20
+ toks file.txt:1-100 # lines 1-100
21
+ toks file.txt:50 # line 50 only
22
+ toks file.txt:50- # line 50 to end
23
+ toks file.txt:-50 # first 50 lines
24
+
25
+ # From stdin
26
+ echo "hello world" | toks
27
+ cat file.txt | toks
28
+
29
+ # Change tokenizer encoding
30
+ toks --encoding cl100k_base file.txt
31
+ toks -e o200k_base file.txt
32
+ ```
33
+
34
+ ## Output
35
+
36
+ ```
37
+ 1234 file1.txt
38
+ 5678 file2.txt
39
+ 6912 total
40
+ ```
41
+
42
+ ## Options
43
+
44
+ | Flag | Description |
45
+ |------|-------------|
46
+ | `-e, --encoding <name>` | Tokenizer encoding (default: `o200k_base`) |
47
+ | `-h, --help` | Show help |
48
+ | `-v, --version` | Show version |
49
+
50
+ ## Supported Encodings
51
+
52
+ - `o200k_base` — GPT-4o, GPT-5, o1, o3, o4 (default)
53
+ - `cl100k_base` — GPT-4, GPT-3.5-turbo
54
+ - `p50k_base` — Codex models
55
+ - `r50k_base` — GPT-3 (davinci)
56
+
57
+ ## Design
58
+
59
+ See [DESIGN.md](DESIGN.md) for implementation details.
60
+
61
+ ## License
62
+
63
+ MIT
64
+
65
+ ---
66
+
67
+ Built with [Claude Code](https://claude.ai/code) (Claude Opus 4.5).