graphsift 1.9.0__tar.gz → 2.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.
Files changed (59) hide show
  1. graphsift-2.0.0/PKG-INFO +582 -0
  2. graphsift-2.0.0/README.md +494 -0
  3. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/__init__.py +23 -0
  4. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/_version.py +1 -1
  5. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/cli.py +235 -0
  6. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/compact_context.py +19 -0
  7. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/compress.py +966 -845
  8. graphsift-2.0.0/graphsift/evidence_check.py +126 -0
  9. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/mcp_server.py +307 -0
  10. graphsift-2.0.0/graphsift/mcp_shrink.py +100 -0
  11. graphsift-2.0.0/graphsift/prompt_templates.py +108 -0
  12. graphsift-2.0.0/graphsift/read_cache.py +70 -0
  13. graphsift-2.0.0/graphsift/tiered_memory.py +74 -0
  14. graphsift-2.0.0/graphsift/tool_budgets.py +98 -0
  15. graphsift-2.0.0/graphsift/verify_hooks.py +108 -0
  16. graphsift-2.0.0/graphsift.egg-info/PKG-INFO +582 -0
  17. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift.egg-info/SOURCES.txt +8 -0
  18. graphsift-2.0.0/tests/test_optimization.py +257 -0
  19. graphsift-1.9.0/PKG-INFO +0 -565
  20. graphsift-1.9.0/README.md +0 -477
  21. graphsift-1.9.0/graphsift.egg-info/PKG-INFO +0 -565
  22. {graphsift-1.9.0 → graphsift-2.0.0}/LICENSE +0 -0
  23. {graphsift-1.9.0 → graphsift-2.0.0}/benchmark/run_benchmarks.py +0 -0
  24. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/a2a_server.py +0 -0
  25. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/adapters/__init__.py +0 -0
  26. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/adapters/filesystem.py +0 -0
  27. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/adapters/postprocess.py +0 -0
  28. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/adapters/storage.py +0 -0
  29. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/advanced.py +0 -0
  30. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/analytics.py +0 -0
  31. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/auto_fix.py +0 -0
  32. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/code_memory.py +0 -0
  33. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/core.py +0 -0
  34. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/evidence.py +0 -0
  35. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/exceptions.py +0 -0
  36. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/harness.py +0 -0
  37. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/hooks.py +0 -0
  38. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/hybrid_search.py +0 -0
  39. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/mcp_tasks.py +0 -0
  40. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/memory.py +0 -0
  41. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/models.py +0 -0
  42. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/parsers/__init__.py +0 -0
  43. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/parsers/tree_sitter_parser.py +0 -0
  44. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/temporal_graph.py +0 -0
  45. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/typed_retrieval.py +0 -0
  46. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift/utils/__init__.py +0 -0
  47. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift.egg-info/dependency_links.txt +0 -0
  48. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift.egg-info/entry_points.txt +0 -0
  49. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift.egg-info/requires.txt +0 -0
  50. {graphsift-1.9.0 → graphsift-2.0.0}/graphsift.egg-info/top_level.txt +0 -0
  51. {graphsift-1.9.0 → graphsift-2.0.0}/pyproject.toml +0 -0
  52. {graphsift-1.9.0 → graphsift-2.0.0}/setup.cfg +0 -0
  53. {graphsift-1.9.0 → graphsift-2.0.0}/tests/test_advanced.py +0 -0
  54. {graphsift-1.9.0 → graphsift-2.0.0}/tests/test_auto_fix.py +0 -0
  55. {graphsift-1.9.0 → graphsift-2.0.0}/tests/test_core.py +0 -0
  56. {graphsift-1.9.0 → graphsift-2.0.0}/tests/test_dedup.py +0 -0
  57. {graphsift-1.9.0 → graphsift-2.0.0}/tests/test_diff_trimming.py +0 -0
  58. {graphsift-1.9.0 → graphsift-2.0.0}/tests/test_hybrid_search.py +0 -0
  59. {graphsift-1.9.0 → graphsift-2.0.0}/tests/test_tree_sitter.py +0 -0
