-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·88 lines (74 loc) · 2.56 KB
/
install.sh
File metadata and controls
executable file
·88 lines (74 loc) · 2.56 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
#!/usr/bin/env bash
set -euo pipefail
TAG_FLAG=""
while [[ $# -gt 0 ]]; do
case $1 in
--tag) TAG_FLAG="$2"; shift 2 ;;
*) break ;;
esac
done
REPO_URL="${1:-https://github.com/hacklabr/opencode-mesa}"
INSTALL_DIR="${2:-$HOME/.local/share/opencode-mesa}"
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
info() { printf "${GREEN}[mesa]${NC} %s\n" "$1"; }
warn() { printf "${YELLOW}[mesa]${NC} %s\n" "$1"; }
error() { printf "${RED}[mesa]${NC} %s\n" "$1" >&2; exit 1; }
command -v git >/dev/null 2>&1 || error "git is required"
command -v node >/dev/null 2>&1 || error "node is required"
command -v npm >/dev/null 2>&1 || error "npm is required"
if [ -d "$INSTALL_DIR" ]; then
info "Updating existing installation at $INSTALL_DIR"
git -C "$INSTALL_DIR" fetch --unshallow 2>/dev/null || true
git -C "$INSTALL_DIR" fetch origin --tags
if [ -n "$TAG_FLAG" ]; then
git -C "$INSTALL_DIR" checkout "tags/$TAG_FLAG"
else
git -C "$INSTALL_DIR" reset --hard origin/main
fi
else
info "Cloning Mesa into $INSTALL_DIR"
git clone --depth 1 "$REPO_URL" "$INSTALL_DIR"
fi
info "Installing dependencies"
rm -rf "$INSTALL_DIR/node_modules"
npm ci --prefix "$INSTALL_DIR" 2>/dev/null || npm install --prefix "$INSTALL_DIR"
info "Building plugin"
npm run build --prefix "$INSTALL_DIR"
info "Generating agents (2 primary + 173 hidden subagents)"
GLOBAL_AGENTS_DIR="$HOME/.config/opencode/agents"
node "$INSTALL_DIR/src/setup/generate-agents.js" "$GLOBAL_AGENTS_DIR"
PLUGIN_PATH="file://$INSTALL_DIR/dist/index.js"
CONFIG_DIR="$HOME/.config/opencode"
CONFIG_FILE="$CONFIG_DIR/opencode.json"
info ""
info "Configuring plugin globally..."
mkdir -p "$CONFIG_DIR"
if [ -f "$CONFIG_FILE" ]; then
if grep -q "opencode-mesa" "$CONFIG_FILE" 2>/dev/null; then
info "Plugin already configured in $CONFIG_FILE"
else
node "$INSTALL_DIR/src/setup/add-plugin.cjs" "$CONFIG_FILE" "$PLUGIN_PATH"
info "Plugin added to $CONFIG_FILE"
fi
else
cat > "$CONFIG_FILE" <<EOCFG
{
"\$schema": "https://opencode.ai/config.json",
"plugin": ["$PLUGIN_PATH"]
}
EOCFG
info "Created $CONFIG_FILE with plugin configured"
fi
info ""
info "Done. Restart opencode to load the plugin."
info ""
info "Agents are generated globally in $GLOBAL_AGENTS_DIR"
info "To also generate agents in a specific project, run:"
info " node $INSTALL_DIR/src/setup/generate-agents.js /path/to/project/.opencode/agents"
info ""
info "Switch agents with Tab or /agent:"
info " /agent briefing-writer — start a discovery session"
info " /agent manager — orchestrate a specialist team"