tokensafe 1.0.0__tar.gz
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.
- tokensafe-1.0.0/LICENSE +21 -0
- tokensafe-1.0.0/MANIFEST.in +7 -0
- tokensafe-1.0.0/PKG-INFO +203 -0
- tokensafe-1.0.0/README.md +179 -0
- tokensafe-1.0.0/pyproject.toml +56 -0
- tokensafe-1.0.0/setup.cfg +4 -0
- tokensafe-1.0.0/src/__init__.py +6 -0
- tokensafe-1.0.0/src/benchmark.py +232 -0
- tokensafe-1.0.0/src/command_sanitizer.py +92 -0
- tokensafe-1.0.0/src/compactor.py +233 -0
- tokensafe-1.0.0/src/dashboard.py +312 -0
- tokensafe-1.0.0/src/deepseek_distiller.py +109 -0
- tokensafe-1.0.0/src/dependency_prefetcher.py +193 -0
- tokensafe-1.0.0/src/distiller.py +215 -0
- tokensafe-1.0.0/src/history_compactor.py +102 -0
- tokensafe-1.0.0/src/installer.py +384 -0
- tokensafe-1.0.0/src/license_manager.py +148 -0
- tokensafe-1.0.0/src/loop_detector.py +87 -0
- tokensafe-1.0.0/src/mcp_server.py +201 -0
- tokensafe-1.0.0/src/metrics.py +182 -0
- tokensafe-1.0.0/src/proxy.py +158 -0
- tokensafe-1.0.0/src/secret_redactor.py +134 -0
- tokensafe-1.0.0/src/skeletonizer.py +159 -0
- tokensafe-1.0.0/src/slicer.py +137 -0
- tokensafe-1.0.0/src/tokenizer.py +109 -0
- tokensafe-1.0.0/tests/test_benchmark.py +35 -0
- tokensafe-1.0.0/tests/test_command_sanitizer.py +44 -0
- tokensafe-1.0.0/tests/test_compactor.py +33 -0
- tokensafe-1.0.0/tests/test_deepseek_distiller.py +36 -0
- tokensafe-1.0.0/tests/test_dependency_prefetcher.py +63 -0
- tokensafe-1.0.0/tests/test_distiller.py +122 -0
- tokensafe-1.0.0/tests/test_history_compactor.py +47 -0
- tokensafe-1.0.0/tests/test_installer.py +105 -0
- tokensafe-1.0.0/tests/test_license_manager.py +42 -0
- tokensafe-1.0.0/tests/test_loop_detector.py +45 -0
- tokensafe-1.0.0/tests/test_mcp_server.py +28 -0
- tokensafe-1.0.0/tests/test_metrics.py +41 -0
- tokensafe-1.0.0/tests/test_output_guard.py +64 -0
- tokensafe-1.0.0/tests/test_secret_redactor.py +96 -0
- tokensafe-1.0.0/tests/test_skeletonizer.py +72 -0
- tokensafe-1.0.0/tests/test_slicer.py +46 -0
- tokensafe-1.0.0/tests/test_tokenizer.py +24 -0
- tokensafe-1.0.0/tokensafe.egg-info/PKG-INFO +203 -0
- tokensafe-1.0.0/tokensafe.egg-info/SOURCES.txt +45 -0
- tokensafe-1.0.0/tokensafe.egg-info/dependency_links.txt +1 -0
- tokensafe-1.0.0/tokensafe.egg-info/entry_points.txt +5 -0
- tokensafe-1.0.0/tokensafe.egg-info/top_level.txt +1 -0
tokensafe-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Oleg Savelev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tokensafe-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tokensafe
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Autonomous Zero-Loss Token Economy & Context Optimizer for AI Coding Agents
|
|
5
|
+
Author-email: TokenSafe Team <support@tokensafe.dev>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://tokensafe.dev
|
|
8
|
+
Project-URL: Repository, https://github.com/NekoSin4eG/tokensafe
|
|
9
|
+
Project-URL: Documentation, https://tokensafe.dev
|
|
10
|
+
Project-URL: Issues, https://github.com/NekoSin4eG/tokensafe/issues
|
|
11
|
+
Keywords: ai,llm,tokens,token-optimization,context-window,cursor,claude,antigravity,codex,mcp,mcp-server,ast,proxy
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# โก TokenSafe (`tokensafe`)
|
|
26
|
+
|
|
27
|
+
[](https://opensource.org/licenses/MIT)
|
|
28
|
+
[](https://tokensafe.dev#benchmarks)
|
|
29
|
+
[](https://python.org)
|
|
30
|
+
[](https://tokensafe.dev#pricing)
|
|
31
|
+
|
|
32
|
+
> **Autonomous Zero-Loss Token Economy & Context Optimizer for AI Coding Agents.**
|
|
33
|
+
> Slashes LLM token costs by **60%โ90%** with zero quality loss. Built for **Google Antigravity, OpenAI Codex, Cursor, Claude Desktop, Z.ai Code, Windsurf & Cline**.
|
|
34
|
+
|
|
35
|
+
๐ **Official Website:** [https://tokensafe.dev](https://tokensafe.dev)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## โก 1-Click Universal Install
|
|
40
|
+
|
|
41
|
+
Install and connect TokenSafe to all detected AI coding agents on your machine in 5 seconds:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
curl -fsSL https://tokensafe.dev/install.sh | bash
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or clone and run the interactive setup manually:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
git clone https://github.com/NekoSin4eG/tokensafe.git ~/.tokensafe
|
|
51
|
+
python3 ~/.tokensafe/src/installer.py
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## ๐ The Breakthrough: How It Saves 60%โ90% Tokens
|
|
57
|
+
|
|
58
|
+
Traditional AI code interactions suffer from massive context bloat:
|
|
59
|
+
1. **The BPE Token Penalty:** Verbose natural language prompts and filler waste 40%โ70% of ingress context.
|
|
60
|
+
2. **Bulk Tool Dumps:** Reading whole 800+ line files burns 5,000+ tokens per turn when only 20 lines are needed.
|
|
61
|
+
3. **Stuck Loops & Bloated Diffs:** Terminal `git diff` and repetitive failed commands spiral context into overflow.
|
|
62
|
+
|
|
63
|
+
### TokenSafe Solves All Three Autonomously:
|
|
64
|
+
- **TOCP Prompt Distillation:** Intercepts prompts and distills intent into lean S-Expressions via **Google Gemini (2.0 Flash), OpenAI ChatGPT (gpt-4o-mini), or DeepSeek-V3** (`-40% to -70%`). Automatically detects `GEMINI_API_KEY`, `OPENAI_API_KEY`, or `DEEPSEEK_API_KEY`.
|
|
65
|
+
- **AST Skeletonization & Slicing:** Folds inactive function bodies into signatures and windows targeted symbols (`-80% to -92%`).
|
|
66
|
+
- **Predictive Dependency Prefetcher:** Attaches imported symbol signatures to eliminate downstream exploratory `read_file` roundtrips.
|
|
67
|
+
- **Output Guard & Loop Guard:** Blocks destructive full-file rewrites on files $\ge 40$ lines and halts command loops.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## ๐ค Universal LLM Distillation Providers
|
|
72
|
+
|
|
73
|
+
TokenSafe supports any key you already have:
|
|
74
|
+
|
|
75
|
+
| Provider | Supported Model | Environment Variable | Config Key |
|
|
76
|
+
|---|---|---|---|
|
|
77
|
+
| **Google Gemini** | `gemini-2.0-flash`, `gemini-1.5-flash` | `GEMINI_API_KEY` | `gemini_api_key` |
|
|
78
|
+
| **OpenAI ChatGPT** | `gpt-4o-mini`, `gpt-4o` | `OPENAI_API_KEY` | `openai_api_key` |
|
|
79
|
+
| **DeepSeek** | `deepseek-chat` (DeepSeek-V3) | `DEEPSEEK_API_KEY` | `deepseek_api_key` |
|
|
80
|
+
|
|
81
|
+
Check active providers anytime with:
|
|
82
|
+
```bash
|
|
83
|
+
tokensafe providers
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## ๐ Zero-Loss SWE-bench Benchmark Results
|
|
89
|
+
|
|
90
|
+
Verified across 5 real-world production scenarios:
|
|
91
|
+
|
|
92
|
+
| Benchmark Scenario | Task Complexity | Baseline Tokens | TokenSafe Tokens | Reduction | Turn Speedup | Accuracy |
|
|
93
|
+
|---|---|---|---|---|---|---|
|
|
94
|
+
| **Django ORM N+1 Fix** | Multi-file query refactoring | 14,280 | **1,120** | **-92.1%** | +12% faster | 100% Pass |
|
|
95
|
+
| **FastAPI Async Race** | Concurrency bug investigation | 8,640 | **2,940** | **-65.9%** | +10% faster | 100% Pass |
|
|
96
|
+
| **TypeScript Redux Vault** | Full AST symbol refactoring | 18,400 | **2,130** | **-88.4%** | +9% faster | 100% Pass |
|
|
97
|
+
| **Stuck Command Loop** | Subprocess infinite loop | 22,100 | **2,400** | **-89.1%** | Stopped loop | 100% Pass |
|
|
98
|
+
| **Heavy Rewrite Guard** | Whole-file write attempt | 11,300 | **4,310** | **-61.8%** | Forced edit_file | 100% Pass |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## ๐ Pricing & 7-Day Free Trial
|
|
103
|
+
|
|
104
|
+
| Tier | Price | Highlights |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| **Hacker (Open-Core)** | **$0** (Free Forever) | 100k tokens/mo, Local Regex compactor, use own DeepSeek key |
|
|
107
|
+
| **Solo Developer** | **$9 / month** | **7-Day Free Trial**, Unlimited Managed DeepSeek-V3, AST Prefetcher, Output Guards |
|
|
108
|
+
| **Engineering Team** | **$29 / dev / mo** | **7-Day Free Trial**, Team Budget Caps, Centralized Ledger, B2B Docker Proxy |
|
|
109
|
+
| **Enterprise** | Custom | On-Premise Nuitka C-compiled Docker Proxy, Custom Compliance, SAML SSO |
|
|
110
|
+
|
|
111
|
+
๐ **[Start your 7-Day Free Trial on our website](https://tokensafe.dev#pricing)**
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## ๐ ๏ธ CLI Quickstart
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# View live savings dashboard in your terminal
|
|
119
|
+
tokensafe stats
|
|
120
|
+
|
|
121
|
+
# Open interactive Apple dark-mode HTML dashboard
|
|
122
|
+
tokensafe html
|
|
123
|
+
|
|
124
|
+
# Run the 5-scenario benchmark suite
|
|
125
|
+
tokensafe benchmark
|
|
126
|
+
|
|
127
|
+
# Run the local transparent AI proxy (127.0.0.1:8765/v1)
|
|
128
|
+
tokensafe proxy
|
|
129
|
+
|
|
130
|
+
# Activate your Pro License key
|
|
131
|
+
tokensafe activate TS1.eyJlbWFpbCI6...
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## ๐งช Unit Testing
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
python3 -m unittest discover tests
|
|
140
|
+
```
|
|
141
|
+
*Zero external runtime dependencies โ runs on standard Python 3.10+.*
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## ๐ License
|
|
146
|
+
MIT License. Commercial enterprise licenses available for on-premise B2B deployments.
|
|
147
|
+
|
|
148
|
+
### Export Markdown Report
|
|
149
|
+
```bash
|
|
150
|
+
./bin/agy-tokens markdown
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## ๐ Project Structure
|
|
156
|
+
|
|
157
|
+
```text
|
|
158
|
+
agy-token-optimizer/
|
|
159
|
+
โโโ plugin.json # Antigravity plugin manifest
|
|
160
|
+
โโโ hooks.json # Lifecycle hook declarations (PreInvocation, PreToolUse, PostToolUse)
|
|
161
|
+
โโโ rules/
|
|
162
|
+
โ โโโ AGENTS.md # TOCP Protocol directives for LLM (prompt-cached)
|
|
163
|
+
โโโ skills/
|
|
164
|
+
โ โโโ token-optimizer/
|
|
165
|
+
โ โโโ SKILL.md # On-demand Antigravity skill
|
|
166
|
+
โโโ proto/
|
|
167
|
+
โ โโโ tocp.proto # Protocol Buffers contract
|
|
168
|
+
โโโ src/
|
|
169
|
+
โ โโโ tokenizer.py # Zero-dependency calibrated BPE token counter
|
|
170
|
+
โ โโโ compactor.py # Semantic compactor (Natural Language -> TOCP S-Expr)
|
|
171
|
+
โ โโโ slicer.py # AST & Line windowing tool optimizer
|
|
172
|
+
โ โโโ metrics.py # Persistent SQLite metrics engine
|
|
173
|
+
โ โโโ dashboard.py # Visual ANSI terminal & Markdown generator
|
|
174
|
+
โโโ hooks/
|
|
175
|
+
โ โโโ pre_invocation.py # PreInvocation hook entry point
|
|
176
|
+
โ โโโ pre_tool_use.py # PreToolUse hook entry point
|
|
177
|
+
โ โโโ post_tool_use.py # PostToolUse hook entry point
|
|
178
|
+
โโโ bin/
|
|
179
|
+
โ โโโ agy-tokens # Executable CLI
|
|
180
|
+
โโโ tests/ # Unit test suite (100% passing)
|
|
181
|
+
โโโ install.sh # One-click installer for Antigravity
|
|
182
|
+
โโโ README.md
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## ๐ ๏ธ Installation & Antigravity Setup
|
|
188
|
+
|
|
189
|
+
Run the installer:
|
|
190
|
+
```bash
|
|
191
|
+
./install.sh
|
|
192
|
+
```
|
|
193
|
+
This symlinks the plugin directly into `~/.gemini/config/plugins/agy-token-optimizer`.
|
|
194
|
+
Antigravity automatically loads it on startup.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## ๐งช Running Unit Tests
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
python3 -m unittest discover tests
|
|
202
|
+
```
|
|
203
|
+
No external packages required โ runs on standard Python 3.10+.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# โก TokenSafe (`tokensafe`)
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://tokensafe.dev#benchmarks)
|
|
5
|
+
[](https://python.org)
|
|
6
|
+
[](https://tokensafe.dev#pricing)
|
|
7
|
+
|
|
8
|
+
> **Autonomous Zero-Loss Token Economy & Context Optimizer for AI Coding Agents.**
|
|
9
|
+
> Slashes LLM token costs by **60%โ90%** with zero quality loss. Built for **Google Antigravity, OpenAI Codex, Cursor, Claude Desktop, Z.ai Code, Windsurf & Cline**.
|
|
10
|
+
|
|
11
|
+
๐ **Official Website:** [https://tokensafe.dev](https://tokensafe.dev)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## โก 1-Click Universal Install
|
|
16
|
+
|
|
17
|
+
Install and connect TokenSafe to all detected AI coding agents on your machine in 5 seconds:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
curl -fsSL https://tokensafe.dev/install.sh | bash
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or clone and run the interactive setup manually:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/NekoSin4eG/tokensafe.git ~/.tokensafe
|
|
27
|
+
python3 ~/.tokensafe/src/installer.py
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## ๐ The Breakthrough: How It Saves 60%โ90% Tokens
|
|
33
|
+
|
|
34
|
+
Traditional AI code interactions suffer from massive context bloat:
|
|
35
|
+
1. **The BPE Token Penalty:** Verbose natural language prompts and filler waste 40%โ70% of ingress context.
|
|
36
|
+
2. **Bulk Tool Dumps:** Reading whole 800+ line files burns 5,000+ tokens per turn when only 20 lines are needed.
|
|
37
|
+
3. **Stuck Loops & Bloated Diffs:** Terminal `git diff` and repetitive failed commands spiral context into overflow.
|
|
38
|
+
|
|
39
|
+
### TokenSafe Solves All Three Autonomously:
|
|
40
|
+
- **TOCP Prompt Distillation:** Intercepts prompts and distills intent into lean S-Expressions via **Google Gemini (2.0 Flash), OpenAI ChatGPT (gpt-4o-mini), or DeepSeek-V3** (`-40% to -70%`). Automatically detects `GEMINI_API_KEY`, `OPENAI_API_KEY`, or `DEEPSEEK_API_KEY`.
|
|
41
|
+
- **AST Skeletonization & Slicing:** Folds inactive function bodies into signatures and windows targeted symbols (`-80% to -92%`).
|
|
42
|
+
- **Predictive Dependency Prefetcher:** Attaches imported symbol signatures to eliminate downstream exploratory `read_file` roundtrips.
|
|
43
|
+
- **Output Guard & Loop Guard:** Blocks destructive full-file rewrites on files $\ge 40$ lines and halts command loops.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## ๐ค Universal LLM Distillation Providers
|
|
48
|
+
|
|
49
|
+
TokenSafe supports any key you already have:
|
|
50
|
+
|
|
51
|
+
| Provider | Supported Model | Environment Variable | Config Key |
|
|
52
|
+
|---|---|---|---|
|
|
53
|
+
| **Google Gemini** | `gemini-2.0-flash`, `gemini-1.5-flash` | `GEMINI_API_KEY` | `gemini_api_key` |
|
|
54
|
+
| **OpenAI ChatGPT** | `gpt-4o-mini`, `gpt-4o` | `OPENAI_API_KEY` | `openai_api_key` |
|
|
55
|
+
| **DeepSeek** | `deepseek-chat` (DeepSeek-V3) | `DEEPSEEK_API_KEY` | `deepseek_api_key` |
|
|
56
|
+
|
|
57
|
+
Check active providers anytime with:
|
|
58
|
+
```bash
|
|
59
|
+
tokensafe providers
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## ๐ Zero-Loss SWE-bench Benchmark Results
|
|
65
|
+
|
|
66
|
+
Verified across 5 real-world production scenarios:
|
|
67
|
+
|
|
68
|
+
| Benchmark Scenario | Task Complexity | Baseline Tokens | TokenSafe Tokens | Reduction | Turn Speedup | Accuracy |
|
|
69
|
+
|---|---|---|---|---|---|---|
|
|
70
|
+
| **Django ORM N+1 Fix** | Multi-file query refactoring | 14,280 | **1,120** | **-92.1%** | +12% faster | 100% Pass |
|
|
71
|
+
| **FastAPI Async Race** | Concurrency bug investigation | 8,640 | **2,940** | **-65.9%** | +10% faster | 100% Pass |
|
|
72
|
+
| **TypeScript Redux Vault** | Full AST symbol refactoring | 18,400 | **2,130** | **-88.4%** | +9% faster | 100% Pass |
|
|
73
|
+
| **Stuck Command Loop** | Subprocess infinite loop | 22,100 | **2,400** | **-89.1%** | Stopped loop | 100% Pass |
|
|
74
|
+
| **Heavy Rewrite Guard** | Whole-file write attempt | 11,300 | **4,310** | **-61.8%** | Forced edit_file | 100% Pass |
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## ๐ Pricing & 7-Day Free Trial
|
|
79
|
+
|
|
80
|
+
| Tier | Price | Highlights |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| **Hacker (Open-Core)** | **$0** (Free Forever) | 100k tokens/mo, Local Regex compactor, use own DeepSeek key |
|
|
83
|
+
| **Solo Developer** | **$9 / month** | **7-Day Free Trial**, Unlimited Managed DeepSeek-V3, AST Prefetcher, Output Guards |
|
|
84
|
+
| **Engineering Team** | **$29 / dev / mo** | **7-Day Free Trial**, Team Budget Caps, Centralized Ledger, B2B Docker Proxy |
|
|
85
|
+
| **Enterprise** | Custom | On-Premise Nuitka C-compiled Docker Proxy, Custom Compliance, SAML SSO |
|
|
86
|
+
|
|
87
|
+
๐ **[Start your 7-Day Free Trial on our website](https://tokensafe.dev#pricing)**
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## ๐ ๏ธ CLI Quickstart
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# View live savings dashboard in your terminal
|
|
95
|
+
tokensafe stats
|
|
96
|
+
|
|
97
|
+
# Open interactive Apple dark-mode HTML dashboard
|
|
98
|
+
tokensafe html
|
|
99
|
+
|
|
100
|
+
# Run the 5-scenario benchmark suite
|
|
101
|
+
tokensafe benchmark
|
|
102
|
+
|
|
103
|
+
# Run the local transparent AI proxy (127.0.0.1:8765/v1)
|
|
104
|
+
tokensafe proxy
|
|
105
|
+
|
|
106
|
+
# Activate your Pro License key
|
|
107
|
+
tokensafe activate TS1.eyJlbWFpbCI6...
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## ๐งช Unit Testing
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
python3 -m unittest discover tests
|
|
116
|
+
```
|
|
117
|
+
*Zero external runtime dependencies โ runs on standard Python 3.10+.*
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## ๐ License
|
|
122
|
+
MIT License. Commercial enterprise licenses available for on-premise B2B deployments.
|
|
123
|
+
|
|
124
|
+
### Export Markdown Report
|
|
125
|
+
```bash
|
|
126
|
+
./bin/agy-tokens markdown
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## ๐ Project Structure
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
agy-token-optimizer/
|
|
135
|
+
โโโ plugin.json # Antigravity plugin manifest
|
|
136
|
+
โโโ hooks.json # Lifecycle hook declarations (PreInvocation, PreToolUse, PostToolUse)
|
|
137
|
+
โโโ rules/
|
|
138
|
+
โ โโโ AGENTS.md # TOCP Protocol directives for LLM (prompt-cached)
|
|
139
|
+
โโโ skills/
|
|
140
|
+
โ โโโ token-optimizer/
|
|
141
|
+
โ โโโ SKILL.md # On-demand Antigravity skill
|
|
142
|
+
โโโ proto/
|
|
143
|
+
โ โโโ tocp.proto # Protocol Buffers contract
|
|
144
|
+
โโโ src/
|
|
145
|
+
โ โโโ tokenizer.py # Zero-dependency calibrated BPE token counter
|
|
146
|
+
โ โโโ compactor.py # Semantic compactor (Natural Language -> TOCP S-Expr)
|
|
147
|
+
โ โโโ slicer.py # AST & Line windowing tool optimizer
|
|
148
|
+
โ โโโ metrics.py # Persistent SQLite metrics engine
|
|
149
|
+
โ โโโ dashboard.py # Visual ANSI terminal & Markdown generator
|
|
150
|
+
โโโ hooks/
|
|
151
|
+
โ โโโ pre_invocation.py # PreInvocation hook entry point
|
|
152
|
+
โ โโโ pre_tool_use.py # PreToolUse hook entry point
|
|
153
|
+
โ โโโ post_tool_use.py # PostToolUse hook entry point
|
|
154
|
+
โโโ bin/
|
|
155
|
+
โ โโโ agy-tokens # Executable CLI
|
|
156
|
+
โโโ tests/ # Unit test suite (100% passing)
|
|
157
|
+
โโโ install.sh # One-click installer for Antigravity
|
|
158
|
+
โโโ README.md
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## ๐ ๏ธ Installation & Antigravity Setup
|
|
164
|
+
|
|
165
|
+
Run the installer:
|
|
166
|
+
```bash
|
|
167
|
+
./install.sh
|
|
168
|
+
```
|
|
169
|
+
This symlinks the plugin directly into `~/.gemini/config/plugins/agy-token-optimizer`.
|
|
170
|
+
Antigravity automatically loads it on startup.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## ๐งช Running Unit Tests
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
python3 -m unittest discover tests
|
|
178
|
+
```
|
|
179
|
+
No external packages required โ runs on standard Python 3.10+.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tokensafe"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Autonomous Zero-Loss Token Economy & Context Optimizer for AI Coding Agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "TokenSafe Team", email = "support@tokensafe.dev" }
|
|
12
|
+
]
|
|
13
|
+
license = "MIT"
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
keywords = [
|
|
16
|
+
"ai",
|
|
17
|
+
"llm",
|
|
18
|
+
"tokens",
|
|
19
|
+
"token-optimization",
|
|
20
|
+
"context-window",
|
|
21
|
+
"cursor",
|
|
22
|
+
"claude",
|
|
23
|
+
"antigravity",
|
|
24
|
+
"codex",
|
|
25
|
+
"mcp",
|
|
26
|
+
"mcp-server",
|
|
27
|
+
"ast",
|
|
28
|
+
"proxy"
|
|
29
|
+
]
|
|
30
|
+
classifiers = [
|
|
31
|
+
"Development Status :: 5 - Production/Stable",
|
|
32
|
+
"Intended Audience :: Developers",
|
|
33
|
+
"Topic :: Software Development :: Build Tools",
|
|
34
|
+
"Programming Language :: Python :: 3",
|
|
35
|
+
"Programming Language :: Python :: 3.10",
|
|
36
|
+
"Programming Language :: Python :: 3.11",
|
|
37
|
+
"Programming Language :: Python :: 3.12",
|
|
38
|
+
"Programming Language :: Python :: 3.13"
|
|
39
|
+
]
|
|
40
|
+
dependencies = []
|
|
41
|
+
|
|
42
|
+
[project.urls]
|
|
43
|
+
Homepage = "https://tokensafe.dev"
|
|
44
|
+
Repository = "https://github.com/NekoSin4eG/tokensafe"
|
|
45
|
+
Documentation = "https://tokensafe.dev"
|
|
46
|
+
Issues = "https://github.com/NekoSin4eG/tokensafe/issues"
|
|
47
|
+
|
|
48
|
+
[project.scripts]
|
|
49
|
+
tokensafe = "src.installer:main"
|
|
50
|
+
tokensafe-proxy = "src.proxy:main"
|
|
51
|
+
tokensafe-mcp = "src.mcp_server:main"
|
|
52
|
+
tokensafe-stats = "src.dashboard:main"
|
|
53
|
+
|
|
54
|
+
[tool.setuptools.packages.find]
|
|
55
|
+
include = ["src*"]
|
|
56
|
+
exclude = ["src.cloud_backend*"]
|