opencode-context-dropper-plugin 0.1.1
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 +86 -0
- package/dist/index.js +13119 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# OpenCode Context Dropper Plugin
|
|
2
|
+
|
|
3
|
+
A Context Dropper plugin for OpenCode, built with Bun and TypeScript. It leverages the internal `context-dropper` APIs to efficiently process a large set of files one-by-one entirely within your OpenCode sessions. It automatically tracks context and handles token pruning to allow continuous agent iteration.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- [Bun](https://bun.sh/) (for building the plugin)
|
|
8
|
+
- [OpenCode](https://github.com/opencode-ai/opencode)
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
This plugin bundles `context-dropper` directly and acts as a self-contained module.
|
|
13
|
+
|
|
14
|
+
1. Build the plugin in this directory:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bun install
|
|
18
|
+
bun run build
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
2. Find or create your OpenCode global configuration file at `~/.opencode/config.json`.
|
|
22
|
+
3. Add the absolute path to this directory (`opencode-plugin`) to the `plugins` array. For example:
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"plugins": ["/Users/far/Projects/context-dropper/opencode-plugin"]
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
Once installed, start OpenCode:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
opencode
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
You can invoke the context dropper loop inside chat simply by using the `/drop` slash command:
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
/drop <filesetName> <instructions>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- `<filesetName>` is the name of a pre-existing fileset in your project.
|
|
45
|
+
- `<instructions>` is the prompt you want the AI to perform on each file sequentially.
|
|
46
|
+
|
|
47
|
+
**Example:**
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
/drop backend-routes Please add try/catch blocks and proper logging to all async functions in this file.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### The Automation Loop
|
|
54
|
+
|
|
55
|
+
Once invoked, the plugin completely takes over the context management:
|
|
56
|
+
|
|
57
|
+
1. It automatically fetches the first file in the fileset and provides it to the agent along with your instructions.
|
|
58
|
+
2. The agent performs the instructions and automatically calls the `context-dropper.next` tool.
|
|
59
|
+
3. **Context Pruning**: When the tool is called, the file is tagged as processed. The plugin drops the previous file's context from the chat history (saving tokens), and feeds the next file to the agent.
|
|
60
|
+
4. This loop continues until all files are processed.
|
|
61
|
+
|
|
62
|
+
To forcefully stop the loop before it finishes, type **"stop context-dropper"**.
|
|
63
|
+
|
|
64
|
+
## Development & Debugging
|
|
65
|
+
|
|
66
|
+
To develop the plugin further, modify files under `src/`.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
bun install
|
|
70
|
+
# rebuild the bundle after changes
|
|
71
|
+
bun run build
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Debugging Logs
|
|
75
|
+
|
|
76
|
+
The plugin writes activity and execution state to a dedicated log file located at:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
~/.opencode/context-dropper.log
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
You can monitor these logs in real-time by running the following command in your terminal:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
tail -f ~/.opencode/context-dropper.log
|
|
86
|
+
```
|