@tokmizer/plugin 1.0.1 → 1.0.2

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/README.md CHANGED
@@ -1,172 +1,265 @@
1
+ <div align="center">
2
+
1
3
  # Tokmizer
2
4
 
3
- Tokmizer reduces token consumption for 21 AI coding agents, including Claude Code, OpenAI Codex, Cursor, Gemini CLI and GitHub Copilot. Aider, Cline and Windsurf run through `tkr wrap`. Works on macOS, Linux, and Windows.
5
+ **Your AI coding agent reads up to 93% fewer tokens of command output, and keeps every error.**
6
+
7
+ Free · no account · Claude Code, Codex, Cursor, Gemini CLI, Copilot and 16 more agents · macOS, Linux, Windows
8
+
9
+ [![npm](https://img.shields.io/npm/v/@tokmizer/plugin?label=npm&color=cb3837)](https://www.npmjs.com/package/@tokmizer/plugin)
10
+ [![licence](https://img.shields.io/badge/licence-Apache--2.0%20%2B%20BUSL--1.1-blue)](https://github.com/norwelltw/Tokmizer/blob/main/packages/plugin/LICENSES.md)
11
+ [![node](https://img.shields.io/badge/node-%E2%89%A5%2020.11-339933)](https://nodejs.org)
12
+
13
+ [Website](https://tokmizer.com) · [Docs](https://tokmizer.com/en/docs) · [Benchmark vs rtk](https://tokmizer.com/en/compare/rtk) · [CI](https://tokmizer.com/en/ci)
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ Every `npm test`, `cargo build`, `git log` or `grep -rn` your agent runs pours its full output into the context window: passing tests, progress bars, compile lines, the same warning 400 times. Tokmizer sits between the command and the model and hands over what matters: the failures, the diagnostics, the result. The full output stays one command away.
20
+
21
+ ## Before and after
22
+
23
+ `cargo test` with three failing tests ([fixture](https://github.com/norwelltw/Tokmizer/blob/main/packages/plugin/src/__tests__/fixtures/test-failures/cargo.txt)).
24
+
25
+ **Before:** 42 lines, 1,102 bytes. Compile lines, every passing test, panic headers, a backtrace hint, and the failure list printed twice.
26
+
27
+ **After:** 11 lines, 382 bytes.
28
+
29
+ ```
30
+ × tests::truthy src/lib.rs:12:27
31
+ assertion failed: add(0, 0) > 0
32
+ × tests::big src/lib.rs:10:24
33
+ assertion `left == right` failed: adding 6 and 1
34
+ left: 8
35
+ right: 7
36
+ × tests::empty src/lib.rs:2:34
37
+ index out of bounds: the len is 0 but the index is 0
38
+ test result: FAILED. 4 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out
39
+ error: test failed, to rerun pass `--lib`
40
+ ```
41
+
42
+ Every assertion, location and value is still there.
4
43
 
5
- It shortens command output before it reaches the model, reducing the space it takes in the context window. The reduction depends on the output and the chosen mode. This is not a promise of lower usage costs or faster work.
44
+ ## Numbers
45
+
46
+ 68 real command outputs replayed offline through each tool's Claude Code hooks (Tokmizer 0.9.71 and rtk 1.0.1 with default settings, o200k_base tokenizer, median of 3 runs, 2026-10-19):
47
+
48
+ | | Tokmizer, Claude Code default mode | Tokmizer, commands rewritten | rtk 1.0.1 |
49
+ | --- | ---: | ---: | ---: |
50
+ | Tokens removed | **93.0%** | **94.3%** | 55.5% |
51
+ | Failure details kept, out of 307 | **307** | **307** | 133 |
52
+ | Failing runs that lost a detail, out of 26 | **0** | **0** | 10 |
53
+ | Cuts without a marker | none found | none found | found |
54
+
55
+ - Claude Code's own `Read`, `Grep` and `Glob` tools are shortened too: large file reads −62% to −91%, `grep` −27% to −94%, `glob` −70%. Smaller code files stay whole.
56
+ - The hook that runs before each command takes about 3 ms with the native launcher, against 11 to 17 ms for rtk (measured 2026-10-16).
57
+
58
+ These figures count command output, not your bill, task success or speed. Small outputs gain less: 51% on the outputs under 30,000 characters. Method, every case and the raw JSON: [tokmizer.com/en/compare/rtk](https://tokmizer.com/en/compare/rtk). A public benchmark you can replay yourself: [BENCHMARK.md](https://github.com/norwelltw/Tokmizer/blob/main/BENCHMARK.md).
6
59
 
7
60
  ## Install
8
61
 
9
- In Claude Code:
62
+ ### Claude Code
10
63
 
11
64
  ```
12
65
  /plugin marketplace add norwelltw/Tokmizer
13
66
  /plugin install tokmizer@tokmizer
14
67
  ```
15
68
 
16
- Then restart Claude Code once, hooks only load at startup. Verify with `/tkr-status`, you should see Status active.
69
+ Restart Claude Code once (hooks load at startup), then run `/tkr-status`. You should see `Status active`.
17
70
 
18
- Any other agent: install the CLI with npm (Node.js 20.11 or newer), then set up every agent found on this machine:
71
+ ### Every other agent
72
+
73
+ Install the CLI, then let `tkr setup --all` hook every agent it finds on this machine:
74
+
75
+ ```bash
76
+ curl -fsSL https://tokmizer.com/install.sh | bash
77
+ tkr setup --all
78
+ ```
79
+
80
+ The script uses npm when Node.js 20.11+ is installed, and otherwise downloads a standalone build for macOS or Linux after checking its signature and SHA-256. Your shell profile is not touched.
81
+
82
+ <table>
83
+ <tr><td><b>npm</b></td><td>
19
84
 
20
85
  ```bash
21
86
  npm install -g @tokmizer/plugin
22
87
  tkr setup --all
23
88
  ```
24
89
 
25
- Without Node.js, the install script uses npm when Node.js 20.11 or newer is there and otherwise downloads a standalone build for macOS or Linux, checked against its SHA-256. It leaves your shell profile unchanged. Then run `tkr setup --all`.
90
+ </td></tr>
91
+ <tr><td><b>Homebrew</b></td><td>
26
92
 
27
93
  ```bash
28
- curl -fsSL https://tokmizer.com/install.sh | bash
94
+ brew install norwelltw/tokmizer/tokmizer
95
+ tkr setup --all
29
96
  ```
30
97
 
31
- Windows (PowerShell):
98
+ </td></tr>
99
+ <tr><td><b>Windows</b><br>PowerShell</td><td>
32
100
 
33
101
  ```powershell
34
102
  npm.cmd install -g @tokmizer/plugin
35
103
  tkr.cmd setup --all
36
104
  ```
37
105
 
38
- See the [installation guide](https://tokmizer.com/en/docs#installation) for per-tool notes.
106
+ </td></tr>
107
+ </table>
39
108
 
40
- Codex, after installing with npm or Homebrew:
109
+ `tkr setup` without `--all` lists what it found and asks. Restart each agent after setup, then run `tkr status`. Installed with npm or Homebrew, `tkr` updates itself 24 hours after a version ships; `tkr auto-update off` stops that.
41
110
 
42
- ```bash
43
- tkr setup-codex
44
- ```
111
+ ### Supported agents
45
112
 
46
- Restart Codex, then approve the hook in `/hooks`. `tkr setup --all` includes Codex.
113
+ | Agent | Setup | Through |
114
+ | --- | --- | --- |
115
+ | Claude Code | plugin above, or `tkr setup-claude` | native hooks |
116
+ | Codex | `tkr setup-codex`, then approve the hook in `/hooks` | native hooks |
117
+ | Cursor | `tkr setup-cursor` | `preToolUse` hook |
118
+ | Gemini CLI | `tkr setup-gemini` | `BeforeTool` hook |
119
+ | GitHub Copilot, VS Code and CLI | `tkr setup-copilot` | `PreToolUse` hook |
120
+ | Factory Droid | `tkr setup-droid` | `PreToolUse` hook |
121
+ | Trae, Trae CN | `tkr setup-trae` | `PreToolUse` hook |
122
+ | Qwen Code | `tkr setup-qwen` | `PreToolUse` hook |
123
+ | Crush | `tkr setup-crush` | `PreToolUse` hook |
124
+ | Junie CLI | `tkr setup-junie` | `PreToolUse` hook |
125
+ | ZCode | `tkr setup-zcode` | `PreToolUse` hook |
126
+ | Grok Build 1.0.4+ | `tkr setup-grok` | `PreToolUse` hook |
127
+ | Antigravity | `tkr setup-antigravity` | `PreToolUse` hook |
128
+ | Mistral Vibe | `tkr setup-vibe` | `pre_tool` hook |
129
+ | OpenCode | `tkr setup-opencode` | plugin |
130
+ | Kilo Code, CLI and VS Code | `tkr setup-kilo` | plugin |
131
+ | Amp | `tkr setup-amp` | plugin |
132
+ | OpenClaw | `tkr setup-openclaw` | plugin |
133
+ | Hermes v2026.8.16+ | `tkr setup-hermes` | plugin |
134
+ | Pi | `tkr setup-pi` | extension |
135
+ | Oh My Pi | `tkr setup-omp` | extension |
136
+ | Aider, Cline, Windsurf | `tkr wrap aider` | command shims, for that session only |
137
+
138
+ Every setup command keeps your other hooks and settings, saves the file as it was in `~/.tokmizer/backup/config/`, and takes itself out with `--remove`. If `tkr` is missing, slow or fails, the command runs exactly as typed.
139
+
140
+ <details>
141
+ <summary>Files each setup command edits</summary>
142
+
143
+ | Command | File |
144
+ | --- | --- |
145
+ | `tkr setup-cursor` | `~/.cursor/hooks.json` |
146
+ | `tkr setup-gemini` | `~/.gemini/settings.json` |
147
+ | `tkr setup-copilot` | `~/.copilot/hooks/tokmizer.json`, or `$COPILOT_HOME/hooks/` |
148
+ | `tkr setup-droid` | `~/.factory/hooks.json`, or `~/.factory/settings.json` when your own `PreToolUse` hooks live there |
149
+ | `tkr setup-trae` | `~/.trae/hooks.json`, plus `~/.trae-cn/hooks.json` when Trae CN is installed |
150
+ | `tkr setup-qwen` | `~/.qwen/settings.json`, or `$QWEN_HOME` |
151
+ | `tkr setup-crush` | `~/.config/crush/crush.json`; a `crush.json` with comments is left untouched and reported |
152
+ | `tkr setup-junie` | `~/.junie/config.json` |
153
+ | `tkr setup-zcode` | `~/.zcode/cli/config.json` |
154
+ | `tkr setup-grok` | `~/.grok/hooks/tokmizer.json` |
155
+ | `tkr setup-antigravity` | `~/.gemini/config/hooks.json` |
156
+ | `tkr setup-vibe` | `~/.vibe/hooks.toml` |
157
+ | `tkr setup-opencode` | `~/.config/opencode/plugins/tokmizer.js` |
158
+ | `tkr setup-kilo` | `~/.config/kilo/plugin/tokmizer.js` |
159
+ | `tkr setup-amp` | `~/.config/amp/plugins/tokmizer.js` |
160
+ | `tkr setup-openclaw` | `~/.openclaw/extensions/tokmizer/`, then `openclaw plugins enable tokmizer` |
161
+ | `tkr setup-hermes` | `~/.hermes/plugins/tokmizer/`, then `hermes plugins enable tokmizer` |
162
+ | `tkr setup-pi` | `~/.pi/agent/extensions/tokmizer.js` |
163
+ | `tkr setup-omp` | `~/.omp/agent/extensions/tokmizer.js` |
47
164
 
48
- If Codex reports `PreToolUse hook returned updatedInput without permissionDecision:allow`, it is running the Claude Code hooks: an older Tokmizer plugin installed in Codex, or hooks copied over by Codex `/import`. Run `tkr doctor --fix`, then approve the Tokmizer hook in `/hooks` and restart Codex.
165
+ `XDG_CONFIG_HOME`, `VIBE_HOME`, `PI_CODING_AGENT_DIR` and `HERMES_HOME` are respected.
49
166
 
50
- Cursor or Gemini CLI, after installing with npm or Homebrew:
167
+ </details>
51
168
 
52
- ```bash
53
- tkr setup-cursor
54
- tkr setup-gemini
55
- ```
169
+ <details>
170
+ <summary>Hooks copied between agents, Codex <code>/import</code></summary>
56
171
 
57
- `tkr setup-cursor` adds a `preToolUse` hook to `~/.cursor/hooks.json`; `tkr setup-gemini` adds a `BeforeTool` hook to `~/.gemini/settings.json`. Each hook routes the agent's shell commands through Tokmizer before they run, keeps your other hooks and settings, and saves the file as it was before each change in `~/.tokmizer/backup/config/` (latest copy only). Remove either with `--remove`. Cursor's `afterShellExecution` and Gemini's `AfterTool` events cannot replace command output, so these hooks rewrite the command itself.
172
+ Codex `/import` copies your Claude Code hooks, and config files get copied by hand. Tokmizer hooks are safe to bring along: each one reads which agent is calling it and answers in that agent's format; if the input mixes two agents, it changes nothing. Afterwards run `tkr setup --all` or `tkr doctor --fix`: each agent gets its own hook, the copied ones are removed, your own hooks stay, and every changed file is backed up.
58
173
 
59
- Other agents with plugin or hook support:
174
+ If Codex reports `PreToolUse hook returned updatedInput without permissionDecision:allow`, it is running Claude Code hooks. Run `tkr doctor --fix`, approve the Tokmizer hook in `/hooks` and restart Codex.
60
175
 
61
- | Agent | Command | What it installs |
62
- | --- | --- | --- |
63
- | OpenCode | `tkr setup-opencode` | plugin `~/.config/opencode/plugins/tokmizer.js` |
64
- | Kilo Code (CLI and VS Code extension) | `tkr setup-kilo` | plugin `~/.config/kilo/plugin/tokmizer.js` |
65
- | Amp | `tkr setup-amp` | plugin `~/.config/amp/plugins/tokmizer.js` |
66
- | Mistral Vibe | `tkr setup-vibe` | `pre_tool` hook in `~/.vibe/hooks.toml` |
67
- | Antigravity | `tkr setup-antigravity` | `PreToolUse` hook in `~/.gemini/config/hooks.json` |
68
- | OpenClaw | `tkr setup-openclaw` | plugin `~/.openclaw/extensions/tokmizer/`, then `openclaw plugins enable tokmizer` |
69
- | Pi | `tkr setup-pi` | extension `~/.pi/agent/extensions/tokmizer.js` |
70
- | Oh My Pi | `tkr setup-omp` | extension `~/.omp/agent/extensions/tokmizer.js` |
71
- | Hermes | `tkr setup-hermes` | plugin `~/.hermes/plugins/tokmizer/`, then `hermes plugins enable tokmizer` (Hermes v2026.8.16 or newer) |
176
+ </details>
72
177
 
73
- Each plugin asks `tkr rewrite` for the Tokmizer form of a shell command just before the agent runs it. If `tkr` is missing, slow or fails, the command runs as typed. `XDG_CONFIG_HOME`, `VIBE_HOME`, `PI_CODING_AGENT_DIR` and `HERMES_HOME` are respected. Run the same command with `--remove` to take it out; your other plugins, hooks and settings are kept.
178
+ ## How it works
74
179
 
75
- GitHub Copilot, Factory Droid, Trae, Qwen Code, Crush, Junie CLI, ZCode or Grok Build, after installing with npm or Homebrew:
180
+ 1. **Before a command runs**, the agent's hook asks Tokmizer whether to route it. If so, it runs through `tkr-exec`, which picks a built-in rule for it: `cargo`, `pytest`, `vitest`, `jest`, `go test`, `gradle`, `git`, `docker`, `kubectl`, `terraform` and many more.
181
+ 2. **The rule shortens the output.** Passing tests, progress, repeated lines and boilerplate go; failures, diagnostics, locations and the exit code stay. A shortened output is never longer than the original.
182
+ 3. **A copy of the full output** stays on your machine. When something was cut, the agent sees a `[tkr restore <hash>]` hint and can fetch it back.
76
183
 
77
- ```bash
78
- tkr setup-copilot
79
- tkr setup-droid
80
- tkr setup-trae
81
- tkr setup-qwen
82
- tkr setup-crush
83
- tkr setup-junie
84
- tkr setup-zcode
85
- tkr setup-grok
86
- ```
184
+ ### Your permission rules stay in force
87
185
 
88
- | Command | Agent | File it edits |
89
- |---|---|---|
90
- | `tkr setup-copilot` | Copilot in VS Code and Copilot CLI | `~/.copilot/hooks/tokmizer.json` (or `$COPILOT_HOME/hooks/`) |
91
- | `tkr setup-droid` | Factory Droid | `~/.factory/hooks.json`, or `~/.factory/settings.json` when your own `PreToolUse` hooks live there |
92
- | `tkr setup-trae` | Trae | `~/.trae/hooks.json`, plus `~/.trae-cn/hooks.json` when Trae CN is installed |
93
- | `tkr setup-qwen` | Qwen Code | `~/.qwen/settings.json` (or `$QWEN_HOME`) |
94
- | `tkr setup-crush` | Crush | `~/.config/crush/crush.json` (or `$XDG_CONFIG_HOME/crush/`) |
95
- | `tkr setup-junie` | Junie CLI | `~/.junie/config.json` |
96
- | `tkr setup-zcode` | ZCode | `~/.zcode/cli/config.json` (`hooks.events.PreToolUse`) |
97
- | `tkr setup-grok` | Grok Build 1.0.4 or newer | `~/.grok/hooks/tokmizer.json` |
186
+ Agents check their allow, ask and deny rules against the command text. Tokmizer reads those rules and leaves a command untouched whenever one of your deny or ask rules matches it, so `git push` or `rm` run as typed and still ask you. For agents whose rules it cannot read, only inspection, build and test commands are routed. Shell functions, aliases and builtins always run as typed, and if a settings file cannot be read, nothing is routed.
98
187
 
99
- Each command adds one `PreToolUse` hook for the agent's shell tool. It rewrites the command before it runs, never approves it: the agent keeps asking for permission as usual. Your other hooks and settings stay as they are, the file as it was before each change is saved in `~/.tokmizer/backup/config/` (latest copy only), and `--remove` takes the hook out again. Restart the agent after setup. Crush still reads `crush.json` but now prefers `crushrc`; a `crush.json` with comments is left untouched and reported.
188
+ <details>
189
+ <summary>Claude Code permission modes</summary>
100
190
 
101
- Permission rules stay in force. Agents match their allow, ask and deny rules against the command text, so Tokmizer leaves a command untouched whenever one of your deny or ask rules matches it. Tokmizer reads those rules for Claude Code (`permissions.deny` and `permissions.ask` in user, project, local and managed settings; a command matched by one of your `permissions.allow` rules is left untouched too, so that rule keeps approving it), OpenCode (`permission` in `opencode.json`), Cursor CLI (`permissions.deny`), Gemini CLI (policy files and `tools.exclude`) and Antigravity CLI (`permissions.deny` and `permissions.ask`). For the other agents, and on top of the Cursor, Gemini and Antigravity rules, only inspection, build and test commands (`cat`, `rg`, `git log`, `npm test`, `cargo build` and similar; inspection only for Codex) are routed; anything else, such as `git push` or `rm`, runs exactly as typed. If a settings file cannot be read, nothing is routed. Shell functions, aliases, builtins and anything that is not a program on your `PATH` always run exactly as typed.
191
+ | Mode | What Tokmizer does |
192
+ | --- | --- |
193
+ | Default | Build and test commands (`npm test`, `cargo test`, `pytest`, `./gradlew build`…) are shortened before they run; Claude Code asks for them once, as it would anyway. Read-only commands (`ls`, `cat`, `git status`) run as typed, so Claude Code still approves them on its own, and their output is shortened once they succeed. Claude Code runs that after-command hook only for successful commands, so a failing read-only command reaches Claude in full. |
194
+ | Default, with a narrow allow rule of yours | A single command typed on its own (no `&&`, `;`, pipe, redirection, `$( )` or wildcard) that one of your allow rules covers, such as `Bash(pytest:*)` in your user or managed settings, is rewritten too when no deny or ask rule matches. Tokmizer then gives the approval Claude Code would have given to the command as typed, so no new prompt appears. |
195
+ | `bypassPermissions`, or a plain `Bash` allow rule | In `bypassPermissions` mode, or when a plain `Bash` allow rule in your user or managed settings applies and the session is in default, `acceptEdits` or `dontAsk` mode, every routed command is rewritten, and failing output is shortened too. |
102
196
 
103
- In Claude Code, a command is rewritten only when that adds no permission prompt: in `bypassPermissions` mode, or when a plain `Bash` allow rule in your user or managed settings applies and the session is in default, `acceptEdits` or `dontAsk` mode. Otherwise it runs exactly as typed, so Claude Code still approves read-only commands such as `ls`, `cat` or `git status` on its own, and Tokmizer shortens the output once the command has succeeded. Claude Code runs that after-command hook only for successful commands, so in this default mode a failing command reaches Claude in full. A single command typed on its own (no `&&`, `;`, pipe, redirection, `$( )` or wildcard) is also rewritten when one of your own allow rules for it, such as `Bash(pytest:*)` or `Bash(cargo build:*)` in your user or managed settings, applies and no deny or ask rule matches: Tokmizer then gives the approval Claude Code would have given to the command as typed, so no new prompt appears. When commands are rewritten, failing output is shortened too, with its failure details kept.
197
+ Your deny and ask rules, `--disallowedTools`, `--settings`, managed policies and the claude.ai console rules always win. In a linked git worktree, commands that mention git run as typed so Claude Code's worktree check never refuses them.
104
198
 
105
- Aider, Cline and Windsurf have no hooks. Start them through Tokmizer, for example `tkr wrap aider`: only that session goes through Tokmizer's command shims. Your own terminals are not changed; `tkr shim global-path on` routes every terminal through the shims by adding a PATH line to your shell profile, and `tkr shim global-path off` removes it.
199
+ </details>
106
200
 
107
- Every agent found on this machine at once (each `tkr setup-…` above runs in turn, agents that are not installed are skipped, and a summary ends the run):
201
+ ## Commands
108
202
 
109
- ```bash
110
- tkr setup --all
111
- ```
203
+ | Claude Code | Terminal | What it does |
204
+ | --- | --- | --- |
205
+ | `/tkr-status` | `tkr status` | account, engine and rule status |
206
+ | `/tkr-gain` | `tkr gain` | tokens saved, by day, project or rule |
207
+ | `/tkr-compression` | `tkr compression light\|balanced\|max` | how hard output is shortened, `balanced` by default |
208
+ | `/tkr-reducer` | `tkr reducer off\|light\|balanced\|max` | shorter replies from the model itself, `off` by default |
209
+ | `/tkr-yolo` | `tkr yolo on\|off\|status` | very aggressive mode, see below |
210
+ | `/power` | `$power` in Codex, `/power` in most agents | plan, build, test and ship a change in one go |
211
+ | `/tkr` | `tkr settings show\|set\|configure` | every setting |
212
+ | `/tkr-telemetry` | `tkr telemetry on\|off\|status` | usage stats |
213
+ | `/tkr-link` | `tkr link <key>` | optional account: synced settings and a dashboard |
214
+ | `/tkr-unlink` | `tkr unlink` | detach this machine from the account |
215
+ | `/tkr-update` | npm, brew or auto-update | latest version |
216
+
217
+ Also in the terminal: `tkr restore`, `tkr doctor [--fix]`, `tkr discover`, `tkr session`, `tkr network`, `tkr filters`, `tkr migrate rtk`, `tkr setup`, `tkr uninstall`. `tkr --help` lists everything.
218
+
219
+ ## Compression modes
220
+
221
+ | Mode | Use it for |
222
+ | --- | --- |
223
+ | `light` | gentle shortening; file reads up to 16 KB stay whole. Pick it when you need implementation details. |
224
+ | `balanced` | the default: compact output, code bodies can be folded in large reads |
225
+ | `max` | the strongest standard level; repeated log lines become one line with a count |
112
226
 
113
- `tkr setup` without `--all` lists the agents it found and asks which ones to set up.
227
+ All three keep failures, distinct diagnostics and exit codes. Short or exact output is often identical across levels. `normal`, `compact` and `minimal` work as aliases.
114
228
 
115
- ### Importing your setup from one agent to another
229
+ > **Warning: YOLO** (`tkr yolo on`) goes further and **can remove errors, list entries and useful details**. It keeps no restore copy, so what it drops cannot be recovered. It is off by default, applies to this machine only and cannot be turned on from the dashboard. Keep it off for debugging, reviews, audits or anything that needs the full output.
116
230
 
117
- Some agents import another agent's settings (Codex `/import` copies your Claude Code hooks), and config files get copied by hand. Tokmizer hooks are safe to bring along: each one reads which agent is calling it from the hook input and answers in that agent's format; if the input mixes fields of two agents, it changes nothing. Afterwards, run `tkr setup --all` or `tkr doctor --fix`: each agent gets its own Tokmizer hook, the copied ones are removed, your own hooks stay and every changed file is backed up in `~/.tokmizer/backup/config/`. `tkr doctor` also checks a project's `.codex/hooks.json` and `.codex/config.toml`. Junie CLI and ZCode send the same hook input as Claude Code, so a hook copied between those three answers in the format of the agent it was set up for.
231
+ The **reducer** is separate: from the next session it asks the model to answer in fewer words, while keeping code, errors and security warnings. It works in Claude Code and in every agent set up with `tkr setup-<agent>`. How much it saves depends on the model.
118
232
 
119
- Homebrew:
233
+ ## Getting the full output back
120
234
 
121
235
  ```bash
122
- brew install norwelltw/tokmizer/tokmizer
123
- tkr setup --all
236
+ tkr restore <hash> # the whole original output
237
+ tkr restore <hash> --lines 120:180 # only some lines
238
+ tkr restore <hash> --grep <pattern> # matching lines with their numbers
239
+ tkr restore --grep <pattern> # search every cached output of this project
240
+ tkr restore --list # what is cached here; --all-projects for every project
124
241
  ```
125
242
 
126
- The formula brings Node.js with it. Installed with npm or Homebrew, tkr updates itself when a new version is out; `tkr auto-update off` stops that. Restart each agent after its setup, then run `tkr status`. An offline installation reports that free activation is pending; run `tkr status` again when online.
127
-
128
- ## Free access
243
+ Copies stay on your machine. Entries are kept 30 days, up to 8 MB each and 200 MB in total; the oldest go first. Private keys, GitHub, npm, AWS, Slack and Stripe tokens, `Bearer` headers and passwords in URLs are masked before a copy is saved; what the agent sees is unchanged. `TOKMIZER_CCR_DISABLED=1` turns copies off.
129
244
 
130
- Tokmizer is free and works without an account. An optional account lets you synchronize settings and view your dashboard. To connect an existing account key:
245
+ ## Measuring your own savings
131
246
 
132
247
  ```bash
133
- tkr link <your-key>
248
+ tkr gain # all time
249
+ tkr gain --week --graph # last 7 days, one bar per day
250
+ tkr gain --by-rule # which rules saved the most
251
+ tkr gain --failures # commands left unchanged, and why
252
+ tkr gain --quota 5x # rough share of a Claude plan budget (pro, 5x or 20x)
134
253
  ```
135
254
 
136
- ## Commands
137
-
138
- In Claude Code:
139
-
140
- - `/tkr` shows or changes settings
141
- - `/tkr-link tokmizer_yourkey` connects an optional account
142
- - `/tkr-unlink` unlinks this machine from your account
143
- - `/tkr-gain` shows the estimated reduction in command-output tokens
144
- - `/tkr-status` shows your account and engine status
145
- - `/tkr-compression` picks the compression level (light, balanced, max)
146
- - `/tkr-yolo on` explicitly enables YOLO on this machine; `/tkr-yolo off` disables it
147
- - `/tkr-reducer` makes the assistant's replies shorter (off, light, balanced, max), in Claude Code and in every agent set up with `tkr setup-<agent>`
148
- - `/tkr-telemetry` views or changes usage stats (command names and token counts; on by default, off in one command)
149
- - `/tkr-update` updates the plugin when a new version is out
150
-
151
- From any terminal (after installing with npm, the install script or Homebrew):
152
-
153
- - `tkr status` shows your account and engine status
154
- - `tkr gain` shows the estimated reduction in command-output tokens
155
- - `tkr link <key>` connects an optional account
156
- - `tkr unlink` unlinks this machine
157
- - `tkr compression light|balanced|max` picks how hard output gets compressed (default balanced)
158
- - `tkr yolo on|off|status` enables, disables, or checks the local YOLO mode
159
- - `tkr reducer off|light|balanced|max` makes the assistant's replies shorter (default off)
160
- - `tkr settings show|set|configure` manages settings and syncs them across your machines
161
- - `tkr network off|on|status` blocks or allows every connection to tokmizer.com
162
- - `tkr migrate rtk` moves your rtk filters, settings and history over and turns off rtk hooks where Tokmizer runs (see [Switching from rtk to Tokmizer](#switching-from-rtk-to-tokmizer))
163
- - `tkr setup [--all]` sets up the agents found on this machine; `tkr setup-<agent> --remove` takes one out
164
- - `tkr doctor [--fix]` shows what is detected and repairs outdated shims and hooks
165
- - `tkr uninstall` removes every hook, shim and PATH line Tokmizer added (see [Uninstall](#uninstall))
255
+ Each view also takes `--project` and `--json`. `tkr gain` estimates command-output tokens as bytes divided by four; it is not your actual usage. Restores count against the saving.
166
256
 
167
257
  ## /power and the reducer in other agents
168
258
 
169
- `tkr setup-<agent>` also installs `/power` and the reducer where the agent offers a documented way to do it; `tkr setup-<agent> --remove` and `tkr uninstall` take them out again. `/power` reads the same synced instructions as in Claude Code (`~/.tokmizer/skills/power.md`, refreshed by `tkr heartbeat`) and runs only the steps the agent's tools allow: it says what is left when it cannot run tests, commit or open a pull request. The reducer uses the same ruleset, word for word, in every agent and follows the single `tkr reducer off|light|balanced|max` setting.
259
+ `tkr setup-<agent>` also installs `/power` and the reducer where the agent offers a documented way to do it. `/power` runs only the steps the agent's tools allow and says what is left when it cannot run tests or open a pull request. A command or skill you wrote yourself is never overwritten. In rules files, Tokmizer only edits the block between `<!-- tokmizer:begin managed-by: tokmizer -->` and `<!-- tokmizer:end -->`.
260
+
261
+ <details>
262
+ <summary>Where each agent gets them</summary>
170
263
 
171
264
  | Agent | `/power` | Reducer |
172
265
  | --- | --- | --- |
@@ -193,90 +286,11 @@ From any terminal (after installing with npm, the install script or Homebrew):
193
286
  | OpenClaw | skill `/power` (`~/.openclaw/skills`) | via plugin: `before_prompt_build`, once you set `plugins.entries.tokmizer.hooks.allowConversationAccess` to `true` |
194
287
  | Cline, Windsurf, Aider | not installed: these agents only get command shims and have no `tkr setup-<agent>` command | not installed |
195
288
 
196
- Never overwritten: an existing `power` command or skill that Tokmizer did not write is left as it is and reported. Rules files keep your text; Tokmizer only edits the block between `<!-- tokmizer:begin managed-by: tokmizer -->` and `<!-- tokmizer:end -->`, saves the file as it was before each change in `~/.tokmizer/backup/config/`, and rewrites that block when the reducer setting or its ruleset changes (`tkr reducer`, `tkr settings`, or a heartbeat). With the reducer off the block is removed, and it comes back when you turn the reducer on. When several agents read the same rules file through symlinks, the block stays until the last of them is removed. The shared `~/.agents/skills/power` skill stays while another agent that reads it is still set up. The OpenCode, Kilo Code, Hermes and OpenClaw plugins read the active ruleset from `~/.tokmizer/reducer-context.txt` (under `TOKMIZER_HOME` when set) without starting a process; Tokmizer rewrites that file when the reducer changes and deletes it when the reducer is off. `tkr uninstall` also deletes these backups.
197
-
198
- ## Choosing a compression mode
199
-
200
- Choose `light` for gentle reduction, `balanced` (the default) for more compact output, or `max` for the strongest standard reduction. The aliases `normal`, `compact`, and `minimal` map to these levels respectively. Short or exact output can be identical across levels.
201
-
202
- Since 0.9.54, Light keeps recognized file reads of up to 16 KB complete; larger reads are shortened again. Balanced and Max can fold code bodies. Choose Light when you need implementation details. Explicit outlining remains available to callers that request it. Host limits and the CLI's output buffer still apply.
203
-
204
- Since 0.9.52, short code reads and small explicit excerpts stay complete by default in all three standard modes. Larger reads can still be shortened. Recognized failures retain their diagnostics; Max can summarize repeated log lines with an occurrence count. Distinct diagnostic messages and command exit codes are preserved.
205
-
206
- Without a linked account, standard settings stay on this machine and work offline after initial activation. With a linked account, changes require a connection and sync across machines. Linking an account restores its server settings.
207
-
208
- The separate `reducer` setting provides response-style instructions, starting with the next session, for Claude Code and for every agent set up with its `tkr setup-<agent>` command (see the table below). The instructions ask the model to preserve code, errors, and security information; compliance and actual savings depend on the model. If the ruleset is unavailable, the CLI reports it instead of claiming activation. Reconnect and run `tkr heartbeat` before starting a new session.
209
-
210
- YOLO is off by default and requires an explicit `on`. It applies only to this machine, is not synchronized, and cannot be enabled from the dashboard.
211
-
212
- | Command | Effect |
213
- | --- | --- |
214
- | `tkr yolo on` | Enable more aggressive compression on this machine |
215
- | `tkr yolo off` | Return to the usual compression mode |
216
- | `tkr yolo status` | Show whether YOLO is enabled |
217
- | `tkr compression light`, `tkr compression balanced`, or `tkr compression max` | Disable YOLO locally. Linked accounts need a connection to sync the standard level |
218
-
219
- **YOLO can remove errors, list entries, and useful details.** It creates no new restoration copies of compressed output. Existing cached output is not deleted, but turning YOLO off cannot recover details discarded while it was on. Command exit codes remain unchanged.
220
-
221
- Use YOLO for repeated commands only when you accept incomplete output and can check the result independently. Turn it off for debugging, diagnosis, exhaustive code review, audits, or any task that needs the complete output. A preserved exit code alone does not verify the result. YOLO is not a promise of faster coding, rendering, or builds.
222
-
223
- Terminal commands managed by Tokmizer use the mode selected when execution starts. Native agent tools use the mode active when their output is received. Output processing that has already started in YOLO remains without a restoration copy after YOLO is turned off. Turning YOLO on blocks new restoration copies. Change modes between commands. This concerns Tokmizer's copies, not any history kept by your agent or terminal.
224
-
225
- `tkr gain` measures output size before and after compression and estimates tokens as UTF-8 bytes divided by four. Token and cost figures are estimates about command output, not a measure of your actual API usage, task quality or completion speed.
226
-
227
- Since 0.9.53, successful `tkr restore` calls are counted as additional output in the local gain history, even with telemetry disabled. They reduce the net saving; repeated restorations count again and can make it negative. The display shows restored tokens separately. `gain --json` exposes the net estimate in `observed.savedTokens` and restoration totals in `restoration`; the existing top-level `savedTokens` remains the total for reduced outputs only. Earlier restorations cannot be reconstructed from local history. Manually repeated commands, prompts, replies and replayed conversation context are not attributed to restoration costs.
228
-
229
- Other local views: `tkr gain --by-rule` groups savings by rule (your custom filters by name, built-in rules by command), `tkr gain --failures` lists commands whose output went through unchanged and why (no rule, nothing to cut, failed run kept in full), and `tkr gain --quota [pro|5x|20x]` estimates the share of a Claude plan budget the savings represent. The quota view is an estimate, not a plan limit: tokens saved per day × 30, divided by an assumed 44,000 tokens per 5-hour window × 144 windows × the plan multiplier (1, 5 or 20). Anthropic does not publish plan limits in tokens. All three combine with a period, `--project` and `--json`.
230
-
231
- The percentages in `tkr gain` measure byte reduction. A byte percentage can differ substantially from the reduction counted by a model's tokenizer. Restoring a full file after reading its outline can cost more tokens than reading it once. Compression is not a promise of faster task completion or a correct answer.
232
-
233
- ## Restoring shortened output
234
-
235
- When Tokmizer shortens an output it can add a `[tkr restore <hash>]` hint. `tkr restore <hash>` prints the complete original output when it is at most 8 MB, except detected secrets, which are masked; for a larger output, the entry holds only the part that was left out and `tkr restore` says so. A unique prefix of the hash is enough.
236
-
237
- | Command | Effect |
238
- | --- | --- |
239
- | `tkr restore <hash>` | Print the cached output |
240
- | `tkr restore <hash> --lines 120:180` | Print only lines 120 to 180 (`120:`, `:40` and `57` also work) |
241
- | `tkr restore <hash> --grep <pattern>` | Print matching lines with their line numbers |
242
- | `tkr restore --grep <pattern>` | Search the cached outputs of the current project |
243
- | `tkr restore --grep <pattern> --all-projects` | Search the cached outputs of every project |
244
- | `tkr restore --list` | List this project's cached outputs with age, size, line count and command (`--all-projects` for every project) |
245
-
246
- Before a copy is saved, private keys, GitHub, npm, AWS, Slack and Stripe live tokens, `Authorization: Bearer` values and passwords in URLs are replaced by `[tkr: secret masked]`; the output your agent sees is unchanged. Entries are kept 30 days, up to 8 MB each and 200 MB in total; the oldest go first. `TOKMIZER_CCR_MAX_AGE_MS`, `TOKMIZER_CCR_ENTRY_MAX_BYTES` and `TOKMIZER_CCR_DIR_CAP_BYTES` change these limits, `TOKMIZER_CCR_DISABLED=1` turns copies off. `tkr gain` shows the restored tokens and the cache size.
247
-
248
- ## Measured comparison
249
-
250
- On October 9, 2026, a fixed set of 30 real and synthetic command outputs contained 774,863 tokens before compression. The table counts tokens with the cl100k tokenizer, excluding restoration notices. It is a test corpus, not a sample of customer usage.
289
+ </details>
251
290
 
252
- These are historical results for the earlier mode behavior, not measurements of the Light read policy introduced in 0.9.54.
291
+ ## Your own rules
253
292
 
254
- | Mode | Output tokens | Preservation checks passed |
255
- | --- | ---: | ---: |
256
- | `light` | 112,816 | 85 / 85 |
257
- | `balanced` | 102,052 | 85 / 85 |
258
- | `max` | 93,131 | 85 / 85 |
259
- | YOLO | 1,925 | 44 / 85 |
260
-
261
- The 85 checks cover 13 of the 30 cases. The other 17 have no complete preservation checks, so these results do not prove universal fidelity. YOLO's smaller output comes with observed information loss.
262
-
263
- The result also depends on the output. In a separate set of five JSON examples, `light` produced 285 tokens, `balanced` 253, and both `max` and YOLO 197. YOLO does not always save more than `max`.
264
-
265
- In one real failed test, `max` kept 302 tokens and YOLO kept 77. Both retained the actual and expected values. YOLO removed the explanation about invoice 42 and the location `payment.test.mjs:4:10`, which were retained by `max`. That missing context can matter when fixing the failure.
266
-
267
- In a separate controlled test for 0.9.52, a repetitive failure log went from 1,094 to 84 tokens in Max (92.3% fewer, counted with cl100k). Every distinct diagnostic and the repetition counts were retained. This result applies to that example, not to typical usage.
268
-
269
- These tokenizer counts are separate from the byte-based estimates in `tkr gain`. They measure output volume, not API usage, an agent's task success, or execution speed. See the [mode guide](https://tokmizer.com/en/docs#configuration) for usage and limits.
270
-
271
- ### Benchmark of October 17, 2026
272
-
273
- Each tool's Claude Code hook chain replayed 68 real command outputs offline (network cut, empty home folder, no account, median of 3 runs) with Tokmizer 0.9.60 and its default settings, against rtk 1.0.1. Tokmizer removed 84% of tokens in Claude Code's default mode and up to 93% when commands are rewritten (`bypassPermissions` or a blanket `Bash` allow); rtk removed 55%. All 307 failure details were kept in both Tokmizer modes. A later offline run of the same 68 cases with Tokmizer 0.9.63, counted with Anthropic's legacy tokenizer rather than o200k_base, gave 84.2% in the default mode without allow rules, 92.8% in the default mode with narrow allow rules for the test and build commands and 93.5% in `bypassPermissions`, against 57.2% for rtk; 307/307 failure details were kept in every Tokmizer mode. The full results are on [tokmizer.com/en/compare/rtk](https://tokmizer.com/en/compare/rtk).
274
-
275
- ## Custom filters
276
-
277
- Add your own output rules as `*.toml` files in `~/.tokmizer/filters/` (or `$TOKMIZER_HOME/filters/`). They load next to the built-in rules and win over them for the commands they match. They stay on your machine and are never uploaded. A file or rule that fails validation is skipped; `tkr doctor` shows what was loaded and why something was skipped.
278
-
279
- A file is used only after you trust it: review it, then run `tkr filters trust` (all files) or `tkr filters trust <file>`. Tokmizer records the file's SHA-256; editing the file stops it from being used until you trust it again. `tkr filters untrust [file]` removes the trust.
293
+ Drop a `*.toml` file in `~/.tokmizer/filters/`. Your rules load next to the built-in ones, win for the commands they match, and never leave your machine.
280
294
 
281
295
  ```toml
282
296
  schema_version = 1
@@ -293,122 +307,95 @@ input = "make[1]: Entering directory '/src'\nok\n"
293
307
  expected = "ok"
294
308
  ```
295
309
 
296
- `schema_version` is optional; a version this tkr cannot read makes the file skipped with a message. `tkr filters test [rule]` runs the inline tests, including on files you have not trusted yet, and exits with 1 when one fails. Tests check the rule as written (the Light level) and ignore trailing whitespace; Balanced and Max shorten `max_lines` further.
297
-
298
- `match_command` is a regular expression tested against the command line. `strip_lines_matching` drops matching lines, `max_lines` caps the number of lines kept and `on_empty` replaces an empty result. Also available: `strip_ansi = true`, `keep_failures = true` (failure lines survive the cap), `truncate_lines_at = 400`, and `priority = 60` to pick between several of your rules that match the same command.
299
-
300
- ## Switching from rtk to Tokmizer
301
-
302
- If you already use rtk, one command brings over what can be brought over and stops commands from going through two hooks:
303
-
304
- ```sh
305
- tkr migrate rtk # show the plan, then ask before changing anything
306
- tkr migrate rtk --dry-run # only show the plan
307
- tkr migrate rtk --yes # apply without asking
308
- tkr migrate rtk --undo # put back every file the migrations changed, newest first
310
+ ```bash
311
+ tkr filters test # run the inline tests, exit 1 on failure
312
+ tkr filters trust # after review: records the file's SHA-256 and starts using it
309
313
  ```
310
314
 
311
- - **Filters.** rtk's global `filters.toml` (`~/.config/rtk/` on Linux, `~/Library/Application Support/rtk/` on macOS, `%APPDATA%\rtk\` on Windows) and the project's `.rtk/filters.toml` become files in `~/.tokmizer/filters/`. Their `[[tests]]` run again on Tokmizer and each result is printed. A filter that uses an option Tokmizer filters do not have (`replace`, `match_output`, `keep_lines_matching`, `head_lines`, `tail_lines`, `filter_stderr`) is not imported, and the plan says why. A file rtk had trusted stays trusted; the others, and project files (Tokmizer filters apply in every project), wait for `tkr filters trust`.
312
- - **Settings.** From `config.toml`: `exclude_commands` (the output of those commands is left unchanged), the `rtk recall` retention or its `disabled` mode (`~/.tokmizer/restore.json`), and telemetry turned off (`tkr telemetry off`). Every other setting is listed as not imported.
313
- - **History.** The totals in rtk's `history.db` are read without changing it. `tkr gain` shows them on their own "Imported from rtk" line, never added to the savings Tokmizer measured. An unreadable file is skipped.
314
- - **Agent hooks.** For each agent where both rtk and Tokmizer are installed (Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Factory Droid, Trae, Mistral Vibe, Antigravity, OpenCode, Pi, Oh My Pi), the rtk hook is removed so commands are not wrapped twice. Where Tokmizer is not installed yet, the rtk hook stays and the plan says which `tkr setup-…` to run first. rtk's own proxy setting (`ANTHROPIC_BASE_URL`) is left alone. `tkr doctor` reports any agent where both still hook the same commands.
315
+ An edited file stops being used until you trust it again. Also available: `strip_ansi`, `keep_failures`, `truncate_lines_at` and `priority`. `tkr doctor` shows what loaded and why something was skipped.
315
316
 
316
- Every changed file is backed up under `~/.tokmizer/migrate-rtk/`. Running `--yes` again changes only what is new since the last migration and says `Already migrated` when nothing is; `--undo` reverts every migration still in place, newest first, and does not overwrite a file you changed after the migration: it tells you where its backup is.
317
+ ## Coming from rtk
317
318
 
318
- `tkr migrate rtk --shim` also adds an `rtk` command to `~/.tokmizer/shims` for scripts and habits: `rtk gain` runs `tkr gain`, `rtk recall <hash>` runs `tkr restore <hash>`, `rtk bypass <cmd>` (or `rtk proxy <cmd>`) runs the command unchanged, and any other subcommand explains what to run instead. It takes over once rtk itself is uninstalled and `~/.tokmizer/shims` is on your `PATH`.
319
-
320
- ## Distribution
321
-
322
- This README is shared by the npm package and the public GitHub repository.
319
+ ```bash
320
+ tkr migrate rtk --dry-run # show the plan
321
+ tkr migrate rtk # show it, ask, then apply
322
+ tkr migrate rtk --undo # put every changed file back
323
+ ```
323
324
 
324
- - The npm package includes the CLI, Claude Code hooks and command templates, the Codex manifest and the compiled compression engine.
325
- - The public repository contains the full source of the package: CLI, hooks, agent adapters, native launcher, setup commands, the TOML rule catalogue and the compression engine.
325
+ It brings over your rtk filters and runs their tests on Tokmizer, plus `exclude_commands`, the `rtk recall` retention and a telemetry opt-out. rtk's history shows on its own line in `tkr gain`. In each agent where Tokmizer is installed, rtk's hook is removed so commands are not wrapped twice. Anything that cannot be imported is listed with the reason, and every changed file is backed up in `~/.tokmizer/migrate-rtk/`. `--shim` adds an `rtk` command that forwards `rtk gain` and `rtk recall` to Tokmizer.
326
326
 
327
- ## Build from source
327
+ ## In CI
328
328
 
329
- Requirements: Node.js 20.11 or later and npm. The native launcher is optional and needs a Rust toolchain.
329
+ Add Tokmizer to Claude Code jobs that run with `anthropics/claude-code-action`:
330
330
 
331
- ```
332
- git clone https://github.com/norwelltw/Tokmizer
333
- cd Tokmizer
334
- npm install
335
- npm run build
336
- npm test
331
+ ```yaml
332
+ - id: tokmizer
333
+ uses: norwelltw/Tokmizer@main
334
+ - uses: anthropics/claude-code-action@v1
335
+ with:
336
+ plugin_marketplaces: ${{ steps.tokmizer.outputs.plugin_marketplaces }}
337
+ plugins: ${{ steps.tokmizer.outputs.plugins }}
337
338
  ```
338
339
 
339
- `npm run build` type-checks the sources and bundles them into `packages/plugin/dist/`. Run the result with `node packages/plugin/dist/bin/tkr.js help`.
340
+ Full workflow and options: [action/README.md](https://github.com/norwelltw/Tokmizer/blob/main/action/README.md).
340
341
 
341
- To build the native launcher for your platform: `npm --workspace packages/plugin run build:native`, then `npm run build` again to copy it into `dist/native/`.
342
+ ## Network and privacy
342
343
 
343
- To try your build in Claude Code, install the folder as a local plugin or link the CLI with `npm --workspace packages/plugin link`.
344
+ Tokmizer works without an account or email. It contacts `tokmizer.com` to keep its rules current and to learn which commands to optimize next. **Never sent: command arguments, command output, file contents, file paths.**
344
345
 
345
- ## Network & privacy
346
+ ```bash
347
+ tkr telemetry off # stop usage stats
348
+ tkr network off # stop every connection; compression keeps working with the built-in rules
349
+ ```
346
350
 
347
- Tokmizer works without an account or email. It contacts `tokmizer.com` to keep its rules up to date and to improve the product. One command turns all of it off: `tkr network off`.
351
+ `TOKMIZER_NETWORK=0` does the same for one shell or a CI job. Rules and commands downloaded from `tokmizer.com` are signed and checked against a key pinned in the CLI.
348
352
 
349
- What leaves your machine, and when:
353
+ <details>
354
+ <summary>Exactly what leaves your machine</summary>
350
355
 
351
356
  | When | What is sent | Why |
352
- |---|---|---|
353
- | First online run, no account | A random install ID, your computer name, OS and version, CPU model and core count, a SHA-256 hash of your network card (MAC) address, a SHA-256 hash of your user name, a fingerprint (SHA-256 of all of these), your time zone and the plugin version | Create the install token used to download rules |
354
- | `tkr link <key>` | The same, plus your key, and your email only if you pass `--email` | Attach this machine to your account |
355
- | Regular check-in (heartbeat) | Install ID, fingerprint, plugin version, local date and time zone; while usage stats are on, also install health counts, for example outdated shims, broken hooks, repairs and commands that ran without Tokmizer because its files were missing | Refresh access, learn that a new version is out and spot broken installs |
356
- | Rule downloads | Install ID, fingerprint, plugin version | Get the latest compression rules and the `/power` and reducer instructions |
357
- | Settings sync, linked accounts only | Your Tokmizer settings | Keep them in sync with the dashboard |
358
- | Usage stats, only while they are on (with or without an account) | Command names such as `npm install` (never arguments; Git and GitHub commands only as the tool and its action, such as `git push` or `gh pr`), token counts, rule IDs with output sizes, session ID, agent name | See which commands to optimize next |
359
- | `tkr unlink` | Install ID, fingerprint | Remove this device from your account |
360
- | CLI self-update, after a check-in reports a new version | Runs `npm i -g @tokmizer/plugin@<version>` or `brew upgrade tokmizer`, which contact the npm registry, Homebrew and GitHub | Keep the CLI current (`tkr auto-update off` stops only this) |
361
-
362
- The hashes are not anonymous: the same machine always gives the same values, and a user name hash can be guessed. Like any web server, `tokmizer.com` sees your IP address and keeps it in its security log. Tokmizer never sends command arguments, command output, file contents or file paths.
363
-
364
- Usage stats are on by default and off in one command: `tkr telemetry off` (or `tkr network off` to stop every connection). The choice is saved on this machine and survives updates; an install that turned them off stays off. Before anything is sent, Tokmizer says so once, in the terminal or in the Claude Code session notice. Check with `tkr telemetry status`.
365
-
366
- ### Usage stats without an account
357
+ | --- | --- | --- |
358
+ | First online run | A random install ID, computer name, OS and version, CPU model and core count, SHA-256 hashes of your network card address and user name, a fingerprint of these, your time zone and the plugin version | create the install token used to download rules |
359
+ | `tkr link <key>` | The same, plus your key, and your email only with `--email` | attach this machine to your account |
360
+ | Check-in (heartbeat) | Install ID, fingerprint, plugin version, local date and time zone; while usage stats are on, install health counts such as outdated shims, broken hooks and repairs | refresh access, announce new versions, spot broken installs |
361
+ | Rule downloads | Install ID, fingerprint, plugin version | latest rules, `/power` and reducer instructions |
362
+ | Settings sync, linked accounts only | Your Tokmizer settings | keep them in sync with the dashboard |
363
+ | Usage stats, only while on | Command names such as `npm install` (never arguments), token counts, rule IDs with output sizes, session ID, agent name | see which commands to optimize next |
364
+ | `tkr unlink` | Install ID, fingerprint | remove this device from your account |
365
+ | Self-update | `npm i -g @tokmizer/plugin@<version>` or `brew upgrade tokmizer` | keep the CLI current; `tkr auto-update off` stops it |
367
366
 
368
- Usage stats do not need an account. Without one, they are stored against this install's random key, not against an email or a person. They are still not anonymous: the computer name and the other device details listed above are sent when the install registers and are kept with that key.
367
+ The hashes are not anonymous: the same machine always gives the same values, and a user name hash can be guessed. Like any web server, `tokmizer.com` sees your IP address and keeps it in its security log. Usage stats are on by default; Tokmizer says so once before anything is sent, and turning them off survives updates. Detailed rows are kept 90 days, then only a running total. With the network off, Tokmizer uses the last downloaded rules for up to 7 days, then the rules built into the CLI. `tkr network off` does not cover Claude Code's own marketplace auto-update. Full policy: [tokmizer.com/en/privacy](https://tokmizer.com/en/privacy).
369
368
 
370
- - **Sent:** for each command, its name, the token count before compression, tokens saved and restored, whether it was compressed, the session ID and the agent name. Never arguments, output, file contents or paths.
371
- - **Only with your consent:** the plugin uploads them only while `tkr telemetry status` says `on`, and tells the server so with each upload. Nothing is accepted from an install that is off or whose network is off.
372
- - **Once per install, before the first upload:** Tokmizer says so once (first run, setup, session start or upgrade) and sends nothing until that notice has been shown, then stays quiet.
373
- - **Kept:** detailed rows for 90 days, then only a running total of tokens saved per key.
374
- - **Linking later:** `tkr link` moves the install's past usage stats to your account, so your dashboard includes them.
375
- - **Turn off:** `tkr telemetry off`. To stop every connection: `tkr network off`.
369
+ </details>
376
370
 
377
- ### Turn the network off
371
+ ## Uninstall
378
372
 
379
373
  ```bash
380
- tkr network off # nothing leaves this machine
381
- tkr network status
382
- tkr network on
374
+ tkr uninstall # every hook, shim, PATH line, /power and reducer block Tokmizer added
375
+ npm uninstall -g @tokmizer/plugin # or: brew uninstall tokmizer
383
376
  ```
384
377
 
385
- In CI or for one shell, set `TOKMIZER_NETWORK=0`. `tkr status` and `tkr doctor` show the current state.
386
-
387
- While it is off there is no sign-up, heartbeat, rule download, settings sync, usage stats or update check. Tokmizer keeps compressing locally: with the last downloaded rules for up to 7 days, then with the rules built into the CLI. Settings are saved on this machine only. `tkr link` and `tkr heartbeat` explain how to turn the network back on.
378
+ In Claude Code: `/plugin uninstall tokmizer@tokmizer`. Your savings history stays in `~/.tokmizer` until you delete it. To pause without uninstalling: `tkr settings set enabled false`.
388
379
 
389
- The switch does not cover Claude Code's own marketplace auto-update, which `/tkr-update` turns on (set `extraKnownMarketplaces.tokmizer.autoUpdate` to `false` in `~/.claude/settings.json` to stop it), nor commands you run yourself such as the installer, `/tkr-update`, npm or brew.
390
-
391
- ### Local data
392
-
393
- - Restoration copies are local and kept up to 30 days. A restore hint identifies available cached content; there is no guarantee that every removed detail has a saved copy. YOLO creates no new restoration copies.
394
- - The [redaction helpers](https://github.com/norwelltw/Tokmizer/blob/main/packages/plugin/src/learn/redact.ts) are available for inspection, like the rest of the source.
395
- - Local state lives in `~/.tokmizer/`.
380
+ ## Build from source
396
381
 
397
- ## Uninstall
382
+ Node.js 20.11+ and npm. The optional native launcher needs Rust.
398
383
 
399
384
  ```bash
400
- tkr uninstall
385
+ git clone https://github.com/norwelltw/Tokmizer
386
+ cd Tokmizer
387
+ npm install
388
+ npm run build
389
+ npm test
390
+ node packages/plugin/dist/bin/tkr.js help
401
391
  ```
402
392
 
403
- `tkr uninstall` removes every hook, shim and PATH line Tokmizer added, `/power` and the reducer in the other agents, and the config backups. It does not remove the program itself. Then run the command for the way you installed it:
393
+ Native launcher: `npm --workspace packages/plugin run build:native`, then `npm run build` again. To try your build in Claude Code, install the folder as a local plugin or run `npm --workspace packages/plugin link`. The `tokmizer.com` service (accounts, rule downloads, telemetry) is not part of this repository.
404
394
 
405
- ```bash
406
- npm uninstall -g @tokmizer/plugin
407
- brew uninstall tokmizer
408
- ```
395
+ ## Licence
409
396
 
410
- In Claude Code: `/plugin uninstall tokmizer@tokmizer`. Your savings history stays in `~/.tokmizer` until you delete that folder. To pause Tokmizer without uninstalling: `tkr settings set enabled false`.
397
+ Apache-2.0, except the compression engine (`packages/plugin/src/engine/`) and the rule catalogue (`packages/plugin/filters/`), which are under the Business Source License 1.1. Production use is allowed, including inside your own tools; offering them as part of a competing token-optimization product or hosted service is not. Each release becomes Apache-2.0 four years after it ships. Rules you write yourself stay yours. Details: [LICENSES.md](https://github.com/norwelltw/Tokmizer/blob/main/packages/plugin/LICENSES.md).
411
398
 
412
- ## License
399
+ ## Bugs and security
413
400
 
414
- Apache-2.0, except the compression engine in `src/engine/` and the rule catalogue in `filters/`, which are under the Business Source License 1.1 and become Apache-2.0 four years after each release. Production use is allowed, including inside your own tools; offering the engine or the rules as part of a competing token-optimization product or hosted service is not. Rules you write yourself stay yours. See [LICENSES.md](LICENSES.md), [LICENSE](LICENSE), [LICENSE-ENGINE](LICENSE-ENGINE) and [NOTICE](NOTICE).
401
+ Found a bug? [Open an issue](https://github.com/norwelltw/Tokmizer/issues/new/choose). You can suggest a fix in it; the maintainer reviews and applies changes, see [CONTRIBUTING.md](https://github.com/norwelltw/Tokmizer/blob/main/CONTRIBUTING.md). Security reports: [SECURITY.md](https://github.com/norwelltw/Tokmizer/blob/main/SECURITY.md).