context-dropper 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.
Files changed (3) hide show
  1. package/README.md +254 -0
  2. package/dist/index.js +6607 -0
  3. package/package.json +34 -0
package/README.md ADDED
@@ -0,0 +1,254 @@
1
+ # context-dropper
2
+
3
+ `context-dropper` is a CLI for iterating through a fixed list of files, tracking
4
+ position, and tagging progress.
5
+
6
+ ## Install and Run
7
+
8
+ ```bash
9
+ bun install
10
+ ```
11
+
12
+ Run directly:
13
+
14
+ ```bash
15
+ bun run src/index.ts --help
16
+ ```
17
+
18
+ Or after building your own wrapper/binary, use:
19
+
20
+ ```bash
21
+ context-dropper --help
22
+ ```
23
+
24
+ ## Command Shape
25
+
26
+ ```bash
27
+ context-dropper [--data-dir <path>] <command>
28
+ ```
29
+
30
+ Global option:
31
+
32
+ - `--data-dir <path>`: directory where filesets and droppers are stored.
33
+ - Default: `./.context-dropper` resolved from current working directory.
34
+
35
+ If run with no command, usage/help is shown. If `fileset` or `dropper` are run
36
+ without a subcommand, that group help is shown.
37
+
38
+ ## Data Layout
39
+
40
+ The CLI stores state under `data-dir`:
41
+
42
+ ```text
43
+ data-dir/
44
+ filesets/
45
+ <name>.txt
46
+ droppers/
47
+ <name>.json
48
+ ```
49
+
50
+ Fileset file (`filesets/<name>.txt`):
51
+
52
+ - One normalized absolute file path per line.
53
+ - Import is immutable: importing the same fileset name again fails.
54
+
55
+ Dropper file (`droppers/<name>.json`):
56
+
57
+ ```json
58
+ {
59
+ "fileset": "my-fileset",
60
+ "pointer_position": 0,
61
+ "tags": {
62
+ "processed": ["/abs/path/a.ts", "/abs/path/b.ts"]
63
+ }
64
+ }
65
+ ```
66
+
67
+ - `tags` is `tag -> filename[]`.
68
+ - Filename arrays are deduplicated and sorted.
69
+
70
+ ## Name Rules
71
+
72
+ Fileset/dropper names must:
73
+
74
+ - Match `^[A-Za-z0-9._-]+$`
75
+ - Not be `.` or `..`
76
+ - Not contain path separators
77
+
78
+ ## Commands
79
+
80
+ ### `fileset`
81
+
82
+ Import from a list file:
83
+
84
+ ```bash
85
+ context-dropper fileset import --name <name> <listFilePath>
86
+ ```
87
+
88
+ - `listFilePath` must be plain text with one path per line.
89
+ - Blank lines are ignored.
90
+ - Relative lines are resolved from the list file directory.
91
+ - Each referenced file must exist and be readable.
92
+ - Stored entries become normalized absolute paths.
93
+
94
+ List filesets:
95
+
96
+ ```bash
97
+ context-dropper fileset list
98
+ ```
99
+
100
+ - Output: one fileset name per line.
101
+
102
+ Show fileset contents:
103
+
104
+ ```bash
105
+ context-dropper fileset show <name>
106
+ ```
107
+
108
+ - Output: one file path per line.
109
+
110
+ Remove fileset:
111
+
112
+ ```bash
113
+ context-dropper fileset remove <name>
114
+ ```
115
+
116
+ - Fails if any dropper still references it.
117
+
118
+ ### `dropper`
119
+
120
+ Create:
121
+
122
+ ```bash
123
+ context-dropper dropper create --fileset <filesetName> <dropperName>
124
+ ```
125
+
126
+ Show current file contents:
127
+
128
+ ```bash
129
+ context-dropper dropper show <dropperName>
130
+ ```
131
+
132
+ Move pointer forward:
133
+
134
+ ```bash
135
+ context-dropper dropper next <dropperName>
136
+ ```
137
+
138
+ - Silent on success.
139
+
140
+ Move pointer backward:
141
+
142
+ ```bash
143
+ context-dropper dropper previous <dropperName>
144
+ ```
145
+
146
+ - Silent on success.
147
+
148
+ Tag current item:
149
+
150
+ ```bash
151
+ context-dropper dropper tag <dropperName> --tag <text> [--tag <text>]...
152
+ ```
153
+
154
+ List tags of current item:
155
+
156
+ ```bash
157
+ context-dropper dropper list-tags <dropperName>
158
+ ```
159
+
160
+ - Output: one tag per line.
161
+
162
+ Remove tags from current item:
163
+
164
+ ```bash
165
+ context-dropper dropper remove-tag <dropperName> --tag <text> [--tag <text>]...
166
+ ```
167
+
168
+ List dropper entries with optional filters:
169
+
170
+ ```bash
171
+ context-dropper dropper list-files <dropperName> [--tag <tag>]... [--filename <absolutePath>]
172
+ ```
173
+
174
+ - Output: paths only, one per line.
175
+ - Repeated `--tag` uses OR semantics.
176
+ - `--filename` is exact path match.
177
+ - When both are provided: AND semantics (`filename` match and tag OR match).
178
+ - Aliases: `context-dropper dropper ls-files <dropperName>`
179
+
180
+ List all droppers, optionally filtered by fileset name:
181
+
182
+ ```bash
183
+ context-dropper dropper list [--fileset <filesetName>]
184
+ ```
185
+
186
+ - Output: one dropper name per line.
187
+ - When `--fileset` is provided, filters for droppers referencing that fileset.
188
+ - Aliases: `context-dropper dropper ls [--fileset <filesetName>]`
189
+
190
+ Dump dropper materialized state:
191
+
192
+ ```bash
193
+ context-dropper dropper dump <dropperName>
194
+ ```
195
+
196
+ - Output: pretty JSON.
197
+
198
+ Remove dropper:
199
+
200
+ ```bash
201
+ context-dropper dropper remove <dropperName>
202
+ ```
203
+
204
+ Check completion:
205
+
206
+ ```bash
207
+ context-dropper dropper is-done <dropperName>
208
+ ```
209
+
210
+ - Done condition: every file has at least one tag.
211
+ - If done: prints `true` and exits `0`.
212
+ - If not done: exits non-zero with an error listing untagged files.
213
+
214
+ ## OpenCode Plugin
215
+
216
+ This repository also includes a dedicated, self-contained plugin for [OpenCode](https://github.com/opencode-ai/opencode) under `opencode-plugin/`.
217
+ The plugin natively binds to the `context-dropper` APIs and lets you iterate through filesets autonomously inside an OpenCode chat session.
218
+ See [opencode-plugin/README.md](./opencode-plugin/README.md) for installation and usage instructions.
219
+
220
+ ## Exit Codes
221
+
222
+ - `0`: success
223
+ - `1`: application error
224
+ - `2`: usage/argument error
225
+ - `3`: dropper exhausted (`show` with no current item, or `next` at end)
226
+ - `4`: dropper at start (`previous` at start)
227
+
228
+ ## Suggested AI-Agent Workflow
229
+
230
+ 1. Import a fileset:
231
+ `context-dropper fileset import --name <filesetName> <listFilePath>`
232
+ 2. Create a dropper:
233
+ `context-dropper dropper create --fileset <filesetName> <dropperName>`
234
+ 3. Ask the agent to perform the task (for example: review/document each file)
235
+ and follow the processing loop below.
236
+
237
+ ## Agent Loop Rule
238
+
239
+ When acting as an agent over a dropper, use this exact loop:
240
+
241
+ 1. Run `context-dropper dropper show <dropperName>`.
242
+ 2. Perform the requested task on that file content.
243
+ 3. Run `context-dropper dropper tag <dropperName> --tag processed`.
244
+ 4. Run `context-dropper dropper is-done <dropperName>`.
245
+ 5. If `is-done` succeeded and printed `true`, stop.
246
+ 6. If `is-done` failed because untagged items remain, run
247
+ `context-dropper dropper next <dropperName>` and repeat from step 1.
248
+
249
+ Notes for agents:
250
+
251
+ - `next` and `previous` are movement only; they do not print file contents.
252
+ - Use `show` to read the current file.
253
+ - Do not stop on `is-done` non-zero unless the message is not
254
+ `Untagged items remain: ...`.