@loongphy/codext 0.111.0-ad42b61-linux-x64 → 0.117.0-4675af1

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.
package/README.md CHANGED
@@ -2,18 +2,56 @@
2
2
 
3
3
  An opinionated Codex CLI. This is strictly a personal hobby project, forked from openai/codex.
4
4
 
5
- ![Codex build](https://img.shields.io/static/v1?label=codex%20build&message=rust-v0.111.0-36ab73925&color=2ea043)
5
+ ![Codex build](https://img.shields.io/static/v1?label=codex%20build&message=rust-v0.117.0-f82d18d&color=2ea043)
6
6
 
7
7
  ![TUI](
8
8
  https://github.com/user-attachments/assets/127abbc2-cb30-4d6e-8a81-ce707260c045)
9
9
 
10
+ > [!IMPORTANT]
11
+ > **DO NOT USE IN PRODUCTION.**
12
+ > To keep upstream sync easy, we do not write test code for what we changed. This project is for experimental use only.
13
+
14
+ * **DX Focused:** Focus strictly on optimizing developer experience, **without adding new features**.
15
+ * **Upstream Sync:** We sync with the upstream repository regularly.
16
+
10
17
  ## Quick Start
11
18
 
19
+ Choose one of these two ways:
20
+
21
+ * Install from npm:
22
+
23
+ ```shell
24
+ npm i -g @loongphy/codext
25
+ ```
26
+
27
+ * Build from source:
28
+
12
29
  ```shell
13
30
  cd codex-rs
14
31
  cargo run --bin codex
15
32
  ```
16
33
 
34
+ ## Features
35
+
36
+ > Full change log: see [CHANGED.md](./CHANGED.md).
37
+
38
+ * `Ctrl+Shift+C` in the TUI composer copies the current draft to the system clipboard; `Ctrl+C` keeps its existing behavior, and empty drafts still fall back to the old `Ctrl+C` path.
39
+ * TUI status header with model/effort, cwd, git summary, and rate-limit status.
40
+ * Collaboration mode presets accept per-mode overrides and default to the active `/model` settings. Example:
41
+
42
+ ```toml
43
+ # config.toml
44
+ [collaboration_modes.plan]
45
+ model = "gpt-5.4"
46
+ reasoning_effort = "xhigh"
47
+
48
+ [collaboration_modes.code]
49
+ model = "gpt-5.4"
50
+ ```
51
+
52
+ * TUI watches `auth.json` for external login changes and reloads auth automatically, with a warning on account switch. This works well with [codex-auth](https://github.com/Loongphy/codex-auth) when you refresh or switch login state outside the TUI.
53
+ * AGENTS.md and project-doc instructions are refreshed on each new user turn, and Codex shows an explicit warning when a refresh is applied.
54
+
17
55
  ## Project Goals
18
56
 
19
57
  We will never merge code from the upstream repo; instead, we re-implement our changes on top of the latest upstream code.
@@ -31,41 +69,6 @@ flowchart TD
31
69
  G --> H[Force-push to fork main]
32
70
  ```
33
71
 
34
- > [!IMPORTANT]
35
- > **DO NOT USE IN PRODUCTION.**
36
- > To keep upstream sync easy, we do not write test code for what we changed. This project is for experimental use only.
37
-
38
- * **DX Focused:** Focus strictly on optimizing developer experience, **without adding new features**.
39
- * **Upstream Sync:** We sync with the upstream repository regularly.
40
-
41
- ## What Changed
42
-
43
- * Added a TUI status header with model/effort, cwd, git summary, and rate-limit status.
44
- * Collaboration mode presets now accept per-mode overrides and default to the active `/model` settings.
45
- * TUI watches `auth.json` for external login changes and reloads auth automatically (with a warning on account switch).
46
- * AGENTS.md/project-doc instructions are refreshed on each new user turn, and Codex shows an explicit warning when a refresh is applied.
47
- * Full change log: see [CHANGED.md](./CHANGED.md).
48
-
49
- ## AGENT Local development check
50
-
51
- 1. DO NOT update any test codes
52
- 2. After making code changes, verify the CLI still launches:
53
-
54
- ```shell
55
- cd ./codex-rs
56
- cargo run --bin codex
57
- ```
58
-
59
- ```toml
60
- # config.toml
61
- [collaboration_modes.plan]
62
- model = "gpt-5.2-codex"
63
- reasoning_effort = "xhigh"
64
-
65
- [collaboration_modes.code]
66
- model = "gpt-5.2-codex"
67
- ```
68
-
69
72
  ## Skills
70
73
 
71
74
  When syncing to the latest upstream codex version, use `.agents/skills/codex-upstream-reapply` to re-implement our custom requirements on top of the newest code, avoiding merge conflicts from the old branch history.
package/bin/codex.js ADDED
@@ -0,0 +1,236 @@
1
+ #!/usr/bin/env node
2
+ // Unified entry point for the Codext CLI.
3
+
4
+ import { spawn } from "node:child_process";
5
+ import { chmodSync, existsSync, statSync } 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_BY_TARGET = {
16
+ "x86_64-unknown-linux-musl": "@loongphy/codext-linux-x64",
17
+ "x86_64-apple-darwin": "@loongphy/codext-darwin-x64",
18
+ "aarch64-apple-darwin": "@loongphy/codext-darwin-arm64",
19
+ "x86_64-pc-windows-msvc": "@loongphy/codext-win32-x64",
20
+ };
21
+
22
+ const { platform, arch } = process;
23
+
24
+ let targetTriple = null;
25
+ switch (platform) {
26
+ case "linux":
27
+ case "android":
28
+ switch (arch) {
29
+ case "x64":
30
+ targetTriple = "x86_64-unknown-linux-musl";
31
+ break;
32
+ default:
33
+ break;
34
+ }
35
+ break;
36
+ case "darwin":
37
+ switch (arch) {
38
+ case "x64":
39
+ targetTriple = "x86_64-apple-darwin";
40
+ break;
41
+ case "arm64":
42
+ targetTriple = "aarch64-apple-darwin";
43
+ break;
44
+ default:
45
+ break;
46
+ }
47
+ break;
48
+ case "win32":
49
+ switch (arch) {
50
+ case "x64":
51
+ targetTriple = "x86_64-pc-windows-msvc";
52
+ break;
53
+ default:
54
+ break;
55
+ }
56
+ break;
57
+ default:
58
+ break;
59
+ }
60
+
61
+ if (!targetTriple) {
62
+ throw new Error(`Unsupported platform: ${platform} (${arch})`);
63
+ }
64
+
65
+ const platformPackage = PLATFORM_PACKAGE_BY_TARGET[targetTriple];
66
+ if (!platformPackage) {
67
+ throw new Error(`Unsupported target triple: ${targetTriple}`);
68
+ }
69
+
70
+ const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
71
+ const localVendorRoot = path.join(__dirname, "..", "vendor");
72
+ const localBinaryPath = path.join(
73
+ localVendorRoot,
74
+ targetTriple,
75
+ "codex",
76
+ codexBinaryName,
77
+ );
78
+
79
+ let vendorRoot;
80
+ try {
81
+ const packageJsonPath = require.resolve(`${platformPackage}/package.json`);
82
+ vendorRoot = path.join(path.dirname(packageJsonPath), "vendor");
83
+ } catch {
84
+ if (existsSync(localBinaryPath)) {
85
+ vendorRoot = localVendorRoot;
86
+ } else {
87
+ const packageManager = detectPackageManager();
88
+ const updateCommand =
89
+ packageManager === "bun"
90
+ ? "bun install -g @loongphy/codext@latest"
91
+ : "npm install -g @loongphy/codext@latest";
92
+ throw new Error(
93
+ `Missing optional dependency ${platformPackage}. Reinstall Codext: ${updateCommand}`,
94
+ );
95
+ }
96
+ }
97
+
98
+ if (!vendorRoot) {
99
+ const packageManager = detectPackageManager();
100
+ const updateCommand =
101
+ packageManager === "bun"
102
+ ? "bun install -g @loongphy/codext@latest"
103
+ : "npm install -g @loongphy/codext@latest";
104
+ throw new Error(
105
+ `Missing optional dependency ${platformPackage}. Reinstall Codext: ${updateCommand}`,
106
+ );
107
+ }
108
+
109
+ const archRoot = path.join(vendorRoot, targetTriple);
110
+ const binaryPath = path.join(archRoot, "codex", codexBinaryName);
111
+
112
+ function ensureExecutable(filePath) {
113
+ if (process.platform === "win32" || !existsSync(filePath)) {
114
+ return;
115
+ }
116
+
117
+ const currentMode = statSync(filePath).mode;
118
+ if ((currentMode & 0o111) !== 0) {
119
+ return;
120
+ }
121
+
122
+ chmodSync(filePath, currentMode | 0o111);
123
+ }
124
+
125
+ // Use an asynchronous spawn instead of spawnSync so that Node is able to
126
+ // respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
127
+ // executing. This allows us to forward those signals to the child process
128
+ // and guarantees that when either the child terminates or the parent
129
+ // receives a fatal signal, both processes exit in a predictable manner.
130
+
131
+ function getUpdatedPath(newDirs) {
132
+ const pathSep = process.platform === "win32" ? ";" : ":";
133
+ const existingPath = process.env.PATH || "";
134
+ const updatedPath = [
135
+ ...newDirs,
136
+ ...existingPath.split(pathSep).filter(Boolean),
137
+ ].join(pathSep);
138
+ return updatedPath;
139
+ }
140
+
141
+ /**
142
+ * Use heuristics to detect the package manager that was used to install Codext
143
+ * in order to give the user a hint about how to update it.
144
+ */
145
+ function detectPackageManager() {
146
+ const userAgent = process.env.npm_config_user_agent || "";
147
+ if (/\bbun\//.test(userAgent)) {
148
+ return "bun";
149
+ }
150
+
151
+ const execPath = process.env.npm_execpath || "";
152
+ if (execPath.includes("bun")) {
153
+ return "bun";
154
+ }
155
+
156
+ if (
157
+ __dirname.includes(".bun/install/global") ||
158
+ __dirname.includes(".bun\\install\\global")
159
+ ) {
160
+ return "bun";
161
+ }
162
+
163
+ return userAgent ? "npm" : null;
164
+ }
165
+
166
+ const additionalDirs = [];
167
+ const pathDir = path.join(archRoot, "path");
168
+ if (existsSync(pathDir)) {
169
+ additionalDirs.push(pathDir);
170
+ }
171
+ const updatedPath = getUpdatedPath(additionalDirs);
172
+
173
+ const env = { ...process.env, PATH: updatedPath };
174
+ const packageManagerEnvVar =
175
+ detectPackageManager() === "bun"
176
+ ? "CODEX_MANAGED_BY_BUN"
177
+ : "CODEX_MANAGED_BY_NPM";
178
+ env[packageManagerEnvVar] = "1";
179
+
180
+ ensureExecutable(binaryPath);
181
+
182
+ const child = spawn(binaryPath, process.argv.slice(2), {
183
+ stdio: "inherit",
184
+ env,
185
+ });
186
+
187
+ child.on("error", (err) => {
188
+ // Typically triggered when the binary is missing or not executable.
189
+ // Re-throwing here will terminate the parent with a non-zero exit code
190
+ // while still printing a helpful stack trace.
191
+ // eslint-disable-next-line no-console
192
+ console.error(err);
193
+ process.exit(1);
194
+ });
195
+
196
+ // Forward common termination signals to the child so that it shuts down
197
+ // gracefully. In the handler we temporarily disable the default behavior of
198
+ // exiting immediately; once the child has been signaled we simply wait for
199
+ // its exit event which will in turn terminate the parent (see below).
200
+ const forwardSignal = (signal) => {
201
+ if (child.killed) {
202
+ return;
203
+ }
204
+ try {
205
+ child.kill(signal);
206
+ } catch {
207
+ /* ignore */
208
+ }
209
+ };
210
+
211
+ ["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
212
+ process.on(sig, () => forwardSignal(sig));
213
+ });
214
+
215
+ // When the child exits, mirror its termination reason in the parent so that
216
+ // shell scripts and other tooling observe the correct exit status.
217
+ // Wrap the lifetime of the child process in a Promise so that we can await
218
+ // its termination in a structured way. The Promise resolves with an object
219
+ // describing how the child exited: either via exit code or due to a signal.
220
+ const childResult = await new Promise((resolve) => {
221
+ child.on("exit", (code, signal) => {
222
+ if (signal) {
223
+ resolve({ type: "signal", signal });
224
+ } else {
225
+ resolve({ type: "code", exitCode: code ?? 1 });
226
+ }
227
+ });
228
+ });
229
+
230
+ if (childResult.type === "signal") {
231
+ // Re-emit the same signal so that the parent terminates with the expected
232
+ // semantics (this also sets the correct exit code of 128 + n).
233
+ process.kill(process.pid, childResult.signal);
234
+ } else {
235
+ process.exit(childResult.exitCode);
236
+ }
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 CHANGED
@@ -1,23 +1,27 @@
1
1
  {
2
2
  "name": "@loongphy/codext",
3
- "version": "0.111.0-ad42b61-linux-x64",
3
+ "version": "0.117.0-4675af1",
4
4
  "license": "Apache-2.0",
5
- "os": [
6
- "linux"
7
- ],
8
- "cpu": [
9
- "x64"
10
- ],
5
+ "bin": {
6
+ "codext": "bin/codex.js"
7
+ },
8
+ "type": "module",
9
+ "engines": {
10
+ "node": ">=16"
11
+ },
11
12
  "files": [
12
- "vendor"
13
+ "bin"
13
14
  ],
14
15
  "repository": {
15
16
  "type": "git",
16
17
  "url": "git+https://github.com/Loongphy/codext.git",
17
18
  "directory": "codex-cli"
18
19
  },
19
- "engines": {
20
- "node": ">=16"
21
- },
22
- "packageManager": "pnpm@10.29.3+sha512.498e1fb4cca5aa06c1dcf2611e6fafc50972ffe7189998c409e90de74566444298ffe43e6cd2acdc775ba1aa7cc5e092a8b7054c811ba8c5770f84693d33d2dc"
20
+ "packageManager": "pnpm@10.29.3+sha512.498e1fb4cca5aa06c1dcf2611e6fafc50972ffe7189998c409e90de74566444298ffe43e6cd2acdc775ba1aa7cc5e092a8b7054c811ba8c5770f84693d33d2dc",
21
+ "optionalDependencies": {
22
+ "@loongphy/codext-linux-x64": "npm:@loongphy/codext@0.117.0-4675af1-linux-x64",
23
+ "@loongphy/codext-darwin-x64": "npm:@loongphy/codext@0.117.0-4675af1-darwin-x64",
24
+ "@loongphy/codext-darwin-arm64": "npm:@loongphy/codext@0.117.0-4675af1-darwin-arm64",
25
+ "@loongphy/codext-win32-x64": "npm:@loongphy/codext@0.117.0-4675af1-win32-x64"
26
+ }
23
27
  }