brevix 0.4.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.
- brevix-0.4.0/LICENSE +21 -0
- brevix-0.4.0/PKG-INFO +272 -0
- brevix-0.4.0/README.md +236 -0
- brevix-0.4.0/pyproject.toml +53 -0
- brevix-0.4.0/setup.cfg +4 -0
- brevix-0.4.0/src/brevix/__init__.py +25 -0
- brevix-0.4.0/src/brevix/accuracy_guard.py +124 -0
- brevix-0.4.0/src/brevix/adaptive.py +37 -0
- brevix-0.4.0/src/brevix/cli.py +243 -0
- brevix-0.4.0/src/brevix/compressor.py +297 -0
- brevix-0.4.0/src/brevix/file_compress.py +80 -0
- brevix-0.4.0/src/brevix/install.py +306 -0
- brevix-0.4.0/src/brevix/session_logs.py +176 -0
- brevix-0.4.0/src/brevix/stats.py +141 -0
- brevix-0.4.0/src/brevix/templates/__init__.py +1 -0
- brevix-0.4.0/src/brevix/templates/brevix_rules.md +71 -0
- brevix-0.4.0/src/brevix/tokens.py +29 -0
- brevix-0.4.0/src/brevix.egg-info/PKG-INFO +272 -0
- brevix-0.4.0/src/brevix.egg-info/SOURCES.txt +27 -0
- brevix-0.4.0/src/brevix.egg-info/dependency_links.txt +1 -0
- brevix-0.4.0/src/brevix.egg-info/entry_points.txt +2 -0
- brevix-0.4.0/src/brevix.egg-info/requires.txt +15 -0
- brevix-0.4.0/src/brevix.egg-info/top_level.txt +1 -0
- brevix-0.4.0/tests/test_accuracy_guard.py +74 -0
- brevix-0.4.0/tests/test_adaptive.py +34 -0
- brevix-0.4.0/tests/test_compressor.py +132 -0
- brevix-0.4.0/tests/test_file_compress.py +67 -0
- brevix-0.4.0/tests/test_install.py +108 -0
- brevix-0.4.0/tests/test_session_logs.py +102 -0
brevix-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brevix Contributors
|
|
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.
|
brevix-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: brevix
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Compress LLM output safely. Save tokens without breaking your code.
|
|
5
|
+
Author-email: Yash Koladiya <yashkoladiya123@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Yash-Koladiya30/brevix
|
|
8
|
+
Project-URL: Repository, https://github.com/Yash-Koladiya30/brevix
|
|
9
|
+
Project-URL: Issues, https://github.com/Yash-Koladiya30/brevix/issues
|
|
10
|
+
Keywords: llm,claude,compression,tokens,cost-optimization,claude-code,ai-tools
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Provides-Extra: guard
|
|
25
|
+
Requires-Dist: sentence-transformers>=2.2.0; extra == "guard"
|
|
26
|
+
Provides-Extra: tokens
|
|
27
|
+
Requires-Dist: tiktoken>=0.5.0; extra == "tokens"
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: sentence-transformers>=2.2.0; extra == "all"
|
|
30
|
+
Requires-Dist: tiktoken>=0.5.0; extra == "all"
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# Brevix
|
|
38
|
+
|
|
39
|
+
> Compress LLM output safely. Save tokens without breaking your code.
|
|
40
|
+
|
|
41
|
+
[](https://github.com/Yash-Koladiya30/brevix/actions/workflows/ci.yml)
|
|
42
|
+
[](https://github.com/Yash-Koladiya30/brevix/actions/workflows/ci.yml)
|
|
43
|
+
[](LICENSE)
|
|
44
|
+
[](https://www.python.org)
|
|
45
|
+
[](https://github.com/Yash-Koladiya30/brevix)
|
|
46
|
+
|
|
47
|
+
**Brevix** is a universal output-compression layer for LLM coding tools. It cuts response tokens 40-75% with a deterministic rule engine and verifies the compressed result still means the same thing as the original — so brevity never breaks correctness.
|
|
48
|
+
|
|
49
|
+
Works with **Claude Code, Cursor, Windsurf, OpenAI Codex CLI, Google Antigravity, Gemini CLI, GitHub Copilot Chat, Aider, Continue.dev, Cline, Roo Code, Zed AI, Augment, Kilo, OpenHands, Tabnine, Warp, Replit, Sourcegraph Amp**, plus any tool that reads `AGENTS.md`.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## What Brevix gives you
|
|
54
|
+
|
|
55
|
+
| Capability | Brevix |
|
|
56
|
+
|------------|:-:|
|
|
57
|
+
| Rule-based compression — Lite, Full, Ultra | ✅ |
|
|
58
|
+
| **Adaptive Auto mode** (picks safest aggressive level per response) | ✅ |
|
|
59
|
+
| **Accuracy Guard** — semantic similarity verification before emit | ✅ |
|
|
60
|
+
| **Strict mode** — auto-fall-back to original when meaning would be lost | ✅ |
|
|
61
|
+
| Protected regions — code, URLs, error quotes are never touched | ✅ |
|
|
62
|
+
| File-level compression with `.original` backup (CLAUDE.md, AGENTS.md, …) | ✅ |
|
|
63
|
+
| MCP middleware (`brevix-shrink`) — compresses tool/prompt/resource descriptions | ✅ |
|
|
64
|
+
| Real Claude Code session-log token counts (`stats --real --since 7d`) | ✅ |
|
|
65
|
+
| Statusline badge — `[BREVIX] ⛏ X.Xk saved` | ✅ |
|
|
66
|
+
| Subagents — investigator / builder / reviewer with terse output formats | ✅ |
|
|
67
|
+
| Three-arm A/B eval harness with `tiktoken o200k_base` | ✅ |
|
|
68
|
+
| 20 platform install targets, idempotent `BREVIX:BEGIN/END` markers | ✅ |
|
|
69
|
+
| 100% local — no telemetry, no API calls in the engine | ✅ |
|
|
70
|
+
| Free + MIT | ✅ |
|
|
71
|
+
|
|
72
|
+
**Brevix's edge:** every compressed output is scored against the original locally. If similarity drops below your threshold, you get warned — or in strict mode, the original is emitted instead. No silent meaning loss on dense technical prose.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Install
|
|
77
|
+
|
|
78
|
+
### One-liner (macOS / Linux / WSL)
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
curl -fsSL https://raw.githubusercontent.com/Yash-Koladiya30/brevix/main/install.sh | bash -s -- --all
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Windows (PowerShell)
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
irm https://raw.githubusercontent.com/Yash-Koladiya30/brevix/main/install.ps1 | iex
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Manual
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pip install brevix # core
|
|
94
|
+
pip install 'brevix[guard]' # + semantic Accuracy Guard
|
|
95
|
+
pip install 'brevix[tokens]' # + accurate tiktoken counts
|
|
96
|
+
pip install 'brevix[all]' # everything
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Plug into your LLM coding tool
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
brevix install --list # show all 20 targets
|
|
103
|
+
brevix install claude-code # Claude Code plugin layout
|
|
104
|
+
brevix install cursor # .cursor/rules/brevix.mdc
|
|
105
|
+
brevix install codex # AGENTS.md + .codex/hooks.json
|
|
106
|
+
brevix install gemini # gemini-extension.json + GEMINI.md
|
|
107
|
+
brevix install all # write rule files for every tool
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Idempotent — re-running updates the Brevix block, leaves your other content alone.
|
|
111
|
+
|
|
112
|
+
### Claude Code marketplace
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
/plugin marketplace add Yash-Koladiya30/brevix
|
|
116
|
+
/plugin install brevix@brevix
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### MCP middleware (compress upstream MCP server descriptions)
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm install -g brevix-shrink
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Then wrap any MCP server in your Claude config:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"mcpServers": {
|
|
130
|
+
"fs-shrunk": {
|
|
131
|
+
"command": "npx",
|
|
132
|
+
"args": ["brevix-shrink", "npx", "-y",
|
|
133
|
+
"@modelcontextprotocol/server-filesystem", "/tmp"]
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Usage
|
|
142
|
+
|
|
143
|
+
### Slash commands (Claude Code, Cursor, etc.)
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
/brevix # toggle on (full mode)
|
|
147
|
+
/brevix lite # gentle compression
|
|
148
|
+
/brevix ultra # max compression
|
|
149
|
+
/brevix auto # pick best mode per response
|
|
150
|
+
/brevix off # disable
|
|
151
|
+
/brevix-commit # terse Conventional Commit message
|
|
152
|
+
/brevix-check # run Accuracy Guard on a snippet
|
|
153
|
+
/brevix-stats # show savings
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
For Codex CLI (no slash commands), use `$brevix lite|full|ultra|auto|off`.
|
|
157
|
+
|
|
158
|
+
### CLI
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Output compression
|
|
162
|
+
brevix compress "Your verbose text here" --mode full
|
|
163
|
+
brevix compress - # stdin
|
|
164
|
+
brevix compress . --mode auto -v # adaptive picks best
|
|
165
|
+
brevix compress . --guard --strict --threshold 0.85
|
|
166
|
+
|
|
167
|
+
# File compression (memory files like CLAUDE.md, AGENTS.md, project notes)
|
|
168
|
+
brevix compress-file CLAUDE.md # writes .original.md backup
|
|
169
|
+
brevix compress-file CLAUDE.md --dry-run
|
|
170
|
+
|
|
171
|
+
# Stats
|
|
172
|
+
brevix stats # estimated, in-process
|
|
173
|
+
brevix stats --real --since 7d # parsed from Claude Code session logs
|
|
174
|
+
brevix stats --share # tweet-ready one-liner
|
|
175
|
+
brevix stats --reset
|
|
176
|
+
|
|
177
|
+
# Verification
|
|
178
|
+
brevix check "original" "compressed"
|
|
179
|
+
brevix count "how many tokens?"
|
|
180
|
+
|
|
181
|
+
# Install rules into a project
|
|
182
|
+
brevix install cursor
|
|
183
|
+
brevix install --list
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Subagents (Claude Code)
|
|
187
|
+
|
|
188
|
+
`agents/` ships three small, focused subagents that emit ~60% smaller tool results than vanilla agents:
|
|
189
|
+
|
|
190
|
+
- **brevix-investigator** — read-only code locator (`path:line — symbol — note`)
|
|
191
|
+
- **brevix-builder** — surgical 1-2 file edits with verification
|
|
192
|
+
- **brevix-reviewer** — bug-focused diff review (`path:line: 🔴 bug: …. fix.`)
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## How Accuracy Guard works
|
|
197
|
+
|
|
198
|
+
1. Compress output via the rule engine.
|
|
199
|
+
2. Score the original vs compressed text with a **local sentence-transformer** (no API cost).
|
|
200
|
+
3. If similarity ≥ threshold (default 0.85) → emit compressed. Otherwise warn, or in `--strict` mode fall back to original.
|
|
201
|
+
4. Without `sentence-transformers` installed, falls back to **content-word containment** (drops stopwords without penalty — fair to compression).
|
|
202
|
+
|
|
203
|
+
Result: compression you can trust on production code, specs, contracts.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Compression example
|
|
208
|
+
|
|
209
|
+
**Before:**
|
|
210
|
+
> The reason your React component is re-rendering on every parent update is that you are passing an inline object as a prop. In JavaScript, every render creates a new object reference, even if the contents are identical. To fix this, wrap the object in `useMemo` so the reference stays stable across renders.
|
|
211
|
+
|
|
212
|
+
**After (full mode):**
|
|
213
|
+
> Inline object prop = new ref each render = re-render. Wrap in `useMemo`.
|
|
214
|
+
|
|
215
|
+
**Tokens saved:** ~75%. **Meaning preserved:** ✅ (similarity 0.91)
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Benchmarks
|
|
220
|
+
|
|
221
|
+
Reproducible three-arm A/B harness in [`evals/`](./evals). Compares no-system-prompt vs "be terse" control vs Brevix on 10 developer prompts.
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
arm n median mean total vs baseline vs control
|
|
225
|
+
baseline 10 221 247.3 2473 — —
|
|
226
|
+
control 10 178 191.6 1916 22.5% —
|
|
227
|
+
brevix 10 119 128.4 1284 48.1% 33.0%
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Run yourself:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
pip install 'brevix[all]' anthropic
|
|
234
|
+
export ANTHROPIC_API_KEY=...
|
|
235
|
+
python evals/llm_run.py --model claude-sonnet-4-6
|
|
236
|
+
python evals/measure.py
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
The `vs control` column is the honest savings — what Brevix adds *beyond* "just be brief."
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Roadmap
|
|
244
|
+
|
|
245
|
+
- [x] Core compression engine (lite/full/ultra)
|
|
246
|
+
- [x] Adaptive (auto) mode
|
|
247
|
+
- [x] Accuracy Guard (semantic + content-word fallback)
|
|
248
|
+
- [x] Local stats counter
|
|
249
|
+
- [x] Multi-platform installer (20 targets)
|
|
250
|
+
- [x] File-level compression (`brevix compress-file`)
|
|
251
|
+
- [x] MCP middleware (`brevix-shrink`)
|
|
252
|
+
- [x] Statusline badge + Claude Code hooks
|
|
253
|
+
- [x] Subagents (investigator/builder/reviewer)
|
|
254
|
+
- [x] Three-arm eval harness
|
|
255
|
+
- [x] PowerShell installer + uninstaller
|
|
256
|
+
- [ ] VSCode extension UI
|
|
257
|
+
- [ ] Browser extension (claude.ai, chatgpt.com web)
|
|
258
|
+
- [ ] Two-way compression (compress prompts before send)
|
|
259
|
+
- [ ] Custom user-defined rule packs
|
|
260
|
+
- [ ] Web dashboard (team tier)
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
MIT — free for personal and commercial use.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Contributing
|
|
271
|
+
|
|
272
|
+
Issues and PRs welcome. See [docs/CONTRIBUTING.md](./docs/CONTRIBUTING.md).
|
brevix-0.4.0/README.md
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# Brevix
|
|
2
|
+
|
|
3
|
+
> Compress LLM output safely. Save tokens without breaking your code.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/Yash-Koladiya30/brevix/actions/workflows/ci.yml)
|
|
6
|
+
[](https://github.com/Yash-Koladiya30/brevix/actions/workflows/ci.yml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://www.python.org)
|
|
9
|
+
[](https://github.com/Yash-Koladiya30/brevix)
|
|
10
|
+
|
|
11
|
+
**Brevix** is a universal output-compression layer for LLM coding tools. It cuts response tokens 40-75% with a deterministic rule engine and verifies the compressed result still means the same thing as the original — so brevity never breaks correctness.
|
|
12
|
+
|
|
13
|
+
Works with **Claude Code, Cursor, Windsurf, OpenAI Codex CLI, Google Antigravity, Gemini CLI, GitHub Copilot Chat, Aider, Continue.dev, Cline, Roo Code, Zed AI, Augment, Kilo, OpenHands, Tabnine, Warp, Replit, Sourcegraph Amp**, plus any tool that reads `AGENTS.md`.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## What Brevix gives you
|
|
18
|
+
|
|
19
|
+
| Capability | Brevix |
|
|
20
|
+
|------------|:-:|
|
|
21
|
+
| Rule-based compression — Lite, Full, Ultra | ✅ |
|
|
22
|
+
| **Adaptive Auto mode** (picks safest aggressive level per response) | ✅ |
|
|
23
|
+
| **Accuracy Guard** — semantic similarity verification before emit | ✅ |
|
|
24
|
+
| **Strict mode** — auto-fall-back to original when meaning would be lost | ✅ |
|
|
25
|
+
| Protected regions — code, URLs, error quotes are never touched | ✅ |
|
|
26
|
+
| File-level compression with `.original` backup (CLAUDE.md, AGENTS.md, …) | ✅ |
|
|
27
|
+
| MCP middleware (`brevix-shrink`) — compresses tool/prompt/resource descriptions | ✅ |
|
|
28
|
+
| Real Claude Code session-log token counts (`stats --real --since 7d`) | ✅ |
|
|
29
|
+
| Statusline badge — `[BREVIX] ⛏ X.Xk saved` | ✅ |
|
|
30
|
+
| Subagents — investigator / builder / reviewer with terse output formats | ✅ |
|
|
31
|
+
| Three-arm A/B eval harness with `tiktoken o200k_base` | ✅ |
|
|
32
|
+
| 20 platform install targets, idempotent `BREVIX:BEGIN/END` markers | ✅ |
|
|
33
|
+
| 100% local — no telemetry, no API calls in the engine | ✅ |
|
|
34
|
+
| Free + MIT | ✅ |
|
|
35
|
+
|
|
36
|
+
**Brevix's edge:** every compressed output is scored against the original locally. If similarity drops below your threshold, you get warned — or in strict mode, the original is emitted instead. No silent meaning loss on dense technical prose.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
### One-liner (macOS / Linux / WSL)
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
curl -fsSL https://raw.githubusercontent.com/Yash-Koladiya30/brevix/main/install.sh | bash -s -- --all
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Windows (PowerShell)
|
|
49
|
+
|
|
50
|
+
```powershell
|
|
51
|
+
irm https://raw.githubusercontent.com/Yash-Koladiya30/brevix/main/install.ps1 | iex
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Manual
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install brevix # core
|
|
58
|
+
pip install 'brevix[guard]' # + semantic Accuracy Guard
|
|
59
|
+
pip install 'brevix[tokens]' # + accurate tiktoken counts
|
|
60
|
+
pip install 'brevix[all]' # everything
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Plug into your LLM coding tool
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
brevix install --list # show all 20 targets
|
|
67
|
+
brevix install claude-code # Claude Code plugin layout
|
|
68
|
+
brevix install cursor # .cursor/rules/brevix.mdc
|
|
69
|
+
brevix install codex # AGENTS.md + .codex/hooks.json
|
|
70
|
+
brevix install gemini # gemini-extension.json + GEMINI.md
|
|
71
|
+
brevix install all # write rule files for every tool
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Idempotent — re-running updates the Brevix block, leaves your other content alone.
|
|
75
|
+
|
|
76
|
+
### Claude Code marketplace
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
/plugin marketplace add Yash-Koladiya30/brevix
|
|
80
|
+
/plugin install brevix@brevix
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### MCP middleware (compress upstream MCP server descriptions)
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm install -g brevix-shrink
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Then wrap any MCP server in your Claude config:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"mcpServers": {
|
|
94
|
+
"fs-shrunk": {
|
|
95
|
+
"command": "npx",
|
|
96
|
+
"args": ["brevix-shrink", "npx", "-y",
|
|
97
|
+
"@modelcontextprotocol/server-filesystem", "/tmp"]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Usage
|
|
106
|
+
|
|
107
|
+
### Slash commands (Claude Code, Cursor, etc.)
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
/brevix # toggle on (full mode)
|
|
111
|
+
/brevix lite # gentle compression
|
|
112
|
+
/brevix ultra # max compression
|
|
113
|
+
/brevix auto # pick best mode per response
|
|
114
|
+
/brevix off # disable
|
|
115
|
+
/brevix-commit # terse Conventional Commit message
|
|
116
|
+
/brevix-check # run Accuracy Guard on a snippet
|
|
117
|
+
/brevix-stats # show savings
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
For Codex CLI (no slash commands), use `$brevix lite|full|ultra|auto|off`.
|
|
121
|
+
|
|
122
|
+
### CLI
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Output compression
|
|
126
|
+
brevix compress "Your verbose text here" --mode full
|
|
127
|
+
brevix compress - # stdin
|
|
128
|
+
brevix compress . --mode auto -v # adaptive picks best
|
|
129
|
+
brevix compress . --guard --strict --threshold 0.85
|
|
130
|
+
|
|
131
|
+
# File compression (memory files like CLAUDE.md, AGENTS.md, project notes)
|
|
132
|
+
brevix compress-file CLAUDE.md # writes .original.md backup
|
|
133
|
+
brevix compress-file CLAUDE.md --dry-run
|
|
134
|
+
|
|
135
|
+
# Stats
|
|
136
|
+
brevix stats # estimated, in-process
|
|
137
|
+
brevix stats --real --since 7d # parsed from Claude Code session logs
|
|
138
|
+
brevix stats --share # tweet-ready one-liner
|
|
139
|
+
brevix stats --reset
|
|
140
|
+
|
|
141
|
+
# Verification
|
|
142
|
+
brevix check "original" "compressed"
|
|
143
|
+
brevix count "how many tokens?"
|
|
144
|
+
|
|
145
|
+
# Install rules into a project
|
|
146
|
+
brevix install cursor
|
|
147
|
+
brevix install --list
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Subagents (Claude Code)
|
|
151
|
+
|
|
152
|
+
`agents/` ships three small, focused subagents that emit ~60% smaller tool results than vanilla agents:
|
|
153
|
+
|
|
154
|
+
- **brevix-investigator** — read-only code locator (`path:line — symbol — note`)
|
|
155
|
+
- **brevix-builder** — surgical 1-2 file edits with verification
|
|
156
|
+
- **brevix-reviewer** — bug-focused diff review (`path:line: 🔴 bug: …. fix.`)
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## How Accuracy Guard works
|
|
161
|
+
|
|
162
|
+
1. Compress output via the rule engine.
|
|
163
|
+
2. Score the original vs compressed text with a **local sentence-transformer** (no API cost).
|
|
164
|
+
3. If similarity ≥ threshold (default 0.85) → emit compressed. Otherwise warn, or in `--strict` mode fall back to original.
|
|
165
|
+
4. Without `sentence-transformers` installed, falls back to **content-word containment** (drops stopwords without penalty — fair to compression).
|
|
166
|
+
|
|
167
|
+
Result: compression you can trust on production code, specs, contracts.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Compression example
|
|
172
|
+
|
|
173
|
+
**Before:**
|
|
174
|
+
> The reason your React component is re-rendering on every parent update is that you are passing an inline object as a prop. In JavaScript, every render creates a new object reference, even if the contents are identical. To fix this, wrap the object in `useMemo` so the reference stays stable across renders.
|
|
175
|
+
|
|
176
|
+
**After (full mode):**
|
|
177
|
+
> Inline object prop = new ref each render = re-render. Wrap in `useMemo`.
|
|
178
|
+
|
|
179
|
+
**Tokens saved:** ~75%. **Meaning preserved:** ✅ (similarity 0.91)
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Benchmarks
|
|
184
|
+
|
|
185
|
+
Reproducible three-arm A/B harness in [`evals/`](./evals). Compares no-system-prompt vs "be terse" control vs Brevix on 10 developer prompts.
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
arm n median mean total vs baseline vs control
|
|
189
|
+
baseline 10 221 247.3 2473 — —
|
|
190
|
+
control 10 178 191.6 1916 22.5% —
|
|
191
|
+
brevix 10 119 128.4 1284 48.1% 33.0%
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Run yourself:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
pip install 'brevix[all]' anthropic
|
|
198
|
+
export ANTHROPIC_API_KEY=...
|
|
199
|
+
python evals/llm_run.py --model claude-sonnet-4-6
|
|
200
|
+
python evals/measure.py
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The `vs control` column is the honest savings — what Brevix adds *beyond* "just be brief."
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Roadmap
|
|
208
|
+
|
|
209
|
+
- [x] Core compression engine (lite/full/ultra)
|
|
210
|
+
- [x] Adaptive (auto) mode
|
|
211
|
+
- [x] Accuracy Guard (semantic + content-word fallback)
|
|
212
|
+
- [x] Local stats counter
|
|
213
|
+
- [x] Multi-platform installer (20 targets)
|
|
214
|
+
- [x] File-level compression (`brevix compress-file`)
|
|
215
|
+
- [x] MCP middleware (`brevix-shrink`)
|
|
216
|
+
- [x] Statusline badge + Claude Code hooks
|
|
217
|
+
- [x] Subagents (investigator/builder/reviewer)
|
|
218
|
+
- [x] Three-arm eval harness
|
|
219
|
+
- [x] PowerShell installer + uninstaller
|
|
220
|
+
- [ ] VSCode extension UI
|
|
221
|
+
- [ ] Browser extension (claude.ai, chatgpt.com web)
|
|
222
|
+
- [ ] Two-way compression (compress prompts before send)
|
|
223
|
+
- [ ] Custom user-defined rule packs
|
|
224
|
+
- [ ] Web dashboard (team tier)
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## License
|
|
229
|
+
|
|
230
|
+
MIT — free for personal and commercial use.
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Contributing
|
|
235
|
+
|
|
236
|
+
Issues and PRs welcome. See [docs/CONTRIBUTING.md](./docs/CONTRIBUTING.md).
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "brevix"
|
|
7
|
+
version = "0.4.0"
|
|
8
|
+
description = "Compress LLM output safely. Save tokens without breaking your code."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [{ name = "Yash Koladiya", email = "yashkoladiya123@gmail.com" }]
|
|
13
|
+
keywords = ["llm", "claude", "compression", "tokens", "cost-optimization", "claude-code", "ai-tools"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
guard = ["sentence-transformers>=2.2.0"]
|
|
29
|
+
tokens = ["tiktoken>=0.5.0"]
|
|
30
|
+
all = ["sentence-transformers>=2.2.0", "tiktoken>=0.5.0"]
|
|
31
|
+
dev = ["pytest>=7.0", "pytest-cov", "ruff"]
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
brevix = "brevix.cli:main"
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/Yash-Koladiya30/brevix"
|
|
38
|
+
Repository = "https://github.com/Yash-Koladiya30/brevix"
|
|
39
|
+
Issues = "https://github.com/Yash-Koladiya30/brevix/issues"
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.packages.find]
|
|
42
|
+
where = ["src"]
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.package-data]
|
|
45
|
+
"brevix.templates" = ["*.md"]
|
|
46
|
+
|
|
47
|
+
[tool.pytest.ini_options]
|
|
48
|
+
testpaths = ["tests"]
|
|
49
|
+
addopts = "-v --tb=short"
|
|
50
|
+
|
|
51
|
+
[tool.ruff]
|
|
52
|
+
line-length = 100
|
|
53
|
+
target-version = "py39"
|
brevix-0.4.0/setup.cfg
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Brevix — compress LLM output safely."""
|
|
2
|
+
|
|
3
|
+
from brevix.compressor import Compressor, CompressionMode, CompressionResult
|
|
4
|
+
from brevix.accuracy_guard import AccuracyGuard, GuardResult
|
|
5
|
+
from brevix.stats import Stats
|
|
6
|
+
from brevix.adaptive import pick_mode, AdaptiveResult
|
|
7
|
+
from brevix.tokens import count_tokens, count_tokens_method
|
|
8
|
+
from brevix.install import install, list_targets, TARGETS
|
|
9
|
+
|
|
10
|
+
__version__ = "0.4.0"
|
|
11
|
+
__all__ = [
|
|
12
|
+
"Compressor",
|
|
13
|
+
"CompressionMode",
|
|
14
|
+
"CompressionResult",
|
|
15
|
+
"AccuracyGuard",
|
|
16
|
+
"GuardResult",
|
|
17
|
+
"Stats",
|
|
18
|
+
"pick_mode",
|
|
19
|
+
"AdaptiveResult",
|
|
20
|
+
"count_tokens",
|
|
21
|
+
"count_tokens_method",
|
|
22
|
+
"install",
|
|
23
|
+
"list_targets",
|
|
24
|
+
"TARGETS",
|
|
25
|
+
]
|