Fall back to configured instruction files if AGENTS.md isn't available (#4544)

Allow users to configure an agents.md alternative to consume, but warn
the user it may degrade model performance.

Fixes #4376
This commit is contained in:
easong-openai
2025-10-01 11:19:59 -07:00
committed by GitHub
parent 2f370e946d
commit 400a5a90bf
5 changed files with 117 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ use super::*;
use crate::app_event::AppEvent;
use crate::app_event_sender::AppEventSender;
use crate::test_backend::VT100Backend;
use crate::tui::FrameRequester;
use codex_core::AuthManager;
use codex_core::CodexAuth;
use codex_core::config::Config;

View File

@@ -36,9 +36,13 @@ pub(crate) fn compose_agents_summary(config: &Config) -> String {
Ok(paths) => {
let mut rels: Vec<String> = Vec::new();
for p in paths {
let file_name = p
.file_name()
.map(|name| name.to_string_lossy().to_string())
.unwrap_or_else(|| "<unknown>".to_string());
let display = if let Some(parent) = p.parent() {
if parent == config.cwd {
"AGENTS.md".to_string()
file_name.clone()
} else {
let mut cur = config.cwd.as_path();
let mut ups = 0usize;
@@ -53,7 +57,7 @@ pub(crate) fn compose_agents_summary(config: &Config) -> String {
}
if reached {
let up = format!("..{}", std::path::MAIN_SEPARATOR);
format!("{}AGENTS.md", up.repeat(ups))
format!("{}{}", up.repeat(ups), file_name)
} else if let Ok(stripped) = p.strip_prefix(&config.cwd) {
stripped.display().to_string()
} else {