13
pnpm-lock.yaml
generated
13
pnpm-lock.yaml
generated
@@ -34,6 +34,9 @@ importers:
|
|||||||
eslint-plugin-jest:
|
eslint-plugin-jest:
|
||||||
specifier: ^29.0.1
|
specifier: ^29.0.1
|
||||||
version: 29.0.1(@typescript-eslint/eslint-plugin@8.45.0(@typescript-eslint/parser@8.45.0(eslint@9.36.0)(typescript@5.9.2))(eslint@9.36.0)(typescript@5.9.2))(eslint@9.36.0)(jest@29.7.0(@types/node@20.19.18)(ts-node@10.9.2(@types/node@20.19.18)(typescript@5.9.2)))(typescript@5.9.2)
|
version: 29.0.1(@typescript-eslint/eslint-plugin@8.45.0(@typescript-eslint/parser@8.45.0(eslint@9.36.0)(typescript@5.9.2))(eslint@9.36.0)(typescript@5.9.2))(eslint@9.36.0)(jest@29.7.0(@types/node@20.19.18)(ts-node@10.9.2(@types/node@20.19.18)(typescript@5.9.2)))(typescript@5.9.2)
|
||||||
|
eslint-plugin-node-import:
|
||||||
|
specifier: ^1.0.5
|
||||||
|
version: 1.0.5(eslint@9.36.0)
|
||||||
jest:
|
jest:
|
||||||
specifier: ^29.7.0
|
specifier: ^29.7.0
|
||||||
version: 29.7.0(@types/node@20.19.18)(ts-node@10.9.2(@types/node@20.19.18)(typescript@5.9.2))
|
version: 29.7.0(@types/node@20.19.18)(ts-node@10.9.2(@types/node@20.19.18)(typescript@5.9.2))
|
||||||
@@ -1084,6 +1087,12 @@ packages:
|
|||||||
jest:
|
jest:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
eslint-plugin-node-import@1.0.5:
|
||||||
|
resolution: {integrity: sha512-razzgbr3EcB5+bm8/gqTqzTJ7Bpiu8PIChiAMRfZCNigr9GZBtnVSI+wPw+RGbWYCCIzWAsK/A7ihoAeSz5j7A==}
|
||||||
|
engines: {node: ^14.18.0 || ^16.0.0 || >= 18.0.0}
|
||||||
|
peerDependencies:
|
||||||
|
eslint: '>=7'
|
||||||
|
|
||||||
eslint-scope@8.4.0:
|
eslint-scope@8.4.0:
|
||||||
resolution: {integrity: sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==}
|
resolution: {integrity: sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
@@ -3244,6 +3253,10 @@ snapshots:
|
|||||||
- supports-color
|
- supports-color
|
||||||
- typescript
|
- typescript
|
||||||
|
|
||||||
|
eslint-plugin-node-import@1.0.5(eslint@9.36.0):
|
||||||
|
dependencies:
|
||||||
|
eslint: 9.36.0
|
||||||
|
|
||||||
eslint-scope@8.4.0:
|
eslint-scope@8.4.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
esrecurse: 4.3.0
|
esrecurse: 4.3.0
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
import eslint from "@eslint/js";
|
import eslint from "@eslint/js";
|
||||||
import { defineConfig } from "eslint/config";
|
import { defineConfig } from "eslint/config";
|
||||||
import tseslint from "typescript-eslint";
|
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": "^9.36.0",
|
||||||
"eslint-config-prettier": "^9.1.2",
|
"eslint-config-prettier": "^9.1.2",
|
||||||
"eslint-plugin-jest": "^29.0.1",
|
"eslint-plugin-jest": "^29.0.1",
|
||||||
|
"eslint-plugin-node-import": "^1.0.5",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"prettier": "^3.6.2",
|
"prettier": "^3.6.2",
|
||||||
"ts-jest": "^29.3.4",
|
"ts-jest": "^29.3.4",
|
||||||
|
"ts-jest-mock-import-meta": "^1.3.1",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"tsup": "^8.5.0",
|
"tsup": "^8.5.0",
|
||||||
"typescript": "^5.9.2",
|
"typescript": "^5.9.2",
|
||||||
"typescript-eslint": "^8.45.0",
|
"typescript-eslint": "^8.45.0"
|
||||||
"ts-jest-mock-import-meta": "^1.3.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ import { Codex } from "@openai/codex-sdk";
|
|||||||
import type { ThreadEvent, ThreadItem } from "@openai/codex-sdk";
|
import type { ThreadEvent, ThreadItem } from "@openai/codex-sdk";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
|
||||||
const executablePath =
|
const codexPathOverride =
|
||||||
process.env.CODEX_EXECUTABLE ??
|
process.env.CODEX_EXECUTABLE ??
|
||||||
path.join(process.cwd(), "..", "..", "codex-rs", "target", "debug", "codex");
|
path.join(process.cwd(), "..", "..", "codex-rs", "target", "debug", "codex");
|
||||||
|
|
||||||
const codex = new Codex({ executablePath });
|
const codex = new Codex({ codexPathOverride });
|
||||||
const thread = codex.startThread();
|
const thread = codex.startThread();
|
||||||
const rl = createInterface({ input, output });
|
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";
|
import readline from "node:readline";
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ export class CodexExec {
|
|||||||
|
|
||||||
if (args.threadId) {
|
if (args.threadId) {
|
||||||
commandArgs.push("resume", args.threadId);
|
commandArgs.push("resume", args.threadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const env = {
|
const env = {
|
||||||
...process.env,
|
...process.env,
|
||||||
@@ -67,7 +67,7 @@ export class CodexExec {
|
|||||||
|
|
||||||
let spawnError: unknown | null = null;
|
let spawnError: unknown | null = null;
|
||||||
child.once("error", (err) => (spawnError = err));
|
child.once("error", (err) => (spawnError = err));
|
||||||
|
|
||||||
if (!child.stdin) {
|
if (!child.stdin) {
|
||||||
child.kill();
|
child.kill();
|
||||||
throw new Error("Child process has no stdin");
|
throw new Error("Child process has no stdin");
|
||||||
@@ -104,7 +104,9 @@ export class CodexExec {
|
|||||||
resolve(code);
|
resolve(code);
|
||||||
} else {
|
} else {
|
||||||
const stderrBuffer = Buffer.concat(stderrChunks);
|
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", () => {
|
jest.mock("node:child_process", () => {
|
||||||
const actual = jest.requireActual<typeof import("child_process")>("child_process");
|
const actual = jest.requireActual<typeof import("node:child_process")>("node:child_process");
|
||||||
return { ...actual, spawn: jest.fn(actual.spawn) };
|
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>;
|
const spawnMock = child_process.spawn as jest.MockedFunction<typeof actualChildProcess.spawn>;
|
||||||
|
|
||||||
export function codexExecSpy(): { args: string[][]; restore: () => void } {
|
export function codexExecSpy(): { args: string[][]; restore: () => void } {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import os from "os";
|
import os from "node:os";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
|
|
||||||
import { codexExecSpy } from "./codexExecSpy";
|
import { codexExecSpy } from "./codexExecSpy";
|
||||||
import { describe, expect, it } from "@jest/globals";
|
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";
|
import { describe, expect, it } from "@jest/globals";
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,6 @@
|
|||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"stripInternal": true
|
"stripInternal": true
|
||||||
},
|
},
|
||||||
"include": ["src", "tests", "tsup.config.ts"],
|
"include": ["src", "tests", "tsup.config.ts", "samples"],
|
||||||
"exclude": ["dist", "node_modules"]
|
"exclude": ["dist", "node_modules"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user