-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·244 lines (210 loc) · 7.33 KB
/
install.sh
File metadata and controls
executable file
·244 lines (210 loc) · 7.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/bash
# OpenCode Orchestrator Plugin Installation Script
# This script installs the orchestrator plugin globally or per-project
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Print colored output
print_info() {
echo -e "${BLUE}ℹ${NC} $1"
}
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
print_error() {
echo -e "${RED}✗${NC} $1"
}
# Check if running in a git repository
is_git_repo() {
git rev-parse --git-dir > /dev/null 2>&1
}
# Main installation function
install() {
echo ""
echo "╔════════════════════════════════════════════════════════╗"
echo "║ OpenCode Orchestrator Plugin Installer ║"
echo "╚════════════════════════════════════════════════════════╝"
echo ""
# Ask for installation type
echo "Select installation type:"
echo " 1) Global installation (all OpenCode projects)"
echo " 2) Project installation (current directory only)"
echo ""
read -p "Enter choice [1-2]: " choice
case $choice in
1)
install_global
;;
2)
install_project
;;
*)
print_error "Invalid choice. Exiting."
exit 1
;;
esac
# Ask about configuration
echo ""
echo "Select configuration template:"
echo " 1) Generic example (default models)"
echo " 2) User-optimized (GPT-5 Codex + Claude + GLM)"
echo " 3) Skip configuration (I'll create my own)"
echo ""
read -p "Enter choice [1-3]: " config_choice
case $config_choice in
1)
install_config "orchestrator.config.example.md" "$INSTALL_PATH"
;;
2)
install_config "orchestrator.config.user-example.md" "$INSTALL_PATH"
;;
3)
print_info "Skipping configuration. You can create your own later."
;;
*)
print_warning "Invalid choice. Skipping configuration."
;;
esac
# Install dependencies
echo ""
print_info "Installing dependencies..."
if command -v bun &> /dev/null; then
print_info "Using Bun..."
bun add yaml
elif command -v npm &> /dev/null; then
print_info "Using npm..."
npm install yaml
else
print_error "Neither bun nor npm found. Please install dependencies manually:"
echo " npm install yaml"
echo " # or"
echo " bun add yaml"
fi
print_success "Dependencies installed!"
# Final instructions
echo ""
echo "╔════════════════════════════════════════════════════════╗"
echo "║ Installation Complete! ║"
echo "╚════════════════════════════════════════════════════════╝"
echo ""
print_success "Plugin and agents installed successfully!"
echo ""
print_info "Next steps:"
echo " 1. Review and customize your configuration:"
echo " ${INSTALL_PATH}/orchestrator.config.md"
echo ""
echo " 2. Restart OpenCode or start a new session"
echo ""
echo " 3. IMPORTANT: Switch to an orchestrator agent!"
echo " - Press Tab to cycle through agents"
echo " - Select: auto-optimized (cost-efficient)"
echo " - Or: auto-performance (quality-focused)"
echo ""
echo " 4. The orchestrator will automatically analyze and select models"
echo ""
print_info "The orchestrator ONLY runs with specific agents (auto-optimized, auto-performance)"
print_info "This prevents interference with other plugins and workflows"
echo ""
print_info "For more information, see README.md and AGENT-SETUP.md"
echo ""
}
# Install globally
install_global() {
INSTALL_PATH="$HOME/.config/opencode"
PLUGIN_PATH="$INSTALL_PATH/plugin"
AGENT_PATH="$INSTALL_PATH/agent"
print_info "Installing globally to: $INSTALL_PATH"
# Create directories
mkdir -p "$PLUGIN_PATH"
mkdir -p "$AGENT_PATH"
print_success "Created plugin and agent directories"
# Copy plugin file
if [ -f "orchestrator.plugin.ts" ]; then
cp orchestrator.plugin.ts "$PLUGIN_PATH/"
print_success "Copied plugin file"
else
print_error "orchestrator.plugin.ts not found in current directory"
exit 1
fi
# Copy agent files (IMPORTANT)
if [ -d "agents" ]; then
cp agents/*.md "$AGENT_PATH/" 2>/dev/null
print_success "Copied agent files (auto-optimized, auto-performance)"
else
print_warning "agents/ directory not found, skipping agent installation"
fi
# Copy types if they exist
if [ -f "types.d.ts" ]; then
cp types.d.ts "$PLUGIN_PATH/"
print_success "Copied type definitions"
fi
}
# Install per-project
install_project() {
if ! is_git_repo; then
print_warning "Not in a git repository. Are you sure you want to continue?"
read -p "Continue? [y/N]: " confirm
if [[ ! $confirm =~ ^[Yy]$ ]]; then
print_info "Installation cancelled."
exit 0
fi
fi
INSTALL_PATH=".opencode"
PLUGIN_PATH="$INSTALL_PATH/plugin"
AGENT_PATH="$INSTALL_PATH/agent"
print_info "Installing to project: $PWD/$INSTALL_PATH"
# Create directories
mkdir -p "$PLUGIN_PATH"
mkdir -p "$AGENT_PATH"
print_success "Created plugin and agent directories"
# Copy plugin file
if [ -f "orchestrator.plugin.ts" ]; then
cp orchestrator.plugin.ts "$PLUGIN_PATH/"
print_success "Copied plugin file"
else
print_error "orchestrator.plugin.ts not found in current directory"
exit 1
fi
# Copy agent files (IMPORTANT)
if [ -d "agents" ]; then
cp agents/*.md "$AGENT_PATH/" 2>/dev/null
print_success "Copied agent files (auto-optimized, auto-performance)"
else
print_warning "agents/ directory not found, skipping agent installation"
fi
# Copy types if they exist
if [ -f "types.d.ts" ]; then
cp types.d.ts "$PLUGIN_PATH/"
print_success "Copied type definitions"
fi
}
# Install configuration
install_config() {
local config_file=$1
local install_path=$2
if [ -f "$config_file" ]; then
# Check if config already exists
if [ -f "$install_path/orchestrator.config.md" ]; then
print_warning "Configuration file already exists."
read -p "Overwrite? [y/N]: " overwrite
if [[ ! $overwrite =~ ^[Yy]$ ]]; then
print_info "Keeping existing configuration."
return
fi
fi
cp "$config_file" "$install_path/orchestrator.config.md"
print_success "Installed configuration: $config_file"
print_info "Please review and customize the configuration file!"
else
print_error "Configuration file not found: $config_file"
fi
}
# Run installation
install