Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Add CLI banner

shukieshah1689c9dad565
diff --git a/cli/beacon/cmd/root.go b/cli/beacon/cmd/root.go
index 28396d6d..0397ad6a 100644
--- a/cli/beacon/cmd/root.go
+++ b/cli/beacon/cmd/root.go
@@ -2,6 +2,7 @@ package cmd
import (
"fmt"
+ "io"
"os"
"github.com/spf13/cobra"
@@ -18,17 +19,64 @@ local telemetry, and writes Wazuh-compatible JSON logs without requiring an
Beacon-hosted backend.`,
Version: version.GetVersion(),
Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("Beacon Endpoint Agent")
- fmt.Println()
- fmt.Println("Start with:")
- fmt.Println(" beacon endpoint install")
- fmt.Println(" beacon endpoint status")
- fmt.Println(" beacon endpoint wazuh print-config")
- fmt.Println()
- cmd.Usage()
+ printRootSplash(cmd)
},
}
+const (
+ beaconPurple = "\x1b[38;5;141m"
+ resetColor = "\x1b[0m"
+)
+
+var beaconBanner = []string{
+ "██████╗ ███████╗ █████╗ ██████╗ ██████╗ ███╗ ██╗",
+ "██╔══██╗██╔════╝██╔══██╗██╔════╝██╔═══██╗████╗ ██║",
+ "██████╔╝█████╗ ███████║██║ ██║ ██║██╔██╗ ██║",
+ "██╔══██╗██╔══╝ ██╔══██║██║ ██║ ██║██║╚██╗██║",
+ "██████╔╝███████╗██║ ██║╚██████╗╚██████╔╝██║ ╚████║",
+ "╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝",
+}
+
+func printRootSplash(cmd *cobra.Command) {
+ out := cmd.OutOrStdout()
+ printBeaconBanner(out, shouldUseColor(out))
+ fmt.Fprintln(out, "Open-source telemetry layer for AI agents.")
+ fmt.Fprintln(out)
+ fmt.Fprintln(out, "Start with:")
+ fmt.Fprintln(out, " beacon endpoint install")
+ fmt.Fprintln(out, " beacon endpoint status")
+ fmt.Fprintln(out, " beacon endpoint wazuh print-config")
+ fmt.Fprintln(out)
+ _ = cmd.Usage()
+}
+
+func printBeaconBanner(out io.Writer, color bool) {
+ if color {
+ fmt.Fprint(out, beaconPurple)
+ }
+ for _, line := range beaconBanner {
+ fmt.Fprintln(out, line)
+ }
+ if color {
+ fmt.Fprint(out, resetColor)
+ }
+}
+
+func shouldUseColor(out io.Writer) bool {
+ if os.Getenv("NO_COLOR") != "" || os.Getenv("TERM") == "dumb" {
+ return false
+ }
+ file, ok := out.(*os.File)
+ if !ok {
+ return false
+ }
+ stat, err := file.Stat()
+ if err != nil {
+ return false
+ }
+ return stat.Mode()&os.ModeCharDevice != 0
+}
+
var completionCmd = &cobra.Command{
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate shell completion scripts",
diff --git a/cli/beacon/cmd/root_test.go b/cli/beacon/cmd/root_test.go
new file mode 100644
index 00000000..e5a84134
--- /dev/null
+++ b/cli/beacon/cmd/root_test.go
@@ -0,0 +1,40 @@
+package cmd
+
+import (
+ "bytes"
+ "strings"
+ "testing"
+
+ "github.com/spf13/cobra"
+)
+
+func TestPrintRootSplash(t *testing.T) {
+ cmd := &cobra.Command{Use: "beacon"}
+ var out bytes.Buffer
+ cmd.SetOut(&out)
+
+ printRootSplash(cmd)
+
+ got := out.String()
+ for _, want := range []string{
+ "██████╗ ███████╗ █████╗ ██████╗ ██████╗ ███╗ ██╗",
+ "Open-source telemetry layer for AI agents.",
+ "Start with:",
+ "beacon endpoint install",
+ "beacon endpoint status",
+ "beacon endpoint wazuh print-config",
+ "Usage:",
+ } {
+ if !strings.Contains(got, want) {
+ t.Fatalf("root splash missing %q:\n%s", want, got)
+ }
+ }
+ if strings.Contains(got, "\x1b[") {
+ t.Fatalf("root splash written to a buffer should not include ANSI escapes:\n%q", got)
+ }
+ for _, line := range beaconBanner {
+ if len([]rune(line)) > 64 {
+ t.Fatalf("banner line %q is too wide: got %d columns", line, len(line))
+ }
+ }
+}