zjbar-opencode 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/README.md +27 -0
- package/dist/index.js +73 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# zjbar-opencode
|
|
2
|
+
|
|
3
|
+
[zjbar](https://github.com/imroc/zjbar) plugin for [OpenCode](https://opencode.ai) — live AI activity indicators in Zellij status bar.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
1. Make sure you have [zjbar](https://github.com/imroc/zjbar) installed in your Zellij layout.
|
|
8
|
+
|
|
9
|
+
2. Add to your `opencode.json`:
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"plugin": ["zjbar-opencode@latest"]
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
3. Start OpenCode inside a Zellij session with the zjbar layout — activity indicators will appear automatically.
|
|
18
|
+
|
|
19
|
+
## What it does
|
|
20
|
+
|
|
21
|
+
Translates OpenCode events into zjbar's unified event format via `zellij pipe`, enabling real-time activity indicators (thinking, tool use, waiting, etc.) on your Zellij tab bar.
|
|
22
|
+
|
|
23
|
+
The plugin only activates when running inside a Zellij session (`ZELLIJ_SESSION_NAME` is set).
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
MIT
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var TOOL_MAP = {
|
|
3
|
+
bash: "Bash",
|
|
4
|
+
read: "Read",
|
|
5
|
+
edit: "Edit",
|
|
6
|
+
write: "Write",
|
|
7
|
+
grep: "Grep",
|
|
8
|
+
glob: "Glob",
|
|
9
|
+
webfetch: "WebFetch",
|
|
10
|
+
websearch: "WebSearch",
|
|
11
|
+
todoreplace: "Task",
|
|
12
|
+
todowrite: "Task"
|
|
13
|
+
};
|
|
14
|
+
function capitalize(s) {
|
|
15
|
+
return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
|
|
16
|
+
}
|
|
17
|
+
var ZjbarPlugin = async ({ $, directory }) => {
|
|
18
|
+
const zellijSession = process.env.ZELLIJ_SESSION_NAME;
|
|
19
|
+
const paneId = process.env.ZELLIJ_PANE_ID;
|
|
20
|
+
if (!zellijSession || !paneId)
|
|
21
|
+
return {};
|
|
22
|
+
const sessionId = crypto.randomUUID();
|
|
23
|
+
const termProgram = process.env.TERM_PROGRAM || null;
|
|
24
|
+
async function sendToZjbar(hookEvent, toolName) {
|
|
25
|
+
const payload = JSON.stringify({
|
|
26
|
+
source: "opencode",
|
|
27
|
+
pane_id: parseInt(paneId, 10),
|
|
28
|
+
session_id: sessionId,
|
|
29
|
+
hook_event: hookEvent,
|
|
30
|
+
tool_name: toolName || null,
|
|
31
|
+
cwd: directory || null,
|
|
32
|
+
zellij_session: zellijSession,
|
|
33
|
+
term_program: termProgram
|
|
34
|
+
});
|
|
35
|
+
try {
|
|
36
|
+
await $`zellij -s ${zellijSession} pipe --name zjbar -- ${payload}`.quiet();
|
|
37
|
+
} catch {}
|
|
38
|
+
}
|
|
39
|
+
await sendToZjbar("SessionStart");
|
|
40
|
+
return {
|
|
41
|
+
event: async ({ event }) => {
|
|
42
|
+
switch (event.type) {
|
|
43
|
+
case "session.created":
|
|
44
|
+
await sendToZjbar("SessionStart");
|
|
45
|
+
break;
|
|
46
|
+
case "session.idle":
|
|
47
|
+
await sendToZjbar("Stop");
|
|
48
|
+
break;
|
|
49
|
+
case "session.deleted":
|
|
50
|
+
await sendToZjbar("SessionEnd");
|
|
51
|
+
break;
|
|
52
|
+
case "permission.asked":
|
|
53
|
+
await sendToZjbar("PermissionRequest");
|
|
54
|
+
break;
|
|
55
|
+
case "message.updated":
|
|
56
|
+
await sendToZjbar("PostToolUse");
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"tool.execute.before": async (input) => {
|
|
61
|
+
const toolName = TOOL_MAP[input.tool] || capitalize(input.tool);
|
|
62
|
+
await sendToZjbar("PreToolUse", toolName);
|
|
63
|
+
},
|
|
64
|
+
"tool.execute.after": async () => {
|
|
65
|
+
await sendToZjbar("PostToolUse");
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
var src_default = ZjbarPlugin;
|
|
70
|
+
export {
|
|
71
|
+
src_default as default,
|
|
72
|
+
ZjbarPlugin
|
|
73
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zjbar-opencode",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "zjbar plugin for OpenCode — live AI activity indicators in Zellij status bar",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "bun build src/index.ts --outdir dist --target node",
|
|
13
|
+
"prepublishOnly": "bun run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"opencode",
|
|
17
|
+
"zellij",
|
|
18
|
+
"zjbar",
|
|
19
|
+
"status-bar",
|
|
20
|
+
"ai",
|
|
21
|
+
"plugin"
|
|
22
|
+
],
|
|
23
|
+
"author": "imroc",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/imroc/zjbar.git",
|
|
28
|
+
"directory": "opencode-plugin"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/imroc/zjbar",
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@opencode-ai/plugin": "^1.0.224"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@opencode-ai/plugin": ">=1.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|