fix: migrate to AGENTS.md (#764)

Migrate from `codex.md` to `AGENTS.md`
This commit is contained in:
Fouad Matin
2025-05-10 15:57:49 -07:00
committed by GitHub
parent e307d007aa
commit 3104d81b7b
3 changed files with 22 additions and 11 deletions

View File

@@ -227,13 +227,13 @@ Key flags: `--model/-m`, `--approval-mode/-a`, `--quiet/-q`, and `--notify`.
## Memory & project docs ## Memory & project docs
Codex merges Markdown instructions in this order: You can give Codex extra instructions and guidance using `AGENTS.md` files. Codex looks for `AGENTS.md` files in the following places, and merges them top-down:
1. `~/.codex/instructions.md` - personal global guidance 1. `~/.codex/AGENTS.md` - personal global guidance
2. `codex.md` at repo root - shared project notes 2. `AGENTS.md` at repo root - shared project notes
3. `codex.md` in cwd - sub-package specifics 3. `AGENTS.md` in the current working directory - sub-folder/feature specifics
Disable with `--no-project-doc` or `CODEX_DISABLE_PROJECT_DOC=1`. Disable loading of these files with `--no-project-doc` or the environment variable `CODEX_DISABLE_PROJECT_DOC=1`.
--- ---
@@ -446,7 +446,7 @@ Below is a comprehensive example of `config.json` with multiple custom providers
### Custom instructions ### Custom instructions
You can create a `~/.codex/instructions.md` file to define custom instructions: You can create a `~/.codex/AGENTS.md` file to define custom guidance for the agent:
```markdown ```markdown
- Always respond with emojis - Always respond with emojis

View File

@@ -68,7 +68,7 @@ const cli = meow(
--auto-edit Automatically approve file edits; still prompt for commands --auto-edit Automatically approve file edits; still prompt for commands
--full-auto Automatically approve edits and commands when executed in the sandbox --full-auto Automatically approve edits and commands when executed in the sandbox
--no-project-doc Do not automatically include the repository's 'codex.md' --no-project-doc Do not automatically include the repository's 'AGENTS.md'
--project-doc <file> Include an additional markdown file at <file> as context --project-doc <file> Include an additional markdown file at <file> as context
--full-stdout Do not truncate stdout/stderr from command outputs --full-stdout Do not truncate stdout/stderr from command outputs
--notify Enable desktop notifications for responses --notify Enable desktop notifications for responses
@@ -144,7 +144,7 @@ const cli = meow(
}, },
noProjectDoc: { noProjectDoc: {
type: "boolean", type: "boolean",
description: "Disable automatic inclusion of project-level codex.md", description: "Disable automatic inclusion of project-level AGENTS.md",
}, },
projectDoc: { projectDoc: {
type: "string", type: "string",

View File

@@ -211,12 +211,22 @@ export type AppConfig = {
export const PRETTY_PRINT = Boolean(process.env["PRETTY_PRINT"] || ""); export const PRETTY_PRINT = Boolean(process.env["PRETTY_PRINT"] || "");
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Project doc support (codex.md) // Project doc support (AGENTS.md / codex.md)
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
export const PROJECT_DOC_MAX_BYTES = 32 * 1024; // 32 kB export const PROJECT_DOC_MAX_BYTES = 32 * 1024; // 32 kB
const PROJECT_DOC_FILENAMES = ["codex.md", ".codex.md", "CODEX.md"]; // We support multiple filenames for project-level agent instructions. As of
// 2025 the recommended convention is to use `AGENTS.md`, however we keep
// the legacy `codex.md` variants for backwards-compatibility so that existing
// repositories continue to work without changes. The list is ordered so that
// the first match wins newer conventions first, older fallbacks later.
const PROJECT_DOC_FILENAMES = [
"AGENTS.md", // preferred
"codex.md", // legacy
".codex.md",
"CODEX.md",
];
const PROJECT_DOC_SEPARATOR = "\n\n--- project-doc ---\n\n"; const PROJECT_DOC_SEPARATOR = "\n\n--- project-doc ---\n\n";
export function discoverProjectDocPath(startDir: string): string | null { export function discoverProjectDocPath(startDir: string): string | null {
@@ -257,7 +267,8 @@ export function discoverProjectDocPath(startDir: string): string | null {
} }
/** /**
* Load the project documentation markdown (codex.md) if present. If the file * Load the project documentation markdown (`AGENTS.md` or the legacy
* `codex.md`) if present. If the file
* exceeds {@link PROJECT_DOC_MAX_BYTES} it will be truncated and a warning is * exceeds {@link PROJECT_DOC_MAX_BYTES} it will be truncated and a warning is
* logged. * logged.
* *