chore: upgrade prettier to v3 (#644)
## Description This PR addresses the following improvements: **Unify Prettier Version**: Currently, the Prettier version used in `/package.json` and `/codex-cli/package.json` are different. In this PR, we're updating both to use Prettier v3. - Prettier v3 introduces improved support for JavaScript and TypeScript. (e.g. the formatting scenario shown in the image below. This is more aligned with the TypeScript indentation standard). <img width="1126" alt="image" src="https://github.com/user-attachments/assets/6e237eb8-4553-4574-b336-ed9561c55370" /> **Add Prettier Auto-Formatting in lint-staged**: We've added a step to automatically run prettier --write on JavaScript and TypeScript files as part of the lint-staged process, before the ESLint checks. - This will help ensure that all committed code is properly formatted according to the project's Prettier configuration.
This commit is contained in:
@@ -71,7 +71,7 @@
|
||||
"eslint-plugin-react-refresh": "^0.4.19",
|
||||
"husky": "^9.1.7",
|
||||
"ink-testing-library": "^3.0.0",
|
||||
"prettier": "^2.8.7",
|
||||
"prettier": "^3.5.3",
|
||||
"punycode": "^2.3.1",
|
||||
"semver": "^7.7.1",
|
||||
"ts-node": "^10.9.1",
|
||||
|
||||
@@ -272,12 +272,12 @@ if (!apiKey && !NO_API_KEY_REQUIRED.has(provider.toLowerCase())) {
|
||||
chalk.underline("https://platform.openai.com/account/api-keys"),
|
||||
)}\n`
|
||||
: provider.toLowerCase() === "gemini"
|
||||
? `You can create a ${chalk.bold(
|
||||
`${provider.toUpperCase()}_API_KEY`,
|
||||
)} ` + `in the ${chalk.bold(`Google AI Studio`)}.\n`
|
||||
: `You can create a ${chalk.bold(
|
||||
`${provider.toUpperCase()}_API_KEY`,
|
||||
)} ` + `in the ${chalk.bold(`${provider}`)} dashboard.\n`
|
||||
? `You can create a ${chalk.bold(
|
||||
`${provider.toUpperCase()}_API_KEY`,
|
||||
)} ` + `in the ${chalk.bold(`Google AI Studio`)}.\n`
|
||||
: `You can create a ${chalk.bold(
|
||||
`${provider.toUpperCase()}_API_KEY`,
|
||||
)} ` + `in the ${chalk.bold(`${provider}`)} dashboard.\n`
|
||||
}`,
|
||||
);
|
||||
process.exit(1);
|
||||
@@ -381,8 +381,8 @@ if (cli.flags.quiet) {
|
||||
cli.flags.fullAuto || cli.flags.approvalMode === "full-auto"
|
||||
? AutoApprovalMode.FULL_AUTO
|
||||
: cli.flags.autoEdit || cli.flags.approvalMode === "auto-edit"
|
||||
? AutoApprovalMode.AUTO_EDIT
|
||||
: config.approvalMode || AutoApprovalMode.SUGGEST;
|
||||
? AutoApprovalMode.AUTO_EDIT
|
||||
: config.approvalMode || AutoApprovalMode.SUGGEST;
|
||||
|
||||
await runQuietMode({
|
||||
prompt,
|
||||
@@ -412,8 +412,8 @@ const approvalPolicy: ApprovalPolicy =
|
||||
cli.flags.fullAuto || cli.flags.approvalMode === "full-auto"
|
||||
? AutoApprovalMode.FULL_AUTO
|
||||
: cli.flags.autoEdit || cli.flags.approvalMode === "auto-edit"
|
||||
? AutoApprovalMode.AUTO_EDIT
|
||||
: config.approvalMode || AutoApprovalMode.SUGGEST;
|
||||
? AutoApprovalMode.AUTO_EDIT
|
||||
: config.approvalMode || AutoApprovalMode.SUGGEST;
|
||||
|
||||
const instance = render(
|
||||
<App
|
||||
|
||||
@@ -135,8 +135,8 @@ export default function TerminalChatInput({
|
||||
? len - 1
|
||||
: selectedSlashSuggestion - 1
|
||||
: selectedSlashSuggestion >= len - 1
|
||||
? 0
|
||||
: selectedSlashSuggestion + 1;
|
||||
? 0
|
||||
: selectedSlashSuggestion + 1;
|
||||
setSelectedSlashSuggestion(nextIdx);
|
||||
// Autocomplete the command in the input
|
||||
const match = matches[nextIdx];
|
||||
|
||||
@@ -135,14 +135,14 @@ function TerminalChatResponseMessage({
|
||||
c.type === "output_text"
|
||||
? c.text
|
||||
: c.type === "refusal"
|
||||
? c.refusal
|
||||
: c.type === "input_text"
|
||||
? c.text
|
||||
: c.type === "input_image"
|
||||
? "<Image>"
|
||||
: c.type === "input_file"
|
||||
? c.filename
|
||||
: "", // unknown content type
|
||||
? c.refusal
|
||||
: c.type === "input_text"
|
||||
? c.text
|
||||
: c.type === "input_image"
|
||||
? "<Image>"
|
||||
: c.type === "input_file"
|
||||
? c.filename
|
||||
: "", // unknown content type
|
||||
)
|
||||
.join(" ")}
|
||||
</Markdown>
|
||||
|
||||
@@ -148,8 +148,8 @@ function formatHistoryForDisplay(items: Array<ResponseItem>): {
|
||||
const cmdArray: Array<string> | undefined = Array.isArray(argsObj?.["cmd"])
|
||||
? (argsObj!["cmd"] as Array<string>)
|
||||
: Array.isArray(argsObj?.["command"])
|
||||
? (argsObj!["command"] as Array<string>)
|
||||
: undefined;
|
||||
? (argsObj!["command"] as Array<string>)
|
||||
: undefined;
|
||||
|
||||
if (cmdArray && cmdArray.length > 0) {
|
||||
commands.push(processCommandArray(cmdArray, filesSet));
|
||||
|
||||
@@ -219,8 +219,8 @@ class Parser {
|
||||
s.normalize("NFC").replace(
|
||||
/./gu,
|
||||
(c) =>
|
||||
((
|
||||
{
|
||||
(
|
||||
({
|
||||
"-": "-",
|
||||
"\u2010": "-",
|
||||
"\u2011": "-",
|
||||
@@ -240,8 +240,8 @@ class Parser {
|
||||
"\u201B": "'",
|
||||
"\u00A0": " ",
|
||||
"\u202F": " ",
|
||||
} as Record<string, string>
|
||||
)[c] ?? c),
|
||||
}) as Record<string, string>
|
||||
)[c] ?? c,
|
||||
);
|
||||
|
||||
if (
|
||||
|
||||
@@ -67,7 +67,7 @@ vi.mock("openai", () => {
|
||||
vi.mock("../src/approvals.js", () => ({
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
}));
|
||||
|
||||
vi.mock("../src/format-command.js", () => ({
|
||||
@@ -94,7 +94,7 @@ describe("cancel before first function_call", () => {
|
||||
approvalPolicy: { mode: "auto" } as any,
|
||||
onItem: () => {},
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
config: { model: "any", instructions: "", notify: false },
|
||||
});
|
||||
|
||||
@@ -74,7 +74,7 @@ vi.mock("openai", () => {
|
||||
vi.mock("../src/approvals.js", () => ({
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
}));
|
||||
|
||||
vi.mock("../src/format-command.js", () => ({
|
||||
@@ -102,7 +102,7 @@ describe("cancel clears previous_response_id", () => {
|
||||
additionalWritableRoots: [],
|
||||
onItem: () => {},
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
config: { model: "any", instructions: "", notify: false },
|
||||
});
|
||||
|
||||
@@ -99,7 +99,7 @@ describe("Agent cancellation race", () => {
|
||||
approvalPolicy: { mode: "auto" } as any,
|
||||
onItem: (i) => items.push(i),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ vi.mock("../src/approvals.js", () => {
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () =>
|
||||
({ type: "auto-approve", runInSandbox: false } as any),
|
||||
({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
isSafeCommand: () => null,
|
||||
};
|
||||
});
|
||||
@@ -96,7 +96,7 @@ describe("Agent cancellation", () => {
|
||||
received.push(item);
|
||||
},
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
@@ -144,7 +144,7 @@ describe("Agent cancellation", () => {
|
||||
approvalPolicy: { mode: "auto" } as any,
|
||||
onItem: (item) => received.push(item),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ vi.mock("openai", () => {
|
||||
vi.mock("../src/approvals.js", () => ({
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
isSafeCommand: () => null,
|
||||
}));
|
||||
|
||||
@@ -121,7 +121,7 @@ describe("function_call_output includes original call ID", () => {
|
||||
additionalWritableRoots: [],
|
||||
onItem: () => {},
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ vi.mock("openai", () => {
|
||||
vi.mock("../src/approvals.js", () => ({
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
isSafeCommand: () => null,
|
||||
}));
|
||||
|
||||
@@ -62,7 +62,7 @@ describe("AgentLoop – generic network/server errors", () => {
|
||||
approvalPolicy: { mode: "auto" } as any,
|
||||
onItem: (i) => received.push(i),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
@@ -106,7 +106,7 @@ describe("AgentLoop – generic network/server errors", () => {
|
||||
approvalPolicy: { mode: "auto" } as any,
|
||||
onItem: (i) => received.push(i),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ describe("Agent interrupt and continue", () => {
|
||||
onLoading: (loading) => {
|
||||
loadingState = loading;
|
||||
},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ vi.mock("openai", () => {
|
||||
vi.mock("../src/approvals.js", () => ({
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
isSafeCommand: () => null,
|
||||
}));
|
||||
|
||||
@@ -61,7 +61,7 @@ describe("AgentLoop – invalid request / 4xx errors", () => {
|
||||
additionalWritableRoots: [],
|
||||
onItem: (i) => received.push(i),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ vi.mock("openai", () => {
|
||||
vi.mock("../src/approvals.js", () => ({
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
isSafeCommand: () => null,
|
||||
}));
|
||||
|
||||
@@ -64,7 +64,7 @@ describe("AgentLoop – max_tokens too large error", () => {
|
||||
approvalPolicy: { mode: "auto" } as any,
|
||||
onItem: (i) => received.push(i),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ vi.mock("openai", () => {
|
||||
vi.mock("../src/approvals.js", () => ({
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
isSafeCommand: () => null,
|
||||
}));
|
||||
|
||||
@@ -112,7 +112,7 @@ describe("AgentLoop – network resilience", () => {
|
||||
additionalWritableRoots: [],
|
||||
onItem: (i) => received.push(i),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
@@ -154,7 +154,7 @@ describe("AgentLoop – network resilience", () => {
|
||||
additionalWritableRoots: [],
|
||||
onItem: (i) => received.push(i),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ vi.mock("../src/approvals.js", () => {
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () =>
|
||||
({ type: "auto-approve", runInSandbox: false } as any),
|
||||
({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
isSafeCommand: () => null,
|
||||
};
|
||||
});
|
||||
@@ -119,7 +119,7 @@ describe("AgentLoop", () => {
|
||||
approvalPolicy: { mode: "suggest" } as any,
|
||||
onItem: () => {},
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ vi.mock("openai", () => {
|
||||
vi.mock("../src/approvals.js", () => ({
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
isSafeCommand: () => null,
|
||||
}));
|
||||
|
||||
@@ -82,7 +82,7 @@ describe("AgentLoop – rate‑limit handling", () => {
|
||||
additionalWritableRoots: [],
|
||||
onItem: (i) => received.push(i),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ vi.mock("openai", () => {
|
||||
vi.mock("../src/approvals.js", () => ({
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
|
||||
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
isSafeCommand: () => null,
|
||||
}));
|
||||
|
||||
@@ -100,7 +100,7 @@ describe("AgentLoop – automatic retry on 5xx errors", () => {
|
||||
additionalWritableRoots: [],
|
||||
onItem: (i) => received.push(i),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
@@ -138,7 +138,7 @@ describe("AgentLoop – automatic retry on 5xx errors", () => {
|
||||
additionalWritableRoots: [],
|
||||
onItem: (i) => received.push(i),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ vi.mock("../src/approvals.js", () => {
|
||||
__esModule: true,
|
||||
alwaysApprovedCommands: new Set<string>(),
|
||||
canAutoApprove: () =>
|
||||
({ type: "auto-approve", runInSandbox: false } as any),
|
||||
({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
isSafeCommand: () => null,
|
||||
};
|
||||
});
|
||||
@@ -116,7 +116,7 @@ describe("Agent terminate (hard cancel)", () => {
|
||||
additionalWritableRoots: [],
|
||||
onItem: (item) => received.push(item),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
@@ -152,7 +152,7 @@ describe("Agent terminate (hard cancel)", () => {
|
||||
additionalWritableRoots: [],
|
||||
onItem: () => {},
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ describe("thinking time counter", () => {
|
||||
additionalWritableRoots: [],
|
||||
onItem: (i) => items.push(i),
|
||||
onLoading: () => {},
|
||||
getCommandConfirmation: async () => ({ review: "yes" } as any),
|
||||
getCommandConfirmation: async () => ({ review: "yes" }) as any,
|
||||
onLastResponseId: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ vi.mock("../src/approvals.js", () => {
|
||||
return {
|
||||
__esModule: true,
|
||||
canAutoApprove: () =>
|
||||
({ type: "auto-approve", runInSandbox: false } as any),
|
||||
({ type: "auto-approve", runInSandbox: false }) as any,
|
||||
isSafeCommand: () => null,
|
||||
};
|
||||
});
|
||||
@@ -51,7 +51,7 @@ describe("handleExecCommand – invalid executable", () => {
|
||||
const execInput = { cmd: ["git show"] } as any;
|
||||
const config = { model: "any", instructions: "" } as any;
|
||||
const policy = { mode: "auto" } as any;
|
||||
const getConfirmation = async () => ({ review: "yes" } as any);
|
||||
const getConfirmation = async () => ({ review: "yes" }) as any;
|
||||
|
||||
const additionalWritableRoots: Array<string> = [];
|
||||
const { outputText, metadata } = await handleExecCommand(
|
||||
|
||||
Reference in New Issue
Block a user