diff --git a/README.md b/README.md index e96e420..50d1d9e 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ agentapi server -- goose ``` > [!NOTE] -> When using Codex, Gemini, Amp or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break. +> When using Codex, Opencode, Gemini, Amp or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break. An OpenAPI schema is available in [openapi.json](openapi.json). diff --git a/cmd/server/server.go b/cmd/server/server.go index 9bf2185..6581e37 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -23,16 +23,17 @@ import ( type AgentType = msgfmt.AgentType const ( - AgentTypeClaude AgentType = msgfmt.AgentTypeClaude - AgentTypeGoose AgentType = msgfmt.AgentTypeGoose - AgentTypeAider AgentType = msgfmt.AgentTypeAider - AgentTypeCodex AgentType = msgfmt.AgentTypeCodex - AgentTypeGemini AgentType = msgfmt.AgentTypeGemini - AgentTypeAmp AgentType = msgfmt.AgentTypeAmp - AgentTypeCursor AgentType = msgfmt.AgentTypeCursor - AgentTypeAuggie AgentType = msgfmt.AgentTypeAuggie - AgentTypeAmazonQ AgentType = msgfmt.AgentTypeAmazonQ - AgentTypeCustom AgentType = msgfmt.AgentTypeCustom + AgentTypeClaude AgentType = msgfmt.AgentTypeClaude + AgentTypeGoose AgentType = msgfmt.AgentTypeGoose + AgentTypeAider AgentType = msgfmt.AgentTypeAider + AgentTypeCodex AgentType = msgfmt.AgentTypeCodex + AgentTypeGemini AgentType = msgfmt.AgentTypeGemini + AgentTypeAmp AgentType = msgfmt.AgentTypeAmp + AgentTypeCursor AgentType = msgfmt.AgentTypeCursor + AgentTypeAuggie AgentType = msgfmt.AgentTypeAuggie + AgentTypeAmazonQ AgentType = msgfmt.AgentTypeAmazonQ + AgentTypeOpencode AgentType = msgfmt.AgentTypeOpencode + AgentTypeCustom AgentType = msgfmt.AgentTypeCustom ) // agentTypeAliases contains the mapping of possible input agent type strings to their canonical AgentType values @@ -48,6 +49,7 @@ var agentTypeAliases = map[string]AgentType{ "cursor-agent": AgentTypeCursor, "q": AgentTypeAmazonQ, "amazonq": AgentTypeAmazonQ, + "opencode": AgentTypeOpencode, "custom": AgentTypeCustom, } diff --git a/cmd/server/server_test.go b/cmd/server/server_test.go index 17cd11d..03c52ff 100644 --- a/cmd/server/server_test.go +++ b/cmd/server/server_test.go @@ -67,6 +67,11 @@ func TestParseAgentType(t *testing.T) { agentTypeVar: "", want: AgentTypeAmazonQ, }, + { + firstArg: "opencode", + agentTypeVar: "", + want: AgentTypeOpencode, + }, { firstArg: "auggie", agentTypeVar: "", @@ -117,6 +122,11 @@ func TestParseAgentType(t *testing.T) { agentTypeVar: "q", want: AgentTypeAmazonQ, }, + { + firstArg: "claude", + agentTypeVar: "opencode", + want: AgentTypeOpencode, + }, { firstArg: "claude", agentTypeVar: "cursor-agent", diff --git a/lib/httpapi/server.go b/lib/httpapi/server.go index e8abab9..b72b4c3 100644 --- a/lib/httpapi/server.go +++ b/lib/httpapi/server.go @@ -196,7 +196,8 @@ func NewServer(ctx context.Context, config ServerConfig) (*Server, error) { return mf.FormatAgentMessage(config.AgentType, message, userInput) } conversation := st.NewConversation(ctx, st.ConversationConfig{ - AgentIO: config.Process, + AgentType: config.AgentType, + AgentIO: config.Process, GetTime: func() time.Time { return time.Now() }, diff --git a/lib/msgfmt/message_box.go b/lib/msgfmt/message_box.go index 9c42468..ce4eeee 100644 --- a/lib/msgfmt/message_box.go +++ b/lib/msgfmt/message_box.go @@ -60,3 +60,22 @@ func removeCodexInputBox(msg string) string { } return strings.Join(lines, "\n") } + +func removeOpencodeMessageBox(msg string) string { + lines := strings.Split(msg, "\n") + // Check the last 3 lines for + // + // ┃ ┃ + // ┃ > ┃ + // ┃ ┃ + // We only check for the first ┃ and then an empty line above it - as sometimes the full input block does not load within a snapshot, + // this leads to displaying a bunch of newlines. + for i := len(lines) - 1; i >= 1; i-- { + if strings.TrimSpace(lines[i-1]) == "" && + strings.ReplaceAll(lines[i], " ", "") == "┃┃" { + lines = lines[:i-1] + break + } + } + return strings.Join(lines, "\n") +} diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index 75082ff..4844b3f 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -196,6 +196,13 @@ func RemoveUserInput(msgRaw string, userInputRaw string, agentType AgentType) st if idx, found := skipTrailingInputBoxLine(msgLines, lastUserInputLineIdx, "┘", "└"); found { lastUserInputLineIdx = idx } + } else if agentType == AgentTypeOpencode { + // skip +2 lines after the input + // ┃ jkmr (08:46 PM) ┃ + // ┃ ┃ + if lastUserInputLineIdx+2 < len(msgLines) { + lastUserInputLineIdx += 2 + } } return strings.Join(msgLines[lastUserInputLineIdx+1:], "\n") @@ -234,6 +241,7 @@ const ( AgentTypeCursor AgentType = "cursor" AgentTypeAuggie AgentType = "auggie" AgentTypeAmazonQ AgentType = "amazonq" + AgentTypeOpencode AgentType = "opencode" AgentTypeCustom AgentType = "custom" ) @@ -251,6 +259,13 @@ func formatCodexMessage(message string, userInput string) string { return message } +func formatOpencodeMessage(message string, userInput string) string { + message = RemoveUserInput(message, userInput, AgentTypeOpencode) + message = removeOpencodeMessageBox(message) + message = trimEmptyLines(message) + return message +} + func FormatAgentMessage(agentType AgentType, message string, userInput string) string { switch agentType { case AgentTypeClaude: @@ -271,6 +286,8 @@ func FormatAgentMessage(agentType AgentType, message string, userInput string) s return formatGenericMessage(message, userInput, agentType) case AgentTypeAmazonQ: return formatGenericMessage(message, userInput, agentType) + case AgentTypeOpencode: + return formatOpencodeMessage(message, userInput) case AgentTypeCustom: return formatGenericMessage(message, userInput, agentType) default: diff --git a/lib/msgfmt/msgfmt_test.go b/lib/msgfmt/msgfmt_test.go index 1afe6a6..9cbb5ca 100644 --- a/lib/msgfmt/msgfmt_test.go +++ b/lib/msgfmt/msgfmt_test.go @@ -218,7 +218,7 @@ func TestTrimEmptyLines(t *testing.T) { func TestFormatAgentMessage(t *testing.T) { dir := "testdata/format" - agentTypes := []AgentType{AgentTypeClaude, AgentTypeGoose, AgentTypeAider, AgentTypeGemini, AgentTypeAmp, AgentTypeCodex, AgentTypeCursor, AgentTypeAuggie, AgentTypeAmazonQ, AgentTypeCustom} + agentTypes := []AgentType{AgentTypeClaude, AgentTypeGoose, AgentTypeAider, AgentTypeGemini, AgentTypeAmp, AgentTypeCodex, AgentTypeCursor, AgentTypeAuggie, AgentTypeAmazonQ, AgentTypeOpencode, AgentTypeCustom} for _, agentType := range agentTypes { t.Run(string(agentType), func(t *testing.T) { cases, err := testdataDir.ReadDir(path.Join(dir, string(agentType))) diff --git a/lib/msgfmt/testdata/format/opencode/first_message/expected.txt b/lib/msgfmt/testdata/format/opencode/first_message/expected.txt new file mode 100644 index 0000000..8882891 --- /dev/null +++ b/lib/msgfmt/testdata/format/opencode/first_message/expected.txt @@ -0,0 +1,12 @@ + █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀ + █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀ + ▀▀▀▀ █▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ + v0.6.8 + + /new new session ctrl+x n + /help show help ctrl+x h + /share share session ctrl+x s + /models list models ctrl+x m + + + Grok Code is free for a limited time \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/opencode/first_message/msg.txt b/lib/msgfmt/testdata/format/opencode/first_message/msg.txt new file mode 100644 index 0000000..7b797b1 --- /dev/null +++ b/lib/msgfmt/testdata/format/opencode/first_message/msg.txt @@ -0,0 +1,604 @@ + █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀ + █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀ + ▀▀▀▀ █▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ + v0.6.8 + + /new new session ctrl+x n + /help show help ctrl+x h + /share share session ctrl+x s + /models list models ctrl+x m + + + Grok Code is free for a limited time + + + ┃ ┃ + ┃ > ┃ + ┃ ┃ + enter send + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + opencode v0.6.8 ~/Documents/work/agentapi tab ┃ BUILD AGENT \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/opencode/first_message/user.txt b/lib/msgfmt/testdata/format/opencode/first_message/user.txt new file mode 100644 index 0000000..e69de29 diff --git a/lib/msgfmt/testdata/format/opencode/second_message/expected.txt b/lib/msgfmt/testdata/format/opencode/second_message/expected.txt new file mode 100644 index 0000000..8767a12 --- /dev/null +++ b/lib/msgfmt/testdata/format/opencode/second_message/expected.txt @@ -0,0 +1,14 @@ + ┃ + ┃ Shell Check git remote URLs to identify repository + ┃ + ┃ $ git remote -v + ┃ origin https://github.com/35C4n0r/agentapi (fetch) + ┃ origin https://github.com/35C4n0r/agentapi (push) + ┃ upstream https://github.com/coder/agentapi.git (fetch) + ┃ upstream https://github.com/coder/agentapi.git (push) + ┃ + + + This is the 35C4n0r/agentapi repository, which is a fork of + coder/agentapi. + Build claude-sonnet-4-20250514 (09:19 PM) \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/opencode/second_message/msg.txt b/lib/msgfmt/testdata/format/opencode/second_message/msg.txt new file mode 100644 index 0000000..2350003 --- /dev/null +++ b/lib/msgfmt/testdata/format/opencode/second_message/msg.txt @@ -0,0 +1,1185 @@ + ┃ ┃ + ┃ Which repo is this ? ┃ + ┃ jkmr (09:19 PM) ┃ + ┃ ┃ + + ┃ + ┃ Shell Check git remote URLs to identify repository + ┃ + ┃ $ git remote -v + ┃ origin https://github.com/35C4n0r/agentapi (fetch) + ┃ origin https://github.com/35C4n0r/agentapi (push) + ┃ upstream https://github.com/coder/agentapi.git (fetch) + ┃ upstream https://github.com/coder/agentapi.git (push) + ┃ + + + This is the 35C4n0r/agentapi repository, which is a fork of + coder/agentapi. + Build claude-sonnet-4-20250514 (09:19 PM) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ┃ ┃ + ┃ > ┃ + ┃ ┃ + enter send Anthropic Claude Sonnet 4 + + opencode v0.6.8 ~/Documents/work/agentapi:feat-opencode tab ┃ BUILD AGENT \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/opencode/second_message/user.txt b/lib/msgfmt/testdata/format/opencode/second_message/user.txt new file mode 100644 index 0000000..c7d3776 --- /dev/null +++ b/lib/msgfmt/testdata/format/opencode/second_message/user.txt @@ -0,0 +1 @@ +Which repo is this ? \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/opencode/thinking/expected.txt b/lib/msgfmt/testdata/format/opencode/thinking/expected.txt new file mode 100644 index 0000000..cbc0e92 --- /dev/null +++ b/lib/msgfmt/testdata/format/opencode/thinking/expected.txt @@ -0,0 +1,2 @@ + Generating... + Build claude-sonnet-4-20250514 (09:23 PM) \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/opencode/thinking/msg.txt b/lib/msgfmt/testdata/format/opencode/thinking/msg.txt new file mode 100644 index 0000000..57bc242 --- /dev/null +++ b/lib/msgfmt/testdata/format/opencode/thinking/msg.txt @@ -0,0 +1,1185 @@ + ┃ ┃ + ┃ Which repo is this ? ┃ + ┃ jkmr (09:23 PM) ┃ + ┃ ┃ + + + Generating... + Build claude-sonnet-4-20250514 (09:23 PM) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ┃ ┃ + ┃ > ┃ + ┃ ┃ + working esc interrupt Anthropic Claude Sonnet 4 + + opencode v0.6.8 ~/Documents/work/agentapi:feat-opencode tab ┃ BUILD AGENT \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/opencode/thinking/user.txt b/lib/msgfmt/testdata/format/opencode/thinking/user.txt new file mode 100644 index 0000000..c7d3776 --- /dev/null +++ b/lib/msgfmt/testdata/format/opencode/thinking/user.txt @@ -0,0 +1 @@ +Which repo is this ? \ No newline at end of file diff --git a/lib/screentracker/conversation.go b/lib/screentracker/conversation.go index d7b12d0..7777e04 100644 --- a/lib/screentracker/conversation.go +++ b/lib/screentracker/conversation.go @@ -24,7 +24,8 @@ type AgentIO interface { } type ConversationConfig struct { - AgentIO AgentIO + AgentType msgfmt.AgentType + AgentIO AgentIO // GetTime returns the current time GetTime func() time.Time // How often to take a snapshot for the stability check @@ -133,15 +134,29 @@ func (c *Conversation) StartSnapshotLoop(ctx context.Context) { }() } -func FindNewMessage(oldScreen, newScreen string) string { +func FindNewMessage(oldScreen, newScreen string, agentType msgfmt.AgentType) string { oldLines := strings.Split(oldScreen, "\n") newLines := strings.Split(newScreen, "\n") oldLinesMap := make(map[string]bool) + + // -1 indicates no header + dynamicHeaderEnd := -1 + + // Skip header lines for Opencode agent type to avoid false positives + // The header contains dynamic content (token count, context percentage, cost) + // that changes between screens, causing line comparison mismatches: + // + // ┃ # Getting Started with Claude CLI ┃ + // ┃ /share to create a shareable link 12.6K/6% ($0.05) ┃ + if len(newLines) >= 2 && agentType == msgfmt.AgentTypeOpencode { + dynamicHeaderEnd = 2 + } + for _, line := range oldLines { oldLinesMap[line] = true } firstNonMatchingLine := len(newLines) - for i, line := range newLines { + for i, line := range newLines[dynamicHeaderEnd+1:] { if !oldLinesMap[line] { firstNonMatchingLine = i break @@ -178,7 +193,7 @@ func (c *Conversation) lastMessage(role ConversationRole) ConversationMessage { // This function assumes that the caller holds the lock func (c *Conversation) updateLastAgentMessage(screen string, timestamp time.Time) { - agentMessage := FindNewMessage(c.screenBeforeLastUserMessage, screen) + agentMessage := FindNewMessage(c.screenBeforeLastUserMessage, screen, c.cfg.AgentType) lastUserMessage := c.lastMessage(ConversationRoleUser) if c.cfg.FormatMessage != nil { agentMessage = c.cfg.FormatMessage(agentMessage, lastUserMessage.Message) diff --git a/lib/screentracker/conversation_test.go b/lib/screentracker/conversation_test.go index 61b28df..53c77fd 100644 --- a/lib/screentracker/conversation_test.go +++ b/lib/screentracker/conversation_test.go @@ -8,6 +8,7 @@ import ( "testing" "time" + "github.com/coder/agentapi/lib/msgfmt" "github.com/stretchr/testify/assert" st "github.com/coder/agentapi/lib/screentracker" @@ -353,12 +354,12 @@ func TestMessages(t *testing.T) { var testdataDir embed.FS func TestFindNewMessage(t *testing.T) { - assert.Equal(t, "", st.FindNewMessage("123456", "123456")) - assert.Equal(t, "1234567", st.FindNewMessage("123456", "1234567")) - assert.Equal(t, "42", st.FindNewMessage("123", "123\n \n \n \n42")) - assert.Equal(t, "12342", st.FindNewMessage("123", "12342\n \n \n \n")) - assert.Equal(t, "42", st.FindNewMessage("123", "123\n \n \n \n42\n \n \n \n")) - assert.Equal(t, "42", st.FindNewMessage("89", "42")) + assert.Equal(t, "", st.FindNewMessage("123456", "123456", msgfmt.AgentTypeCustom)) + assert.Equal(t, "1234567", st.FindNewMessage("123456", "1234567", msgfmt.AgentTypeCustom)) + assert.Equal(t, "42", st.FindNewMessage("123", "123\n \n \n \n42", msgfmt.AgentTypeCustom)) + assert.Equal(t, "12342", st.FindNewMessage("123", "12342\n \n \n \n", msgfmt.AgentTypeCustom)) + assert.Equal(t, "42", st.FindNewMessage("123", "123\n \n \n \n42\n \n \n \n", msgfmt.AgentTypeCustom)) + assert.Equal(t, "42", st.FindNewMessage("89", "42", msgfmt.AgentTypeCustom)) dir := "testdata/diff" cases, err := testdataDir.ReadDir(dir) @@ -371,7 +372,7 @@ func TestFindNewMessage(t *testing.T) { assert.NoError(t, err) expected, err := testdataDir.ReadFile(path.Join(dir, c.Name(), "expected.txt")) assert.NoError(t, err) - assert.Equal(t, string(expected), st.FindNewMessage(string(before), string(after))) + assert.Equal(t, string(expected), st.FindNewMessage(string(before), string(after), msgfmt.AgentTypeCustom)) }) } }