-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·198 lines (171 loc) · 5.32 KB
/
install.sh
File metadata and controls
executable file
·198 lines (171 loc) · 5.32 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
Usage:
./install.sh [--codex-home PATH]
./install.sh --version
./install.sh --print-installed-version [--codex-home PATH]
Installs the repo's Codex skills and blueprint payload into CODEX_HOME. If
CODEX_HOME is unset, ~/.codex is used.
EOF
}
codex_home=${CODEX_HOME:-"$HOME/.codex"}
action="install"
while [[ $# -gt 0 ]]; do
case "$1" in
--codex-home)
codex_home=$2
shift 2
;;
--version)
action="print_repo_version"
shift
;;
--print-installed-version)
action="print_installed_version"
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
done
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
version_file="$repo_root/VERSION"
skills_src="$repo_root/skill"
blueprints_src="$repo_root/blueprints"
skills_dst="$codex_home/skills"
vendor_root="$codex_home/vendor/visionos-codex-kit"
blueprints_dst="$vendor_root/blueprints"
install_manifest="$vendor_root/install.json"
codex_home_preexisted="yes"
codex_cli_present="yes"
codex_home_has_prior_state="no"
repo_version=""
if [[ ! -f "$version_file" ]]; then
echo "Missing version file: $version_file" >&2
exit 1
fi
repo_version=$(tr -d '[:space:]' < "$version_file")
if [[ -z "$repo_version" ]]; then
echo "Version file is empty: $version_file" >&2
exit 1
fi
if [[ "$action" == "print_repo_version" ]]; then
printf '%s\n' "$repo_version"
exit 0
fi
if [[ "$action" == "print_installed_version" ]]; then
if [[ ! -f "$install_manifest" ]]; then
echo "Installed manifest not found at $install_manifest" >&2
exit 1
fi
python3 - "$install_manifest" <<'PY'
import json
import sys
from pathlib import Path
manifest_path = Path(sys.argv[1])
payload = json.loads(manifest_path.read_text())
version = payload.get("source_version")
if not version:
raise SystemExit(f"Installed manifest at {manifest_path} does not contain source_version.")
print(version)
PY
exit 0
fi
if [[ ! -d "$codex_home" ]]; then
codex_home_preexisted="no"
fi
if ! command -v codex >/dev/null 2>&1; then
codex_cli_present="no"
fi
if [[ -d "$codex_home" ]]; then
if [[ -e "$codex_home/auth.json" \
|| -e "$codex_home/history.jsonl" \
|| -e "$codex_home/session_index.jsonl" \
|| -e "$codex_home/version.json" \
|| -e "$codex_home/internal_storage.json" \
|| -d "$codex_home/sessions" \
|| -d "$codex_home/log" \
|| -d "$codex_home/sqlite" ]]; then
codex_home_has_prior_state="yes"
fi
fi
install_tree() {
local src=$1
local dst=$2
mkdir -p "$(dirname "$dst")"
rm -rf "$dst"
rsync -a "$src/" "$dst/"
}
if [[ ! -d "$skills_src/visionos-3d-development" ]]; then
echo "Missing skill source: $skills_src/visionos-3d-development" >&2
exit 1
fi
if [[ ! -d "$skills_src/visionos-app-bootstrap" ]]; then
echo "Missing skill source: $skills_src/visionos-app-bootstrap" >&2
exit 1
fi
if [[ ! -d "$blueprints_src/templates" ]]; then
echo "Missing blueprint source tree: $blueprints_src" >&2
exit 1
fi
mkdir -p "$codex_home"
if [[ "$codex_home_preexisted" == "no" ]]; then
printf 'CODEX_HOME does not exist yet. Creating %s now.\n' "$codex_home"
printf 'This is fine for first-time setup: the skills will be staged there and Codex can discover them later.\n'
fi
if [[ "$codex_cli_present" == "no" ]]; then
printf 'Warning: no `codex` command is currently available in PATH.\n'
printf 'The skills and blueprints will still be installed into %s, but Codex itself still needs to be installed or launched separately.\n' "$codex_home"
fi
mkdir -p "$skills_dst" "$vendor_root"
install_tree "$skills_src/visionos-3d-development" "$skills_dst/visionos-3d-development"
install_tree "$skills_src/visionos-app-bootstrap" "$skills_dst/visionos-app-bootstrap"
install_tree "$blueprints_src" "$blueprints_dst"
repo_commit="unknown"
repo_tag=""
if git -C "$repo_root" rev-parse --short HEAD >/dev/null 2>&1; then
repo_commit=$(git -C "$repo_root" rev-parse --short HEAD)
fi
if git -C "$repo_root" describe --tags --exact-match >/dev/null 2>&1; then
repo_tag=$(git -C "$repo_root" describe --tags --exact-match)
fi
installed_at=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
cat > "$install_manifest" <<EOF
{
"installed_at": "$installed_at",
"source_repo": "$repo_root",
"source_version": "$repo_version",
"source_commit": "$repo_commit",
"source_tag": "$repo_tag",
"codex_home": "$codex_home",
"skills": {
"visionos-3d-development": "$skills_dst/visionos-3d-development",
"visionos-app-bootstrap": "$skills_dst/visionos-app-bootstrap"
},
"blueprints_root": "$blueprints_dst"
}
EOF
printf 'Installed visionOS Codex Kit %s into %s\n' "$repo_version" "$codex_home"
printf ' skill: %s\n' "$skills_dst/visionos-3d-development"
printf ' skill: %s\n' "$skills_dst/visionos-app-bootstrap"
printf ' blueprints: %s\n' "$blueprints_dst"
printf ' manifest: %s\n' "$install_manifest"
printf ' version: %s\n' "$repo_version"
printf ' commit: %s\n' "$repo_commit"
if [[ -n "$repo_tag" ]]; then
printf ' tag: %s\n' "$repo_tag"
fi
if [[ "$codex_home_has_prior_state" == "no" ]]; then
printf '\n'
printf 'No prior Codex runtime state was detected in %s.\n' "$codex_home"
printf 'That is still okay. These assets are now staged there and will be ready when Codex starts using that home.\n'
fi