@@ -1,5 +1,14 @@
|
||||
import eslint from "@eslint/js";
|
||||
import { defineConfig } from "eslint/config";
|
||||
import tseslint from "typescript-eslint";
|
||||
import nodeImport from "eslint-plugin-node-import";
|
||||
|
||||
export default defineConfig(eslint.configs.recommended, tseslint.configs.recommended);
|
||||
export default defineConfig(eslint.configs.recommended, tseslint.configs.recommended, {
|
||||
plugins: {
|
||||
"node-import": nodeImport,
|
||||
},
|
||||
|
||||
rules: {
|
||||
"node-import/prefer-node-protocol": 2,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -50,13 +50,14 @@
|
||||
"eslint": "^9.36.0",
|
||||
"eslint-config-prettier": "^9.1.2",
|
||||
"eslint-plugin-jest": "^29.0.1",
|
||||
"eslint-plugin-node-import": "^1.0.5",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.6.2",
|
||||
"ts-jest": "^29.3.4",
|
||||
"ts-jest-mock-import-meta": "^1.3.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsup": "^8.5.0",
|
||||
"typescript": "^5.9.2",
|
||||
"typescript-eslint": "^8.45.0",
|
||||
"ts-jest-mock-import-meta": "^1.3.1"
|
||||
"typescript-eslint": "^8.45.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import { Codex } from "@openai/codex-sdk";
|
||||
import type { ThreadEvent, ThreadItem } from "@openai/codex-sdk";
|
||||
import path from "node:path";
|
||||
|
||||
const executablePath =
|
||||
const codexPathOverride =
|
||||
process.env.CODEX_EXECUTABLE ??
|
||||
path.join(process.cwd(), "..", "..", "codex-rs", "target", "debug", "codex");
|
||||
|
||||
const codex = new Codex({ executablePath });
|
||||
const codex = new Codex({ codexPathOverride });
|
||||
const thread = codex.startThread();
|
||||
const rl = createInterface({ input, output });
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { spawn } from "child_process";
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
import readline from "node:readline";
|
||||
|
||||
@@ -49,7 +49,7 @@ export class CodexExec {
|
||||
|
||||
if (args.threadId) {
|
||||
commandArgs.push("resume", args.threadId);
|
||||
}
|
||||
}
|
||||
|
||||
const env = {
|
||||
...process.env,
|
||||
@@ -67,7 +67,7 @@ export class CodexExec {
|
||||
|
||||
let spawnError: unknown | null = null;
|
||||
child.once("error", (err) => (spawnError = err));
|
||||
|
||||
|
||||
if (!child.stdin) {
|
||||
child.kill();
|
||||
throw new Error("Child process has no stdin");
|
||||
@@ -104,7 +104,9 @@ export class CodexExec {
|
||||
resolve(code);
|
||||
} else {
|
||||
const stderrBuffer = Buffer.concat(stderrChunks);
|
||||
reject(new Error(`Codex Exec exited with code ${code}: ${stderrBuffer.toString('utf8')}`));
|
||||
reject(
|
||||
new Error(`Codex Exec exited with code ${code}: ${stderrBuffer.toString("utf8")}`),
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import * as child_process from "child_process";
|
||||
import * as child_process from "node:child_process";
|
||||
|
||||
jest.mock("child_process", () => {
|
||||
const actual = jest.requireActual<typeof import("child_process")>("child_process");
|
||||
jest.mock("node:child_process", () => {
|
||||
const actual = jest.requireActual<typeof import("node:child_process")>("node:child_process");
|
||||
return { ...actual, spawn: jest.fn(actual.spawn) };
|
||||
});
|
||||
|
||||
const actualChildProcess = jest.requireActual<typeof import("child_process")>("child_process");
|
||||
const actualChildProcess = jest.requireActual<typeof import("node:child_process")>("node:child_process");
|
||||
const spawnMock = child_process.spawn as jest.MockedFunction<typeof actualChildProcess.spawn>;
|
||||
|
||||
export function codexExecSpy(): { args: string[][]; restore: () => void } {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import { codexExecSpy } from "./codexExecSpy";
|
||||
import { describe, expect, it } from "@jest/globals";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import path from "path";
|
||||
import path from "node:path";
|
||||
|
||||
import { describe, expect, it } from "@jest/globals";
|
||||
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
"outDir": "dist",
|
||||
"stripInternal": true
|
||||
},
|
||||
"include": ["src", "tests", "tsup.config.ts"],
|
||||
"include": ["src", "tests", "tsup.config.ts", "samples"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user