From 4a4e671ac0a60095c7851bad4221e7eeb13ea8a5 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Mon, 11 Aug 2025 18:58:55 +0530 Subject: [PATCH 1/3] feat: update support for codex cli - support codex xli v0.20.0 --- cmd/server/server.go | 3 - lib/msgfmt/message_box.go | 43 +++----------- lib/msgfmt/msgfmt.go | 3 +- .../codex/confirmation_box/expected.txt | 15 +++-- .../format/codex/confirmation_box/msg.txt | 37 +++--------- .../format/codex/confirmation_box/user.txt | 1 - .../format/codex/first_message/expected.txt | 18 +++--- .../format/codex/first_message/msg.txt | 40 ++++--------- .../codex/multi-line-input/expected.txt | 36 ++++++++---- .../format/codex/multi-line-input/msg.txt | 58 ++++++++++--------- .../format/codex/multi-line-input/user.txt | 11 ++-- .../format/codex/second_message/expected.txt | 22 ++++++- .../format/codex/second_message/msg.txt | 41 +++++++------ .../format/codex/second_message/user.txt | 2 +- .../format/codex/thinking/expected.txt | 13 +++++ .../testdata/format/codex/thinking/msg.txt | 16 +++-- .../testdata/format/codex/thinking/user.txt | 2 +- 17 files changed, 180 insertions(+), 181 deletions(-) diff --git a/cmd/server/server.go b/cmd/server/server.go index 3313b51..921ea34 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -74,9 +74,6 @@ func runServer(ctx context.Context, logger *slog.Logger, argsToPass []string) er } if termHeight < 10 { return xerrors.Errorf("term height must be at least 10") - } else if agentType == AgentTypeCodex && termHeight > 930 { - logger.Warn(fmt.Sprintf("Term height is set to %d which may cause issues with Codex. Setting it to 930 instead.", termHeight)) - termHeight = 930 // codex has a bug where the TUI distorts the screen if the height is too large, see: https://github.com/openai/codex/issues/1608 } printOpenAPI := viper.GetBool(FlagPrintOpenAPI) diff --git a/lib/msgfmt/message_box.go b/lib/msgfmt/message_box.go index d568280..0f75bd9 100644 --- a/lib/msgfmt/message_box.go +++ b/lib/msgfmt/message_box.go @@ -8,7 +8,7 @@ import ( // ─────────────── // > // ─────────────── -// Used by Claude Code, Goose, and Aider. +// Used by Goose, and Aider. func findGreaterThanMessageBox(lines []string) int { for i := len(lines) - 1; i >= max(len(lines)-6, 0); i-- { if strings.Contains(lines[i], ">") { @@ -25,7 +25,6 @@ func findGreaterThanMessageBox(lines []string) int { // ─────────────── // | // ─────────────── -// Used by OpenAI Codex. func findGenericSlimMessageBox(lines []string) int { for i := len(lines) - 3; i >= max(len(lines)-9, 0); i-- { if strings.Contains(lines[i], "───────────────") && @@ -52,40 +51,12 @@ func removeMessageBox(msg string) string { return strings.Join(lines, "\n") } -func removeCodexMessageBox(msg string) string { +func removeCodexInputBox(msg string) string { lines := strings.Split(msg, "\n") - messageBoxEndIdx := -1 - messageBoxStartIdx := -1 - - for i := len(lines) - 1; i >= 0; i-- { - if messageBoxEndIdx == -1 { - if strings.Contains(lines[i], "╰────────") && strings.Contains(lines[i], "───────╯") { - messageBoxEndIdx = i - } - } else { - // We reached the start of the message box (we don't want to show this line), also exit the loop - if strings.Contains(lines[i], "╭") && strings.Contains(lines[i], "───────╮") { - // We only want this to be i in case the top of the box is visible - messageBoxStartIdx = i - break - } - - // We are in between the start and end of the message box, so remove the │ from the start and end of the line, let the trimEmptyLines handle the rest - if strings.HasPrefix(lines[i], "│") { - lines[i] = strings.TrimPrefix(lines[i], "│") - } - if strings.HasSuffix(lines[i], "│") { - lines[i] = strings.TrimSuffix(lines[i], "│") - lines[i] = strings.TrimRight(lines[i], " \t") - } - } - } - - // If we didn't find messageBoxEndIdx, set it to the end of the lines - if messageBoxEndIdx == -1 { - messageBoxEndIdx = len(lines) + // Remove the input box, we need to match the exact pattern, because thinking follows the same pattern of ▌ followed by text + if len(lines)-2 >= 0 && strings.Contains(lines[len(lines)-2], "▌ Ask Codex to do anything") { + idx := len(lines) - 2 + lines = append(lines[:idx], lines[idx+1:]...) } - - return strings.Join(lines[messageBoxStartIdx+1:messageBoxEndIdx], "\n") - + return strings.Join(lines, "\n") } diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index 3560aa7..1edb25e 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -218,8 +218,7 @@ func formatGenericMessage(message string, userInput string) string { func formatCodexMessage(message string, userInput string) string { message = RemoveUserInput(message, userInput) - message = removeMessageBox(message) - message = removeCodexMessageBox(message) + message = removeCodexInputBox(message) message = trimEmptyLines(message) return message } diff --git a/lib/msgfmt/testdata/format/codex/confirmation_box/expected.txt b/lib/msgfmt/testdata/format/codex/confirmation_box/expected.txt index 9363e91..cb2e794 100644 --- a/lib/msgfmt/testdata/format/codex/confirmation_box/expected.txt +++ b/lib/msgfmt/testdata/format/codex/confirmation_box/expected.txt @@ -1,10 +1,9 @@ -Shell Command -~/Documents/work/agentapi$ git rev-parse --show-toplevel +> You are running Codex in /Users/jkmr -Allow command? + Since this folder is not version controlled, we recommend requiring + approval of all edits and commands. - ▶ Yes (y) - Yes, always approve this exact command for this session (a) - Edit or give feedback (e) - No, and keep going (n) - No, and stop for now (esc) \ No newline at end of file + 1. Allow Codex to work in this folder without asking for approval +> 2. Require approval of edits and commands + + Press Enter to continue \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/confirmation_box/msg.txt b/lib/msgfmt/testdata/format/codex/confirmation_box/msg.txt index eccfd92..cb2e794 100644 --- a/lib/msgfmt/testdata/format/codex/confirmation_box/msg.txt +++ b/lib/msgfmt/testdata/format/codex/confirmation_box/msg.txt @@ -1,28 +1,9 @@ -╭Messages (tab to focus)──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│OpenAI Codex v0.10.0 (research preview) │ -│ │ -│codex session 790ba389-ab4d-47be-bb16-9cc7f36bcf2b │ -│workdir: /Users/jkmr/Documents/work/agentapi │ -│model: codex-mini-latest │ -│provider: openai │ -│approval: untrusted │ -│sandbox: read-only │ -│reasoning effort: medium │ -│reasoning summaries: auto │ -│ │ -│user │ -│what repository are you in? │ -│ │ -╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭Review───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│Shell Command │ -│~/Documents/work/agentapi$ git rev-parse --show-toplevel │ -│ │ -│Allow command? │ -│ │ -│ ▶ Yes (y) │ -│ Yes, always approve this exact command for this session (a) │ -│ Edit or give feedback (e) │ -│ No, and keep going (n) │ -│ No, and stop for now (esc) │ -╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +> You are running Codex in /Users/jkmr + + Since this folder is not version controlled, we recommend requiring + approval of all edits and commands. + + 1. Allow Codex to work in this folder without asking for approval +> 2. Require approval of edits and commands + + Press Enter to continue \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/confirmation_box/user.txt b/lib/msgfmt/testdata/format/codex/confirmation_box/user.txt index 338205d..e69de29 100644 --- a/lib/msgfmt/testdata/format/codex/confirmation_box/user.txt +++ b/lib/msgfmt/testdata/format/codex/confirmation_box/user.txt @@ -1 +0,0 @@ -what repository are you in? \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/first_message/expected.txt b/lib/msgfmt/testdata/format/codex/first_message/expected.txt index 660ecde..6efbf6f 100644 --- a/lib/msgfmt/testdata/format/codex/first_message/expected.txt +++ b/lib/msgfmt/testdata/format/codex/first_message/expected.txt @@ -1,10 +1,10 @@ -OpenAI Codex v0.10.0 (research preview) +>_ You are using OpenAI Codex in ~ -codex session 56576d81-529d-42f3-843b-78d870054a75 -workdir: /Users/jkmr/Documents/work/agentapi -model: codex-mini-latest -provider: openai -approval: untrusted -sandbox: read-only -reasoning effort: medium -reasoning summaries: auto \ No newline at end of file + To get started, describe a task or try one of these commands: + + /init - create an AGENTS.md file with instructions for Codex + /status - show current session configuration and token usage + /diff - show git diff (including untracked files) + /prompts - show example prompts + + ⏎ send Shift+⏎ newline Ctrl+C quit \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/first_message/msg.txt b/lib/msgfmt/testdata/format/codex/first_message/msg.txt index a779309..76b1ef4 100644 --- a/lib/msgfmt/testdata/format/codex/first_message/msg.txt +++ b/lib/msgfmt/testdata/format/codex/first_message/msg.txt @@ -1,29 +1,11 @@ -╭Messages (tab to focus)──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│OpenAI Codex v0.10.0 (research preview) │ -│ │ -│codex session 56576d81-529d-42f3-843b-78d870054a75 │ -│workdir: /Users/jkmr/Documents/work/agentapi │ -│model: codex-mini-latest │ -│provider: openai │ -│approval: untrusted │ -│sandbox: read-only │ -│reasoning effort: medium │ -│reasoning summaries: auto │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ send a message │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────Enter to send | Ctrl+D to quit | Ctrl+J for newline╯ \ No newline at end of file +>_ You are using OpenAI Codex in ~ + + To get started, describe a task or try one of these commands: + + /init - create an AGENTS.md file with instructions for Codex + /status - show current session configuration and token usage + /diff - show git diff (including untracked files) + /prompts - show example prompts + +▌ Ask Codex to do anything + ⏎ send Shift+⏎ newline Ctrl+C quit \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/multi-line-input/expected.txt b/lib/msgfmt/testdata/format/codex/multi-line-input/expected.txt index a42ca83..f700907 100644 --- a/lib/msgfmt/testdata/format/codex/multi-line-input/expected.txt +++ b/lib/msgfmt/testdata/format/codex/multi-line-input/expected.txt @@ -1,14 +1,30 @@ -command (code: 127, duration: 10ms) -$ bash -lc 'rg -n "func formatCodexMessage"' -bash: line 1: rg: command not found +>_ You are using OpenAI Codex in ~/Documents/work/agentapi -command (code: 0, duration: 8.23s) -$ bash -lc 'grep -R "formatCodexMessage" -n .' -./lib/msgfmt/testdata/format/claude/multi-line-input/user.txt:3:func formatCodexMessage(message string, userInput string) string { -./lib/msgfmt/msgfmt.go:219:func formatCodexMessage(message string, userInput string) string { -./lib/msgfmt/msgfmt.go:236: return formatCodexMessage(message, userInput) + To get started, describe a task or try one of these commands: + + /init - create an AGENTS.md file with instructions for Codex + /status - show current session configuration and token usage + /diff - show git diff (including untracked files) + /prompts - show example prompts + +user +Which file has this snippet +func formatCodexMessage(message string, userInput string) string { + message = RemoveUserInput(message, userInput) + message = removeCodexInputBox(message) + message = trimEmptyLines(message) + return message +} + +⚡ Ran command grep -R formatCodexMessage -n . + ⎿ ./lib/msgfmt/testdata/format/codex/multi-line-input/user.txt:3:func formatCodexMessage(message string, userInput string) string {} + ./lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt:2:│$ bash -lc 'rg -n "func formatCodexMessage"' │ + ./lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt:6:│$ bash -lc 'grep -R "formatCodexMessage" -n .' │ + ... +12 lines codex -The formatCodexMessage function is defined in: +The `formatCodexMessage` function is defined in: + +`lib/msgfmt/msgfmt.go` (around line 219) -lib/msgfmt/msgfmt.go (around line 219) \ No newline at end of file + Ctrl+C again to quit 12437 tokens used 96% context left \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt b/lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt index b409343..6a9c105 100644 --- a/lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt +++ b/lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt @@ -1,27 +1,31 @@ -│command (code: 127, duration: 10ms) │ -│$ bash -lc 'rg -n "func formatCodexMessage"' │ -│bash: line 1: rg: command not found │ -│ │ -│command (code: 0, duration: 8.23s) │ -│$ bash -lc 'grep -R "formatCodexMessage" -n .' │ -│./lib/msgfmt/testdata/format/claude/multi-line-input/user.txt:3:func formatCodexMessage(message string, userInput string) string { │ -│./lib/msgfmt/msgfmt.go:219:func formatCodexMessage(message string, userInput string) string { │ -│./lib/msgfmt/msgfmt.go:236: return formatCodexMessage(message, userInput) │ -│ │ -│codex │ -│The formatCodexMessage function is defined in: │ -│ │ -│lib/msgfmt/msgfmt.go (around line 219) │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ send a message — 97% context left │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────Enter to send | Ctrl+D to quit | Ctrl+J for newline╯ \ No newline at end of file +>_ You are using OpenAI Codex in ~/Documents/work/agentapi + + To get started, describe a task or try one of these commands: + + /init - create an AGENTS.md file with instructions for Codex + /status - show current session configuration and token usage + /diff - show git diff (including untracked files) + /prompts - show example prompts + +user +Which file has this snippet +func formatCodexMessage(message string, userInput string) string { + message = RemoveUserInput(message, userInput) + message = removeCodexInputBox(message) + message = trimEmptyLines(message) + return message +} + +⚡ Ran command grep -R formatCodexMessage -n . + ⎿ ./lib/msgfmt/testdata/format/codex/multi-line-input/user.txt:3:func formatCodexMessage(message string, userInput string) string {} + ./lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt:2:│$ bash -lc 'rg -n "func formatCodexMessage"' │ + ./lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt:6:│$ bash -lc 'grep -R "formatCodexMessage" -n .' │ + ... +12 lines + +codex +The `formatCodexMessage` function is defined in: + +`lib/msgfmt/msgfmt.go` (around line 219) + +▌ Ask Codex to do anything + Ctrl+C again to quit 12437 tokens used 96% context left \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/multi-line-input/user.txt b/lib/msgfmt/testdata/format/codex/multi-line-input/user.txt index 4250545..e85fa2a 100644 --- a/lib/msgfmt/testdata/format/codex/multi-line-input/user.txt +++ b/lib/msgfmt/testdata/format/codex/multi-line-input/user.txt @@ -1,4 +1,7 @@ -Which file is this function from? -```go -func formatCodexMessage(message string, userInput string) string {} -``` +Which file has this snippet +func formatCodexMessage(message string, userInput string) string { + message = RemoveUserInput(message, userInput) + message = removeCodexInputBox(message) + message = trimEmptyLines(message) + return message +} \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/second_message/expected.txt b/lib/msgfmt/testdata/format/codex/second_message/expected.txt index 2ce98fe..3618087 100644 --- a/lib/msgfmt/testdata/format/codex/second_message/expected.txt +++ b/lib/msgfmt/testdata/format/codex/second_message/expected.txt @@ -1,2 +1,22 @@ +>_ You are using OpenAI Codex in ~/Documents/work/agentapi + + To get started, describe a task or try one of these commands: + + /init - create an AGENTS.md file with instructions for Codex + /status - show current session configuration and token usage + /diff - show git diff (including untracked files) + /prompts - show example prompts + +user +How many untracked files are there? + +⚡ Ran command git status --porcelain + ⎿ M cmd/server/server.go + M lib/msgfmt/message_box.go + M lib/msgfmt/msgfmt.go + ... +2 lines + codex -I’m doing great, thanks for asking! How can I help you today? \ No newline at end of file +There are 2 untracked files (`.env` and `forge.yaml`). + + ⏎ send Ctrl+J newline Ctrl+C quit 18724 tokens used 96% context left \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/second_message/msg.txt b/lib/msgfmt/testdata/format/codex/second_message/msg.txt index 03ece28..1382723 100644 --- a/lib/msgfmt/testdata/format/codex/second_message/msg.txt +++ b/lib/msgfmt/testdata/format/codex/second_message/msg.txt @@ -1,17 +1,24 @@ -│user │ -│how are you? │ -│ │ -│codex │ -│I’m doing great, thanks for asking! How can I help you today? │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -│ │ -╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ send a message — 99% context left │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────Enter to send | Ctrl+D to quit | Ctrl+J for newline╯ \ No newline at end of file + +>_ You are using OpenAI Codex in ~/Documents/work/agentapi + + To get started, describe a task or try one of these commands: + + /init - create an AGENTS.md file with instructions for Codex + /status - show current session configuration and token usage + /diff - show git diff (including untracked files) + /prompts - show example prompts + +user +How many untracked files are there? + +⚡ Ran command git status --porcelain + ⎿ M cmd/server/server.go + M lib/msgfmt/message_box.go + M lib/msgfmt/msgfmt.go + ... +2 lines + +codex +There are 2 untracked files (`.env` and `forge.yaml`). + +▌ Ask Codex to do anything + ⏎ send Ctrl+J newline Ctrl+C quit 18724 tokens used 96% context left \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/second_message/user.txt b/lib/msgfmt/testdata/format/codex/second_message/user.txt index c01e0f3..f739c91 100644 --- a/lib/msgfmt/testdata/format/codex/second_message/user.txt +++ b/lib/msgfmt/testdata/format/codex/second_message/user.txt @@ -1 +1 @@ -how are you? \ No newline at end of file +How many untracked files are there? \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/thinking/expected.txt b/lib/msgfmt/testdata/format/codex/thinking/expected.txt index e69de29..3045ad3 100644 --- a/lib/msgfmt/testdata/format/codex/thinking/expected.txt +++ b/lib/msgfmt/testdata/format/codex/thinking/expected.txt @@ -0,0 +1,13 @@ +>_ You are using OpenAI Codex in ~/Documents/work/agentapi + + To get started, describe a task or try one of these commands: + + /init - create an AGENTS.md file with instructions for Codex + /status - show current session configuration and token usage + /diff - show git diff (including untracked files) + /prompts - show example prompts + +user +Think for a very long time and tell me all about Theory of Relativity. + +▌ • Working (3s • Ctrl C to interrupt) \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/thinking/msg.txt b/lib/msgfmt/testdata/format/codex/thinking/msg.txt index 25fc796..3045ad3 100644 --- a/lib/msgfmt/testdata/format/codex/thinking/msg.txt +++ b/lib/msgfmt/testdata/format/codex/thinking/msg.txt @@ -1,5 +1,13 @@ +>_ You are using OpenAI Codex in ~/Documents/work/agentapi + + To get started, describe a task or try one of these commands: + + /init - create an AGENTS.md file with instructions for Codex + /status - show current session configuration and token usage + /diff - show git diff (including untracked files) + /prompts - show example prompts + user -how are you? -╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│( ● ) Thinking.. │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ \ No newline at end of file +Think for a very long time and tell me all about Theory of Relativity. + +▌ • Working (3s • Ctrl C to interrupt) \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/thinking/user.txt b/lib/msgfmt/testdata/format/codex/thinking/user.txt index c01e0f3..8d861d0 100644 --- a/lib/msgfmt/testdata/format/codex/thinking/user.txt +++ b/lib/msgfmt/testdata/format/codex/thinking/user.txt @@ -1 +1 @@ -how are you? \ No newline at end of file +Think for a very long time and tell me all about Theory of Relativity. \ No newline at end of file From b4cbdcf2cc3bfe5b7bf8b7cd1d01b0c715900f2c Mon Sep 17 00:00:00 2001 From: 35C4n0r <70096901+35C4n0r@users.noreply.github.com> Date: Mon, 11 Aug 2025 19:06:42 +0530 Subject: [PATCH 2/3] Update lib/msgfmt/message_box.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- lib/msgfmt/message_box.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/msgfmt/message_box.go b/lib/msgfmt/message_box.go index 0f75bd9..32d3816 100644 --- a/lib/msgfmt/message_box.go +++ b/lib/msgfmt/message_box.go @@ -54,7 +54,7 @@ func removeMessageBox(msg string) string { func removeCodexInputBox(msg string) string { lines := strings.Split(msg, "\n") // Remove the input box, we need to match the exact pattern, because thinking follows the same pattern of ▌ followed by text - if len(lines)-2 >= 0 && strings.Contains(lines[len(lines)-2], "▌ Ask Codex to do anything") { + if len(lines) >= 2 && strings.Contains(lines[len(lines)-2], "▌ Ask Codex to do anything") { idx := len(lines) - 2 lines = append(lines[:idx], lines[idx+1:]...) } From 2c2f71b5f0f422e924b6a72361938800af2aa5b5 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Mon, 11 Aug 2025 20:32:23 +0530 Subject: [PATCH 3/3] fix: update tests --- lib/msgfmt/message_box.go | 2 +- .../format/codex/multi-line-input/expected.txt | 18 ------------------ .../format/codex/multi-line-input/msg.txt | 9 --------- .../format/codex/second_message/expected.txt | 12 ------------ .../format/codex/second_message/msg.txt | 10 ---------- .../format/codex/thinking/expected.txt | 12 ------------ .../testdata/format/codex/thinking/msg.txt | 9 --------- 7 files changed, 1 insertion(+), 71 deletions(-) diff --git a/lib/msgfmt/message_box.go b/lib/msgfmt/message_box.go index 32d3816..9c42468 100644 --- a/lib/msgfmt/message_box.go +++ b/lib/msgfmt/message_box.go @@ -8,7 +8,7 @@ import ( // ─────────────── // > // ─────────────── -// Used by Goose, and Aider. +// Used by Claude Code, Goose, and Aider. func findGreaterThanMessageBox(lines []string) int { for i := len(lines) - 1; i >= max(len(lines)-6, 0); i-- { if strings.Contains(lines[i], ">") { diff --git a/lib/msgfmt/testdata/format/codex/multi-line-input/expected.txt b/lib/msgfmt/testdata/format/codex/multi-line-input/expected.txt index f700907..edd162f 100644 --- a/lib/msgfmt/testdata/format/codex/multi-line-input/expected.txt +++ b/lib/msgfmt/testdata/format/codex/multi-line-input/expected.txt @@ -1,21 +1,3 @@ ->_ You are using OpenAI Codex in ~/Documents/work/agentapi - - To get started, describe a task or try one of these commands: - - /init - create an AGENTS.md file with instructions for Codex - /status - show current session configuration and token usage - /diff - show git diff (including untracked files) - /prompts - show example prompts - -user -Which file has this snippet -func formatCodexMessage(message string, userInput string) string { - message = RemoveUserInput(message, userInput) - message = removeCodexInputBox(message) - message = trimEmptyLines(message) - return message -} - ⚡ Ran command grep -R formatCodexMessage -n . ⎿ ./lib/msgfmt/testdata/format/codex/multi-line-input/user.txt:3:func formatCodexMessage(message string, userInput string) string {} ./lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt:2:│$ bash -lc 'rg -n "func formatCodexMessage"' │ diff --git a/lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt b/lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt index 6a9c105..1cee5a4 100644 --- a/lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt +++ b/lib/msgfmt/testdata/format/codex/multi-line-input/msg.txt @@ -1,12 +1,3 @@ ->_ You are using OpenAI Codex in ~/Documents/work/agentapi - - To get started, describe a task or try one of these commands: - - /init - create an AGENTS.md file with instructions for Codex - /status - show current session configuration and token usage - /diff - show git diff (including untracked files) - /prompts - show example prompts - user Which file has this snippet func formatCodexMessage(message string, userInput string) string { diff --git a/lib/msgfmt/testdata/format/codex/second_message/expected.txt b/lib/msgfmt/testdata/format/codex/second_message/expected.txt index 3618087..644783e 100644 --- a/lib/msgfmt/testdata/format/codex/second_message/expected.txt +++ b/lib/msgfmt/testdata/format/codex/second_message/expected.txt @@ -1,15 +1,3 @@ ->_ You are using OpenAI Codex in ~/Documents/work/agentapi - - To get started, describe a task or try one of these commands: - - /init - create an AGENTS.md file with instructions for Codex - /status - show current session configuration and token usage - /diff - show git diff (including untracked files) - /prompts - show example prompts - -user -How many untracked files are there? - ⚡ Ran command git status --porcelain ⎿ M cmd/server/server.go M lib/msgfmt/message_box.go diff --git a/lib/msgfmt/testdata/format/codex/second_message/msg.txt b/lib/msgfmt/testdata/format/codex/second_message/msg.txt index 1382723..9e36f66 100644 --- a/lib/msgfmt/testdata/format/codex/second_message/msg.txt +++ b/lib/msgfmt/testdata/format/codex/second_message/msg.txt @@ -1,13 +1,3 @@ - ->_ You are using OpenAI Codex in ~/Documents/work/agentapi - - To get started, describe a task or try one of these commands: - - /init - create an AGENTS.md file with instructions for Codex - /status - show current session configuration and token usage - /diff - show git diff (including untracked files) - /prompts - show example prompts - user How many untracked files are there? diff --git a/lib/msgfmt/testdata/format/codex/thinking/expected.txt b/lib/msgfmt/testdata/format/codex/thinking/expected.txt index 3045ad3..856ce84 100644 --- a/lib/msgfmt/testdata/format/codex/thinking/expected.txt +++ b/lib/msgfmt/testdata/format/codex/thinking/expected.txt @@ -1,13 +1 @@ ->_ You are using OpenAI Codex in ~/Documents/work/agentapi - - To get started, describe a task or try one of these commands: - - /init - create an AGENTS.md file with instructions for Codex - /status - show current session configuration and token usage - /diff - show git diff (including untracked files) - /prompts - show example prompts - -user -Think for a very long time and tell me all about Theory of Relativity. - ▌ • Working (3s • Ctrl C to interrupt) \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/thinking/msg.txt b/lib/msgfmt/testdata/format/codex/thinking/msg.txt index 3045ad3..521bad8 100644 --- a/lib/msgfmt/testdata/format/codex/thinking/msg.txt +++ b/lib/msgfmt/testdata/format/codex/thinking/msg.txt @@ -1,12 +1,3 @@ ->_ You are using OpenAI Codex in ~/Documents/work/agentapi - - To get started, describe a task or try one of these commands: - - /init - create an AGENTS.md file with instructions for Codex - /status - show current session configuration and token usage - /diff - show git diff (including untracked files) - /prompts - show example prompts - user Think for a very long time and tell me all about Theory of Relativity.