tokler-cli 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.
- package/LICENSE +21 -0
- package/README.md +46 -0
- package/bin/tokler.js +52 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agnel Nieves
|
|
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,46 @@
|
|
|
1
|
+
# tokler-cli
|
|
2
|
+
|
|
3
|
+
Privacy-first AI token analyzer CLI. Count, audit, and optimize prompt and MCP token costs across OpenAI, Anthropic, and Gemini. Everything runs fully local: no telemetry, no uploads, nothing leaves your machine.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npx tokler-cli --help
|
|
9
|
+
# or
|
|
10
|
+
bunx tokler-cli --help
|
|
11
|
+
# or install globally (installs the `tokler` command)
|
|
12
|
+
npm i -g tokler-cli
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The `tokler-cli` package is a thin launcher exposing the `tokler` command. The actual binary ships in a per-platform package (`tokler-darwin-arm64`, `tokler-darwin-x64`) pulled in automatically as an optional dependency.
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
| Command | What it does |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `tokler count <FILE>` | Count tokens in a file or stdin. `--all` compares providers. |
|
|
22
|
+
| `tokler compare <FILE>` | Side-by-side token counts across providers. |
|
|
23
|
+
| `tokler viz <FILE>` | Visualize token boundaries (count plus estimate band for Claude). |
|
|
24
|
+
| `tokler audit <FILE>` | Run the rules engine: ranked findings with savings estimates. |
|
|
25
|
+
| `tokler redact <FILE>` | Strip secrets from input. Runs before anything else. |
|
|
26
|
+
| `tokler cost <FILE>` | Estimate provider cost for an input. |
|
|
27
|
+
| `tokler mcp <CONFIG>` | Analyze an MCP config: tool-definition token cost and CLI-swap savings. |
|
|
28
|
+
| `tokler drift <FILE>` | Compare the same input across tokenizer versions (encoding drift). |
|
|
29
|
+
| `tokler scan` | Discover your local agent configs (Claude, Cursor, Codex, VS Code, Zed, and more) and report MCP token costs, CLI-swap savings, instruction-file weight, and shell secret hygiene. Read-only. |
|
|
30
|
+
|
|
31
|
+
Use `-` as the file argument to read stdin, and `--json` for machine-readable output where supported. Run `tokler <command> --help` for full flags.
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
echo "hello world" | tokler count -
|
|
35
|
+
tokler audit prompt.md
|
|
36
|
+
tokler mcp ~/.config/claude/claude_desktop_config.json
|
|
37
|
+
tokler scan
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Supported platforms
|
|
41
|
+
|
|
42
|
+
macOS arm64 (Apple Silicon) and macOS x64 (Intel). Linux and Windows builds are coming.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
MIT
|
package/bin/tokler.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require("node:child_process");
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
const PLATFORMS = {
|
|
9
|
+
"darwin-arm64": "tokler-darwin-arm64",
|
|
10
|
+
"darwin-x64": "tokler-darwin-x64",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const key = `${process.platform}-${process.arch}`;
|
|
14
|
+
const pkg = PLATFORMS[key];
|
|
15
|
+
|
|
16
|
+
function fail() {
|
|
17
|
+
console.error(`tokler: unsupported platform ${key}.`);
|
|
18
|
+
console.error("Supported today: macOS arm64 (Apple Silicon) and macOS x64 (Intel).");
|
|
19
|
+
console.error("Linux and Windows builds are coming.");
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!pkg) fail();
|
|
24
|
+
|
|
25
|
+
let binPath = null;
|
|
26
|
+
|
|
27
|
+
// Development mode: sibling platform package in the source tree.
|
|
28
|
+
const devPath = path.join(__dirname, "..", "..", pkg, "bin", "tokler");
|
|
29
|
+
if (fs.existsSync(devPath)) {
|
|
30
|
+
binPath = devPath;
|
|
31
|
+
} else {
|
|
32
|
+
try {
|
|
33
|
+
binPath = require.resolve(`${pkg}/bin/tokler`);
|
|
34
|
+
} catch {
|
|
35
|
+
console.error(`tokler: could not find the ${pkg} package.`);
|
|
36
|
+
console.error("It ships as an optionalDependency of tokler; your installer may have skipped it.");
|
|
37
|
+
console.error("Try reinstalling: npm install tokler (or bun add tokler).");
|
|
38
|
+
console.error("Supported today: macOS arm64 and macOS x64. Linux and Windows builds are coming.");
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const result = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
44
|
+
|
|
45
|
+
if (result.error) {
|
|
46
|
+
console.error(`tokler: failed to launch binary: ${result.error.message}`);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
if (result.signal) {
|
|
50
|
+
process.kill(process.pid, result.signal);
|
|
51
|
+
}
|
|
52
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tokler-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Privacy-first AI token analyzer CLI. Count, audit, and optimize prompt and MCP token costs across OpenAI, Anthropic, and Gemini. Runs fully local.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"tokler": "bin/tokler.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/tokler.js",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
17
|
+
"optionalDependencies": {
|
|
18
|
+
"tokler-darwin-arm64": "0.1.0",
|
|
19
|
+
"tokler-darwin-x64": "0.1.0"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"llm",
|
|
23
|
+
"tokens",
|
|
24
|
+
"tokenizer",
|
|
25
|
+
"cli",
|
|
26
|
+
"anthropic",
|
|
27
|
+
"openai",
|
|
28
|
+
"gemini",
|
|
29
|
+
"mcp",
|
|
30
|
+
"prompt",
|
|
31
|
+
"cost"
|
|
32
|
+
]
|
|
33
|
+
}
|