-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·158 lines (137 loc) · 4.31 KB
/
install.sh
File metadata and controls
executable file
·158 lines (137 loc) · 4.31 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
#!/usr/bin/env bash
set -euo pipefail
# Global installation only for now
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV="$SCRIPT_DIR/.venv"
MANIFEST="$SCRIPT_DIR/install-manifest.yml"
# Parse arguments
SKILL_FILTER=""
USE_LOCAL_SDK=false
while [[ $# -gt 0 ]]; do
case "$1" in
--skill=*)
SKILL_FILTER="${1#*=}"
shift
;;
--local)
USE_LOCAL_SDK=true
shift
;;
*)
echo "Usage: $0 [--skill=<skill-name>] [--local]" >&2
echo " --local Install flatagents SDK from ~/code/flatagents/sdk/python (editable)"
exit 1
;;
esac
done
LOCAL_SDK_PATH="${FLATAGENTS_SDK_PATH:-$HOME/code/flatagents}/sdk/python"
# Detect package manager
if command -v uv &>/dev/null; then
USE_UV=true
else
USE_UV=false
fi
# Helper function to run pip with correct target
pip_install() {
if [[ "$USE_UV" = true ]]; then
uv pip install -p "$VENV/bin/python" "$@"
else
python -m pip install "$@"
fi
}
# Create virtualenv if needed
if [[ ! -d "$VENV" ]]; then
echo "Creating shared virtualenv at $VENV..."
if [[ "$USE_UV" = true ]]; then
uv venv "$VENV"
else
python3 -m venv "$VENV"
fi
fi
# Activate venv (needed for non-uv commands and PATH)
source "$VENV/bin/activate"
# Ensure pip exists in venv (some Python builds omit pip)
if [[ "$USE_UV" = false ]]; then
if ! python -m pip --version >/dev/null 2>&1; then
echo "pip not found in $VENV, bootstrapping with ensurepip..."
python -m ensurepip --upgrade
python -m pip install -U pip
fi
fi
# Install flatagents SDK (local or remote with auto-upgrade)
if [[ "$USE_LOCAL_SDK" = true ]]; then
if [[ ! -d "$LOCAL_SDK_PATH" ]]; then
echo "ERROR: Local SDK not found at $LOCAL_SDK_PATH" >&2
exit 1
fi
echo "Installing flatagents from local SDK (editable)..."
pip_install -e "$LOCAL_SDK_PATH"
else
echo "Installing/upgrading flatagents from PyPI..."
pip_install --upgrade flatagents
fi
# Install project in editable mode with base dependencies
echo "Installing base dependencies..."
pip_install -e "$SCRIPT_DIR"
# Parse manifest to get skill list
if [[ -z "$SKILL_FILTER" ]]; then
# Install all skills from manifest
if [[ ! -f "$MANIFEST" ]]; then
echo "ERROR: install-manifest.yml not found" >&2
exit 1
fi
# Extract skills from YAML (simple parser for "- <skill>" lines)
SKILLS=$(grep "^ - " "$MANIFEST" | sed 's/^ - //')
else
# Install specific skill
SKILLS="$SKILL_FILTER"
fi
# Install optional dependencies for selected skills
for skill in $SKILLS; do
echo "Installing dependencies for $skill..."
pip_install -e "$SCRIPT_DIR"["$skill"] || {
# Fallback if the group doesn't exist, just install base
echo " (no skill-specific dependencies for $skill)"
}
# Install skill src if it has its own directory
if [[ -d "$SCRIPT_DIR/$skill" ]]; then
echo "Installing editable package: $skill"
pip_install -e "$SCRIPT_DIR/$skill" 2>/dev/null || true
fi
done
# Symlink skills to ~/.flatagents/skills/ (override with FLATAGENTS_SKILLS_DIR)
SKILLS_DIR="${FLATAGENTS_SKILLS_DIR:-$HOME/.flatagents/skills}"
mkdir -p "$SKILLS_DIR"
for skill in $SKILLS; do
SKILL_RUN_SH="$SCRIPT_DIR/$skill"
if [[ -d "$SKILL_RUN_SH" ]]; then
SKILL_LINK="$SKILLS_DIR/$skill"
# Remove old link if exists
[[ -L "$SKILL_LINK" ]] && rm "$SKILL_LINK"
# Create symlink to skill
ln -s "$SKILL_RUN_SH" "$SKILL_LINK"
echo " ✓ Symlinked: $skill -> $SKILL_LINK"
fi
done
echo ""
echo "✓ Installation complete!"
echo ""
echo "Configuration:"
echo " 1. Set API key for your LLM provider (e.g., ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.)"
echo " 2. Edit agents/*.yml files in each skill to configure provider/model"
echo " 3. For search_refiner: Also set EXA_API_KEY for web search"
echo ""
if [[ -n "$SKILL_FILTER" ]]; then
echo "Installed skill: $SKILL_FILTER"
echo "Usage: $SCRIPT_DIR/$SKILL_FILTER/run.sh [args]"
else
echo "Installed skills:"
for skill in $SKILLS; do
echo " - $skill"
done
echo ""
echo "Usage examples:"
for skill in $SKILLS; do
echo " $SCRIPT_DIR/$skill/run.sh [args]"
done
fi