openslimedit 1.0.1 → 1.0.2
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/README.md +114 -41
- package/package.json +3 -5
- package/src/index.ts +47 -2
- package/scripts/postinstall.js +0 -55
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenSlimedit
|
|
2
2
|
|
|
3
|
-
An [OpenCode](https://github.com/anomalyco/opencode) plugin that reduces token usage by up to
|
|
3
|
+
An [OpenCode](https://github.com/anomalyco/opencode) plugin that reduces token usage by up to 45% with zero configuration. It compresses tool descriptions, compacts read output, and adds line-range edit support.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -9,14 +9,16 @@ An [OpenCode](https://github.com/anomalyco/opencode) plugin that reduces token u
|
|
|
9
9
|
```
|
|
10
10
|
Total tokens vs baseline (lower is better)
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
Claude Sonnet 4.5 [========================>
|
|
14
|
-
GPT 5.2 Codex [====================>
|
|
15
|
-
Minimax M2.5 Free [==================>
|
|
12
|
+
GPT 5.3 Codex [================================> ] -45.1% saved
|
|
13
|
+
Claude Sonnet 4.5 [========================> ] -32.6% saved
|
|
14
|
+
GPT 5.2 Codex [====================> ] -26.7% saved
|
|
15
|
+
Minimax M2.5 Free [==================> ] -24.8% saved
|
|
16
|
+
Claude Opus 4.6 [=================> ] -21.8% saved
|
|
16
17
|
```
|
|
17
18
|
|
|
18
19
|
| Model | Baseline | OpenSlimedit | Saved |
|
|
19
20
|
|---|---|---|---|
|
|
21
|
+
| GPT 5.3 Codex | 77,494 tokens | 42,509 tokens | **-45.1%** |
|
|
20
22
|
| Claude Opus 4.6 | 60,841 tokens | 47,590 tokens | **-21.8%** |
|
|
21
23
|
| Claude Sonnet 4.5 | 120,884 tokens | 81,471 tokens | **-32.6%** |
|
|
22
24
|
| GPT 5.2 Codex | 39,185 tokens | 28,713 tokens | **-26.7%** |
|
|
@@ -47,47 +49,21 @@ No custom tools. No system prompt injection. No modifications to built-in tool b
|
|
|
47
49
|
- [OpenCode](https://github.com/anomalyco/opencode) with plugin hook support
|
|
48
50
|
- [Bun](https://bun.sh) runtime
|
|
49
51
|
|
|
50
|
-
### Option 1: Install from npm
|
|
51
|
-
|
|
52
52
|
```bash
|
|
53
53
|
npm install openslimedit
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
or
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
bun add openslimedit
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
The postinstall script automatically adds the plugin to your project's `.opencode/opencode.json` config.
|
|
63
|
-
|
|
64
|
-
### Option 2: Install from source
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
git clone https://github.com/ASidorenkoCode/openslimedit.git
|
|
68
|
-
cd openslimedit
|
|
69
|
-
bun install
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Then add to your OpenCode config:
|
|
56
|
+
Then add it to your OpenCode config (`.opencode/opencode.json` or `opencode.jsonc`):
|
|
73
57
|
|
|
74
58
|
```json
|
|
75
59
|
{
|
|
76
|
-
"
|
|
77
|
-
"openslimedit"
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}
|
|
60
|
+
"plugin": [
|
|
61
|
+
"openslimedit@latest"
|
|
62
|
+
]
|
|
81
63
|
}
|
|
82
64
|
```
|
|
83
65
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
opencode
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
That's it. The plugin activates automatically and reduces token usage on every interaction.
|
|
66
|
+
Start OpenCode and the plugin activates automatically.
|
|
91
67
|
|
|
92
68
|
---
|
|
93
69
|
|
|
@@ -121,6 +97,7 @@ Hashline:
|
|
|
121
97
|
Minimax M2.5 Free █████████ +9.1%
|
|
122
98
|
|
|
123
99
|
OpenSlimedit:
|
|
100
|
+
GPT 5.3 Codex ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ -45.1%
|
|
124
101
|
Claude Opus 4.6 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ -21.8%
|
|
125
102
|
Claude Sonnet 4.5 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ -32.6%
|
|
126
103
|
GPT 5.2 Codex ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ -26.7%
|
|
@@ -163,6 +140,16 @@ The hash-tagged read output, custom tool schemas, and system prompt injection ad
|
|
|
163
140
|
|
|
164
141
|
*\*Hashline multi-edit failed (760s timeout loop); total includes failed run*
|
|
165
142
|
|
|
143
|
+
#### GPT 5.3 Codex
|
|
144
|
+
|
|
145
|
+
| Case | Baseline | OpenSlimedit |
|
|
146
|
+
|---|---|---|
|
|
147
|
+
| single-edit | 10,445 | **10,402 (-0.4%)** |
|
|
148
|
+
| multi-line-replace | 20,468 | **11,312 (-44.7%)** |
|
|
149
|
+
| multi-edit | 21,299 | **6,068 (-71.5%)** |
|
|
150
|
+
| large-file-edit | 25,282 | **14,727 (-41.8%)** |
|
|
151
|
+
| **Total** | **77,494** | **42,509 (-45.1%)** |
|
|
152
|
+
|
|
166
153
|
#### Minimax M2.5 Free
|
|
167
154
|
|
|
168
155
|
| Case | Baseline | Hashline | Smart Edit | OpenSlimedit |
|
|
@@ -177,6 +164,7 @@ The hash-tagged read output, custom tool schemas, and system prompt injection ad
|
|
|
177
164
|
|
|
178
165
|
| Model | Hashline | Smart Edit | OpenSlimedit |
|
|
179
166
|
|---|---|---|---|
|
|
167
|
+
| **GPT 5.3 Codex** | — | — | **-45.1%** |
|
|
180
168
|
| **Claude Opus 4.6** | +14.0% | -2.5% | **-21.8%** |
|
|
181
169
|
| **Claude Sonnet 4.5** | +15.2% | — | **-32.6%** |
|
|
182
170
|
| **GPT 5.2 Codex** | +49.9%* | — | **-26.7%** |
|
|
@@ -184,15 +172,37 @@ The hash-tagged read output, custom tool schemas, and system prompt injection ad
|
|
|
184
172
|
|
|
185
173
|
*\*Includes failed multi-edit run*
|
|
186
174
|
|
|
175
|
+
### Large File Scaling
|
|
176
|
+
|
|
177
|
+
The benchmarks above use small files (21-115 lines). How does OpenSlimedit perform on real-world file sizes?
|
|
178
|
+
|
|
179
|
+
#### Minimax M2.5 Free
|
|
180
|
+
|
|
181
|
+
| File Size | Baseline | OpenSlimedit | Saved |
|
|
182
|
+
|---|---|---|---|
|
|
183
|
+
| 1k lines | 37,743 | 30,697 | **-18.7%** |
|
|
184
|
+
| 3k lines | 29,021 | 25,832 | **-11.0%** |
|
|
185
|
+
| 6k lines | 29,422 | 25,747 | **-12.5%** |
|
|
186
|
+
| 10k lines | 29,405 | 25,742 | **-12.5%** |
|
|
187
|
+
|
|
188
|
+
#### GPT 5.3 Codex (5-iteration average)
|
|
189
|
+
|
|
190
|
+
| File Size | Baseline | OpenSlimedit | Saved |
|
|
191
|
+
|---|---|---|---|
|
|
192
|
+
| 1k lines | 38,962 | 29,833 | **-23.4%** |
|
|
193
|
+
| 3k lines | 59,283 | 38,861 | **-34.4%** |
|
|
194
|
+
| 6k lines | 70,380 | 29,193 | **-58.5%** |
|
|
195
|
+
| 10k lines | 65,888 | 34,315 | **-47.9%** |
|
|
196
|
+
|
|
197
|
+
Minimax shows consistent savings (11-19%) at all file sizes. GPT 5.3 Codex shows even larger savings (23-59%) that increase with file size — the baseline becomes noisier and more expensive on larger files while OpenSlimedit stays consistent.
|
|
198
|
+
|
|
187
199
|
### Key Findings
|
|
188
200
|
|
|
189
201
|
- **Tool description compression is the biggest win.** Tool schemas are sent with every API call. Shortening them saves thousands of input tokens per step, and this compounds across multi-step tasks.
|
|
190
202
|
- **Hashline increases token usage for most models.** The hash-tagged read output, custom tool schemas, and system prompt injection add per-step overhead that outweighs the savings from shorter `oldString` values.
|
|
191
|
-
- **OpenSlimedit consistently saves
|
|
203
|
+
- **OpenSlimedit consistently saves 11-45% across all tested models and file sizes** with zero regressions on Opus 4.6. GPT 5.3 Codex shows the largest savings at 45.1%. Some models show regressions on individual cases (Minimax on multi-edit, Codex 5.2 on single-edit) but the total is always significantly lower.
|
|
192
204
|
- **Custom tools confuse some models.** Minimax and Codex struggle with non-standard tool schemas, leading to extra steps or failures. OpenSlimedit avoids this entirely by only modifying descriptions of existing tools.
|
|
193
205
|
|
|
194
|
-
> **Note:** These benchmarks use small files (21-115 lines). On larger files, the relative savings from tool description compression become even more significant as more API steps are needed.
|
|
195
|
-
|
|
196
206
|
<details>
|
|
197
207
|
<summary>Raw data — Hashline runs</summary>
|
|
198
208
|
|
|
@@ -238,6 +248,10 @@ The hash-tagged read output, custom tool schemas, and system prompt injection ad
|
|
|
238
248
|
| baseline | minimax-m2.5-free | multi-line-replace | 16,274 ms | 10,668 | 437 | 11,105 | yes |
|
|
239
249
|
| baseline | minimax-m2.5-free | multi-edit | 43,462 ms | 1,233 | 1,075 | 2,308 | yes |
|
|
240
250
|
| baseline | minimax-m2.5-free | large-file-edit | 20,430 ms | 3,250 | 677 | 3,927 | yes |
|
|
251
|
+
| baseline | gpt-5.3-codex | single-edit | 12,075 ms | 10,218 | 227 | 10,445 | yes |
|
|
252
|
+
| baseline | gpt-5.3-codex | multi-line-replace | 22,378 ms | 20,110 | 358 | 20,468 | yes |
|
|
253
|
+
| baseline | gpt-5.3-codex | multi-edit | 17,870 ms | 20,723 | 576 | 21,299 | yes |
|
|
254
|
+
| baseline | gpt-5.3-codex | large-file-edit | 22,028 ms | 24,384 | 898 | 25,282 | yes |
|
|
241
255
|
|
|
242
256
|
</details>
|
|
243
257
|
|
|
@@ -278,6 +292,66 @@ The hash-tagged read output, custom tool schemas, and system prompt injection ad
|
|
|
278
292
|
| openslimedit | minimax-m2.5-free | multi-line-replace | 14,744 ms | 1,316 | 405 | 1,721 | yes |
|
|
279
293
|
| openslimedit | minimax-m2.5-free | multi-edit | 13,289 ms | 7,385 | 649 | 8,034 | yes |
|
|
280
294
|
| openslimedit | minimax-m2.5-free | large-file-edit | 21,090 ms | 3,214 | 699 | 3,913 | yes |
|
|
295
|
+
| openslimedit | gpt-5.3-codex | single-edit | 10,638 ms | 10,186 | 216 | 10,402 | yes |
|
|
296
|
+
| openslimedit | gpt-5.3-codex | multi-line-replace | 10,419 ms | 10,974 | 338 | 11,312 | yes |
|
|
297
|
+
| openslimedit | gpt-5.3-codex | multi-edit | 15,752 ms | 5,470 | 598 | 6,068 | yes |
|
|
298
|
+
| openslimedit | gpt-5.3-codex | large-file-edit | 28,453 ms | 13,359 | 1,368 | 14,727 | yes |
|
|
299
|
+
|
|
300
|
+
</details>
|
|
301
|
+
|
|
302
|
+
<details>
|
|
303
|
+
<summary>Raw data — Large file scaling runs</summary>
|
|
304
|
+
|
|
305
|
+
| Mode | Model | Case | Time | Input | Output | Total | Success |
|
|
306
|
+
|---|---|---|---|---|---|---|---|
|
|
307
|
+
| baseline | minimax-m2.5-free | 1k-lines | 51,367 ms | 36,733 | 1,010 | 37,743 | yes |
|
|
308
|
+
| baseline | minimax-m2.5-free | 3k-lines | 39,505 ms | 28,392 | 629 | 29,021 | yes |
|
|
309
|
+
| baseline | minimax-m2.5-free | 6k-lines | 47,862 ms | 28,398 | 1,024 | 29,422 | yes |
|
|
310
|
+
| baseline | minimax-m2.5-free | 10k-lines | 40,794 ms | 28,523 | 882 | 29,405 | yes |
|
|
311
|
+
| openslimedit | minimax-m2.5-free | 1k-lines | 25,237 ms | 29,788 | 909 | 30,697 | yes |
|
|
312
|
+
| openslimedit | minimax-m2.5-free | 3k-lines | 45,621 ms | 25,247 | 585 | 25,832 | yes |
|
|
313
|
+
| openslimedit | minimax-m2.5-free | 6k-lines | 33,315 ms | 25,158 | 589 | 25,747 | yes |
|
|
314
|
+
| openslimedit | minimax-m2.5-free | 10k-lines | 19,114 ms | 25,173 | 569 | 25,742 | yes |
|
|
315
|
+
| baseline | gpt-5.3-codex | 1k-lines | 59,368 ms | 36,850 | 1,818 | 38,668 | yes |
|
|
316
|
+
| baseline | gpt-5.3-codex | 1k-lines | 39,687 ms | 35,650 | 1,692 | 37,342 | yes |
|
|
317
|
+
| baseline | gpt-5.3-codex | 1k-lines | 30,868 ms | 34,345 | 1,551 | 35,896 | yes |
|
|
318
|
+
| baseline | gpt-5.3-codex | 1k-lines | 30,132 ms | 34,123 | 1,436 | 35,559 | yes |
|
|
319
|
+
| baseline | gpt-5.3-codex | 1k-lines | 36,521 ms | 45,786 | 1,558 | 47,344 | yes |
|
|
320
|
+
| baseline | gpt-5.3-codex | 3k-lines | 37,920 ms | 61,005 | 1,595 | 62,600 | yes |
|
|
321
|
+
| baseline | gpt-5.3-codex | 3k-lines | 42,808 ms | 63,127 | 2,088 | 65,215 | yes |
|
|
322
|
+
| baseline | gpt-5.3-codex | 3k-lines | 29,531 ms | 48,845 | 1,422 | 50,267 | yes |
|
|
323
|
+
| baseline | gpt-5.3-codex | 3k-lines | 29,003 ms | 71,641 | 1,260 | 72,901 | yes |
|
|
324
|
+
| baseline | gpt-5.3-codex | 3k-lines | 29,224 ms | 44,010 | 1,421 | 45,431 | yes |
|
|
325
|
+
| baseline | gpt-5.3-codex | 6k-lines | 32,856 ms | 53,029 | 1,665 | 54,694 | yes |
|
|
326
|
+
| baseline | gpt-5.3-codex | 6k-lines | 35,228 ms | 79,907 | 1,764 | 81,671 | yes |
|
|
327
|
+
| baseline | gpt-5.3-codex | 6k-lines | 42,342 ms | 92,061 | 2,144 | 94,205 | yes |
|
|
328
|
+
| baseline | gpt-5.3-codex | 6k-lines | 33,617 ms | 74,514 | 1,562 | 76,076 | yes |
|
|
329
|
+
| baseline | gpt-5.3-codex | 6k-lines | 35,195 ms | 43,847 | 1,407 | 45,254 | yes |
|
|
330
|
+
| baseline | gpt-5.3-codex | 10k-lines | 29,958 ms | 77,713 | 1,412 | 79,125 | yes |
|
|
331
|
+
| baseline | gpt-5.3-codex | 10k-lines | 37,031 ms | 61,844 | 1,758 | 63,602 | yes |
|
|
332
|
+
| baseline | gpt-5.3-codex | 10k-lines | 29,698 ms | 61,034 | 1,493 | 62,527 | yes |
|
|
333
|
+
| baseline | gpt-5.3-codex | 10k-lines | 41,649 ms | 60,975 | 1,533 | 62,508 | yes |
|
|
334
|
+
| baseline | gpt-5.3-codex | 10k-lines | 26,924 ms | 60,525 | 1,152 | 61,677 | yes |
|
|
335
|
+
| openslimedit | gpt-5.3-codex | 1k-lines | 35,515 ms | 16,960 | 1,696 | 18,656 | yes |
|
|
336
|
+
| openslimedit | gpt-5.3-codex | 1k-lines | 27,865 ms | 42,485 | 1,198 | 43,683 | yes |
|
|
337
|
+
| openslimedit | gpt-5.3-codex | 1k-lines | 30,197 ms | 20,297 | 1,540 | 21,837 | yes |
|
|
338
|
+
| openslimedit | gpt-5.3-codex | 1k-lines | 42,478 ms | 31,444 | 1,959 | 33,403 | yes |
|
|
339
|
+
| openslimedit | gpt-5.3-codex | 1k-lines | 23,994 ms | 30,360 | 1,225 | 31,585 | yes |
|
|
340
|
+
| openslimedit | gpt-5.3-codex | 3k-lines | 35,438 ms | 46,056 | 1,774 | 47,830 | yes |
|
|
341
|
+
| openslimedit | gpt-5.3-codex | 3k-lines | 38,383 ms | 60,527 | 1,983 | 62,510 | yes |
|
|
342
|
+
| openslimedit | gpt-5.3-codex | 3k-lines | 39,220 ms | 23,657 | 1,699 | 25,356 | yes |
|
|
343
|
+
| openslimedit | gpt-5.3-codex | 3k-lines | 28,254 ms | 27,737 | 1,428 | 29,165 | yes |
|
|
344
|
+
| openslimedit | gpt-5.3-codex | 3k-lines | 29,321 ms | 28,430 | 1,013 | 29,443 | yes |
|
|
345
|
+
| openslimedit | gpt-5.3-codex | 6k-lines | 29,934 ms | 27,332 | 1,451 | 28,783 | yes |
|
|
346
|
+
| openslimedit | gpt-5.3-codex | 6k-lines | 29,402 ms | 22,984 | 1,445 | 24,429 | yes |
|
|
347
|
+
| openslimedit | gpt-5.3-codex | 6k-lines | 34,198 ms | 28,639 | 1,410 | 30,049 | yes |
|
|
348
|
+
| openslimedit | gpt-5.3-codex | 6k-lines | 32,525 ms | 33,417 | 1,669 | 35,086 | yes |
|
|
349
|
+
| openslimedit | gpt-5.3-codex | 6k-lines | 26,625 ms | 26,330 | 1,286 | 27,616 | yes |
|
|
350
|
+
| openslimedit | gpt-5.3-codex | 10k-lines | 26,953 ms | 28,106 | 1,180 | 29,286 | yes |
|
|
351
|
+
| openslimedit | gpt-5.3-codex | 10k-lines | 33,084 ms | 28,065 | 1,423 | 29,488 | yes |
|
|
352
|
+
| openslimedit | gpt-5.3-codex | 10k-lines | 33,384 ms | 38,156 | 1,324 | 39,480 | yes |
|
|
353
|
+
| openslimedit | gpt-5.3-codex | 10k-lines | 32,269 ms | 42,259 | 1,277 | 43,536 | yes |
|
|
354
|
+
| openslimedit | gpt-5.3-codex | 10k-lines | 28,136 ms | 28,476 | 1,308 | 29,784 | yes |
|
|
281
355
|
|
|
282
356
|
</details>
|
|
283
357
|
|
|
@@ -288,9 +362,8 @@ The hash-tagged read output, custom tool schemas, and system prompt injection ad
|
|
|
288
362
|
```
|
|
289
363
|
openslimedit/
|
|
290
364
|
├── src/
|
|
291
|
-
│ └── index.ts
|
|
365
|
+
│ └── index.ts # Plugin implementation (single file)
|
|
292
366
|
├── package.json
|
|
293
|
-
├── tsconfig.json
|
|
294
367
|
├── LICENSE
|
|
295
368
|
└── README.md
|
|
296
369
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openslimedit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "OpenCode plugin that reduces token usage by up to 33% — compresses tool descriptions, compacts read output, adds line-range edit support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,15 +21,13 @@
|
|
|
21
21
|
"code-editing",
|
|
22
22
|
"ai"
|
|
23
23
|
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
|
|
26
|
-
},
|
|
24
|
+
"scripts": {},
|
|
25
|
+
"main": "./src/index.ts",
|
|
27
26
|
"exports": {
|
|
28
27
|
".": "./src/index.ts"
|
|
29
28
|
},
|
|
30
29
|
"files": [
|
|
31
30
|
"src",
|
|
32
|
-
"scripts",
|
|
33
31
|
"LICENSE",
|
|
34
32
|
"README.md"
|
|
35
33
|
],
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
1
1
|
import type { Plugin } from "@opencode-ai/plugin"
|
|
2
2
|
import * as fs from "fs"
|
|
3
3
|
import * as path from "path"
|
|
4
|
+
import { z } from "zod"
|
|
4
5
|
|
|
5
6
|
const LINE_RANGE_RE = /^(\d+)(?:\s*-\s*(\d+))?$/
|
|
6
7
|
|
|
8
|
+
// Minimal parameter schemas (no .describe() calls = no descriptions in JSON schema)
|
|
9
|
+
const SLIM_PARAMS: Record<string, any> = {
|
|
10
|
+
read: z.object({
|
|
11
|
+
filePath: z.string(),
|
|
12
|
+
offset: z.coerce.number().optional(),
|
|
13
|
+
limit: z.coerce.number().optional(),
|
|
14
|
+
}),
|
|
15
|
+
edit: z.object({
|
|
16
|
+
filePath: z.string(),
|
|
17
|
+
oldString: z.string(),
|
|
18
|
+
newString: z.string(),
|
|
19
|
+
replaceAll: z.boolean().optional(),
|
|
20
|
+
}),
|
|
21
|
+
write: z.object({
|
|
22
|
+
filePath: z.string(),
|
|
23
|
+
content: z.string(),
|
|
24
|
+
}),
|
|
25
|
+
bash: z.object({
|
|
26
|
+
command: z.string(),
|
|
27
|
+
timeout: z.number().optional(),
|
|
28
|
+
}),
|
|
29
|
+
glob: z.object({
|
|
30
|
+
pattern: z.string(),
|
|
31
|
+
path: z.string().optional(),
|
|
32
|
+
}),
|
|
33
|
+
grep: z.object({
|
|
34
|
+
pattern: z.string(),
|
|
35
|
+
path: z.string().optional(),
|
|
36
|
+
include: z.string().optional(),
|
|
37
|
+
}),
|
|
38
|
+
}
|
|
39
|
+
|
|
7
40
|
export const OpenSlimeditPlugin: Plugin = async ({ directory }) => {
|
|
8
41
|
function resolvePath(filePath: string): string {
|
|
9
42
|
if (path.isAbsolute(filePath)) return path.normalize(filePath)
|
|
@@ -11,7 +44,7 @@ export const OpenSlimeditPlugin: Plugin = async ({ directory }) => {
|
|
|
11
44
|
}
|
|
12
45
|
|
|
13
46
|
return {
|
|
14
|
-
//
|
|
47
|
+
// Shorten tool descriptions + strip parameter descriptions
|
|
15
48
|
"tool.definition": async (input: any, output: any) => {
|
|
16
49
|
const SLIM: Record<string, string> = {
|
|
17
50
|
read: "Read file content.",
|
|
@@ -26,10 +59,22 @@ export const OpenSlimeditPlugin: Plugin = async ({ directory }) => {
|
|
|
26
59
|
if (SLIM[input.toolID]) {
|
|
27
60
|
output.description = SLIM[input.toolID]
|
|
28
61
|
}
|
|
62
|
+
// Parameter schema compression disabled — hurts large-file-edit on minimax
|
|
63
|
+
// if (SLIM_PARAMS[input.toolID]) {
|
|
64
|
+
// output.parameters = SLIM_PARAMS[input.toolID]
|
|
65
|
+
// }
|
|
29
66
|
},
|
|
30
67
|
|
|
31
|
-
// Compact
|
|
68
|
+
// Compact tool output: shorten read paths, strip footer, compress edit results
|
|
32
69
|
"tool.execute.after": async (input, output) => {
|
|
70
|
+
// Compress edit output
|
|
71
|
+
if (input.tool === "edit") {
|
|
72
|
+
if (output.output.startsWith("Edit applied successfully.")) {
|
|
73
|
+
output.output = "OK"
|
|
74
|
+
}
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
33
78
|
if (input.tool !== "read") return
|
|
34
79
|
if (output.output.includes("<type>directory</type>")) return
|
|
35
80
|
|
package/scripts/postinstall.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import fs from "fs"
|
|
2
|
-
import path from "path"
|
|
3
|
-
|
|
4
|
-
const PLUGIN_NAME = "openslimedit"
|
|
5
|
-
|
|
6
|
-
// INIT_CWD is set by npm/bun to the directory where install was run
|
|
7
|
-
const projectDir = process.env.INIT_CWD
|
|
8
|
-
if (!projectDir) {
|
|
9
|
-
console.log(` openslimedit installed. Add "${PLUGIN_NAME}" to your .opencode/opencode.json plugins array.`)
|
|
10
|
-
process.exit(0)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const configDir = path.join(projectDir, ".opencode")
|
|
14
|
-
const configFile = path.join(configDir, "opencode.json")
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
let config = {}
|
|
18
|
-
|
|
19
|
-
if (fs.existsSync(configFile)) {
|
|
20
|
-
const raw = fs.readFileSync(configFile, "utf-8")
|
|
21
|
-
config = JSON.parse(raw)
|
|
22
|
-
} else {
|
|
23
|
-
// Also check for opencode.jsonc
|
|
24
|
-
const jsoncFile = path.join(configDir, "opencode.jsonc")
|
|
25
|
-
if (fs.existsSync(jsoncFile)) {
|
|
26
|
-
console.log(` openslimedit: found opencode.jsonc — please add "${PLUGIN_NAME}" to the plugin array manually.`)
|
|
27
|
-
process.exit(0)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (!Array.isArray(config.plugin)) {
|
|
32
|
-
config.plugin = []
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Check if already configured (with or without version suffix)
|
|
36
|
-
const alreadyExists = config.plugin.some(
|
|
37
|
-
(p) => p === PLUGIN_NAME || p.startsWith(PLUGIN_NAME + "@")
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
if (alreadyExists) {
|
|
41
|
-
console.log(` openslimedit: already configured in ${configFile}`)
|
|
42
|
-
process.exit(0)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
config.plugin.push(PLUGIN_NAME)
|
|
46
|
-
|
|
47
|
-
if (!fs.existsSync(configDir)) {
|
|
48
|
-
fs.mkdirSync(configDir, { recursive: true })
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
fs.writeFileSync(configFile, JSON.stringify(config, null, 2) + "\n")
|
|
52
|
-
console.log(` openslimedit: added to ${configFile}`)
|
|
53
|
-
} catch (err) {
|
|
54
|
-
console.log(` openslimedit installed. Add "${PLUGIN_NAME}" to your .opencode/opencode.json plugins array.`)
|
|
55
|
-
}
|