-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsync-agents.sh
More file actions
executable file
·44 lines (34 loc) · 1.11 KB
/
sync-agents.sh
File metadata and controls
executable file
·44 lines (34 loc) · 1.11 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROFILES_DIR="${SCRIPT_DIR}/profiles"
if [[ ! -d "${PROFILES_DIR}" ]]; then
echo "error: profiles/ directory not found at ${PROFILES_DIR}" >&2
exit 1
fi
synced=0
for profile_file in "${PROFILES_DIR}"/AGENTS.agent-*.md; do
[[ -f "${profile_file}" ]] || continue
# Extract profile name: AGENTS.agent-work.md -> agent-work
basename="$(basename "${profile_file}")"
profile="${basename#AGENTS.}" # agent-work.md
profile="${profile%.md}" # agent-work
target_dir="${HOME}/.pi/${profile}"
target="${target_dir}/AGENTS.md"
if [[ ! -d "${target_dir}" ]]; then
echo "skip: ${target_dir} does not exist (profile '${profile}' not set up)"
continue
fi
# Remove existing file/symlink before creating new one
if [[ -e "${target}" || -L "${target}" ]]; then
rm "${target}"
fi
ln -s "${profile_file}" "${target}"
echo "linked: ${profile_file} -> ${target}"
((synced++))
done
if [[ ${synced} -eq 0 ]]; then
echo "warning: no profiles were synced"
else
echo "done: synced ${synced} profile(s)"
fi