kompactor 0.5.0__tar.gz → 0.7.2__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.
- kompactor-0.7.2/PKG-INFO +252 -0
- kompactor-0.7.2/README.md +230 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/__init__.py +1 -1
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/cli.py +171 -7
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/config.py +6 -6
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/graph.py +1 -1
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/hooks.py +2 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/installer.py +85 -6
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/server.py +3 -3
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/shellwrap.py +1 -1
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/static/usage.html +70 -66
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/store.py +5 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/ui.html +29 -5
- kompactor-0.7.2/kompactor.egg-info/PKG-INFO +252 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/pyproject.toml +15 -16
- {kompactor-0.5.0 → kompactor-0.7.2}/tests/test_kompactor.py +45 -20
- kompactor-0.5.0/PKG-INFO +0 -274
- kompactor-0.5.0/README.md +0 -251
- kompactor-0.5.0/kompactor.egg-info/PKG-INFO +0 -274
- {kompactor-0.5.0 → kompactor-0.7.2}/LICENSE +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/__main__.py +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/_launch.py +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/estimate.py +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/filters.py +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/langs.py +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/outline.py +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/prove.py +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/rules.py +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/samples.py +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/static/fonts/OFL.txt +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/static/fonts/plex-mono-400.woff2 +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/static/fonts/plex-mono-500.woff2 +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/static/fonts/plex-sans-400.woff2 +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/static/fonts/plex-sans-500.woff2 +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/static/fonts/plex-sans-600.woff2 +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/static/logo-mark.svg +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor/tokens.py +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor.egg-info/SOURCES.txt +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor.egg-info/dependency_links.txt +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor.egg-info/entry_points.txt +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor.egg-info/requires.txt +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/kompactor.egg-info/top_level.txt +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/setup.cfg +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/tests/test_graph.py +0 -0
- {kompactor-0.5.0 → kompactor-0.7.2}/tests/test_shell.py +0 -0
kompactor-0.7.2/PKG-INFO
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kompactor
|
|
3
|
+
Version: 0.7.2
|
|
4
|
+
Summary: Cut the tokens Claude Code spends on noise: compacted command output (failing runs included), outline-first reads, a local code graph, and per-turn savings.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/amarkum/kompactor
|
|
7
|
+
Project-URL: Evidence, https://github.com/amarkum/kompactor/blob/main/evidence/REPORT.md
|
|
8
|
+
Project-URL: Issues, https://github.com/amarkum/kompactor/issues
|
|
9
|
+
Keywords: claude,claude-code,tokens,context,llm,compaction
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Software Development
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Provides-Extra: exact
|
|
20
|
+
Requires-Dist: tiktoken>=0.7; extra == "exact"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
<p align="center">
|
|
24
|
+
<img src="https://raw.githubusercontent.com/amarkum/kompactor/main/docs/brand/kompactor-logo-light.png" alt="Kompactor" width="240">
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<p align="center"><b>Cut the tokens Claude Code spends on noise.</b><br>
|
|
28
|
+
Shorter tool output for Claude, the same answers, and a dashboard that shows what every turn saved.</p>
|
|
29
|
+
|
|
30
|
+
<p align="center">Claude Code CLI and VS Code · Python, Go, TypeScript, React · no dependencies (Python 3.9+) · MIT</p>
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
Most of a Claude Code session's tokens aren't your prompt or Claude's answer. They're tool output: test runs, installs, `git log`, whole-file reads. That output is sent again on every later turn until the context is compacted. Kompactor shrinks it before Claude reads it, and always keeps errors, failing tests, your own stack frames and summary lines.
|
|
35
|
+
|
|
36
|
+
**Measured in real Claude Code sessions:** −16% tokens, −10% cost, −22% output tokens at the default level, with the same answers (27/27 correct with and without). Up to −37% cost on a failing test run. [See the evidence](#evidence)
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
## Contents
|
|
41
|
+
|
|
42
|
+
[Install](#install) · [After you install](#after-you-install) · [How it works](#how-it-works) · [Use it from Claude Code](#use-it-from-claude-code) · [Quality vs tokens](#quality-vs-tokens) · [See your savings](#see-your-savings) · [Turn it off](#turn-it-off-or-remove-it) · [Evidence](#evidence) · [Code graph](#code-graph) · [Teams](#use-it-across-a-team) · [Commands](#commands)
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
Pick one. All of them set up the same thing, and the CLI and the VS Code extension share it.
|
|
47
|
+
|
|
48
|
+
**Claude Code plugin** (recommended). In any Claude Code session, one line at a time:
|
|
49
|
+
```
|
|
50
|
+
/plugin marketplace add amarkum/kompactor
|
|
51
|
+
/plugin install kompactor@kompactor
|
|
52
|
+
/kompactor setup
|
|
53
|
+
```
|
|
54
|
+
The last step adds the status line and the shell prefix that compacts failing commands, which a plugin can't set itself. Then restart Claude Code.
|
|
55
|
+
|
|
56
|
+
**pip / pipx / uv** (macOS, Linux, Windows):
|
|
57
|
+
```bash
|
|
58
|
+
pipx install kompactor # or: pip install kompactor · uv tool install kompactor
|
|
59
|
+
kompactor setup
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**VS Code.** Download `kompactor-0.7.2.vsix` from [Releases](https://github.com/amarkum/kompactor/releases), install it (Extensions › `⋯` › *Install from VSIX…*), and click **Enable** when Kompactor asks.
|
|
63
|
+
|
|
64
|
+
## After you install
|
|
65
|
+
|
|
66
|
+
1. **Restart Claude Code** (CLI or VS Code). Kompactor starts with the next session.
|
|
67
|
+
2. **Work as usual.** You don't call Kompactor; it acts on Claude's tool calls by itself. After each reply you'll see a line such as `Kompactor: −8.2k tokens this turn`, and the status line shows the running total.
|
|
68
|
+
3. **Check it's on:** run `kompactor` in a terminal (or `/kompactor` in Claude Code). It shows whether it's on, your level, savings so far and how to change things:
|
|
69
|
+
```
|
|
70
|
+
Kompactor 0.7.2: ON
|
|
71
|
+
Connected via the Claude Code plugin. New Claude Code sessions are compacted.
|
|
72
|
+
Level: Balanced (level 3 of 5). Change it: `kompactor config preset 1-5`, the dashboard, or /kompactor balanced
|
|
73
|
+
Saved so far: 41.3k tokens (−38%) over 52 tool calls. Details: `kompactor gain`
|
|
74
|
+
```
|
|
75
|
+
4. **Open the dashboard:** `kompactor start` runs it in the background on a free port and prints the address.
|
|
76
|
+
|
|
77
|
+
## How it works
|
|
78
|
+
|
|
79
|
+
Kompactor uses Claude Code's hooks, so it sits between Claude's tools and Claude itself:
|
|
80
|
+
|
|
81
|
+
| When Claude… | Kompactor… |
|
|
82
|
+
|---|---|
|
|
83
|
+
| runs a command | drops passing tests, progress bars, download chatter, library stack frames and lock-file diffs. Keeps errors, failures, your frames and summaries. |
|
|
84
|
+
| runs a command that **fails** | runs it to completion through a shell prefix, compacts it and passes the exit code through. (Without this, Claude Code cuts failing output to its first and last ~5K characters, usually losing the failures at the end.) |
|
|
85
|
+
| opens a big source file | returns its outline first: symbols with line ranges, who imports it and which tests cover it. Claude reads only the ranges it needs; repeating the read returns the whole file. |
|
|
86
|
+
| first searches the code | gives a short map of the most depended-on modules, once per session. |
|
|
87
|
+
| writes a reply | gets a few lines of rules: answer first, smallest diff, reuse before writing (0–177 tokens, depending on the level). |
|
|
88
|
+
|
|
89
|
+
**Nothing is lost.** Every shortened output keeps a raw copy that Claude can fetch with `kompactor show <id>`. Kompactor never changes what a command does, your permission rules still apply, and if anything goes wrong it lets the original output through. Everything runs on your machine; nothing is sent anywhere ([privacy](https://github.com/amarkum/kompactor/blob/main/PRIVACY.md)).
|
|
90
|
+
|
|
91
|
+
## Use it from Claude Code
|
|
92
|
+
|
|
93
|
+
Type these in any Claude Code chat:
|
|
94
|
+
|
|
95
|
+
| Command | What it does |
|
|
96
|
+
|---|---|
|
|
97
|
+
| `/kompactor` or `/kompactor status` | Is it on, current level, savings so far |
|
|
98
|
+
| `/kompactor balanced`, `/kompactor max savings`, `/kompactor max quality` | Change the level |
|
|
99
|
+
| `/kompactor stop` · `/kompactor start` | Pause it · turn it back on |
|
|
100
|
+
| `/kompactor review` | Suggests cuts in your current diff: duplicated helpers, unused options, dead branches |
|
|
101
|
+
| `/kompactor audit` · `/kompactor debt` | Dead-code candidates · a list of FIXME/HACK/TODO shortcuts |
|
|
102
|
+
|
|
103
|
+
Claude also uses the code graph on its own when it needs to find code or check what a change affects.
|
|
104
|
+
|
|
105
|
+
## Quality vs tokens
|
|
106
|
+
|
|
107
|
+

|
|
108
|
+
|
|
109
|
+
One level sets everything. Change it on the dashboard, with `/kompactor <level>` in chat, or with `kompactor config preset <1-5>`. Each project can have its own level.
|
|
110
|
+
|
|
111
|
+
| Level | What Claude gets |
|
|
112
|
+
|---|---|
|
|
113
|
+
| 1 Max quality | Almost everything. Only outputs over ~1.5k tokens are touched, and only pure noise is removed. |
|
|
114
|
+
| 2 Quality | Noisy commands compacted, passing tests hidden, one-line `git log`, outlines for files over 800 lines. |
|
|
115
|
+
| 3 **Balanced** (default) | Outlines from 400 lines, library frames trimmed, a 500-token code map, lean-code rules. |
|
|
116
|
+
| 4 Savings | Tighter caps, 3 lines of diff context, outlines from 250 lines, shorter prose. |
|
|
117
|
+
| 5 Max savings | 80-line caps, 1 line of diff context, outlines from 150 lines, telegraphic prose. |
|
|
118
|
+
|
|
119
|
+
The dashboard also lets you change any single option, with a live preview of exactly what Claude would see.
|
|
120
|
+
|
|
121
|
+
## See your savings
|
|
122
|
+
|
|
123
|
+
| Where | What you see |
|
|
124
|
+
|---|---|
|
|
125
|
+
| After each reply | `Kompactor: −8.2k tokens this turn (13.1k › 4.9k, −63%) · session −41k · context ≈31% smaller` |
|
|
126
|
+
| CLI status line | `Kompactor −41.3k · ctx −31% · last turn −8.2k · Balanced` |
|
|
127
|
+
| VS Code status bar | Running savings; hover for details |
|
|
128
|
+
| Dashboard (`kompactor start`) | Per-turn chart, biggest wins, savings by feature and by project |
|
|
129
|
+
| `kompactor gain` | The same numbers in the terminal |
|
|
130
|
+
| `kompactor estimate` | Replays your **past** sessions and shows what Kompactor would have saved |
|
|
131
|
+
|
|
132
|
+
The numbers are conservative: they count only what Claude would really have read, and a saving is reversed when Claude reads the full file anyway.
|
|
133
|
+
|
|
134
|
+
## Turn it off or remove it
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
kompactor stop # pause: Claude Code output passes through untouched; settings are kept
|
|
138
|
+
kompactor start # turn it back on
|
|
139
|
+
kompactor uninstall # remove hooks, status line, shell prefix and skill (add --purge to delete ~/.kompactor too)
|
|
140
|
+
```
|
|
141
|
+
Then remove the package the way you installed it: `claude plugin uninstall kompactor`, `pipx uninstall kompactor`, or uninstall the extension in VS Code. Setup never replaces a status line or shell prefix you already had, and keeps a backup in `~/.claude/settings.json.kompactor-backup`.
|
|
142
|
+
|
|
143
|
+
## Evidence
|
|
144
|
+
|
|
145
|
+
`kompactor prove` runs each task in real headless Claude Code sessions (`claude -p`), 3 times without Kompactor and 3 times with it, interleaved, with the same prompt, tools, turn limit and budget cap. Tokens are input + cache writes + cache reads + output across every API call; cost is Claude Code's own figure.
|
|
146
|
+
|
|
147
|
+
| Task | Repo | Tokens | Cost | Turns | Correct (without › with) |
|
|
148
|
+
|---|---|---:|---:|---|---|
|
|
149
|
+
| Find the failing Go test and its error | Cobra | **−33%** | **−18%** | 3.3 › 2.0 | 3/3 › 3/3 |
|
|
150
|
+
| Find how requests are deduplicated | SWR | **−32%** | −12% | 3.0 › 2.0 | 3/3 › 3/3 |
|
|
151
|
+
| Find where the session cookie is signed | Flask | **−26%** | −11% | 3.7 › 2.7 | 3/3 › 3/3 |
|
|
152
|
+
| Find the flag-group validation function | Cobra | −24% | −6% | 2.7 › 2.3 | 3/3 › 3/3 |
|
|
153
|
+
| Most-changed files in the last 40 commits | Flask | −16% | +4% | 3.7 › 3.0 | 3/3 › 3/3 |
|
|
154
|
+
| Find the failing vitest test (`--reporter=verbose`) | zustand | −7% | **−37%** | 2.0 › 2.0 | 3/3 › 3/3 |
|
|
155
|
+
| Type-check and list errors | ky | +1% | −2% | 2.0 › 2.0 | 3/3 › 3/3 |
|
|
156
|
+
| Find the failing pytest tests | Flask | +1% | +3% | 2.0 › 2.0 | 3/3 › 3/3 |
|
|
157
|
+
| What does changing `createStore` affect | zustand | +17% | +4% | 2.0 › 2.3 | 3/3 › 3/3 |
|
|
158
|
+
| **Total (54 sessions)** | | **−16%** | **−10%** | | **27/27 › 27/27** |
|
|
159
|
+
|
|
160
|
+
At the other levels, against the same baseline:
|
|
161
|
+
|
|
162
|
+
| Level | Tokens | Cost | Output tokens | Correct |
|
|
163
|
+
|---|---:|---:|---:|---|
|
|
164
|
+
| 1 Max quality | +3% | −1% | 0% | 27/27 |
|
|
165
|
+
| 3 Balanced (default) | **−16%** | **−10%** | **−22%** | 27/27 |
|
|
166
|
+
| 5 Max savings | −12% | −10% | −22% | 27/27 |
|
|
167
|
+
|
|
168
|
+
- **The wins come from avoided turns.** Every turn re-sends the whole context. The vitest failure was 32K characters of passing tests; Kompactor gave Claude 1K characters with the failure, at 37% lower cost.
|
|
169
|
+
- **Short sessions pay a small fixed cost.** On 2-turn tasks with little output, Kompactor's rules add about 1%.
|
|
170
|
+
- **Single commands shrink much more** than whole sessions, because most of a session is Claude Code's own fixed context:
|
|
171
|
+
|
|
172
|
+
| Repo | Command | Raw tokens | Balanced | Max savings |
|
|
173
|
+
|---|---|---:|---:|---:|
|
|
174
|
+
| Flask | `pytest -v tests` (1 failure, 482 passed) | 9,842 | 1,138 (**−88%**) | 696 (**−93%**) |
|
|
175
|
+
| Flask | `grep -rn 'def ' src` | 8,492 | 3,230 (−62%) | 1,323 (−84%) |
|
|
176
|
+
| Flask | `git log -n 40` | 1,457 | 598 (−59%) | 598 (−59%) |
|
|
177
|
+
| ky | `npm install` (fresh) | ~33,000 | 469 (**−99%**) | 451 (−99%) |
|
|
178
|
+
| Flask | Read `src/flask/app.py` (1,625 lines) › outline | 14,084 | 1,490 (−89%) | 1,490 (−89%) |
|
|
179
|
+
| ky | Read `source/core/Ky.ts` (1,376 lines) › outline | 12,452 | 919 (−93%) | 919 (−93%) |
|
|
180
|
+
|
|
181
|
+
**Read more:** [full report](https://github.com/amarkum/kompactor/blob/main/evidence/REPORT.md) · [every session's tokens, tool calls and answers](https://github.com/amarkum/kompactor/blob/main/evidence/results.json) · [what Claude received in each arm for the same failing test run](https://github.com/amarkum/kompactor/blob/main/evidence/EXAMPLE.md) (15,617 vs 1,039 characters) · [how Kompactor compares with graphify, rtk, caveman and others](https://github.com/amarkum/kompactor/blob/main/docs/comparison.md)
|
|
182
|
+
|
|
183
|
+
**Check it on your own work:** `kompactor estimate` replays your past sessions, and `kompactor prove` reruns tasks with and without Kompactor.
|
|
184
|
+
|
|
185
|
+
## Code graph
|
|
186
|
+
|
|
187
|
+

|
|
188
|
+
|
|
189
|
+
A local index of your repo (Python, Go, TypeScript, JavaScript, React), built in about a second and refreshed in the background. Nothing is sent anywhere and nothing is written to the repo.
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
kompactor graph query "session cookie" find code by topic, with line ranges and who uses it
|
|
193
|
+
kompactor graph impact createStore what uses it, and which tests to run
|
|
194
|
+
kompactor graph explain Name one symbol: signature, callers, callees, tests
|
|
195
|
+
kompactor graph report core modules, entry points, import cycles
|
|
196
|
+
kompactor graph unused dead-code candidates
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Supported languages and what Kompactor knows about each: [docs/languages.md](https://github.com/amarkum/kompactor/blob/main/docs/languages.md).
|
|
200
|
+
|
|
201
|
+
## Use it across a team
|
|
202
|
+
|
|
203
|
+

|
|
204
|
+
|
|
205
|
+
**Turn it on for everyone who works in a repo.** Commit this as `.claude/settings.json`:
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"extraKnownMarketplaces": {
|
|
209
|
+
"kompactor": { "source": { "source": "github", "repo": "amarkum/kompactor" }, "autoUpdate": true }
|
|
210
|
+
},
|
|
211
|
+
"enabledPlugins": { "kompactor@kompactor": true }
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
When a teammate trusts the folder, Claude Code installs the plugin; each person then runs `/kompactor setup` once.
|
|
215
|
+
|
|
216
|
+
**Set the team's level for a repo** with a committed `.kompactor.json`:
|
|
217
|
+
```json
|
|
218
|
+
{ "preset": 4, "overrides": { "never_compact": ["terraform plan"] } }
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Admins** can put the same keys in Claude Code's managed settings to roll it out to every machine. To control what your team runs, fork the repo and use `your-org/kompactor` in the commands above. The [usage guide](https://github.com/amarkum/kompactor/blob/main/docs/usage.html) (also in the dashboard as **Guide**) covers rollout, troubleshooting and FAQs.
|
|
222
|
+
|
|
223
|
+
## Commands
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
kompactor status: on/off, level, savings, how to use it
|
|
227
|
+
kompactor setup connect to Claude Code (CLI + VS Code) and open the dashboard
|
|
228
|
+
kompactor start / stop turn on (dashboard in the background) / pause
|
|
229
|
+
kompactor uninstall [--purge] remove from Claude Code
|
|
230
|
+
kompactor presets list levels kompactor config preset 4 change level
|
|
231
|
+
kompactor gain savings so far kompactor estimate replay past sessions
|
|
232
|
+
kompactor graph <action> query, impact, explain, callers, deps, path, report, unused
|
|
233
|
+
kompactor show ID / search TEXT the raw outputs Kompactor shortened
|
|
234
|
+
kompactor prove A/B test Kompactor in real Claude Code sessions
|
|
235
|
+
kompactor doctor check the installation
|
|
236
|
+
kompactor ui the dashboard, in the foreground
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Development
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
python -m unittest discover tests # 82 tests, including the real shell prefix run as Claude Code runs it
|
|
243
|
+
node vscode/test/smoke.js # VS Code extension against a mock API
|
|
244
|
+
./scripts/build-vsix.sh # › dist/kompactor-<version>.vsix
|
|
245
|
+
python scripts/bump_version.py X.Y.Z # bump every version; pushing to main publishes to PyPI
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
How Claude Code's hooks behave on success, failure and very long output, and why Kompactor uses a shell prefix rather than rewriting commands: [docs/SPEC.md](https://github.com/amarkum/kompactor/blob/main/docs/SPEC.md).
|
|
249
|
+
|
|
250
|
+
Kompactor was called Kompact until version 0.4; installing it replaces an old Kompact install's settings.
|
|
251
|
+
|
|
252
|
+
[Privacy](https://github.com/amarkum/kompactor/blob/main/PRIVACY.md) · [MIT License](https://github.com/amarkum/kompactor/blob/main/LICENSE)
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/amarkum/kompactor/main/docs/brand/kompactor-logo-light.png" alt="Kompactor" width="240">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center"><b>Cut the tokens Claude Code spends on noise.</b><br>
|
|
6
|
+
Shorter tool output for Claude, the same answers, and a dashboard that shows what every turn saved.</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">Claude Code CLI and VS Code · Python, Go, TypeScript, React · no dependencies (Python 3.9+) · MIT</p>
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Most of a Claude Code session's tokens aren't your prompt or Claude's answer. They're tool output: test runs, installs, `git log`, whole-file reads. That output is sent again on every later turn until the context is compacted. Kompactor shrinks it before Claude reads it, and always keeps errors, failing tests, your own stack frames and summary lines.
|
|
13
|
+
|
|
14
|
+
**Measured in real Claude Code sessions:** −16% tokens, −10% cost, −22% output tokens at the default level, with the same answers (27/27 correct with and without). Up to −37% cost on a failing test run. [See the evidence](#evidence)
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
## Contents
|
|
19
|
+
|
|
20
|
+
[Install](#install) · [After you install](#after-you-install) · [How it works](#how-it-works) · [Use it from Claude Code](#use-it-from-claude-code) · [Quality vs tokens](#quality-vs-tokens) · [See your savings](#see-your-savings) · [Turn it off](#turn-it-off-or-remove-it) · [Evidence](#evidence) · [Code graph](#code-graph) · [Teams](#use-it-across-a-team) · [Commands](#commands)
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
Pick one. All of them set up the same thing, and the CLI and the VS Code extension share it.
|
|
25
|
+
|
|
26
|
+
**Claude Code plugin** (recommended). In any Claude Code session, one line at a time:
|
|
27
|
+
```
|
|
28
|
+
/plugin marketplace add amarkum/kompactor
|
|
29
|
+
/plugin install kompactor@kompactor
|
|
30
|
+
/kompactor setup
|
|
31
|
+
```
|
|
32
|
+
The last step adds the status line and the shell prefix that compacts failing commands, which a plugin can't set itself. Then restart Claude Code.
|
|
33
|
+
|
|
34
|
+
**pip / pipx / uv** (macOS, Linux, Windows):
|
|
35
|
+
```bash
|
|
36
|
+
pipx install kompactor # or: pip install kompactor · uv tool install kompactor
|
|
37
|
+
kompactor setup
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**VS Code.** Download `kompactor-0.7.2.vsix` from [Releases](https://github.com/amarkum/kompactor/releases), install it (Extensions › `⋯` › *Install from VSIX…*), and click **Enable** when Kompactor asks.
|
|
41
|
+
|
|
42
|
+
## After you install
|
|
43
|
+
|
|
44
|
+
1. **Restart Claude Code** (CLI or VS Code). Kompactor starts with the next session.
|
|
45
|
+
2. **Work as usual.** You don't call Kompactor; it acts on Claude's tool calls by itself. After each reply you'll see a line such as `Kompactor: −8.2k tokens this turn`, and the status line shows the running total.
|
|
46
|
+
3. **Check it's on:** run `kompactor` in a terminal (or `/kompactor` in Claude Code). It shows whether it's on, your level, savings so far and how to change things:
|
|
47
|
+
```
|
|
48
|
+
Kompactor 0.7.2: ON
|
|
49
|
+
Connected via the Claude Code plugin. New Claude Code sessions are compacted.
|
|
50
|
+
Level: Balanced (level 3 of 5). Change it: `kompactor config preset 1-5`, the dashboard, or /kompactor balanced
|
|
51
|
+
Saved so far: 41.3k tokens (−38%) over 52 tool calls. Details: `kompactor gain`
|
|
52
|
+
```
|
|
53
|
+
4. **Open the dashboard:** `kompactor start` runs it in the background on a free port and prints the address.
|
|
54
|
+
|
|
55
|
+
## How it works
|
|
56
|
+
|
|
57
|
+
Kompactor uses Claude Code's hooks, so it sits between Claude's tools and Claude itself:
|
|
58
|
+
|
|
59
|
+
| When Claude… | Kompactor… |
|
|
60
|
+
|---|---|
|
|
61
|
+
| runs a command | drops passing tests, progress bars, download chatter, library stack frames and lock-file diffs. Keeps errors, failures, your frames and summaries. |
|
|
62
|
+
| runs a command that **fails** | runs it to completion through a shell prefix, compacts it and passes the exit code through. (Without this, Claude Code cuts failing output to its first and last ~5K characters, usually losing the failures at the end.) |
|
|
63
|
+
| opens a big source file | returns its outline first: symbols with line ranges, who imports it and which tests cover it. Claude reads only the ranges it needs; repeating the read returns the whole file. |
|
|
64
|
+
| first searches the code | gives a short map of the most depended-on modules, once per session. |
|
|
65
|
+
| writes a reply | gets a few lines of rules: answer first, smallest diff, reuse before writing (0–177 tokens, depending on the level). |
|
|
66
|
+
|
|
67
|
+
**Nothing is lost.** Every shortened output keeps a raw copy that Claude can fetch with `kompactor show <id>`. Kompactor never changes what a command does, your permission rules still apply, and if anything goes wrong it lets the original output through. Everything runs on your machine; nothing is sent anywhere ([privacy](https://github.com/amarkum/kompactor/blob/main/PRIVACY.md)).
|
|
68
|
+
|
|
69
|
+
## Use it from Claude Code
|
|
70
|
+
|
|
71
|
+
Type these in any Claude Code chat:
|
|
72
|
+
|
|
73
|
+
| Command | What it does |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `/kompactor` or `/kompactor status` | Is it on, current level, savings so far |
|
|
76
|
+
| `/kompactor balanced`, `/kompactor max savings`, `/kompactor max quality` | Change the level |
|
|
77
|
+
| `/kompactor stop` · `/kompactor start` | Pause it · turn it back on |
|
|
78
|
+
| `/kompactor review` | Suggests cuts in your current diff: duplicated helpers, unused options, dead branches |
|
|
79
|
+
| `/kompactor audit` · `/kompactor debt` | Dead-code candidates · a list of FIXME/HACK/TODO shortcuts |
|
|
80
|
+
|
|
81
|
+
Claude also uses the code graph on its own when it needs to find code or check what a change affects.
|
|
82
|
+
|
|
83
|
+
## Quality vs tokens
|
|
84
|
+
|
|
85
|
+

|
|
86
|
+
|
|
87
|
+
One level sets everything. Change it on the dashboard, with `/kompactor <level>` in chat, or with `kompactor config preset <1-5>`. Each project can have its own level.
|
|
88
|
+
|
|
89
|
+
| Level | What Claude gets |
|
|
90
|
+
|---|---|
|
|
91
|
+
| 1 Max quality | Almost everything. Only outputs over ~1.5k tokens are touched, and only pure noise is removed. |
|
|
92
|
+
| 2 Quality | Noisy commands compacted, passing tests hidden, one-line `git log`, outlines for files over 800 lines. |
|
|
93
|
+
| 3 **Balanced** (default) | Outlines from 400 lines, library frames trimmed, a 500-token code map, lean-code rules. |
|
|
94
|
+
| 4 Savings | Tighter caps, 3 lines of diff context, outlines from 250 lines, shorter prose. |
|
|
95
|
+
| 5 Max savings | 80-line caps, 1 line of diff context, outlines from 150 lines, telegraphic prose. |
|
|
96
|
+
|
|
97
|
+
The dashboard also lets you change any single option, with a live preview of exactly what Claude would see.
|
|
98
|
+
|
|
99
|
+
## See your savings
|
|
100
|
+
|
|
101
|
+
| Where | What you see |
|
|
102
|
+
|---|---|
|
|
103
|
+
| After each reply | `Kompactor: −8.2k tokens this turn (13.1k › 4.9k, −63%) · session −41k · context ≈31% smaller` |
|
|
104
|
+
| CLI status line | `Kompactor −41.3k · ctx −31% · last turn −8.2k · Balanced` |
|
|
105
|
+
| VS Code status bar | Running savings; hover for details |
|
|
106
|
+
| Dashboard (`kompactor start`) | Per-turn chart, biggest wins, savings by feature and by project |
|
|
107
|
+
| `kompactor gain` | The same numbers in the terminal |
|
|
108
|
+
| `kompactor estimate` | Replays your **past** sessions and shows what Kompactor would have saved |
|
|
109
|
+
|
|
110
|
+
The numbers are conservative: they count only what Claude would really have read, and a saving is reversed when Claude reads the full file anyway.
|
|
111
|
+
|
|
112
|
+
## Turn it off or remove it
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
kompactor stop # pause: Claude Code output passes through untouched; settings are kept
|
|
116
|
+
kompactor start # turn it back on
|
|
117
|
+
kompactor uninstall # remove hooks, status line, shell prefix and skill (add --purge to delete ~/.kompactor too)
|
|
118
|
+
```
|
|
119
|
+
Then remove the package the way you installed it: `claude plugin uninstall kompactor`, `pipx uninstall kompactor`, or uninstall the extension in VS Code. Setup never replaces a status line or shell prefix you already had, and keeps a backup in `~/.claude/settings.json.kompactor-backup`.
|
|
120
|
+
|
|
121
|
+
## Evidence
|
|
122
|
+
|
|
123
|
+
`kompactor prove` runs each task in real headless Claude Code sessions (`claude -p`), 3 times without Kompactor and 3 times with it, interleaved, with the same prompt, tools, turn limit and budget cap. Tokens are input + cache writes + cache reads + output across every API call; cost is Claude Code's own figure.
|
|
124
|
+
|
|
125
|
+
| Task | Repo | Tokens | Cost | Turns | Correct (without › with) |
|
|
126
|
+
|---|---|---:|---:|---|---|
|
|
127
|
+
| Find the failing Go test and its error | Cobra | **−33%** | **−18%** | 3.3 › 2.0 | 3/3 › 3/3 |
|
|
128
|
+
| Find how requests are deduplicated | SWR | **−32%** | −12% | 3.0 › 2.0 | 3/3 › 3/3 |
|
|
129
|
+
| Find where the session cookie is signed | Flask | **−26%** | −11% | 3.7 › 2.7 | 3/3 › 3/3 |
|
|
130
|
+
| Find the flag-group validation function | Cobra | −24% | −6% | 2.7 › 2.3 | 3/3 › 3/3 |
|
|
131
|
+
| Most-changed files in the last 40 commits | Flask | −16% | +4% | 3.7 › 3.0 | 3/3 › 3/3 |
|
|
132
|
+
| Find the failing vitest test (`--reporter=verbose`) | zustand | −7% | **−37%** | 2.0 › 2.0 | 3/3 › 3/3 |
|
|
133
|
+
| Type-check and list errors | ky | +1% | −2% | 2.0 › 2.0 | 3/3 › 3/3 |
|
|
134
|
+
| Find the failing pytest tests | Flask | +1% | +3% | 2.0 › 2.0 | 3/3 › 3/3 |
|
|
135
|
+
| What does changing `createStore` affect | zustand | +17% | +4% | 2.0 › 2.3 | 3/3 › 3/3 |
|
|
136
|
+
| **Total (54 sessions)** | | **−16%** | **−10%** | | **27/27 › 27/27** |
|
|
137
|
+
|
|
138
|
+
At the other levels, against the same baseline:
|
|
139
|
+
|
|
140
|
+
| Level | Tokens | Cost | Output tokens | Correct |
|
|
141
|
+
|---|---:|---:|---:|---|
|
|
142
|
+
| 1 Max quality | +3% | −1% | 0% | 27/27 |
|
|
143
|
+
| 3 Balanced (default) | **−16%** | **−10%** | **−22%** | 27/27 |
|
|
144
|
+
| 5 Max savings | −12% | −10% | −22% | 27/27 |
|
|
145
|
+
|
|
146
|
+
- **The wins come from avoided turns.** Every turn re-sends the whole context. The vitest failure was 32K characters of passing tests; Kompactor gave Claude 1K characters with the failure, at 37% lower cost.
|
|
147
|
+
- **Short sessions pay a small fixed cost.** On 2-turn tasks with little output, Kompactor's rules add about 1%.
|
|
148
|
+
- **Single commands shrink much more** than whole sessions, because most of a session is Claude Code's own fixed context:
|
|
149
|
+
|
|
150
|
+
| Repo | Command | Raw tokens | Balanced | Max savings |
|
|
151
|
+
|---|---|---:|---:|---:|
|
|
152
|
+
| Flask | `pytest -v tests` (1 failure, 482 passed) | 9,842 | 1,138 (**−88%**) | 696 (**−93%**) |
|
|
153
|
+
| Flask | `grep -rn 'def ' src` | 8,492 | 3,230 (−62%) | 1,323 (−84%) |
|
|
154
|
+
| Flask | `git log -n 40` | 1,457 | 598 (−59%) | 598 (−59%) |
|
|
155
|
+
| ky | `npm install` (fresh) | ~33,000 | 469 (**−99%**) | 451 (−99%) |
|
|
156
|
+
| Flask | Read `src/flask/app.py` (1,625 lines) › outline | 14,084 | 1,490 (−89%) | 1,490 (−89%) |
|
|
157
|
+
| ky | Read `source/core/Ky.ts` (1,376 lines) › outline | 12,452 | 919 (−93%) | 919 (−93%) |
|
|
158
|
+
|
|
159
|
+
**Read more:** [full report](https://github.com/amarkum/kompactor/blob/main/evidence/REPORT.md) · [every session's tokens, tool calls and answers](https://github.com/amarkum/kompactor/blob/main/evidence/results.json) · [what Claude received in each arm for the same failing test run](https://github.com/amarkum/kompactor/blob/main/evidence/EXAMPLE.md) (15,617 vs 1,039 characters) · [how Kompactor compares with graphify, rtk, caveman and others](https://github.com/amarkum/kompactor/blob/main/docs/comparison.md)
|
|
160
|
+
|
|
161
|
+
**Check it on your own work:** `kompactor estimate` replays your past sessions, and `kompactor prove` reruns tasks with and without Kompactor.
|
|
162
|
+
|
|
163
|
+
## Code graph
|
|
164
|
+
|
|
165
|
+

|
|
166
|
+
|
|
167
|
+
A local index of your repo (Python, Go, TypeScript, JavaScript, React), built in about a second and refreshed in the background. Nothing is sent anywhere and nothing is written to the repo.
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
kompactor graph query "session cookie" find code by topic, with line ranges and who uses it
|
|
171
|
+
kompactor graph impact createStore what uses it, and which tests to run
|
|
172
|
+
kompactor graph explain Name one symbol: signature, callers, callees, tests
|
|
173
|
+
kompactor graph report core modules, entry points, import cycles
|
|
174
|
+
kompactor graph unused dead-code candidates
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Supported languages and what Kompactor knows about each: [docs/languages.md](https://github.com/amarkum/kompactor/blob/main/docs/languages.md).
|
|
178
|
+
|
|
179
|
+
## Use it across a team
|
|
180
|
+
|
|
181
|
+

|
|
182
|
+
|
|
183
|
+
**Turn it on for everyone who works in a repo.** Commit this as `.claude/settings.json`:
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"extraKnownMarketplaces": {
|
|
187
|
+
"kompactor": { "source": { "source": "github", "repo": "amarkum/kompactor" }, "autoUpdate": true }
|
|
188
|
+
},
|
|
189
|
+
"enabledPlugins": { "kompactor@kompactor": true }
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
When a teammate trusts the folder, Claude Code installs the plugin; each person then runs `/kompactor setup` once.
|
|
193
|
+
|
|
194
|
+
**Set the team's level for a repo** with a committed `.kompactor.json`:
|
|
195
|
+
```json
|
|
196
|
+
{ "preset": 4, "overrides": { "never_compact": ["terraform plan"] } }
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Admins** can put the same keys in Claude Code's managed settings to roll it out to every machine. To control what your team runs, fork the repo and use `your-org/kompactor` in the commands above. The [usage guide](https://github.com/amarkum/kompactor/blob/main/docs/usage.html) (also in the dashboard as **Guide**) covers rollout, troubleshooting and FAQs.
|
|
200
|
+
|
|
201
|
+
## Commands
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
kompactor status: on/off, level, savings, how to use it
|
|
205
|
+
kompactor setup connect to Claude Code (CLI + VS Code) and open the dashboard
|
|
206
|
+
kompactor start / stop turn on (dashboard in the background) / pause
|
|
207
|
+
kompactor uninstall [--purge] remove from Claude Code
|
|
208
|
+
kompactor presets list levels kompactor config preset 4 change level
|
|
209
|
+
kompactor gain savings so far kompactor estimate replay past sessions
|
|
210
|
+
kompactor graph <action> query, impact, explain, callers, deps, path, report, unused
|
|
211
|
+
kompactor show ID / search TEXT the raw outputs Kompactor shortened
|
|
212
|
+
kompactor prove A/B test Kompactor in real Claude Code sessions
|
|
213
|
+
kompactor doctor check the installation
|
|
214
|
+
kompactor ui the dashboard, in the foreground
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Development
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
python -m unittest discover tests # 82 tests, including the real shell prefix run as Claude Code runs it
|
|
221
|
+
node vscode/test/smoke.js # VS Code extension against a mock API
|
|
222
|
+
./scripts/build-vsix.sh # › dist/kompactor-<version>.vsix
|
|
223
|
+
python scripts/bump_version.py X.Y.Z # bump every version; pushing to main publishes to PyPI
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
How Claude Code's hooks behave on success, failure and very long output, and why Kompactor uses a shell prefix rather than rewriting commands: [docs/SPEC.md](https://github.com/amarkum/kompactor/blob/main/docs/SPEC.md).
|
|
227
|
+
|
|
228
|
+
Kompactor was called Kompact until version 0.4; installing it replaces an old Kompact install's settings.
|
|
229
|
+
|
|
230
|
+
[Privacy](https://github.com/amarkum/kompactor/blob/main/PRIVACY.md) · [MIT License](https://github.com/amarkum/kompactor/blob/main/LICENSE)
|