opencode-tmux-session 0.1.0 → 0.2.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/bin/setup.js +51 -0
- package/commands/new-session.md +9 -0
- package/package.json +6 -3
package/bin/setup.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { dirname, join } from "path";
|
|
5
|
+
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const PKG = join(__dirname, "..");
|
|
8
|
+
|
|
9
|
+
const OCODE = join(process.env.HOME || process.env.USERPROFILE, ".config", "opencode");
|
|
10
|
+
const COMMANDS_DIR = join(OCODE, "commands");
|
|
11
|
+
const CONFIG_PATH = join(OCODE, "opencode.json");
|
|
12
|
+
|
|
13
|
+
let ok = true;
|
|
14
|
+
|
|
15
|
+
const cmdSrc = join(PKG, "commands", "new-session.md");
|
|
16
|
+
const cmdDst = join(COMMANDS_DIR, "new-session.md");
|
|
17
|
+
if (existsSync(cmdSrc)) {
|
|
18
|
+
if (!existsSync(COMMANDS_DIR)) mkdirSync(COMMANDS_DIR, { recursive: true });
|
|
19
|
+
copyFileSync(cmdSrc, cmdDst);
|
|
20
|
+
console.log(`✓ Installed command: ${cmdDst}`);
|
|
21
|
+
} else {
|
|
22
|
+
console.error(`✗ Command file not found: ${cmdSrc}`);
|
|
23
|
+
ok = false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (existsSync(CONFIG_PATH)) {
|
|
27
|
+
try {
|
|
28
|
+
const raw = readFileSync(CONFIG_PATH, "utf-8");
|
|
29
|
+
const config = JSON.parse(raw);
|
|
30
|
+
if (!Array.isArray(config.plugin)) config.plugin = [];
|
|
31
|
+
if (!config.plugin.includes("opencode-tmux-session")) {
|
|
32
|
+
config.plugin.push("opencode-tmux-session");
|
|
33
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2) + "\n");
|
|
34
|
+
console.log("✓ Added opencode-tmux-session to plugin array");
|
|
35
|
+
} else {
|
|
36
|
+
console.log("ℹ opencode-tmux-session already in plugin array");
|
|
37
|
+
}
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.error(`✗ Failed to update opencode.json: ${e.message}`);
|
|
40
|
+
ok = false;
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
console.error("✗ opencode.json not found, plugin entry not added");
|
|
44
|
+
ok = false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (ok) {
|
|
48
|
+
console.log("\nDone! Restart opencode for changes to take effect.");
|
|
49
|
+
} else {
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Open a new opencode session in a new tmux window
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The user wants to start a new opencode session.
|
|
6
|
+
|
|
7
|
+
!`if tmux new-window opencode; then tmux display-message -d 5000 "✓ New session opened in new window"; else tmux display-message -d 5000 "✗ Failed to open new session"; fi`
|
|
8
|
+
|
|
9
|
+
Tell the user a new session has been opened in a new tmux window and ask what they'd like to do next.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-tmux-session",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "OpenCode plugin — fork sessions to tmux side panes and open new sessions in tmux windows with status notifications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,12 +16,15 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
|
-
"dist"
|
|
19
|
+
"dist",
|
|
20
|
+
"commands",
|
|
21
|
+
"bin"
|
|
20
22
|
],
|
|
21
23
|
"scripts": {
|
|
22
24
|
"build": "tsc",
|
|
23
25
|
"prepublishOnly": "npm run build",
|
|
24
|
-
"typecheck": "tsc --noEmit"
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"postinstall": "node bin/setup.js"
|
|
25
28
|
},
|
|
26
29
|
"keywords": [
|
|
27
30
|
"opencode",
|