From 9f1b658a063e1cc54f5a22b7a008ae4c947adc9c Mon Sep 17 00:00:00 2001 From: dj-oyu <68707227+dj-oyu@users.noreply.github.com> Date: Sun, 1 Mar 2026 04:13:34 +0900 Subject: [PATCH] fix(cli): restore --stats flag lost in Cobra migration The --stats flag was not carried over when the CLI was migrated from manual os.Args parsing to Cobra commands. Add it back to the gateway command and forward enableStats to NewAgentLoop. Co-Authored-By: Claude Opus 4.6 --- cmd/picoclaw/internal/gateway/command.go | 4 +++- cmd/picoclaw/internal/gateway/helpers.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/picoclaw/internal/gateway/command.go b/cmd/picoclaw/internal/gateway/command.go index b304c2516..35976ff10 100644 --- a/cmd/picoclaw/internal/gateway/command.go +++ b/cmd/picoclaw/internal/gateway/command.go @@ -8,6 +8,7 @@ func NewGatewayCommand() *cobra.Command { var ( debug bool orchestration bool + enableStats bool ) cmd := &cobra.Command{ @@ -16,12 +17,13 @@ func NewGatewayCommand() *cobra.Command { Short: "Start picoclaw gateway", Args: cobra.NoArgs, RunE: func(_ *cobra.Command, _ []string) error { - return gatewayCmd(debug, orchestration) + return gatewayCmd(debug, orchestration, enableStats) }, } cmd.Flags().BoolVarP(&debug, "debug", "d", false, "Enable debug logging") cmd.Flags().BoolVar(&orchestration, "orchestration", false, "Enable subagent orchestration") + cmd.Flags().BoolVar(&enableStats, "stats", false, "Enable stats tracking") return cmd } diff --git a/cmd/picoclaw/internal/gateway/helpers.go b/cmd/picoclaw/internal/gateway/helpers.go index f332cdbf4..8001c1a23 100644 --- a/cmd/picoclaw/internal/gateway/helpers.go +++ b/cmd/picoclaw/internal/gateway/helpers.go @@ -47,7 +47,7 @@ import ( "github.com/sipeed/picoclaw/pkg/tools" ) -func gatewayCmd(debug bool, orchestration bool) error { +func gatewayCmd(debug bool, orchestration bool, enableStats bool) error { if debug { logger.SetLevel(logger.DEBUG) fmt.Println("šŸ” Debug mode enabled") @@ -72,7 +72,7 @@ func gatewayCmd(debug bool, orchestration bool) error { } msgBus := bus.NewMessageBus() - agentLoop := agent.NewAgentLoop(cfg, msgBus, provider) + agentLoop := agent.NewAgentLoop(cfg, msgBus, provider, enableStats) // Print agent startup info fmt.Println("\nšŸ“¦ Agent Status:")