From 6616a4726cd2ecac8eaa84c00641c624ab3ebcdb Mon Sep 17 00:00:00 2001 From: beads/crew/collins Date: Wed, 21 Jan 2026 17:28:47 -0800 Subject: [PATCH] feat(mail): support positional message arg in reply command Allow `gt mail reply "message"` in addition to `-m` flag. This is a desire-path fix - agents naturally try positional syntax. Co-Authored-By: Claude Opus 4.5 --- internal/cmd/mail.go | 10 ++++++---- internal/cmd/mail_thread.go | 13 ++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/internal/cmd/mail.go b/internal/cmd/mail.go index 623f137c..13c5f22a 100644 --- a/internal/cmd/mail.go +++ b/internal/cmd/mail.go @@ -268,7 +268,7 @@ Examples: } var mailReplyCmd = &cobra.Command{ - Use: "reply ", + Use: "reply [message]", Short: "Reply to a message", Long: `Reply to a specific message. @@ -277,10 +277,13 @@ This is a convenience command that automatically: - Prefixes the subject with "Re: " (if not already present) - Sends to the original sender +The message body can be provided as a positional argument or via -m flag. + Examples: + gt mail reply msg-abc123 "Thanks, working on it now" gt mail reply msg-abc123 -m "Thanks, working on it now" gt mail reply msg-abc123 -s "Custom subject" -m "Reply body"`, - Args: cobra.ExactArgs(1), + Args: cobra.RangeArgs(1, 2), RunE: runMailReply, } @@ -457,8 +460,7 @@ func init() { // Reply flags mailReplyCmd.Flags().StringVarP(&mailReplySubject, "subject", "s", "", "Override reply subject (default: Re: )") - mailReplyCmd.Flags().StringVarP(&mailReplyMessage, "message", "m", "", "Reply message body (required)") - _ = mailReplyCmd.MarkFlagRequired("message") + mailReplyCmd.Flags().StringVarP(&mailReplyMessage, "message", "m", "", "Reply message body") // Search flags mailSearchCmd.Flags().StringVar(&mailSearchFrom, "from", "", "Filter by sender address") diff --git a/internal/cmd/mail_thread.go b/internal/cmd/mail_thread.go index fbae845c..181a8b4f 100644 --- a/internal/cmd/mail_thread.go +++ b/internal/cmd/mail_thread.go @@ -82,6 +82,17 @@ func runMailThread(cmd *cobra.Command, args []string) error { func runMailReply(cmd *cobra.Command, args []string) error { msgID := args[0] + // Get message body from positional arg or flag (positional takes precedence) + messageBody := mailReplyMessage + if len(args) > 1 { + messageBody = args[1] + } + + // Validate message is provided + if messageBody == "" { + return fmt.Errorf("message body required: provide as second argument or use -m flag") + } + // All mail uses town beads (two-level architecture) workDir, err := findMailWorkDir() if err != nil { @@ -118,7 +129,7 @@ func runMailReply(cmd *cobra.Command, args []string) error { From: from, To: original.From, // Reply to sender Subject: subject, - Body: mailReplyMessage, + Body: messageBody, Type: mail.TypeReply, Priority: mail.PriorityNormal, ReplyTo: msgID,