@grympler/opencode-tmux-handover 1.0.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,320 @@
1
+ # Quick Reference: Distribution & Configuration
2
+
3
+ Fast lookup guide for common tasks.
4
+
5
+ ---
6
+
7
+ ## Local → NPM: Publishing Checklist
8
+
9
+ - [ ] Update `package.json` with correct metadata
10
+ - [ ] Add scope if publishing as organization (`@org/name`)
11
+ - [ ] Run `npm test` to verify code quality
12
+ - [ ] Update version: `npm version patch` (or minor/major)
13
+ - [ ] Create npm account: `npm adduser`
14
+ - [ ] Publish: `npm publish`
15
+ - [ ] Verify: `npm view tt-plugin`
16
+ - [ ] Add to OpenCode config: `"plugin": ["tt-plugin"]`
17
+
18
+ **Time estimate:** 5-10 minutes
19
+
20
+ ---
21
+
22
+ ## Adding Configuration: Quick Steps
23
+
24
+ ### For Developers
25
+
26
+ 1. Create `src/config.ts` with `loadConfig()` function
27
+ 2. Update `src/index.ts` to use `config.enabledCommands`
28
+ 3. Create `src/scripts/opencode-tt-config.sh` setup script
29
+ 4. Add `src/commands/tt-configure.md` command definition
30
+ 5. Update `install.sh` to symlink config script
31
+
32
+ **Files to create/modify:**
33
+ ```
34
+ NEW: src/config.ts
35
+ MODIFY: src/index.ts
36
+ NEW: src/scripts/opencode-tt-config.sh
37
+ NEW: src/commands/tt-configure.md
38
+ MODIFY: install.sh
39
+ ```
40
+
41
+ **Time estimate:** 30 minutes implementation + testing
42
+
43
+ ### For Users
44
+
45
+ 1. Run `/tt-configure` to create config file
46
+ 2. Edit `~/.config/opencode/tt-plugin-config.json`
47
+ 3. Customize `enabledCommands` array
48
+ 4. Restart OpenCode
49
+
50
+ **Time estimate:** 2 minutes
51
+
52
+ ---
53
+
54
+ ## Configuration Options
55
+
56
+ ### Minimal Config
57
+ ```json
58
+ {
59
+ "enabledCommands": ["tmux"]
60
+ }
61
+ ```
62
+
63
+ ### All Options
64
+ ```json
65
+ {
66
+ "enabledCommands": ["tmux", "tmux-oc", "tmux-claude", "tmux-copilot"],
67
+ "defaultTerminal": "alacritty",
68
+ "sessionPrefix": "dev"
69
+ }
70
+ ```
71
+
72
+ ### Location
73
+ ```
74
+ ~/.config/opencode/tt-plugin-config.json
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Installation Methods
80
+
81
+ ### Local (Development)
82
+ ```bash
83
+ git clone https://github.com/yourname/tt-plugin.git
84
+ cd tt-plugin
85
+ npm run install
86
+ ```
87
+
88
+ ### From npm (Production)
89
+ 1. Add to `~/.config/opencode/opencode.json`:
90
+ ```json
91
+ {
92
+ "plugin": ["tt-plugin"]
93
+ }
94
+ ```
95
+ 2. Restart OpenCode
96
+ 3. Done! Auto-installed to `~/.cache/opencode/node_modules/`
97
+
98
+ ### From GitHub Packages (Organization)
99
+ ```json
100
+ {
101
+ "plugin": ["@yourorg/tt-plugin"]
102
+ }
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Publishing Versions
108
+
109
+ | Phase | Version | Command |
110
+ |-------|---------|---------|
111
+ | Beta | 0.1.0 | `npm version prerelease` |
112
+ | Patch Fix | 1.0.1 | `npm version patch` |
113
+ | New Feature | 1.1.0 | `npm version minor` |
114
+ | Breaking Change | 2.0.0 | `npm version major` |
115
+
116
+ Then: `npm publish`
117
+
118
+ ---
119
+
120
+ ## Plugin Loading Priorities
121
+
122
+ When OpenCode starts, plugins load in this order:
123
+
124
+ 1. npm plugins in global config
125
+ 2. npm plugins in project config
126
+ 3. Local plugins in `~/.config/opencode/plugins/`
127
+ 4. Local plugins in `.opencode/plugins/`
128
+
129
+ **Result:** npm plugins can be overridden by local plugins
130
+
131
+ ---
132
+
133
+ ## Environment Variables
134
+
135
+ ### For Users
136
+ ```bash
137
+ # Override config via environment
138
+ export TT_PLUGIN_COMMANDS="tmux,tmux-oc"
139
+ export TT_PLUGIN_TERMINAL="kitty"
140
+ export TT_PLUGIN_PREFIX="myprefix"
141
+ ```
142
+
143
+ ### For Developers
144
+ ```bash
145
+ # Debug plugin loading
146
+ export DEBUG=opencode:*
147
+
148
+ # Check where plugin is loaded from
149
+ ls -la ~/.cache/opencode/node_modules/tt-plugin/
150
+
151
+ # Force local plugin
152
+ rm ~/.cache/opencode/node_modules/tt-plugin/
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Common Errors & Fixes
158
+
159
+ ### "Plugin not found"
160
+ ```bash
161
+ # If using npm package:
162
+ npm install -g tt-plugin # Local install for testing
163
+
164
+ # Check OpenCode config
165
+ cat ~/.config/opencode/opencode.json
166
+
167
+ # Restart OpenCode
168
+ ```
169
+
170
+ ### Config file not found
171
+ ```bash
172
+ # First run /tt-configure command
173
+ # Or manually create:
174
+ mkdir -p ~/.config/opencode
175
+ touch ~/.config/opencode/tt-plugin-config.json
176
+ ```
177
+
178
+ ### Invalid JSON in config
179
+ ```bash
180
+ # Validate JSON
181
+ cat ~/.config/opencode/tt-plugin-config.json | jq .
182
+
183
+ # Fix with online tool
184
+ # https://jsonlint.com/
185
+ ```
186
+
187
+ ### Command not working
188
+ ```bash
189
+ # Check if enabled in config
190
+ cat ~/.config/opencode/tt-plugin-config.json | grep enabledCommands
191
+
192
+ # Restart OpenCode for changes to take effect
193
+ ```
194
+
195
+ ---
196
+
197
+ ## Key Files
198
+
199
+ | File | Purpose | Scope |
200
+ |------|---------|-------|
201
+ | `package.json` | Package metadata | Publishing |
202
+ | `src/index.ts` | Plugin entry point | All |
203
+ | `src/config.ts` | Configuration logic | Configuration |
204
+ | `src/commands/*.md` | Command definitions | Plugin |
205
+ | `src/scripts/*.sh` | Implementations | Plugin |
206
+ | `install.sh` | Installation script | Local |
207
+ | `~/.config/opencode/opencode.json` | OpenCode config | User |
208
+ | `~/.config/opencode/tt-plugin-config.json` | Plugin config | User |
209
+ | `~/.cache/opencode/node_modules/tt-plugin/` | npm installed plugin | npm |
210
+
211
+ ---
212
+
213
+ ## Command Structure
214
+
215
+ ### Current Commands
216
+ ```
217
+ /tmux - Simple tmux session
218
+ /tmux-oc - Tmux + OpenCode split
219
+ /tmux-claude - Tmux + Claude split
220
+ /tmux-copilot - Tmux + Copilot split
221
+ ```
222
+
223
+ ### With Configuration
224
+ ```
225
+ /tt-configure - NEW: Setup/edit configuration
226
+ /tmux - Respects config
227
+ /tmux-oc - Respects config
228
+ /tmux-claude - Respects config
229
+ /tmux-copilot - Respects config
230
+ ```
231
+
232
+ ---
233
+
234
+ ## Resources
235
+
236
+ - **OpenCode Docs:** https://opencode.ai/docs
237
+ - **Plugins:** https://opencode.ai/docs/plugins
238
+ - **Commands:** https://opencode.ai/docs/commands
239
+ - **npm Publishing:** https://docs.npmjs.com/packages-and-modules
240
+ - **Ecosystem:** https://opencode.ai/docs/ecosystem
241
+
242
+ ---
243
+
244
+ ## One-Liner Commands
245
+
246
+ ### Publish to npm
247
+ ```bash
248
+ npm version patch && npm publish
249
+ ```
250
+
251
+ ### Test configuration
252
+ ```bash
253
+ cat ~/.config/opencode/tt-plugin-config.json | jq .
254
+ ```
255
+
256
+ ### Check installed plugins
257
+ ```bash
258
+ cat ~/.config/opencode/opencode.json | jq '.plugin'
259
+ ```
260
+
261
+ ### List symlinked commands
262
+ ```bash
263
+ ls -la ~/.config/opencode/commands/ | grep tmux
264
+ ```
265
+
266
+ ### View npm package info
267
+ ```bash
268
+ npm view tt-plugin version
269
+ ```
270
+
271
+ ### Check OpenCode version
272
+ ```bash
273
+ opencode --version
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Decision Tree
279
+
280
+ **Q: How do I want to distribute?**
281
+ - Local development → Keep as is, use `npm run install`
282
+ - Open source → Publish to npm
283
+ - Organization only → Publish to GitHub Packages
284
+
285
+ **Q: Do I need configuration?**
286
+ - No, static commands → Don't add config
287
+ - Yes, users choose commands → Add `enabledCommands` setting
288
+ - Yes, complex settings → Use environment variables or config file
289
+
290
+ **Q: How to let users configure?**
291
+ - Command-driven → Create `/tt-configure` command
292
+ - File-only → Document `~/.config/opencode/tt-plugin-config.json`
293
+ - UI → Build web interface (advanced)
294
+
295
+ **Q: What's the release process?**
296
+ - Solo project → Semantic versioning + npm
297
+ - Team project → Use `semantic-release` for automation
298
+ - Enterprise → Use GitHub Actions for CI/CD
299
+
300
+ ---
301
+
302
+ ## Next Milestones
303
+
304
+ | Step | Effort | Impact |
305
+ |------|--------|--------|
306
+ | Add configuration support | 30 min | Medium |
307
+ | Publish to npm | 10 min | High |
308
+ | Add environment variables | 15 min | Low |
309
+ | Create configuration UI | 2 hours | High |
310
+ | Add telemetry | 1 hour | Medium |
311
+ | Automated releases | 1 hour | High |
312
+
313
+ ---
314
+
315
+ ## Support
316
+
317
+ - **Documentation:** See `DISTRIBUTION_AND_CONFIG.md` and `IMPLEMENTATION_GUIDE.md`
318
+ - **Issues:** https://github.com/yourusername/tt-plugin/issues
319
+ - **OpenCode Help:** https://github.com/anomalyco/opencode/issues
320
+ - **Discord:** https://opencode.ai/discord
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # OpenCode Tmux Plugin Suite
2
+
3
+ Launch tmux sessions from OpenCode with various AI assistants in split panes.
4
+
5
+ ## What It Does
6
+
7
+ This plugin provides multiple commands to open maximized tmux sessions:
8
+
9
+ - **`/tmux`** - Simple tmux session (single pane)
10
+ - **`/tmux-oc`** - Tmux with horizontal split, OpenCode in right pane
11
+ - **`/tmux-claude`** - Tmux with horizontal split, Claude in right pane
12
+ - **`/tmux-copilot`** - Tmux with horizontal split, GitHub Copilot in right pane
13
+
14
+ All commands run locally — no LLM calls, no token costs.
15
+
16
+ ## Requirements
17
+
18
+ - OpenCode Desktop (dev build with `command.execute.before` hook)
19
+ - tmux
20
+ - A terminal emulator (gnome-terminal, terminator, konsole, alacritty, kitty, xterm)
21
+
22
+ ### Optional - For AI Assistant Splits
23
+
24
+ - **`/tmux-oc`** - OpenCode (included with OpenCode Desktop)
25
+ - **`/tmux-claude`** - [Claude CLI](https://github.com/anthropics/claude-cli) (`claude` command)
26
+ - **`/tmux-copilot`** - [GitHub Copilot CLI](https://github.com/github/copilot-cli) (`copilot` command)
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ ./install.sh
32
+ ```
33
+
34
+ This will:
35
+ 1. Register the plugin in `~/.config/opencode/opencode.json`
36
+ 2. Symlink command definitions to `~/.config/opencode/commands/`
37
+
38
+ ### Manual Installation
39
+
40
+ If you prefer to set it up manually, add the plugin path to your `opencode.json`:
41
+
42
+ ```json
43
+ {
44
+ "plugin": [
45
+ "/path/to/tt-plugin"
46
+ ]
47
+ }
48
+ ```
49
+
50
+ And symlink the commands:
51
+
52
+ ```bash
53
+ ln -s $(pwd)/src/commands/tmux.md ~/.config/opencode/commands/
54
+ ln -s $(pwd)/src/commands/tmux-oc.md ~/.config/opencode/commands/
55
+ ln -s $(pwd)/src/commands/tmux-claude.md ~/.config/opencode/commands/
56
+ ln -s $(pwd)/src/commands/tmux-copilot.md ~/.config/opencode/commands/
57
+ ```
58
+
59
+ ## Usage
60
+
61
+ Type any of the commands in OpenCode:
62
+
63
+ - **`/tmux`** - Simple tmux session
64
+ - **`/tmux-oc`** - Tmux + OpenCode split
65
+ - **`/tmux-claude`** - Tmux + Claude split
66
+ - **`/tmux-copilot`** - Tmux + Copilot split
67
+
68
+ Each command will:
69
+ - First run: Create a new tmux session
70
+ - Already in tmux: Create a new split in current window
71
+ - Session exists: Attach to existing session
72
+
73
+ Session names are based on directory names.
74
+
75
+ ## Uninstall
76
+
77
+ ```bash
78
+ ./uninstall.sh
79
+ ```
80
+
81
+ This will unregister the plugin from `opencode.json` and remove command symlinks.
82
+
83
+ ## File Structure
84
+
85
+ ```
86
+ src/
87
+ ├── index.ts # Main plugin entry point
88
+ ├── commands/
89
+ │ ├── tmux.md # /tmux command definition
90
+ │ ├── tmux-oc.md # /tmux-oc command definition
91
+ │ ├── tmux-claude.md # /tmux-claude command definition
92
+ │ └── tmux-copilot.md # /tmux-copilot command definition
93
+ └── scripts/
94
+ ├── opencode-tmux.sh # Simple tmux script
95
+ ├── opencode-tmux-oc.sh # OpenCode split script
96
+ ├── opencode-tmux-claude.sh # Claude split script
97
+ └── opencode-tmux-copilot.sh # Copilot split script
98
+
99
+ scripts/
100
+ ├── register-plugin.js # Registers plugin in opencode.json
101
+ └── unregister-plugin.js # Unregisters plugin from opencode.json
102
+
103
+ install.sh # Installation script
104
+ uninstall.sh # Uninstallation script
105
+ package.json # Plugin manifest
106
+ ```
107
+
108
+ ## How It Works
109
+
110
+ The plugin uses OpenCode's `command.execute.before` hook to intercept commands before they reach the LLM. When a command is detected:
111
+
112
+ 1. The plugin executes the corresponding bash script
113
+ 2. The script launches a terminal with tmux
114
+ 3. For split commands, the AI assistant launches in the right pane
115
+ 4. The command output is cleared (`output.parts = []`) to prevent LLM processing
116
+
117
+ The plugin is self-contained - bash scripts are referenced using relative paths from the plugin directory, so no global installation of scripts is needed.
package/install.sh ADDED
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Colors for output
5
+ RED='\033[0;31m'
6
+ GREEN='\033[0;32m'
7
+ YELLOW='\033[1;33m'
8
+ BLUE='\033[0;34m'
9
+ NC='\033[0m' # No Color
10
+
11
+ # Configuration
12
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13
+ OPENCODE_CONFIG="${HOME}/.config/opencode"
14
+
15
+ echo -e "${BLUE}=== OpenCode Tmux Plugin Suite Installation ===${NC}\n"
16
+
17
+ # Ensure directories exist
18
+ echo -e "${YELLOW}Creating directories...${NC}"
19
+ mkdir -p "${OPENCODE_CONFIG}/commands"
20
+
21
+ # Function to create symlink with backup
22
+ create_symlink() {
23
+ local src="$1"
24
+ local dest="$2"
25
+ local name="$3"
26
+
27
+ if [ ! -f "$src" ]; then
28
+ echo -e "${RED}✗ Source file not found: $src${NC}"
29
+ return 1
30
+ fi
31
+
32
+ # Backup existing file if it exists and is not already a symlink
33
+ if [ -e "$dest" ] && [ ! -L "$dest" ]; then
34
+ echo -e "${YELLOW} Backing up existing $name to ${dest}.bak${NC}"
35
+ mv "$dest" "${dest}.bak"
36
+ fi
37
+
38
+ # Remove old symlink if it exists
39
+ if [ -L "$dest" ]; then
40
+ rm "$dest"
41
+ fi
42
+
43
+ # Create symlink
44
+ ln -s "$src" "$dest"
45
+ echo -e "${GREEN}✓ Symlinked $name${NC}"
46
+ }
47
+
48
+ # Function to remove old symlink if exists
49
+ remove_old_symlink() {
50
+ local dest="$1"
51
+ local name="$2"
52
+
53
+ if [ -L "$dest" ]; then
54
+ rm "$dest"
55
+ echo -e "${YELLOW} Removed old $name symlink${NC}"
56
+ fi
57
+ }
58
+
59
+ # Remove old plugin symlinks (cleanup from old install)
60
+ echo -e "${YELLOW}Cleaning up old plugin symlinks...${NC}"
61
+ remove_old_symlink "${OPENCODE_CONFIG}/plugins/tmux-launcher.ts" "tmux-launcher plugin"
62
+ remove_old_symlink "${OPENCODE_CONFIG}/plugins/tmux-oc-launcher.ts" "tmux-oc-launcher plugin"
63
+ remove_old_symlink "${OPENCODE_CONFIG}/plugins/tmux-claude-launcher.ts" "tmux-claude-launcher plugin"
64
+ remove_old_symlink "${OPENCODE_CONFIG}/plugins/tmux-copilot-launcher.ts" "tmux-copilot-launcher plugin"
65
+
66
+ # Remove old script symlinks (cleanup from old install)
67
+ echo -e "${YELLOW}Cleaning up old script symlinks...${NC}"
68
+ remove_old_symlink "${HOME}/.local/bin/opencode-tmux.sh" "opencode-tmux.sh script"
69
+ remove_old_symlink "${HOME}/.local/bin/opencode-tmux-oc.sh" "opencode-tmux-oc.sh script"
70
+ remove_old_symlink "${HOME}/.local/bin/opencode-tmux-claude.sh" "opencode-tmux-claude.sh script"
71
+ remove_old_symlink "${HOME}/.local/bin/opencode-tmux-copilot.sh" "opencode-tmux-copilot.sh script"
72
+
73
+ # Install commands
74
+ echo -e "\n${YELLOW}Installing command files...${NC}"
75
+
76
+ create_symlink \
77
+ "${SCRIPT_DIR}/src/commands/tmux.md" \
78
+ "${OPENCODE_CONFIG}/commands/tmux.md" \
79
+ "tmux command"
80
+
81
+ create_symlink \
82
+ "${SCRIPT_DIR}/src/commands/tmux-oc.md" \
83
+ "${OPENCODE_CONFIG}/commands/tmux-oc.md" \
84
+ "tmux-oc command"
85
+
86
+ create_symlink \
87
+ "${SCRIPT_DIR}/src/commands/tmux-claude.md" \
88
+ "${OPENCODE_CONFIG}/commands/tmux-claude.md" \
89
+ "tmux-claude command"
90
+
91
+ create_symlink \
92
+ "${SCRIPT_DIR}/src/commands/tmux-copilot.md" \
93
+ "${OPENCODE_CONFIG}/commands/tmux-copilot.md" \
94
+ "tmux-copilot command"
95
+
96
+ create_symlink \
97
+ "${SCRIPT_DIR}/src/commands/tt-configure.md" \
98
+ "${OPENCODE_CONFIG}/commands/tt-configure.md" \
99
+ "tt-configure command"
100
+
101
+ # Install configuration script
102
+ echo -e "\n${YELLOW}Installing configuration script...${NC}"
103
+ create_symlink \
104
+ "${SCRIPT_DIR}/src/scripts/opencode-tt-config.sh" \
105
+ "${OPENCODE_CONFIG}/commands/tt-configure-script.sh" \
106
+ "configuration helper script"
107
+
108
+ # Register plugin in opencode.json
109
+ echo -e "\n${YELLOW}Registering plugin in opencode.json...${NC}"
110
+ node "${SCRIPT_DIR}/scripts/register-plugin.js"
111
+
112
+ # Verification
113
+ echo -e "\n${YELLOW}Verifying installation...${NC}"
114
+
115
+ errors=0
116
+
117
+ # Check commands
118
+ for cmd in tmux tmux-oc tmux-claude tmux-copilot tt-configure; do
119
+ if [ -L "${OPENCODE_CONFIG}/commands/${cmd}.md" ] && [ -f "${OPENCODE_CONFIG}/commands/${cmd}.md" ]; then
120
+ echo -e "${GREEN}✓ Command ${cmd} symlink verified${NC}"
121
+ else
122
+ echo -e "${RED}✗ Command ${cmd} symlink failed${NC}"
123
+ ((errors++))
124
+ fi
125
+ done
126
+
127
+ # Check syntax of bash scripts
128
+ echo -e "\n${YELLOW}Checking script syntax...${NC}"
129
+ for script in opencode-tmux.sh opencode-tmux-oc.sh opencode-tmux-claude.sh opencode-tmux-copilot.sh opencode-tt-config.sh; do
130
+ if bash -n "${SCRIPT_DIR}/src/scripts/${script}" 2>/dev/null; then
131
+ echo -e "${GREEN}✓ Shell script ${script} syntax valid${NC}"
132
+ else
133
+ echo -e "${RED}✗ Shell script ${script} syntax error${NC}"
134
+ ((errors++))
135
+ fi
136
+ done
137
+
138
+ # Summary
139
+ echo -e "\n${BLUE}=== Installation Summary ===${NC}"
140
+ echo -e "Commands: ${OPENCODE_CONFIG}/commands/"
141
+ echo -e "Plugin: ${SCRIPT_DIR} (registered in opencode.json)"
142
+
143
+ if [ $errors -eq 0 ]; then
144
+ echo -e "\n${GREEN}✓ Installation successful!${NC}"
145
+ echo -e "\n${YELLOW}Available commands:${NC}"
146
+ echo -e " ${GREEN}/tmux${NC} - Simple tmux session (maximized)"
147
+ echo -e " ${GREEN}/tmux-oc${NC} - Tmux with OpenCode in split"
148
+ echo -e " ${GREEN}/tmux-claude${NC} - Tmux with Claude in split"
149
+ echo -e " ${GREEN}/tmux-copilot${NC} - Tmux with GitHub Copilot in split"
150
+ echo -e " ${GREEN}/tt-configure${NC} - Configure plugin settings"
151
+ echo -e "\n${YELLOW}The plugin is now loaded via opencode.json plugin array${NC}"
152
+ echo -e "${YELLOW}To uninstall, run:${NC} ./uninstall.sh"
153
+ exit 0
154
+ else
155
+ echo -e "\n${RED}✗ Installation failed with $errors error(s)${NC}"
156
+ exit 1
157
+ fi
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@grympler/opencode-tmux-handover",
3
+ "version": "1.0.0",
4
+ "description": "OpenCode Desktop plugin for launching tmux with AI assistants (OpenCode, Claude, Copilot) in split panes",
5
+ "main": "src/index.ts",
6
+ "type": "module",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "scripts": {
11
+ "install": "bash install.sh",
12
+ "uninstall": "bash uninstall.sh",
13
+ "test": "echo 'See TESTING.md for comprehensive test procedures'"
14
+ },
15
+ "keywords": [
16
+ "opencode",
17
+ "plugin",
18
+ "tmux",
19
+ "terminal",
20
+ "split-window",
21
+ "command",
22
+ "claude",
23
+ "copilot"
24
+ ],
25
+ "author": "Olivier <olivier@example.com>",
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/grympler/opencode-tmux-handover"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/grympler/opencode-tmux-handover/issues"
33
+ },
34
+ "engines": {
35
+ "opencode": ">=dev",
36
+ "tmux": ">=3.0",
37
+ "bash": ">=4.0"
38
+ },
39
+ "files": [
40
+ "src/",
41
+ "scripts/",
42
+ "install.sh",
43
+ "uninstall.sh",
44
+ "README.md",
45
+ "DISTRIBUTION_AND_CONFIG.md",
46
+ "IMPLEMENTATION_GUIDE.md",
47
+ "QUICK_REFERENCE.md",
48
+ "package.json"
49
+ ]
50
+ }
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readFileSync, writeFileSync } from "fs"
4
+ import { dirname, resolve } from "path"
5
+ import { fileURLToPath } from "url"
6
+ import { homedir } from "os"
7
+
8
+ const __filename = fileURLToPath(import.meta.url)
9
+ const __dirname = dirname(__filename)
10
+
11
+ const OPENCODE_CONFIG_PATH = resolve(homedir(), ".config/opencode/opencode.json")
12
+ const PLUGIN_DIR = resolve(__dirname, "..")
13
+
14
+ function registerPlugin() {
15
+ try {
16
+ let config = { plugin: [] }
17
+
18
+ try {
19
+ const content = readFileSync(OPENCODE_CONFIG_PATH, "utf-8")
20
+ config = JSON.parse(content)
21
+ } catch (err) {
22
+ console.log("Creating new opencode.json...")
23
+ }
24
+
25
+ if (!Array.isArray(config.plugin)) {
26
+ config.plugin = []
27
+ }
28
+
29
+ if (config.plugin.includes(PLUGIN_DIR)) {
30
+ console.log("Plugin already registered in opencode.json")
31
+ return
32
+ }
33
+
34
+ config.plugin.push(PLUGIN_DIR)
35
+
36
+ writeFileSync(OPENCODE_CONFIG_PATH, JSON.stringify(config, null, 2) + "\n")
37
+ console.log(`✓ Plugin registered: ${PLUGIN_DIR}`)
38
+ console.log(`✓ Updated: ${OPENCODE_CONFIG_PATH}`)
39
+ } catch (err) {
40
+ console.error("Error registering plugin:", err)
41
+ process.exit(1)
42
+ }
43
+ }
44
+
45
+ registerPlugin()