From 8efee81230418f567b22351b36d282a71f933ad0 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Mon, 3 Nov 2025 18:38:47 +0530 Subject: [PATCH 01/19] feat: opencode initial prompt hack test --- lib/httpapi/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/httpapi/server.go b/lib/httpapi/server.go index b97f8da..cb3849d 100644 --- a/lib/httpapi/server.go +++ b/lib/httpapi/server.go @@ -326,6 +326,12 @@ func (s *Server) StartSnapshotLoop(ctx context.Context) { // Send initial prompt when agent becomes stable for the first time if !s.conversation.InitialPromptSent && convertStatus(currentStatus) == AgentStatusStable { + + // If agent type is opencode + if s.agentType == mf.AgentTypeOpencode { + time.Sleep(5 * time.Second) + } + if err := s.conversation.SendMessage(FormatMessage(s.agentType, s.conversation.InitialPrompt)...); err != nil { s.logger.Error("Failed to send initial prompt", "error", err) } else { From c8e93c3084150abceaa101755431679f8178d419 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Mon, 3 Nov 2025 22:44:34 +0530 Subject: [PATCH 02/19] wip --- lib/httpapi/server.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/httpapi/server.go b/lib/httpapi/server.go index cb3849d..9e48279 100644 --- a/lib/httpapi/server.go +++ b/lib/httpapi/server.go @@ -332,6 +332,11 @@ func (s *Server) StartSnapshotLoop(ctx context.Context) { time.Sleep(5 * time.Second) } + // If we still have it as stable, go ahead. + if convertStatus(currentStatus) != AgentStatusStable { + break + } + if err := s.conversation.SendMessage(FormatMessage(s.agentType, s.conversation.InitialPrompt)...); err != nil { s.logger.Error("Failed to send initial prompt", "error", err) } else { From 3001416e6aa10a2408330782173c17801e4ba875 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Mon, 3 Nov 2025 22:44:55 +0530 Subject: [PATCH 03/19] wip --- lib/httpapi/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/httpapi/server.go b/lib/httpapi/server.go index 9e48279..15083b4 100644 --- a/lib/httpapi/server.go +++ b/lib/httpapi/server.go @@ -333,7 +333,7 @@ func (s *Server) StartSnapshotLoop(ctx context.Context) { } // If we still have it as stable, go ahead. - if convertStatus(currentStatus) != AgentStatusStable { + if convertStatus(s.conversation.Status()) != AgentStatusStable { break } From 192cbea6432a546e45541d8813945293d55477c7 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Mon, 3 Nov 2025 23:04:18 +0530 Subject: [PATCH 04/19] wip --- lib/httpapi/server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/httpapi/server.go b/lib/httpapi/server.go index 15083b4..c51425e 100644 --- a/lib/httpapi/server.go +++ b/lib/httpapi/server.go @@ -327,6 +327,8 @@ func (s *Server) StartSnapshotLoop(ctx context.Context) { // Send initial prompt when agent becomes stable for the first time if !s.conversation.InitialPromptSent && convertStatus(currentStatus) == AgentStatusStable { + fmt.Printf("AgentType: %s", mf.AgentTypeOpencode) + // If agent type is opencode if s.agentType == mf.AgentTypeOpencode { time.Sleep(5 * time.Second) From 187946680cedb615ba568e83472332bb578187b9 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Mon, 3 Nov 2025 23:16:50 +0530 Subject: [PATCH 05/19] wip --- lib/msgfmt/message_box.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/msgfmt/message_box.go b/lib/msgfmt/message_box.go index ce4eeee..b9c20db 100644 --- a/lib/msgfmt/message_box.go +++ b/lib/msgfmt/message_box.go @@ -70,9 +70,10 @@ func removeOpencodeMessageBox(msg string) string { // ┃ ┃ // 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], " ", "") == "┃┃" { + for i := len(lines) - 2; i >= 1; i-- { + if strings.ReplaceAll(lines[i-1], " ", "") == "┃┃" && + strings.ReplaceAll(lines[i+1], " ", "") == "┃┃" && + strings.ReplaceAll(lines[i], " ", "") == "┃>┃" { lines = lines[:i-1] break } From b054d2ebd6730500fe194e23258453c64f255ba2 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Mon, 3 Nov 2025 23:23:39 +0530 Subject: [PATCH 06/19] wip --- lib/msgfmt/msgfmt.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index 0cf1ca8..377fd09 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -262,8 +262,8 @@ func formatCodexMessage(message string, userInput string) string { } func formatOpencodeMessage(message string, userInput string) string { - message = RemoveUserInput(message, userInput, AgentTypeOpencode) - message = removeOpencodeMessageBox(message) + //message = RemoveUserInput(message, userInput, AgentTypeOpencode) + //message = removeOpencodeMessageBox(message) message = trimEmptyLines(message) return message } From 21629b8f565d8cf1c943d92714d2d0ddc1fe22f7 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Mon, 3 Nov 2025 23:29:12 +0530 Subject: [PATCH 07/19] wip --- lib/msgfmt/msgfmt.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index 377fd09..fc48ba3 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -196,13 +196,6 @@ 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") @@ -262,7 +255,7 @@ func formatCodexMessage(message string, userInput string) string { } func formatOpencodeMessage(message string, userInput string) string { - //message = RemoveUserInput(message, userInput, AgentTypeOpencode) + message = RemoveUserInput(message, userInput, AgentTypeOpencode) //message = removeOpencodeMessageBox(message) message = trimEmptyLines(message) return message From 0393c0701acc7ce4cb48d2e7daeaedec37ab6786 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 4 Nov 2025 22:16:49 +0530 Subject: [PATCH 08/19] wip --- lib/httpapi/server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/httpapi/server.go b/lib/httpapi/server.go index c51425e..0effa41 100644 --- a/lib/httpapi/server.go +++ b/lib/httpapi/server.go @@ -327,7 +327,7 @@ func (s *Server) StartSnapshotLoop(ctx context.Context) { // Send initial prompt when agent becomes stable for the first time if !s.conversation.InitialPromptSent && convertStatus(currentStatus) == AgentStatusStable { - fmt.Printf("AgentType: %s", mf.AgentTypeOpencode) + fmt.Printf("AgentType: %s\n", mf.AgentTypeOpencode) // If agent type is opencode if s.agentType == mf.AgentTypeOpencode { @@ -336,7 +336,7 @@ func (s *Server) StartSnapshotLoop(ctx context.Context) { // If we still have it as stable, go ahead. if convertStatus(s.conversation.Status()) != AgentStatusStable { - break + continue } if err := s.conversation.SendMessage(FormatMessage(s.agentType, s.conversation.InitialPrompt)...); err != nil { From 8d51c68a2aa4bf5fd158b97476a2816bc4eac5ae Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 4 Nov 2025 22:25:45 +0530 Subject: [PATCH 09/19] wip --- lib/msgfmt/msgfmt.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index fc48ba3..73f8f7d 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -256,7 +256,7 @@ func formatCodexMessage(message string, userInput string) string { func formatOpencodeMessage(message string, userInput string) string { message = RemoveUserInput(message, userInput, AgentTypeOpencode) - //message = removeOpencodeMessageBox(message) + message = removeOpencodeMessageBox(message) message = trimEmptyLines(message) return message } From 6d0f987b0f3f14e7e833d98dee0b028f0be20ebd Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 4 Nov 2025 22:42:34 +0530 Subject: [PATCH 10/19] wip --- lib/msgfmt/message_box.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/msgfmt/message_box.go b/lib/msgfmt/message_box.go index b9c20db..e06c195 100644 --- a/lib/msgfmt/message_box.go +++ b/lib/msgfmt/message_box.go @@ -1,6 +1,7 @@ package msgfmt import ( + "fmt" "strings" ) @@ -63,6 +64,11 @@ func removeCodexInputBox(msg string) string { func removeOpencodeMessageBox(msg string) string { lines := strings.Split(msg, "\n") + fmt.Println("\n\n\n\n\n") + fmt.Println("===================================") + for i := 0; i < len(lines); i++ { + fmt.Printf("%d: %s\n", i, lines[i]) + } // Check the last 3 lines for // // ┃ ┃ @@ -74,9 +80,12 @@ func removeOpencodeMessageBox(msg string) string { if strings.ReplaceAll(lines[i-1], " ", "") == "┃┃" && strings.ReplaceAll(lines[i+1], " ", "") == "┃┃" && strings.ReplaceAll(lines[i], " ", "") == "┃>┃" { + fmt.Printf("Magic at line: %d, %s\n", i, lines[i]) lines = lines[:i-1] break } } + fmt.Println("===================================") + fmt.Println("\n\n\n\n") return strings.Join(lines, "\n") } From bd2d126f372bd26283debedb277b40b87254cdfc Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 4 Nov 2025 22:51:52 +0530 Subject: [PATCH 11/19] wip --- lib/msgfmt/msgfmt.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index 73f8f7d..fc48ba3 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -256,7 +256,7 @@ func formatCodexMessage(message string, userInput string) string { func formatOpencodeMessage(message string, userInput string) string { message = RemoveUserInput(message, userInput, AgentTypeOpencode) - message = removeOpencodeMessageBox(message) + //message = removeOpencodeMessageBox(message) message = trimEmptyLines(message) return message } From a18875d7dddf9899a166c50d499bf0ce5aad6f82 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 4 Nov 2025 22:59:28 +0530 Subject: [PATCH 12/19] wip --- lib/msgfmt/msgfmt.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index fc48ba3..ba132ef 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -255,9 +255,9 @@ func formatCodexMessage(message string, userInput string) string { } func formatOpencodeMessage(message string, userInput string) string { - message = RemoveUserInput(message, userInput, AgentTypeOpencode) + //message = RemoveUserInput(message, userInput, AgentTypeOpencode) //message = removeOpencodeMessageBox(message) - message = trimEmptyLines(message) + //message = trimEmptyLines(message) return message } From e6b40a166f9bf30d4e2afa63e4cc0b19dc3830c0 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 4 Nov 2025 23:07:28 +0530 Subject: [PATCH 13/19] wip --- lib/msgfmt/msgfmt.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index ba132ef..88b1c37 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -255,7 +255,7 @@ func formatCodexMessage(message string, userInput string) string { } func formatOpencodeMessage(message string, userInput string) string { - //message = RemoveUserInput(message, userInput, AgentTypeOpencode) + message = RemoveUserInput(message, userInput, AgentTypeOpencode) //message = removeOpencodeMessageBox(message) //message = trimEmptyLines(message) return message From 5486d314efb3cbf56549b0bb48e9a8434d20f09b Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 4 Nov 2025 23:20:47 +0530 Subject: [PATCH 14/19] wip --- lib/msgfmt/msgfmt.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index 88b1c37..722a290 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -1,6 +1,7 @@ package msgfmt import ( + "fmt" "strings" ) @@ -255,7 +256,14 @@ func formatCodexMessage(message string, userInput string) string { } func formatOpencodeMessage(message string, userInput string) string { - message = RemoveUserInput(message, userInput, AgentTypeOpencode) + fmt.Println("\n\n\n\n\n") + fmt.Println("===================================") + if len(message) > 10 { + fmt.Println(message[len(message)-7:]) + } + fmt.Println("===================================") + fmt.Println("\n\n\n\n\n") + //message = RemoveUserInput(message, userInput, AgentTypeOpencode) //message = removeOpencodeMessageBox(message) //message = trimEmptyLines(message) return message From 55a9ea0401d23e9e5608769db8f95a306babf497 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Wed, 5 Nov 2025 07:21:49 +0530 Subject: [PATCH 15/19] wip --- lib/msgfmt/msgfmt.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index 722a290..f4ecd40 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -258,12 +258,16 @@ func formatCodexMessage(message string, userInput string) string { func formatOpencodeMessage(message string, userInput string) string { fmt.Println("\n\n\n\n\n") fmt.Println("===================================") - if len(message) > 10 { - fmt.Println(message[len(message)-7:]) + lines := strings.Split(message, "\n") + if len(lines) > 10 { + for _, data := range lines[len(lines)-7:] { + fmt.Println(data) + } + fmt.Println(lines[len(lines)-7:]) } fmt.Println("===================================") fmt.Println("\n\n\n\n\n") - //message = RemoveUserInput(message, userInput, AgentTypeOpencode) + message = RemoveUserInput(message, userInput, AgentTypeOpencode) //message = removeOpencodeMessageBox(message) //message = trimEmptyLines(message) return message From a0c464e67099e323980a72e5fd4d2035a3c5820f Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Wed, 5 Nov 2025 08:19:43 +0530 Subject: [PATCH 16/19] wip --- lib/msgfmt/msgfmt.go | 13 +------------ lib/screentracker/conversation.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index f4ecd40..dd650e7 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -1,7 +1,6 @@ package msgfmt import ( - "fmt" "strings" ) @@ -256,17 +255,7 @@ func formatCodexMessage(message string, userInput string) string { } func formatOpencodeMessage(message string, userInput string) string { - fmt.Println("\n\n\n\n\n") - fmt.Println("===================================") - lines := strings.Split(message, "\n") - if len(lines) > 10 { - for _, data := range lines[len(lines)-7:] { - fmt.Println(data) - } - fmt.Println(lines[len(lines)-7:]) - } - fmt.Println("===================================") - fmt.Println("\n\n\n\n\n") + message = RemoveUserInput(message, userInput, AgentTypeOpencode) //message = removeOpencodeMessageBox(message) //message = trimEmptyLines(message) diff --git a/lib/screentracker/conversation.go b/lib/screentracker/conversation.go index 4617e8e..4210119 100644 --- a/lib/screentracker/conversation.go +++ b/lib/screentracker/conversation.go @@ -143,6 +143,18 @@ func (c *Conversation) StartSnapshotLoop(ctx context.Context) { func FindNewMessage(oldScreen, newScreen string, agentType msgfmt.AgentType) string { oldLines := strings.Split(oldScreen, "\n") newLines := strings.Split(newScreen, "\n") + + fmt.Println("\n\n\n\n\n") + fmt.Println("===================================") + lines := newLines + if len(lines) > 10 { + for _, data := range lines[len(lines)-9:] { + fmt.Println(data) + } + } + fmt.Println("===================================") + fmt.Println("\n\n\n\n\n") + oldLinesMap := make(map[string]bool) // -1 indicates no header From ac814088120561fb8bf56c145f473b95569b559e Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Wed, 5 Nov 2025 09:17:10 +0530 Subject: [PATCH 17/19] wip --- lib/msgfmt/message_box.go | 12 ++---------- lib/msgfmt/msgfmt.go | 4 ++-- lib/screentracker/conversation.go | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib/msgfmt/message_box.go b/lib/msgfmt/message_box.go index e06c195..eead397 100644 --- a/lib/msgfmt/message_box.go +++ b/lib/msgfmt/message_box.go @@ -64,11 +64,6 @@ func removeCodexInputBox(msg string) string { func removeOpencodeMessageBox(msg string) string { lines := strings.Split(msg, "\n") - fmt.Println("\n\n\n\n\n") - fmt.Println("===================================") - for i := 0; i < len(lines); i++ { - fmt.Printf("%d: %s\n", i, lines[i]) - } // Check the last 3 lines for // // ┃ ┃ @@ -77,15 +72,12 @@ func removeOpencodeMessageBox(msg string) string { // 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) - 2; i >= 1; i-- { - if strings.ReplaceAll(lines[i-1], " ", "") == "┃┃" && - strings.ReplaceAll(lines[i+1], " ", "") == "┃┃" && - strings.ReplaceAll(lines[i], " ", "") == "┃>┃" { + if strings.ReplaceAll(lines[i-2], " ", "") != "┃┃" && + strings.ReplaceAll(lines[i], " ", "") == "┃┃" { fmt.Printf("Magic at line: %d, %s\n", i, lines[i]) lines = lines[:i-1] break } } - fmt.Println("===================================") - fmt.Println("\n\n\n\n") return strings.Join(lines, "\n") } diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index dd650e7..64c2556 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -257,8 +257,8 @@ func formatCodexMessage(message string, userInput string) string { func formatOpencodeMessage(message string, userInput string) string { message = RemoveUserInput(message, userInput, AgentTypeOpencode) - //message = removeOpencodeMessageBox(message) - //message = trimEmptyLines(message) + message = removeOpencodeMessageBox(message) + message = trimEmptyLines(message) return message } diff --git a/lib/screentracker/conversation.go b/lib/screentracker/conversation.go index 4210119..b709970 100644 --- a/lib/screentracker/conversation.go +++ b/lib/screentracker/conversation.go @@ -144,16 +144,16 @@ func FindNewMessage(oldScreen, newScreen string, agentType msgfmt.AgentType) str oldLines := strings.Split(oldScreen, "\n") newLines := strings.Split(newScreen, "\n") - fmt.Println("\n\n\n\n\n") - fmt.Println("===================================") - lines := newLines - if len(lines) > 10 { - for _, data := range lines[len(lines)-9:] { - fmt.Println(data) - } - } - fmt.Println("===================================") - fmt.Println("\n\n\n\n\n") + //fmt.Println("\n\n\n\n\n") + //fmt.Println("===================================") + //lines := newLines + //if len(lines) > 10 { + // for _, data := range lines[len(lines)-9:] { + // fmt.Println(data) + // } + //} + //fmt.Println("===================================") + //fmt.Println("\n\n\n\n\n") oldLinesMap := make(map[string]bool) From f1c653eb00dfd0826568cec5cd60121ddea16621 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Wed, 5 Nov 2025 09:27:00 +0530 Subject: [PATCH 18/19] wip --- lib/msgfmt/message_box.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/msgfmt/message_box.go b/lib/msgfmt/message_box.go index eead397..0433c9c 100644 --- a/lib/msgfmt/message_box.go +++ b/lib/msgfmt/message_box.go @@ -1,7 +1,6 @@ package msgfmt import ( - "fmt" "strings" ) @@ -71,10 +70,10 @@ func removeOpencodeMessageBox(msg string) string { // ┃ ┃ // 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) - 2; i >= 1; i-- { + for i := len(lines) - 1; i >= 2; i-- { if strings.ReplaceAll(lines[i-2], " ", "") != "┃┃" && strings.ReplaceAll(lines[i], " ", "") == "┃┃" { - fmt.Printf("Magic at line: %d, %s\n", i, lines[i]) + //fmt.Printf("Magic at line: %d, %s\n", i, lines[i]) lines = lines[:i-1] break } From c70bf830bc54847567ea942360ec033f9bd7c088 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Wed, 5 Nov 2025 11:28:47 +0530 Subject: [PATCH 19/19] wip --- lib/httpapi/server.go | 11 ++++------- lib/msgfmt/message_box.go | 1 - lib/msgfmt/msgfmt.go | 7 +++++++ lib/screentracker/conversation.go | 12 ------------ 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/lib/httpapi/server.go b/lib/httpapi/server.go index 0effa41..f425b54 100644 --- a/lib/httpapi/server.go +++ b/lib/httpapi/server.go @@ -327,16 +327,13 @@ func (s *Server) StartSnapshotLoop(ctx context.Context) { // Send initial prompt when agent becomes stable for the first time if !s.conversation.InitialPromptSent && convertStatus(currentStatus) == AgentStatusStable { - fmt.Printf("AgentType: %s\n", mf.AgentTypeOpencode) - // If agent type is opencode if s.agentType == mf.AgentTypeOpencode { time.Sleep(5 * time.Second) - } - - // If we still have it as stable, go ahead. - if convertStatus(s.conversation.Status()) != AgentStatusStable { - continue + // If we still have it as stable, go ahead. + if convertStatus(s.conversation.Status()) != AgentStatusStable { + continue + } } if err := s.conversation.SendMessage(FormatMessage(s.agentType, s.conversation.InitialPrompt)...); err != nil { diff --git a/lib/msgfmt/message_box.go b/lib/msgfmt/message_box.go index 0433c9c..32aa55d 100644 --- a/lib/msgfmt/message_box.go +++ b/lib/msgfmt/message_box.go @@ -73,7 +73,6 @@ func removeOpencodeMessageBox(msg string) string { for i := len(lines) - 1; i >= 2; i-- { if strings.ReplaceAll(lines[i-2], " ", "") != "┃┃" && strings.ReplaceAll(lines[i], " ", "") == "┃┃" { - //fmt.Printf("Magic at line: %d, %s\n", i, lines[i]) lines = lines[:i-1] break } diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index 64c2556..6660a63 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") diff --git a/lib/screentracker/conversation.go b/lib/screentracker/conversation.go index b709970..4617e8e 100644 --- a/lib/screentracker/conversation.go +++ b/lib/screentracker/conversation.go @@ -143,18 +143,6 @@ func (c *Conversation) StartSnapshotLoop(ctx context.Context) { func FindNewMessage(oldScreen, newScreen string, agentType msgfmt.AgentType) string { oldLines := strings.Split(oldScreen, "\n") newLines := strings.Split(newScreen, "\n") - - //fmt.Println("\n\n\n\n\n") - //fmt.Println("===================================") - //lines := newLines - //if len(lines) > 10 { - // for _, data := range lines[len(lines)-9:] { - // fmt.Println(data) - // } - //} - //fmt.Println("===================================") - //fmt.Println("\n\n\n\n\n") - oldLinesMap := make(map[string]bool) // -1 indicates no header