opencode-queue 0.6.1 → 0.6.3
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 +52 -44
- package/index.ts +10 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
# opencode-queue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/opencode-queue)
|
|
4
|
+
[](https://github.com/mirsella/opencode-queue/actions/workflows/ci.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/opencode-queue)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
Queue OpenCode input until the current session is idle.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- Queues normal prompts entered while a session is busy
|
|
10
|
-
- Queues prompts with either `/queue prompt` or `prompt /queue`
|
|
11
|
-
- Queues slash commands with either `/queue /review` or `/review /queue`
|
|
12
|
-
- Queues shell commands with `/queue !ls`
|
|
13
|
-
- Hides queued placeholders from both the UI transcript and the running agent
|
|
14
|
-
- Preserves the selected agent, model, and thinking variant for queued input
|
|
15
|
-
- Replays queued input in order once the session becomes idle
|
|
16
|
-
- Replays queued commands as a visible `/command` message before executing them
|
|
17
|
-
- Registers `/queue` as a real OpenCode slash command
|
|
18
|
-
- Shows the current queue with `/queue list`
|
|
19
|
-
- Clears the current queue with `/queue clear`
|
|
9
|
+
`opencode-queue` adds a real `/queue` slash command. It lets you type the next prompt, slash command, or shell command while an agent is still working, without interrupting the current run.
|
|
20
10
|
|
|
21
11
|
## Install
|
|
22
12
|
|
|
23
|
-
Add
|
|
13
|
+
Add the plugin to your OpenCode config:
|
|
24
14
|
|
|
25
15
|
```jsonc
|
|
26
16
|
{
|
|
@@ -28,49 +18,67 @@ Add it to your OpenCode plugin list:
|
|
|
28
18
|
}
|
|
29
19
|
```
|
|
30
20
|
|
|
31
|
-
OpenCode installs npm plugins automatically at startup.
|
|
32
|
-
|
|
33
|
-
Restart OpenCode after installing.
|
|
34
|
-
|
|
35
|
-
## Usage
|
|
21
|
+
Restart OpenCode after installing. OpenCode installs npm plugins automatically at startup.
|
|
36
22
|
|
|
37
|
-
|
|
23
|
+
## Quick Examples
|
|
38
24
|
|
|
39
25
|
```text
|
|
40
|
-
/queue continue after
|
|
26
|
+
/queue continue after this task
|
|
27
|
+
continue after this task /queue
|
|
28
|
+
|
|
41
29
|
/queue /review
|
|
42
|
-
/queue /commit
|
|
43
|
-
/queue !ls
|
|
44
|
-
continue after the current task finishes /queue
|
|
45
30
|
/review /queue
|
|
31
|
+
|
|
32
|
+
/queue !ls
|
|
33
|
+
|
|
46
34
|
/queue list
|
|
47
35
|
/queue clear
|
|
48
36
|
```
|
|
49
37
|
|
|
38
|
+
## Syntax
|
|
39
|
+
|
|
40
|
+
| Input | What it does |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `/queue message` | Queue a normal prompt. |
|
|
43
|
+
| `message /queue` | Queue a normal prompt using trailing syntax. |
|
|
44
|
+
| `/queue /review` | Queue a slash command. |
|
|
45
|
+
| `/review /queue` | Queue a slash command using trailing syntax. |
|
|
46
|
+
| `/queue !ls` | Queue an OpenCode shell block. |
|
|
47
|
+
| `/queue` | Show the current queue. |
|
|
48
|
+
| `/queue list` | Show the current queue. |
|
|
49
|
+
| `/queue clear` | Clear the current queue. |
|
|
50
|
+
|
|
51
|
+
## Behavior
|
|
52
|
+
|
|
53
|
+
When the session is busy:
|
|
54
|
+
|
|
55
|
+
- Queued entries are hidden from the transcript and from the running agent.
|
|
56
|
+
- The current agent run keeps using its original agent, model, and thinking variant.
|
|
57
|
+
- Queued entries replay in order after the session becomes idle.
|
|
58
|
+
- Only one queued entry is sent per idle transition, so queued work runs one item at a time.
|
|
59
|
+
|
|
50
60
|
When the session is idle:
|
|
51
61
|
|
|
62
|
+
- `/queue message` sends `message` immediately.
|
|
63
|
+
- `message /queue` sends `message` immediately.
|
|
64
|
+
- `/queue /review` runs `/review` immediately.
|
|
65
|
+
- `/review /queue` runs `/review` immediately.
|
|
66
|
+
- `/queue !ls` runs `ls` immediately as an OpenCode shell block.
|
|
67
|
+
- `/queue` and `/queue list` show the current queue.
|
|
68
|
+
- `/queue clear` clears the current queue.
|
|
69
|
+
|
|
70
|
+
## Queue Management
|
|
71
|
+
|
|
52
72
|
```text
|
|
53
|
-
/queue hello
|
|
54
|
-
/queue /review
|
|
55
|
-
/queue !date
|
|
56
|
-
hello /queue
|
|
57
|
-
/review /queue
|
|
58
73
|
/queue
|
|
74
|
+
/queue list
|
|
75
|
+
/queue clear
|
|
59
76
|
```
|
|
60
77
|
|
|
61
|
-
|
|
78
|
+
The queue is in-memory and scoped to the current session.
|
|
62
79
|
|
|
63
80
|
## Notes
|
|
64
81
|
|
|
65
|
-
- This
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
- Idle `/queue /command` immediately runs the nested command.
|
|
69
|
-
- Idle `/queue !command` immediately runs the shell command as an OpenCode shell block.
|
|
70
|
-
- `/queue` and `/queue list` show the in-memory queue for the current session.
|
|
71
|
-
- `/queue clear` drops all currently queued items for the current session.
|
|
72
|
-
- Native shell-mode suffixes like `!command /queue` are not supported because OpenCode handles leading `!` before plugin command hooks run.
|
|
73
|
-
|
|
74
|
-
## License
|
|
75
|
-
|
|
76
|
-
MIT
|
|
82
|
+
- This plugin registers `/queue` as a real OpenCode slash command.
|
|
83
|
+
- It does not add a keyboard shortcut. OpenCode plugins cannot currently register custom TUI keybindings.
|
|
84
|
+
- Queued placeholders are hidden instead of deleted, then filtered out before messages are sent to the model.
|
package/index.ts
CHANGED
|
@@ -135,21 +135,21 @@ export const QueuePlugin: Plugin = async ({ client }) => {
|
|
|
135
135
|
console.warn("QueuePlugin skipped queued item without replayable content")
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
const flush =
|
|
138
|
+
const flush = (sid: string) => {
|
|
139
139
|
const list = queue.get(sid)
|
|
140
140
|
if (flushing.has(sid) || !list?.length) return
|
|
141
|
+
const item = list.shift()
|
|
142
|
+
if (!item) return
|
|
143
|
+
|
|
144
|
+
if (list.length) queue.set(sid, list)
|
|
145
|
+
else queue.delete(sid)
|
|
141
146
|
|
|
142
147
|
flushing.add(sid)
|
|
143
|
-
|
|
144
|
-
while (list.length) await replay(sid, list.shift()!)
|
|
145
|
-
} catch (error) {
|
|
148
|
+
void replay(sid, item).catch(async (error) => {
|
|
146
149
|
console.error("QueuePlugin failed to flush queued input", error)
|
|
147
150
|
await toast(`Queue failed: ${error instanceof Error ? error.message : String(error)}`, "error")
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
else queue.delete(sid)
|
|
151
|
-
flushing.delete(sid)
|
|
152
|
-
}
|
|
151
|
+
})
|
|
152
|
+
flushing.delete(sid)
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
return {
|
|
@@ -167,7 +167,7 @@ export const QueuePlugin: Plugin = async ({ client }) => {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
busy.delete(sid)
|
|
170
|
-
|
|
170
|
+
flush(sid)
|
|
171
171
|
},
|
|
172
172
|
"command.execute.before": async (input, output) => {
|
|
173
173
|
const sid = input.sessionID
|
package/package.json
CHANGED