opencode-tmux-session 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.
@@ -0,0 +1,5 @@
1
+ import { type Plugin } from "@opencode-ai/plugin";
2
+ export declare const TmuxSessionPlugin: Plugin;
3
+ export default TmuxSessionPlugin;
4
+ export declare const server: Plugin;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAMlD,eAAO,MAAM,iBAAiB,EAAE,MA4B/B,CAAC;AAEF,eAAe,iBAAiB,CAAC;AACjC,eAAO,MAAM,MAAM,QAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ import { appendFileSync } from "fs";
2
+ const LOG = "/tmp/opencode-tmux-session.log";
3
+ const log = (m) => { try {
4
+ appendFileSync(LOG, `[${Date.now()}] ${m}\n`);
5
+ }
6
+ catch { } };
7
+ export const TmuxSessionPlugin = async ({ $ }) => {
8
+ log("init");
9
+ if (!process.env.TMUX_PANE) {
10
+ log("no tmux");
11
+ return {};
12
+ }
13
+ return {
14
+ event: async ({ event }) => {
15
+ if (event.type === "session.created") {
16
+ const id = event.properties.info?.id;
17
+ const pid = event.properties.info?.parentID;
18
+ if (!id || pid)
19
+ return;
20
+ const cmd = `opencode --session ${id}`;
21
+ log(`fork: ${cmd}`);
22
+ try {
23
+ const r = await $ `tmux split-window -d ${cmd}`.nothrow();
24
+ if (r.exitCode === 0) {
25
+ await $ `tmux display-message -d 5000 "✓ Forked: new session opened in side pane (${id.slice(0, 8)})"`.nothrow();
26
+ }
27
+ else {
28
+ await $ `tmux display-message -d 5000 "✗ Fork failed: could not create side pane"`.nothrow();
29
+ }
30
+ log(`exit=${r.exitCode}`);
31
+ }
32
+ catch (e) {
33
+ await $ `tmux display-message -d 5000 "✗ Fork error: ${String(e).slice(0, 60)}"`.nothrow();
34
+ log(`err=${e}`);
35
+ }
36
+ }
37
+ },
38
+ };
39
+ };
40
+ export default TmuxSessionPlugin;
41
+ export const server = TmuxSessionPlugin;
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AAEpC,MAAM,GAAG,GAAG,gCAAgC,CAAC;AAC7C,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,GAAG,IAAI,CAAC;IAAC,cAAc,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;AAAC,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;AAE/F,MAAM,CAAC,MAAM,iBAAiB,GAAW,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE;IACvD,GAAG,CAAC,MAAM,CAAC,CAAC;IAEZ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAAC,OAAO,EAAE,CAAC;IAAC,CAAC;IAE1D,OAAO;QACL,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YACzB,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBACrC,MAAM,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;gBACrC,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC;gBAC5C,IAAI,CAAC,EAAE,IAAI,GAAG;oBAAE,OAAO;gBACvB,MAAM,GAAG,GAAG,sBAAsB,EAAE,EAAE,CAAC;gBACvC,GAAG,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;gBACpB,IAAI,CAAC;oBACH,MAAM,CAAC,GAAG,MAAM,CAAC,CAAA,wBAAwB,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;oBACzD,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;wBACrB,MAAM,CAAC,CAAA,4EAA4E,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;oBAClH,CAAC;yBAAM,CAAC;wBACN,MAAM,CAAC,CAAA,0EAA0E,CAAC,OAAO,EAAE,CAAC;oBAC9F,CAAC;oBACD,GAAG,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAC5B,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,MAAM,CAAC,CAAA,+CAA+C,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;oBAC1F,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC;AACjC,MAAM,CAAC,MAAM,MAAM,GAAG,iBAAiB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "opencode-tmux-session",
3
+ "version": "0.1.0",
4
+ "description": "OpenCode plugin — fork sessions to tmux side panes and open new sessions in tmux windows with status notifications",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./server": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "prepublishOnly": "npm run build",
24
+ "typecheck": "tsc --noEmit"
25
+ },
26
+ "keywords": [
27
+ "opencode",
28
+ "opencode-plugin",
29
+ "tmux",
30
+ "session",
31
+ "fork",
32
+ "terminal",
33
+ "multiplexer"
34
+ ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": ""
38
+ },
39
+ "license": "MIT",
40
+ "engines": {
41
+ "opencode": ">=1.3.13"
42
+ },
43
+ "dependencies": {
44
+ "@opencode-ai/plugin": "^1.3.13"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^26.0.1",
48
+ "typescript": "^5.5.0"
49
+ }
50
+ }