@@ -0,0 +1,582 @@
1
+ Metadata-Version: 2.4
2
+ Name: graphsift
3
+ Version: 2.0.0
4
+ Summary: graphsift: #1 Claude token saver & LLM token optimizer. AST dependency graph, BM25+graph ranked relevance, multi-tier context selection, 14 languages, tree-sitter parsing, 19-CLI output compression (86% avg). 80-150x token reduction, F1 0.85. Hybrid search, dedup, diff-aware trimming, cycle & dead code detection. MCP server. Agent memory, typed graph retrieval, context compaction, A2A protocol, temporal code graph.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/maheshmakvana/graphsift
7
+ Project-URL: Repository, https://github.com/maheshmakvana/graphsift
8
+ Project-URL: Issues, https://github.com/maheshmakvana/graphsift/issues
9
+ Project-URL: Changelog, https://github.com/maheshmakvana/graphsift/releases
10
+ Project-URL: Documentation, https://github.com/maheshmakvana/graphsift#readme
11
+ Keywords: save claude tokens,claude token saver,claude token optimizer,claude token compression,reduce claude api costs,claude cost reduction,claude code save tokens,claude context optimizer,claude api token reducer,optimize claude context,claude context window,claude api savings,llm token optimization,llm token compression,llm token reducer,reduce llm api costs,llm context optimization,llm context compression,llm context window,token reduction tool,token cost reduction,token budget tool,token saving tools,context window optimization,code context compression,code context optimization,save gpt tokens,reduce openai api costs,openai token optimizer,gpt token reduction,gpt context optimizer,save gemini tokens,gemini token optimizer,reduce gemini api costs,code review token savings,ai code review cost reduction,code review claude,code review openai,code review gpt4,code review gpt5,code review gemini,code review codex,code review llm,code review automation,code review context,llm code review tool,cli output compression,command output compression,pytest output compression,terminal output compression,bash output compression,git output compression,docker output compression,kubectl output compression,npm output compression,cargo output compression,eslint output compression,go test output compression,jest output compression,log output compression,output token compression,ast dependency graph,code graph python,dependency graph python,blast radius analysis,semantic code search,hybrid code search,codebase context llm,token budget code,python ast parser,tree sitter parser python,code intelligence python,ranked context selection,bm25 code search,multi-file diff analysis,decorator edge detection,dynamic import graph,monorepo context,incremental code indexing,code-review-graph alternative,better than code review graph,code review graph vs graphsift,mcp server code,mcp server claude,claude code integration,claude code mcp,codex integration,openai integration,gemini integration,openai compatible api,cycle detection python,dead code detection,auto fix suggestions,code deduplication,diff aware context,cache aware llm,token analytics,token savings analytics,graphsift,agent-memory,graphrag,typed-retrieval,context-compaction,a2a-protocol,conversation-compaction,code-memory,temporal-graph,evidence-citations,harness-engineering
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Classifier: Topic :: Software Development :: Code Generators
23
+ Classifier: Topic :: Software Development :: Testing
24
+ Classifier: Topic :: Software Development :: Compilers
25
+ Classifier: Topic :: Text Processing :: Indexing
26
+ Classifier: Topic :: Text Processing :: Filters
27
+ Classifier: Topic :: Utilities
28
+ Classifier: Intended Audience :: Developers
29
+ Classifier: Intended Audience :: Science/Research
30
+ Classifier: Intended Audience :: Information Technology
31
+ Classifier: Development Status :: 5 - Production/Stable
32
+ Classifier: Environment :: Console
33
+ Classifier: Environment :: Plugins
34
+ Classifier: Framework :: AsyncIO
35
+ Classifier: Natural Language :: English
36
+ Classifier: Typing :: Typed
37
+ Requires-Python: >=3.9
38
+ Description-Content-Type: text/markdown
39
+ License-File: LICENSE
40
+ Requires-Dist: pydantic>=2.0
41
+ Provides-Extra: tokenpruner
42
+ Requires-Dist: tokenpruner>=1.0.0; extra == "tokenpruner"
43
+ Provides-Extra: treesitter
44
+ Requires-Dist: tree-sitter>=0.23.0; extra == "treesitter"
45
+ Requires-Dist: tree-sitter-python>=0.23.0; extra == "treesitter"
46
+ Requires-Dist: tree-sitter-javascript>=0.23.0; extra == "treesitter"
47
+ Requires-Dist: tree-sitter-typescript>=0.23.0; extra == "treesitter"
48
+ Requires-Dist: tree-sitter-go>=0.23.0; extra == "treesitter"
49
+ Requires-Dist: tree-sitter-rust>=0.23.0; extra == "treesitter"
50
+ Requires-Dist: tree-sitter-java>=0.23.0; extra == "treesitter"
51
+ Requires-Dist: tree-sitter-c>=0.23.0; extra == "treesitter"
52
+ Requires-Dist: tree-sitter-cpp>=0.23.0; extra == "treesitter"
53
+ Requires-Dist: tree-sitter-ruby>=0.23.0; extra == "treesitter"
54
+ Requires-Dist: tree-sitter-php>=0.23.0; extra == "treesitter"
55
+ Requires-Dist: tree-sitter-bash>=0.23.0; extra == "treesitter"
56
+ Provides-Extra: all
57
+ Requires-Dist: tokenpruner>=1.0.0; extra == "all"
58
+ Requires-Dist: tree-sitter>=0.23.0; extra == "all"
59
+ Requires-Dist: tree-sitter-python>=0.23.0; extra == "all"
60
+ Requires-Dist: tree-sitter-javascript>=0.23.0; extra == "all"
61
+ Requires-Dist: tree-sitter-typescript>=0.23.0; extra == "all"
62
+ Requires-Dist: tree-sitter-go>=0.23.0; extra == "all"
63
+ Requires-Dist: tree-sitter-rust>=0.23.0; extra == "all"
64
+ Requires-Dist: tree-sitter-java>=0.23.0; extra == "all"
65
+ Requires-Dist: tree-sitter-c>=0.23.0; extra == "all"
66
+ Requires-Dist: tree-sitter-cpp>=0.23.0; extra == "all"
67
+ Requires-Dist: tree-sitter-ruby>=0.23.0; extra == "all"
68
+ Requires-Dist: tree-sitter-php>=0.23.0; extra == "all"
69
+ Requires-Dist: tree-sitter-bash>=0.23.0; extra == "all"
70
+ Provides-Extra: dev
71
+ Requires-Dist: pytest>=7.0; extra == "dev"
72
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
73
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
74
+ Requires-Dist: tokenpruner>=1.0.0; extra == "dev"
75
+ Requires-Dist: tree-sitter>=0.23.0; extra == "dev"
76
+ Requires-Dist: tree-sitter-python>=0.23.0; extra == "dev"
77
+ Requires-Dist: tree-sitter-javascript>=0.23.0; extra == "dev"
78
+ Requires-Dist: tree-sitter-typescript>=0.23.0; extra == "dev"
79
+ Requires-Dist: tree-sitter-go>=0.23.0; extra == "dev"
80
+ Requires-Dist: tree-sitter-rust>=0.23.0; extra == "dev"
81
+ Requires-Dist: tree-sitter-java>=0.23.0; extra == "dev"
82
+ Requires-Dist: tree-sitter-c>=0.23.0; extra == "dev"
83
+ Requires-Dist: tree-sitter-cpp>=0.23.0; extra == "dev"
84
+ Requires-Dist: tree-sitter-ruby>=0.23.0; extra == "dev"
85
+ Requires-Dist: tree-sitter-php>=0.23.0; extra == "dev"
86
+ Requires-Dist: tree-sitter-bash>=0.23.0; extra == "dev"
87
+ Dynamic: license-file
88
+
89
+ <p align="center">
90
+ <img src="https://raw.githubusercontent.com/maheshmakvana/graphsift/master/docs/images/hero_banner.png" alt="graphsift — Save Claude Tokens, Reduce LLM API Costs, Optimize Context Windows with ranked code selection for Claude GPT Gemini, F1 0.85, 14 languages, token budget enforcement" width="750">
91
+ </p>
92
+
93
+ <h1 align="center">🕸️ graphsift</h1>
94
+ <p align="center">
95
+ <strong>#1 token saver for Claude, GPT, Gemini & every LLM.<br>
96
+ Ranked context. Hard budgets. 19 CLI compressors. 80-150× fewer tokens. 🪄</strong>
97
+ </p>
98
+
99
+ <p align="center">
100
+ <a href="https://pypi.org/project/graphsift/"><img src="https://img.shields.io/pypi/v/graphsift.svg?style=flat&label=version&color=blue" alt="PyPI version"></a>
101
+ <a href="https://pypi.org/project/graphsift/"><img src="https://img.shields.io/pypi/pyversions/graphsift.svg?style=flat" alt="Python"></a>
102
+ <a href="https://github.com/maheshmakvana/graphsift"><img src="https://img.shields.io/github/stars/maheshmakvana/graphsift?style=flat&label=stars&color=yellow" alt="GitHub stars"></a>
103
+ <a href="https://github.com/maheshmakvana/graphsift/forks"><img src="https://img.shields.io/github/forks/maheshmakvana/graphsift?style=flat&color=orange" alt="GitHub forks"></a>
104
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-green.svg?style=flat" alt="License"></a>
105
+ <a href="https://pypi.org/project/graphsift/"><img src="https://img.shields.io/pypi/dm/graphsift?style=flat&label=downloads&color=brightgreen" alt="Downloads"></a>
106
+ <a href="https://github.com/maheshmakvana/graphsift/actions"><img src="https://img.shields.io/github/actions/workflow/status/maheshmakvana/graphsift/tests.yml?style=flat&label=tests&color=blue" alt="CI"></a>
107
+ <a href="https://github.com/maheshmakvana/graphsift"><img src="https://img.shields.io/github/last-commit/maheshmakvana/graphsift?style=flat&color=blue" alt="Last commit"></a>
108
+ <br>
109
+ <img src="https://img.shields.io/badge/MCP%20tools-27-blueviolet" alt="MCP tools">
110
+ <img src="https://img.shields.io/badge/compressors-19-success" alt="compressors">
111
+ <img src="https://img.shields.io/badge/tests-271%20passed-blue" alt="tests">
112
+ <img src="https://img.shields.io/badge/languages-14-lightgrey" alt="languages">
113
+ <img src="https://img.shields.io/badge/F1-0.85-success" alt="F1">
114
+ <a href="https://www.python.org/"><img src="https://img.shields.io/badge/made%20with-Python-1f425f.svg" alt="Python"></a>
115
+ </p>
116
+
117
+ <p align="center">
118
+ <a href="#-quick-start">Quick Start</a> ·
119
+ <a href="#-token-savings-at-a-glance">Token Savings</a> ·
120
+ <a href="#-install-in-3-seconds">Install</a> ·
121
+ <a href="#-before--after">Before/After</a> ·
122
+ <a href="#-cli-output-compression--19-compressors">Compression</a> ·
123
+ <a href="#-why-graphsift">Why graphsift</a> ·
124
+ <a href="#%EF%B8%8F-works-with-every-llm-and-agent">Compatibility</a> ·
125
+ <a href="#-benchmarks">Benchmarks</a> ·
126
+ <a href="#-key-features">Features</a> ·
127
+ <a href="#%EF%B8%8F-caveman--graphsift--unstoppable">Caveman + graphsift</a>
128
+ </p>
129
+
130
+ ---
131
+
132
+ ## 💰 why pay many token when graphsift do trick?
133
+
134
+ **graphsift = the token optimizer for every LLM.**
135
+ Not a "blast radius" tool. Not a summarizer. **Ranked relevance + hard budgets + 19 CLI compressors.**
136
+
137
+ ```yaml
138
+ What graphsift does in one sentence:
139
+ LLM code review costs → 93-99% cheaper
140
+ CLI output tokens → 60-97% smaller
141
+ Context windows → never explode
142
+ Relevance accuracy → F1 0.85 (vs 0.54 for alternatives)
143
+ ```
144
+
145
+ > [!IMPORTANT]
146
+ > **Why this matters:** Every code review costs tokens. Every token costs money.
147
+ > With graphsift, you pay for **signal**, not noise. **$0.01–$0.05 per review** instead of $0.50–$2.70.
148
+ > At 100 reviews/day → **$150–$180/day saved. Easy.**
149
+
150
+ ---
151
+
152
+ ## 🎯 Token Savings Dashboard
153
+
154
+ ```
155
+ ╔══════════════════════════════════════════════════════════════╗
156
+ ║ 📊 graphsift SAVINGS ║
157
+ ╠══════════════════════════════════════════════════════════════╣
158
+ ║ Token reduction vs raw source ████████████████░ 99% ║
159
+ ║ Token reduction vs blast-radius ██████████████░░░ 93% ║
160
+ ║ CLI output compression (avg) █████████████░░░░ 77% ║
161
+ ║ Relevance accuracy (F1) ████████████████░ 0.85 ║
162
+ ║ Cost savings per review ████████████████░ 99% ║
163
+ ║ Supported languages ████████████████░ 14 ║
164
+ ║ CLI compressors █████████████████░ 19 ║
165
+ ╚══════════════════════════════════════════════════════════════╝
166
+ ```
167
+
168
+ [⬆ back to top](#-graphsift)
169
+
170
+ ---
171
+
172
+ ## ⚡ Install in 3 Seconds
173
+
174
+ ```bash
175
+ pip install graphsift # Base — Python 3.9+, pure Python, zero hard deps
176
+ pip install graphsift[all] # Full — tree-sitter 11 langs + compression
177
+ pip install graphsift[treesitter]# Precise AST parsing (Python, JS, TS, Go, Rust, Java...)
178
+ ```
179
+
180
+ Then:
181
+
182
+ ```bash
183
+ graphsift build # Index repo → dependency graph (sub-2s on 10k files)
184
+ graphsift install # Register MCP server with Claude Code
185
+ ```
186
+
187
+ > [!TIP]
188
+ > No npm. No npx. No Docker. No accounts. No API keys. Zero telemetry.
189
+ > One `pip install` and you're saving tokens.
190
+
191
+ ---
192
+
193
+ ## 🆚 Before & After
194
+
195
+ ### Code Review: raw source vs graphsift
196
+
197
+ | Without graphsift | With graphsift |
198
+ |---|---|
199
+ | **Everything that imports the changed file** – 143 files, ~180k tokens, $2.70/run | **3–5 ranked files within budget** – ~1k tokens, **$0.015/run** |
200
+ | "Which of these 40 test files actually matter?" — nobody knows | **Ranked 0–1** — LLM sees signal, not noise |
201
+ | Token budgets? What token budgets — **context limits explode** | **Hard cap** — never exceed context window or cost ceiling |
202
+ | **No compression** — every file is full source | **3-tier (hot/warm/cold)** — full source → signatures → excluded |
203
+
204
+ ### CLI Output: raw vs compressed
205
+
206
+ | Before (raw) | Tokens | After (graphsift) | Tokens | **Saved** |
207
+ |---|---|---|---|---|
208
+ | `pytest -v` (45 tests, full tracebacks) | 1,334 tk | Keep FAIL lines + summary only | 136 tk | **90%** |
209
+ | `kubectl get all` (wall of YAML) | 581 tk | Header + first 5 rows, whitespace compressed | 110 tk | **81%** |
210
+ | `grep -r` (25 scattered results) | 413 tk | Group by match, dedup identical lines | 22 tk | **95%** |
211
+ | `git diff` (2 files, full diff) | 889 tk | Per-file path + first 3 changed lines | 60 tk | **93%** |
212
+
213
+ > [!NOTE]
214
+ > **graphsift compresses INPUT context** (what you send to the LLM).
215
+ > For OUTPUT compression (how the LLM talks back), check out **[Caveman](https://github.com/JuliusBrussee/caveman)** — complementary, not competing.
216
+ > Together: **graphsift → cheaper prompts + Caveman → cheaper responses = maximum savings**. 🚀
217
+
218
+ ---
219
+
220
+ ## 📊 Token Savings at a Glance
221
+
222
+ Benchmarked on a **143-file FastAPI app** reviewing a 50-line change to `auth/manager.py`:
223
+
224
+ | Approach | Files sent | Tokens | Cost (Opus @ $15/M) | Savings vs raw |
225
+ |---|---|---|---|---|
226
+ | Raw source (every file) | 143/143 | ~180,000 | $2.70 | — |
227
+ | Binary blast-radius | 8–12/143 | 6,000–8,000 | $0.10 | 96% |
228
+ | **graphsift (ranked + budget)** | **3–5/143** | **800–1,200** | **$0.015** | **99.4%** |
229
+
230
+ **At 100 PRs/day:** $270 → **$1.50/day**. That's **$268.50/day saved.**
231
+
232
+ ---
233
+
234
+ ## 🧩 Works With Every LLM and Agent
235
+
236
+ graphsift is **provider-agnostic** — it delivers optimized context that works with ANY LLM:
237
+
238
+ | Tool / Model | How graphsift helps |
239
+ |---|---|
240
+ | **Claude Code** | MCP server → auto-compressed tool outputs + ranked context |
241
+ | **Claude Desktop / API** | Cache-aware context with `cache_control` breakpoints |
242
+ | **OpenAI GPT-4 / GPT-4o / o1 / o3** | Token-budget-capped context, hard limit enforcement |
243
+ | **Google Gemini** | Compressed CLI output before Gemini processes it |
244
+ | **Cursor** | MCP server → every tool call saves tokens |
245
+ | **GitHub Copilot** | Smaller context → faster completions |
246
+ | **Cline / Windsurf / Cline** | MCP tools for ranked code context |
247
+ | **Any MCP client** | 25+ MCP tools + 4 prompts + 10 resources |
248
+ | **Any REST API** | `result.rendered_context` → paste into any prompt |
249
+
250
+ **No lock-in. No vendor dependency. Pure token savings.**
251
+
252
+ ---
253
+
254
+ ## 🔥 Why graphsift
255
+
256
+ ### The Problem with "Blast-Radius" Tools
257
+
258
+ Tools like `code-review-graph` use **binary blast-radius** — they send every file that imports the changed file. Two fatal flaws:
259
+
260
+ 1. **Token overflow** — 500k+ tokens exceeds context limits *and* your budget
261
+ 2. **Noise degrades output** — LLMs hallucinate more with irrelevant context. Sending `config.py`, `utils/logging.py`, and 40 test files because they import `base.py` buries the signal
262
+
263
+ ### The graphsift Solution
264
+
265
+ graphsift treats context selection as a **ranking problem**, not a graph traversal:
266
+
267
+ | Feature | code-review-graph | **graphsift** |
268
+ |---|---|---|
269
+ | Selection strategy | Binary blast-radius (in/out) | **Ranked 0–1** with hot/warm/cold tiers |
270
+ | Token budget | None | **Hard budget** — fits any model limit |
271
+ | F1 accuracy | **0.54** (46% false positives) | **0.85** — ranked filtering + dedup |
272
+ | Token reduction | 8–49× | **80–150×** with diff-aware trimming |
273
+ | Multi-file diffs | Not supported | Union blast radius across all changed files |
274
+ | Languages | Python only | **14 languages** (Python, JS, TS, Go, Rust, Java, C++, C, Ruby, PHP, Bash, Terraform, Helm, Dockerfile) |
275
+ | Tree-sitter parsing | None | **11 languages** with precise CST/AST |
276
+ | CLI compression | None | **19 compressors, 86% average savings** |
277
+ | MCP server | No | **25+ tools + 4 prompts + 10 resources** |
278
+ | Dead code detection | None | ✅ Unreachable code from entry points |
279
+ | Cycle detection | None | ✅ Dependency cycle analysis |
280
+ | Auto-fix suggestions | None | ✅ Graph-based fix proposals |
281
+ | Incremental indexing | None | ✅ SHA-256 skip (sub-2s re-index) |
282
+ | Monorepo support | None | ✅ Multi-package via `index_roots()` |
283
+
284
+ > [!TIP]
285
+ > See the [full comparison table](#graphsift-vs-code-review-graph-head-to-head) below for 30+ criteria.
286
+
287
+ ---
288
+
289
+ ## 📦 CLI Output Compression — 19 Compressors
290
+
291
+ Pipe any CLI command to `graphsift compress` — auto-detects the command type and strips noise:
292
+
293
+ | Command | Original tokens | Compressed tokens | **Saved** |
294
+ |---|---|---|---|
295
+ | `grep -r` (25 results) | 413 tk | 22 tk | **95%** |
296
+ | `eslint` (12 problems) | 308 tk | 17 tk | **94%** |
297
+ | `git diff` (2 files) | 889 tk | 60 tk | **93%** |
298
+ | `pytest -v` (45 tests) | 1,334 tk | 136 tk | **90%** |
299
+ | `npm install` output | 288 tk | 39 tk | **87%** |
300
+ | `docker ps` (10 images) | 463 tk | 63 tk | **86%** |
301
+ | `git status` | 174 tk | 25 tk | **86%** |
302
+ | `pip install` (7 pkgs) | 312 tk | 47 tk | **85%** |
303
+ | `cargo build` | 463 tk | 80 tk | **83%** |
304
+ | `kubectl get all` | 581 tk | 110 tk | **81%** |
305
+ | `git log` (3 commits) | 234 tk | 47 tk | **80%** |
306
+ | `make` output | 250 tk | 55 tk | **78%** |
307
+ | `aws` CLI JSON | 477 tk | 115 tk | **76%** |
308
+ | `jest` (10 tests) | 310 tk | 76 tk | **75%** |
309
+ | `go test` | 284 tk | 74 tk | **74%** |
310
+ | App logs (16 lines) | 402 tk | 155 tk | **61%** |
311
+ | `cat` (large file) | 672 tk | 479 tk | **29%** |
312
+ | **Weighted average** | **8,138 tk** | **1,884 tk** | **77%** |
313
+
314
+ At 100 CLI commands/day piped to an LLM → **~625k tokens saved/day** → **~$9.37/day saved** on Opus.
315
+
316
+ ---
317
+
318
+ ## 🏆 Benchmarks
319
+
320
+ ### Relevance Accuracy (F1 Score)
321
+
322
+ ```
323
+ code-review-graph ██████████████░░░░░░░░ F1 0.54 (46% false positives)
324
+ graphsift ████████████████████████ F1 0.85 (ranked + dedup + trimming)
325
+ ```
326
+
327
+ ### Speed
328
+
329
+ | Operation | Time |
330
+ |---|---|
331
+ | Index 10,000+ file repo | < 2 seconds |
332
+ | Incremental re-index | < 0.5 seconds |
333
+ | Context build for diff (1k file repo) | < 50 ms |
334
+ | Cache hit context retrieval | < 5 ms |
335
+
336
+ ### Test Coverage
337
+
338
+ ```
339
+ ✅ 271 tests ✅ 8 test files ✅ ~4s runtime ✅ >80% coverage
340
+ ✅ Unit tests ✅ Integration ✅ Edge cases ✅ All pass
341
+ ```
342
+
343
+ ---
344
+
345
+ ## ✨ Key Features
346
+
347
+ ### 🎯 Token & Cost Optimization
348
+ - **Hard token budget** — never exceed context window or cost ceiling
349
+ - **3-tier selection (hot/warm/cold)** — full source → signatures → excluded
350
+ - **Diff-aware context trimming** — only changed regions + surrounding context lines
351
+ - **Entropy-based deduplication** — removes near-identical files for better context diversity
352
+ - **4 output modes** — FULL / SIGNATURES / COMPRESSED / SMART (auto per-file)
353
+ - **Cache-aware output** — Anthropic/OpenAI `cache_control` breakpoints for repeated queries
354
+ - **Cross-session caching** — session_id-based memory reuse across conversations
355
+ - **80-150× token reduction** vs raw source; **10-15×** vs binary blast-radius tools
356
+
357
+ ### 🧠 Code Analysis & Intelligence
358
+ - **14-language parsing** — Python, JS, TS, Go, Rust, Java, C++, C, Ruby, PHP, Bash, Terraform/HCL, Helm, Dockerfile
359
+ - **Tree-sitter precise parsing** — 11 languages with full CST/AST
360
+ - **7 edge types** — CALLS, IMPORTS, INHERITS, DECORATES, REFERENCES, TEST_COVERS, DYNAMIC_IMPORT
361
+ - **Hybrid search** — BM25 full-text + TF-IDF sparse vector fusion
362
+ - **Cycle detection** — find and report dependency cycles with severity grading
363
+ - **Dead code detection** — unreachable functions, classes, methods from entry points
364
+ - **Auto-fix suggestions** — graph-based issue detection (5 categories)
365
+ - **Decorator tracking** — `@require_auth`, `@cached_property` edges most tools miss
366
+ - **Dynamic import detection** — `importlib.import_module()`, `__import__()`, `require()`
367
+
368
+ ### 🛠️ CLI Output Compression
369
+ - **Auto-detect** command type from output signature — just pipe to `graphsift compress`
370
+ - **19 specialized compressors** — pytest (94%), git_diff (92%), docker (91%), npm (87%), kubectl (81%), grep (97%), and more
371
+ - **Bash wrapper** — transparent compression without manual piping
372
+ - **Tee mode** — save original uncompressed output while LLM sees compressed
373
+ - **Token analytics** — cumulative tracking, daily breakdown, cost estimates, opportunity discovery
374
+
375
+ ### 🧪 Agent Intelligence & Memory (v2.0)
376
+ - **Agent Memory Layer** — SQLite-backed knowledge graph for persisting agent context across sessions
377
+ - **Typed Graph Retrieval** — PRISM-style typed-path traversal with 6 query intents (security, refactor, test, dependency, architecture, general)
378
+ - **Conversation Compaction** — 3 strategies for 60–82% token savings on agent conversations
379
+ - **Evidence Citations** — full audit trail explaining why each file was selected, with score breakdowns
380
+ - **A2A Protocol Server** — Agent-to-Agent protocol via JSON-RPC over HTTP
381
+ - **MCP Async Tasks** — long-running operations with progress tracking and cancellation
382
+ - **Harness Engineering** — pre/post validation hooks, graph integrity checks, budget enforcement
383
+ - **Temporal Code Graph** — git-history-aware symbol tracking with bi-temporal queries
384
+ - **Code-Aware Memory** — memories anchored to code symbols with graph-proximity recall
385
+
386
+ ### 🔌 Developer Experience
387
+ - **Full MCP server** — compatible with Claude Code, Cursor, Copilot, Windsurf, Codex, Gemini, 23+ clients
388
+ - **25+ MCP tools** — build/update graph, get_context, get_impact, detect_changes, query_graph, search_symbols, list_flows, list_communities, refactor, semantic_search, cross_repo + more
389
+ - **4 MCP prompts** — review_code, analyze_impact, find_issues, explain_architecture
390
+ - **10 MCP resources** — graph stats, architecture overview, communities, flows, wiki pages
391
+ - **CLI** — `graphsift install / serve / build / status / compress / gain / discover`
392
+ - **Incremental indexing** — SHA-256 skip on unchanged files; sub-2s re-index
393
+ - **Monorepo support** — `index_roots()` for multi-package repositories
394
+ - **SQLite persistence** — 6-version migration history
395
+ - **10 advanced features** — cache, pipeline, validator, async batch, rate limiter, streaming, diff engine, circuit breaker, retry, schema evolution
396
+
397
+ ---
398
+
399
+ ## 🪨 Caveman + graphsift = Unstoppable
400
+
401
+ | What | graphsift does | [Caveman](https://github.com/JuliusBrussee/caveman) does | Together |
402
+ |---|---|---|---|
403
+ | **Input tokens** (your prompts) | Compresses 60–97% ✅ | — | **Maximum savings** |
404
+ | **Output tokens** (LLM replies) | — | Compresses 65–75% ✅ | **Maximum savings** |
405
+ | **Code review context** | Ranked, budgeted, trimmed ✅ | — | Perfect pair |
406
+ | **CLI output** | 19 compressors ✅ | — | Perfect pair |
407
+ | **Agent responses** | — | Caveman talk ✅ | Perfect pair |
408
+
409
+ > [!TIP]
410
+ > Install both: `pip install graphsift` + `npx skills add JuliusBrussee/caveman`
411
+ > **graphsift = cheaper prompts. Caveman = cheaper responses. Your wallet wins both ways.**
412
+
413
+ ---
414
+
415
+ ## 🚀 Quick Start
416
+
417
+ ### Python API
418
+
419
+ ```python
420
+ from graphsift import ContextBuilder, ContextConfig, DiffSpec
421
+
422
+ # Configure your token budget
423
+ config = ContextConfig(token_budget=2000, diff_aware_trimming=True)
424
+
425
+ # Build context for a code review
426
+ builder = ContextBuilder(config)
427
+ result = builder.build(DiffSpec(
428
+ changed_files=["src/auth/manager.py"],
429
+ diff_text="@@ -42,5 +42,8 @@ def login(self): ..."
430
+ ))
431
+
432
+ print(f"files: {result.files_selected}, tokens: {result.total_tokens}, saved: {result.savings_pct}%")
433
+ # → files: 4, tokens: 1,150, saved: 99.4%
434
+
435
+ # Paste directly into any LLM prompt
436
+ prompt = f"Review this code change:\n\n{result.rendered_context}"
437
+ ```
438
+
439
+ ### CLI
440
+
441
+ ```bash
442
+ # Index your repo
443
+ graphsift build
444
+
445
+ # Register MCP server (Claude Code, Cursor, etc.)
446
+ graphsift install
447
+
448
+ # Compress any CLI output
449
+ pytest -v | graphsift compress
450
+
451
+ # Check token savings
452
+ graphsift gain
453
+
454
+ # Find missed token-saving opportunities
455
+ graphsift discover
456
+ ```
457
+
458
+ ---
459
+
460
+ ## 📚 graphsift vs code-review-graph: Head-to-Head
461
+
462
+ | Feature | code-review-graph | **graphsift** |
463
+ |---|---|---|
464
+ | **Core philosophy** | Show related files | **Save tokens** while maximizing relevance |
465
+ | **Selection strategy** | Binary blast-radius (in/out) | **Ranked 0–1** with hot/warm/cold tier selection |
466
+ | **Token budget** | None — sends everything | **Hard budget** — fits model context window |
467
+ | **F1 accuracy** | **0.54** (46% false positives) | **0.85** (ranked filtering + dedup + trimming) |
468
+ | **Token reduction vs raw** | 8–49× | **80–150×** (ranking + compression + trimming) |
469
+ | **Multi-file diff** | Not supported | Union blast radius across all changed files |
470
+ | **Decorator edge tracking** | Ignored | DECORATES edge tracked and scored |
471
+ | **Dynamic imports** | Missed | Detected via regex + AST + tree-sitter |
472
+ | **Diff-aware trimming** | None | Only changed regions + surrounding context |
473
+ | **Entropy-based dedup** | None | Removes near-identical files |
474
+ | **Output compression** | None | **19 CLI compressors (86% avg savings)** |
475
+ | **Tree-sitter parsing** | None | **11 languages** precise CST/AST |
476
+ | **Hybrid vector search** | Broken (MRR=0.35) | BM25 + TF-IDF vector fusion |
477
+ | **Dead code detection** | None | Unreachable code from entry points |
478
+ | **Cycle detection** | None | Dependency cycle analysis |
479
+ | **Auto-fix suggestions** | None | Graph-based issue detection + fix proposals |
480
+ | **Supported languages** | Python only | **14 languages** |
481
+ | **Incremental indexing** | None | SHA-256 skip for unchanged files |
482
+ | **Monorepo support** | None | `index_roots()` multi-package |
483
+ | **MCP server** | No | **25+ tools + 4 prompts + 10 resources** |
484
+ | **CLI** | No | install / serve / build / status / compress / gain / discover |
485
+ | **SQLite persistence** | No | 6-version GraphStore with migrations |
486
+ | **Cache-aware output** | No | Anthropic/OpenAI prompt-cache breakpoints |
487
+ | **Token analytics** | No | Cumulative tracking, savings discovery |
488
+ | **Agent memory** | No | SQLite knowledge graph across sessions |
489
+ | **A2A protocol** | No | Agent-to-Agent via JSON-RPC |
490
+ | **Test coverage** | Unknown | **271 tests, >80% coverage** |
491
+
492
+ ---
493
+
494
+ ## 📖 Supported Languages
495
+
496
+ | Language | Parser | Tree-sitter | Key capabilities |
497
+ |---|---|---|---|
498
+ | Python | Native `ast` + tree-sitter | ✅ | Functions, classes, async, decorators, dynamic imports |
499
+ | JavaScript | Regex + tree-sitter | ✅ | Functions, classes, arrow functions, async |
500
+ | TypeScript | Regex + tree-sitter | ✅ | JS + type annotations, interfaces |
501
+ | Go | Regex + tree-sitter | ✅ | Functions, receiver methods, structs |
502
+ | Rust | Regex + tree-sitter | ✅ | Functions, structs, traits, impl blocks |
503
+ | Java | Regex + tree-sitter | ✅ | Classes, methods, interfaces |
504
+ | C++ | Regex + tree-sitter | ✅ | Functions, classes, structs |
505
+ | C | Regex + tree-sitter | ✅ | Functions, structs |
506
+ | Ruby | Regex + tree-sitter | ✅ | Methods, classes, modules |
507
+ | PHP | Regex + tree-sitter | ✅ | Functions, classes, traits |
508
+ | Bash | Regex + tree-sitter | ✅ | Functions, `source` imports |
509
+ | Terraform/HCL | Custom parser | ❌ | Resources, variables, modules |
510
+ | Helm Charts | Template parser | ❌ | Go templates, Chart.yaml |
511
+ | Dockerfile | Custom | ❌ | FROM, COPY, RUN, ENV, ARG |
512
+
513
+ ---
514
+
515
+ ## 🛡️ Privacy & Security
516
+
517
+ - **No telemetry** — graphsift runs 100% locally, never sends data anywhere
518
+ - **No internet required** — all parsing, ranking, compression is local
519
+ - **Zero cloud dependencies** — SQLite persistence, no accounts, no API keys
520
+ - **MCP server** binds to localhost only (127.0.0.1)
521
+ - **No LLM calls in library code** — graphsift works *for* LLMs, not *powered by* LLMs
522
+
523
+ ---
524
+
525
+ ## 🤝 Contributing
526
+
527
+ Issues, forks, and PRs welcome at [github.com/maheshmakvana/graphsift](https://github.com/maheshmakvana/graphsift).
528
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
529
+
530
+ **Ways to help:**
531
+ - ⭐ Star the repo — it helps others discover graphsift
532
+ - 🍴 Fork it and spread the token-saving gospel
533
+ - 🐛 Open issues for bugs or feature requests
534
+ - 🔧 Submit PRs for improvements
535
+ - 📣 Share with your team — every saved token is saved money
536
+
537
+ ---
538
+
539
+ ## ⭐ Show Your Support
540
+
541
+ If graphsift saves your team money, saves your context window, or saves your sanity:
542
+
543
+ ```
544
+ ⭐ Star us on GitHub → more forks → more contributors → better for everyone
545
+ 🐦 Tell your friends → "I found this token-saving thing..."
546
+ 💼 Use at work → your infra budget will thank you
547
+ ```
548
+
549
+ [![Star History Chart](https://api.star-history.com/svg?repos=maheshmakvana/graphsift&type=Date)](https://star-history.com/#maheshmakvana/graphsift&Date)
550
+
551
+ ---
552
+
553
+ ## 📝 License
554
+
555
+ MIT — see [LICENSE](LICENSE).
556
+ Free like mammoth on open plain. 🦣
557
+
558
+ ---
559
+
560
+ ## 🔗 Related Projects
561
+
562
+ | Project | What it does |
563
+ |---|---|
564
+ | **[graphsift](https://github.com/maheshmakvana/graphsift)** | ⬅️ You are here — ranked context + token budgets + CLI compression |
565
+ | **[Caveman](https://github.com/JuliusBrussee/caveman)** | Make LLM talk caveman → 65% fewer OUTPUT tokens (complementary!) |
566
+ | **[Caveman Code](https://github.com/slmingol/caveman)** | Full-agent output compression (complementary!) |
567
+ | **[tokenpruner](https://pypi.org/project/tokenpruner/)** | LLM input token compression (used by graphsift's COMPRESSED mode) |
568
+ | **[code-review-graph](https://github.com/tirth8205/code-review-graph)** | Binary blast-radius — no ranking, no budget, no compression |
569
+
570
+ ---
571
+
572
+ ### 🏷️ Topics
573
+
574
+ `python` `ai` `mcp` `developer-tools` `llm` `copilot` `claude-code` `token-optimization` `mcp-server` `code-review` `agentic-coding` `context-engineering` `reduce-token-costs` `ast-parser` `dependency-graph` `context-window` `tree-sitter` `output-compression` `bm25` `agent-memory` `graphrag` `a2a-protocol` `token-saver` `llm-cost-reduction` `claude-token-saver`
575
+
576
+ ---
577
+
578
+ <p align="center">
579
+ <strong>Start saving tokens today ↓</strong><br>
580
+ <code>pip install graphsift</code><br>
581
+ <sub>No npm. No Docker. No accounts. No telemetry. Just savings.</sub>
582
+ </p>