@tokmizer/plugin 0.9.60 → 0.9.62
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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/LICENSE +176 -0
- package/LICENSE-ENGINE +107 -0
- package/LICENSES.md +29 -0
- package/NOTICE +18 -0
- package/README.md +66 -19
- package/THIRD-PARTY-NOTICES.md +446 -0
- package/command-templates/tkr-status.md +1 -1
- package/dist/bin/tkr-codex-hook.js +4 -4
- package/dist/bin/tkr-daemon.js +58 -58
- package/dist/bin/tkr-exec +35 -35
- package/dist/bin/tkr-exec.js +35 -35
- package/dist/bin/tkr-processor.js +4 -4
- package/dist/bin/tkr-shim.js +4 -4
- package/dist/bin/tkr.js +85 -85
- package/dist/hooks-host/command-expansion.js +3 -0
- package/dist/hooks-host/post-tool-use.js +4 -4
- package/dist/hooks-host/pre-tool-use.js +5 -5
- package/dist/hooks-host/reducer-stop.js +13 -13
- package/dist/hooks-host/session-recap.js +1 -1
- package/dist/index.js +4 -4
- package/dist/native/manifest.json +12 -12
- package/dist/native/single.json +12 -12
- package/dist/native/tkr-exec-darwin-arm64 +0 -0
- package/dist/native/tkr-exec-darwin-x64 +0 -0
- package/dist/native/tkr-exec-linux-arm64 +0 -0
- package/dist/native/tkr-exec-linux-x64 +0 -0
- package/dist/native/tkr-exec-win32-arm64.exe +0 -0
- package/dist/native/tkr-exec-win32-x64.exe +0 -0
- package/hooks/hooks.json +12 -0
- package/package.json +13 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/LICENSE-ENGINE
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
5
|
+
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Impulse Creation
|
|
11
|
+
|
|
12
|
+
Licensed Work: Tokmizer compression engine and rule catalogue, version
|
|
13
|
+
as published: the contents of the src/engine/ and
|
|
14
|
+
filters/ directories of the @tokmizer/plugin package
|
|
15
|
+
and its source repository, including the default
|
|
16
|
+
rules built from filters/ and embedded in the
|
|
17
|
+
compiled package.
|
|
18
|
+
The Licensed Work is (c) 2026 Impulse Creation.
|
|
19
|
+
|
|
20
|
+
Additional Use Grant: You may make production use of the Licensed Work,
|
|
21
|
+
without charge, including as a component of the
|
|
22
|
+
Tokmizer command-line tools, hooks and plugins, and
|
|
23
|
+
inside your own internal tools and workflows. This
|
|
24
|
+
grant does not permit offering the Licensed Work, or a
|
|
25
|
+
derivative of it (including the engine or the rules,
|
|
26
|
+
alone or together), to third parties as part of a
|
|
27
|
+
product or service, paid or hosted, whose purpose is
|
|
28
|
+
to reduce, compress or optimize the tokens or the
|
|
29
|
+
context sent to AI models and that competes with
|
|
30
|
+
Tokmizer. For such use, contact contact@tokmizer.com.
|
|
31
|
+
|
|
32
|
+
Change Date: Four years after the date on which this version of
|
|
33
|
+
the Licensed Work is first publicly distributed by the
|
|
34
|
+
Licensor (for a version first distributed on
|
|
35
|
+
2026-10-15, the Change Date is 2030-10-15)
|
|
36
|
+
|
|
37
|
+
Change License: Apache License, Version 2.0
|
|
38
|
+
|
|
39
|
+
For information about alternative licensing arrangements for the Licensed
|
|
40
|
+
Work, please contact contact@tokmizer.com.
|
|
41
|
+
|
|
42
|
+
-----------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
Terms
|
|
45
|
+
|
|
46
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
47
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
48
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
49
|
+
production use.
|
|
50
|
+
|
|
51
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
52
|
+
available distribution of a specific version of the Licensed Work under this
|
|
53
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
54
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
55
|
+
above terminate.
|
|
56
|
+
|
|
57
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
58
|
+
currently in effect as described in this License, you must purchase a
|
|
59
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
60
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
61
|
+
|
|
62
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
63
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
64
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
65
|
+
for each version of the Licensed Work released by Licensor.
|
|
66
|
+
|
|
67
|
+
You must conspicuously display this License on each original or modified copy
|
|
68
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
69
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
70
|
+
License apply to your use of that work.
|
|
71
|
+
|
|
72
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
73
|
+
terminate your rights under this License for the current and all other
|
|
74
|
+
versions of the Licensed Work.
|
|
75
|
+
|
|
76
|
+
This License does not grant you any right in any trademark or logo of
|
|
77
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
78
|
+
Licensor as expressly required by this License).
|
|
79
|
+
|
|
80
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
81
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
82
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
83
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
84
|
+
TITLE.
|
|
85
|
+
|
|
86
|
+
-----------------------------------------------------------------------------
|
|
87
|
+
|
|
88
|
+
Covenants of Licensor
|
|
89
|
+
|
|
90
|
+
In consideration of the right to use this License's text and the "Business
|
|
91
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
92
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
93
|
+
|
|
94
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
95
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
96
|
+
where "compatible" means that software provided under the Change License can
|
|
97
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
98
|
+
later version. Licensor may specify additional Change Licenses without
|
|
99
|
+
limitation.
|
|
100
|
+
|
|
101
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
102
|
+
impose any additional restriction on the right granted in this License, as
|
|
103
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
104
|
+
|
|
105
|
+
3. To specify a Change Date.
|
|
106
|
+
|
|
107
|
+
4. Not to modify this License in any other way.
|
package/LICENSES.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Licences
|
|
2
|
+
|
|
3
|
+
Tokmizer uses two licences, split by directory. No source file carries a licence header: the directory decides.
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Impulse Creation, the copyright holder and the Licensor named in the BUSL-1.1 files.
|
|
6
|
+
|
|
7
|
+
| Path | Licence | Text |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `src/engine/**` (compression engine: pipeline, routing, matcher, filter schema and loader, transforms, structured compaction, test-failure folding) | BUSL-1.1, converts to Apache-2.0 on the Change Date | [`src/engine/LICENSE`](src/engine/LICENSE) |
|
|
10
|
+
| `filters/**` (TOML rule catalogue), including the default rules built from it and embedded in `dist/` | BUSL-1.1, same Licensed Work as the engine | [`filters/LICENSE`](filters/LICENSE) |
|
|
11
|
+
| Everything else: CLI (`src/bin`, `src/*.ts`), hooks (`hooks/`, `src/hooks-host`), agent adapters (`src/adapters`, `agent-plugins/`), daemon, launcher and shims (`src/daemon`, `src/exec`, `src/shim`), native launcher (`native/`), setup commands (`command-templates/`, `codex-plugin/`, `.claude-plugin/`, install scripts), tests and fixtures (`src/__tests__`), build scripts (`scripts/`) and documentation | Apache-2.0 | [`LICENSE`](LICENSE) |
|
|
12
|
+
| `dist/` and the npm package `@tokmizer/plugin` | `Apache-2.0 AND BUSL-1.1`: the bundled files contain code and rules under both licences | both texts above |
|
|
13
|
+
| Third-party code bundled into `dist/` and into the native launcher | its own licence | [`THIRD-PARTY-NOTICES.md`](THIRD-PARTY-NOTICES.md) |
|
|
14
|
+
|
|
15
|
+
The BUSL-1.1 text is the same file in `src/engine/LICENSE`, `filters/LICENSE` and, at the root, [`LICENSE-ENGINE`](LICENSE-ENGINE).
|
|
16
|
+
|
|
17
|
+
## What BUSL-1.1 allows here
|
|
18
|
+
|
|
19
|
+
You can read, copy, modify and redistribute the engine and the rules, and use them in production, including inside the Tokmizer CLI, hooks and plugins and in your own internal tools. You cannot offer the engine or the rules, alone or together, or a derivative of them, to third parties as part of a product or service that reduces, compresses or optimizes AI-model tokens or context and competes with Tokmizer. The exact terms are in [`LICENSE-ENGINE`](LICENSE-ENGINE).
|
|
20
|
+
|
|
21
|
+
Each published version becomes Apache-2.0 on its Change Date: four years after that version's first public release, or earlier if the licence file of that version says so.
|
|
22
|
+
|
|
23
|
+
## Your own rules
|
|
24
|
+
|
|
25
|
+
Rules you write yourself, in your project or user configuration, are yours. Writing or reading rules in the same TOML format with your own tools needs no licence from us; only the engine source and the rule catalogue published here are BUSL-1.1.
|
|
26
|
+
|
|
27
|
+
## Contributions
|
|
28
|
+
|
|
29
|
+
Contributions are accepted under the Tokmizer Contributor License Agreement, which grants Impulse Creation the right to distribute them under the licence of the directory they change and under other licences, including commercial ones. The agreement is `CLA.md` at the root of the public repository; the process is described in its `CONTRIBUTING.md`.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Tokmizer
|
|
2
|
+
Copyright 2026 Impulse Creation
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE),
|
|
5
|
+
except the compression engine in src/engine/ and the rule catalogue in
|
|
6
|
+
filters/, which are licensed under the Business Source License 1.1 (see
|
|
7
|
+
LICENSE-ENGINE, src/engine/LICENSE and filters/LICENSE).
|
|
8
|
+
LICENSES.md maps each directory to its licence.
|
|
9
|
+
|
|
10
|
+
The TOML filter rule format and parts of the rule catalogue in filters/
|
|
11
|
+
(rule names, some descriptions and some line patterns) are derived from rtk
|
|
12
|
+
(https://github.com/rtk-ai/rtk), Copyright Patrick Szymkowiak and the rtk
|
|
13
|
+
contributors, licensed under the Apache License, Version 2.0. Those derived
|
|
14
|
+
portions remain available under the Apache License, Version 2.0; the
|
|
15
|
+
Business Source License 1.1 applies to the changes and additions made here.
|
|
16
|
+
|
|
17
|
+
The npm package and the native launcher bundle third-party software. Their
|
|
18
|
+
copyright notices and licence texts are reproduced in THIRD-PARTY-NOTICES.md.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Tokmizer
|
|
2
2
|
|
|
3
|
-
Tokmizer reduces token consumption for AI coding
|
|
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.
|
|
4
4
|
|
|
5
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 guarantee of a lower bill or faster coding, rendering, or builds.
|
|
6
6
|
|
|
@@ -15,7 +15,14 @@ In Claude Code:
|
|
|
15
15
|
|
|
16
16
|
Then restart Claude Code once, hooks only load at startup. Verify with `/tkr-status`, you should see Status active.
|
|
17
17
|
|
|
18
|
-
Any other
|
|
18
|
+
Any other agent: install the CLI with npm (Node.js 20.11 or newer), then set up every agent found on this machine:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g @tokmizer/plugin
|
|
22
|
+
tkr setup --all
|
|
23
|
+
```
|
|
24
|
+
|
|
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`.
|
|
19
26
|
|
|
20
27
|
```bash
|
|
21
28
|
curl -fsSL https://tokmizer.com/install.sh | bash
|
|
@@ -25,7 +32,7 @@ Windows (PowerShell):
|
|
|
25
32
|
|
|
26
33
|
```powershell
|
|
27
34
|
npm.cmd install -g @tokmizer/plugin
|
|
28
|
-
tkr.cmd
|
|
35
|
+
tkr.cmd setup --all
|
|
29
36
|
```
|
|
30
37
|
|
|
31
38
|
See the [installation guide](https://tokmizer.com/en/docs#installation) for per-tool notes.
|
|
@@ -36,7 +43,7 @@ Codex, after installing with npm or Homebrew:
|
|
|
36
43
|
tkr setup-codex
|
|
37
44
|
```
|
|
38
45
|
|
|
39
|
-
Restart Codex, then approve the hook in `/hooks`.
|
|
46
|
+
Restart Codex, then approve the hook in `/hooks`. `tkr setup --all` includes Codex.
|
|
40
47
|
|
|
41
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.
|
|
42
49
|
|
|
@@ -93,7 +100,9 @@ Each command adds one `PreToolUse` hook for the agent's shell tool. It rewrites
|
|
|
93
100
|
|
|
94
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.
|
|
95
102
|
|
|
96
|
-
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.
|
|
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. When commands are rewritten, failing output is shortened too, with its failure details kept.
|
|
104
|
+
|
|
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.
|
|
97
106
|
|
|
98
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):
|
|
99
108
|
|
|
@@ -111,10 +120,10 @@ Homebrew:
|
|
|
111
120
|
|
|
112
121
|
```bash
|
|
113
122
|
brew install norwelltw/tokmizer/tokmizer
|
|
114
|
-
tkr
|
|
123
|
+
tkr setup --all
|
|
115
124
|
```
|
|
116
125
|
|
|
117
|
-
Node.js
|
|
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.
|
|
118
127
|
|
|
119
128
|
## Free access
|
|
120
129
|
|
|
@@ -139,7 +148,7 @@ In Claude Code:
|
|
|
139
148
|
- `/tkr-telemetry` views or changes usage stats (command names and token counts; on by default, off in one command)
|
|
140
149
|
- `/tkr-update` updates the plugin when a new version is out
|
|
141
150
|
|
|
142
|
-
From any terminal (after
|
|
151
|
+
From any terminal (after installing with npm, the install script or Homebrew):
|
|
143
152
|
|
|
144
153
|
- `tkr status` shows your account and engine status
|
|
145
154
|
- `tkr gain` shows the estimated reduction in command-output tokens
|
|
@@ -151,6 +160,9 @@ From any terminal (after the shell-shim install, or `npm install -g @tokmizer/pl
|
|
|
151
160
|
- `tkr settings show|set|configure` manages settings and syncs them across your machines
|
|
152
161
|
- `tkr network off|on|status` blocks or allows every connection to tokmizer.com
|
|
153
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))
|
|
154
166
|
|
|
155
167
|
## /power and the reducer in other agents
|
|
156
168
|
|
|
@@ -187,7 +199,7 @@ Never overwritten: an existing `power` command or skill that Tokmizer did not wr
|
|
|
187
199
|
|
|
188
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.
|
|
189
201
|
|
|
190
|
-
|
|
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.
|
|
191
203
|
|
|
192
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.
|
|
193
205
|
|
|
@@ -212,7 +224,7 @@ Terminal commands managed by Tokmizer use the mode selected when execution start
|
|
|
212
224
|
|
|
213
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 your actual bill or a measure of task quality or completion speed.
|
|
214
226
|
|
|
215
|
-
|
|
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.
|
|
216
228
|
|
|
217
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`.
|
|
218
230
|
|
|
@@ -236,7 +248,7 @@ Entries are kept 30 days, up to 8 MB each and 200 MB in total; the oldest go fir
|
|
|
236
248
|
|
|
237
249
|
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.
|
|
238
250
|
|
|
239
|
-
These are historical results for the earlier mode behavior, not measurements of the
|
|
251
|
+
These are historical results for the earlier mode behavior, not measurements of the Light read policy introduced in 0.9.54.
|
|
240
252
|
|
|
241
253
|
| Mode | Output tokens | Preservation checks passed |
|
|
242
254
|
| --- | ---: | ---: |
|
|
@@ -255,6 +267,10 @@ In a separate controlled test for 0.9.52, a repetitive failure log went from 1,0
|
|
|
255
267
|
|
|
256
268
|
These tokenizer counts are separate from the byte-based estimates in `tkr gain`. They measure output volume, not your bill, an agent's task success, or execution speed. See the [mode guide](https://tokmizer.com/en/docs#configuration) for usage and limits.
|
|
257
269
|
|
|
270
|
+
### Benchmark of October 17, 2026
|
|
271
|
+
|
|
272
|
+
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 plain `Bash` allow rule); rtk removed 55%. All 307 failure details were kept in both Tokmizer modes. The full results are on [tokmizer.com/en/compare/rtk](https://tokmizer.com/en/compare/rtk).
|
|
273
|
+
|
|
258
274
|
## Custom filters
|
|
259
275
|
|
|
260
276
|
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.
|
|
@@ -304,10 +320,26 @@ Every changed file is backed up under `~/.tokmizer/migrate-rtk/`. Running `--yes
|
|
|
304
320
|
|
|
305
321
|
This README is shared by the npm package and the public GitHub repository.
|
|
306
322
|
|
|
307
|
-
- The npm package includes the CLI, Claude Code hooks and command templates, and the
|
|
308
|
-
- The public repository contains
|
|
323
|
+
- The npm package includes the CLI, Claude Code hooks and command templates, the Codex manifest and the compiled compression engine.
|
|
324
|
+
- 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
|
+
|
|
326
|
+
## Build from source
|
|
309
327
|
|
|
310
|
-
|
|
328
|
+
Requirements: Node.js 20.11 or later and npm. The native launcher is optional and needs a Rust toolchain.
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
git clone https://github.com/norwelltw/Tokmizer
|
|
332
|
+
cd Tokmizer
|
|
333
|
+
npm install
|
|
334
|
+
npm run build
|
|
335
|
+
npm test
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
`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`.
|
|
339
|
+
|
|
340
|
+
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/`.
|
|
341
|
+
|
|
342
|
+
To try your build in Claude Code, install the folder as a local plugin or link the CLI with `npm --workspace packages/plugin link`.
|
|
311
343
|
|
|
312
344
|
## Network & privacy
|
|
313
345
|
|
|
@@ -319,10 +351,10 @@ What leaves your machine, and when:
|
|
|
319
351
|
|---|---|---|
|
|
320
352
|
| 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 |
|
|
321
353
|
| `tkr link <key>` | The same, plus your key, and your email only if you pass `--email` | Attach this machine to your account |
|
|
322
|
-
| Regular check-in (heartbeat) | Install ID, fingerprint, plugin version, local date and time zone | Refresh access
|
|
354
|
+
| 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 |
|
|
323
355
|
| Rule downloads | Install ID, fingerprint, plugin version | Get the latest compression rules and the `/power` and reducer instructions |
|
|
324
356
|
| Settings sync, linked accounts only | Your Tokmizer settings | Keep them in sync with the dashboard |
|
|
325
|
-
| Usage stats, only while they are on (with or without an account) | Command names such as `npm install` (never arguments; Git and GitHub commands
|
|
357
|
+
| 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 |
|
|
326
358
|
| `tkr unlink` | Install ID, fingerprint | Remove this device from your account |
|
|
327
359
|
| 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) |
|
|
328
360
|
|
|
@@ -351,16 +383,31 @@ tkr network on
|
|
|
351
383
|
|
|
352
384
|
In CI or for one shell, set `TOKMIZER_NETWORK=0`. `tkr status` and `tkr doctor` show the current state.
|
|
353
385
|
|
|
354
|
-
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
|
|
386
|
+
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.
|
|
355
387
|
|
|
356
388
|
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.
|
|
357
389
|
|
|
358
390
|
### Local data
|
|
359
391
|
|
|
360
392
|
- 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.
|
|
361
|
-
- The
|
|
393
|
+
- 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.
|
|
362
394
|
- Local state lives in `~/.tokmizer/`.
|
|
363
395
|
|
|
396
|
+
## Uninstall
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
tkr uninstall
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
`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:
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
npm uninstall -g @tokmizer/plugin
|
|
406
|
+
brew uninstall tokmizer
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
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`.
|
|
410
|
+
|
|
364
411
|
## License
|
|
365
412
|
|
|
366
|
-
|
|
413
|
+
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).
|