-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·90 lines (72 loc) · 2.75 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·90 lines (72 loc) · 2.75 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
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
shared_source="$script_dir/rules/AGENTS.md"
claude_source="$script_dir/rules/CLAUDE.md"
backend_skill_source="$script_dir/skills/backend-code-guide"
frontend_api_docs_source="$script_dir/skills/frontend-api-docs"
iteration_delivery_source="$script_dir/skills/iteration-delivery"
if [ ! -f "$shared_source" ] || [ ! -f "$claude_source" ] || \
[ ! -f "$backend_skill_source/SKILL.md" ] || \
[ ! -f "$frontend_api_docs_source/SKILL.md" ] || \
[ ! -f "$iteration_delivery_source/SKILL.md" ]; then
echo 'Managed rule or skill files are missing from the repository.' >&2
exit 1
fi
project_root=
if [ -n "${DEVELOP_SKILLS_PROJECT_ROOT:-}" ]; then
if [ ! -d "$DEVELOP_SKILLS_PROJECT_ROOT" ]; then
echo 'DEVELOP_SKILLS_PROJECT_ROOT must be an existing directory.' >&2
exit 1
fi
project_root=$(CDPATH= cd -- "$DEVELOP_SKILLS_PROJECT_ROOT" && pwd -P)
fi
if [ -n "${DEVELOP_SKILLS_TARGET_HOME:-}" ]; then
target_home=$DEVELOP_SKILLS_TARGET_HOME
codex_dir="$target_home/.codex"
claude_dir="$target_home/.claude"
else
target_home=$HOME
codex_dir=${CODEX_HOME:-"$target_home/.codex"}
claude_dir="$target_home/.claude"
fi
backup_stamp=$(date '+%Y%m%d-%H%M%S')
next_backup_path() {
target=$1
candidate="${target}.backup-${backup_stamp}"
suffix=1
while [ -e "$candidate" ] || [ -L "$candidate" ]; do
candidate="${target}.backup-${backup_stamp}-${suffix}"
suffix=$((suffix + 1))
done
printf '%s\n' "$candidate"
}
link_rule() {
source=$1
target=$2
target_dir=$(dirname -- "$target")
mkdir -p "$target_dir"
if [ -L "$target" ] && [ "$(readlink "$target")" = "$source" ]; then
printf 'unchanged %s -> %s\n' "$target" "$source"
return
fi
if [ -e "$target" ] || [ -L "$target" ]; then
backup=$(next_backup_path "$target")
mv "$target" "$backup"
printf 'backed up %s -> %s\n' "$target" "$backup"
fi
ln -s "$source" "$target"
printf 'linked %s -> %s\n' "$target" "$source"
}
link_rule "$shared_source" "$codex_dir/AGENTS.md"
link_rule "$shared_source" "$claude_dir/rules/shared-engineering.md"
link_rule "$claude_source" "$claude_dir/CLAUDE.md"
link_rule "$frontend_api_docs_source" "$codex_dir/skills/frontend-api-docs"
link_rule "$frontend_api_docs_source" "$claude_dir/skills/frontend-api-docs"
link_rule "$iteration_delivery_source" "$codex_dir/skills/iteration-delivery"
link_rule "$iteration_delivery_source" "$claude_dir/skills/iteration-delivery"
if [ -n "$project_root" ]; then
link_rule "$backend_skill_source" "$project_root/.codex/skills/backend-code-guide"
link_rule "$backend_skill_source" "$project_root/.claude/skills/backend-code-guide"
fi
echo 'Installation complete. Start new Codex and Claude Code sessions to load the rules.'