forked from code-yeongyu/oh-my-openagent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·77 lines (66 loc) · 3.3 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·77 lines (66 loc) · 3.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
#!/usr/bin/env bash
# Cross-harness dev-environment bootstrap for oh-my-openagent.
#
# Single source of truth for setting up a working tree so an agent (or human)
# can build and QA the plugin. Wired into Codex App (.codex/setup.sh), Cursor
# (.cursor/environment.json install), Claude Code (.claude/settings.json
# SessionStart), and the devcontainer (postCreateCommand). Idempotent and safe
# to re-run: it skips the (slow) build when dist/index.js already exists unless
# OMO_AGENT_FORCE_BUILD=1.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "$REPO_ROOT"
log() { printf '[setup] %s\n' "$*"; }
# Credentials, set once: source the gitignored .env if present so keys are
# never prompted for again on this machine. See .env.example.
if [ -f "$REPO_ROOT/.env" ]; then
log "loading credentials from .env"
set -a
# shellcheck disable=SC1091
. "$REPO_ROOT/.env"
set +a
fi
# Required toolchain.
missing=0
for tool in bun node git; do
if ! command -v "$tool" >/dev/null 2>&1; then
log "ERROR: required tool '$tool' not found on PATH"
missing=1
fi
done
if [ "$missing" -ne 0 ]; then
log "install the missing tools and re-run. See CONTRIBUTING.md (Prerequisites)."
exit 1
fi
# Optional toolchain (non-fatal).
if ! command -v tmux >/dev/null 2>&1; then
log "WARN: tmux not found - interactive_bash and team-mode will be unavailable"
fi
log "bun $(bun --version) / node $(node --version) / $(git --version)"
# Warn (do not fail) when the local toolchain drifts from the CI-pinned versions.
expected_bun="1.3.12"
expected_node_major="24"
bun_version="$(bun --version 2>/dev/null || echo unknown)"
node_major="$(node --version 2>/dev/null | sed -E 's/^v?([0-9]+).*/\1/')"
[ "$bun_version" = "$expected_bun" ] || log "WARN: Bun $bun_version differs from CI-pinned $expected_bun (see .devcontainer/Dockerfile)"
[ "$node_major" = "$expected_node_major" ] || log "WARN: Node major $node_major differs from CI-pinned $expected_node_major"
# --ignore-scripts: the root package.json 'prepare' runs 'bun run build'; skip it
# here so the explicit, guarded build below stays idempotent.
log "installing dependencies (bun install --ignore-scripts)"
bun install --ignore-scripts
# Frontend third-party references live as pinned submodules under
# packages/shared-skills/upstreams/ and are materialized into the skill at build
# time. Both steps are NON-FATAL: an offline dev still gets a working tree (the
# brand refs are simply absent locally); CI/publish run the build chain which
# materializes them with --strict so the shipped package is complete.
log "initializing provenance submodules (non-fatal)"
git submodule update --init --recursive || log "WARN: submodule init skipped (offline?); frontend brand refs will be absent locally"
log "materializing frontend references from submodules (non-fatal)"
node packages/shared-skills/scripts/materialize-frontend-refs.mjs || log "WARN: frontend refs not materialized (submodules missing?)"
if [ ! -f "$REPO_ROOT/dist/index.js" ] || [ "${OMO_AGENT_FORCE_BUILD:-0}" = "1" ]; then
log "building plugin (dist/index.js missing or OMO_AGENT_FORCE_BUILD=1)"
bun run build
else
log "dist/index.js present - skipping build (set OMO_AGENT_FORCE_BUILD=1 to force a rebuild)"
fi
log "ready. Run 'bun test' to verify, or 'source script/agent/qa-sandbox.sh' for isolated QA."