@serkanalgur/opencode-slim 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13876 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/compress.d.ts +28 -0
- package/dist/lib/compress.d.ts.map +1 -0
- package/dist/lib/config.d.ts +5 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/prompts.d.ts +4 -0
- package/dist/lib/prompts.d.ts.map +1 -0
- package/dist/lib/state.d.ts +8 -0
- package/dist/lib/state.d.ts.map +1 -0
- package/dist/lib/strategies.d.ts +12 -0
- package/dist/lib/strategies.d.ts.map +1 -0
- package/dist/lib/types.d.ts +90 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 serkanalgur
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# opencode-slim
|
|
2
|
+
|
|
3
|
+
Smart context management plugin for OpenCode. Optimizes token usage through semantic compression, cost-aware pruning, and adaptive thresholds.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Semantic Compression** - Groups related tool calls and compresses them intelligently
|
|
8
|
+
- **Cost-Aware Pruning** - Considers token pricing when deciding what to compress
|
|
9
|
+
- **Adaptive Thresholds** - Learns from compression history to optimize timing
|
|
10
|
+
- **Session Persistence** - Saves state across restarts
|
|
11
|
+
- **Deduplication** - Removes repeated tool calls automatically
|
|
12
|
+
- **Error Purging** - Cleans up failed tool call outputs after configurable turns
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
opencode plugin @serkanalgur/opencode-slim@latest --global
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Configuration
|
|
21
|
+
|
|
22
|
+
Create `~/.config/opencode/slim.jsonc`:
|
|
23
|
+
|
|
24
|
+
```jsonc
|
|
25
|
+
{
|
|
26
|
+
"enabled": true,
|
|
27
|
+
"compress": {
|
|
28
|
+
"enabled": true,
|
|
29
|
+
"permission": "allow",
|
|
30
|
+
"maxContextLimit": "80%",
|
|
31
|
+
"minContextLimit": "40%",
|
|
32
|
+
"nudgeFrequency": 5,
|
|
33
|
+
"protectUserMessages": false,
|
|
34
|
+
"protectedTools": ["task", "skill", "todowrite", "todoread"]
|
|
35
|
+
},
|
|
36
|
+
"strategies": {
|
|
37
|
+
"deduplication": {
|
|
38
|
+
"enabled": true,
|
|
39
|
+
"protectedTools": []
|
|
40
|
+
},
|
|
41
|
+
"purgeErrors": {
|
|
42
|
+
"enabled": true,
|
|
43
|
+
"turns": 4,
|
|
44
|
+
"protectedTools": []
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"adaptive": {
|
|
48
|
+
"enabled": true,
|
|
49
|
+
"learningRate": 0.1,
|
|
50
|
+
"minCompressionRatio": 0.3
|
|
51
|
+
},
|
|
52
|
+
"costAware": {
|
|
53
|
+
"enabled": true,
|
|
54
|
+
"cacheBoostFactor": 0.5
|
|
55
|
+
},
|
|
56
|
+
"persistence": {
|
|
57
|
+
"enabled": true,
|
|
58
|
+
"directory": "~/.config/opencode/slim"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## How It Works
|
|
64
|
+
|
|
65
|
+
### Semantic Compression
|
|
66
|
+
|
|
67
|
+
Unlike simple text truncation, slim analyzes the semantic content of messages and groups related tool calls together. This preserves context while removing redundancy.
|
|
68
|
+
|
|
69
|
+
### Cost-Aware Pruning
|
|
70
|
+
|
|
71
|
+
Slim considers the cost of tokens when deciding what to compress. It prioritizes compressing expensive operations (like large file reads) while preserving cheap but important context.
|
|
72
|
+
|
|
73
|
+
### Adaptive Thresholds
|
|
74
|
+
|
|
75
|
+
The plugin learns from your compression patterns and adjusts thresholds over time. If you tend to need more context, it will compress less aggressively. If you're efficient, it will compress more.
|
|
76
|
+
|
|
77
|
+
### Session Persistence
|
|
78
|
+
|
|
79
|
+
State is saved to disk, so compression history and learning persist across restarts.
|
|
80
|
+
|
|
81
|
+
## Commands
|
|
82
|
+
|
|
83
|
+
- `/slim` - Show current context stats and compression history
|
|
84
|
+
- `/slim compress` - Manually trigger compression
|
|
85
|
+
- `/slim reset` - Reset adaptive learning
|
|
86
|
+
|
|
87
|
+
## Comparison with DCP
|
|
88
|
+
|
|
89
|
+
| Feature | slim | DCP |
|
|
90
|
+
|---------|------|-----|
|
|
91
|
+
| Semantic grouping | ✅ | ❌ |
|
|
92
|
+
| Cost awareness | ✅ | ❌ |
|
|
93
|
+
| Adaptive thresholds | ✅ | ❌ |
|
|
94
|
+
| Session persistence | ✅ | ❌ |
|
|
95
|
+
| File count | ~8 | ~150 |
|
|
96
|
+
| License | MIT | AGPL-3.0 |
|
|
97
|
+
| Config complexity | Low | High |
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;;;;;AAoSjD,wBAA8C"}
|