### Runtime Test Setup Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md Steps to start tmux and the OpenCode server for runtime testing. ```bash # Start tmux tmux # Start OpenCode with port flag opencode --port 4096 # Give this test prompt: # "Search the codebase for all SwiftUI views and analyze the architecture. Work in parallel." ``` -------------------------------- ### Installation and Build Test Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md Commands to install dependencies, build the project, and install the plugin for testing. ```bash cd ~/Code/opencode-subagent-tmux bun install bun run build bun run install:plugin ``` -------------------------------- ### Build and Run Development Setup Script Source: https://github.com/angansamadder/opentmux/blob/main/docs/LOCAL_DEVELOPMENT.md Build the project and execute the development setup script to prepare the local environment. ```bash bun run build ./scripts/dev-setup.sh ``` -------------------------------- ### Installation and Setup Script Source: https://github.com/angansamadder/opentmux/blob/main/PLAN.md Shell script for installing the OpenCode agent tmux plugin. It includes steps for cloning the repository, installing dependencies, building the plugin, and installing it into OpenCode. ```bash # 1. Clone/Navigate to plugin directory cd ~/Code/opencode-agent-tmux # 2. Install dependencies bun install # 3. Build the plugin bun run build # 4. Install to OpenCode bun run install:plugin # 5. Start OpenCode with tmux support tmux opencode --port 4096 ``` -------------------------------- ### Local Development Quick Start Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Commands to set up the development environment, reload the shell, and start the development server in watch mode. ```bash ./scripts/dev-setup.sh # Initial setup source ~/.zshrc # Reload shell bun run dev # Watch mode opencode # Test in separate terminal ``` -------------------------------- ### Automatic Installation of opentmux Source: https://github.com/angansamadder/opentmux/blob/main/docs/installation.md Use this one-liner command for a quick and recommended installation. It clones the repository, installs dependencies, and builds the plugin. ```bash git clone https://github.com/AnganSamadder/opentmux.git ~/Code/opentmux && \ cd ~/Code/opentmux && \ bun install && \ bun run build ``` -------------------------------- ### Install Dependencies (Manual) Source: https://github.com/angansamadder/opentmux/blob/main/docs/installation.md Installs project dependencies using Bun. This step also automatically sets up the shell alias and wrapper script. ```bash bun install ``` -------------------------------- ### User Configuration Example Source: https://github.com/angansamadder/opentmux/blob/main/PLAN.md An example of how to configure the opencode-agent-tmux plugin in the user's OpenCode configuration directory. This allows customization of plugin behavior. ```json { "enabled": true, "port": 4096, "layout": "main-vertical", "paneTitle": "🤖 {agentType}", "autoClose": true } ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/angansamadder/opentmux/blob/main/docs/LOCAL_DEVELOPMENT.md Clone the opentmux repository and install its dependencies using bun. ```bash git clone https://github.com/AnganSamadder/opentmux.git cd opentmux bun install ``` -------------------------------- ### Test Postinstall Script Manually Source: https://github.com/angansamadder/opentmux/blob/main/docs/LOCAL_DEVELOPMENT.md Execute the install script directly from the dist directory to test its functionality. ```bash node dist/scripts/install.js ``` -------------------------------- ### Development Build Command Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md Commands for setting up the project, running in watch mode for development, building, and installing the plugin. ```bash # Setup cd ~/Code/opencode-subagent-tmux bun install # Development bun run dev # Watch mode # Build bun run build # Install to OpenCode bun run install:plugin # Test tmux opencode --port 4096 # Then spawn subagents and verify panes appear ``` -------------------------------- ### Build the Plugin (Manual) Source: https://github.com/angansamadder/opentmux/blob/main/docs/installation.md Builds the opentmux plugin after dependencies have been installed. ```bash bun run build ``` -------------------------------- ### OpenCode Tmux Plugin Installation Script Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md This JavaScript script automates the installation of the OpenCode Tmux Subagent plugin. It builds the TypeScript code, creates a default configuration file if one doesn't exist, and registers the plugin with the main OpenCode configuration. It also provides instructions on how to use the plugin after installation. ```javascript #!/usr/bin/env node import { execSync } from 'child_process'; import fs from 'fs'; import path from 'path'; import os from 'os'; const configDir = path.join(os.homedir(), '.config', 'opencode'); const pluginConfigPath = path.join(configDir, 'opencode-subagent-tmux.json'); const openCodeConfigPath = path.join(configDir, 'opencode.json'); // 1. Build the plugin console.log('Building plugin...'); execSync('bun run build', { stdio: 'inherit' }); // 2. Create plugin config if it doesn't exist if (!fs.existsSync(pluginConfigPath)) { console.log('Creating plugin configuration...'); const defaultConfig = JSON.parse( fs.readFileSync('config/default.json', 'utf-8') ); fs.writeFileSync(pluginConfigPath, JSON.stringify(defaultConfig, null, 2)); } // 3. Add to OpenCode plugins list console.log('Registering plugin with OpenCode...'); const openCodeConfig = JSON.parse(fs.readFileSync(openCodeConfigPath, 'utf-8')); if (!openCodeConfig.plugins) { openCodeConfig.plugins = []; } const pluginPath = path.resolve('./dist/index.js'); if (!openCodeConfig.plugins.includes(pluginPath)) { openCodeConfig.plugins.push(pluginPath); fs.writeFileSync(openCodeConfigPath, JSON.stringify(openCodeConfig, null, 2)); console.log('Plugin registered successfully!'); } else { console.log('Plugin already registered.'); } console.log(' Installation complete!'); console.log(' To use the plugin:'); console.log('1. Start tmux: tmux'); console.log('2. Start OpenCode with port flag: opencode --port 4096'); console.log('3. Spawn subagents and watch them appear in new panes!'); ``` -------------------------------- ### Running Multiple OpenCode Instances Source: https://github.com/angansamadder/opentmux/blob/main/MULTI_PORT.md Demonstrates how to start multiple OpenCode instances in separate terminals. The wrapper script automatically finds the next available port if the default (4096) is occupied. ```bash # Terminal 1 opencode # → Starts on port 4096 # Terminal 2 (new window) opencode # → Detects 4096 in use, starts on port 4097 # → Shows: "⚠️ Port 4096 is in use, using port 4097 instead" # Terminal 3 opencode # → Starts on port 4098 ``` -------------------------------- ### Run Development in Watch Mode Source: https://github.com/angansamadder/opentmux/blob/main/docs/LOCAL_DEVELOPMENT.md Start the development server in watch mode using bun to automatically rebuild on file changes. ```bash bun run dev ``` -------------------------------- ### Install OpenTmux Plugin via NPM Source: https://github.com/angansamadder/opentmux/blob/main/README.md Install the opentmux NPM package globally. This command also configures your shell to use the smart wrapper. ```bash npm install -g opentmux ``` -------------------------------- ### Recreate Symlink Source: https://github.com/angansamadder/opentmux/blob/main/docs/LOCAL_DEVELOPMENT.md Recreate the symlink for the opentmux binary by running the development setup script. ```bash ./scripts/dev-setup.sh ``` -------------------------------- ### Run Integration Tests Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Execute integration test scripts for plugin and multi-port support. Includes setup for local development and running the opencode command. ```bash # Integration test scripts ./scripts/test-plugin.sh # Test plugin integration ./scripts/test-multiport.sh # Test multi-port support # Manual test after local build ./scripts/dev-setup.sh # Sets up local development source ~/.zshrc # Reload shell config opencode # Run to test integration ``` -------------------------------- ### Clone opentmux Repository (Manual) Source: https://github.com/angansamadder/opentmux/blob/main/docs/installation.md Part of the manual installation process. Clones the opentmux repository into the ~/Code directory. ```bash mkdir -p ~/Code cd ~/Code git clone https://github.com/AnganSamadder/opentmux.git cd opentmux ``` -------------------------------- ### Verify Tmux Installation Source: https://github.com/angansamadder/opentmux/blob/main/README.md Check if tmux is installed on your system. This is a prerequisite for OpenTmux functionality. ```bash which tmux ``` -------------------------------- ### Configuring OpenCode Port Range Source: https://github.com/angansamadder/opentmux/blob/main/MULTI_PORT.md Changes the starting port for the automatic port detection range by setting the OPENCODE_PORT_START environment variable. The system will then attempt to use ports starting from the specified value up to 10 subsequent ports. ```bash OPENCODE_PORT=5000 opencode # Will try ports 5000-5010 ``` -------------------------------- ### Manually Setting OpenCode Port Source: https://github.com/angansamadder/opentmux/blob/main/MULTI_PORT.md Forces OpenCode to start on a specific port by setting the OPENCODE_PORT environment variable before execution. ```bash OPENCODE_PORT=5000 opencode ``` -------------------------------- ### Reload Shell Configuration Source: https://github.com/angansamadder/opentmux/blob/main/docs/installation.md After automatic installation, reload your shell configuration to apply changes. Use the appropriate command for your shell. ```bash source ~/.zshrc # or ~/.bashrc ``` -------------------------------- ### Conventional Commits for Version Bumping Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Examples of using conventional commit messages for Git. These messages help automate version bumping and changelog generation. ```bash git commit -m "feat: add new feature" # Minor version bump git commit -m "fix: resolve bug" # Patch version bump git commit -m "feat!: breaking change" # Major version bump ``` -------------------------------- ### Initialize Git Repository and Project Structure Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md Sets up the project directory, initializes a git repository, and creates the basic file structure for the plugin. ```bash mkdir -p ~/Code/opencode-subagent-tmux cd ~/Code/opencode-subagent-tmux git init echo "# OpenCode Subagent Tmux Plugin" > README.md git add README.md git commit -m "Initial commit" mkdir -p src/utils mkdir -p config mkdir -p scripts ``` -------------------------------- ### Run Multiple OpenCode Instances Source: https://github.com/angansamadder/opentmux/blob/main/SETUP_COMPLETE.md Demonstrates how to run multiple independent OpenCode sessions simultaneously. Each instance will auto-detect and use an available port, creating its own set of tmux panes. ```bash # Terminal 1 opencode # → Port 4096 # Terminal 2 opencode # → Port 4097 (auto-detected!) # Terminal 3 opencode # → Port 4098 ``` -------------------------------- ### Test Launching opencode with tmux Source: https://github.com/angansamadder/opentmux/blob/main/docs/LOCAL_DEVELOPMENT.md Launch the opencode command, which should integrate with tmux. ```bash opencode ``` -------------------------------- ### Build Project with Bun Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Commands to build the TypeScript project to the dist/ directory using Bun. Includes a watch mode for development and a type-checking-only option. ```bash # Full build (compile TypeScript to dist/) bun run build # Watch mode for development bun run dev # Type checking only (no emit) bun run typecheck ``` -------------------------------- ### Test opentmux Binary Help Source: https://github.com/angansamadder/opentmux/blob/main/docs/LOCAL_DEVELOPMENT.md Verify the opentmux binary by testing its help command. ```bash opentmux --help ``` -------------------------------- ### Launch OpenCode with Custom Port Source: https://github.com/angansamadder/opentmux/blob/main/TMUX_LAUNCHER.md Set a custom port for OpenCode by prefixing the opencode command with the OPENCODE_PORT environment variable. Alternatively, export the variable in your ~/.zshrc for persistent configuration. ```bash OPENCODE_PORT=8080 opencode ``` ```bash export OPENCODE_PORT=4096 ``` -------------------------------- ### Creating a GitHub Release Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Command to create a GitHub release using the GitHub CLI. This is an optional step for documentation purposes. ```bash gh release create vX.Y.Z --title "vX.Y.Z" --notes "Release notes..." ``` -------------------------------- ### Verify OpenCode Alias Source: https://github.com/angansamadder/opentmux/blob/main/SETUP_COMPLETE.md Check if the 'opencode' alias is correctly set up and points to the plugin's wrapper script. ```bash # 1. Verify alias which opencode # Should show: /Users/angansamadder/Code/opencode-agent-tmux/bin/opentmux ``` -------------------------------- ### Port Checking Methods Source: https://github.com/angansamadder/opentmux/blob/main/MULTI_PORT.md Lists the methods used by the OpenCode wrapper script to check port availability, ordered by preference. ```text 1. lsof -i :PORT (most reliable) 2. nc -z localhost PORT (fallback) 3. curl http://localhost:PORT/health (last resort) ``` -------------------------------- ### Activate Shell Alias Source: https://github.com/angansamadder/opentmux/blob/main/SETUP_COMPLETE.md Source your shell configuration file to activate the newly added shell alias for launching OpenCode. ```bash source ~/.zshrc ``` -------------------------------- ### Git Tagging and Pushing for Releases Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Steps to update the package.json version, commit the change, tag the release, and push to the main branch and tags. ```bash git add package.json git commit -m "Bump version to X.Y.Z" git tag vX.Y.Z git push origin main --tags ``` -------------------------------- ### Initialize OpenCode Subagent Tmux Plugin Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md Entry point for the OpenCode plugin, responsible for loading configuration, initializing the TmuxSessionManager, and registering cleanup handlers. ```typescript export async function init(context: PluginContext) { const config = await loadConfig(); if (!config.enabled) { console.log('opencode-subagent-tmux: disabled in config'); return; } if (!isInsideTmux()) { console.log('opencode-subagent-tmux: not running inside tmux, skipping'); return; } const manager = new TmuxSessionManager(config, context); await manager.start(); console.log('opencode-subagent-tmux: initialized'); } ``` -------------------------------- ### OpenTmux Configuration Options Source: https://github.com/angansamadder/opentmux/blob/main/README.md Customize OpenTmux behavior by creating a JSON configuration file. Options include enabling/disabling the plugin, setting the server port, defining tmux layout, main pane size, and auto-close behavior. ```json { "enabled": true, "port": 4096, "layout": "main-vertical", "main_pane_size": 60, "auto_close": true } ``` -------------------------------- ### Test OpenCode Agent Plugin Source: https://github.com/angansamadder/opentmux/blob/main/SETUP_COMPLETE.md Provide this prompt to OpenCode to test the opencode-agent-tmux plugin by launching three agents in parallel. ```text I need you to help me test the opencode-agent-tmux plugin. Please launch 3 agents in parallel using the call_omo_agent tool with run_in_background=true: 1. Explorer Agent: Search the current directory for all TypeScript files 2. Explorer Agent: Find all configuration files (JSON, YAML) 3. Librarian Agent: Search GitHub for OpenCode plugin examples Launch these in parallel and report the task IDs. ``` -------------------------------- ### Check Plugin Logs Source: https://github.com/angansamadder/opentmux/blob/main/SETUP_COMPLETE.md Follow the log file for the OpenCode Agent Tmux Plugin to diagnose issues and monitor activity. ```bash # 2. Check logs tail -f /tmp/opencode-agent-tmux.log ``` -------------------------------- ### Good Async/Await Patterns in TypeScript Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Demonstrates correct usage of async/await for concurrent and sequential operations. Avoid unnecessary awaits when a promise can be returned directly. ```typescript // ✅ Good - proper async/await async function closePanes(panes: string[]): Promise { await Promise.all(panes.map(pane => closePane(pane))); } // ✅ Good - sequential when order matters async function setup(): Promise { await initializeConfig(); await startTmuxManager(); } // ❌ Bad - unnecessary await in return async function getData(): Promise { return await fetchData(); // Just use: return fetchData(); } ``` -------------------------------- ### Test Multi-Port Functionality Source: https://github.com/angansamadder/opentmux/blob/main/SETUP_COMPLETE.md Execute a script to test the multi-port detection and handling capabilities of the OpenCode Agent Tmux Plugin. ```bash # 3. Test multi-port ./test-multiport.sh ``` -------------------------------- ### Perform Type Checking Source: https://github.com/angansamadder/opentmux/blob/main/docs/LOCAL_DEVELOPMENT.md Run the type checking process for the project using the bun run typecheck command. ```bash bun run typecheck ``` -------------------------------- ### Reinstall Globally Source: https://github.com/angansamadder/opentmux/blob/main/docs/LOCAL_DEVELOPMENT.md Reinstall opentmux globally to trigger the postinstall script and set up aliases. ```bash npm install -g opentmux@latest ``` -------------------------------- ### Check OpenTmux Log Source: https://github.com/angansamadder/opentmux/blob/main/README.md Access the OpenTmux log file to troubleshoot issues with pane spawning. ```bash cat /tmp/opentmux.log ``` -------------------------------- ### Package JSON Configuration for Tmux Plugin Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md Defines the project's metadata, build scripts, and dependencies for the OpenCode subagent tmux plugin. ```json { "name": "opencode-subagent-tmux", "version": "1.0.0", "description": "Tmux integration for OpenCode subagents - view subagent execution in real-time tmux panes", "main": "dist/index.js", "type": "module", "scripts": { "build": "tsup src/index.ts --format esm --dts", "dev": "tsup src/index.ts --format esm --dts --watch", "install:plugin": "node scripts/install.js" }, "keywords": ["opencode", "plugin", "tmux", "subagent"], "author": "", "license": "MIT", "devDependencies": { "@types/node": "^20.0.0", "tsup": "^8.0.0", "typescript": "^5.0.0" }, "dependencies": {} } ``` -------------------------------- ### Handle Tmux Session Creation Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md This TypeScript function handles the creation of new tmux sessions for subagents. It verifies that the environment is within tmux, the OpenCode server is reachable, and then spawns a new tmux pane for the subagent session. It also initiates monitoring for the session to close the pane when the session ends. ```typescript async handleSessionCreated(session: Session) { // Only handle child sessions (subagents) if (!session.parentID) { return; } // Check if tmux pane can be spawned if (!isInsideTmux()) { return; } // Verify OpenCode server is reachable const serverUrl = `http://localhost:${this.config.port}`; const isHealthy = await checkServerHealth(serverUrl); if (!isHealthy) { console.error('OpenCode server not reachable'); return; } // Spawn tmux pane const title = `${session.agentType || 'subagent'}`; const paneId = await spawnTmuxPane( session.id, title, this.config, serverUrl ); if (paneId) { // Monitor session and close pane when done this.monitorSession(session.id, paneId); } } ``` -------------------------------- ### TypeScript Import Statement Order Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Demonstrates the correct order and grouping for import statements in TypeScript, including type-only imports, Node.js built-ins, external dependencies, and relative imports. ```typescript // ✅ Good import type { Plugin } from './types'; import * as fs from 'node:fs'; import * as path from 'node:path'; import { z } from 'zod'; import { TmuxSessionManager } from './tmux-session-manager'; import { log, startTmuxCheck } from './utils'; // ❌ Bad - missing node: prefix, wrong order import { z } from 'zod'; import * as fs from 'fs'; import { log } from './utils'; import type { Plugin } from './types'; ``` -------------------------------- ### Default OpenCode Tmux Plugin Configuration Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md This JSON object defines the default configuration settings for the OpenCode Tmux Subagent plugin. It includes parameters for enabling the plugin, the port for the OpenCode server, tmux layout and pane options, and auto-close behavior. ```json { "enabled": true, "port": 4096, "layout": "main-vertical", "paneOptions": "-h -d", "autoClose": true, "debug": false } ``` -------------------------------- ### Add OpenCode Tmux Launcher to PATH Source: https://github.com/angansamadder/opentmux/blob/main/TMUX_LAUNCHER.md Configure your PATH to include the directory containing the OpenCode Tmux launcher script and rename the script to 'opencode'. This method overrides the default opencode command. ```bash # Add to ~/.zshrc export PATH="/Users/angansamadder/Code/opencode-agent-tmux/bin:$PATH" # Rename the wrapper to 'opencode' (this overrides the real opencode command) mv /Users/angansamadder/Code/opencode-agent-tmux/bin/opentmux \ /Users/angansamadder/Code/opencode-agent-tmux/bin/opencode ``` -------------------------------- ### Configure OpenCode to Use OpenTmux Plugin Source: https://github.com/angansamadder/opentmux/blob/main/README.md Add 'opentmux' to the plugin array in your OpenCode configuration file to enable the plugin. ```json { "plugin": [ "opentmux" ] } ``` -------------------------------- ### Default Configuration Schema Source: https://github.com/angansamadder/opentmux/blob/main/PLAN.md Defines the default configuration structure for the tmux plugin. This JSON schema specifies the available settings and their types. ```json { "enabled": true, "port": 4096, "layout": "main-vertical", "paneOptions": "-h -d" } ``` -------------------------------- ### Spawn Tmux Pane Utility Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md This TypeScript function spawns a new tmux pane for an OpenCode session. It first checks if the execution is within a tmux environment. If so, it constructs and executes a tmux command to split the window and attach the OpenCode session to the new pane, returning the pane ID. It also handles applying a layout if specified in the configuration. ```typescript export async function spawnTmuxPane( sessionId: string, title: string, config: Config, serverUrl: string ): Promise { if (!isInsideTmux()) { return null; } try { const command = `opencode attach ${serverUrl} --session ${sessionId}`; const { stdout } = await execAsync( `tmux split-window ${config.paneOptions} -P -F '#{pane_id}' "${command}" ``` ```typescript ); const paneId = stdout.trim(); // Apply layout if (config.layout) { await execAsync(`tmux select-layout ${config.layout}`); } return paneId; } catch (error) { console.error('Failed to spawn tmux pane:', error); return null; } } ``` -------------------------------- ### Check Port Usage Source: https://github.com/angansamadder/opentmux/blob/main/SETUP_COMPLETE.md Use 'lsof' to check if a specific port is currently in use, which can be helpful when troubleshooting port conflicts. ```bash # Port already in use? # Check with lsof -i :4096 ``` -------------------------------- ### Verify opentmux Binary Location Source: https://github.com/angansamadder/opentmux/blob/main/docs/LOCAL_DEVELOPMENT.md Check the current location of the opentmux binary to ensure it points to the local development version. ```bash which opentmux ``` -------------------------------- ### TypeScript Configuration for Tmux Plugin Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md Configures the TypeScript compiler for the project, specifying module resolution, target, and output settings. ```json { "compilerOptions": { "target": "ES2022", "module": "ESNext", "lib": ["ES2022"], "moduleResolution": "node", "esModuleInterop": true, "strict": true, "skipLibCheck": true, "declaration": true, "outDir": "./dist", "rootDir": "./src" }, "include": ["src/**/*"], "exclude": ["node_modules", "dist"] } ``` -------------------------------- ### Check Symlink Existence Source: https://github.com/angansamadder/opentmux/blob/main/docs/LOCAL_DEVELOPMENT.md Verify if the opentmux symlink exists in the npm global bin directory. ```bash ls -la $(npm config get prefix)/bin/opentmux ``` -------------------------------- ### Shell Alias Configuration Source: https://github.com/angansamadder/opentmux/blob/main/SETUP_COMPLETE.md Configuration for the shell alias 'opencode' in ~/.zshrc, which points to the wrapper script and sets the default OpenCode port. ```bash # >>> opencode-agent-tmux >>> export OPENCODE_PORT=4096 alias opencode='/Users/angansamadder/Code/opencode-agent-tmux/bin/opentmux' # <<< opencode-agent-tmux <<< ``` -------------------------------- ### Git Ignore File for Tmux Plugin Source: https://github.com/angansamadder/opentmux/blob/main/SISYPHUS-PROMPT.md Specifies files and directories that should be ignored by Git, such as build outputs and dependencies. ```gitignore node_modules/ dist/ *.log .DS_Store ``` -------------------------------- ### Register opentmux Plugin in OpenCode Config Source: https://github.com/angansamadder/opentmux/blob/main/docs/installation.md Add the path to the opentmux plugin in your OpenCode configuration file to register it. ```json { "plugin": [ "/Users/YOUR_USERNAME/Code/opentmux" ] } ``` -------------------------------- ### TypeScript Type Exports Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Demonstrates exporting both values and types in TypeScript, including re-exporting types from other modules for centralized access. ```typescript // ✅ Good - export both value and type export const TmuxLayoutSchema = z.enum(['main-horizontal', 'main-vertical']); export type TmuxLayout = z.infer; // ✅ Good - re-export types from index export type { PluginConfig, TmuxConfig, TmuxLayout } from './config'; ``` -------------------------------- ### Zod for Runtime Configuration Validation Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Utilizes Zod schemas to define and validate configuration objects at runtime, ensuring data integrity. Includes schema definition and safe parsing. ```typescript // ✅ Good - use Zod schemas for config validation export const PluginConfigSchema = z.object({ enabled: z.boolean().default(true), port: z.number().default(4096), }); export type PluginConfig = z.infer; // Parse and validate const result = PluginConfigSchema.safeParse(parsed); if (result.success) { return result.data; } ``` -------------------------------- ### Async Error Handling with Try-Catch Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Implements robust error handling for asynchronous operations using try-catch blocks, logging errors with context, and providing graceful degradation. ```typescript // ✅ Good - try/catch with proper logging try { const content = fs.readFileSync(configPath, 'utf-8'); const parsed = JSON.parse(content); return PluginConfigSchema.parse(parsed); } catch (err) { log('[plugin] config load error', { configPath, error: String(err) }); return defaultConfig; } // ✅ Good - graceful degradation const sessions = await fetchSessions().catch(() => []); ``` -------------------------------- ### Shell Alias for OpenCode Tmux Launcher Source: https://github.com/angansamadder/opentmux/blob/main/TMUX_LAUNCHER.md Add this alias to your ~/.zshrc for easy access to the OpenCode Tmux launcher. Reload your shell after adding. ```bash # OpenCode with automatic tmux launching alias opencode='/Users/angansamadder/Code/opencode-agent-tmux/bin/opentmux' ``` -------------------------------- ### TypeScript Strict Typing Source: https://github.com/angansamadder/opentmux/blob/main/AGENTS.md Enforces strict typing in TypeScript functions by explicitly defining parameter and return types, avoiding implicit 'any'. ```typescript // ✅ Good - explicit types function loadConfig(directory: string): PluginConfig { const configPaths: string[] = [ path.join(directory, 'opencode-agent-tmux.json'), ]; // ... } // ❌ Bad - implicit any function loadConfig(directory) { const configPaths = [...]; // ... } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.