diff --git a/.github/actions/setup-ci/action.yml b/.github/actions/setup-ci/action.yml index 59f8850d27..8e95f29fa5 100644 --- a/.github/actions/setup-ci/action.yml +++ b/.github/actions/setup-ci/action.yml @@ -53,6 +53,7 @@ runs: echo "cargo-target-dir=$cargo_target_dir" >> "$GITHUB_OUTPUT" { + echo "CODEX_REPO_ROOT=$GITHUB_WORKSPACE" echo "BAZEL_OUTPUT_BASE=$bazel_output_base" echo "BAZEL_OUTPUT_USER_ROOT=$bazel_output_user_root" echo "BAZEL_REPOSITORY_CACHE=$bazel_repository_cache" diff --git a/.github/workflows/rust-release.yml b/.github/workflows/rust-release.yml index c154a8aed4..e07c23b3ba 100644 --- a/.github/workflows/rust-release.yml +++ b/.github/workflows/rust-release.yml @@ -15,6 +15,7 @@ on: - "rust-v*.*.*" env: + CODEX_REPO_ROOT: ${{ github.workspace }} CODEX_ZSH_RELEASE_TAG: codex-zsh-v0.1.0 CODEX_ZSH_MANIFEST_SHA256: c534eab89dcea7e3d8a5e5b3f49c025c7c64cd4e4d9814ee24871de58a9359a1 diff --git a/justfile b/justfile index d59e3b4e96..ec70adfc84 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,6 @@ set working-directory := "codex-rs" set positional-arguments +export CODEX_REPO_ROOT := justfile_directory() export JUST_SHELL := justfile_directory() / "scripts/just-shell.py" set shell := ["python3", "-c", 'import os, runpy; runpy.run_path(os.environ["JUST_SHELL"], run_name="__main__")'] set windows-shell := ["python", "-c", 'import os, runpy; runpy.run_path(os.environ["JUST_SHELL"], run_name="__main__")'] @@ -35,6 +36,11 @@ file-search *args: code-mode-host *args: cargo run --bin codex-code-mode-host -- {args} +# Assemble a local Codex package. +[no-cd] +assemble-codex-package *args: + {{ python }} {{ justfile_directory() }}/scripts/build_codex_package.py {args} + # Build the CLI and run the app-server test client app-server-test-client *args: cargo build -p codex-cli diff --git a/scripts/codex_package/README.md b/scripts/codex_package/README.md index 461b80e343..972659d4e6 100644 --- a/scripts/codex_package/README.md +++ b/scripts/codex_package/README.md @@ -4,6 +4,14 @@ This package contains the implementation behind `scripts/build_codex_package.py` The top-level script is the stable executable entry point; these modules keep the package-building logic split by responsibility. +Run the builder through `just`: + +```bash +just assemble-codex-package --help +just assemble-codex-package --variant codex-app-server +just assemble-codex-package --target x86_64-unknown-linux-gnu +``` + The builder creates a canonical Codex package directory: ```text diff --git a/scripts/codex_package/ripgrep.py b/scripts/codex_package/ripgrep.py index 33a484022b..155c5d323e 100644 --- a/scripts/codex_package/ripgrep.py +++ b/scripts/codex_package/ripgrep.py @@ -3,12 +3,9 @@ from pathlib import Path from .dotslash import fetch_dotslash_executable -from .targets import REPO_ROOT -from .targets import TargetSpec -from .targets import resolve_input_path +from .targets import TargetSpec, resolve_input_path - -RG_MANIFEST = REPO_ROOT / "scripts" / "codex_package" / "rg" +RG_MANIFEST = Path(__file__).with_name("rg") def resolve_rg_bin(spec: TargetSpec, rg_bin: Path | None) -> Path: diff --git a/scripts/codex_package/targets.py b/scripts/codex_package/targets.py index 016202cf5f..e217e8d0fd 100644 --- a/scripts/codex_package/targets.py +++ b/scripts/codex_package/targets.py @@ -1,13 +1,18 @@ """Supported package targets and default binary discovery.""" +import os import platform import stat from dataclasses import dataclass from pathlib import Path - -SCRIPT_DIR = Path(__file__).resolve().parents[1] -REPO_ROOT = SCRIPT_DIR.parent +_repo_root = os.environ.get("CODEX_REPO_ROOT") +if _repo_root is None: + raise RuntimeError( + "CODEX_REPO_ROOT must point to the repository root; " + "run `just assemble-codex-package` to set it automatically" + ) +REPO_ROOT = Path(_repo_root) @dataclass(frozen=True) diff --git a/scripts/codex_package/zsh.py b/scripts/codex_package/zsh.py index 35c62a3854..e4ecc2de68 100644 --- a/scripts/codex_package/zsh.py +++ b/scripts/codex_package/zsh.py @@ -3,12 +3,9 @@ from pathlib import Path from .dotslash import fetch_dotslash_executable -from .targets import REPO_ROOT -from .targets import TargetSpec -from .targets import resolve_input_path +from .targets import TargetSpec, resolve_input_path - -ZSH_MANIFEST = REPO_ROOT / "scripts" / "codex_package" / "codex-zsh" +ZSH_MANIFEST = Path(__file__).with_name("codex-zsh") ZSH_RESOURCE_PATH = Path("zsh") / "bin" / "zsh"