opencode-queue 0.2.0 → 0.3.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.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/index.ts +8 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -12,6 +12,7 @@ This plugin adds a `/queue ...` prefix that keeps the current run focused instea
12
12
  - Replays queued input in order once the session becomes idle
13
13
  - Replays queued commands as a visible `/command` message before executing them
14
14
  - Shows the current queue with `/queue list`
15
+ - Clears the current queue with `/queue clear`
15
16
 
16
17
  ## Install
17
18
 
@@ -36,6 +37,7 @@ While the agent is busy:
36
37
  /queue /review
37
38
  /queue /commit
38
39
  /queue list
40
+ /queue clear
39
41
  ```
40
42
 
41
43
  Queued items stay hidden while the current run is still working, then replay automatically when the session becomes idle.
@@ -46,6 +48,7 @@ Queued items stay hidden while the current run is still working, then replay aut
46
48
  - Idle `/queue some text` is treated like a normal prompt with the `/queue` prefix removed.
47
49
  - Idle `/queue /command` is left alone and is not intercepted.
48
50
  - `/queue list` shows the in-memory queue for the current session.
51
+ - `/queue clear` drops all currently queued items for the current session.
49
52
 
50
53
  ## License
51
54
 
package/index.ts CHANGED
@@ -53,6 +53,12 @@ export const QueuePlugin: Plugin = async ({ client }) => {
53
53
  return items.map((item, i) => `${i + 1}. ${item.text}`).join("\n")
54
54
  }
55
55
 
56
+ const clear = (sid: string) => {
57
+ const count = queue.get(sid)?.length ?? 0
58
+ queue.delete(sid)
59
+ return count ? `Cleared ${count} queued item${count === 1 ? "" : "s"}` : "Queue is empty"
60
+ }
61
+
56
62
  const replay = async (sid: string, item: Item) => {
57
63
  if (!item.command || item.arguments === undefined) {
58
64
  if (!item.parts?.length) {
@@ -140,9 +146,9 @@ export const QueuePlugin: Plugin = async ({ client }) => {
140
146
  const files = output.parts.filter((part): part is FilePart => part.type === "file")
141
147
  const trimmed = body.trim()
142
148
 
143
- if ((!trimmed || trimmed === "list") && !files.length) {
149
+ if ((!trimmed || trimmed === "list" || trimmed === "clear") && !files.length) {
144
150
  hide(output.message.id, text)
145
- await toast(summary(sessionID), "info", 5000)
151
+ await toast(trimmed === "clear" ? clear(sessionID) : summary(sessionID), "info", 5000)
146
152
  return
147
153
  }
148
154
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "opencode-queue",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "type": "module",
6
6
  "description": "Queue OpenCode prompts and slash commands until the agent is idle",
7
7
  "main": "./index.ts",