-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·194 lines (183 loc) · 7.89 KB
/
install.sh
File metadata and controls
executable file
·194 lines (183 loc) · 7.89 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
#!/usr/bin/env bash
set -euo pipefail
REPO_URL="${REPO_URL:-https://github.com/dmoliveira/my_opencode.git}"
REPO_REF="${REPO_REF:-}"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.config/opencode/my_opencode}"
CONFIG_DIR="$HOME/.config/opencode"
CONFIG_PATH="$CONFIG_DIR/opencode.json"
NON_INTERACTIVE=false
SKIP_SELF_CHECK=false
RUN_WIZARD=false
WIZARD_RECONFIGURE=false
while [ "$#" -gt 0 ]; do
case "$1" in
--non-interactive)
NON_INTERACTIVE=true
;;
--skip-self-check)
SKIP_SELF_CHECK=true
;;
--wizard)
RUN_WIZARD=true
;;
--reconfigure)
WIZARD_RECONFIGURE=true
;;
-h|--help)
printf "Usage: %s [--non-interactive] [--skip-self-check] [--wizard] [--reconfigure]\n" "$0"
exit 0
;;
*)
printf "Error: unknown argument: %s\n" "$1" >&2
exit 2
;;
esac
shift
done
if ! command -v git >/dev/null 2>&1; then
printf "Error: git is required but not installed.\n" >&2
exit 1
fi
if ! command -v python3 >/dev/null 2>&1; then
printf "Error: python3 is required but not installed.\n" >&2
exit 1
fi
mkdir -p "$CONFIG_DIR"
if [ -d "$INSTALL_DIR/.git" ]; then
printf "Updating existing config repo at %s\n" "$INSTALL_DIR"
git -C "$INSTALL_DIR" fetch --all --prune
git -C "$INSTALL_DIR" pull --ff-only
else
if [ -e "$INSTALL_DIR" ] && [ ! -d "$INSTALL_DIR/.git" ]; then
printf "Error: %s exists and is not a git repository.\n" "$INSTALL_DIR" >&2
exit 1
fi
printf "Cloning config repo into %s\n" "$INSTALL_DIR"
git clone --depth 1 "$REPO_URL" "$INSTALL_DIR"
fi
if [ -n "$REPO_REF" ]; then
printf "Checking out repo ref %s\n" "$REPO_REF"
git -C "$INSTALL_DIR" fetch --all --prune >/dev/null 2>&1 || true
git -C "$INSTALL_DIR" checkout "$REPO_REF"
fi
chmod +x "$INSTALL_DIR/scripts/mcp_command.py" "$INSTALL_DIR/scripts/plugin_command.py" "$INSTALL_DIR/scripts/notify_command.py" "$INSTALL_DIR/scripts/session_digest.py" "$INSTALL_DIR/scripts/opencode_session.sh" "$INSTALL_DIR/scripts/telemetry_command.py" "$INSTALL_DIR/scripts/post_session_command.py" "$INSTALL_DIR/scripts/policy_command.py" "$INSTALL_DIR/scripts/doctor_command.py" "$INSTALL_DIR/scripts/config_command.py" "$INSTALL_DIR/scripts/stack_profile_command.py" "$INSTALL_DIR/scripts/install_wizard.py" "$INSTALL_DIR/scripts/nvim_integration_command.py" "$INSTALL_DIR/scripts/devtools_command.py" "$INSTALL_DIR/scripts/background_task_manager.py" "$INSTALL_DIR/scripts/refactor_lite_command.py"
if [ -f "$INSTALL_DIR/scripts/browser_command.py" ]; then
chmod +x "$INSTALL_DIR/scripts/browser_command.py"
fi
if [ -f "$INSTALL_DIR/scripts/start_work_command.py" ]; then
chmod +x "$INSTALL_DIR/scripts/start_work_command.py"
fi
ln -sfn "$INSTALL_DIR/opencode.json" "$CONFIG_PATH"
if [ "$RUN_WIZARD" = true ]; then
printf "\nRunning install wizard...\n"
WIZARD_ARGS=()
if [ "$WIZARD_RECONFIGURE" = true ]; then
WIZARD_ARGS+=("--reconfigure")
fi
if [ "$NON_INTERACTIVE" = true ]; then
WIZARD_ARGS+=("--non-interactive")
fi
python3 "$INSTALL_DIR/scripts/install_wizard.py" "${WIZARD_ARGS[@]}"
fi
if [ "$SKIP_SELF_CHECK" = false ]; then
printf "\nRunning self-check...\n"
python3 "$INSTALL_DIR/scripts/mcp_command.py" status
python3 "$INSTALL_DIR/scripts/plugin_command.py" status
python3 "$INSTALL_DIR/scripts/notify_command.py" status
python3 "$INSTALL_DIR/scripts/notify_command.py" doctor
python3 "$INSTALL_DIR/scripts/session_digest.py" show || true
python3 "$INSTALL_DIR/scripts/session_digest.py" doctor
python3 "$INSTALL_DIR/scripts/telemetry_command.py" status
python3 "$INSTALL_DIR/scripts/post_session_command.py" status
python3 "$INSTALL_DIR/scripts/policy_command.py" status
python3 "$INSTALL_DIR/scripts/config_command.py" status
python3 "$INSTALL_DIR/scripts/config_command.py" layers
python3 "$INSTALL_DIR/scripts/background_task_manager.py" status
python3 "$INSTALL_DIR/scripts/background_task_manager.py" doctor --json
if [ -f "$INSTALL_DIR/scripts/refactor_lite_command.py" ]; then
python3 "$INSTALL_DIR/scripts/refactor_lite_command.py" profile --scope "scripts/*.py" --dry-run --json
fi
python3 "$INSTALL_DIR/scripts/stack_profile_command.py" status
python3 "$INSTALL_DIR/scripts/browser_command.py" status
python3 "$INSTALL_DIR/scripts/browser_command.py" doctor --json
if [ -f "$INSTALL_DIR/scripts/start_work_command.py" ]; then
SELF_CHECK_PLAN="$HOME/.config/opencode/my_opencode/.install-selfcheck-plan.md"
python3 -c "from pathlib import Path; Path('$SELF_CHECK_PLAN').write_text('---\nid: install-selfcheck-plan\ntitle: Install Selfcheck Plan\nowner: installer\ncreated_at: 2026-02-13T00:00:00Z\nversion: 1\n---\n\n# Plan\n\n- [ ] 1. Confirm command wiring\n- [ ] 2. Confirm checkpoint persistence\n', encoding='utf-8')"
python3 "$INSTALL_DIR/scripts/start_work_command.py" "$SELF_CHECK_PLAN" --deviation "install self-check" --json
python3 "$INSTALL_DIR/scripts/start_work_command.py" "$SELF_CHECK_PLAN" --background --json
python3 "$INSTALL_DIR/scripts/background_task_manager.py" run --max-jobs 1
python3 "$INSTALL_DIR/scripts/start_work_command.py" status --json
python3 "$INSTALL_DIR/scripts/start_work_command.py" deviations --json
python3 "$INSTALL_DIR/scripts/start_work_command.py" doctor --json
fi
python3 "$INSTALL_DIR/scripts/nvim_integration_command.py" status
python3 "$INSTALL_DIR/scripts/devtools_command.py" status
python3 "$INSTALL_DIR/scripts/doctor_command.py" run || true
if ! python3 "$INSTALL_DIR/scripts/plugin_command.py" doctor; then
if [ "$NON_INTERACTIVE" = true ]; then
printf "\nSelf-check failed in non-interactive mode.\n" >&2
exit 1
fi
printf "\nSelf-check reported missing prerequisites; setup can continue.\n"
python3 "$INSTALL_DIR/scripts/plugin_command.py" setup-keys
fi
fi
printf "\nDone! ✅\n"
printf "Config linked: %s -> %s\n" "$CONFIG_PATH" "$INSTALL_DIR/opencode.json"
printf "\nOpen OpenCode and use:\n"
printf " /mcp status\n"
printf " /mcp help\n"
printf " /mcp doctor\n"
printf " /mcp enable context7\n"
printf " /mcp disable context7\n"
printf " /plugin status\n"
printf " /plugin doctor\n"
printf " /doctor run\n"
printf " /notify status\n"
printf " /notify profile focus\n"
printf " /notify doctor\n"
printf " /digest run --reason manual\n"
printf " /digest-run-post\n"
printf " /digest show\n"
printf " /digest doctor\n"
printf " /telemetry status\n"
printf " /telemetry profile local\n"
printf " /post-session status\n"
printf " /policy profile strict\n"
printf " /config status\n"
printf " /config layers\n"
printf " /config backup\n"
printf " /bg status\n"
printf " /bg doctor --json\n"
printf " /refactor-lite profile --scope scripts/*.py --dry-run --json\n"
printf " /hooks status\n"
printf " /hooks enable\n"
printf " /hooks doctor --json\n"
printf " /model-routing status\n"
printf " /model-profile status\n"
printf " /routing status\n"
printf " /routing explain --category deep --json\n"
printf " /keyword-mode status\n"
printf " /keyword-mode detect --prompt 'safe-apply deep-analyze investigate this refactor'\n"
printf " /keyword-mode disable-keyword ulw\n"
printf " /keyword-mode doctor --json\n"
printf " /rules status\n"
printf " /rules explain scripts/selftest.py --json\n"
printf " /stack apply focus\n"
printf " /browser status\n"
printf " /browser profile agent-browser\n"
printf " /browser doctor --json\n"
printf " /start-work ~/.config/opencode/my_opencode/plan.md --json\n"
printf " /start-work-bg ~/.config/opencode/my_opencode/plan.md\n"
printf " /start-work status --json\n"
printf " /start-work deviations --json\n"
printf " /start-work-doctor-json\n"
printf " /nvim status\n"
printf " /devtools status\n"
printf " /devtools install all\n"
printf " /nvim install minimal --link-init\n"
printf " ~/.config/opencode/my_opencode/install.sh --wizard --reconfigure\n"
printf " /doctor-json\n"
printf " /setup-keys\n"
printf " /plugin enable supermemory\n"
printf " /plugin disable supermemory\n"