-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·144 lines (123 loc) · 3.98 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·144 lines (123 loc) · 3.98 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
#!/usr/bin/env bash
set -euo pipefail
repository_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
workbench_root="$repository_root/apps/workbench"
kura_manifest="$workbench_root/vendor/kura/crates/Cargo.toml"
rebuild_agent=0
rebuild_kura=0
prepare_only=0
usage() {
cat <<'EOF'
Usage: ./dev.sh [options]
Start the Loopforge Workbench development environment from the repository root.
Missing dependencies and sidecars are prepared automatically. Existing sidecars
are reused so frontend development keeps its fast Vite hot-reload loop.
Options:
--rebuild-agent Rebuild the Loopforge Agent sidecar before starting.
--rebuild-kura Rebuild the Kura sidecar before starting.
--rebuild-sidecars Rebuild both sidecars before starting.
--prepare-only Prepare dependencies and sidecars, then exit.
-h, --help Show this help message.
EOF
}
fail() {
printf 'dev.sh: %s\n' "$1" >&2
exit 1
}
require_command() {
command -v "$1" >/dev/null 2>&1 || fail "required command not found: $1"
}
while (($# > 0)); do
case "$1" in
--rebuild-agent)
rebuild_agent=1
;;
--rebuild-kura)
rebuild_kura=1
;;
--rebuild-sidecars)
rebuild_agent=1
rebuild_kura=1
;;
--prepare-only)
prepare_only=1
;;
-h | --help)
usage
exit 0
;;
*)
usage >&2
fail "unknown option: $1"
;;
esac
shift
done
require_command pnpm
require_command cargo
if [[ ! -f "$kura_manifest" ]]; then
require_command git
printf 'Initializing the pinned Kura submodule...\n'
git -C "$repository_root" submodule update --init --recursive -- \
apps/workbench/vendor/kura
fi
[[ -f "$kura_manifest" ]] || fail "Kura submodule initialization did not produce $kura_manifest"
cd "$workbench_root"
printf 'Checking Workbench dependencies...\n'
pnpm install --frozen-lockfile
executable_suffix=""
if [[ "${OS:-}" == "Windows_NT" ]]; then
executable_suffix=".exe"
fi
kura_binary="$workbench_root/resources/kura$executable_suffix"
agent_binary="$workbench_root/resources/loopforge-agent$executable_suffix"
sidecar_ready() {
if [[ -n "$executable_suffix" ]]; then
[[ -f "$1" ]]
else
[[ -x "$1" ]]
fi
}
# The Kura sidecar is only reusable if it was built from the submodule commit
# currently checked out. A stale binary from before a submodule bump can still
# start and then fail in confusing ways, so treat a mismatch as not-ready.
kura_sidecar_current() {
sidecar_ready "$kura_binary" || return 1
local stamp="$workbench_root/resources/kura.build.json"
[[ -f "$stamp" ]] || return 1
local built current
built="$(sed -n 's/.*"commit"[[:space:]]*:[[:space:]]*"\([0-9a-f]*\)".*/\1/p' "$stamp")"
current="$(git -C "$workbench_root/vendor/kura" rev-parse HEAD 2>/dev/null)" || return 1
[[ -n "$built" && "$built" == "$current" ]]
}
if ((rebuild_kura == 1)) || ! kura_sidecar_current; then
printf 'Building the Kura sidecar...\n'
pnpm build:kura
else
printf 'Reusing Kura sidecar: %s\n' "$kura_binary"
fi
# The Agent sidecar has no commit stamp to compare against -- it is built from
# the working tree, not a pinned submodule -- so freshness is judged by whether
# any source file is newer than the binary. Without this the launcher happily
# reused a sidecar two days older than the code, and every endpoint added in
# between was simply absent with no indication why.
agent_sidecar_current() {
sidecar_ready "$agent_binary" || return 1
local newer
newer="$(find "$repository_root/apps/agent" "$repository_root/cli" \
-name '*.py' -newer "$agent_binary" -print -quit 2>/dev/null)"
[[ -z "$newer" ]]
}
if ((rebuild_agent == 1)) || ! agent_sidecar_current; then
require_command uv
printf 'Building the Loopforge Agent sidecar...\n'
pnpm build:agent
else
printf 'Reusing Loopforge Agent sidecar: %s\n' "$agent_binary"
fi
if ((prepare_only == 1)); then
printf 'Development environment is ready.\n'
exit 0
fi
printf 'Starting Loopforge Workbench with frontend hot reload...\n'
exec pnpm dev:desktop