Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 797a81e

Browse files
35C4n0rCopilot
andauthored
feat: update support for codex cli (#51)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5c425c6 commit 797a81e

File tree

17 files changed

+110
-181
lines changed

17 files changed

+110
-181
lines changed

‎cmd/server/server.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ func runServer(ctx context.Context, logger *slog.Logger, argsToPass []string) er
7474
}
7575
if termHeight < 10 {
7676
return xerrors.Errorf("term height must be at least 10")
77-
} else if agentType == AgentTypeCodex && termHeight > 930 {
78-
logger.Warn(fmt.Sprintf("Term height is set to %d which may cause issues with Codex. Setting it to 930 instead.", termHeight))
79-
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
8077
}
8178

8279
printOpenAPI := viper.GetBool(FlagPrintOpenAPI)

‎lib/msgfmt/message_box.go‎

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func findGreaterThanMessageBox(lines []string) int {
2525
// ───────────────
2626
// |
2727
// ───────────────
28-
// Used by OpenAI Codex.
2928
func findGenericSlimMessageBox(lines []string) int {
3029
for i := len(lines) - 3; i >= max(len(lines)-9, 0); i-- {
3130
if strings.Contains(lines[i], "───────────────") &&
@@ -52,40 +51,12 @@ func removeMessageBox(msg string) string {
5251
return strings.Join(lines, "\n")
5352
}
5453

55-
func removeCodexMessageBox(msg string) string {
54+
func removeCodexInputBox(msg string) string {
5655
lines := strings.Split(msg, "\n")
57-
messageBoxEndIdx := -1
58-
messageBoxStartIdx := -1
59-
60-
for i := len(lines) - 1; i >= 0; i-- {
61-
if messageBoxEndIdx == -1 {
62-
if strings.Contains(lines[i], "╰────────") && strings.Contains(lines[i], "───────╯") {
63-
messageBoxEndIdx = i
64-
}
65-
} else {
66-
// We reached the start of the message box (we don't want to show this line), also exit the loop
67-
if strings.Contains(lines[i], "╭") && strings.Contains(lines[i], "───────╮") {
68-
// We only want this to be i in case the top of the box is visible
69-
messageBoxStartIdx = i
70-
break
71-
}
72-
73-
// 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
74-
if strings.HasPrefix(lines[i], "│") {
75-
lines[i] = strings.TrimPrefix(lines[i], "│")
76-
}
77-
if strings.HasSuffix(lines[i], "│") {
78-
lines[i] = strings.TrimSuffix(lines[i], "│")
79-
lines[i] = strings.TrimRight(lines[i], " \t")
80-
}
81-
}
82-
}
83-
84-
// If we didn't find messageBoxEndIdx, set it to the end of the lines
85-
if messageBoxEndIdx == -1 {
86-
messageBoxEndIdx = len(lines)
56+
// Remove the input box, we need to match the exact pattern, because thinking follows the same pattern of ▌ followed by text
57+
if len(lines) >= 2 && strings.Contains(lines[len(lines)-2], "▌ Ask Codex to do anything") {
58+
idx := len(lines) - 2
59+
lines = append(lines[:idx], lines[idx+1:]...)
8760
}
88-
89-
return strings.Join(lines[messageBoxStartIdx+1:messageBoxEndIdx], "\n")
90-
61+
return strings.Join(lines, "\n")
9162
}

‎lib/msgfmt/msgfmt.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ func formatGenericMessage(message string, userInput string) string {
218218

219219
func formatCodexMessage(message string, userInput string) string {
220220
message = RemoveUserInput(message, userInput)
221-
message = removeMessageBox(message)
222-
message = removeCodexMessageBox(message)
221+
message = removeCodexInputBox(message)
223222
message = trimEmptyLines(message)
224223
return message
225224
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
Shell Command
2-
~/Documents/work/agentapi$ git rev-parse --show-toplevel
1+
> You are running Codex in /Users/jkmr
32

4-
Allow command?
3+
Since this folder is not version controlled, we recommend requiring
4+
approval of all edits and commands.
55

6-
▶ Yes (y)
7-
Yes, always approve this exact command for this session (a)
8-
Edit or give feedback (e)
9-
No, and keep going (n)
10-
No, and stop for now (esc)
6+
1. Allow Codex to work in this folder without asking for approval
7+
> 2. Require approval of edits and commands
8+
9+
Press Enter to continue
Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
1-
╭Messages (tab to focus)──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
2-
│OpenAI Codex v0.10.0 (research preview) │
3-
│ │
4-
│codex session 790ba389-ab4d-47be-bb16-9cc7f36bcf2b │
5-
│workdir: /Users/jkmr/Documents/work/agentapi │
6-
│model: codex-mini-latest │
7-
│provider: openai │
8-
│approval: untrusted │
9-
│sandbox: read-only │
10-
│reasoning effort: medium │
11-
│reasoning summaries: auto │
12-
│ │
13-
│user │
14-
│what repository are you in? │
15-
│ │
16-
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
17-
╭Review───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
18-
│Shell Command │
19-
│~/Documents/work/agentapi$ git rev-parse --show-toplevel │
20-
│ │
21-
│Allow command? │
22-
│ │
23-
│ ▶ Yes (y) │
24-
│ Yes, always approve this exact command for this session (a) │
25-
│ Edit or give feedback (e) │
26-
│ No, and keep going (n) │
27-
│ No, and stop for now (esc) │
28-
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
1+
> You are running Codex in /Users/jkmr
2+
3+
Since this folder is not version controlled, we recommend requiring
4+
approval of all edits and commands.
5+
6+
1. Allow Codex to work in this folder without asking for approval
7+
> 2. Require approval of edits and commands
8+
9+
Press Enter to continue
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
what repository are you in?
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
OpenAI Codex v0.10.0 (research preview)
1+
>_ You are using OpenAI Codex in ~
22

3-
codex session 56576d81-529d-42f3-843b-78d870054a75
4-
workdir: /Users/jkmr/Documents/work/agentapi
5-
model: codex-mini-latest
6-
provider: openai
7-
approval: untrusted
8-
sandbox: read-only
9-
reasoning effort: medium
10-
reasoning summaries: auto
3+
To get started, describe a task or try one of these commands:
4+
5+
/init - create an AGENTS.md file with instructions for Codex
6+
/status - show current session configuration and token usage
7+
/diff - show git diff (including untracked files)
8+
/prompts - show example prompts
9+
10+
⏎ send Shift+⏎ newline Ctrl+C quit
Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,11 @@
1-
╭Messages (tab to focus)──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
2-
│OpenAI Codex v0.10.0 (research preview) │
3-
│ │
4-
│codex session 56576d81-529d-42f3-843b-78d870054a75 │
5-
│workdir: /Users/jkmr/Documents/work/agentapi │
6-
│model: codex-mini-latest │
7-
│provider: openai │
8-
│approval: untrusted │
9-
│sandbox: read-only │
10-
│reasoning effort: medium │
11-
│reasoning summaries: auto │
12-
│ │
13-
│ │
14-
│ │
15-
│ │
16-
│ │
17-
│ │
18-
│ │
19-
│ │
20-
│ │
21-
│ │
22-
│ │
23-
│ │
24-
│ │
25-
│ │
26-
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
27-
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
28-
│ send a message │
29-
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────Enter to send | Ctrl+D to quit | Ctrl+J for newline╯
1+
>_ You are using OpenAI Codex in ~
2+
3+
To get started, describe a task or try one of these commands:
4+
5+
/init - create an AGENTS.md file with instructions for Codex
6+
/status - show current session configuration and token usage
7+
/diff - show git diff (including untracked files)
8+
/prompts - show example prompts
9+
10+
▌ Ask Codex to do anything
11+
⏎ send Shift+⏎ newline Ctrl+C quit

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /