-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·126 lines (111 loc) · 4.05 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·126 lines (111 loc) · 4.05 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
#!/usr/bin/env bash
set -euo pipefail
REPO_URL="${AUTO_PR_REPO_URL:-https://github.com/0-sayed/auto-pr.git}"
INSTALL_DIR="${AUTO_PR_INSTALL_DIR:-$HOME/.local/share/auto-pr}"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
validate_checkout() {
local checkout_dir=$1
local origin_url
origin_url="$(git -C "$checkout_dir" config --get remote.origin.url || true)"
if [ "$origin_url" != "$REPO_URL" ] || [ ! -f "$checkout_dir/plugins/auto-pr/.codex-plugin/plugin.json" ]; then
echo "Install directory exists but is not this Auto PR checkout: $checkout_dir" >&2
echo "Set AUTO_PR_INSTALL_DIR to another path or move that directory first." >&2
exit 1
fi
}
if [ ! -d "$ROOT/plugins/auto-pr" ]; then
if ! command -v git >/dev/null 2>&1; then
echo "Auto PR installer needs git to download the bundle." >&2
exit 1
fi
if [ -d "$INSTALL_DIR/.git" ]; then
validate_checkout "$INSTALL_DIR"
git -C "$INSTALL_DIR" pull --ff-only
elif [ -e "$INSTALL_DIR" ]; then
echo "Install directory exists but is not an Auto PR git checkout: $INSTALL_DIR" >&2
echo "Set AUTO_PR_INSTALL_DIR to another path or move that directory first." >&2
exit 1
else
mkdir -p "$(dirname "$INSTALL_DIR")"
git clone --depth 1 "$REPO_URL" "$INSTALL_DIR"
fi
exec bash "$INSTALL_DIR/install.sh" "$@"
fi
PLUGIN="$ROOT/plugins/auto-pr"
SKILLS_SRC="$PLUGIN/skills"
WORKFLOWS_SRC="$ROOT/archon/workflows"
SCRIPTS_SRC="$ROOT/archon/scripts"
SKILLS_DEST="${AGENTS_SKILLS_DIR:-$HOME/.agents/skills}"
ARCHON_HOME_DIR="${ARCHON_HOME:-$HOME/.archon}"
GLOBAL_WORKFLOWS_DEST="${ARCHON_GLOBAL_WORKFLOWS_DIR:-$ARCHON_HOME_DIR/.archon/workflows}"
MARKETPLACE_SOURCE="${AUTO_PR_MARKETPLACE_SOURCE:-0-sayed/auto-pr}"
MARKETPLACE_NAME="${AUTO_PR_MARKETPLACE_NAME:-auto-pr-marketplace}"
MANAGED_MARKER=".auto-pr-managed"
LEGACY_SKILLS=()
mkdir -p "$SKILLS_DEST" "$ARCHON_HOME_DIR/scripts" "$GLOBAL_WORKFLOWS_DEST"
for name in "${LEGACY_SKILLS[@]}"; do
target="$SKILLS_DEST/$name"
if [ -L "$target" ]; then
current_target="$(readlink "$target")"
case "$current_target" in
"$ROOT"/plugins/auto-pr/skills/*|"$INSTALL_DIR"/plugins/auto-pr/skills/*)
rm "$target"
echo "removed legacy skill link: $name"
;;
esac
elif [ -e "$target" ] && [ -f "$target/$MANAGED_MARKER" ]; then
rm -rf "$target"
echo "removed legacy managed skill: $name"
fi
done
for skill in "$SKILLS_SRC"/*; do
[ -d "$skill" ] || continue
name="$(basename "$skill")"
target="$SKILLS_DEST/$name"
if [ -L "$target" ]; then
current_target="$(readlink "$target")"
if [ "$current_target" = "$skill" ]; then
echo "skill already linked: $name"
else
echo "skip skill conflict: $target points to $current_target" >&2
fi
elif [ -e "$target" ]; then
if [ -f "$target/$MANAGED_MARKER" ]; then
rm -rf "$target"
cp -a "$skill" "$target"
touch "$target/$MANAGED_MARKER"
echo "updated managed skill: $name"
else
echo "skip skill conflict: $target already exists and is not Auto PR-managed" >&2
fi
else
ln -s "$skill" "$target"
echo "linked skill: $name"
fi
done
for script in "$SCRIPTS_SRC"/*; do
[ -f "$script" ] || continue
target="$ARCHON_HOME_DIR/scripts/$(basename "$script")"
cp -f "$script" "$target"
echo "updated script: $(basename "$script")"
done
for workflow in "$WORKFLOWS_SRC"/*; do
[ -f "$workflow" ] || continue
target="$GLOBAL_WORKFLOWS_DEST/$(basename "$workflow")"
cp -f "$workflow" "$target"
echo "updated workflow: $(basename "$workflow")"
done
if command -v codex >/dev/null 2>&1; then
if codex plugin marketplace add "$MARKETPLACE_SOURCE" >/dev/null 2>&1; then
echo "registered Codex marketplace: $MARKETPLACE_SOURCE"
else
codex plugin marketplace upgrade "$MARKETPLACE_NAME" >/dev/null 2>&1 || true
echo "updated Codex marketplace: $MARKETPLACE_NAME"
fi
fi
echo "Installed Auto PR"
echo "Bundle: $ROOT"
echo "Skills: $SKILLS_DEST"
echo "Scripts: $ARCHON_HOME_DIR/scripts"
echo "Global workflows: $GLOBAL_WORKFLOWS_DEST"
echo "Restart Codex, then run: archon workflow list"