anolisa-tokenless 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +770 -0
- package/adapters/tokenless/claude-code/.claude-plugin/marketplace.json +15 -0
- package/adapters/tokenless/claude-code/.claude-plugin/plugin.json +9 -0
- package/adapters/tokenless/claude-code/hooks/hooks.json +38 -0
- package/adapters/tokenless/claude-code/scripts/detect.sh +193 -0
- package/adapters/tokenless/claude-code/scripts/install.sh +92 -0
- package/adapters/tokenless/claude-code/scripts/uninstall.sh +50 -0
- package/adapters/tokenless/codex/.codex-plugin/plugin.json +20 -0
- package/adapters/tokenless/codex/README.md +160 -0
- package/adapters/tokenless/codex/hooks/hooks.json +52 -0
- package/adapters/tokenless/codex/scripts/_common.sh +25 -0
- package/adapters/tokenless/codex/scripts/check-tokenless +94 -0
- package/adapters/tokenless/codex/scripts/compress-response +441 -0
- package/adapters/tokenless/codex/scripts/detect.sh +61 -0
- package/adapters/tokenless/codex/scripts/install.sh +151 -0
- package/adapters/tokenless/codex/scripts/rewrite-hook +282 -0
- package/adapters/tokenless/codex/scripts/tool-ready +303 -0
- package/adapters/tokenless/codex/scripts/uninstall.sh +78 -0
- package/adapters/tokenless/common/commands/tokenless-stats.toml +2 -0
- package/adapters/tokenless/common/cosh-extension.json +65 -0
- package/adapters/tokenless/common/hooks/compress_response_hook.py +487 -0
- package/adapters/tokenless/common/hooks/compress_schema_hook.py +144 -0
- package/adapters/tokenless/common/hooks/compress_toon_hook.py +160 -0
- package/adapters/tokenless/common/hooks/hook_utils.py +584 -0
- package/adapters/tokenless/common/hooks/rewrite_hook.py +223 -0
- package/adapters/tokenless/common/hooks/run-hook.sh +62 -0
- package/adapters/tokenless/common/hooks/tool_categories.json +99 -0
- package/adapters/tokenless/common/hooks/tool_ready_hook.sh +571 -0
- package/adapters/tokenless/common/tokenless-env-fix.sh +730 -0
- package/adapters/tokenless/common/tool-ready-spec.json +113 -0
- package/adapters/tokenless/dsh/cordis.patch.yml +8 -0
- package/adapters/tokenless/dsh/dist/index.js +399 -0
- package/adapters/tokenless/dsh/package.json +26 -0
- package/adapters/tokenless/hermes/__init__.py +572 -0
- package/adapters/tokenless/hermes/plugin.yaml +9 -0
- package/adapters/tokenless/hermes/scripts/detect.sh +80 -0
- package/adapters/tokenless/hermes/scripts/install.sh +60 -0
- package/adapters/tokenless/hermes/scripts/uninstall.sh +45 -0
- package/adapters/tokenless/manifest.json +147 -0
- package/adapters/tokenless/openclaw/dist/index.d.ts +27 -0
- package/adapters/tokenless/openclaw/dist/index.js +598 -0
- package/adapters/tokenless/openclaw/dist/tool_categories.json +99 -0
- package/adapters/tokenless/openclaw/index.ts +720 -0
- package/adapters/tokenless/openclaw/openclaw.plugin.json +40 -0
- package/adapters/tokenless/openclaw/package.json +24 -0
- package/adapters/tokenless/openclaw/scripts/detect.sh +102 -0
- package/adapters/tokenless/openclaw/scripts/install.sh +75 -0
- package/adapters/tokenless/openclaw/scripts/uninstall.sh +46 -0
- package/adapters/tokenless/openclaw/tsconfig.json +13 -0
- package/adapters/tokenless/opencode/plugin.js +246 -0
- package/adapters/tokenless/opencode/scripts/detect.sh +38 -0
- package/adapters/tokenless/opencode/scripts/install.sh +56 -0
- package/adapters/tokenless/opencode/scripts/uninstall.sh +29 -0
- package/adapters/tokenless/qoder/.qoder-plugin/plugin.json +11 -0
- package/adapters/tokenless/qoder/commands/tokenless-stats.md +8 -0
- package/adapters/tokenless/qoder/hooks/hooks.json +36 -0
- package/adapters/tokenless/qoder/hooks/run-hook.sh +51 -0
- package/adapters/tokenless/qoder/scripts/detect.sh +35 -0
- package/adapters/tokenless/qoder/scripts/install.sh +136 -0
- package/adapters/tokenless/qoder/scripts/uninstall.sh +106 -0
- package/adapters/tokenless/qwencode/qwen-extension.json +69 -0
- package/adapters/tokenless/qwencode/scripts/detect.sh +125 -0
- package/adapters/tokenless/qwencode/scripts/install.sh +128 -0
- package/adapters/tokenless/qwencode/scripts/uninstall.sh +62 -0
- package/bin/rtk +6 -0
- package/bin/tokenless +6 -0
- package/bin/toon +6 -0
- package/package.json +57 -0
- package/scripts/postinstall.js +208 -0
package/README.md
ADDED
|
@@ -0,0 +1,770 @@
|
|
|
1
|
+
# Token-Less
|
|
2
|
+
|
|
3
|
+
[中文版](README_zh.md)
|
|
4
|
+
|
|
5
|
+
**LLM token optimization toolkit** — schema/response compression + command rewriting + tool environment readiness.
|
|
6
|
+
|
|
7
|
+
Token-Less combines complementary strategies to minimize LLM token consumption:
|
|
8
|
+
|
|
9
|
+
- **Schema & Response Compression** — Compresses OpenAI Function Calling tool definitions and API responses via the `tokenless-schema` library, cutting structural overhead before tokens ever reach the context window.
|
|
10
|
+
- **TOON Context Compression** — Encodes JSON responses to TOON (Token-Oriented Object Notation) format via the `toon` binary, reducing token usage by 15-40% for structured data.
|
|
11
|
+
- **Command Rewriting** — Integrates [RTK](https://github.com/rtk-ai/rtk) to filter and rewrite CLI command output, eliminating noise that would otherwise waste 60–90% of tokens.
|
|
12
|
+
- **Tool Ready (legacy, hard-disabled)** — Its pre-call dependency checks are retained in source but unconditionally bypassed while the readiness model is redesigned.
|
|
13
|
+
|
|
14
|
+
Agent adapters are available for:
|
|
15
|
+
|
|
16
|
+
- **OpenClaw plugin** — covers command rewriting, response compression, and schema compression in one plugin.
|
|
17
|
+
- **copilot-shell hook** — intercepts Shell commands via a PreToolUse hook and delegates to RTK for command rewriting + output filtering.
|
|
18
|
+
- **Hermes Agent plugin** — response compression, TOON encoding, command rewriting (block + suggest), and registered but hard-disabled Tool Ready via Hermes's native plugin system.
|
|
19
|
+
- **Qoder CLI plugin** — registered but hard-disabled Tool Ready, command rewriting, and response compression via Qoder's native hook system.
|
|
20
|
+
- **Claude Code plugin** — RTK command rewriting, response/TOON compression, and registered but hard-disabled Tool Ready via Claude Code's official plugin marketplace.
|
|
21
|
+
- **Codex plugin** — response compression, TOON encoding, registered but hard-disabled Tool Ready, and command rewriting via Codex's native hook system.
|
|
22
|
+
- **OpenCode plugin** — schema/response/TOON compression, registered but hard-disabled Tool Ready, and command rewriting via OpenCode's local plugin API.
|
|
23
|
+
- **DeepSeek Harness plugin** — native response compression and environment-error attribution through DSH's `tools/post-execute` seam.
|
|
24
|
+
|
|
25
|
+
For framework developers, the separate **AgentScope Python integration** replaces successful
|
|
26
|
+
final tool responses and provides a marker-scoped native retrieval Tool.
|
|
27
|
+
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
| Capability | Token Savings | Details |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| Schema compression | ~57% | Compresses OpenAI Function Calling tool schemas |
|
|
33
|
+
| Response compression | ~26–78% | Compresses API / tool responses (varies by content type) |
|
|
34
|
+
| Reversible compression (stash) | — | Dropped array items are stashed and retrievable via `<<tokenless:KEY>>` markers |
|
|
35
|
+
| TOON context compression | 15–40% | Encodes JSON to TOON format for LLMs |
|
|
36
|
+
| Command rewriting | 60–90% | Filters CLI output via RTK (70+ commands supported) |
|
|
37
|
+
| Tool Ready | reduces retry waste | Legacy pre-call check, auto-fix, and blocking; hard-disabled |
|
|
38
|
+
| OpenClaw plugin | — | Command rewriting ✅, Response compression ✅, Schema compression ✅ |
|
|
39
|
+
| copilot-shell hooks | — | Tool Ready ⛔ hard-disabled, Command rewriting ✅, Response compression ✅, TOON ✅, Schema compression ✅ |
|
|
40
|
+
| Hermes Agent plugin | — | Tool Ready ⛔ hard-disabled, Command rewriting ✅, Response compression ✅, TOON ✅, Schema compression ⏳ |
|
|
41
|
+
| Qoder CLI plugin | — | Tool Ready ⛔ hard-disabled, Command rewriting ✅, Response compression ✅ |
|
|
42
|
+
| Claude Code plugin | — | Tool Ready ⛔ hard-disabled, Command rewriting ✅, Response compression ✅, TOON ✅ |
|
|
43
|
+
| Codex plugin | — | Tool Ready ⛔ hard-disabled, Command rewriting ✅, Response compression ✅, TOON ✅ |
|
|
44
|
+
| OpenCode plugin | — | Tool Ready ⛔ hard-disabled, Command rewriting ✅, Schema compression ✅, Response compression ✅, TOON ✅ |
|
|
45
|
+
| DeepSeek Harness plugin | — | Response compression ✅, Environment-error attribution ✅ |
|
|
46
|
+
| AgentScope framework integration | — | Response compression ✅, Native retrieval Tool ✅ |
|
|
47
|
+
| Zero runtime deps | — | Pure Rust, single static binary |
|
|
48
|
+
|
|
49
|
+
## Applicable Scenarios & Expected Effects
|
|
50
|
+
|
|
51
|
+
tokenless only removes redundancy from **tool call responses** before they enter the LLM context; it does not touch model reasoning or conversation history. The payoff depends heavily on the share and shape of tool responses in the session.
|
|
52
|
+
|
|
53
|
+
### Where it pays off
|
|
54
|
+
|
|
55
|
+
| Workload | Primary strategy | Why |
|
|
56
|
+
|----------|-----------------|-----|
|
|
57
|
+
| Shell-heavy (build/test/triage) | Command rewriting (RTK) | `cargo`/`npm`/`go`/`pytest` output carries lots of progress/warning noise; RTK cuts 60–90% |
|
|
58
|
+
| API/fetch-heavy (REST, web_fetch) | Response compression + TOON | JSON carries debug/null/empty and syntax overhead; 26–78% compression, TOON adds 15–40% |
|
|
59
|
+
| Agents with many tools | Schema compression | Many Function Calling definitions carry verbose descriptions; ~57% |
|
|
60
|
+
| Long responses that must stay faithful | Reversible compression (Stash) | Truncated content is `retrieve`-able end-to-end lossless; thresholds can be tightened safely |
|
|
61
|
+
|
|
62
|
+
### Where it pays little or doesn't apply
|
|
63
|
+
|
|
64
|
+
- **Chat-heavy / few tool calls**: tool-response share is tiny, overall savings approach 0.
|
|
65
|
+
- **Already-short responses**: when `after >= before`, the CLI emits the original and records no stats (expected).
|
|
66
|
+
- **Model inference tokens / billed tokens**: outside what tokenless touches.
|
|
67
|
+
|
|
68
|
+
### Estimating the effect
|
|
69
|
+
|
|
70
|
+
> The shares below are **illustrative estimates** that vary widely by task, not measured constants.
|
|
71
|
+
|
|
72
|
+
| Session component | Typical share | tokenless can optimize |
|
|
73
|
+
|-----------|-------------|----------------------|
|
|
74
|
+
| LLM reasoning output (text generation) | ~35% | ❌ Not involved |
|
|
75
|
+
| LLM input (system prompt + conversation history) | ~40% | ❌ Not involved |
|
|
76
|
+
| Tool call arguments | ~5% | ❌ Not involved |
|
|
77
|
+
| **Tool responses (API returns + command output)** | **~20%** | **✅ Optimization scope** |
|
|
78
|
+
|
|
79
|
+
**Actual savings rate = reported compression rate × tool response share**
|
|
80
|
+
|
|
81
|
+
Example: dashboard shows 60% compression rate, but if tool responses account for 20% of total consumption, the actual savings rate is 60% × 20% = **12%**. This is why savings feel "lighter than a feather" in experiments consuming 15 million tokens — tokenless only optimizes the ~3 million tokens of tool responses.
|
|
82
|
+
|
|
83
|
+
> Stash makes compression **end-to-end lossless**: you can tighten truncation thresholds for higher inline savings and recover the original via the `<<tokenless:KEY>>` marker when needed, with no correctness impact. Use `TOKENLESS_COMPRESSION_ENABLED=0/1` dual runs to compare real savings.
|
|
84
|
+
> See [user manual](../../docs/user-guide/en/token-saving/tokenless/user-manual.md) for per-strategy trigger conditions.
|
|
85
|
+
|
|
86
|
+
## Architecture
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
Token-Less/
|
|
90
|
+
├── crates/tokenless-schema/ # Core library: SchemaCompressor + ResponseCompressor
|
|
91
|
+
├── crates/tokenless-ccr/ # Reversible compression stash (Compress-Cache-Retrieve)
|
|
92
|
+
├── crates/tokenless-runtime/ # Stateful in-process compression and retrieval API
|
|
93
|
+
├── crates/tokenless-cli/ # CLI binary: `tokenless` command (env-check, compress, retrieve, stats)
|
|
94
|
+
├── python/tokenless/ # PyO3 package: `anolisa_tokenless`
|
|
95
|
+
├── python/agentscope/ # Pure-Python AgentScope integration package
|
|
96
|
+
├── adapters/tokenless/ # FHS bundle for Agent plugins, hooks, and extensions
|
|
97
|
+
│ ├── manifest.json # Adapter manifest for supported Agent products
|
|
98
|
+
│ ├── common/ # Shared: hooks, spec, env-fix, commands, cosh-extension
|
|
99
|
+
│ │ ├── hooks/ # copilot-shell hooks (tool-ready + rewrite + compression)
|
|
100
|
+
│ │ ├── cosh-extension.json # copilot-shell extension manifest (references common/hooks/)
|
|
101
|
+
│ │ ├── tool-ready-spec.json # Dormant legacy dependency specification
|
|
102
|
+
│ │ ├── tokenless-env-fix.sh # Auto-fix script for missing deps
|
|
103
|
+
│ │ └── commands/ # Hook command configs
|
|
104
|
+
│ ├── openclaw/ # OpenClaw plugin + agent scripts
|
|
105
|
+
│ ├── hermes/ # Hermes Agent plugin + scripts
|
|
106
|
+
│ ├── qoder/ # Qoder CLI plugin + scripts
|
|
107
|
+
│ ├── claude-code/ # Claude Code plugin + marketplace + hooks
|
|
108
|
+
│ ├── codex/ # Codex plugin + scripts
|
|
109
|
+
│ ├── opencode/ # OpenCode local plugin + scripts
|
|
110
|
+
│ └── dsh/ # Native DeepSeek Harness bundle
|
|
111
|
+
├── third_party/rtk/ # RTK vendored source (justfile clone+patch from GitHub)
|
|
112
|
+
├── third_party/patches/ # Patches for vendored third_party sources
|
|
113
|
+
├── Makefile # Unified build system
|
|
114
|
+
└── scripts/ # Helper scripts
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Quick Start
|
|
118
|
+
|
|
119
|
+
Install the published component with the ANOLISA CLI:
|
|
120
|
+
|
|
121
|
+
The install script places `anolisa` in `~/.local/bin`, and a user-mode
|
|
122
|
+
Tokenless installation places `tokenless`, `rtk`, and `toon` in that same
|
|
123
|
+
directory. Export it once if the current shell has not picked it up yet.
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
curl -fsSL https://get.agentic-os.sh | bash
|
|
127
|
+
|
|
128
|
+
# Make the default install directory available in this shell
|
|
129
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
130
|
+
anolisa --version
|
|
131
|
+
anolisa install tokenless
|
|
132
|
+
tokenless --version
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Alinux users with the YUM repository configured may install the RPM instead:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
sudo yum install anolisa tokenless
|
|
139
|
+
sudo anolisa --install-mode system adopt tokenless
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Installing the CLI from the same YUM repository makes it available on sudo's
|
|
143
|
+
system path. `adopt` then records the directly installed RPM in system state so
|
|
144
|
+
adapter commands can use its component contract.
|
|
145
|
+
|
|
146
|
+
Current public packages support Linux x86_64/aarch64 and macOS Apple Silicon.
|
|
147
|
+
Intel macOS does not currently have a published package. The repository's npm
|
|
148
|
+
packaging sources are for release construction and are not a public
|
|
149
|
+
`anolisa-tokenless` installation route. The retained
|
|
150
|
+
`@anolisa/tokenless-darwin-x64` optional-dependency entry describes a release
|
|
151
|
+
build target; it does not indicate registry availability.
|
|
152
|
+
|
|
153
|
+
ANOLISA-managed and adopted RPM installations place the available adapters
|
|
154
|
+
without changing an Agent product's user configuration. Run these commands
|
|
155
|
+
as the user who owns that configuration, and enable only the adapter you need:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
anolisa adapter scan
|
|
159
|
+
anolisa adapter enable tokenless openclaw
|
|
160
|
+
anolisa adapter status tokenless
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
DeepSeek Harness requires at least one explicit profile name. When enabling
|
|
164
|
+
multiple profiles, pass every name in the same command; see the plugin section
|
|
165
|
+
below for the complete-set behavior. Use an enabled name when starting DSH:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
anolisa adapter enable tokenless dsh --profile <profile>
|
|
169
|
+
dsh --profile <profile>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Developers building from source can use:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Clone repo (no submodules needed)
|
|
176
|
+
git clone <repo-url>
|
|
177
|
+
cd Token-Less
|
|
178
|
+
|
|
179
|
+
# Full setup: build + install binaries + deploy all adapters
|
|
180
|
+
make setup
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The source setup installs `tokenless` to `~/.local/bin`, places the `rtk` and
|
|
184
|
+
`toon` helpers alongside it, and deploys all adapters for development.
|
|
185
|
+
|
|
186
|
+
### Build the Python runtime
|
|
187
|
+
|
|
188
|
+
Framework authors can build the in-process Python API from source:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
make python-wheel
|
|
192
|
+
python3 -m venv /tmp/tokenless-python
|
|
193
|
+
/tmp/tokenless-python/bin/pip install target/wheels/anolisa_tokenless-*.whl
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
This target requires a discoverable CPython 3.11+ development environment and
|
|
197
|
+
uses `uvx` to provision Maturin by default. Install
|
|
198
|
+
[`uv`](https://docs.astral.sh/uv/) first, or run
|
|
199
|
+
`make python-wheel MATURIN=maturin` with a compatible Maturin already on
|
|
200
|
+
`PATH`. The same Python environment is required by `cargo test --workspace`;
|
|
201
|
+
plain workspace-default Cargo commands exclude the Python extension.
|
|
202
|
+
|
|
203
|
+
The `anolisa_tokenless` module supports CPython 3.11 and later on the platform
|
|
204
|
+
where its native wheel was built. It currently exposes JSON response
|
|
205
|
+
compression and Stash retrieval; it does not bundle the CLI, RTK, TOON, or a
|
|
206
|
+
framework integration. The package is built and tested in this repository but is
|
|
207
|
+
not yet published to PyPI. See the [runtime design](docs/design/runtime-library.md)
|
|
208
|
+
and the [user manual](../../docs/user-guide/en/token-saving/tokenless/user-manual.md#build-the-python-runtime-from-source).
|
|
209
|
+
|
|
210
|
+
## CLI Usage
|
|
211
|
+
|
|
212
|
+
### compress-schema
|
|
213
|
+
|
|
214
|
+
Compress a single tool schema:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# From file
|
|
218
|
+
tokenless compress-schema -f tool.json
|
|
219
|
+
|
|
220
|
+
# From stdin
|
|
221
|
+
cat tool.json | tokenless compress-schema
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Compress a batch of tools (JSON array):
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
tokenless compress-schema -f tools.json --batch
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### compress-response
|
|
231
|
+
|
|
232
|
+
Compress an API response:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# From file
|
|
236
|
+
tokenless compress-response -f response.json
|
|
237
|
+
|
|
238
|
+
# From stdin
|
|
239
|
+
curl -s https://api.example.com/data | tokenless compress-response
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
By default `compress-response` stashes dropped array items so they can be
|
|
243
|
+
retrieved later (see [Reversible compression](docs/stash-reversible-compression.md)).
|
|
244
|
+
Pass `--no-stash` for lossy truncation, or `--stash-db <path>` to override the
|
|
245
|
+
stash database (default `~/.tokenless/stash.db`).
|
|
246
|
+
|
|
247
|
+
### retrieve
|
|
248
|
+
|
|
249
|
+
Recover a payload stashed during `compress-response`. Accepts a bare 24-hex
|
|
250
|
+
hash or any text containing a `<<tokenless:HASH>>` marker:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Bare hash
|
|
254
|
+
tokenless retrieve c30ccf5ed1125e0ed871ba8e
|
|
255
|
+
|
|
256
|
+
# Or paste the whole truncation line — the hash is extracted automatically.
|
|
257
|
+
# (Use the FULL 24-hex hash from your output; the value below is shorthand.)
|
|
258
|
+
tokenless retrieve "<... 195 items truncated, retrieve with <<tokenless:c30ccf5ed1125e0ed871ba8e>>"
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### compress-toon / decompress-toon
|
|
262
|
+
|
|
263
|
+
Encode JSON to TOON format (or decode back to JSON):
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
# Encode JSON to TOON
|
|
267
|
+
echo '{"name":"Alice","age":30}' | tokenless compress-toon
|
|
268
|
+
# name: Alice
|
|
269
|
+
# age: 30
|
|
270
|
+
|
|
271
|
+
# Decode TOON back to JSON
|
|
272
|
+
echo 'name: Alice\nage: 30' | tokenless decompress-toon
|
|
273
|
+
# {"name":"Alice","age":30}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Inspect token savings
|
|
277
|
+
|
|
278
|
+
Use `show` to print the complete stored before/after payload, or `diff` to
|
|
279
|
+
explain the estimated token saving and highlight only changed lines:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
tokenless stats show 42
|
|
283
|
+
tokenless stats diff 42
|
|
284
|
+
tokenless stats diff --session <session-id>
|
|
285
|
+
tokenless stats diff --session <session-id> --tool-use-id <tool-use-id>
|
|
286
|
+
tokenless stats diff 42 --json
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Session overviews contain metrics only. Record and tool-use reports include a
|
|
290
|
+
unified content diff; consecutive active stages are linked only when their
|
|
291
|
+
stored output/input content matches exactly, avoiding duplicate intermediate
|
|
292
|
+
token counts. See [Measuring Tokenless Savings](../../docs/user-guide/en/token-saving/tokenless/measuring-savings.md)
|
|
293
|
+
for options and measurement limits.
|
|
294
|
+
|
|
295
|
+
### Database location
|
|
296
|
+
|
|
297
|
+
Tokenless stores statistics and reversible-compression data in
|
|
298
|
+
`~/.tokenless/stats.db` and `~/.tokenless/stash.db`. Set one directory for both:
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
export TOKENLESS_DATA_DIR="$HOME/path/to/tokenless-data"
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
The directory may be any absolute path the current user can access, including
|
|
305
|
+
a managed service directory under `/var/lib`; filesystem root, relative paths,
|
|
306
|
+
and parent traversal are rejected. The existing `TOKENLESS_STATS_DB`,
|
|
307
|
+
`TOKENLESS_STASH_DB`, and `--stash-db` overrides take precedence but must stay
|
|
308
|
+
under the real user home or selected data directory. Configuration remains at
|
|
309
|
+
`~/.tokenless/config.json`.
|
|
310
|
+
|
|
311
|
+
## copilot-shell Hooks
|
|
312
|
+
|
|
313
|
+
The adapter provides hooks that are auto-discovered by copilot-shell via the cosh extension manifest:
|
|
314
|
+
|
|
315
|
+
| Hook | Event | File | Description |
|
|
316
|
+
|------|-------|------|-------------|
|
|
317
|
+
| Tool Ready (hard-disabled) | PreToolUse (all tools) | `tool_ready_hook.sh` | Silent pass-through; no check, repair, context, or block |
|
|
318
|
+
| Command rewriting | PreToolUse (Shell) | `rewrite_hook.py` | Rewrite commands via RTK |
|
|
319
|
+
| Response compression + attribution + TOON | PostToolUse | `compress_response_hook.py` | Compress + env error attribution + TOON |
|
|
320
|
+
| Schema compression | BeforeModel | `compress_schema_hook.py` | Compress tool schemas |
|
|
321
|
+
|
|
322
|
+
### Install
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
make cosh-extension-install # or: make openclaw-install, make hermes-install
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Hooks are registered via the cosh extension manifest (`cosh-extension.json`) and auto-discovered by copilot-shell — no manual `settings.json` configuration needed.
|
|
329
|
+
|
|
330
|
+
## Tool Ready
|
|
331
|
+
|
|
332
|
+
Tool Ready was designed to prevent wasted LLM tokens from retrying commands that fail due to missing environment dependencies.
|
|
333
|
+
|
|
334
|
+
**Legacy behavior**: Before each tool call, the `tool_ready_hook.sh` hook checked the tool's dependency list (from `tool-ready-spec.json`). Missing dependencies could produce `NOT_READY` with "Skip retry" guidance.
|
|
335
|
+
|
|
336
|
+
Tool Ready is currently hard-disabled across all adapters. Its registered hooks return before reading the dependency specification, checking the environment, attempting repair, or emitting a block decision. No environment variable can re-enable the legacy behavior; doing so requires an intentional source change and a new release.
|
|
337
|
+
|
|
338
|
+
Post-tool failure attribution, response compression, command rewriting, TOON encoding, Stash, and statistics are independent and remain active.
|
|
339
|
+
|
|
340
|
+
### env-check CLI
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
# Report the disabled state for a specific tool
|
|
344
|
+
tokenless env-check --tool Shell
|
|
345
|
+
|
|
346
|
+
# Report the disabled state for all tools
|
|
347
|
+
tokenless env-check --all
|
|
348
|
+
|
|
349
|
+
# Report the disabled state for checklist mode
|
|
350
|
+
tokenless env-check --checklist
|
|
351
|
+
|
|
352
|
+
# Machine-readable disabled state; no tools/summary checklist is emitted
|
|
353
|
+
tokenless env-check --checklist --json
|
|
354
|
+
|
|
355
|
+
# Accepted for compatibility; does not inspect or repair the environment
|
|
356
|
+
tokenless env-check --tool Shell --fix
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
These commands currently report that Tool Ready is hard-disabled and do not inspect or modify the environment.
|
|
360
|
+
Every JSON mode returns exactly the same three-field schema:
|
|
361
|
+
|
|
362
|
+
```json
|
|
363
|
+
{"tool":"checklist","status":"UNKNOWN","enabled":false}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
`tool` identifies the requested tool or the `all`/`checklist` scope. The dormant
|
|
367
|
+
legacy `tools` and `summary` checklist fields are never emitted while the hard
|
|
368
|
+
bypass is active.
|
|
369
|
+
|
|
370
|
+
### Configuration
|
|
371
|
+
|
|
372
|
+
The dormant legacy per-tool dependencies remain in `tool-ready-spec.json`
|
|
373
|
+
(shipped within the adapter bundle at `common/tool-ready-spec.json`). The hard
|
|
374
|
+
bypass does not read this file:
|
|
375
|
+
|
|
376
|
+
```json
|
|
377
|
+
{
|
|
378
|
+
"Shell": {
|
|
379
|
+
"required": [
|
|
380
|
+
{ "binary": "jq", "package": "jq", "manager": "apt" }
|
|
381
|
+
],
|
|
382
|
+
"recommended": [
|
|
383
|
+
{ "binary": "rtk", "version": ">=0.35", "package": "rtk", "manager": "cargo",
|
|
384
|
+
"fallback": [
|
|
385
|
+
{ "method": "symlink", "binary": "rtk", "source": "/usr/libexec/anolisa/tokenless/rtk" }
|
|
386
|
+
]
|
|
387
|
+
}
|
|
388
|
+
]
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
String format `"jq"` is also supported (auto-converts to object).
|
|
394
|
+
|
|
395
|
+
## OpenClaw Plugin
|
|
396
|
+
|
|
397
|
+
The plugin hooks into the OpenClaw agent loop at two stages:
|
|
398
|
+
|
|
399
|
+
| Hook | Event | Action | Status |
|
|
400
|
+
|---|---|---|---|
|
|
401
|
+
| Tool Ready | `before_tool_call` | Registered silent pass-through; no check, repair, context, or block | ⛔ Hard-disabled |
|
|
402
|
+
| Command rewriting | `before_tool_call` | Rewrites `exec` commands to RTK equivalents for filtered output | ✅ Active |
|
|
403
|
+
| Response compression | `tool_result_persist` | Compresses tool results before they enter the context window | ✅ Active |
|
|
404
|
+
| Schema compression | — | Not supported by OpenClaw's hook system | ⏳ → ✅ |
|
|
405
|
+
|
|
406
|
+
**Response compression details:**
|
|
407
|
+
- Automatically compresses results from all tool types (`web_search`, `web_fetch`, `read_file`, etc.)
|
|
408
|
+
- Skips `exec` tool results when RTK is enabled — RTK already produces optimized output, avoiding double-compression
|
|
409
|
+
- Observed savings: **~78%** on `web_fetch` results, varies by content type
|
|
410
|
+
|
|
411
|
+
Each hook degrades gracefully — if the corresponding binary (`rtk` or `tokenless`) is not installed, that hook is silently skipped.
|
|
412
|
+
|
|
413
|
+
### Configuration
|
|
414
|
+
|
|
415
|
+
Options in `openclaw.plugin.json`:
|
|
416
|
+
|
|
417
|
+
| Option | Default | Description |
|
|
418
|
+
|---|---|---|
|
|
419
|
+
| `rtk_enabled` | `true` | Enable RTK command rewriting |
|
|
420
|
+
| `schema_compression_enabled` | `true` | Enable tool schema compression (pending OpenClaw support) |
|
|
421
|
+
| `response_compression_enabled` | `true` | Enable tool response compression via `tool_result_persist` |
|
|
422
|
+
| `verbose` | `true` | Log detailed rewrite/compression info |
|
|
423
|
+
|
|
424
|
+
## Hermes Agent Plugin
|
|
425
|
+
|
|
426
|
+
The plugin registers hooks at three Hermes events, covering five strategies:
|
|
427
|
+
|
|
428
|
+
| Strategy | Event | Action | Status |
|
|
429
|
+
|---|---|---|---|
|
|
430
|
+
| Tool Ready | `pre_tool_call` | Registered silent pass-through; no check, repair, context, or block | ⛔ Hard-disabled |
|
|
431
|
+
| Command rewriting | `pre_tool_call` | Blocks original command, suggests `rtk`-rewritten version (one extra round-trip) | ✅ Active |
|
|
432
|
+
| Response compression | `transform_tool_result` | Compresses tool results via `tokenless compress-response` | ✅ Active |
|
|
433
|
+
| TOON encoding | `transform_tool_result` | Pipeline step after response compression — encodes JSON to TOON format | ✅ Active |
|
|
434
|
+
| Session tracking | `on_session_start` | Propagates agent/session IDs for stats recording | ✅ Active |
|
|
435
|
+
| Schema compression | — | Not supported by Hermes hook system (no hook exposes tool schemas) | ⏳ Blocked |
|
|
436
|
+
|
|
437
|
+
**How command rewriting works in Hermes**: Hermes's `pre_tool_call` hook can only block tool execution (not modify arguments), so the plugin blocks the original shell command and returns a message suggesting the RTK-rewritten version. The agent then re-executes with the optimized command, adding one extra tool-call round-trip. This is safe — `rtk rewrite` only does text substitution and never executes the command.
|
|
438
|
+
|
|
439
|
+
Each hook degrades gracefully — if the corresponding binary is not installed, that hook is silently skipped.
|
|
440
|
+
|
|
441
|
+
### Install
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
make hermes-install
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
Enable the plugin:
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
hermes plugins enable tokenless
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
Or add to `~/.hermes/config.yaml`:
|
|
454
|
+
|
|
455
|
+
```yaml
|
|
456
|
+
plugins:
|
|
457
|
+
enabled:
|
|
458
|
+
- tokenless
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
## Qoder CLI Plugin
|
|
462
|
+
|
|
463
|
+
The plugin registers hooks at three Qoder events, covering three strategies:
|
|
464
|
+
|
|
465
|
+
| Strategy | Event | Action | Status |
|
|
466
|
+
|---|---|---|---|
|
|
467
|
+
| Tool Ready | `PreToolUse` | Registered silent pass-through; no check, repair, context, or block | ⛔ Hard-disabled |
|
|
468
|
+
| Command rewriting | `PreToolUse` | Rewrites shell commands via RTK for token savings | ✅ Active |
|
|
469
|
+
| Response compression | `PostToolUse` | Compresses tool responses and encodes to TOON format | ✅ Active |
|
|
470
|
+
|
|
471
|
+
Each hook degrades gracefully — if the corresponding binary is not installed, that hook is silently skipped.
|
|
472
|
+
|
|
473
|
+
### Install
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
make qoder-install
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
## Claude Code Plugin
|
|
480
|
+
|
|
481
|
+
The plugin registers hooks at two Claude Code events, covering four strategies:
|
|
482
|
+
|
|
483
|
+
| Strategy | Event | Action | Status |
|
|
484
|
+
|---|---|---|---|
|
|
485
|
+
| Tool Ready | `PreToolUse` | Registered silent pass-through; no check, repair, context, or block | ⛔ Hard-disabled |
|
|
486
|
+
| Command rewriting | `PreToolUse` (Bash) | Rewrites shell commands via RTK for token savings | ✅ Active |
|
|
487
|
+
| Response compression | `PostToolUse` | Compresses tool responses and encodes to TOON format | ✅ Active |
|
|
488
|
+
| TOON encoding | `PostToolUse` | Pipeline step after response compression — encodes JSON to TOON format | ✅ Active |
|
|
489
|
+
|
|
490
|
+
Claude Code v2 requires plugins to be sourced from a registered marketplace. We expose the adapter's `claude-code/` directory as a single-plugin marketplace (`anolisa-tokenless`), then install `tokenless@anolisa-tokenless` from it. The marketplace name is component-scoped so multiple ANOLISA components can each register their own without colliding.
|
|
491
|
+
|
|
492
|
+
### Install
|
|
493
|
+
|
|
494
|
+
```bash
|
|
495
|
+
make claude-code-install
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
## Codex Plugin
|
|
499
|
+
|
|
500
|
+
The plugin registers hooks at four Codex events, covering four strategies:
|
|
501
|
+
|
|
502
|
+
| Strategy | Event | Action | Status |
|
|
503
|
+
|---|---|---|---|
|
|
504
|
+
| Session check | `SessionStart` | Verifies tokenless CLI is installed and functional (non-blocking) | ✅ Active |
|
|
505
|
+
| Tool Ready | `PreToolUse` | Registered silent pass-through; no check, repair, context, or block | ⛔ Hard-disabled |
|
|
506
|
+
| Command rewriting | `PreToolUse` | Rewrites shell commands via RTK for token savings | ✅ Active |
|
|
507
|
+
| Response compression | `PostToolUse` | Compresses tool responses and encodes to TOON format, injects compressed summary as `additionalContext` | ✅ Active |
|
|
508
|
+
|
|
509
|
+
> **Codex Protocol Constraint**: PostToolUse hooks cannot suppress the original tool output. The plugin injects a compressed *summary* as `additionalContext` — the model sees both the original output and the compressed summary.
|
|
510
|
+
|
|
511
|
+
### Install
|
|
512
|
+
|
|
513
|
+
```bash
|
|
514
|
+
make codex-install
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
## OpenCode Plugin
|
|
518
|
+
|
|
519
|
+
The local plugin uses OpenCode's mutable tool hooks, so compressed output
|
|
520
|
+
replaces the original model-visible response instead of being appended to it.
|
|
521
|
+
|
|
522
|
+
| Strategy | Event | Action | Status |
|
|
523
|
+
|---|---|---|---|
|
|
524
|
+
| Tool Ready | `tool.execute.before` | Registered silent pass-through; no check, repair, context, or block | ⛔ Hard-disabled |
|
|
525
|
+
| Command rewriting | `tool.execute.before` (bash) | Rewrites shell commands via RTK | ✅ Active |
|
|
526
|
+
| Response + TOON compression | `tool.execute.after` | Replaces structured tool output with a smaller representation | ✅ Active |
|
|
527
|
+
| Schema compression | `tool.definition` | Compresses tool descriptions and JSON Schemas | ✅ Active |
|
|
528
|
+
|
|
529
|
+
Install the plugin globally, then restart OpenCode:
|
|
530
|
+
|
|
531
|
+
```bash
|
|
532
|
+
make opencode-install
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
The installer creates a `tokenless.js` symbolic link in OpenCode's global
|
|
536
|
+
`plugins/` directory and never overwrites an existing unmanaged file. It honors
|
|
537
|
+
`OPENCODE_CONFIG_DIR`, `XDG_CONFIG_HOME`, and the explicit
|
|
538
|
+
`TOKENLESS_OPENCODE_CONFIG_DIR` override.
|
|
539
|
+
|
|
540
|
+
## DeepSeek Harness Plugin
|
|
541
|
+
|
|
542
|
+
The native DSH bundle compresses successful single-block JSON tool results
|
|
543
|
+
through `tools/post-execute` and keeps the original result unless the Tokenless
|
|
544
|
+
CLI returns strictly smaller valid JSON. Content-retrieval tools remain
|
|
545
|
+
lossless by default. Environment-error attribution stays active when response
|
|
546
|
+
compression is disabled, skipped, or unable to reduce the result.
|
|
547
|
+
|
|
548
|
+
Enable the bundle for every desired DSH profile in one command by repeating
|
|
549
|
+
`--profile`:
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
anolisa adapter enable tokenless dsh \
|
|
553
|
+
--profile web \
|
|
554
|
+
--profile headless
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
Each enable or re-enable treats the supplied profiles as the complete desired
|
|
558
|
+
set. It removes the bundle from profiles recorded by the prior receipt but
|
|
559
|
+
omitted from the new command, so always include every profile that should keep
|
|
560
|
+
Tokenless. Each name must match a profile passed to `dsh --profile <profile>`.
|
|
561
|
+
Configuration belongs in that profile's `cordis.patch.yml`; see the
|
|
562
|
+
[DeepSeek Harness integration reference](../../docs/user-guide/en/token-saving/tokenless/framework-integration.md#deepseek-harness-native-processing)
|
|
563
|
+
for every option and default.
|
|
564
|
+
|
|
565
|
+
## AgentScope Framework Integration
|
|
566
|
+
|
|
567
|
+
AgentScope 1.0.11 through 1.0.x and AgentScope 2.0.x applications install two same-version Python
|
|
568
|
+
wheels explicitly.
|
|
569
|
+
The framework integration uses the `anolisa-tokenless` runtime directly and
|
|
570
|
+
does not start a CLI subprocess. Neither Python package is currently published
|
|
571
|
+
to a package index. Build and install both wheels from a source checkout:
|
|
572
|
+
|
|
573
|
+
```bash
|
|
574
|
+
make python-wheel agentscope-wheel
|
|
575
|
+
python -m pip install \
|
|
576
|
+
target/wheels/anolisa_tokenless-*.whl \
|
|
577
|
+
target/wheels/anolisa_tokenless_agentscope-*.whl
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
The public entry point and configuration are the same across both major
|
|
581
|
+
versions. AgentScope 1.x and 2.x expose different lifecycle hooks, so only the
|
|
582
|
+
final attachment step differs.
|
|
583
|
+
|
|
584
|
+
AgentScope 1.x must install the integration after the Agent and all of its tool
|
|
585
|
+
functions have been created. Installation binds retrieval to that Agent's
|
|
586
|
+
memory so a stash hash cannot be retrieved unless its marker is visible there.
|
|
587
|
+
|
|
588
|
+
```python
|
|
589
|
+
from agentscope.agent import ReActAgent
|
|
590
|
+
from tokenless_agentscope import TokenlessAgentScope, TokenlessConfig
|
|
591
|
+
|
|
592
|
+
integration = TokenlessAgentScope(
|
|
593
|
+
TokenlessConfig(
|
|
594
|
+
mode="balanced",
|
|
595
|
+
data_dir="/absolute/path/to/tenant-tokenless-data",
|
|
596
|
+
),
|
|
597
|
+
)
|
|
598
|
+
agent = ReActAgent(..., toolkit=toolkit)
|
|
599
|
+
integration.install(agent)
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
AgentScope 2.x receives the retrieval Tool and middleware during construction;
|
|
603
|
+
this works from 2.0.0 and does not depend on mutable Toolkit APIs added in later
|
|
604
|
+
patch versions.
|
|
605
|
+
|
|
606
|
+
```python
|
|
607
|
+
from agentscope.agent import Agent
|
|
608
|
+
from agentscope.tool import Toolkit
|
|
609
|
+
from tokenless_agentscope import TokenlessAgentScope, TokenlessConfig
|
|
610
|
+
|
|
611
|
+
integration = TokenlessAgentScope(
|
|
612
|
+
TokenlessConfig(
|
|
613
|
+
mode="balanced",
|
|
614
|
+
data_dir="/absolute/path/to/tenant-tokenless-data",
|
|
615
|
+
# retrieve_tool_name="tenant_tokenless_retrieve",
|
|
616
|
+
),
|
|
617
|
+
)
|
|
618
|
+
toolkit = Toolkit(tools=[*application_tools, *integration.tools])
|
|
619
|
+
|
|
620
|
+
agent = Agent(
|
|
621
|
+
...,
|
|
622
|
+
toolkit=toolkit,
|
|
623
|
+
middlewares=integration.middlewares,
|
|
624
|
+
)
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
AgentScope App is supported from 2.0.1. It derives an isolated Tokenless data
|
|
628
|
+
directory for every user/agent/session below the configured absolute base
|
|
629
|
+
directory:
|
|
630
|
+
|
|
631
|
+
```python
|
|
632
|
+
from agentscope.app import create_app
|
|
633
|
+
|
|
634
|
+
app = create_app(..., **integration.app_options())
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
Set a unique `retrieve_tool_name` in `TokenlessConfig` if the application
|
|
638
|
+
already defines `tokenless_retrieve`; App assembly does not expose the other
|
|
639
|
+
tools to this factory for a preflight collision check.
|
|
640
|
+
|
|
641
|
+
AgentScope 2.0.0 does not expose App-level Agent middleware or Tool injection,
|
|
642
|
+
so that patch release supports direct Agent construction only. The existing
|
|
643
|
+
`TokenlessMiddleware` 2.x API remains available for compatibility; new code
|
|
644
|
+
should use `TokenlessAgentScope` so it does not depend on patch-specific
|
|
645
|
+
Toolkit mutation or automatic Tool collection.
|
|
646
|
+
|
|
647
|
+
| Mode | Policy |
|
|
648
|
+
|---|---|
|
|
649
|
+
| `conservative` | Compress every non-excluded tool with 1 MiB / 65,536 / depth 32 limits |
|
|
650
|
+
| `balanced` | Skip Read/Glob/Grep; use 65,536 / 128 / depth 8 for Shell and conservative limits elsewhere |
|
|
651
|
+
| `aggressive` | Skip Read/Glob/Grep; use CLI defaults of 4,096 / 32 / depth 8 elsewhere |
|
|
652
|
+
|
|
653
|
+
`balanced` is the default. The read-only retrieval Tool is auto-allowed only
|
|
654
|
+
for a 24-character hash whose marker is present in AgentScope 1.x memory or the
|
|
655
|
+
AgentScope 2.x context/summary. In 1.x, call `install()` only after registering
|
|
656
|
+
the tools that should be compressed; tools registered later are not wrapped.
|
|
657
|
+
Pass a different absolute `data_dir` to each user or tenant for direct Agents;
|
|
658
|
+
`TOKENLESS_DATA_DIR` is only a process-wide fallback when `data_dir` is omitted.
|
|
659
|
+
Retain the default one-hour stash TTL unless the application has a deliberate
|
|
660
|
+
lifecycle policy, and do not expect retrieval across nodes. This integration
|
|
661
|
+
does not enable Shell, MCP, TOON, RTK, or schema compression. Its source lives
|
|
662
|
+
under `python/agentscope/` for independent wheel distribution.
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
## Build
|
|
666
|
+
|
|
667
|
+
| Target | Description |
|
|
668
|
+
|---|---|
|
|
669
|
+
| `make build` | Build `tokenless` + `rtk` + `toon` (release mode) |
|
|
670
|
+
| `make build-tokenless` | Build `tokenless` + `rtk` (via justfile) |
|
|
671
|
+
| `make build-toon` | Install TOON binary via `cargo install toon-format` |
|
|
672
|
+
| `make python-wheel` | Build the native `anolisa-tokenless` wheel |
|
|
673
|
+
| `make agentscope-wheel` | Build the pure-Python AgentScope integration wheel |
|
|
674
|
+
| `make test-python-runtime` | Install and test the wheel in an isolated environment |
|
|
675
|
+
| `make test-agentscope-integration` | Test both wheels with supported AgentScope versions |
|
|
676
|
+
| `make install` | Build and install binaries to `BIN_DIR` (default: ~/.local/bin) |
|
|
677
|
+
| `make test` | Run all tests (Rust + hooks) |
|
|
678
|
+
| `make test-hooks` | Run hook integration tests |
|
|
679
|
+
| `make lint` | Run clippy checks |
|
|
680
|
+
| `make fmt` | Format code |
|
|
681
|
+
| `make clean` | Clean build artifacts |
|
|
682
|
+
| `make package-raw` | Package prebuilt target binaries as an ANOLISA raw archive |
|
|
683
|
+
| `make adapter-install` | Install all available framework adapters |
|
|
684
|
+
| `make adapter-uninstall` | Remove all adapters |
|
|
685
|
+
| `make cosh-extension-install` | Install Copilot Shell extension |
|
|
686
|
+
| `make cosh-extension-uninstall` | Remove Copilot Shell extension |
|
|
687
|
+
| `make openclaw-install` | Install OpenClaw plugin |
|
|
688
|
+
| `make openclaw-uninstall` | Remove OpenClaw plugin |
|
|
689
|
+
| `make hermes-install` | Install Hermes Agent plugin |
|
|
690
|
+
| `make hermes-uninstall` | Remove Hermes Agent plugin |
|
|
691
|
+
| `make qoder-install` | Install Qoder CLI plugin |
|
|
692
|
+
| `make qoder-uninstall` | Remove Qoder CLI plugin |
|
|
693
|
+
| `make claude-code-install` | Install Claude Code plugin |
|
|
694
|
+
| `make claude-code-uninstall` | Remove Claude Code plugin |
|
|
695
|
+
| `make codex-install` | Install Codex plugin |
|
|
696
|
+
| `make codex-uninstall` | Remove Codex plugin |
|
|
697
|
+
| `make opencode-install` | Install OpenCode local plugin |
|
|
698
|
+
| `make opencode-uninstall` | Remove OpenCode local plugin |
|
|
699
|
+
| `make setup` | Full setup: build + install + all adapters |
|
|
700
|
+
|
|
701
|
+
Override install paths:
|
|
702
|
+
|
|
703
|
+
```bash
|
|
704
|
+
make install BIN_DIR=/usr/local/bin
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
## Raw Packaging
|
|
708
|
+
|
|
709
|
+
Raw packaging accepts already-built `tokenless`, `rtk`, and `toon`
|
|
710
|
+
executables in one directory and applies the stable component payload layout:
|
|
711
|
+
|
|
712
|
+
```bash
|
|
713
|
+
make package-raw \
|
|
714
|
+
BIN_DIR="$PWD/target/release-bins" \
|
|
715
|
+
TARGET_OS=linux \
|
|
716
|
+
TARGET_ARCH=aarch64 \
|
|
717
|
+
OUTPUT_DIR="$PWD/dist"
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
Supported raw targets are `linux-x86_64`, `linux-aarch64`, and
|
|
721
|
+
`macos-aarch64`. `darwin`/`arm64` and `amd64`/`x64` are accepted as input
|
|
722
|
+
aliases, while artifact names always use the canonical ANOLISA labels. The
|
|
723
|
+
packer verifies the ELF or Mach-O architecture without executing cross-target
|
|
724
|
+
binaries, embeds the component-owned `.anolisa/component.toml`, materializes
|
|
725
|
+
adapter hook symlinks, and emits a reproducible
|
|
726
|
+
`tokenless-<version>-<os>-<arch>.tar.gz` archive. Set `SOURCE_DATE_EPOCH` when
|
|
727
|
+
the caller needs an epoch other than the source commit time.
|
|
728
|
+
|
|
729
|
+
npm packaging also accepts prebuilt `linux-x64`, `linux-arm64`, `darwin-x64`,
|
|
730
|
+
and `darwin-arm64` binary directories under `target/npm-prebuilt`. The packer
|
|
731
|
+
validates and assembles them:
|
|
732
|
+
|
|
733
|
+
```bash
|
|
734
|
+
node npm/scripts/package-npm.js --all
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
See [npm/README.md](npm/README.md#packaging-for-npm) for the fixed directory
|
|
738
|
+
layout and single-target interface.
|
|
739
|
+
|
|
740
|
+
## Project Structure
|
|
741
|
+
|
|
742
|
+
| Path | Description |
|
|
743
|
+
|---|---|
|
|
744
|
+
| `crates/tokenless-cli/` | CLI binary — `tokenless` command (compress, stats, env-check) |
|
|
745
|
+
| `crates/tokenless-schema/` | Core Rust library — `SchemaCompressor` and `ResponseCompressor` |
|
|
746
|
+
| `crates/tokenless-runtime/` | Stateful Rust API shared by the CLI and language bindings |
|
|
747
|
+
| `python/tokenless/` | PyO3 package exposing `anolisa_tokenless` for CPython 3.11+ |
|
|
748
|
+
| `python/agentscope/` | Independent AgentScope framework integration and wheel metadata |
|
|
749
|
+
| `adapters/tokenless/` | FHS adapter bundle — manifest, env-check spec/fix, hooks, OpenClaw plugin |
|
|
750
|
+
| `adapters/tokenless/hermes/` | Hermes Agent adapter — plugin + detect/install/uninstall scripts |
|
|
751
|
+
| `adapters/tokenless/qoder/` | Qoder CLI adapter — plugin + detect/install/uninstall scripts |
|
|
752
|
+
| `adapters/tokenless/claude-code/` | Claude Code adapter — marketplace + plugin + hooks dispatcher |
|
|
753
|
+
| `adapters/tokenless/codex/` | Codex adapter — plugin + Python hook scripts |
|
|
754
|
+
| `adapters/tokenless/opencode/` | OpenCode adapter — local JavaScript plugin + lifecycle scripts |
|
|
755
|
+
| `third_party/rtk/` | RTK vendored source — command rewriting engine (justfile clone+patch) |
|
|
756
|
+
| `third_party/patches/` | Patches for vendored third_party sources |
|
|
757
|
+
| `packaging/raw/` | Component-owned ANOLISA raw packer and target validation |
|
|
758
|
+
| `Makefile` | Unified build system for the entire workspace |
|
|
759
|
+
|
|
760
|
+
## Prerequisites
|
|
761
|
+
|
|
762
|
+
- **Rust** toolchain >= 1.89 — required by rtk (edition 2024) and toon-format (is_multiple_of). Install via [rustup](https://rustup.rs)
|
|
763
|
+
- **just** — build runner for rtk setup (clone + patch orchestration)
|
|
764
|
+
- **Git** — for rtk source download via justfile
|
|
765
|
+
- **CPython 3.11+ development environment and uv** — only for the Python wheel
|
|
766
|
+
and commands that explicitly include all workspace members
|
|
767
|
+
|
|
768
|
+
## License
|
|
769
|
+
|
|
770
|
+
Apache License 2.0 — see [LICENSE](LICENSE).
|