sharp-context 0.1.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.
- sharp_context-0.1.0/.gitignore +75 -0
- sharp_context-0.1.0/PKG-INFO +201 -0
- sharp_context-0.1.0/README.md +173 -0
- sharp_context-0.1.0/pyproject.toml +50 -0
- sharp_context-0.1.0/sharp_context/__init__.py +27 -0
- sharp_context-0.1.0/sharp_context/checkpoint.py +295 -0
- sharp_context-0.1.0/sharp_context/config.py +72 -0
- sharp_context-0.1.0/sharp_context/dedup.py +239 -0
- sharp_context-0.1.0/sharp_context/entropy.py +277 -0
- sharp_context-0.1.0/sharp_context/knapsack.py +348 -0
- sharp_context-0.1.0/sharp_context/prefetch.py +297 -0
- sharp_context-0.1.0/sharp_context/server.py +624 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Node/JS
|
|
2
|
+
node_modules/
|
|
3
|
+
npm-debug.log*
|
|
4
|
+
.next/
|
|
5
|
+
web/.next/
|
|
6
|
+
|
|
7
|
+
# Editor
|
|
8
|
+
.vscode/
|
|
9
|
+
.idea/
|
|
10
|
+
|
|
11
|
+
# Python
|
|
12
|
+
__pycache__/
|
|
13
|
+
.venv/
|
|
14
|
+
*.pyc
|
|
15
|
+
.env
|
|
16
|
+
|
|
17
|
+
# Rust / Cargo
|
|
18
|
+
target/
|
|
19
|
+
Cargo.lock
|
|
20
|
+
|
|
21
|
+
# Data / Temp
|
|
22
|
+
*.log
|
|
23
|
+
.DS_Store
|
|
24
|
+
|
|
25
|
+
# Model caches / generated
|
|
26
|
+
.fastembed_cache/
|
|
27
|
+
server/.fastembed_cache/
|
|
28
|
+
*.onnx
|
|
29
|
+
*.lock
|
|
30
|
+
|
|
31
|
+
# Environment secrets (never commit)
|
|
32
|
+
web/.env.local
|
|
33
|
+
web/.env.production
|
|
34
|
+
.env.local
|
|
35
|
+
|
|
36
|
+
# =========================================================
|
|
37
|
+
# ALLOWLIST — only these directories are tracked
|
|
38
|
+
# =========================================================
|
|
39
|
+
|
|
40
|
+
# Core engine (Rust)
|
|
41
|
+
# openrustswarm-core/ — tracked
|
|
42
|
+
|
|
43
|
+
# Web dashboard (Next.js)
|
|
44
|
+
# web/ — tracked
|
|
45
|
+
|
|
46
|
+
# CogOps Skill (OpenClaw integration)
|
|
47
|
+
# cogops-skill/ — tracked
|
|
48
|
+
|
|
49
|
+
# WASM bridge
|
|
50
|
+
# cogops-wasm/ — tracked
|
|
51
|
+
|
|
52
|
+
# Python server
|
|
53
|
+
# server/ — tracked
|
|
54
|
+
|
|
55
|
+
# Public assets
|
|
56
|
+
# demo/, examples/, dist/ — tracked
|
|
57
|
+
|
|
58
|
+
# =========================================================
|
|
59
|
+
# EXCLUDED (internal / generated / one-off)
|
|
60
|
+
# =========================================================
|
|
61
|
+
openrustswarm/
|
|
62
|
+
benchmarks/
|
|
63
|
+
scripts/
|
|
64
|
+
docs/
|
|
65
|
+
hacker_news_launch.md
|
|
66
|
+
eval_*.py
|
|
67
|
+
test_*.py
|
|
68
|
+
medieval_demo.py
|
|
69
|
+
real_10k_log_swarm.py
|
|
70
|
+
CODEBASE_AUDIT.md
|
|
71
|
+
LAUNCH.md
|
|
72
|
+
*.jsonl
|
|
73
|
+
server/diagnose_api.py
|
|
74
|
+
server/verify_ui.py
|
|
75
|
+
server/run_task_help.txt
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sharp-context
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Information-theoretic context optimization for AI coding agents. Knapsack-optimal token budgeting, Shannon entropy scoring, SimHash dedup, predictive pre-fetch. MCP server.
|
|
5
|
+
Project-URL: Homepage, https://github.com/juyterman1000/sharp-context
|
|
6
|
+
Project-URL: Documentation, https://github.com/juyterman1000/sharp-context#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/juyterman1000/sharp-context
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/juyterman1000/sharp-context/issues
|
|
9
|
+
Project-URL: Full Framework, https://github.com/juyterman1000/ebbiforge
|
|
10
|
+
Author-email: Ebbiforge Team <fastrunner10090@gmail.com>
|
|
11
|
+
License: MIT
|
|
12
|
+
Keywords: agentic-ai,checkpoint,claude,context-optimization,copilot,cursor,deduplication,entropy,knapsack,llm,mcp,token-cost
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: mcp>=1.0.0
|
|
25
|
+
Provides-Extra: memory
|
|
26
|
+
Requires-Dist: hippocampus-sharp-memory>=1.0.0; extra == 'memory'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# SharpContext
|
|
30
|
+
|
|
31
|
+
**Information-theoretic context optimization for AI coding agents.**
|
|
32
|
+
|
|
33
|
+
Every AI coding tool manages context with dumb FIFO truncation — stuffing tokens until the window is full, then cutting from the top. SharpContext applies mathematics to select the **optimal** context subset.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
pip install sharp-context
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## What It Does
|
|
40
|
+
|
|
41
|
+
An MCP server that sits between your AI coding tool and the LLM, providing:
|
|
42
|
+
|
|
43
|
+
| Engine | What it does | How it works |
|
|
44
|
+
|--------|-------------|--------------|
|
|
45
|
+
| 🎒 **Knapsack Optimizer** | Selects mathematically optimal context subset | 0/1 Knapsack DP — maximizes relevance within token budget |
|
|
46
|
+
| 📊 **Entropy Scorer** | Measures information density per fragment | Shannon entropy + token surprisal + boilerplate detection |
|
|
47
|
+
| 🔍 **SimHash Dedup** | Catches near-duplicate content in O(1) | 64-bit SimHash with LSH banding (Proximity 2026) |
|
|
48
|
+
| 🔮 **Predictive Pre-fetch** | Pre-loads context before the agent asks | Static analysis + learned co-access patterns |
|
|
49
|
+
| 💾 **Checkpoint & Resume** | Crash recovery for multi-step tasks | Gzipped JSON state serialization |
|
|
50
|
+
|
|
51
|
+
## Setup
|
|
52
|
+
|
|
53
|
+
### Cursor
|
|
54
|
+
|
|
55
|
+
Add to `.cursor/mcp.json`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcpServers": {
|
|
60
|
+
"sharp-context": {
|
|
61
|
+
"command": "sharp-context"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Claude Code
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
claude mcp add sharp-context -- sharp-context
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Cline / Any MCP Client
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"sharp-context": {
|
|
78
|
+
"command": "sharp-context",
|
|
79
|
+
"args": []
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## MCP Tools
|
|
85
|
+
|
|
86
|
+
### `remember_fragment`
|
|
87
|
+
Store context with auto-dedup and entropy scoring.
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
remember_fragment(content="def process_payment(...)...", source="file:payments.py")
|
|
91
|
+
→ {"status": "ingested", "entropy_score": 0.82}
|
|
92
|
+
|
|
93
|
+
remember_fragment(content="def process_payment(...)...") # same content
|
|
94
|
+
→ {"status": "duplicate", "duplicate_of": "a1b2c3", "tokens_saved": 45}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### `optimize_context`
|
|
98
|
+
Select the optimal context subset for a token budget.
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
optimize_context(token_budget=128000, query="fix payment bug")
|
|
102
|
+
→ {
|
|
103
|
+
"selected_fragments": [...],
|
|
104
|
+
"optimization_stats": {"method": "exact_dp", "budget_utilization": 0.73},
|
|
105
|
+
"tokens_saved_this_call": 42000
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### `recall_relevant`
|
|
110
|
+
Semantic recall of stored fragments.
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
recall_relevant(query="database connection pooling", top_k=5)
|
|
114
|
+
→ [{"fragment_id": "...", "relevance": 0.87, "content": "..."}]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### `checkpoint_state` / `resume_state`
|
|
118
|
+
Save and restore full session state.
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
checkpoint_state(task_description="Refactoring auth module", current_step="Step 5/8")
|
|
122
|
+
→ {"status": "checkpoint_saved", "fragments_saved": 47}
|
|
123
|
+
|
|
124
|
+
resume_state()
|
|
125
|
+
→ {"status": "resumed", "restored_fragments": 47, "metadata": {"step": "Step 5/8"}}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `prefetch_related`
|
|
129
|
+
Predict and pre-load likely-needed context.
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
prefetch_related(file_path="src/payments.py", source_content="from utils import...")
|
|
133
|
+
→ [{"path": "src/utils.py", "reason": "import", "confidence": 0.70}]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### `get_stats`
|
|
137
|
+
Session statistics and cost savings.
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
get_stats()
|
|
141
|
+
→ {
|
|
142
|
+
"savings": {
|
|
143
|
+
"total_tokens_saved": 284000,
|
|
144
|
+
"total_duplicates_caught": 12,
|
|
145
|
+
"estimated_cost_saved_usd": 0.85
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## The Math
|
|
151
|
+
|
|
152
|
+
### Knapsack Context Selection
|
|
153
|
+
|
|
154
|
+
Context selection is the 0/1 Knapsack Problem:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
Maximize: Σ r(fᵢ) · x(fᵢ) for selected fragments
|
|
158
|
+
Subject to: Σ c(fᵢ) · x(fᵢ) ≤ B (token budget)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Where relevance `r(f)` is a weighted combination of:
|
|
162
|
+
- **Recency** (Ebbinghaus forgetting curve decay)
|
|
163
|
+
- **Frequency** (spaced repetition boost)
|
|
164
|
+
- **Semantic similarity** (SimHash Hamming distance)
|
|
165
|
+
- **Information density** (Shannon entropy)
|
|
166
|
+
|
|
167
|
+
Solved via DP with budget quantization: O(N × 1000) instead of O(N × B).
|
|
168
|
+
|
|
169
|
+
### Shannon Entropy Scoring
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
H(fragment) = -Σ p(char) · log₂(p(char))
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
High entropy = unique, surprising content (prioritize).
|
|
176
|
+
Low entropy = boilerplate, repetitive patterns (deprioritize).
|
|
177
|
+
|
|
178
|
+
### SimHash Deduplication
|
|
179
|
+
|
|
180
|
+
64-bit fingerprints with 4-band LSH bucketing:
|
|
181
|
+
- Hamming distance ≤ 3 → near-duplicate (99% recall)
|
|
182
|
+
- Hamming distance ≥ 10 → genuinely different (<1% false positive)
|
|
183
|
+
|
|
184
|
+
## References
|
|
185
|
+
|
|
186
|
+
- Shannon (1948) — Information Theory
|
|
187
|
+
- Charikar (2002) — SimHash
|
|
188
|
+
- Ebbinghaus (1885) — Forgetting Curve
|
|
189
|
+
- ICPC (arXiv 2025) — In-context Prompt Compression
|
|
190
|
+
- Proximity (arXiv 2026) — LSH-bucketed Semantic Caching
|
|
191
|
+
- RCC (ICLR 2025) — Recurrent Context Compression
|
|
192
|
+
- ILRe (ICLR 2026) — Intermediate Layer Retrieval
|
|
193
|
+
- Agentic Plan Caching (arXiv 2025)
|
|
194
|
+
|
|
195
|
+
## Part of the Ebbiforge Ecosystem
|
|
196
|
+
|
|
197
|
+
SharpContext uses techniques from the [hippocampus-sharp-memory](https://pypi.org/project/hippocampus-sharp-memory/) engine and the [Ebbiforge](https://pypi.org/project/ebbiforge/) Rust core.
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# SharpContext
|
|
2
|
+
|
|
3
|
+
**Information-theoretic context optimization for AI coding agents.**
|
|
4
|
+
|
|
5
|
+
Every AI coding tool manages context with dumb FIFO truncation — stuffing tokens until the window is full, then cutting from the top. SharpContext applies mathematics to select the **optimal** context subset.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
pip install sharp-context
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What It Does
|
|
12
|
+
|
|
13
|
+
An MCP server that sits between your AI coding tool and the LLM, providing:
|
|
14
|
+
|
|
15
|
+
| Engine | What it does | How it works |
|
|
16
|
+
|--------|-------------|--------------|
|
|
17
|
+
| 🎒 **Knapsack Optimizer** | Selects mathematically optimal context subset | 0/1 Knapsack DP — maximizes relevance within token budget |
|
|
18
|
+
| 📊 **Entropy Scorer** | Measures information density per fragment | Shannon entropy + token surprisal + boilerplate detection |
|
|
19
|
+
| 🔍 **SimHash Dedup** | Catches near-duplicate content in O(1) | 64-bit SimHash with LSH banding (Proximity 2026) |
|
|
20
|
+
| 🔮 **Predictive Pre-fetch** | Pre-loads context before the agent asks | Static analysis + learned co-access patterns |
|
|
21
|
+
| 💾 **Checkpoint & Resume** | Crash recovery for multi-step tasks | Gzipped JSON state serialization |
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
### Cursor
|
|
26
|
+
|
|
27
|
+
Add to `.cursor/mcp.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"mcpServers": {
|
|
32
|
+
"sharp-context": {
|
|
33
|
+
"command": "sharp-context"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Claude Code
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
claude mcp add sharp-context -- sharp-context
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Cline / Any MCP Client
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"sharp-context": {
|
|
50
|
+
"command": "sharp-context",
|
|
51
|
+
"args": []
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## MCP Tools
|
|
57
|
+
|
|
58
|
+
### `remember_fragment`
|
|
59
|
+
Store context with auto-dedup and entropy scoring.
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
remember_fragment(content="def process_payment(...)...", source="file:payments.py")
|
|
63
|
+
→ {"status": "ingested", "entropy_score": 0.82}
|
|
64
|
+
|
|
65
|
+
remember_fragment(content="def process_payment(...)...") # same content
|
|
66
|
+
→ {"status": "duplicate", "duplicate_of": "a1b2c3", "tokens_saved": 45}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### `optimize_context`
|
|
70
|
+
Select the optimal context subset for a token budget.
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
optimize_context(token_budget=128000, query="fix payment bug")
|
|
74
|
+
→ {
|
|
75
|
+
"selected_fragments": [...],
|
|
76
|
+
"optimization_stats": {"method": "exact_dp", "budget_utilization": 0.73},
|
|
77
|
+
"tokens_saved_this_call": 42000
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### `recall_relevant`
|
|
82
|
+
Semantic recall of stored fragments.
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
recall_relevant(query="database connection pooling", top_k=5)
|
|
86
|
+
→ [{"fragment_id": "...", "relevance": 0.87, "content": "..."}]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### `checkpoint_state` / `resume_state`
|
|
90
|
+
Save and restore full session state.
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
checkpoint_state(task_description="Refactoring auth module", current_step="Step 5/8")
|
|
94
|
+
→ {"status": "checkpoint_saved", "fragments_saved": 47}
|
|
95
|
+
|
|
96
|
+
resume_state()
|
|
97
|
+
→ {"status": "resumed", "restored_fragments": 47, "metadata": {"step": "Step 5/8"}}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### `prefetch_related`
|
|
101
|
+
Predict and pre-load likely-needed context.
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
prefetch_related(file_path="src/payments.py", source_content="from utils import...")
|
|
105
|
+
→ [{"path": "src/utils.py", "reason": "import", "confidence": 0.70}]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### `get_stats`
|
|
109
|
+
Session statistics and cost savings.
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
get_stats()
|
|
113
|
+
→ {
|
|
114
|
+
"savings": {
|
|
115
|
+
"total_tokens_saved": 284000,
|
|
116
|
+
"total_duplicates_caught": 12,
|
|
117
|
+
"estimated_cost_saved_usd": 0.85
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## The Math
|
|
123
|
+
|
|
124
|
+
### Knapsack Context Selection
|
|
125
|
+
|
|
126
|
+
Context selection is the 0/1 Knapsack Problem:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
Maximize: Σ r(fᵢ) · x(fᵢ) for selected fragments
|
|
130
|
+
Subject to: Σ c(fᵢ) · x(fᵢ) ≤ B (token budget)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Where relevance `r(f)` is a weighted combination of:
|
|
134
|
+
- **Recency** (Ebbinghaus forgetting curve decay)
|
|
135
|
+
- **Frequency** (spaced repetition boost)
|
|
136
|
+
- **Semantic similarity** (SimHash Hamming distance)
|
|
137
|
+
- **Information density** (Shannon entropy)
|
|
138
|
+
|
|
139
|
+
Solved via DP with budget quantization: O(N × 1000) instead of O(N × B).
|
|
140
|
+
|
|
141
|
+
### Shannon Entropy Scoring
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
H(fragment) = -Σ p(char) · log₂(p(char))
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
High entropy = unique, surprising content (prioritize).
|
|
148
|
+
Low entropy = boilerplate, repetitive patterns (deprioritize).
|
|
149
|
+
|
|
150
|
+
### SimHash Deduplication
|
|
151
|
+
|
|
152
|
+
64-bit fingerprints with 4-band LSH bucketing:
|
|
153
|
+
- Hamming distance ≤ 3 → near-duplicate (99% recall)
|
|
154
|
+
- Hamming distance ≥ 10 → genuinely different (<1% false positive)
|
|
155
|
+
|
|
156
|
+
## References
|
|
157
|
+
|
|
158
|
+
- Shannon (1948) — Information Theory
|
|
159
|
+
- Charikar (2002) — SimHash
|
|
160
|
+
- Ebbinghaus (1885) — Forgetting Curve
|
|
161
|
+
- ICPC (arXiv 2025) — In-context Prompt Compression
|
|
162
|
+
- Proximity (arXiv 2026) — LSH-bucketed Semantic Caching
|
|
163
|
+
- RCC (ICLR 2025) — Recurrent Context Compression
|
|
164
|
+
- ILRe (ICLR 2026) — Intermediate Layer Retrieval
|
|
165
|
+
- Agentic Plan Caching (arXiv 2025)
|
|
166
|
+
|
|
167
|
+
## Part of the Ebbiforge Ecosystem
|
|
168
|
+
|
|
169
|
+
SharpContext uses techniques from the [hippocampus-sharp-memory](https://pypi.org/project/hippocampus-sharp-memory/) engine and the [Ebbiforge](https://pypi.org/project/ebbiforge/) Rust core.
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
MIT
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sharp-context"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Information-theoretic context optimization for AI coding agents. Knapsack-optimal token budgeting, Shannon entropy scoring, SimHash dedup, predictive pre-fetch. MCP server."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Ebbiforge Team", email = "fastrunner10090@gmail.com" },
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"mcp", "context-optimization", "token-cost", "agentic-ai",
|
|
17
|
+
"knapsack", "entropy", "deduplication", "checkpoint",
|
|
18
|
+
"cursor", "claude", "copilot", "llm",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"License :: OSI Approved :: MIT License",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.10",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
30
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
31
|
+
]
|
|
32
|
+
dependencies = [
|
|
33
|
+
"mcp>=1.0.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
memory = ["hippocampus-sharp-memory>=1.0.0"]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/juyterman1000/sharp-context"
|
|
41
|
+
Documentation = "https://github.com/juyterman1000/sharp-context#readme"
|
|
42
|
+
Repository = "https://github.com/juyterman1000/sharp-context"
|
|
43
|
+
"Bug Tracker" = "https://github.com/juyterman1000/sharp-context/issues"
|
|
44
|
+
"Full Framework" = "https://github.com/juyterman1000/ebbiforge"
|
|
45
|
+
|
|
46
|
+
[project.scripts]
|
|
47
|
+
sharp-context = "sharp_context.server:main"
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.targets.wheel]
|
|
50
|
+
packages = ["sharp_context"]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""
|
|
2
|
+
SharpContext — Information-Theoretic Context Optimization for Agentic AI
|
|
3
|
+
========================================================================
|
|
4
|
+
|
|
5
|
+
An MCP server that mathematically optimizes what goes into an LLM's
|
|
6
|
+
context window. Uses knapsack dynamic programming, Shannon entropy scoring,
|
|
7
|
+
SimHash deduplication, and predictive pre-fetching to cut token costs by
|
|
8
|
+
50–70% while improving agent accuracy.
|
|
9
|
+
|
|
10
|
+
Quick Setup (Cursor)::
|
|
11
|
+
|
|
12
|
+
Add to .cursor/mcp.json:
|
|
13
|
+
{
|
|
14
|
+
"mcpServers": {
|
|
15
|
+
"sharp-context": {
|
|
16
|
+
"command": "sharp-context"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Quick Setup (Claude Code)::
|
|
22
|
+
|
|
23
|
+
claude mcp add sharp-context -- sharp-context
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
__version__ = "0.1.0"
|