-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·262 lines (242 loc) · 9.54 KB
/
install.sh
File metadata and controls
executable file
·262 lines (242 loc) · 9.54 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
#!/usr/bin/env bash
# OpenCode SDLC Wizard installer.
#
# Non-destructive merge of the wizard into a target repo's .opencode/ dir.
# Pattern mirrors codex-sdlc-wizard's install.sh (battle-tested across
# 6 config-merge cases). Differences here: no TOML config (OpenCode uses
# opencode.json), plus a JS plugin shim instead of a hooks.json registration.
#
# Usage:
# bash install.sh [--target-dir PATH] [--force]
#
# Default --target-dir is the current working directory.
#
# Idempotent: re-running on an already-installed repo is safe — files are only
# overwritten with --force; otherwise existing customizations are preserved
# and a per-file MATCH/CUSTOMIZED/MISSING report is printed.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
TARGET_DIR="$(pwd)"
FORCE=0
while [ $# -gt 0 ]; do
case "$1" in
--target-dir)
shift
[ $# -eq 0 ] && { echo "Missing value for --target-dir" >&2; exit 1; }
TARGET_DIR="$1"
;;
--target-dir=*) TARGET_DIR="${1#*=}" ;;
--force) FORCE=1 ;;
-h|--help)
sed -n '2,16p' "$0"
exit 0
;;
*)
echo "Unknown arg: $1" >&2
exit 1
;;
esac
shift
done
if [ ! -d "$TARGET_DIR" ]; then
echo "Target dir does not exist: $TARGET_DIR" >&2
exit 1
fi
WIZARD_VERSION="$(grep -o '"version"[[:space:]]*:[[:space:]]*"[^"]*"' "$SCRIPT_DIR/package.json" | head -1 | sed 's/.*"\([^"]*\)"$/\1/')"
[ -z "$WIZARD_VERSION" ] && WIZARD_VERSION="unknown"
echo "OpenCode SDLC Wizard v$WIZARD_VERSION"
echo "Target: $TARGET_DIR"
echo ""
# Sibling-wizard detection — two SDLC wizards in one repo is supported (each
# writes to its own directory), but worth surfacing so users don't expect a
# merge of behavior. Caught during the states-project-research consumption
# test where the repo already had claude-sdlc-wizard installed.
SIBLINGS=""
if [ -d "$TARGET_DIR/.claude/skills/sdlc" ] || \
[ -f "$TARGET_DIR/CLAUDE_CODE_SDLC_WIZARD.md" ]; then
SIBLINGS="${SIBLINGS} - claude-sdlc-wizard (.claude/)
"
fi
if [ -d "$TARGET_DIR/.codex" ]; then
SIBLINGS="${SIBLINGS} - codex-sdlc-wizard (.codex/)
"
fi
if [ -n "$SIBLINGS" ]; then
echo "Note: detected sibling SDLC wizard installation(s):"
printf '%s' "$SIBLINGS"
echo " opencode-sdlc-wizard installs to .opencode/ — both can coexist."
echo ""
fi
# Required source files in this repo (the bundle)
REQUIRED_SOURCES=(
"AGENTS.md"
"PRIVACY.md"
".opencode/plugins/sdlc-wizard.js"
".opencode/hooks/_find-sdlc-root.sh"
".opencode/hooks/sdlc-prompt-check.sh"
".opencode/hooks/tdd-pretool-check.sh"
".opencode/hooks/instructions-loaded-check.sh"
".opencode/hooks/model-effort-check.sh"
".opencode/hooks/precompact-seam-check.sh"
"scripts/detect-backends.sh"
"scripts/configure-backend.sh"
"scripts/pick-backend.sh"
"scripts/cross-model-review.sh"
"scripts/check-updates.sh"
"scripts/validate-review-artifact.sh"
"scripts/validate-review-artifact.js"
"skills/sdlc/SKILL.md"
"skills/setup-wizard/SKILL.md"
"skills/update-wizard/SKILL.md"
"skills/feedback/SKILL.md"
"skills/cross-model-review/SKILL.md"
"templates/testing/firmware.md"
"templates/testing/data-science.md"
"templates/testing/cli.md"
"templates/testing/web.md"
"templates/sdlc.md"
"templates/architecture.md"
"templates/schemas/handoff.schema.json"
"templates/schemas/response.schema.json"
)
for f in "${REQUIRED_SOURCES[@]}"; do
if [ ! -f "$SCRIPT_DIR/$f" ]; then
echo "Bundle is missing: $f" >&2
echo "Re-install the wizard or report a bug." >&2
exit 1
fi
done
# Map source path → target path (target uses .opencode/ for everything plugin-side,
# .opencode/skills/ for skills so OpenCode discovers them natively)
declare_target() {
case "$1" in
"AGENTS.md") echo "AGENTS.md" ;;
"PRIVACY.md") echo "PRIVACY.md" ;;
".opencode/plugins/sdlc-wizard.js") echo ".opencode/plugins/sdlc-wizard.js" ;;
".opencode/hooks/"*) echo "$1" ;;
"scripts/detect-backends.sh") echo ".opencode/scripts/detect-backends.sh" ;;
"scripts/configure-backend.sh") echo ".opencode/scripts/configure-backend.sh" ;;
"scripts/pick-backend.sh") echo ".opencode/scripts/pick-backend.sh" ;;
"scripts/cross-model-review.sh") echo ".opencode/scripts/cross-model-review.sh" ;;
"scripts/check-updates.sh") echo ".opencode/scripts/check-updates.sh" ;;
"scripts/validate-review-artifact.sh") echo ".opencode/scripts/validate-review-artifact.sh" ;;
"scripts/validate-review-artifact.js") echo ".opencode/scripts/validate-review-artifact.js" ;;
"skills/sdlc/SKILL.md") echo ".opencode/skills/sdlc/SKILL.md" ;;
"skills/setup-wizard/SKILL.md") echo ".opencode/skills/setup-wizard/SKILL.md" ;;
"skills/update-wizard/SKILL.md") echo ".opencode/skills/update-wizard/SKILL.md" ;;
"skills/feedback/SKILL.md") echo ".opencode/skills/feedback/SKILL.md" ;;
"skills/cross-model-review/SKILL.md") echo ".opencode/skills/cross-model-review/SKILL.md" ;;
"templates/testing/firmware.md") echo ".opencode/templates/testing/firmware.md" ;;
"templates/testing/data-science.md") echo ".opencode/templates/testing/data-science.md" ;;
"templates/testing/cli.md") echo ".opencode/templates/testing/cli.md" ;;
"templates/testing/web.md") echo ".opencode/templates/testing/web.md" ;;
"templates/sdlc.md") echo ".opencode/templates/sdlc.md" ;;
"templates/architecture.md") echo ".opencode/templates/architecture.md" ;;
"templates/schemas/handoff.schema.json") echo ".opencode/schemas/handoff.schema.json" ;;
"templates/schemas/response.schema.json") echo ".opencode/schemas/response.schema.json" ;;
*) echo "$1" ;;
esac
}
# File classification: MATCH / CUSTOMIZED / MISSING
classify() {
local src_abs="$1"
local dst_abs="$2"
if [ ! -f "$dst_abs" ]; then
echo "MISSING"
return
fi
if cmp -s "$src_abs" "$dst_abs"; then
echo "MATCH"
else
echo "CUSTOMIZED"
fi
}
INSTALLED=0
SKIPPED=0
UPDATED=0
for src_rel in "${REQUIRED_SOURCES[@]}"; do
dst_rel="$(declare_target "$src_rel")"
src_abs="$SCRIPT_DIR/$src_rel"
dst_abs="$TARGET_DIR/$dst_rel"
status="$(classify "$src_abs" "$dst_abs")"
case "$status" in
MATCH)
printf " MATCH %s\n" "$dst_rel"
;;
MISSING)
mkdir -p "$(dirname "$dst_abs")"
cp "$src_abs" "$dst_abs"
printf " INSTALLED %s\n" "$dst_rel"
INSTALLED=$((INSTALLED + 1))
;;
CUSTOMIZED)
if [ "$FORCE" -eq 1 ]; then
cp "$src_abs" "$dst_abs"
printf " OVERWROTE %s (--force)\n" "$dst_rel"
UPDATED=$((UPDATED + 1))
else
printf " CUSTOMIZED %s (kept; rerun with --force to overwrite)\n" "$dst_rel"
SKIPPED=$((SKIPPED + 1))
fi
;;
esac
done
# Make hook + script files executable
for d in "$TARGET_DIR/.opencode/hooks" "$TARGET_DIR/.opencode/scripts"; do
[ -d "$d" ] || continue
for f in "$d"/*.sh; do
[ -f "$f" ] && chmod +x "$f"
done
done
# Drop a metadata stamp so update/check can detect drift later. Only
# (re)write the stamp when something actually changed — preserves the
# original installed_at on no-op re-runs (idempotency).
META_DIR="$TARGET_DIR/.opencode"
mkdir -p "$META_DIR"
STAMP_FILE="$META_DIR/.wizard-stamp"
if [ ! -f "$STAMP_FILE" ] || [ "$INSTALLED" -gt 0 ] || [ "$UPDATED" -gt 0 ]; then
{
echo "# Managed by opencode-sdlc-wizard. Do not edit by hand."
echo "wizard_version=$WIZARD_VERSION"
echo "installed_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
} > "$STAMP_FILE"
fi
echo ""
echo "Summary: $INSTALLED installed, $UPDATED overwrote, $SKIPPED kept-customized."
echo ""
if [ "$INSTALLED" -gt 0 ] || [ "$UPDATED" -gt 0 ]; then
cat <<EOF
Next steps:
1. Open OpenCode in this directory. AGENTS.md will be auto-loaded.
2. The plugin (.opencode/plugins/sdlc-wizard.js) auto-loads at session start
and shells out to .opencode/hooks/ for SDLC enforcement.
3. (Optional) Pick a backend — one-shot:
npx opencode-sdlc-wizard pick # auto-pick highest-privacy
npx opencode-sdlc-wizard pick --free-tier-first # bias to free tiers
npx opencode-sdlc-wizard pick --tier T --provider P # override
npx opencode-sdlc-wizard pick --dry-run # preview, don't write
Or the underlying two-step (what \`pick\` orchestrates):
bash .opencode/scripts/detect-backends.sh
bash .opencode/scripts/configure-backend.sh \\
--tier private_local --provider ollama \\
--model qwen3-coder:30b
Tiers (see PRIVACY.md for the privacy contract per tier):
private_local: ollama / lm_studio / llama.cpp / vllm / mlx
enterprise: azure_openai / aws_bedrock
hosted_oss: together / groq / openrouter / cerebras / deepseek / nvidia_nim
managed: opencode (Zen — PAYG, free tier; official new-user entry)
proprietary: anthropic / openai / google_aistudio / zai
subscription: github-copilot / chatgpt / grok (all OAuth via \`opencode /connect\`)
For per-agent routing (planner / reviewer / security / small_model)
plus permission sandboxes, see the same \`pick\` flags — e.g.
npx opencode-sdlc-wizard pick \\
--tier proprietary --provider anthropic \\
--reviewer-tier hosted_oss --reviewer-provider cerebras \\
--sandbox-test-writer --sandbox-docs
Cost guidance for each path: docs/cost-ladder.md (\$0 / \$20 / \$200 monthly
budgets, per-job picker, capability-floor table).
4. Run skill({ name: "sdlc" }) inside OpenCode to invoke the SDLC workflow.
The installer does not write opencode.json on its own — backend selection is
opt-in via the configure-backend.sh script (or the setup-wizard skill).
EOF
fi