-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
251 lines (221 loc) · 9.84 KB
/
justfile
File metadata and controls
251 lines (221 loc) · 9.84 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
set working-directory := "codex-rs"
set positional-arguments
# Display help
help:
just -l
# `codex`
alias c := codex
codex *args:
cargo run --bin codex -- "$@"
# `codex exec`
exec *args:
cargo run --bin codex -- exec "$@"
# Start `codex exec-server` and run codex-tui.
[no-cd]
tui-with-exec-server *args:
./scripts/run_tui_with_exec_server.sh "$@"
# Run the CLI version of the file-search crate.
file-search *args:
cargo run --bin codex-file-search -- "$@"
# Build the CLI and run the app-server test client
app-server-test-client *args:
cargo build -p codex-cli
cargo run -p codex-app-server-test-client -- --codex-bin ./target/debug/codex "$@"
# format code
fmt:
cargo fmt -- --config imports_granularity=Item 2>/dev/null
fix *args:
cargo clippy --fix --tests --allow-dirty "$@"
clippy *args:
cargo clippy --tests "$@"
install:
rustup show active-toolchain
cargo fetch
# Run `cargo nextest` since it's faster than `cargo test`, though including
# --no-fail-fast is important to ensure all tests are run.
#
# Run `cargo install cargo-nextest` if you don't have it installed.
# Prefer this for routine local runs. Workspace crate features are banned, so
# there should be no need to add `--all-features`.
test:
cargo nextest run --no-fail-fast
# Build and run Codex from source using Bazel.
# Note we have to use the combination of `[no-cd]` and `--run_under="cd $PWD &&"`
# to ensure that Bazel runs the command in the current working directory.
[no-cd]
bazel-codex *args:
bazel run //codex-rs/cli:codex --run_under="cd $PWD &&" -- "$@"
[no-cd]
bazel-lock-update:
bazel mod deps --lockfile_mode=update
[no-cd]
bazel-lock-check:
./scripts/check-module-bazel-lock.sh
bazel-test:
bazel test --test_tag_filters=-argument-comment-lint //... --keep_going
[no-cd]
bazel-clippy:
bazel_targets="$(./scripts/list-bazel-clippy-targets.sh)" && bazel build --config=clippy -- ${bazel_targets}
[no-cd]
bazel-argument-comment-lint:
bazel build --config=argument-comment-lint -- $(./tools/argument-comment-lint/list-bazel-targets.sh)
bazel-remote-test:
bazel test --test_tag_filters=-argument-comment-lint //... --config=remote --platforms=//:rbe --keep_going
build-for-release:
bazel build //codex-rs/cli:release_binaries --config=remote
# Build a machine-local codex binary with reasonable runtime-focused tuning on
# top of the existing release profile. This keeps the build to a single pass
# and intentionally skips PGO.
#
# Intended for homogeneous local boxes or clusters where `target-cpu=native`
# is acceptable.
#
# Optional environment variables:
# CODEX_PERF_EXTRA_FLAGS='...' append extra rustc flags
# CODEX_PERF_FEATURES='...' pass cargo features to codex-cli
#
# Each perf build prunes `./target` back down to `./target/release/codex` so a
# PATH entry or symlink targeting that binary keeps working without retaining
# the full build tree.
perf-build-local:
#!/usr/bin/env bash
set -euo pipefail
export CARGO_PROFILE_RELEASE_PANIC=abort
EXTRA_FLAGS="${CODEX_PERF_EXTRA_FLAGS:-}"
export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-C target-cpu=native${EXTRA_FLAGS:+ $EXTRA_FLAGS}"
if [ -n "${CODEX_PERF_FEATURES:-}" ]; then
cargo build -p codex-cli --release --locked --features "$CODEX_PERF_FEATURES"
else
cargo build -p codex-cli --release --locked
fi
./scripts/prune_perf_build_target.sh ./target/release/codex
# Build a machine-local codex binary using profile-guided optimization on top
# of the same local tuning as `perf-build-local`.
#
# Optional environment variables:
# CODEX_PGO_DIR='...' override the temporary profile data directory
# CODEX_PGO_TRAIN='...' extra representative training commands to run
# CODEX_PERF_EXTRA_FLAGS='...' append extra rustc flags
# CODEX_PERF_FEATURES='...' pass cargo features to codex-cli
perf-build-local-pgo:
#!/usr/bin/env bash
set -euo pipefail
export CARGO_PROFILE_RELEASE_PANIC=abort
PGO_DIR="${CODEX_PGO_DIR:-${TMPDIR:-/tmp}/codex-pgo}"
rm -rf "$PGO_DIR"
mkdir -p "$PGO_DIR"
LLVM_PROFDATA="$(command -v llvm-profdata || true)"
if [ -z "$LLVM_PROFDATA" ]; then
RUST_HOST="$(rustc -vV | sed -n 's/^host: //p')"
RUST_LLVM_PROFDATA="$(rustc --print sysroot)/lib/rustlib/$RUST_HOST/bin/llvm-profdata"
if [ -x "$RUST_LLVM_PROFDATA" ]; then
LLVM_PROFDATA="$RUST_LLVM_PROFDATA"
fi
fi
if [ -z "$LLVM_PROFDATA" ] && command -v xcrun >/dev/null 2>&1; then
LLVM_PROFDATA="$(xcrun --find llvm-profdata 2>/dev/null || true)"
fi
if [ -z "$LLVM_PROFDATA" ]; then
echo "llvm-profdata not found; install llvm-tools-preview or add llvm-profdata to PATH" >&2
exit 127
fi
EXTRA_FLAGS="${CODEX_PERF_EXTRA_FLAGS:-}"
COMMON_RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-C target-cpu=native${EXTRA_FLAGS:+ $EXTRA_FLAGS}"
if [ -n "${CODEX_PERF_FEATURES:-}" ]; then
RUSTFLAGS="$COMMON_RUSTFLAGS -C profile-generate=$PGO_DIR" cargo build -p codex-cli --release --locked --features "$CODEX_PERF_FEATURES"
else
RUSTFLAGS="$COMMON_RUSTFLAGS -C profile-generate=$PGO_DIR" cargo build -p codex-cli --release --locked
fi
./target/release/codex --help >/dev/null
./target/release/codex exec --help >/dev/null
./target/release/codex mcp --help >/dev/null
if [ -n "${CODEX_PGO_TRAIN:-}" ]; then sh -lc "$CODEX_PGO_TRAIN"; fi
"$LLVM_PROFDATA" merge -output="$PGO_DIR/merged.profdata" "$PGO_DIR"
if [ -n "${CODEX_PERF_FEATURES:-}" ]; then
RUSTFLAGS="$COMMON_RUSTFLAGS -C profile-use=$PGO_DIR/merged.profdata -C llvm-args=-pgo-warn-missing-function" cargo build -p codex-cli --release --locked --features "$CODEX_PERF_FEATURES"
else
RUSTFLAGS="$COMMON_RUSTFLAGS -C profile-use=$PGO_DIR/merged.profdata -C llvm-args=-pgo-warn-missing-function" cargo build -p codex-cli --release --locked
fi
./scripts/prune_perf_build_target.sh ./target/release/codex
# Build a reproducible local binary tuned specifically for Apple M3 machines.
# This is functionally similar to `perf-build-local` on this Mac, but pins the
# CPU target instead of relying on `native`.
perf-build-m3:
#!/usr/bin/env bash
set -euo pipefail
export CARGO_PROFILE_RELEASE_PANIC=abort
EXTRA_FLAGS="${CODEX_PERF_EXTRA_FLAGS:-}"
export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-C target-cpu=apple-m3${EXTRA_FLAGS:+ $EXTRA_FLAGS}"
if [ -n "${CODEX_PERF_FEATURES:-}" ]; then
cargo build -p codex-cli --release --locked --features "$CODEX_PERF_FEATURES"
else
cargo build -p codex-cli --release --locked
fi
./scripts/prune_perf_build_target.sh ./target/release/codex
# Build an Apple M3-tuned codex binary using profile-guided optimization.
perf-build-m3-pgo:
#!/usr/bin/env bash
set -euo pipefail
export CARGO_PROFILE_RELEASE_PANIC=abort
PGO_DIR="${CODEX_PGO_DIR:-${TMPDIR:-/tmp}/codex-pgo-m3}"
rm -rf "$PGO_DIR"
mkdir -p "$PGO_DIR"
LLVM_PROFDATA="$(command -v llvm-profdata || true)"
if [ -z "$LLVM_PROFDATA" ]; then
RUST_HOST="$(rustc -vV | sed -n 's/^host: //p')"
RUST_LLVM_PROFDATA="$(rustc --print sysroot)/lib/rustlib/$RUST_HOST/bin/llvm-profdata"
if [ -x "$RUST_LLVM_PROFDATA" ]; then
LLVM_PROFDATA="$RUST_LLVM_PROFDATA"
fi
fi
if [ -z "$LLVM_PROFDATA" ] && command -v xcrun >/dev/null 2>&1; then
LLVM_PROFDATA="$(xcrun --find llvm-profdata 2>/dev/null || true)"
fi
if [ -z "$LLVM_PROFDATA" ]; then
echo "llvm-profdata not found; install llvm-tools-preview or add llvm-profdata to PATH" >&2
exit 127
fi
EXTRA_FLAGS="${CODEX_PERF_EXTRA_FLAGS:-}"
COMMON_RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-C target-cpu=apple-m3${EXTRA_FLAGS:+ $EXTRA_FLAGS}"
if [ -n "${CODEX_PERF_FEATURES:-}" ]; then
RUSTFLAGS="$COMMON_RUSTFLAGS -C profile-generate=$PGO_DIR" cargo build -p codex-cli --release --locked --features "$CODEX_PERF_FEATURES"
else
RUSTFLAGS="$COMMON_RUSTFLAGS -C profile-generate=$PGO_DIR" cargo build -p codex-cli --release --locked
fi
./target/release/codex --help >/dev/null
./target/release/codex exec --help >/dev/null
./target/release/codex mcp --help >/dev/null
if [ -n "${CODEX_PGO_TRAIN:-}" ]; then sh -lc "$CODEX_PGO_TRAIN"; fi
"$LLVM_PROFDATA" merge -output="$PGO_DIR/merged.profdata" "$PGO_DIR"
if [ -n "${CODEX_PERF_FEATURES:-}" ]; then
RUSTFLAGS="$COMMON_RUSTFLAGS -C profile-use=$PGO_DIR/merged.profdata -C llvm-args=-pgo-warn-missing-function" cargo build -p codex-cli --release --locked --features "$CODEX_PERF_FEATURES"
else
RUSTFLAGS="$COMMON_RUSTFLAGS -C profile-use=$PGO_DIR/merged.profdata -C llvm-args=-pgo-warn-missing-function" cargo build -p codex-cli --release --locked
fi
./scripts/prune_perf_build_target.sh ./target/release/codex
# Run the MCP server
mcp-server-run *args:
cargo run -p codex-mcp-server -- "$@"
# Regenerate the json schema for config.toml from the current config types.
write-config-schema:
cargo run -p codex-core --bin codex-write-config-schema
# Regenerate vendored app-server protocol schema artifacts.
write-app-server-schema *args:
cargo run -p codex-app-server-protocol --bin write_schema_fixtures -- "$@"
[no-cd]
write-hooks-schema:
cargo run --manifest-path ./codex-rs/Cargo.toml -p codex-hooks --bin write_hooks_schema_fixtures
# Run the argument-comment Dylint checks across codex-rs.
[no-cd]
argument-comment-lint *args:
if [ "$#" -eq 0 ]; then \
bazel build --config=argument-comment-lint -- $(./tools/argument-comment-lint/list-bazel-targets.sh); \
else \
./tools/argument-comment-lint/run-prebuilt-linter.py "$@"; \
fi
[no-cd]
argument-comment-lint-from-source *args:
./tools/argument-comment-lint/run.py "$@"
# Tail logs from the state SQLite database
log *args:
if [ "${1:-}" = "--" ]; then shift; fi; cargo run -p codex-state --bin logs_client -- "$@"