Skip to content

Commit d40a5cb

Browse files
committed
Document npm install for open-codex
1 parent 3a94db8 commit d40a5cb

6 files changed

Lines changed: 97 additions & 48 deletions

File tree

README.md

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</p>
1010

1111
<p align="center">
12-
<code>codex</code> remains the command name, and <code>@openai/codex</code> remains the compatibility target for the current CLI surface.
12+
Install with <code>npm install -g @leonw24/open-codex</code>, then run <code>open-codex</code>.
1313
</p>
1414

1515
<p align="center">
@@ -115,15 +115,29 @@ The intent of this repository is to keep development open and reviewable in publ
115115

116116
## Compatibility Notes
117117

118-
This fork keeps the current Codex CLI naming surface intact:
118+
This fork keeps the native Codex CLI implementation close to upstream, but the npm distribution uses fork-specific names so it can coexist with the official package:
119119

120-
- command name: `codex`
121-
- package naming target: `@openai/codex`
120+
- npm package: `@leonw24/open-codex`
121+
- npm command: `open-codex`
122+
- native binary identity: `codex-cli`
122123

123-
That means the README, docs, and fork messaging are intentionally about the project identity and maintenance model, not a wholesale rename of the CLI interface.
124+
That means installing this fork from npm does not overwrite the official `codex` command from `@openai/codex`.
124125

125126
## Quickstart
126127

128+
### Option A: install from npm
129+
130+
The npm package is published under the `leonw24` scope:
131+
132+
```shell
133+
npm install -g @leonw24/open-codex
134+
open-codex --version
135+
```
136+
137+
The current npm payload is published for Linux x64. For other platforms, build from source until this fork publishes platform artifacts for macOS, Windows, and Linux arm64.
138+
139+
### Option B: build from source
140+
127141
If you want to use this fork from source, build the Rust workspace and install the resulting binary locally.
128142

129143
```shell
@@ -135,21 +149,21 @@ cargo build --release
135149

136150
Then choose one of these install modes:
137151

138-
### Option A: replace your local `codex`
152+
#### Replace your local `codex`
139153

140154
```shell
141155
mkdir -p ~/.local/bin
142156
install -m 755 target/release/codex ~/.local/bin/codex
143157
```
144158

145-
### Option B: install this fork as `codex-dev`
159+
#### Install this fork as `open-codex`
146160

147161
```shell
148162
mkdir -p ~/.local/bin
149-
install -m 755 target/release/codex ~/.local/bin/codex-dev
163+
install -m 755 target/release/codex ~/.local/bin/open-codex
150164
```
151165

152-
After that, run either `codex` or `codex-dev`, depending on which install path you chose.
166+
After that, run either `codex` or `open-codex`, depending on which install path you chose.
153167

154168
## Docs
155169

@@ -255,15 +269,29 @@ Codex CLI 是开源的,但上游仓库当前对外部代码贡献采用 invita
255269

256270
## 兼容性说明
257271

258-
这个 fork 保留当前 Codex CLI 的命名表面
272+
这个 fork 的原生 CLI 实现尽量贴近 upstream,但 npm 分发使用 fork 自己的命名,这样可以和官方包共存
259273

260-
- 命令名仍然是:`codex`
261-
- 当前兼容的包命名目标仍然是:`@openai/codex`
274+
- npm 包名:`@leonw24/open-codex`
275+
- npm 命令名:`open-codex`
276+
- 原生二进制身份:`codex-cli`
262277

263-
也就是说,这份 README 的重点是项目身份和维护方式,而不是把 CLI 的命令名整体重命名掉
278+
也就是说,通过 npm 安装这个 fork 不会覆盖官方 `@openai/codex` 提供的 `codex` 命令
264279

265280
## Quickstart
266281

282+
### 方式 A:通过 npm 安装
283+
284+
npm 包发布在 `leonw24` scope 下:
285+
286+
```shell
287+
npm install -g @leonw24/open-codex
288+
open-codex --version
289+
```
290+
291+
当前 npm payload 已发布 Linux x64 版本。macOS、Windows 和 Linux arm64 在发布对应平台 artifact 之前,请先使用源码构建方式安装。
292+
293+
### 方式 B:从源码构建
294+
267295
如果你想从源码使用这个 fork,可以先构建 Rust workspace,再把产出的二进制安装到本地。
268296

269297
```shell
@@ -275,21 +303,21 @@ cargo build --release
275303

