Repository navigation
Expand file tree
/
Copy pathtask
More file actions
executable file
·178 lines (166 loc) · 8.09 KB
/
Copy pathtask
File metadata and controls
executable file
·178 lines (166 loc) · 8.09 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
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Local development commands for DOXA Rust 2.0.
set -eu
fail() { printf 'task: %s\n' "$*" >&2; exit 1; }
info() { printf 'task: %s\n' "$*" >&2; }
case $0 in
*/*) script_dir=${0%/*} ;;
*) script_dir=. ;;
esac
root=$(CDPATH= cd -- "$script_dir" && pwd -P) || fail 'cannot find repository root'
tui_manifest=$root/rust/doxa-tui/Cargo.toml
daemon_manifest=$root/rust/doxa-daemon/Cargo.toml
remote_manifest=$root/rust/doxa-remote/Cargo.toml
isolation_manifest=$root/rust/doxa-isolation/Cargo.toml
[ -f "$tui_manifest" ] && [ -f "$daemon_manifest" ] && [ -f "$remote_manifest" ] ||
fail 'run this script from the DOXA Rust source checkout'
usage() {
cat <<'EOF'
Usage: ./task COMMAND [arguments]
build [--release] Build the frontend, daemon, remote adapter and native LORE
install Build and install committed HEAD as the Rust doxa launcher
codex-provider [args] Build/install the pinned protected Codex app-server
run [doxa args] Build and run the frontend in the current directory
new [doxa args] Build and start a new session in the current directory
doctor [args] Build and check the native launch dependencies
remote serve Build and start the private Rust browser adapter
remote connect URL HOST_ID
Connect this machine's sessions to a private hub
remote tui URL Open native remote session tabs
hub Build and start the private Rust server hub
hub push-keygen Create a private VAPID key for browser background alerts
test Run all Rust crate tests
clean Remove the task's local Rust build directory
help Show this help
DOXA_TASK_TARGET_DIR defaults to <repo>/target/rust-task.
DOXA_TASK_PROFILE=release selects release binaries for run/new/doctor.
DOXA_RUST_BIN_DIR defaults to ~/.local/bin. install writes the Rust launcher
and a desktop shortcut from committed HEAD. Provider CLIs must be on PATH.
Pass --codex-bin or --claude-bin to select a provider CLI executable.
codex-provider needs Python 3 for build tooling and bootstraps a private
Rust 1.95 toolchain; installed provider dispatch is native Rust.
EOF
}
case ${DOXA_TASK_TARGET_DIR:-$root/target/rust-task} in
/*) target_dir=${DOXA_TASK_TARGET_DIR:-$root/target/rust-task} ;;
*) target_dir=$root/${DOXA_TASK_TARGET_DIR} ;;
esac
export CARGO_TARGET_DIR=$target_dir
export CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS:-2}
if [ -z "${TMPDIR:-}" ]; then
TMPDIR=${XDG_CACHE_HOME:-$HOME/.cache}/doxa/task-tmp
mkdir -p "$TMPDIR"
chmod 700 "$TMPDIR"
export TMPDIR
fi
profile=${DOXA_TASK_PROFILE:-debug}
case $profile in debug|release) : ;; *) fail 'DOXA_TASK_PROFILE must be debug or release' ;; esac
build() {
mode=$1
command -v cargo >/dev/null 2>&1 || fail 'cargo is required (install Rust first)'
mkdir -p "$target_dir"
: > "$target_dir/.doxa-task-build"
if [ "$mode" = release ]; then
info 'building release frontend, plugin worker, daemon and native LORE'
cargo build --release --locked --manifest-path "$tui_manifest" --bin doxa-rs
cargo build --release --locked --manifest-path "$tui_manifest" --bin doxa-plugin-worker
cargo build --release --locked --manifest-path "$daemon_manifest" --bin doxa-daemon
cargo build --release --locked --manifest-path "$remote_manifest" --bin doxa-remote
cargo build --release --locked --manifest-path "$isolation_manifest" --bin doxa-isolation-worker
cargo build --release --locked --manifest-path "$tui_manifest" --package lore-core --bin lore-rs
else
info 'building debug frontend, plugin worker, daemon and native LORE'
cargo build --locked --manifest-path "$tui_manifest" --bin doxa-rs
cargo build --locked --manifest-path "$tui_manifest" --bin doxa-plugin-worker
cargo build --locked --manifest-path "$daemon_manifest" --bin doxa-daemon
cargo build --locked --manifest-path "$remote_manifest" --bin doxa-remote
cargo build --locked --manifest-path "$isolation_manifest" --bin doxa-isolation-worker
cargo build --locked --manifest-path "$tui_manifest" --package lore-core --bin lore-rs
fi
}
launch() {
verb=$1
shift
build "$profile"
binary=$target_dir/$profile/doxa-rs
daemon=$target_dir/$profile/doxa-daemon
plugin_worker=$target_dir/$profile/doxa-plugin-worker
lore=$target_dir/$profile/lore-rs
[ -x "$binary" ] && [ -x "$plugin_worker" ] && [ -x "$daemon" ] && [ -x "$lore" ] || fail 'Cargo produced no runnable frontend, plugin worker, daemon or native LORE'
export DOXA_LORE_RS=$lore
export DOXA_DAEMON_BIN=$daemon
export DOXA_REMOTE_BIN=$target_dir/$profile/doxa-remote
export DOXA_ISOLATION_WORKER=$target_dir/$profile/doxa-isolation-worker
case $verb in
run) exec "$binary" "$@" ;;
*) exec "$binary" "$verb" "$@" ;;
esac
}
install_committed() {
command -v git >/dev/null 2>&1 || fail 'git is required to install this checkout'
revision=$(git -C "$root" rev-parse HEAD) || fail 'cannot resolve checkout HEAD'
if ! git -C "$root" diff --quiet || ! git -C "$root" diff --cached --quiet; then
info 'install uses committed HEAD; working-tree changes are not included'
fi
DOXA_RUST_REPO_URL="$root" sh "$root/scripts/install.sh" "$revision"
}
install_codex_provider() {
command -v python3 >/dev/null 2>&1 || fail 'Python 3 is required for provider build tooling'
case ${1:-} in
-h|--help) exec python3 "$root/scripts/install_codex_protected.py" "$@" ;;
esac
command -v cargo >/dev/null 2>&1 || fail 'cargo is required to build the native provider launcher'
cargo build --release --locked --manifest-path "$tui_manifest" \
--package doxa-engines --bin doxa-codex-protected
python3 "$root/scripts/install_codex_protected.py" \
--launcher "$target_dir/release/doxa-codex-protected" "$@"
}
command=${1:-help}
[ "$#" -eq 0 ] || shift
case $command in
help|-h|--help) [ "$#" -eq 0 ] || fail 'help takes no arguments'; usage ;;
build)
case ${1:-} in
'') [ "$#" -eq 0 ] || fail 'usage: ./task build [--release]'; build debug ;;
--release) [ "$#" -eq 1 ] || fail 'usage: ./task build [--release]'; build release ;;
*) fail 'usage: ./task build [--release]' ;;
esac ;;
install) [ "$#" -eq 0 ] || fail 'install takes no arguments'; install_committed ;;
codex-provider) install_codex_provider "$@" ;;
run|new|doctor) launch "$command" "$@" ;;
remote)
case $#:${1:-} in
1:serve|2:list|2:tui|3:connect|4:send|5:answer) launch remote "$@" ;;
*) fail 'usage: ./task remote serve | connect URL HOST_ID | tui URL | list URL | send URL SESSION TEXT | answer URL SESSION REQUEST_ID allow|deny' ;;
esac ;;
hub)
[ "$#" -eq 0 ] || { [ "$#" -eq 1 ] && [ "$1" = push-keygen ]; } || fail 'usage: ./task hub [push-keygen]'
cargo build --locked --manifest-path "$root/rust/doxa-hub/Cargo.toml" --bin doxa-hub
exec "$target_dir/debug/doxa-hub" "$@" ;;
test)
[ "$#" -eq 0 ] || fail 'test takes no arguments'
command -v cargo >/dev/null 2>&1 || fail 'cargo is required (install Rust first)'
mkdir -p "$target_dir"
: > "$target_dir/.doxa-task-build"
cargo build --locked --manifest-path "$tui_manifest" --package lore-core --bin lore-rs
export DOXA_LORE_RS=$target_dir/debug/lore-rs
[ -x "$DOXA_LORE_RS" ] || fail 'Cargo produced no native LORE executable'
for crate in doxa-tui doxa-remote doxa-hub doxa-engines doxa-lore doxa-peers doxa-protocol \
doxa-claude doxa-transcript doxa-state doxa-runtime doxa-daemon \
doxa-worktrees doxa-vendors doxa-isolation doxa-fleet; do
case $crate in
doxa-daemon|doxa-vendors)
cargo test --locked --features local-test-server \
--manifest-path "$root/rust/$crate/Cargo.toml" ;;
*) cargo test --locked --manifest-path "$root/rust/$crate/Cargo.toml" ;;
esac
done
;;
clean)
[ "$#" -eq 0 ] || fail 'clean takes no arguments'
[ -z "${DOXA_TASK_TARGET_DIR:-}" ] || fail 'clean requires the default target directory'
[ -f "$target_dir/.doxa-task-build" ] || fail 'target directory was not created by ./task'
rm -rf "$target_dir" ;;
*) fail "unknown command: $command (run ./task help)" ;;
esac