Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Back out @lib indirection in tsconfig.json (#111)

Michael Bolin9b733fc48fb8
diff --git a/codex-cli/src/app.tsx b/codex-cli/src/app.tsx
index dbb0cdedc8..c0b8c6f4e3 100644
--- a/codex-cli/src/app.tsx
+++ b/codex-cli/src/app.tsx
@@ -1,5 +1,5 @@
+import type { ApprovalPolicy } from "./approvals";
import type { AppConfig } from "./utils/config";
-import type { ApprovalPolicy } from "@lib/approvals";
import type { ResponseItem } from "openai/resources/responses/responses";
import TerminalChat from "./components/chat/terminal-chat";
diff --git a/codex-cli/src/lib/approvals.ts b/codex-cli/src/approvals.ts
similarity index 99%
rename from codex-cli/src/lib/approvals.ts
rename to codex-cli/src/approvals.ts
index 8985939a43..0cf3703b54 100644
--- a/codex-cli/src/lib/approvals.ts
+++ b/codex-cli/src/approvals.ts
@@ -3,7 +3,7 @@ import type { ParseEntry, ControlOperator } from "shell-quote";
import {
identify_files_added,
identify_files_needed,
-} from "../utils/agent/apply-patch";
+} from "./utils/agent/apply-patch";
import * as path from "path";
import { parse } from "shell-quote";
diff --git a/codex-cli/src/cli.tsx b/codex-cli/src/cli.tsx
index 5e43dff1f3..0af421a431 100644
--- a/codex-cli/src/cli.tsx
+++ b/codex-cli/src/cli.tsx
@@ -1,9 +1,9 @@
#!/usr/bin/env node
import type { AppRollout } from "./app";
+import type { ApprovalPolicy } from "./approvals";
import type { CommandConfirmation } from "./utils/agent/agent-loop";
import type { AppConfig } from "./utils/config";
-import type { ApprovalPolicy } from "@lib/approvals";
import type { ResponseItem } from "openai/resources/responses/responses";
import App from "./app";
@@ -124,7 +124,7 @@ const cli = meow(
fullContext: {
type: "boolean",
aliases: ["f"],
- description: `Run in full-context editing approach. The model is given the whole code
+ description: `Run in full-context editing approach. The model is given the whole code
directory as context and performs changes in one go without acting.`,
},
},
diff --git a/codex-cli/src/components/chat/multiline-editor.tsx b/codex-cli/src/components/chat/multiline-editor.tsx
index c18555447e..c99961bbcd 100644
--- a/codex-cli/src/components/chat/multiline-editor.tsx
+++ b/codex-cli/src/components/chat/multiline-editor.tsx
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useTerminalSize } from "../../hooks/use-terminal-size";
-import TextBuffer from "../../lib/text-buffer.js";
+import TextBuffer from "../../text-buffer.js";
import chalk from "chalk";
import { Box, Text, useInput, useStdin } from "ink";
import { EventEmitter } from "node:events";
diff --git a/codex-cli/src/components/chat/terminal-chat-tool-call-item.tsx b/codex-cli/src/components/chat/terminal-chat-tool-call-item.tsx
index 1aeb7d7e98..5853460884 100644
--- a/codex-cli/src/components/chat/terminal-chat-tool-call-item.tsx
+++ b/codex-cli/src/components/chat/terminal-chat-tool-call-item.tsx
@@ -1,5 +1,5 @@
+import { parseApplyPatch } from "../../parse-apply-patch";
import { shortenPath } from "../../utils/short-path";
-import { parseApplyPatch } from "@lib/parse-apply-patch";
import chalk from "chalk";
import { Text } from "ink";
import React from "react";
diff --git a/codex-cli/src/components/chat/terminal-chat.tsx b/codex-cli/src/components/chat/terminal-chat.tsx
index bbc9bb052a..35fecec564 100644
--- a/codex-cli/src/components/chat/terminal-chat.tsx
+++ b/codex-cli/src/components/chat/terminal-chat.tsx
@@ -1,6 +1,6 @@
+import type { ApplyPatchCommand, ApprovalPolicy } from "../../approvals.js";
import type { CommandConfirmation } from "../../utils/agent/agent-loop.js";
import type { AppConfig } from "../../utils/config.js";
-import type { ApplyPatchCommand, ApprovalPolicy } from "@lib/approvals.js";
import type { ColorName } from "chalk";
import type { ResponseItem } from "openai/resources/responses/responses.mjs";
import type { ReviewDecision } from "src/utils/agent/review.ts";
@@ -12,6 +12,7 @@ import {
uniqueById,
} from "./terminal-chat-utils.js";
import TerminalMessageHistory from "./terminal-message-history.js";
+import { formatCommandForDisplay } from "../../format-command.js";
import { useConfirmation } from "../../hooks/use-confirmation.js";
import { useTerminalSize } from "../../hooks/use-terminal-size.js";
import { AgentLoop } from "../../utils/agent/agent-loop.js";
@@ -25,7 +26,6 @@ import ApprovalModeOverlay from "../approval-mode-overlay.js";
import HelpOverlay from "../help-overlay.js";
import HistoryOverlay from "../history-overlay.js";
import ModelOverlay from "../model-overlay.js";
-import { formatCommandForDisplay } from "@lib/format-command.js";
import { Box, Text } from "ink";
import React, { useEffect, useMemo, useState } from "react";
import { inspect } from "util";
diff --git a/codex-cli/src/lib/format-command.ts b/codex-cli/src/format-command.ts
similarity index 100%
rename from codex-cli/src/lib/format-command.ts
rename to codex-cli/src/format-command.ts
diff --git a/codex-cli/src/lib/parse-apply-patch.ts b/codex-cli/src/parse-apply-patch.ts
similarity index 100%
rename from codex-cli/src/lib/parse-apply-patch.ts
rename to codex-cli/src/parse-apply-patch.ts
diff --git a/codex-cli/src/lib/text-buffer.ts b/codex-cli/src/text-buffer.ts
similarity index 100%
rename from codex-cli/src/lib/text-buffer.ts
rename to codex-cli/src/text-buffer.ts
diff --git a/codex-cli/src/utils/agent/agent-loop.ts b/codex-cli/src/utils/agent/agent-loop.ts
index e2b465733d..d88604c471 100644
--- a/codex-cli/src/utils/agent/agent-loop.ts
+++ b/codex-cli/src/utils/agent/agent-loop.ts
@@ -1,6 +1,6 @@
import type { ReviewDecision } from "./review.js";
+import type { ApplyPatchCommand, ApprovalPolicy } from "../../approvals.js";
import type { AppConfig } from "../config.js";
-import type { ApplyPatchCommand, ApprovalPolicy } from "@lib/approvals.js";
import type {
ResponseFunctionToolCall,
ResponseInputItem,
diff --git a/codex-cli/src/utils/agent/exec.ts b/codex-cli/src/utils/agent/exec.ts
index aade68a860..a441f192f8 100644
--- a/codex-cli/src/utils/agent/exec.ts
+++ b/codex-cli/src/utils/agent/exec.ts
@@ -5,7 +5,7 @@ import { process_patch } from "./apply-patch.js";
import { SandboxType } from "./sandbox/interface.js";
import { execWithSeatbelt } from "./sandbox/macos-seatbelt.js";
import { exec as rawExec } from "./sandbox/raw-exec.js";
-import { formatCommandForDisplay } from "@lib/format-command.js";
+import { formatCommandForDisplay } from "../../format-command.js";
import fs from "fs";
import os from "os";
diff --git a/codex-cli/src/utils/agent/handle-exec-command.ts b/codex-cli/src/utils/agent/handle-exec-command.ts
index 5eaa11d660..41b7abbcd4 100644
--- a/codex-cli/src/utils/agent/handle-exec-command.ts
+++ b/codex-cli/src/utils/agent/handle-exec-command.ts
@@ -1,7 +1,7 @@
import type { CommandConfirmation } from "./agent-loop.js";
import type { AppConfig } from "../config.js";
import type { ExecInput } from "./sandbox/interface.js";
-import type { ApplyPatchCommand, ApprovalPolicy } from "@lib/approvals.js";
+import type { ApplyPatchCommand, ApprovalPolicy } from "../../approvals.js";
import type { ResponseInputItem } from "openai/resources/responses/responses.mjs";
import { exec, execApplyPatch } from "./exec.js";
@@ -9,8 +9,8 @@ import { isLoggingEnabled, log } from "./log.js";
import { ReviewDecision } from "./review.js";
import { FullAutoErrorMode } from "../auto-approval-mode.js";
import { SandboxType } from "./sandbox/interface.js";
-import { canAutoApprove } from "@lib/approvals.js";
-import { formatCommandForDisplay } from "@lib/format-command.js";
+import { canAutoApprove } from "../../approvals.js";
+import { formatCommandForDisplay } from "../../format-command.js";
import { access } from "fs/promises";
// ---------------------------------------------------------------------------
diff --git a/codex-cli/src/utils/agent/review.ts b/codex-cli/src/utils/agent/review.ts
index ed2af0ce17..a370388569 100644
--- a/codex-cli/src/utils/agent/review.ts
+++ b/codex-cli/src/utils/agent/review.ts
@@ -1,4 +1,4 @@
-import type { SafeCommandReason } from "@lib/approvals";
+import type { SafeCommandReason } from "../../approvals";
export type CommandReviewDetails = {
cmd: Array<string>;
diff --git a/codex-cli/src/utils/parsers.ts b/codex-cli/src/utils/parsers.ts
index cb477c1d7d..815e7b2f00 100644
--- a/codex-cli/src/utils/parsers.ts
+++ b/codex-cli/src/utils/parsers.ts
@@ -3,11 +3,13 @@ import type {
ExecInput,
ExecOutputMetadata,
} from "./agent/sandbox/interface.js";
-import type { SafeCommandReason } from "@lib/approvals.js";
import type { ResponseFunctionToolCall } from "openai/resources/responses/responses.mjs";
+import { isSafeCommand, type SafeCommandReason } from "../approvals.js";
import { log } from "node:console";
import process from "process";
+import { parse } from "shell-quote";
+import { formatCommandForDisplay } from "src/format-command.js";
// The console utility import is intentionally explicit to avoid bundlers from
// including the entire `console` module when only the `log` function is
@@ -23,52 +25,6 @@ const SAFE_SHELL_OPERATORS: ReadonlySet<string> = new Set([
";",
]);
-// Lazily resolve heavy dependencies at runtime to avoid test environments
-// (which might not have the @lib alias configured) from failing at import
-// time. If the modules cannot be loaded we fall back to permissive stub
-// implementations so that basic functionality – like unit‑testing small UI
-// helpers – continues to work without the full codex‑lib dependency tree.
-
-let isSafeCommand: (cmd: Array<string>) => SafeCommandReason | null = () =>
- null;
-let shellQuoteParse:
- | ((cmd: string, env?: Record<string, string | undefined>) => Array<unknown>)
- | undefined;
-let formatCommandForDisplay: (cmd: Array<string>) => string = (cmd) =>
- cmd.join(" ");
-
-async function loadLibs(): Promise<void> {
- try {
- const approvals = await import("@lib/approvals.js");
- if (typeof approvals.isSafeCommand === "function") {
- isSafeCommand = approvals.isSafeCommand;
- }
- } catch {
- // ignore – keep stub
- }
- try {
- const fmt = await import("@lib/format-command.js");
- if (typeof fmt.formatCommandForDisplay === "function") {
- formatCommandForDisplay = fmt.formatCommandForDisplay;
- }
- } catch {
- // ignore – keep stub
- }
- try {
- const sq = await import("shell-quote");
- if (typeof sq.parse === "function") {
- shellQuoteParse = sq.parse as typeof shellQuoteParse;
- }
- } catch {
- // ignore – keep stub
- }
-}
-
-// Trigger the dynamic import in the background; callers that need the real
-// implementation should await the returned promise (parsers currently does not
-// require this for correctness during tests).
-void loadLibs();
-
export function parseToolCallOutput(toolCallOutput: string): {
output: string;
metadata: ExecOutputMetadata;
@@ -175,10 +131,9 @@ function computeAutoApproval(cmd: Array<string>): SafeCommandReason | null {
cmd.length === 3 &&
cmd[0] === "bash" &&
cmd[1] === "-lc" &&
- typeof cmd[2] === "string" &&
- shellQuoteParse
+ typeof cmd[2] === "string"
) {
- const parsed = shellQuoteParse(cmd[2], process.env ?? {});
+ const parsed = parse(cmd[2], process.env ?? {});
if (parsed.length === 0) {
return null;
}
diff --git a/codex-cli/tests/agent-cancel-early.test.ts b/codex-cli/tests/agent-cancel-early.test.ts
index b7b5fdcae7..b235a6d6bc 100644
--- a/codex-cli/tests/agent-cancel-early.test.ts
+++ b/codex-cli/tests/agent-cancel-early.test.ts
@@ -64,13 +64,13 @@ vi.mock("openai", () => {
};
});
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
}));
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
__esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "),
}));
diff --git a/codex-cli/tests/agent-cancel-prev-response.test.ts b/codex-cli/tests/agent-cancel-prev-response.test.ts
index 4047f88452..fe73c338cc 100644
--- a/codex-cli/tests/agent-cancel-prev-response.test.ts
+++ b/codex-cli/tests/agent-cancel-prev-response.test.ts
@@ -71,13 +71,13 @@ vi.mock("openai", () => {
});
// Stub helpers not relevant for this test.
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
}));
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
__esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "),
}));
diff --git a/codex-cli/tests/agent-cancel-race.test.ts b/codex-cli/tests/agent-cancel-race.test.ts
index c9c1845d8e..89e7cca744 100644
--- a/codex-cli/tests/agent-cancel-race.test.ts
+++ b/codex-cli/tests/agent-cancel-race.test.ts
@@ -67,11 +67,11 @@ vi.mock("openai", () => {
});
// Stubs for external helpers referenced indirectly.
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
__esModule: true,
isSafeCommand: () => null,
}));
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
__esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "),
}));
diff --git a/codex-cli/tests/agent-cancel.test.ts b/codex-cli/tests/agent-cancel.test.ts
index 93ff5ba317..69c17f7f7e 100644
--- a/codex-cli/tests/agent-cancel.test.ts
+++ b/codex-cli/tests/agent-cancel.test.ts
@@ -47,7 +47,7 @@ vi.mock("openai", () => {
});
// Mock the approvals and formatCommand helpers referenced by handle‑exec‑command.
-vi.mock("@lib/approvals.js", () => {
+vi.mock("../src/approvals.js", () => {
return {
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
@@ -57,7 +57,7 @@ vi.mock("@lib/approvals.js", () => {
};
});
-vi.mock("@lib/format-command.js", () => {
+vi.mock("../src/format-command.js", () => {
return {
__esModule: true,
formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "),
diff --git a/codex-cli/tests/agent-function-call-id.test.ts b/codex-cli/tests/agent-function-call-id.test.ts
index 7d0a55d122..d50c08eea4 100644
--- a/codex-cli/tests/agent-function-call-id.test.ts
+++ b/codex-cli/tests/agent-function-call-id.test.ts
@@ -88,14 +88,14 @@ vi.mock("openai", () => {
});
// Stub approvals & command formatting – not relevant for this test.
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null,
}));
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
__esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "),
}));
diff --git a/codex-cli/tests/agent-generic-network-error.test.ts b/codex-cli/tests/agent-generic-network-error.test.ts
index 8c636fbda3..942adff668 100644
--- a/codex-cli/tests/agent-generic-network-error.test.ts
+++ b/codex-cli/tests/agent-generic-network-error.test.ts
@@ -23,14 +23,14 @@ vi.mock("openai", () => {
});
// Stub approvals / formatting helpers – unrelated to network handling.
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null,
}));
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
__esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "),
}));
diff --git a/codex-cli/tests/agent-invalid-request-error.test.ts b/codex-cli/tests/agent-invalid-request-error.test.ts
index 631d451944..090d0b52d9 100644
--- a/codex-cli/tests/agent-invalid-request-error.test.ts
+++ b/codex-cli/tests/agent-invalid-request-error.test.ts
@@ -22,14 +22,14 @@ vi.mock("openai", () => {
};
});
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null,
}));
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
__esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "),
}));
diff --git a/codex-cli/tests/agent-max-tokens-error.test.ts b/codex-cli/tests/agent-max-tokens-error.test.ts
index 5e01229454..de4fd17026 100644
--- a/codex-cli/tests/agent-max-tokens-error.test.ts
+++ b/codex-cli/tests/agent-max-tokens-error.test.ts
@@ -22,14 +22,14 @@ vi.mock("openai", () => {
};
});
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null,
}));
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
__esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "),
}));
diff --git a/codex-cli/tests/agent-network-errors.test.ts b/codex-cli/tests/agent-network-errors.test.ts
index e01b08e918..f98ea5bf19 100644
--- a/codex-cli/tests/agent-network-errors.test.ts
+++ b/codex-cli/tests/agent-network-errors.test.ts
@@ -42,14 +42,14 @@ vi.mock("openai", () => {
});
// Stub approvals / formatting helpers – not relevant here.
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null,
}));
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
__esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "),
}));
diff --git a/codex-cli/tests/agent-project-doc.test.ts b/codex-cli/tests/agent-project-doc.test.ts
index 97ad9c8c34..d3050f3953 100644
--- a/codex-cli/tests/agent-project-doc.test.ts
+++ b/codex-cli/tests/agent-project-doc.test.ts
@@ -51,7 +51,7 @@ vi.mock("openai", () => {
// The AgentLoop pulls these helpers in order to decide whether a command can
// be auto‑approved. None of that matters for this test, so we stub the module
// with minimal no‑op implementations.
-vi.mock("@lib/approvals.js", () => {
+vi.mock("../src/approvals.js", () => {
return {
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
@@ -61,7 +61,7 @@ vi.mock("@lib/approvals.js", () => {
};
});
-vi.mock("@lib/format-command.js", () => {
+vi.mock("../src/format-command.js", () => {
return {
__esModule: true,
formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "),
diff --git a/codex-cli/tests/agent-rate-limit-error.test.ts b/codex-cli/tests/agent-rate-limit-error.test.ts
index 18779450aa..9782744679 100644
--- a/codex-cli/tests/agent-rate-limit-error.test.ts
+++ b/codex-cli/tests/agent-rate-limit-error.test.ts
@@ -34,14 +34,14 @@ vi.mock("openai", () => {
// Stub helpers that the agent indirectly imports so it does not attempt any
// file‑system access or real approvals logic during the test.
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null,
}));
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
__esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "),
}));
diff --git a/codex-cli/tests/agent-server-retry.test.ts b/codex-cli/tests/agent-server-retry.test.ts
index 9ec4eb5aac..09278f2ceb 100644
--- a/codex-cli/tests/agent-server-retry.test.ts
+++ b/codex-cli/tests/agent-server-retry.test.ts
@@ -32,14 +32,14 @@ vi.mock("openai", () => {
};
});
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null,
}));
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
__esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "),
}));
diff --git a/codex-cli/tests/agent-terminate.test.ts b/codex-cli/tests/agent-terminate.test.ts
index 7a60456518..bce77437af 100644
--- a/codex-cli/tests/agent-terminate.test.ts
+++ b/codex-cli/tests/agent-terminate.test.ts
@@ -49,7 +49,7 @@ vi.mock("openai", () => {
// --- Helpers referenced by handle‑exec‑command -----------------------------
-vi.mock("@lib/approvals.js", () => {
+vi.mock("../src/approvals.js", () => {
return {
__esModule: true,
alwaysApprovedCommands: new Set<string>(),
@@ -59,7 +59,7 @@ vi.mock("@lib/approvals.js", () => {
};
});
-vi.mock("@lib/format-command.js", () => {
+vi.mock("../src/format-command.js", () => {
return {
__esModule: true,
formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "),
diff --git a/codex-cli/tests/agent-thinking-time.test.ts b/codex-cli/tests/agent-thinking-time.test.ts
index c94d8a5e5e..7132070084 100644
--- a/codex-cli/tests/agent-thinking-time.test.ts
+++ b/codex-cli/tests/agent-thinking-time.test.ts
@@ -74,12 +74,12 @@ vi.mock("openai", () => {
});
// Stub helpers referenced indirectly so we do not pull in real FS/network
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
__esModule: true,
isSafeCommand: () => null,
}));
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
__esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "),
}));
diff --git a/codex-cli/tests/approvals.test.ts b/codex-cli/tests/approvals.test.ts
index e06db94092..7cb0bd3d3e 100644
--- a/codex-cli/tests/approvals.test.ts
+++ b/codex-cli/tests/approvals.test.ts
@@ -1,6 +1,6 @@
-import type { SafetyAssessment } from "../src/lib/approvals";
+import type { SafetyAssessment } from "../src/approvals";
-import { canAutoApprove } from "../src/lib/approvals";
+import { canAutoApprove } from "../src/approvals";
import { describe, test, expect } from "vitest";
describe("canAutoApprove()", () => {
diff --git a/codex-cli/tests/external-editor.test.ts b/codex-cli/tests/external-editor.test.ts
index d530be5ecc..77041c2870 100644
--- a/codex-cli/tests/external-editor.test.ts
+++ b/codex-cli/tests/external-editor.test.ts
@@ -1,4 +1,4 @@
-import TextBuffer from "../src/lib/text-buffer";
+import TextBuffer from "../src/text-buffer";
import { describe, it, expect, vi } from "vitest";
/* -------------------------------------------------------------------------
diff --git a/codex-cli/tests/format-command.test.ts b/codex-cli/tests/format-command.test.ts
index 3981d9b106..7de417308a 100644
--- a/codex-cli/tests/format-command.test.ts
+++ b/codex-cli/tests/format-command.test.ts
@@ -1,4 +1,4 @@
-import { formatCommandForDisplay } from "../src/lib/format-command";
+import { formatCommandForDisplay } from "../src/format-command";
import { describe, test, expect } from "vitest";
describe("formatCommandForDisplay()", () => {
diff --git a/codex-cli/tests/invalid-command-handling.test.ts b/codex-cli/tests/invalid-command-handling.test.ts
index 6619b4f240..a3f87a7251 100644
--- a/codex-cli/tests/invalid-command-handling.test.ts
+++ b/codex-cli/tests/invalid-command-handling.test.ts
@@ -22,7 +22,7 @@ describe("rawExec – invalid command handling", () => {
// ---------------------------------------------------------------------------
// Mock approvals and logging helpers so the test focuses on execution flow.
-vi.mock("@lib/approvals.js", () => {
+vi.mock("../src/approvals.js", () => {
return {
__esModule: true,
canAutoApprove: () =>
@@ -31,7 +31,7 @@ vi.mock("@lib/approvals.js", () => {
};
});
-vi.mock("@lib/format-command.js", () => {
+vi.mock("../src/format-command.js", () => {
return {
__esModule: true,
formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "),
diff --git a/codex-cli/tests/multiline-external-editor-shortcut.test.tsx b/codex-cli/tests/multiline-external-editor-shortcut.test.tsx
index 158a5e655d..9b2e2f25e5 100644
--- a/codex-cli/tests/multiline-external-editor-shortcut.test.tsx
+++ b/codex-cli/tests/multiline-external-editor-shortcut.test.tsx
@@ -1,6 +1,6 @@
import { renderTui } from "./ui-test-helpers.js";
import MultilineTextEditor from "../src/components/chat/multiline-editor.js";
-import TextBuffer from "../src/lib/text-buffer.js";
+import TextBuffer from "../src/text-buffer.js";
import * as React from "react";
import { describe, it, expect, vi } from "vitest";
diff --git a/codex-cli/tests/multiline-history-behavior.test.tsx b/codex-cli/tests/multiline-history-behavior.test.tsx
index 5c906837ee..cada52ddab 100644
--- a/codex-cli/tests/multiline-history-behavior.test.tsx
+++ b/codex-cli/tests/multiline-history-behavior.test.tsx
@@ -34,12 +34,12 @@ vi.mock("../src/utils/input-utils.js", () => ({
})),
}));
-// Mock the optional @lib/* dependencies so the dynamic import in parsers.ts
+// Mock the optional ../src/* dependencies so the dynamic import in parsers.ts
// does not fail during the test environment where the alias isn't configured.
-vi.mock("@lib/format-command.js", () => ({
+vi.mock("../src/format-command.js", () => ({
formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "),
}));
-vi.mock("@lib/approvals.js", () => ({
+vi.mock("../src/approvals.js", () => ({
isSafeCommand: (_cmd: Array<string>) => null,
}));
diff --git a/codex-cli/tests/parse-apply-patch.test.ts b/codex-cli/tests/parse-apply-patch.test.ts
index 0195542e56..53aa119093 100644
--- a/codex-cli/tests/parse-apply-patch.test.ts
+++ b/codex-cli/tests/parse-apply-patch.test.ts
@@ -1,4 +1,4 @@
-import { parseApplyPatch } from "../src/lib/parse-apply-patch";
+import { parseApplyPatch } from "../src/parse-apply-patch";
import { expect, test, describe } from "vitest";
// Helper function to unwrap a non‑null result in tests that expect success.
diff --git a/codex-cli/tests/text-buffer-copy-paste.test.ts b/codex-cli/tests/text-buffer-copy-paste.test.ts
index 311b2b9aa6..cc1fd119e5 100644
--- a/codex-cli/tests/text-buffer-copy-paste.test.ts
+++ b/codex-cli/tests/text-buffer-copy-paste.test.ts
@@ -1,4 +1,4 @@
-import TextBuffer from "../src/lib/text-buffer.js";
+import TextBuffer from "../src/text-buffer.js";
import { describe, it, expect } from "vitest";
// These tests ensure that the TextBuffer copy‑&‑paste logic keeps parity with
diff --git a/codex-cli/tests/text-buffer-crlf.test.ts b/codex-cli/tests/text-buffer-crlf.test.ts
index 4b33b498b5..736c22a27d 100644
--- a/codex-cli/tests/text-buffer-crlf.test.ts
+++ b/codex-cli/tests/text-buffer-crlf.test.ts
@@ -1,4 +1,4 @@
-import TextBuffer from "../src/lib/text-buffer.js";
+import TextBuffer from "../src/text-buffer.js";
import { describe, it, expect } from "vitest";
describe("TextBuffer – newline normalisation", () => {
diff --git a/codex-cli/tests/text-buffer-gaps.test.ts b/codex-cli/tests/text-buffer-gaps.test.ts
index 986ad37eed..046d468e8a 100644
--- a/codex-cli/tests/text-buffer-gaps.test.ts
+++ b/codex-cli/tests/text-buffer-gaps.test.ts
@@ -1,4 +1,4 @@
-import TextBuffer from "../src/lib/text-buffer";
+import TextBuffer from "../src/text-buffer";
import { describe, it, expect } from "vitest";
// The purpose of this test‑suite is NOT to make the implementation green today
diff --git a/codex-cli/tests/text-buffer-word.test.ts b/codex-cli/tests/text-buffer-word.test.ts
index 009786a28c..4ea7679450 100644
--- a/codex-cli/tests/text-buffer-word.test.ts
+++ b/codex-cli/tests/text-buffer-word.test.ts
@@ -1,4 +1,4 @@
-import TextBuffer from "../src/lib/text-buffer.js";
+import TextBuffer from "../src/text-buffer.js";
import { describe, test, expect } from "vitest";
describe("TextBuffer – word‑wise navigation & deletion", () => {
diff --git a/codex-cli/tests/text-buffer.test.ts b/codex-cli/tests/text-buffer.test.ts
index ae78f29409..c3f33d0fa1 100644
--- a/codex-cli/tests/text-buffer.test.ts
+++ b/codex-cli/tests/text-buffer.test.ts
@@ -1,4 +1,4 @@
-import TextBuffer from "../src/lib/text-buffer";
+import TextBuffer from "../src/text-buffer";
import { describe, it, expect } from "vitest";
describe("TextBuffer – basic editing parity with Rust suite", () => {
diff --git a/codex-cli/tsconfig.json b/codex-cli/tsconfig.json
index 626fc5dbf4..d1dacc9149 100644
--- a/codex-cli/tsconfig.json
+++ b/codex-cli/tsconfig.json
@@ -11,9 +11,6 @@
],
"types": ["node"],
"baseUrl": "./",
- "paths": {
- "@lib/*": ["./src/lib/*"]
- },
"resolveJsonModule": false, // ESM doesn't yet support JSON modules.
"jsx": "react",
"declaration": true,