276304
然后在下面两种安装方式中选一个:
277305

278-
### 方式 A:直接覆盖你本地的 `codex`
306+
#### 直接覆盖你本地的 `codex`
279307

280308
```shell
281309
mkdir -p ~/.local/bin
282310
install -m 755 target/release/codex ~/.local/bin/codex
283311
```
284312

285-
### 方式 B:并行安装为 `codex-dev`
313+
#### 并行安装为 `open-codex`
286314

287315
```shell
288316
mkdir -p ~/.local/bin
289-
install -m 755 target/release/codex ~/.local/bin/codex-dev
317+
install -m 755 target/release/codex ~/.local/bin/open-codex
290318
```
291319

292-
之后根据你的安装方式,运行 `codex``codex-dev` 即可。
320+
之后根据你的安装方式,运行 `codex``open-codex` 即可。
293321

294322
## 文档
295323

codex-cli/bin/codex.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ const __dirname = path.dirname(__filename);
1313
const require = createRequire(import.meta.url);
1414

1515
const PLATFORM_PACKAGE_BY_TARGET = {
16-
"x86_64-unknown-linux-musl": "@openai/codex-linux-x64",
17-
"aarch64-unknown-linux-musl": "@openai/codex-linux-arm64",
18-
"x86_64-apple-darwin": "@openai/codex-darwin-x64",
19-
"aarch64-apple-darwin": "@openai/codex-darwin-arm64",
20-
"x86_64-pc-windows-msvc": "@openai/codex-win32-x64",
21-
"aarch64-pc-windows-msvc": "@openai/codex-win32-arm64",
16+
"x86_64-unknown-linux-gnu": "@leonw24/open-codex-linux-x64",
17+
"aarch64-unknown-linux-gnu": "@leonw24/open-codex-linux-arm64",
18+
"x86_64-apple-darwin": "@leonw24/open-codex-darwin-x64",
19+
"aarch64-apple-darwin": "@leonw24/open-codex-darwin-arm64",
20+
"x86_64-pc-windows-msvc": "@leonw24/open-codex-win32-x64",
21+
"aarch64-pc-windows-msvc": "@leonw24/open-codex-win32-arm64",
2222
};
2323

