Lightweight coding agent that runs in your terminal
Rust
fix(core): load custom prompts from symlinked Markdown files (#3643)
Soroush Yousefpourfff576cf9846
diff --git a/codex-rs/core/src/custom_prompts.rs b/codex-rs/core/src/custom_prompts.rsindex d92c683902..66b2bab32c 100644--- a/codex-rs/core/src/custom_prompts.rs+++ b/codex-rs/core/src/custom_prompts.rs@@ -32,12 +32,11 @@ pub async fn discover_prompts_in_excluding(while let Ok(Some(entry)) = entries.next_entry().await {let path = entry.path();- let is_file = entry- .file_type()+ let is_file_like = fs::metadata(&path).await- .map(|ft| ft.is_file())+ .map(|m| m.is_file()).unwrap_or(false);- if !is_file {+ if !is_file_like {continue;}// Only include Markdown files with a .md extension.@@ -197,6 +196,25 @@ mod tests {assert_eq!(names, vec!["good"]);}+ #[tokio::test]+ #[cfg(unix)]+ async fn discovers_symlinked_md_files() {+ let tmp = tempdir().expect("create TempDir");+ let dir = tmp.path();++ // Create a real file+ fs::write(dir.join("real.md"), b"real content").unwrap();++ // Create a symlink to the real file+ std::os::unix::fs::symlink(dir.join("real.md"), dir.join("link.md")).unwrap();++ let found = discover_prompts_in(dir).await;+ let names: Vec<String> = found.into_iter().map(|e| e.name).collect();++ // Both real and link should be discovered, sorted alphabetically+ assert_eq!(names, vec!["link", "real"]);+ }+#[tokio::test]async fn parses_frontmatter_and_strips_from_body() {let tmp = tempdir().expect("create TempDir");diff --git a/docs/prompts.md b/docs/prompts.mdindex 0c2eb3bcd6..7b47d9383a 100644--- a/docs/prompts.md+++ b/docs/prompts.md@@ -5,7 +5,7 @@ Custom prompts turn your repeatable instructions into reusable slash commands, s### Where prompts live- Location: store prompts in `$CODEX_HOME/prompts/` (defaults to `~/.codex/prompts/`). Set `CODEX_HOME` if you want to use a different folder.-- File type: Codex only loads `.md` files. Non-Markdown files are ignored.+- File type: Codex only loads `.md` files. Non-Markdown files are ignored. Both regular files and symlinks to Markdown files are supported.- Naming: The filename (without `.md`) becomes the prompt name. A file called `review.md` registers the prompt `review`.- Refresh: Prompts are loaded when a session starts. Restart Codex (or start a new session) after adding or editing files.- Conflicts: Files whose names collide with built-in commands (like `init`) stay hidden in the slash popup, but you can still invoke them with `/prompts:<name>`.