-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·286 lines (248 loc) · 10.3 KB
/
install.sh
File metadata and controls
executable file
·286 lines (248 loc) · 10.3 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
source "$SCRIPT_DIR/lib/json-node.sh"
source "$SCRIPT_DIR/lib/codex-config.sh"
require_node
case "$(uname -s)" in
MINGW*|MSYS*|CYGWIN*) IS_WINDOWS=true ;;
*) IS_WINDOWS=false ;;
esac
MODEL_PROFILE="mixed"
while [ $# -gt 0 ]; do
case "$1" in
--model-profile)
shift
if [ $# -eq 0 ]; then
echo "Missing value for --model-profile (expected: mixed or maximum)" >&2
exit 1
fi
MODEL_PROFILE="$1"
;;
--model-profile=*)
MODEL_PROFILE="${1#*=}"
;;
esac
shift
done
case "$MODEL_PROFILE" in
mixed|maximum) ;;
*)
echo "Unsupported model profile: $MODEL_PROFILE (expected: mixed or maximum)" >&2
exit 1
;;
esac
WIZARD_VERSION="$(json_get_file "$SCRIPT_DIR/package.json" 'data.version || "unknown"')"
[ -z "$WIZARD_VERSION" ] && WIZARD_VERSION="unknown"
print_feedback_guidance() {
local command_name="$1"
local failure_point="$2"
local repo_shape="${3:-unknown}"
echo ""
echo "Likely wizard-level failure detected."
echo "Report bugs or improvements back to codex-sdlc-wizard."
echo "No issue will be posted automatically."
echo "Issue-ready details:"
echo " wizard version: $WIZARD_VERSION"
echo " command: $command_name"
echo " repo shape: $repo_shape"
echo " failure point: $failure_point"
}
require_bundle_file() {
local path="$1"
local label="$2"
if [ ! -f "$path" ]; then
print_feedback_guidance "install" "missing bundled runtime file: $label" "unknown"
exit 1
fi
}
for required in \
"AGENTS.md" \
"SDLC-LOOP.md" \
"START-SDLC.md" \
"PROVE-IT.md" \
"start-sdlc.sh" \
"start-sdlc.ps1" \
".codex/config.toml" \
".codex/hooks.json" \
".codex/unix-hooks.json" \
".codex/windows-hooks.json" \
".codex/hooks/bash-guard.sh" \
".codex/hooks/session-start.sh" \
".codex/hooks/sdlc-prompt-check.sh" \
".codex/hooks/git-guard.cjs" \
".codex/hooks/session-start.cjs" \
".codex/hooks/compact-guard.cjs" \
".codex/hooks/git-guard.ps1" \
".codex/hooks/session-start.ps1" \
".agents/skills/sdlc/SKILL.md"; do
require_bundle_file "$SCRIPT_DIR/$required" "$required"
done
CODEX_HOME_DIR="${CODEX_HOME:-$HOME/.codex}"
SKILLS_ROOT="$CODEX_HOME_DIR/skills"
SKILLS_BACKUP_ROOT="$CODEX_HOME_DIR/backups/skills"
GLOBAL_HELPER_SKILLS=("feedback" "setup-wizard" "update-wizard")
copy_if_missing() {
local source="$1"
local target="$2"
local label="$3"
if [ ! -f "$target" ]; then
cp "$source" "$target"
echo "Created $label"
else
echo "$label already exists - skipping (review manually)"
fi
}
install_repo_skill() {
local name="$1"
local source="$SCRIPT_DIR/.agents/skills/$name/SKILL.md"
local target=".agents/skills/$name/SKILL.md"
mkdir -p "$(dirname "$target")"
if [ -f "$target" ]; then
echo "$target already exists - skipping (review manually)"
else
cp "$source" "$target"
echo "Installed $target"
fi
}
install_global_skill() {
local skill_path="$1"
local skill_name
[ -d "$skill_path" ] || return 0
skill_name="$(basename "$skill_path")"
if [ -d "$SKILLS_ROOT/$skill_name" ]; then
cp -R "$SKILLS_ROOT/$skill_name" "$SKILLS_BACKUP_ROOT/$skill_name.bak.$(date +%s)"
rm -rf "$SKILLS_ROOT/$skill_name"
echo "Backed up existing Codex skill: $skill_name"
fi
cp -R "$skill_path" "$SKILLS_ROOT/"
echo "Installed Codex skill: $skill_name"
}
global_skill_matches_bundle() {
local skill_name="$1"
local bundled_path="$SCRIPT_DIR/skills/$skill_name"
local target_path="$SKILLS_ROOT/$skill_name"
[ -d "$bundled_path" ] || return 1
[ -d "$target_path" ] || return 1
diff -qr "$bundled_path" "$target_path" >/dev/null 2>&1
}
remove_wizard_managed_global_skill() {
local skill_name="$1"
local reason="$2"
local target_path="$SKILLS_ROOT/$skill_name"
[ -d "$target_path" ] || return 0
if ! global_skill_matches_bundle "$skill_name"; then
echo "Preserved user-owned global Codex skill: $skill_name"
return 0
fi
mkdir -p "$SKILLS_BACKUP_ROOT"
cp -R "$target_path" "$SKILLS_BACKUP_ROOT/$skill_name.bak.$(date +%s)"
rm -rf "$target_path"
echo "Removed wizard-managed global Codex skill: $skill_name ($reason)"
}
prune_legacy_global_skill() {
local legacy_name="$1"
local canonical_name="$2"
local legacy_path="$SKILLS_ROOT/$legacy_name"
[ -d "$legacy_path" ] || return 0
mkdir -p "$SKILLS_BACKUP_ROOT"
cp -R "$legacy_path" "$SKILLS_BACKUP_ROOT/$legacy_name.bak.$(date +%s)"
rm -rf "$legacy_path"
echo "Removed legacy Codex skill: $legacy_name (canonical: $canonical_name)"
}
write_model_profile() {
mkdir -p .codex-sdlc
cat > .codex-sdlc/model-profile.json <<EOF
{
"selected_profile": "$MODEL_PROFILE",
"profiles": {
"mixed": {
"main_model": "gpt-5.4-mini",
"main_reasoning": "xhigh",
"review_model": "gpt-5.5",
"review_reasoning": "xhigh",
"tradeoff": "Smaller/faster main model for routine work while keeping xhigh main reasoning and xhigh review."
},
"maximum": {
"main_model": "gpt-5.5",
"main_reasoning": "xhigh",
"review_model": "gpt-5.5",
"review_reasoning": "xhigh",
"tradeoff": "Higher latency and token usage in exchange for maximum stability and depth."
}
},
"policy": {
"high_confidence_threshold_percent": 95,
"low_confidence_rule": "Research more first. If confidence stays below 95%, escalate review to xhigh. Use the maximum profile for abstract, complex, or high-blast-radius work."
}
}
EOF
echo "Wrote .codex-sdlc/model-profile.json ($MODEL_PROFILE)"
}
echo "Installing SDLC Wizard for Codex CLI..."
copy_if_missing "$SCRIPT_DIR/AGENTS.md" "AGENTS.md" "AGENTS.md"
copy_if_missing "$SCRIPT_DIR/SDLC-LOOP.md" "SDLC-LOOP.md" "SDLC-LOOP.md"
copy_if_missing "$SCRIPT_DIR/START-SDLC.md" "START-SDLC.md" "START-SDLC.md"
copy_if_missing "$SCRIPT_DIR/PROVE-IT.md" "PROVE-IT.md" "PROVE-IT.md"
mkdir -p "$SKILLS_ROOT" "$SKILLS_BACKUP_ROOT"
for skill_name in "${GLOBAL_HELPER_SKILLS[@]}"; do
install_global_skill "$SCRIPT_DIR/skills/$skill_name"
done
remove_wizard_managed_global_skill "sdlc" "repo-scoped .agents/skills/sdlc is the canonical \$sdlc entrypoint"
prune_legacy_global_skill "codex-sdlc" "sdlc"
mkdir -p .codex/hooks
merge_codex_config_profile ".codex/config.toml" "$MODEL_PROFILE"
echo "Merged repo-local Codex config for model profile '$MODEL_PROFILE'"
if [ -f ".codex/hooks.json" ]; then
cp .codex/hooks.json ".codex/hooks.json.bak.$(date +%s)"
echo "Backed up existing hooks.json"
fi
cp "$SCRIPT_DIR/.codex/hooks/"*.sh .codex/hooks/
chmod +x .codex/hooks/*.sh
cp "$SCRIPT_DIR/.codex/hooks/"*.cjs .codex/hooks/
rm -f .codex/hooks/git-guard.js .codex/hooks/session-start.js
if [ "$IS_WINDOWS" = "true" ]; then
cp "$SCRIPT_DIR/.codex/windows-hooks.json" .codex/hooks.json
cp "$SCRIPT_DIR/.codex/hooks/git-guard.ps1" .codex/hooks/
cp "$SCRIPT_DIR/.codex/hooks/session-start.ps1" .codex/hooks/
copy_if_missing "$SCRIPT_DIR/start-sdlc.ps1" "start-sdlc.ps1" "start-sdlc.ps1"
echo "Installed .codex/hooks.json (universal Node hooks)"
echo "Installed Node and PowerShell hook scripts"
else
cp "$SCRIPT_DIR/.codex/unix-hooks.json" .codex/hooks.json
copy_if_missing "$SCRIPT_DIR/start-sdlc.sh" "start-sdlc.sh" "start-sdlc.sh"
chmod +x start-sdlc.sh
echo "Installed .codex/hooks.json (universal Node hooks)"
fi
echo "Installed shell hook scripts"
install_repo_skill sdlc
write_model_profile
echo ""
echo "SDLC Wizard for Codex installed."
START_MODEL="$(profile_model "$MODEL_PROFILE")"
START_REASONING="$(profile_reasoning "$MODEL_PROFILE")"
echo "Recommended start: codex -m $START_MODEL -c 'model_reasoning_effort=\"$START_REASONING\"'"
echo "Use plain 'codex' instead if you want to rely on trusted repo-local config."
echo "Fresh-session note: if you ran this from inside an existing Codex session, exit and reopen Codex in this repo so repo-local config, hooks, and skills load."
echo "Hook review note: if Codex says hooks need review, open /hooks after restart and review pending repo hooks before relying on enforcement."
echo "Start new with selected profile: codex -m $START_MODEL -c 'model_reasoning_effort=\"$START_REASONING\"'"
echo "Resume with selected profile: codex resume -m $START_MODEL -c 'model_reasoning_effort=\"$START_REASONING\"'"
echo "If resume warns it came back with a different model, resume explicitly with: codex resume -m gpt-5.5 -c 'model_reasoning_effort=\"xhigh\"'"
echo "If you normally use yolo-style sessions, use the canonical full-trust Codex flag:"
echo " codex --dangerously-bypass-approvals-and-sandbox -m $START_MODEL -c 'model_reasoning_effort=\"$START_REASONING\"'"
echo " codex resume --dangerously-bypass-approvals-and-sandbox -m $START_MODEL -c 'model_reasoning_effort=\"$START_REASONING\"'"
echo "Codex may accept --yolo as shorthand; this wizard prints the canonical full-trust flag."
echo "Full-auto is not full-trust: full-trust bypasses sandbox and approval prompts."
echo "Full-trust warning: only use that variant in repos you fully trust."
echo "Model profile: '$MODEL_PROFILE'."
echo " - mixed: gpt-5.4-mini main pass + gpt-5.5 xhigh review for better speed, lower latency, and lower token usage."
echo " - maximum: gpt-5.5 xhigh throughout for maximum stability and the most thorough \"ultimate mode\"."
echo "Wrote repo-local .codex/config.toml model keys for this profile; mixed is wizard policy, not a native Codex mode."
echo "Codex loads project config only after the repo is trusted, and trusted project config overrides your user-level ~/.codex/config.toml."
echo "If confidence drops below 95%, research more first. If it still stays below 95%, escalate review to xhigh."
echo "Repo-scoped skills are still a work in progress. Today the supported public workflow skill is '\$sdlc'."
echo "Codex treats same-name skills from different scopes as distinct choices; normal setup installs global helper skills only and keeps repo-scoped '\$sdlc' canonical."
echo "Additional repo-scoped workflows stay unnamed until their public contracts are ready."
echo "Auth-heavy note: for Windows / WAM / MFA or other live sign-in flows, the prompt itself stays user-owned."
echo "This wizard still owns command shape, checks, and the verify/resume steps after you complete sign-in."
echo "If auth, license, tenant, or permission state decides what work is possible, add a repo-local doctor / check-capability / Test-*Access helper."