The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(cli): stop beacon scan from cutting characters in half (#1055)
Rudy Mizrahi Celeklia7682f0b1d05
diff --git a/cli/beacon/cmd/scan.go b/cli/beacon/cmd/scan.goindex b0684942..88cfe3de 100644--- a/cli/beacon/cmd/scan.go+++ b/cli/beacon/cmd/scan.go@@ -199,11 +199,7 @@ func summarizeEvent(e asymptoteobserve.Event) string {}func truncate(s string, n int) string {- s = strings.ReplaceAll(strings.ReplaceAll(s, "\n", " "), "\r", " ")- if len(s) <= n {- return s- }- return s[:n-1] + "…"+ return truncateRunes(strings.NewReplacer("\n", " ", "\r", " ").Replace(s), n)}func init() {diff --git a/cli/beacon/cmd/scan_test.go b/cli/beacon/cmd/scan_test.goindex 07b371dc..27825a3e 100644--- a/cli/beacon/cmd/scan_test.go+++ b/cli/beacon/cmd/scan_test.go@@ -6,6 +6,9 @@ import ("path/filepath""strings""testing"+ "unicode/utf8"++ "github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve""github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve/threatrules")@@ -202,3 +205,20 @@ func TestScanEmptyRulesDirKeepsMessage(t *testing.T) {t.Fatalf("want the unchanged empty-store message, got %v", err)}}++// A finding's prompt or command is cut to fit one line. The cut must land between characters:+// a prompt in Japanese or with accents is mostly multibyte, and a byte cut prints a broken rune.+func TestSummarizeEventTruncatesWholeCharacters(t *testing.T) {+ prompt := strings.Repeat("é", 150)+ got := summarizeEvent(asymptoteobserve.Event{+ Event: asymptoteobserve.EventInfo{Action: "prompt.submitted"},+ Prompt: &asymptoteobserve.PromptInfo{Text: prompt},+ })+ if !utf8.ValidString(got) {+ t.Fatalf("summary is not valid UTF-8: %q", got)+ }+ want := "prompt.submitted: " + strings.Repeat("é", 99) + "…"+ if got != want {+ t.Fatalf("summary = %q, want %q", got, want)+ }+}