@jacks001314/codex-go 0.1.0 → 1.0.0
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 +8 -3
- package/bin/codex.js +66 -4
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# Codex Go
|
|
1
|
+
# Codex Go
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
The latest audited alignment target is Rust `main` at `970b7f2ff4f612b8e8cd340eb6b6d789d7141dd2`; see [the 2026-08-22 alignment record](./update/plan_2026_08_22.md).
|
|
4
|
+
[parity.json](./parity.json) records the current SDK and implementation evidence. Candidate baseline, commit, domain, and contract state live under [parity/](./parity/); only `parity/baseline.json` with `certificationReady: true` denotes a fully certified release.
|
|
5
5
|
|
|
6
6
|
`codex_go` 是 Codex CLI 的 Go 实现,目标是逐步对齐 Rust 版 Codex CLI 的命令行行为、配置语义、认证、模型请求、TUI、app-server、MCP、插件、沙箱和会话能力。
|
|
7
7
|
|
|
@@ -140,6 +140,11 @@ node .\npm\scripts\publish-packages.mjs --directory .\dist\v0.1.0\npm --otp 1234
|
|
|
140
140
|
.\scripts\build.ps1
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
+
Windows builds also write `codex-command-runner.exe` and
|
|
144
|
+
`codex-windows-sandbox-setup.exe` under `bin\codex-resources`. NPM platform
|
|
145
|
+
packages use the official `vendor/<target-triple>/bin` layout with a sibling
|
|
146
|
+
`codex-resources` directory.
|
|
147
|
+
|
|
143
148
|
编译指定版本和目标平台:
|
|
144
149
|
|
|
145
150
|
```powershell
|
package/bin/codex.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
|
-
import { existsSync } from "node:fs";
|
|
4
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import path from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
7
8
|
|
|
8
9
|
const require = createRequire(import.meta.url);
|
|
10
|
+
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const codexPackageRoot = realpathSync(path.resolve(scriptDir, ".."));
|
|
9
12
|
const platformPackages = {
|
|
10
13
|
"linux-x64": "@jacks001314/codex-go-linux-x64",
|
|
11
14
|
"linux-arm64": "@jacks001314/codex-go-linux-arm64",
|
|
@@ -14,10 +17,19 @@ const platformPackages = {
|
|
|
14
17
|
"win32-x64": "@jacks001314/codex-go-win32-x64",
|
|
15
18
|
"win32-arm64": "@jacks001314/codex-go-win32-arm64",
|
|
16
19
|
};
|
|
20
|
+
const targetTriples = {
|
|
21
|
+
"linux-x64": "x86_64-unknown-linux-musl",
|
|
22
|
+
"linux-arm64": "aarch64-unknown-linux-musl",
|
|
23
|
+
"darwin-x64": "x86_64-apple-darwin",
|
|
24
|
+
"darwin-arm64": "aarch64-apple-darwin",
|
|
25
|
+
"win32-x64": "x86_64-pc-windows-msvc",
|
|
26
|
+
"win32-arm64": "aarch64-pc-windows-msvc",
|
|
27
|
+
};
|
|
17
28
|
|
|
18
29
|
const target = `${process.platform}-${process.arch}`;
|
|
19
30
|
const platformPackage = platformPackages[target];
|
|
20
|
-
|
|
31
|
+
const targetTriple = targetTriples[target];
|
|
32
|
+
if (!platformPackage || !targetTriple) {
|
|
21
33
|
console.error(`Unsupported platform: ${process.platform} (${process.arch})`);
|
|
22
34
|
process.exit(1);
|
|
23
35
|
}
|
|
@@ -26,9 +38,16 @@ let packageJsonPath;
|
|
|
26
38
|
try {
|
|
27
39
|
packageJsonPath = require.resolve(`${platformPackage}/package.json`);
|
|
28
40
|
} catch {
|
|
41
|
+
const packageManager = detectPackageManager();
|
|
42
|
+
const updateCommand =
|
|
43
|
+
packageManager === "bun"
|
|
44
|
+
? "bun install -g @jacks001314/codex-go@latest"
|
|
45
|
+
: packageManager === "pnpm"
|
|
46
|
+
? "pnpm add -g @jacks001314/codex-go@latest"
|
|
47
|
+
: "npm install -g @jacks001314/codex-go@latest";
|
|
29
48
|
console.error(
|
|
30
49
|
`Missing optional dependency ${platformPackage}. ` +
|
|
31
|
-
|
|
50
|
+
`Reinstall with: ${updateCommand}`,
|
|
32
51
|
);
|
|
33
52
|
process.exit(1);
|
|
34
53
|
}
|
|
@@ -36,6 +55,8 @@ try {
|
|
|
36
55
|
const executable = path.join(
|
|
37
56
|
path.dirname(packageJsonPath),
|
|
38
57
|
"vendor",
|
|
58
|
+
targetTriple,
|
|
59
|
+
"bin",
|
|
39
60
|
process.platform === "win32" ? "codex.exe" : "codex",
|
|
40
61
|
);
|
|
41
62
|
if (!existsSync(executable)) {
|
|
@@ -43,8 +64,49 @@ if (!existsSync(executable)) {
|
|
|
43
64
|
process.exit(1);
|
|
44
65
|
}
|
|
45
66
|
|
|
46
|
-
|
|
67
|
+
function isPnpmOwnedCodexInstall(nodeModulesDir) {
|
|
68
|
+
if (!existsSync(path.join(nodeModulesDir, ".modules.yaml"))) return false;
|
|
69
|
+
try {
|
|
70
|
+
return realpathSync(path.join(nodeModulesDir, "@jacks001314", "codex-go")) === codexPackageRoot;
|
|
71
|
+
} catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function detectPackageManager() {
|
|
77
|
+
const entrypointDir = path.dirname(path.resolve(process.argv[1]));
|
|
78
|
+
for (const startDir of new Set([codexPackageRoot, entrypointDir])) {
|
|
79
|
+
const filesystemRoot = path.parse(startDir).root;
|
|
80
|
+
for (let currentDir = startDir; currentDir !== filesystemRoot; currentDir = path.dirname(currentDir)) {
|
|
81
|
+
if (isPnpmOwnedCodexInstall(path.join(currentDir, "node_modules"))) return "pnpm";
|
|
82
|
+
}
|
|
83
|
+
if (isPnpmOwnedCodexInstall(path.join(filesystemRoot, "node_modules"))) return "pnpm";
|
|
84
|
+
}
|
|
85
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
86
|
+
const execPath = process.env.npm_execpath || "";
|
|
87
|
+
if (
|
|
88
|
+
/\bbun\//.test(userAgent) ||
|
|
89
|
+
execPath.includes("bun") ||
|
|
90
|
+
scriptDir.includes(".bun/install/global") ||
|
|
91
|
+
scriptDir.includes(".bun\\install\\global")
|
|
92
|
+
) {
|
|
93
|
+
return "bun";
|
|
94
|
+
}
|
|
95
|
+
return userAgent ? "npm" : null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const packageManager = detectPackageManager();
|
|
99
|
+
const packageManagerEnvVar =
|
|
100
|
+
packageManager === "bun"
|
|
101
|
+
? "CODEX_MANAGED_BY_BUN"
|
|
102
|
+
: packageManager === "pnpm"
|
|
103
|
+
? "CODEX_MANAGED_BY_PNPM"
|
|
104
|
+
: "CODEX_MANAGED_BY_NPM";
|
|
105
|
+
const env = { ...process.env, CODEX_MANAGED_PACKAGE_ROOT: codexPackageRoot };
|
|
106
|
+
delete env.CODEX_MANAGED_BY_NPM;
|
|
47
107
|
delete env.CODEX_MANAGED_BY_BUN;
|
|
108
|
+
delete env.CODEX_MANAGED_BY_PNPM;
|
|
109
|
+
env[packageManagerEnvVar] = "1";
|
|
48
110
|
|
|
49
111
|
const child = spawn(executable, process.argv.slice(2), {
|
|
50
112
|
stdio: "inherit",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jacks001314/codex-go",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Codex CLI implemented in Go",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"url": "git+https://github.com/jacks001314/codex_go.git"
|
|
19
19
|
},
|
|
20
20
|
"optionalDependencies": {
|
|
21
|
-
"@jacks001314/codex-go-linux-x64": "
|
|
22
|
-
"@jacks001314/codex-go-linux-arm64": "
|
|
23
|
-
"@jacks001314/codex-go-darwin-x64": "
|
|
24
|
-
"@jacks001314/codex-go-darwin-arm64": "
|
|
25
|
-
"@jacks001314/codex-go-win32-x64": "
|
|
26
|
-
"@jacks001314/codex-go-win32-arm64": "
|
|
21
|
+
"@jacks001314/codex-go-linux-x64": "1.0.0",
|
|
22
|
+
"@jacks001314/codex-go-linux-arm64": "1.0.0",
|
|
23
|
+
"@jacks001314/codex-go-darwin-x64": "1.0.0",
|
|
24
|
+
"@jacks001314/codex-go-darwin-arm64": "1.0.0",
|
|
25
|
+
"@jacks001314/codex-go-win32-x64": "1.0.0",
|
|
26
|
+
"@jacks001314/codex-go-win32-arm64": "1.0.0"
|
|
27
27
|
}
|
|
28
28
|
}
|