2424
const { platform, arch } = process;
@@ -29,10 +29,10 @@ switch (platform) {
2929
case "android":
3030
switch (arch) {
3131
case "x64":
32-
targetTriple = "x86_64-unknown-linux-musl";
32+
targetTriple = "x86_64-unknown-linux-gnu";
3333
break;
3434
case "arm64":
35-
targetTriple = "aarch64-unknown-linux-musl";
35+
targetTriple = "aarch64-unknown-linux-gnu";
3636
break;
3737
default:
3838
break;
@@ -95,8 +95,8 @@ try {
9595
const packageManager = detectPackageManager();
9696
const updateCommand =
9797
packageManager === "bun"
98-
? "bun install -g @openai/codex@latest"
99-
: "npm install -g @openai/codex@latest";
98+
? "bun install -g @leonw24/open-codex@latest"
99+
: "npm install -g @leonw24/open-codex@latest";
100100
throw new Error(
101101
`Missing optional dependency ${platformPackage}. Reinstall Codex: ${updateCommand}`,
102102
);
@@ -107,8 +107,8 @@ if (!vendorRoot) {
107107
const packageManager = detectPackageManager();
108108
const updateCommand =
109109
packageManager === "bun"
110-
? "bun install -g @openai/codex@latest"
111-
: "npm install -g @openai/codex@latest";
110+
? "bun install -g @leonw24/open-codex@latest"
111+
: "npm install -g @leonw24/open-codex@latest";
112112
throw new Error(
113113
`Missing optional dependency ${platformPackage}. Reinstall Codex: ${updateCommand}`,
114114
);

codex-cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "@openai/codex",
2+
"name": "@leonw24/open-codex",
33
"version": "0.124.0-leon",
44
"license": "Apache-2.0",
55
"bin": {
6-
"codex": "bin/codex.js"
6+
"open-codex": "bin/codex.js"
77
},
88
"type": "module",
99
"engines": {
@@ -15,7 +15,7 @@
1515
],
1616
"repository": {
1717
"type": "git",
18-
"url": "git+https://github.com/openai/codex.git",
18+
"url": "git+https://github.com/LEON-gittech/codex.git",
1919
"directory": "codex-cli"
2020
},
2121
"packageManager": "pnpm@10.29.3+sha512.498e1fb4cca5aa06c1dcf2611e6fafc50972ffe7189998c409e90de74566444298ffe43e6cd2acdc775ba1aa7cc5e092a8b7054c811ba8c5770f84693d33d2dc"

codex-cli/scripts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This downloads the native artifacts once, hydrates `vendor/` for each package, a
1515
tarballs to `dist/npm/`.
1616

1717
When `--package codex` is provided, the staging helper builds the lightweight
18-
`@openai/codex` meta package plus all platform-native `@openai/codex` variants
18+
`@leonw24/open-codex` meta package plus all platform-native `@leonw24/open-codex` variants
1919
that are later published under platform-specific dist-tags.
2020

2121
If you need to invoke `build_npm_package.py` directly, run

codex-cli/scripts/build_npm_package.py

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/usr/bin/env python3
2-
"""Stage and optionally package the @openai/codex npm module."""
2+
"""Stage and optionally package the @leonw24/open-codex npm module."""
3+
4+
from __future__ import annotations
35

46
import argparse
57
import json
8+
import os
69
import shutil
710
import subprocess
811
import sys
@@ -14,48 +17,48 @@
1417
REPO_ROOT = CODEX_CLI_ROOT.parent
1518
RESPONSES_API_PROXY_NPM_ROOT = REPO_ROOT / "codex-rs" / "responses-api-proxy" / "npm"
1619
CODEX_SDK_ROOT = REPO_ROOT / "sdk" / "typescript"
17-
CODEX_NPM_NAME = "@openai/codex"
20+
CODEX_NPM_NAME = "@leonw24/open-codex"
1821

1922
# `npm_name` is the local optional-dependency alias consumed by `bin/codex.js`.
20-
# The underlying package published to npm is always `@openai/codex`.
23+
# The underlying package published to npm is always `@leonw24/open-codex`.
2124
CODEX_PLATFORM_PACKAGES: dict[str, dict[str, str]] = {
2225
"codex-linux-x64": {
23-
"npm_name": "@openai/codex-linux-x64",
26+
"npm_name": "@leonw24/open-codex-linux-x64",
2427
"npm_tag": "linux-x64",
25-
"target_triple": "x86_64-unknown-linux-musl",
28+
"target_triple": "x86_64-unknown-linux-gnu",
2629
"os": "linux",
2730
"cpu": "x64",
2831
},
2932
"codex-linux-arm64": {
30-
"npm_name": "@openai/codex-linux-arm64",
33+
"npm_name": "@leonw24/open-codex-linux-arm64",
3134
"npm_tag": "linux-arm64",
32-
"target_triple": "aarch64-unknown-linux-musl",
35+
"target_triple": "aarch64-unknown-linux-gnu",
3336
"os": "linux",
3437
"cpu": "arm64",
3538
},
3639
"codex-darwin-x64": {
37-
"npm_name": "@openai/codex-darwin-x64",
40+
"npm_name": "@leonw24/open-codex-darwin-x64",
3841
"npm_tag": "darwin-x64",
3942
"target_triple": "x86_64-apple-darwin",
4043
"os": "darwin",
4144
"cpu": "x64",
4245
},
4346
"codex-darwin-arm64": {
44-
"npm_name": "@openai/codex-darwin-arm64",
47+
"npm_name": "@leonw24/open-codex-darwin-arm64",
4548
"npm_tag": "darwin-arm64",
4649
"target_triple": "aarch64-apple-darwin",
4750
"os": "darwin",
4851
"cpu": "arm64",
4952
},
5053
"codex-win32-x64": {
51-
"npm_name": "@openai/codex-win32-x64",
54+
"npm_name": "@leonw24/open-codex-win32-x64",
5255
"npm_tag": "win32-x64",
5356
"target_triple": "x86_64-pc-windows-msvc",
5457
"os": "win32",
5558
"cpu": "x64",
5659
},
5760
"codex-win32-arm64": {
58-
"npm_name": "@openai/codex-win32-arm64",
61+
"npm_name": "@leonw24/open-codex-win32-arm64",
5962
"npm_tag": "win32-arm64",
6063
"target_triple": "aarch64-pc-windows-msvc",
6164
"os": "win32",
@@ -95,6 +98,23 @@
9598
}
9699

97100

101+
def platform_packages_for_meta() -> list[str]:
102+
requested = os.environ.get("CODEX_NPM_PLATFORM_PACKAGES")
103+
if not requested:
104+
return [
105+
platform_package
106+
for platform_package in PACKAGE_EXPANSIONS["codex"]
107+
if platform_package != "codex"
108+
]
109+
110+
packages = [package.strip() for package in requested.split(",") if package.strip()]
111+
unknown = [package for package in packages if package not in CODEX_PLATFORM_PACKAGES]
112+
if unknown:
113+
unknown_list = ", ".join(sorted(unknown))
114+
raise RuntimeError(f"Unknown CODEX_NPM_PLATFORM_PACKAGES entries: {unknown_list}")
115+
return packages
116+
117+
98118
def parse_args() -> argparse.Namespace:
99119
parser = argparse.ArgumentParser(description="Build or stage the Codex CLI npm package.")
100120
parser.add_argument(
@@ -308,8 +328,7 @@ def stage_sources(staging_dir: Path, version: str, package: str) -> None:
308328
f"npm:{CODEX_NPM_NAME}@"
309329
f"{compute_platform_package_version(version, CODEX_PLATFORM_PACKAGES[platform_package]['npm_tag'])}"
310330
)
311-
for platform_package in PACKAGE_EXPANSIONS["codex"]
312-
if platform_package != "codex"
331+
for platform_package in platform_packages_for_meta()
313332
}
314333

315334
elif package == "codex-sdk":
@@ -419,7 +438,9 @@ def run_npm_pack(staging_dir: Path, output_path: Path) -> Path:
419438
output_path = output_path.resolve()
420439
output_path.parent.mkdir(parents=True, exist_ok=True)
421440

422-
with tempfile.TemporaryDirectory(prefix="codex-npm-pack-") as pack_dir_str:
441+
runner_temp = Path(os.environ.get("RUNNER_TEMP", tempfile.gettempdir()))
442+
runner_temp.mkdir(parents=True, exist_ok=True)
443+
with tempfile.TemporaryDirectory(prefix="codex-npm-pack-", dir=runner_temp) as pack_dir_str:
423444
pack_dir = Path(pack_dir_str)
424445
stdout = subprocess.check_output(
425446
["npm", "pack", "--json", "--pack-destination", str(pack_dir)],

scripts/stage_npm_packages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
BUILD_SCRIPT = REPO_ROOT / "codex-cli" / "scripts" / "build_npm_package.py"
1818
INSTALL_NATIVE_DEPS = REPO_ROOT / "codex-cli" / "scripts" / "install_native_deps.py"
1919
WORKFLOW_NAME = ".github/workflows/rust-release.yml"
20-
GITHUB_REPO = "openai/codex"
20+
GITHUB_REPO = "LEON-gittech/codex"
2121

2222
_SPEC = importlib.util.spec_from_file_location("codex_build_npm_package", BUILD_SCRIPT)
2323
if _SPEC is None or _SPEC.loader is None:

0 commit comments

Comments
 (0)