@rickgetz/codex 0.122.0-rick.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +54 -0
  2. package/bin/codex.js +242 -0
  3. package/bin/rg +79 -0
  4. package/package.json +24 -0
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ <p align="center"><code>npm i -g @rickgetz/codex</code></p>
2
+ <p align="center"><strong>Codex CLI</strong> is a coding agent from OpenAI that runs locally on your computer.
3
+ <p align="center">
4
+ <img src="https://github.com/openai/codex/blob/main/.github/codex-cli-splash.png" alt="Codex CLI splash" width="80%" />
5
+ </p>
6
+ <p align="center">Forked from <a href="https://github.com/openai/codex">openai/codex</a>. This fork is maintained by <a href="https://github.com/richardgetz">Rick Getz</a> and keeps upstream attribution and licensing intact.</p>
7
+ </br>
8
+ If you want Codex in your code editor (VS Code, Cursor, Windsurf), <a href="https://developers.openai.com/codex/ide">install in your IDE.</a>
9
+ </br>If you want the desktop app experience, run <code>codex app</code> or visit <a href="https://chatgpt.com/codex?app-landing-page=true">the Codex App page</a>.
10
+ </br>If you are looking for the <em>cloud-based agent</em> from OpenAI, <strong>Codex Web</strong>, go to <a href="https://chatgpt.com/codex">chatgpt.com/codex</a>.</p>
11
+
12
+ ---
13
+
14
+ ## Quickstart
15
+
16
+ ### Installing and running Codex CLI
17
+
18
+ Install globally with your preferred package manager:
19
+
20
+ ```shell
21
+ # Install using npm
22
+ npm install -g @rickgetz/codex
23
+ ```
24
+
25
+ Then simply run `codex` to get started.
26
+
27
+ <details>
28
+ <summary>You can also go to the <a href="https://github.com/richardgetz/codex/releases/latest">latest fork GitHub Release</a> and download the Apple Silicon macOS binary.</summary>
29
+
30
+ This fork currently publishes:
31
+
32
+ - macOS
33
+ - Apple Silicon/arm64: `codex-aarch64-apple-darwin.tar.gz`
34
+
35
+ Each archive contains a single entry with the platform baked into the name (`codex-aarch64-apple-darwin`), so you likely want to rename it to `codex` after extracting it.
36
+
37
+ </details>
38
+
39
+ ### Using Codex with your ChatGPT plan
40
+
41
+ Run `codex` and select **Sign in with ChatGPT**. We recommend signing into your ChatGPT account to use Codex as part of your Plus, Pro, Business, Edu, or Enterprise plan. [Learn more about what's included in your ChatGPT plan](https://help.openai.com/en/articles/11369540-codex-in-chatgpt).
42
+
43
+ You can also use Codex with an API key, but this requires [additional setup](https://developers.openai.com/codex/auth#sign-in-with-an-api-key).
44
+
45
+ ## Docs
46
+
47
+ - [**Codex Documentation**](https://developers.openai.com/codex)
48
+ - [**Contributing**](./docs/contributing.md)
49
+ - [**Installing & building**](./docs/install.md)
50
+ - [**Fork differences**](./docs/fork-differences.md)
51
+ - [**Fork npm releases**](./docs/fork-release.md)
52
+ - [**Open source fund**](./docs/open-source-fund.md)
53
+
54
+ This repository is licensed under the [Apache-2.0 License](LICENSE).
package/bin/codex.js ADDED
@@ -0,0 +1,242 @@
1
+ #!/usr/bin/env node
2
+ // Unified entry point for the Codex CLI.
3
+
4
+ import { spawn } from "node:child_process";
5
+ import { existsSync, readFileSync } from "fs";
6
+ import { createRequire } from "node:module";
7
+ import path from "path";
8
+ import { fileURLToPath } from "url";
9
+
10
+ // __dirname equivalent in ESM
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+ const require = createRequire(import.meta.url);
14
+
15
+ const PLATFORM_PACKAGE_SUFFIX_BY_TARGET = {
16
+ "x86_64-unknown-linux-musl": "codex-linux-x64",
17
+ "aarch64-unknown-linux-musl": "codex-linux-arm64",
18
+ "x86_64-apple-darwin": "codex-darwin-x64",
19
+ "aarch64-apple-darwin": "codex-darwin-arm64",
20
+ "x86_64-pc-windows-msvc": "codex-win32-x64",
21
+ "aarch64-pc-windows-msvc": "codex-win32-arm64",
22
+ };
23
+ const rootPackageJson = JSON.parse(
24
+ readFileSync(path.join(__dirname, "..", "package.json"), "utf8"),
25
+ );
26
+ const rootPackageName = rootPackageJson.name || "@rickgetz/codex";
27
+
28
+ function packageAliasName(basePackageName, suffix) {
29
+ if (basePackageName.startsWith("@")) {
30
+ const [scope, packageName] = basePackageName.split("/", 2);
31
+ return `${scope}/${packageName}-${suffix.replace(/^codex-/, "")}`;
32
+ }
33
+ return `${basePackageName}-${suffix.replace(/^codex-/, "")}`;
34
+ }
35
+
36
+ const { platform, arch } = process;
37
+
38
+ let targetTriple = null;
39
+ switch (platform) {
40
+ case "linux":
41
+ case "android":
42
+ switch (arch) {
43
+ case "x64":
44
+ targetTriple = "x86_64-unknown-linux-musl";
45
+ break;
46
+ case "arm64":
47
+ targetTriple = "aarch64-unknown-linux-musl";
48
+ break;
49
+ default:
50
+ break;
51
+ }
52
+ break;
53
+ case "darwin":
54
+ switch (arch) {
55
+ case "x64":
56
+ targetTriple = "x86_64-apple-darwin";
57
+ break;
58
+ case "arm64":
59
+ targetTriple = "aarch64-apple-darwin";
60
+ break;
61
+ default:
62
+ break;
63
+ }
64
+ break;
65
+ case "win32":
66
+ switch (arch) {
67
+ case "x64":
68
+ targetTriple = "x86_64-pc-windows-msvc";
69
+ break;
70
+ case "arm64":
71
+ targetTriple = "aarch64-pc-windows-msvc";
72
+ break;
73
+ default:
74
+ break;
75
+ }
76
+ break;
77
+ default:
78
+ break;
79
+ }
80
+
81
+ if (!targetTriple) {
82
+ throw new Error(`Unsupported platform: ${platform} (${arch})`);
83
+ }
84
+
85
+ const platformPackageSuffix = PLATFORM_PACKAGE_SUFFIX_BY_TARGET[targetTriple];
86
+ if (!platformPackageSuffix) {
87
+ throw new Error(`Unsupported target triple: ${targetTriple}`);
88
+ }
89
+ const platformPackage = packageAliasName(rootPackageName, platformPackageSuffix);
90
+
91
+ const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
92
+ const localVendorRoot = path.join(__dirname, "..", "vendor");
93
+ const localBinaryPath = path.join(
94
+ localVendorRoot,
95
+ targetTriple,
96
+ "codex",
97
+ codexBinaryName,
98
+ );
99
+
100
+ let vendorRoot;
101
+ try {
102
+ const packageJsonPath = require.resolve(`${platformPackage}/package.json`);
103
+ vendorRoot = path.join(path.dirname(packageJsonPath), "vendor");
104
+ } catch {
105
+ if (existsSync(localBinaryPath)) {
106
+ vendorRoot = localVendorRoot;
107
+ } else {
108
+ const packageManager = detectPackageManager();
109
+ const updateCommand =
110
+ packageManager === "bun"
111
+ ? `bun install -g ${rootPackageName}@latest`
112
+ : `npm install -g ${rootPackageName}@latest`;
113
+ throw new Error(
114
+ `Missing optional dependency ${platformPackage}. Reinstall Codex: ${updateCommand}`,
115
+ );
116
+ }
117
+ }
118
+
119
+ if (!vendorRoot) {
120
+ const packageManager = detectPackageManager();
121
+ const updateCommand =
122
+ packageManager === "bun"
123
+ ? `bun install -g ${rootPackageName}@latest`
124
+ : `npm install -g ${rootPackageName}@latest`;
125
+ throw new Error(
126
+ `Missing optional dependency ${platformPackage}. Reinstall Codex: ${updateCommand}`,
127
+ );
128
+ }
129
+
130
+ const archRoot = path.join(vendorRoot, targetTriple);
131
+ const binaryPath = path.join(archRoot, "codex", codexBinaryName);
132
+
133
+ // Use an asynchronous spawn instead of spawnSync so that Node is able to
134
+ // respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
135
+ // executing. This allows us to forward those signals to the child process
136
+ // and guarantees that when either the child terminates or the parent
137
+ // receives a fatal signal, both processes exit in a predictable manner.
138
+
139
+ function getUpdatedPath(newDirs) {
140
+ const pathSep = process.platform === "win32" ? ";" : ":";
141
+ const existingPath = process.env.PATH || "";
142
+ const updatedPath = [
143
+ ...newDirs,
144
+ ...existingPath.split(pathSep).filter(Boolean),
145
+ ].join(pathSep);
146
+ return updatedPath;
147
+ }
148
+
149
+ /**
150
+ * Use heuristics to detect the package manager that was used to install Codex
151
+ * in order to give the user a hint about how to update it.
152
+ */
153
+ function detectPackageManager() {
154
+ const userAgent = process.env.npm_config_user_agent || "";
155
+ if (/\bbun\//.test(userAgent)) {
156
+ return "bun";
157
+ }
158
+
159
+ const execPath = process.env.npm_execpath || "";
160
+ if (execPath.includes("bun")) {
161
+ return "bun";
162
+ }
163
+
164
+ if (
165
+ __dirname.includes(".bun/install/global") ||
166
+ __dirname.includes(".bun\\install\\global")
167
+ ) {
168
+ return "bun";
169
+ }
170
+
171
+ return userAgent ? "npm" : null;
172
+ }
173
+
174
+ const additionalDirs = [];
175
+ const pathDir = path.join(archRoot, "path");
176
+ if (existsSync(pathDir)) {
177
+ additionalDirs.push(pathDir);
178
+ }
179
+ const updatedPath = getUpdatedPath(additionalDirs);
180
+
181
+ const env = { ...process.env, PATH: updatedPath };
182
+ const packageManagerEnvVar =
183
+ detectPackageManager() === "bun"
184
+ ? "CODEX_MANAGED_BY_BUN"
185
+ : "CODEX_MANAGED_BY_NPM";
186
+ env[packageManagerEnvVar] = "1";
187
+
188
+ const child = spawn(binaryPath, process.argv.slice(2), {
189
+ stdio: "inherit",
190
+ env,
191
+ });
192
+
193
+ child.on("error", (err) => {
194
+ // Typically triggered when the binary is missing or not executable.
195
+ // Re-throwing here will terminate the parent with a non-zero exit code
196
+ // while still printing a helpful stack trace.
197
+ // eslint-disable-next-line no-console
198
+ console.error(err);
199
+ process.exit(1);
200
+ });
201
+
202
+ // Forward common termination signals to the child so that it shuts down
203
+ // gracefully. In the handler we temporarily disable the default behavior of
204
+ // exiting immediately; once the child has been signaled we simply wait for
205
+ // its exit event which will in turn terminate the parent (see below).
206
+ const forwardSignal = (signal) => {
207
+ if (child.killed) {
208
+ return;
209
+ }
210
+ try {
211
+ child.kill(signal);
212
+ } catch {
213
+ /* ignore */
214
+ }
215
+ };
216
+
217
+ ["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
218
+ process.on(sig, () => forwardSignal(sig));
219
+ });
220
+
221
+ // When the child exits, mirror its termination reason in the parent so that
222
+ // shell scripts and other tooling observe the correct exit status.
223
+ // Wrap the lifetime of the child process in a Promise so that we can await
224
+ // its termination in a structured way. The Promise resolves with an object
225
+ // describing how the child exited: either via exit code or due to a signal.
226
+ const childResult = await new Promise((resolve) => {
227
+ child.on("exit", (code, signal) => {
228
+ if (signal) {
229
+ resolve({ type: "signal", signal });
230
+ } else {
231
+ resolve({ type: "code", exitCode: code ?? 1 });
232
+ }
233
+ });
234
+ });
235
+
236
+ if (childResult.type === "signal") {
237
+ // Re-emit the same signal so that the parent terminates with the expected
238
+ // semantics (this also sets the correct exit code of 128 + n).
239
+ process.kill(process.pid, childResult.signal);
240
+ } else {
241
+ process.exit(childResult.exitCode);
242
+ }
package/bin/rg ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env dotslash
2
+
3
+ {
4
+ "name": "rg",
5
+ "platforms": {
6
+ "macos-aarch64": {
7
+ "size": 1777930,
8
+ "hash": "sha256",
9
+ "digest": "378e973289176ca0c6054054ee7f631a065874a352bf43f0fa60ef079b6ba715",
10
+ "format": "tar.gz",
11
+ "path": "ripgrep-15.1.0-aarch64-apple-darwin/rg",
12
+ "providers": [
13
+ {
14
+ "url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-aarch64-apple-darwin.tar.gz"
15
+ }
16
+ ]
17
+ },
18
+ "linux-aarch64": {
19
+ "size": 1869959,
20
+ "hash": "sha256",
21
+ "digest": "2b661c6ef508e902f388e9098d9c4c5aca72c87b55922d94abdba830b4dc885e",
22
+ "format": "tar.gz",
23
+ "path": "ripgrep-15.1.0-aarch64-unknown-linux-gnu/rg",
24
+ "providers": [
25
+ {
26
+ "url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-aarch64-unknown-linux-gnu.tar.gz"
27
+ }
28
+ ]
29
+ },
30
+ "macos-x86_64": {
31
+ "size": 1894127,
32
+ "hash": "sha256",
33
+ "digest": "64811cb24e77cac3057d6c40b63ac9becf9082eedd54ca411b475b755d334882",
34
+ "format": "tar.gz",
35
+ "path": "ripgrep-15.1.0-x86_64-apple-darwin/rg",
36
+ "providers": [
37
+ {
38
+ "url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-x86_64-apple-darwin.tar.gz"
39
+ }
40
+ ]
41
+ },
42
+ "linux-x86_64": {
43
+ "size": 2263077,
44
+ "hash": "sha256",
45
+ "digest": "1c9297be4a084eea7ecaedf93eb03d058d6faae29bbc57ecdaf5063921491599",
46
+ "format": "tar.gz",
47
+ "path": "ripgrep-15.1.0-x86_64-unknown-linux-musl/rg",
48
+ "providers": [
49
+ {
50
+ "url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-x86_64-unknown-linux-musl.tar.gz"
51
+ }
52
+ ]
53
+ },
54
+ "windows-x86_64": {
55
+ "size": 1810687,
56
+ "hash": "sha256",
57
+ "digest": "124510b94b6baa3380d051fdf4650eaa80a302c876d611e9dba0b2e18d87493a",
58
+ "format": "zip",
59
+ "path": "ripgrep-15.1.0-x86_64-pc-windows-msvc/rg.exe",
60
+ "providers": [
61
+ {
62
+ "url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-x86_64-pc-windows-msvc.zip"
63
+ }
64
+ ]
65
+ },
66
+ "windows-aarch64": {
67
+ "size": 1675460,
68
+ "hash": "sha256",
69
+ "digest": "00d931fb5237c9696ca49308818edb76d8eb6fc132761cb2a1bd616b2df02f8e",
70
+ "format": "zip",
71
+ "path": "ripgrep-15.1.0-aarch64-pc-windows-msvc/rg.exe",
72
+ "providers": [
73
+ {
74
+ "url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-aarch64-pc-windows-msvc.zip"
75
+ }
76
+ ]
77
+ }
78
+ }
79
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@rickgetz/codex",
3
+ "version": "0.122.0-rick.4",
4
+ "license": "Apache-2.0",
5
+ "bin": {
6
+ "codex": "bin/codex.js"
7
+ },
8
+ "type": "module",
9
+ "engines": {
10
+ "node": ">=16"
11
+ },
12
+ "files": [
13
+ "bin"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/richardgetz/codex.git",
18
+ "directory": "codex-cli"
19
+ },
20
+ "packageManager": "pnpm@10.29.3+sha512.498e1fb4cca5aa06c1dcf2611e6fafc50972ffe7189998c409e90de74566444298ffe43e6cd2acdc775ba1aa7cc5e092a8b7054c811ba8c5770f84693d33d2dc",
21
+ "optionalDependencies": {
22
+ "@rickgetz/codex-darwin-arm64": "npm:@rickgetz/codex@0.122.0-rick.4-darwin-arm64"
23
+ }
24
+ }