Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
'plandex convo' accepts --plain/-p flag for plain text. also accepts message number or range to display subset of messages
Dane Schneiderfd4a00c18159
diff --git a/app/cli/cmd/convo.go b/app/cli/cmd/convo.goindex a9110a0f..c41ca8da 100644--- a/app/cli/cmd/convo.go+++ b/app/cli/cmd/convo.go@@ -13,15 +13,20 @@ import ("github.com/spf13/cobra")+var plainTextOutput bool+// convoCmd represents the convo commandvar convoCmd = &cobra.Command{- Use: "convo",+ Use: "convo [msg-range]",Short: "Display complete conversation history",+ Long: `Display complete conversation history. Optionally specify a message number or range of messages (e.g. '1' or '5' or '1-5' or '5-')`,Run: convo,}func init() {RootCmd.AddCommand(convoCmd)++ convoCmd.Flags().BoolVarP(&plainTextOutput, "plain", "p", false, "Output conversation in plain text with no ANSI codes")}const stoppedEarlyMsg = "You stopped the reply early"@@ -43,9 +48,46 @@ func convo(cmd *cobra.Command, args []string) {return}+ var msgRange string+ var msgRangeStart, msgRangeEnd int+ if len(args) > 0 {+ msgRange = args[0]+ }+ if msgRange != "" {+ // validate either a number or a range of numbers+ if strings.Contains(msgRange, "-") {+ _, err := fmt.Sscanf(msgRange, "%d-%d", &msgRangeStart, &msgRangeEnd)+ if err != nil {+ _, err := fmt.Sscanf(msgRange, "%d-", &msgRangeStart)++ if err != nil {+ term.OutputErrorAndExit("Invalid message range: %s", msgRange)+ }++ msgRangeEnd = len(conversation)+ }+ } else {+ _, err := fmt.Sscanf(msgRange, "%d", &msgRangeStart)+ if err != nil {+ term.OutputErrorAndExit("Invalid message number: %s", msgRange)+ }+ msgRangeEnd = msgRangeStart+ }+ }+var convo stringvar totalTokens int+ var didCut boolfor i, msg := range conversation {+ if msgRangeStart > 0 && msg.Num < msgRangeStart {+ didCut = true+ continue+ }+ if msgRangeEnd > 0 && msg.Num > msgRangeEnd {+ didCut = true+ break+ }+var author stringif msg.Role == "assistant" {author = "π€ Plandex"@@ -71,27 +113,45 @@ func convo(cmd *cobra.Command, args []string) {header := fmt.Sprintf("#### %d | %s | %s | %d πͺ ", i+1,author, formattedTs, msg.Tokens)- // convMarkdown = append(convMarkdown, header, msg.Message, "")-- md, err := term.GetMarkdown(header + "\n" + msg.Message + "\n\n")- if err != nil {- term.OutputErrorAndExit("Error creating markdown representation: %v", err)+ if plainTextOutput {+ convo += header + "\n" + msg.Message + "\n\n"+ } else {+ md, err := term.GetMarkdown(header + "\n" + msg.Message + "\n\n")+ if err != nil {+ term.OutputErrorAndExit("Error creating markdown representation: %v", err)+ }+ convo += md}- convo += md- if msg.Stopped {- convo += fmt.Sprintf(" π %s\n\n", color.New(color.Bold).Sprint(stoppedEarlyMsg))+ if !didCut && msg.Stopped {+ if plainTextOutput {+ convo += fmt.Sprintf(" π %s\n\n", stoppedEarlyMsg)+ } else {+ convo += fmt.Sprintf(" π %s\n\n", color.New(color.Bold).Sprint(stoppedEarlyMsg))+ }}totalTokens += msg.Tokens}- convo = strings.ReplaceAll(convo, stoppedEarlyMsg, color.New(term.ColorHiRed).Sprint(stoppedEarlyMsg))+ if !plainTextOutput {+ convo = strings.ReplaceAll(convo, stoppedEarlyMsg, color.New(term.ColorHiRed).Sprint(stoppedEarlyMsg))+ }output :=- fmt.Sprintf("\n%s", convo) +- term.GetDivisionLine() ++ fmt.Sprintf("\n%s", convo)++ if !plainTextOutput && !didCut {+ output += term.GetDivisionLine() +color.New(color.Bold, term.ColorHiCyan).Sprint(" Conversation size β") + fmt.Sprintf(" %d πͺ", totalTokens) + "\n\n"+ }- term.PageOutput(output)+ if plainTextOutput {+ fmt.Println(output)+ } else {+ term.PageOutput(output)++ fmt.Println()+ term.PrintCmds("", "convo 1", "convo 2-5", "convo --plain", "log")+ }}diff --git a/app/cli/cmd/log.go b/app/cli/cmd/log.goindex 7f1a2f1e..c86ce036 100644--- a/app/cli/cmd/log.go+++ b/app/cli/cmd/log.go@@ -52,6 +52,9 @@ func runLog(cmd *cobra.Command, args []string) {term.PageOutput(withLocalTimestamps)+ fmt.Println()+ term.PrintCmds("", "rewind", "continue", "convo", "convo 1", "convo 2-5")+}func convertTimestampsToLocal(input string) (string, error) {diff --git a/app/cli/term/help.go b/app/cli/term/help.goindex 795621a8..e3a932e7 100644--- a/app/cli/term/help.go+++ b/app/cli/term/help.go@@ -36,6 +36,9 @@ var CmdDesc = map[string][2]string{"update": {"u", "update outdated context"},"log": {"", "show log of plan updates"},"convo": {"", "show plan conversation"},+ "convo 1": {"", "show a specific message in the conversation"},+ "convo 2-5": {"", "show a range of messages in the conversation"},+ "convo --plain": {"", "show conversation in plain text"},"branches": {"br", "list plan branches"},"checkout": {"co", "checkout or create a branch"},"build": {"b", "build any pending changes"},@@ -143,7 +146,7 @@ func PrintCustomHelp() {fmt.Fprintln(builder)color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " History ")- printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "convo", "log", "rewind")+ printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "log", "rewind", "convo", "convo 1", "convo 2-5", "convo --plain")fmt.Fprintln(builder)color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Control ")diff --git a/releases/cli/versions/1.0.2.md b/releases/cli/versions/1.0.2.mdindex 24bb60f1..e61dc903 100644--- a/releases/cli/versions/1.0.2.md+++ b/releases/cli/versions/1.0.2.md@@ -1 +1,3 @@-- Give notes added to context with `plandex load -n 'some note'` a name in the `context ls` list\ No newline at end of file+- Give notes added to context with `plandex load -n 'some note'` an auto-generated name in the `context ls` list.+- Added a `--plain / -p` flag to `plandex convo` that outputs the conversation in plain text with no ANSI codes.+- `plandex convo` now accepts a message number or range of messages to display (e.g. `plandex convo 1`, `plandex convo 1-5`, `plandex convo 2-`). Use `plandex convo 1` to show the initial prompt.\ No newline at end of file