opencode-tmux-alert 0.1.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.
- package/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +64 -0
- package/package.json +39 -0
- package/scripts/alert.sh +16 -0
- package/scripts/clear.sh +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sean Halberthal
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# opencode-tmux-alert
|
|
4
|
+
|
|
5
|
+
**Tmux alert plugin for [OpenCode](https://opencode.ai) — get notified when your AI agent needs attention.**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/opencode-tmux-alert)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](https://opencode.ai/docs/plugins/)
|
|
10
|
+
|
|
11
|
+
[Quick Start](#quick-start) · [How It Works](#how-it-works) · [Events](#events) · [Customisation](#customisation)
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### Package
|
|
20
|
+
|
|
21
|
+
Install in your OpenCode config directory:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bun install opencode-tmux-alert
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then add the plugin to your `opencode.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"plugin": ["opencode-tmux-alert"]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Local file
|
|
36
|
+
|
|
37
|
+
Copy `src/index.ts` into your OpenCode plugins directory:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cp src/index.ts ~/.config/opencode/plugins/opencode-tmux-alert.ts
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## How It Works
|
|
46
|
+
|
|
47
|
+
When OpenCode needs your attention — a task finishes, a permission is requested, or a question is asked — the plugin triggers a tmux alert on the current window. When you respond, the alert clears automatically.
|
|
48
|
+
|
|
49
|
+
The bundled scripts do two things:
|
|
50
|
+
|
|
51
|
+
1. **Set a tmux user option** (`@opencode-alert`) that you can reference in your status line
|
|
52
|
+
2. **Send a bell character** (`\a`) which triggers tmux's built-in `monitor-bell` notification
|
|
53
|
+
|
|
54
|
+
This means alerts work out of the box with a standard tmux config, and can be further customised with status line formatting.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Events
|
|
59
|
+
|
|
60
|
+
| Event | Trigger | Action |
|
|
61
|
+
|-------|---------|--------|
|
|
62
|
+
| `session.idle` | Task completed, agent waiting | Alert |
|
|
63
|
+
| `permission.updated` | Agent needs permission to proceed | Alert |
|
|
64
|
+
| `message.part.updated` | Tool pending approval | Alert |
|
|
65
|
+
| `tui.prompt.append` | Agent asking a question | Alert |
|
|
66
|
+
| `message.updated` (user) | User submits a message | Clear |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Customisation
|
|
71
|
+
|
|
72
|
+
### Status line indicator
|
|
73
|
+
|
|
74
|
+
Use the `@opencode-alert` user option in your tmux status format to show a visual indicator:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# In tmux.conf — show an indicator when OpenCode needs attention
|
|
78
|
+
set -g status-right "#{?@opencode-alert,#[fg=yellow] OpenCode,} ..."
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Custom scripts
|
|
82
|
+
|
|
83
|
+
Override the bundled alert and clear scripts with your own via environment variables:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
export OPENCODE_ALERT_SCRIPT="$HOME/my-scripts/alert.sh"
|
|
87
|
+
export OPENCODE_CLEAR_SCRIPT="$HOME/my-scripts/clear.sh"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Your scripts receive no arguments. The `TMUX_PANE` environment variable is available if you need to target the current window.
|
|
91
|
+
|
|
92
|
+
### tmux bell monitoring
|
|
93
|
+
|
|
94
|
+
To use the bell-based alerts, enable monitoring in your `tmux.conf`:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
set -g monitor-bell on
|
|
98
|
+
set -g visual-bell off # optional — suppress the visual flash
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Requirements
|
|
104
|
+
|
|
105
|
+
- [OpenCode](https://opencode.ai) with plugin support
|
|
106
|
+
- [tmux](https://github.com/tmux/tmux) — the plugin disables itself gracefully if not running inside tmux
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
[MIT](LICENSE)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Plugin } from "@opencode-ai/plugin";
|
|
2
|
+
/**
|
|
3
|
+
* Tmux alert plugin for OpenCode.
|
|
4
|
+
*
|
|
5
|
+
* Sends visual alerts to tmux when OpenCode needs attention:
|
|
6
|
+
* - Task completed (session idle)
|
|
7
|
+
* - Permission requested
|
|
8
|
+
* - Question asked (prompt append)
|
|
9
|
+
*
|
|
10
|
+
* Clears the alert when the user submits a message.
|
|
11
|
+
*
|
|
12
|
+
* Customise alert/clear scripts via environment variables:
|
|
13
|
+
* OPENCODE_ALERT_SCRIPT — path to a custom alert script
|
|
14
|
+
* OPENCODE_CLEAR_SCRIPT — path to a custom clear script
|
|
15
|
+
*/
|
|
16
|
+
export declare const TmuxAlertPlugin: Plugin;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { resolve, dirname } from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
/**
|
|
4
|
+
* Tmux alert plugin for OpenCode.
|
|
5
|
+
*
|
|
6
|
+
* Sends visual alerts to tmux when OpenCode needs attention:
|
|
7
|
+
* - Task completed (session idle)
|
|
8
|
+
* - Permission requested
|
|
9
|
+
* - Question asked (prompt append)
|
|
10
|
+
*
|
|
11
|
+
* Clears the alert when the user submits a message.
|
|
12
|
+
*
|
|
13
|
+
* Customise alert/clear scripts via environment variables:
|
|
14
|
+
* OPENCODE_ALERT_SCRIPT — path to a custom alert script
|
|
15
|
+
* OPENCODE_CLEAR_SCRIPT — path to a custom clear script
|
|
16
|
+
*/
|
|
17
|
+
export const TmuxAlertPlugin = async ({ $ }) => {
|
|
18
|
+
const pluginDir = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const scriptsDir = resolve(pluginDir, "../scripts");
|
|
20
|
+
const alertScript = process.env.OPENCODE_ALERT_SCRIPT ?? resolve(scriptsDir, "alert.sh");
|
|
21
|
+
const clearScript = process.env.OPENCODE_CLEAR_SCRIPT ?? resolve(scriptsDir, "clear.sh");
|
|
22
|
+
if (!process.env.TMUX) {
|
|
23
|
+
console.error("[opencode-tmux-alert] Not running inside tmux — plugin disabled");
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
const alert = async () => {
|
|
27
|
+
await $ `${alertScript}`;
|
|
28
|
+
};
|
|
29
|
+
const clear = async () => {
|
|
30
|
+
await $ `${clearScript}`;
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
event: async ({ event }) => {
|
|
34
|
+
try {
|
|
35
|
+
// Task completed — session is now idle
|
|
36
|
+
if (event.type === "session.idle") {
|
|
37
|
+
await alert();
|
|
38
|
+
}
|
|
39
|
+
// Permission requested
|
|
40
|
+
if (event.type === "permission.updated") {
|
|
41
|
+
await alert();
|
|
42
|
+
}
|
|
43
|
+
// Tool pending permission approval
|
|
44
|
+
if (event.type === "message.part.updated" &&
|
|
45
|
+
event.properties.part.type === "tool" &&
|
|
46
|
+
event.properties.part.state.status === "pending") {
|
|
47
|
+
await alert();
|
|
48
|
+
}
|
|
49
|
+
// Agent asking a question
|
|
50
|
+
if (event.type === "tui.prompt.append") {
|
|
51
|
+
await alert();
|
|
52
|
+
}
|
|
53
|
+
// User submitted a message — clear the alert
|
|
54
|
+
if (event.type === "message.updated" &&
|
|
55
|
+
event.properties.info.role === "user") {
|
|
56
|
+
await clear();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error("[opencode-tmux-alert] Error:", error);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opencode-tmux-alert",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tmux alert plugin for OpenCode — get notified when your AI agent needs attention",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"scripts"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "bun test",
|
|
14
|
+
"prepublishOnly": "bun test && bun run build"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"opencode",
|
|
18
|
+
"opencode-plugin",
|
|
19
|
+
"tmux",
|
|
20
|
+
"alert",
|
|
21
|
+
"notification"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/seanhalberthal/opencode-tmux-alert.git"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/seanhalberthal/opencode-tmux-alert",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/seanhalberthal/opencode-tmux-alert/issues"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@opencode-ai/plugin": "^1.2.10"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^22.0.0",
|
|
37
|
+
"typescript": "^5.7.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/scripts/alert.sh
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Trigger a tmux alert for the current window.
|
|
3
|
+
#
|
|
4
|
+
# Sets the user option @opencode-alert to "1" and sends a bell character.
|
|
5
|
+
# Use #{@opencode-alert} in your tmux status format to show a visual indicator.
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
PANE_ID="${TMUX_PANE:-}"
|
|
10
|
+
[ -z "$PANE_ID" ] && exit 0
|
|
11
|
+
|
|
12
|
+
# Set a user option that can be read from the tmux status line
|
|
13
|
+
tmux set-option -w -t "$PANE_ID" @opencode-alert 1 2>/dev/null || true
|
|
14
|
+
|
|
15
|
+
# Send bell — triggers tmux monitor-bell and visual-bell
|
|
16
|
+
printf '\a'
|