Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Consolidate Codex environment setup (#3901)

Maximilian Roose66da8e6f2f6
diff --git a/.claude/skills/running-tend/SKILL.md b/.claude/skills/running-tend/SKILL.md
index dd017b45c..9b05705fd 100644
--- a/.claude/skills/running-tend/SKILL.md
+++ b/.claude/skills/running-tend/SKILL.md
@@ -300,7 +300,7 @@ For each weekly run, check upstream and bump:
- **`baptiste0928/cargo-install@v3` blocks** in `.github/workflows/{affected,ci,coverage,nightly}.yaml` and `.github/actions/{test,tend}-setup/action.yaml` — every `version: "=X.Y.Z"` against `cargo info <crate>`. Today: `cargo-affected`, `cargo-insta`, `cargo-nextest`, `cargo-llvm-cov`, `cargo-msrv`, `cargo-udeps`, `lychee`, `worktrunk`. `cargo-affected` is pinned twice in `affected.yaml`; move both together. Verify each crate's `rust-version` against the pinned toolchain and note compatibility in the PR body (see PR #1657 for the format).
- **`hustcer/setup-nu@v3`** `version:` input — latest from `gh api repos/nushell/nushell/releases/latest --jq '.tag_name'`. Five call sites: `coverage.yaml` (`code-coverage`), `nightly.yaml` (`feature-powerset`), `benchmarks.yaml` (`benchmarks`), and `.github/actions/{test,tend}-setup/action.yaml` — `tend-setup`'s copy is what puts `nu` in the agent's sandbox, so it moves with the others.
-- **Codex Cloud tools** — `dev/codex.sh` pins pre-commit, cargo-insta, cargo-nextest, Nushell, and PowerShell; `setup-web` pins Nushell and PowerShell. Keep cargo-insta, cargo-nextest, and Nushell level with `.github/actions/test-setup/action.yaml`, which pins the same three — the gate runs `--all-features`, so Nushell's version moves PTY snapshots. Nothing under `.github/` pins PowerShell (CI runs whatever the runner image ships), so bump that one on its own.
+- **Codex Cloud tools** — `.codex/cloud.sh` pins pre-commit, cargo-insta, cargo-nextest, Nushell, and PowerShell; `setup-web` pins Nushell and PowerShell. Keep cargo-insta, cargo-nextest, and Nushell level with `.github/actions/test-setup/action.yaml`, which pins the same three — the gate runs `--all-features`, so Nushell's version moves PTY snapshots. Nothing under `.github/` pins PowerShell (CI runs whatever the runner image ships), so bump that one on its own.
- **Docs site packages** in `docs/package.json` are covered by Dependabot's `/docs` npm entry. Do not duplicate those bumps in this manual pin pass. The one thing that pass does own is the `ignore` entry for `typescript` majors in `.github/dependabot.yaml`: it suppresses the proposal Dependabot would otherwise make, so nothing else can surface it. Check `npm view @astrojs/check peerDependencies.typescript` against the current `typescript` major and delete the entry once the range covers it — the rule is version-agnostic, so left in place it blocks a major `@astrojs/check` fully supports just as silently as the TypeScript 7 it was added for (#3877).
- **Runner images** — `ubuntu-24.04`, `macos-15`, `windows-2022`. Keep `windows-2022` pinned (actions/runner-images#12677 — windows-2025 lacks the D: drive).
diff --git a/.codex/cloud.sh b/.codex/cloud.sh
new file mode 100755
index 000000000..43d13fbd4
--- /dev/null
+++ b/.codex/cloud.sh
@@ -0,0 +1,80 @@
+#!/usr/bin/env bash
+# Codex Cloud environment for worktrunk's test suite.
+#
+# The environment uses the `universal` image, caching, unrestricted internet,
+# and no variables or secrets. Configure its settings fields with these
+# commands. `dev/codex.sh` remains a supported forwarding entry point for
+# settings that still name that path:
+#
+# bash .codex/cloud.sh setup
+# bash .codex/cloud.sh maintain
+#
+# Validate a built environment with `cargo run -- hook pre-merge --yes`.
+#
+# The universal image is missing the shells, tools, and git version the suite
+# needs. `setup` installs them; `maintain` re-warms the toolchain and caches for
+# an environment restored from cache. Both run as root, which is how Codex Cloud
+# runs the agent — so the tests that need an unprivileged uid skip, as they
+# already do under `task setup-web`. The standing TODO is in
+# tests/integration_tests/approval_pty.rs.
+#
+# The gate runs `--all-features`, so nu and pwsh drive PTY snapshots their own
+# versions can move. cargo-insta, cargo-nextest, and nu are kept level with the
+# pins in .github/actions/test-setup/action.yaml. CI has no pwsh pin — it takes
+# whatever the runner image ships — so that version answers to nothing but this
+# file.
+
+set -euo pipefail
+
+PRE_COMMIT_VERSION=4.6.2
+INSTA_VERSION=1.48.0
+NEXTEST_VERSION=0.9.143
+NU_VERSION=0.115.0
+PWSH_VERSION=7.6.5
+
+cd "$(dirname "${BASH_SOURCE[0]}")/.."
+
+setup() {
+ export DEBIAN_FRONTEND=noninteractive
+
+ apt-get update -qq
+ apt-get install -y -qq --no-install-recommends software-properties-common
+ add-apt-repository -y ppa:git-core/ppa
+ apt-get update -qq
+ apt-get install -y -qq --no-install-recommends git zsh fish xz-utils lsof
+
+ uv tool install --force pre-commit=="$PRE_COMMIT_VERSION"
+
+ tmp="$(mktemp -d)"
+ curl -fsSL "https://github.com/mitsuhiko/insta/releases/download/$INSTA_VERSION/cargo-insta-x86_64-unknown-linux-gnu.tar.xz" | tar -xJ -C "$tmp"
+ install -D -m 0755 "$tmp/cargo-insta-x86_64-unknown-linux-gnu/cargo-insta" /root/.local/bin/cargo-insta
+ curl -fsSL "https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-$NEXTEST_VERSION/cargo-nextest-$NEXTEST_VERSION-x86_64-unknown-linux-gnu.tar.gz" | tar -xz -C "$tmp"
+ install -D -m 0755 "$tmp/cargo-nextest" /root/.local/bin/cargo-nextest
+ curl -fsSL "https://github.com/nushell/nushell/releases/download/$NU_VERSION/nu-$NU_VERSION-x86_64-unknown-linux-gnu.tar.gz" | tar -xz -C "$tmp"
+ install -D -m 0755 "$tmp/nu-$NU_VERSION-x86_64-unknown-linux-gnu/nu" /root/.local/bin/nu
+ rm -r -- "$tmp"
+
+ install -d /opt/microsoft/powershell/7
+ curl -fsSL "https://github.com/PowerShell/PowerShell/releases/download/v$PWSH_VERSION/powershell-$PWSH_VERSION-linux-x64.tar.gz" | tar -xz -C /opt/microsoft/powershell/7
+ chmod 0755 /opt/microsoft/powershell/7/pwsh
+ ln -sf /opt/microsoft/powershell/7/pwsh /usr/local/bin/pwsh
+ # pwsh needs the image's libicu, and without it lands on PATH but aborts at
+ # startup — so run it rather than looking for it.
+ pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
+
+ # A stale git fails the suite obscurely; fail here instead.
+ dpkg --compare-versions "$(git version | awk '{print $3}')" ge 2.54.0
+ git config --system --add safe.directory "$PWD"
+}
+
+maintain() {
+ rustup component add rust-docs
+ pre-commit install-hooks
+ cargo fetch --locked
+}
+
+case "${1-}" in
+ setup) setup; maintain ;;
+ maintain) maintain ;;
+ *) echo "usage: bash .codex/cloud.sh setup|maintain" >&2; exit 1 ;;
+esac
diff --git a/.codex/environments/environment.toml b/.codex/environments/environment.toml
new file mode 100644
index 000000000..e3c53c8b2
--- /dev/null
+++ b/.codex/environments/environment.toml
@@ -0,0 +1,7 @@
+# Codex desktop environment. Codex Cloud uses .codex/cloud.sh.
+# Project hooks require prior Worktrunk approval and continue in the background.
+version = 1
+name = "Worktrunk"
+
+[setup]
+script = "wt hook post-start"
diff --git a/CLAUDE.md b/CLAUDE.md
index bcb02144b..de9e0ef26 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -7,7 +7,7 @@ cargo run -- hook pre-merge --yes # all tests + lints (runs automatically in w
```
Claude Code web: run `task setup-web` first. Test commands, isolation, and coverage investigation: `tests/CLAUDE.md`.
-Codex Cloud: use the setup in `dev/codex.sh`.
+Codex Cloud: use the setup in `.codex/cloud.sh`.
## Project Status
diff --git a/dev/codex.sh b/dev/codex.sh
index c15ef6133..4cf3fcd09 100755
--- a/dev/codex.sh
+++ b/dev/codex.sh
@@ -1,79 +1,4 @@
#!/usr/bin/env bash
-# Codex Cloud environment for worktrunk's test suite.
-#
-# The environment uses the `universal` image, caching, unrestricted internet,
-# and no variables or secrets. Its two settings fields hold these commands, so
-# they stay short and fixed across changes to this file:
-#
-# bash dev/codex.sh setup
-# bash dev/codex.sh maintain
-#
-# Validate a built environment with `cargo run -- hook pre-merge --yes`.
-#
-# The universal image is missing the shells, tools, and git version the suite
-# needs. `setup` installs them; `maintain` re-warms the toolchain and caches for
-# an environment restored from cache. Both run as root, which is how Codex Cloud
-# runs the agent — so the tests that need an unprivileged uid skip, as they
-# already do under `task setup-web`. The standing TODO is in
-# tests/integration_tests/approval_pty.rs.
-#
-# The gate runs `--all-features`, so nu and pwsh drive PTY snapshots their own
-# versions can move. cargo-insta, cargo-nextest, and nu are kept level with the
-# pins in .github/actions/test-setup/action.yaml. CI has no pwsh pin — it takes
-# whatever the runner image ships — so that version answers to nothing but this
-# file.
+# Supported forwarding entry point for Codex Cloud settings that use this path.
-set -euo pipefail
-
-PRE_COMMIT_VERSION=4.6.2
-INSTA_VERSION=1.48.0
-NEXTEST_VERSION=0.9.143
-NU_VERSION=0.115.0
-PWSH_VERSION=7.6.5
-
-cd "$(dirname "${BASH_SOURCE[0]}")/.."
-
-setup() {
- export DEBIAN_FRONTEND=noninteractive
-
- apt-get update -qq
- apt-get install -y -qq --no-install-recommends software-properties-common
- add-apt-repository -y ppa:git-core/ppa
- apt-get update -qq
- apt-get install -y -qq --no-install-recommends git zsh fish xz-utils lsof
-
- uv tool install --force pre-commit=="$PRE_COMMIT_VERSION"
-
- tmp="$(mktemp -d)"
- curl -fsSL "https://github.com/mitsuhiko/insta/releases/download/$INSTA_VERSION/cargo-insta-x86_64-unknown-linux-gnu.tar.xz" | tar -xJ -C "$tmp"
- install -D -m 0755 "$tmp/cargo-insta-x86_64-unknown-linux-gnu/cargo-insta" /root/.local/bin/cargo-insta
- curl -fsSL "https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-$NEXTEST_VERSION/cargo-nextest-$NEXTEST_VERSION-x86_64-unknown-linux-gnu.tar.gz" | tar -xz -C "$tmp"
- install -D -m 0755 "$tmp/cargo-nextest" /root/.local/bin/cargo-nextest
- curl -fsSL "https://github.com/nushell/nushell/releases/download/$NU_VERSION/nu-$NU_VERSION-x86_64-unknown-linux-gnu.tar.gz" | tar -xz -C "$tmp"
- install -D -m 0755 "$tmp/nu-$NU_VERSION-x86_64-unknown-linux-gnu/nu" /root/.local/bin/nu
- rm -r -- "$tmp"
-
- install -d /opt/microsoft/powershell/7
- curl -fsSL "https://github.com/PowerShell/PowerShell/releases/download/v$PWSH_VERSION/powershell-$PWSH_VERSION-linux-x64.tar.gz" | tar -xz -C /opt/microsoft/powershell/7
- chmod 0755 /opt/microsoft/powershell/7/pwsh
- ln -sf /opt/microsoft/powershell/7/pwsh /usr/local/bin/pwsh
- # pwsh needs the image's libicu, and without it lands on PATH but aborts at
- # startup — so run it rather than looking for it.
- pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
-
- # A stale git fails the suite obscurely; fail here instead.
- dpkg --compare-versions "$(git version | awk '{print $3}')" ge 2.54.0
- git config --system --add safe.directory "$PWD"
-}
-
-maintain() {
- rustup component add rust-docs
- pre-commit install-hooks
- cargo fetch --locked
-}
-
-case "${1-}" in
- setup) setup; maintain ;;
- maintain) maintain ;;
- *) echo "usage: ${BASH_SOURCE[0]} setup|maintain" >&2; exit 1 ;;
-esac
+exec "$(dirname "${BASH_SOURCE[0]}")/../.codex/cloud.sh" "$@"