feat: implement CLI support for metadata display (Phase 4)

This commit is contained in:
berniegreen
2025-12-31 12:41:06 -06:00
parent 569f50179d
commit 66d3bf786e
3 changed files with 8 additions and 2 deletions

View File

@@ -104,6 +104,7 @@ type Flags struct {
Notification bool `long:"notification" yaml:"notification" description:"Send desktop notification when command completes"` 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)"` 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)"` 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"` 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, Voice: o.Voice,
Notification: o.Notification || o.NotificationCommand != "", Notification: o.Notification || o.NotificationCommand != "",
NotificationCommand: o.NotificationCommand, NotificationCommand: o.NotificationCommand,
ShowMetadata: o.ShowMetadata,
} }
return return
} }

View File

@@ -85,9 +85,12 @@ func (o *Chatter) Send(request *domain.ChatRequest, opts *domain.ChatOptions) (s
printedStream = true printedStream = true
} }
case domain.StreamTypeUsage: case domain.StreamTypeUsage:
// Placeholder for metadata handling if opts.ShowMetadata && update.Usage != nil {
// Future logic: Store usage in session or context 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: case domain.StreamTypeError:
fmt.Fprintf(os.Stderr, "Error: %s\n", update.Content)
errChan <- errors.New(update.Content) errChan <- errors.New(update.Content)
} }
} }

View File

@@ -51,6 +51,7 @@ type ChatOptions struct {
Voice string Voice string
Notification bool Notification bool
NotificationCommand string NotificationCommand string
ShowMetadata bool
} }
// NormalizeMessages remove empty messages and ensure messages order user-assist-user // NormalizeMessages remove empty messages and ensure messages order user-assist-user