Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·130 lines (114 loc) · 3.56 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·130 lines (114 loc) · 3.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
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
#!/usr/bin/env bash
# Install (or update) the EPCV agents, commands, skills, and plugins for OpenCode.
#
# Copies the generic parts of this repo's opencode/ directory into either
# the global OpenCode config directory or a project's .opencode/ directory.
# Re-running the script updates a previous install: every item this repo
# provides is replaced with the current version; anything else in the
# destination (your own agents, commands, skills) is left alone.
#
# Machine-local configuration (opencode.json, tui.json) is not part of this
# repo and is never installed.
set -euo pipefail
usage() {
cat <<'EOF'
Usage:
./install.sh --global [--symlink]
./install.sh --project <path> [--symlink]
Targets:
--global Install for all projects, into $XDG_CONFIG_HOME/opencode
(default ~/.config/opencode)
--project <path> Install into <path>/.opencode for a single project
Options:
--symlink Symlink items into place instead of copying, so a
`git pull` in this repo updates every install
-h, --help Show this help
What gets installed:
agents/ EPCV agents (explorer, planner, coder, verifier,
GeneralCoder) and their subagents
commands/ /explore, /plan, /code, /verify, /epcv, /commit-task
skills/ the workflow rules each agent loads
plugins/ the context-cache plugin
Re-run the same command at any time to update an existing install.
EOF
}
fail() {
echo "error: $1" >&2
exit 1
}
target=""
project_path=""
symlink=false
while [ $# -gt 0 ]; do
case "$1" in
--global)
[ -z "$target" ] || fail "specify only one of --global or --project"
target="global"
;;
--project)
[ -z "$target" ] || fail "specify only one of --global or --project"
target="project"
[ $# -ge 2 ] || fail "--project requires a path"
project_path="$2"
shift
;;
--symlink)
symlink=true
;;
-h | --help)
usage
exit 0
;;
*)
usage >&2
fail "unknown argument: $1"
;;
esac
shift
done
[ -n "$target" ] || {
usage >&2
fail "specify --global or --project <path>"
}
# Resolve the repo's opencode directory relative to this script.
script_dir="$(cd "$(dirname "$0")" && pwd)"
source_dir="$script_dir/opencode"
[ -d "$source_dir" ] || fail "source directory not found: $source_dir"
if [ "$target" = "global" ]; then
dest_root="${XDG_CONFIG_HOME:-$HOME/.config}/opencode"
else
[ -d "$project_path" ] || fail "project path is not a directory: $project_path"
dest_root="$(cd "$project_path" && pwd)/.opencode"
fi
# Subdirectories of the repo's opencode/ directory that get installed.
# Source and destination names match the current OpenCode docs (plural).
subdirs="agents commands skills plugins"
installed=0
for name in $subdirs; do
src="$source_dir/$name"
dest="$dest_root/$name"
[ -d "$src" ] || continue
mkdir -p "$dest"
for item in "$src"/*; do
[ -e "$item" ] || continue
base="$(basename "$item")"
rm -rf "${dest:?}/$base"
if [ "$symlink" = true ]; then
ln -s "$item" "$dest/$base"
else
cp -R "$item" "$dest/$base"
fi
installed=$((installed + 1))
echo " $name/$base"
done
done
[ "$installed" -gt 0 ] || fail "nothing to install — is this a complete checkout?"
mode="copied"
[ "$symlink" = true ] && mode="symlinked"
echo
echo "Done: $installed items $mode into $dest_root"
if [ "$symlink" = true ]; then
echo "Symlinked installs update automatically when you git pull this repo."
else
echo "To update later, git pull this repo and re-run the same command."
fi