Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/msgfmt/message_box.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,24 @@ func removeOpencodeMessageBox(msg string) string {
}
return strings.Join(lines, "\n")
}

func removeAmpMessageBox(msg string) string {
lines := strings.Split(msg, "\n")
msgBoxEndFound := false
msgBoxStartIdx := len(lines)
for i := len(lines) - 1; i >= 0; i-- {
line := strings.TrimSpace(lines[i])
if !msgBoxEndFound && strings.HasPrefix(line, "╰") && strings.HasSuffix(line, "╯") {
msgBoxEndFound = true
}
if msgBoxEndFound && strings.HasPrefix(line, "╭") && strings.HasSuffix(line, "╮") {
msgBoxStartIdx = i
break
}
}
formattedMsg := strings.Join(lines[:msgBoxStartIdx], "\n")
if len(formattedMsg) == 0 {
return "Welcome to Amp"
}
return formattedMsg
}
9 changes: 8 additions & 1 deletion lib/msgfmt/msgfmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ func formatOpencodeMessage(message string, userInput string) string {
return message
}

func formatAmpMessage(message string, userInput string) string {
message = RemoveUserInput(message, userInput, AgentTypeAmp)
message = removeAmpMessageBox(message)
message = trimEmptyLines(message)
return message
}

func FormatAgentMessage(agentType AgentType, message string, userInput string) string {
switch agentType {
case AgentTypeClaude:
Expand All @@ -283,7 +290,7 @@ func FormatAgentMessage(agentType AgentType, message string, userInput string) s
case AgentTypeCopilot:
return formatGenericMessage(message, userInput, agentType)
case AgentTypeAmp:
return formatGenericMessage(message, userInput, agentType)
return formatAmpMessage(message, userInput)
case AgentTypeCursor:
return formatGenericMessage(message, userInput, agentType)
case AgentTypeAuggie:
Expand Down
17 changes: 16 additions & 1 deletion lib/msgfmt/testdata/format/amp/first_message/expected.txt
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
Welcome to Amp
..............
.....:::::.......... Welcome to Amp
....:::::::::::..........
....::::----::::::::.......
...::::---------:::::::::..... Ctrl+O to execute commands
...::::------------:::::::::... Type @ to mention files
....::----=======-----::::::::... Ctrl+C to exit
...:::---==========-----::::::...
...::---====++++====-----:::::...
...::--====++++++====----:::::.. Use the amp: help command for more information
..::---===++++++====----::::...
..:::--====+++++====----:::...
..:::---==========---::::.. Smart mode now uses Gemini 3 Pro.
..:::----===-----::::...
...::::----:::::...
............
33 changes: 29 additions & 4 deletions lib/msgfmt/testdata/format/amp/first_message/msg.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
Welcome to Amp

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯



..............
.....:::::.......... Welcome to Amp
....:::::::::::..........
....::::----::::::::.......
...::::---------:::::::::..... Ctrl+O to execute commands
...::::------------:::::::::... Type @ to mention files
....::----=======-----::::::::... Ctrl+C to exit
...:::---==========-----::::::...
...::---====++++====-----:::::...
...::--====++++++====----:::::.. Use the amp: help command for more information
..::---===++++++====----::::...
..:::--====+++++====----:::...
..:::---==========---::::.. Smart mode now uses Gemini 3 Pro.
..:::----===-----::::...
...::::----:::::...
............





╭─smart (click or Ctrl+S to switch)─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────~/Documents/work/agentapi (fix-amp-formatting)─╯
14 changes: 4 additions & 10 deletions lib/msgfmt/testdata/format/amp/multi-line-input/expected.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
∴ Thinking
The user is asking me to identify which file contains this specific TypeScript code snippet. The code shows a useEffect hook that sets up polling
for messages and server status. I need to search for this code in the codebase to find the file it belongs to.
✓ Thinking ▶

I should use the Grep tool to search for some unique parts of this code to locate the file.
Grep const messageInterval = setInterval\(fetchMessages, 1000

✓ Grep Set up polling for messages and server status
✓ Thinking ▶

✓ Grep const messageInterval = setInterval\(fetchMessages, 1000\)

✓ List Directory /mnt/c/Users/Username/test-amp

No files found in the workspace containing this code.
✓ Grep setInterval in chat
70 changes: 37 additions & 33 deletions lib/msgfmt/testdata/format/amp/multi-line-input/msg.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
┃ Which file is this code from?
┃ ```ts
┃ // Set up polling for messages and server status
┃ useEffect(() => {
┃ // Check server status initially
┃ checkServerStatus();
┃ // Set up polling intervals
┃ const messageInterval = setInterval(fetchMessages, 1000);
┃ const statusInterval = setInterval(checkServerStatus, 250);
┃ // Clean up intervals on component unmount
┃ return () => {
┃ clearInterval(messageInterval);
┃ clearInterval(statusInterval);
┃ };
┃ }, []);
┃ ```

∴ Thinking
The user is asking me to identify which file contains this specific TypeScript code snippet. The code shows a useEffect hook that sets up polling
for messages and server status. I need to search for this code in the codebase to find the file it belongs to.

I should use the Grep tool to search for some unique parts of this code to locate the file.

✓ Grep Set up polling for messages and server status

✓ Grep const messageInterval = setInterval\(fetchMessages, 1000\)

✓ List Directory /mnt/c/Users/Username/test-amp

No files found in the workspace containing this code.



┃ Which file is this code from?
┃ ```ts
┃ // Set up polling for messages and server status
┃ useEffect(() => {
┃ // Check server status initially
┃ checkServerStatus();
┃ // Set up polling intervals
┃ const messageInterval = setInterval(fetchMessages, 1000);
┃ const statusInterval = setInterval(checkServerStatus, 250);
┃ // Clean up intervals on component unmount
┃ return () => {
┃ clearInterval(messageInterval);
┃ clearInterval(statusInterval);
┃ };
┃ }, []);
┃ ```

✓ Thinking ▶

✓ Grep const messageInterval = setInterval\(fetchMessages, 1000

✓ Thinking ▶

✓ Grep setInterval in chat

╭─smart─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────~/Documents/work/agentapi (fix-amp-formatting)─╯
∿ Waiting for response... Esc to cancel 2% of 983k
9 changes: 2 additions & 7 deletions lib/msgfmt/testdata/format/amp/second_message/expected.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
∴ Thinking
The user is asking a simple social greeting "How are you?". This is a casual question about my state/wellbeing. I should respond concisely and
directly as per my instructions to keep responses short (fewer than 4 lines unless asked for detail). I don't need to use any tools for this simple
greeting.
✓ Thinking ▶

I should avoid elaborate explanations or summaries, and just give a brief, direct response.

I'm ready to help you with your coding tasks. What would you like to work on?
I am doing well and ready to help you with your software engineering tasks. How can I assist you with the agentapi repository today?
18 changes: 11 additions & 7 deletions lib/msgfmt/testdata/format/amp/second_message/msg.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
┃ How are you?

∴ Thinking
The user is asking a simple social greeting "How are you?". This is a casual question about my state/wellbeing. I should respond concisely and
directly as per my instructions to keep responses short (fewer than 4 lines unless asked for detail). I don't need to use any tools for this simple
greeting.

I should avoid elaborate explanations or summaries, and just give a brief, direct response.
┃ How are you?

I'm ready to help you with your coding tasks. What would you like to work on?
✓ Thinking ▶

I am doing well and ready to help you with your software engineering tasks. How can I assist you with the agentapi repository today?

╭─smart─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────~/Documents/work/agentapi (fix-amp-formatting)─╯
1% of 983k