Skip to content

Commit 627ed37

Browse files
Use codex from npm dependency & prepare for npm publish (#84)
* LLM-26485: prepare codex-acp for npm release * LLM-26485: move project under @JetBrains organization namespace * LLM-26485: simplify build command * LLM-26485: move main dependencies from devDependencies to dependencies
1 parent 3559fb4 commit 627ed37

4 files changed

Lines changed: 61 additions & 20 deletions

File tree

build.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { build } from 'esbuild';
2+
3+
await build({
4+
entryPoints: ['src/index.ts'],
5+
bundle: true,
6+
platform: 'node',
7+
format: 'esm',
8+
outfile: 'dist/index.js',
9+
external: ['@openai/codex'],
10+
// Polyfill `require` for CJS modules bundled into ESM output
11+
banner: {
12+
js: "import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);",
13+
},
14+
});

package-lock.json

Lines changed: 28 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
{
2-
"name": "codex-acp",
2+
"name": "@jetbrains/codex-acp",
33
"version": "0.0.31",
44
"description": "",
55
"main": "dist/index.js",
6+
"bin": {
7+
"codex-acp": "dist/index.js"
8+
},
9+
"files": [
10+
"dist/",
11+
"README.md",
12+
"LICENSE",
13+
"package.json"
14+
],
615
"scripts": {
16+
"prepublishOnly": "npm run build",
17+
"build": "node build.mjs",
718
"bundle:all": "npm run bundle:linux-x64 && npm run bundle:linux-arm64 && npm run bundle:darwin-x64 && npm run bundle:darwin-arm64 && npm run bundle:win-x64 && npm run bundle:win-arm64",
819
"bundle:linux-x64": "bun build src/index.ts --minify --sourcemap --compile --target=bun-linux-x64-baseline --outfile dist/bin/codex-acp-x64-linux",
920
"bundle:linux-arm64": "bun build src/index.ts --minify --sourcemap --compile --target=bun-linux-arm64 --outfile dist/bin/codex-acp-arm64-linux",
@@ -30,7 +41,7 @@
3041
"license": "ISC",
3142
"type": "module",
3243
"devDependencies": {
33-
"@openai/codex": "^0.114.0",
44+
"esbuild": "^0.25.0",
3445
"@types/node": "^24.10.1",
3546
"mcp-hello-world": "^1.1.2",
3647
"tsx": "^4.20.6",
@@ -39,8 +50,9 @@
3950
},
4051
"dependencies": {
4152
"@agentclientprotocol/sdk": "^0.12.0",
42-
"diff": "^8.0.3",
53+
"vscode-jsonrpc": "^8.2.1",
4354
"open": "^11.0.0",
44-
"vscode-jsonrpc": "^8.2.1"
55+
"diff": "^8.0.3",
56+
"@openai/codex": "^0.114.0"
4557
}
4658
}

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
import {createRequire} from "node:module";
34
import * as acp from "@agentclientprotocol/sdk";
45
import {startCodexConnection} from "./CodexJsonRpcConnection";
56
import {CodexAcpServer} from "./CodexAcpServer";
@@ -29,7 +30,8 @@ if (process.argv[2] === "login") {
2930
}
3031

3132
function startAcpServer() {
32-
const codexPath = process.env["CODEX_PATH"] ?? "codex";
33+
const defaultCodexPath = createRequire(import.meta.url).resolve("@openai/codex/bin/codex.js");
34+
const codexPath = process.env["CODEX_PATH"] ?? defaultCodexPath;
3335
const configString = process.env["CODEX_CONFIG"];
3436
const authRequestString = process.env["DEFAULT_AUTH_REQUEST"];
3537
const modelProvider = process.env["MODEL_PROVIDER"];

0 commit comments

Comments
 (0)