-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·66 lines (57 loc) · 2.22 KB
/
install.sh
File metadata and controls
executable file
·66 lines (57 loc) · 2.22 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SOURCE_DIR="${SCRIPT_DIR}/opencode"
TARGET_DIR="${HOME}/.config/opencode"
if [ ! -d "${SOURCE_DIR}" ]; then
printf 'Source directory not found: %s\n' "${SOURCE_DIR}" >&2
exit 1
fi
mkdir -p "${TARGET_DIR}"
if command -v rsync >/dev/null 2>&1; then
rsync -a --exclude '.DS_Store' --exclude '.serena/' "${SOURCE_DIR}/" "${TARGET_DIR}/"
else
cp -R "${SOURCE_DIR}/." "${TARGET_DIR}/"
fi
# Deploy custom Serena context
SERENA_CONTEXT_SOURCE="${SOURCE_DIR}/serena/opencode-context.yml"
SERENA_CONTEXT_DIR="${HOME}/.serena/config/contexts"
SERENA_CONTEXT_TARGET="${SERENA_CONTEXT_DIR}/opencode.yml"
serena_context_status="skipped"
if [ -f "${SERENA_CONTEXT_SOURCE}" ]; then
mkdir -p "${SERENA_CONTEXT_DIR}"
if [ -f "${SERENA_CONTEXT_TARGET}" ] && diff -q "${SERENA_CONTEXT_SOURCE}" "${SERENA_CONTEXT_TARGET}" >/dev/null 2>&1; then
serena_context_status="up to date"
else
cp "${SERENA_CONTEXT_SOURCE}" "${SERENA_CONTEXT_TARGET}"
serena_context_status="deployed"
fi
fi
count_files() {
local dir="$1"
if [ -d "${dir}" ]; then
find "${dir}" -type f | wc -l | tr -d ' '
else
printf '0'
fi
}
printf 'Installed OpenCode configuration to %s\n' "${TARGET_DIR}"
printf ' config: %s\n' "$( [ -f "${TARGET_DIR}/opencode.json" ] && printf 'opencode.json' || printf 'missing' )"
printf ' agents: %s files\n' "$(count_files "${TARGET_DIR}/agents")"
printf ' commands: %s files\n' "$(count_files "${TARGET_DIR}/commands")"
printf ' skills: %s files\n' "$(count_files "${TARGET_DIR}/skills")"
printf ' tools: %s files\n' "$(count_files "${TARGET_DIR}/tools")"
printf ' AGENTS.md: %s\n' "$( [ -f "${TARGET_DIR}/AGENTS.md" ] && printf 'installed' || printf 'missing' )"
printf ' serena context: %s\n' "${serena_context_status}"
# Check TypeScript runtime for custom tools
if [ "$(count_files "${TARGET_DIR}/tools")" -gt 0 ]; then
if command -v bun >/dev/null 2>&1; then
printf ' ts runtime: bun\n'
elif command -v npx >/dev/null 2>&1; then
printf ' ts runtime: npx (tsx)\n'
else
printf '\n'
printf 'WARNING: Custom tools require a TypeScript runtime.\n'
printf 'Install one of: bun (https://bun.sh) or Node.js with tsx.\n'
fi
fi