From 66d3bf786ed2ffd9a55cd113dce1f70d659526b8 Mon Sep 17 00:00:00 2001 From: berniegreen Date: Wed, 31 Dec 2025 12:41:06 -0600 Subject: [PATCH] feat: implement CLI support for metadata display (Phase 4) --- internal/cli/flags.go | 2 ++ internal/core/chatter.go | 7 +++++-- internal/domain/domain.go | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/cli/flags.go b/internal/cli/flags.go index e018bc47..274c856c 100644 --- a/internal/cli/flags.go +++ b/internal/cli/flags.go @@ -104,6 +104,7 @@ type Flags struct { Notification bool `long:"notification" yaml:"notification" description:"Send desktop notification when command completes"` NotificationCommand string `long:"notification-command" yaml:"notificationCommand" description:"Custom command to run for notifications (overrides built-in notifications)"` Thinking domain.ThinkingLevel `long:"thinking" yaml:"thinking" description:"Set reasoning/thinking level (e.g., off, low, medium, high, or numeric tokens for Anthropic or Google Gemini)"` + ShowMetadata bool `long:"show-metadata" description:"Print metadata to stderr"` Debug int `long:"debug" description:"Set debug level (0=off, 1=basic, 2=detailed, 3=trace)" default:"0"` } @@ -459,6 +460,7 @@ func (o *Flags) BuildChatOptions() (ret *domain.ChatOptions, err error) { Voice: o.Voice, Notification: o.Notification || o.NotificationCommand != "", NotificationCommand: o.NotificationCommand, + ShowMetadata: o.ShowMetadata, } return } diff --git a/internal/core/chatter.go b/internal/core/chatter.go index 37178c75..61aea454 100644 --- a/internal/core/chatter.go +++ b/internal/core/chatter.go @@ -85,9 +85,12 @@ func (o *Chatter) Send(request *domain.ChatRequest, opts *domain.ChatOptions) (s printedStream = true } case domain.StreamTypeUsage: - // Placeholder for metadata handling - // Future logic: Store usage in session or context + if opts.ShowMetadata && update.Usage != nil { + fmt.Fprintf(os.Stderr, "\n[Metadata] Input: %d | Output: %d | Total: %d\n", + update.Usage.InputTokens, update.Usage.OutputTokens, update.Usage.TotalTokens) + } case domain.StreamTypeError: + fmt.Fprintf(os.Stderr, "Error: %s\n", update.Content) errChan <- errors.New(update.Content) } } diff --git a/internal/domain/domain.go b/internal/domain/domain.go index bd6fbbdf..3c1b8ed0 100644 --- a/internal/domain/domain.go +++ b/internal/domain/domain.go @@ -51,6 +51,7 @@ type ChatOptions struct { Voice string Notification bool NotificationCommand string + ShowMetadata bool } // NormalizeMessages remove empty messages and ensure messages order user-assist-user