npm: ship platform packages in Codex package layout

## Summary

The npm platform packages should stop carrying a bespoke native layout now that the release workflow builds canonical Codex package archives. Keeping npm on the same `bin/`, `codex-resources/`, and `codex-path/` structure lets the Rust package-layout detection behave consistently across standalone, npm, and future DotSlash installs.

This changes platform npm packages to stage the `codex-package` artifact for each target under `vendor/<target>`. The Node launcher now resolves `bin/codex` and prepends `codex-path`, while retaining legacy `vendor/<target>/codex` and `vendor/<target>/path` fallback support for local development and migration. The npm staging helper downloads `codex-package` archives instead of rebuilding the CLI payload from individual `codex`, `rg`, `bwrap`, and sandbox helper artifacts.

CI still needs to stage npm packages from historical rust-release workflow artifacts that predate package archives, so the staging scripts now expose an explicit `--allow-legacy-codex-package` fallback. That fallback synthesizes the canonical package layout from legacy per-binary artifacts and is wired only into the CI smoke path; release staging remains strict and continues to require real package archives.

## Test plan

- `python3 -m py_compile codex-cli/scripts/build_npm_package.py codex-cli/scripts/install_native_deps.py scripts/stage_npm_packages.py scripts/codex_package/cli.py`
- `node --check codex-cli/bin/codex.js`
- `ruby -e 'require "yaml"; YAML.load_file(".github/workflows/rust-release.yml"); YAML.load_file(".github/workflows/ci.yml"); puts "ok"'`
- Staged a synthetic `codex-linux-x64` platform package from a canonical vendor tree and verified it copied only `bin/`, `codex-path/`, `codex-resources/`, and `codex-package.json`.
- Imported `install_native_deps.py` and extracted a synthetic `codex-package-x86_64-unknown-linux-musl.tar.gz` into `vendor/<target>`.
- Ran legacy-layout conversion smokes for Linux, Windows, and unsigned macOS artifact naming.
- `NPM_CONFIG_CACHE="$tmp_dir/npm-cache" python3 ./scripts/stage_npm_packages.py --release-version 0.125.0 --workflow-url https://github.com/openai/codex/actions/runs/26131514935 --package codex --allow-legacy-codex-package --output-dir "$tmp_dir"`
- `node codex-cli/bin/codex.js --version`
This commit is contained in:
Michael Bolin
2026-05-20 08:48:10 -07:00
parent 394773ab80
commit b729eadbf1
7 changed files with 307 additions and 64 deletions
+19 -3
View File
@@ -1,8 +1,6 @@
#!/usr/bin/env python3
"""Stage one or more Codex npm packages for release."""
from __future__ import annotations
import argparse
import importlib.util
import json
@@ -68,6 +66,15 @@ def parse_args() -> argparse.Namespace:
"Intended for CI compatibility only; release staging should not use this."
),
)
parser.add_argument(
"--allow-legacy-codex-package",
action="store_true",
help=(
"Allow codex-package layouts to be synthesized from legacy per-binary "
"workflow artifacts. Intended for CI compatibility only; release staging "
"should not use this."
),
)
return parser.parse_args()
@@ -124,11 +131,15 @@ def install_native_components(
workflow_url: str,
components: set[str],
vendor_root: Path,
*,
allow_legacy_codex_package: bool,
) -> None:
if not components:
return
cmd = [str(INSTALL_NATIVE_DEPS), "--workflow-url", workflow_url]
if allow_legacy_codex_package:
cmd.append("--allow-legacy-codex-package")
for component in sorted(components):
cmd.extend(["--component", component])
cmd.append(str(vendor_root))
@@ -172,7 +183,12 @@ def main() -> int:
args.release_version, args.workflow_url
)
vendor_temp_root = Path(tempfile.mkdtemp(prefix="npm-native-", dir=runner_temp))
install_native_components(workflow_url, native_components_to_install, vendor_temp_root)
install_native_components(
workflow_url,
native_components_to_install,
vendor_temp_root,
allow_legacy_codex_package=args.allow_legacy_codex_package,
)
vendor_src = vendor_temp_root / "vendor"
if resolved_head_sha: