codex-potter 0.0.0-dev
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 +27 -0
- package/bin/codex-potter.js +113 -0
- package/package.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# CodexPotter
|
|
2
|
+
|
|
3
|
+
Install:
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install -g codex-potter
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Run:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
codex-potter --yolo
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Supported platforms (via bundled native binaries):
|
|
16
|
+
|
|
17
|
+
- macOS: Apple Silicon + Intel
|
|
18
|
+
- Linux: x86_64 + aarch64
|
|
19
|
+
- Windows: x86_64 + aarch64 (ARM64)
|
|
20
|
+
- Android: treated as Linux (uses the bundled Linux musl binaries)
|
|
21
|
+
|
|
22
|
+
Build from source:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
cargo build
|
|
26
|
+
./target/debug/codex-potter --yolo
|
|
27
|
+
```
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Unified entry point for the CodexPotter CLI.
|
|
3
|
+
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
const { platform, arch } = process;
|
|
12
|
+
|
|
13
|
+
let targetTriple = null;
|
|
14
|
+
switch (platform) {
|
|
15
|
+
case "linux":
|
|
16
|
+
case "android":
|
|
17
|
+
switch (arch) {
|
|
18
|
+
case "x64":
|
|
19
|
+
targetTriple = "x86_64-unknown-linux-musl";
|
|
20
|
+
break;
|
|
21
|
+
case "arm64":
|
|
22
|
+
targetTriple = "aarch64-unknown-linux-musl";
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
case "darwin":
|
|
29
|
+
switch (arch) {
|
|
30
|
+
case "x64":
|
|
31
|
+
targetTriple = "x86_64-apple-darwin";
|
|
32
|
+
break;
|
|
33
|
+
case "arm64":
|
|
34
|
+
targetTriple = "aarch64-apple-darwin";
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
case "win32":
|
|
41
|
+
switch (arch) {
|
|
42
|
+
case "x64":
|
|
43
|
+
targetTriple = "x86_64-pc-windows-msvc";
|
|
44
|
+
break;
|
|
45
|
+
case "arm64":
|
|
46
|
+
targetTriple = "aarch64-pc-windows-msvc";
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!targetTriple) {
|
|
57
|
+
throw new Error(`Unsupported platform: ${platform} (${arch})`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const vendorRoot = path.join(__dirname, "..", "vendor");
|
|
61
|
+
const archRoot = path.join(vendorRoot, targetTriple);
|
|
62
|
+
const binaryName =
|
|
63
|
+
process.platform === "win32" ? "codex-potter.exe" : "codex-potter";
|
|
64
|
+
const binaryPath = path.join(archRoot, "codex-potter", binaryName);
|
|
65
|
+
|
|
66
|
+
const env = { ...process.env, CODEX_POTTER_MANAGED_BY_NPM: "1" };
|
|
67
|
+
|
|
68
|
+
// Use an asynchronous spawn instead of spawnSync so that Node is able to
|
|
69
|
+
// respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
|
|
70
|
+
// executing. This allows us to forward those signals to the child process
|
|
71
|
+
// and guarantees that when either the child terminates or the parent
|
|
72
|
+
// receives a fatal signal, both processes exit in a predictable manner.
|
|
73
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
74
|
+
stdio: "inherit",
|
|
75
|
+
env,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
child.on("error", (err) => {
|
|
79
|
+
// eslint-disable-next-line no-console
|
|
80
|
+
console.error(err);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const forwardSignal = (signal) => {
|
|
85
|
+
if (child.killed) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
child.kill(signal);
|
|
90
|
+
} catch {
|
|
91
|
+
/* ignore */
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
|
|
96
|
+
process.on(sig, () => forwardSignal(sig));
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const childResult = await new Promise((resolve) => {
|
|
100
|
+
child.on("exit", (code, signal) => {
|
|
101
|
+
if (signal) {
|
|
102
|
+
resolve({ type: "signal", signal });
|
|
103
|
+
} else {
|
|
104
|
+
resolve({ type: "code", exitCode: code ?? 1 });
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
if (childResult.type === "signal") {
|
|
110
|
+
process.kill(process.pid, childResult.signal);
|
|
111
|
+
} else {
|
|
112
|
+
process.exit(childResult.exitCode);
|
|
113
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codex-potter",
|
|
3
|
+
"version": "0.0.0-dev",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"bin": {
|
|
6
|
+
"codex-potter": "bin/codex-potter.js"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=16"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"vendor",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/breezewish/codex-potter.git",
|
|
20
|
+
"directory": "npm"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|