fix: 修复 Codex AGENTS.md 标题匹配模式

- 支持 "Codex Code Guidelines" 和 "Codex Instructions" 两种标题
- 使用不区分大小写的正则匹配
This commit is contained in:
catlog22
2026-01-08 20:25:04 +08:00
parent a433861f77
commit 8f7ab3e268

View File

@@ -918,8 +918,11 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
const isCodex = target === 'codex';
const targetDir = isCodex ? join(homedir(), '.codex') : join(homedir(), '.claude');
const targetFile = isCodex ? join(targetDir, 'AGENTS.md') : join(targetDir, 'CLAUDE.md');
const headerText = isCodex ? '# Codex Instructions\n\n' : '# Claude Instructions\n\n';
const headerPattern = isCodex ? /^# Codex Instructions\n\n?/ : /^# Claude Instructions\n\n?/;
const headerText = isCodex ? '# Codex Code Guidelines\n\n' : '# Claude Instructions\n\n';
// Match common header patterns for both tools
const headerPattern = isCodex
? /^#\s*(Codex\s*(Code\s*)?(Guidelines|Instructions))\n\n?/i
: /^#\s*Claude\s*Instructions\n\n?/i;
const chineseRefLine = `- **中文回复准则**: @${guidelinesRef}`;
const chineseRefPattern = /^- \*\*中文回复准则\*\*:.*chinese-response\.md.*$/gm;