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
prettification
Dane Schneiderbbdd9aec9465
diff --git a/cli/cmd/new.go b/cli/cmd/new.goindex a8fa6a50..9d47820d 100644--- a/cli/cmd/new.go+++ b/cli/cmd/new.go@@ -163,6 +163,6 @@ func new(cmd *cobra.Command, args []string) {}fmt.Println()- lib.PrintCmds("load", "tell")+ lib.PrintCmds("", "load", "tell")}diff --git a/cli/lib/proposal.go b/cli/lib/proposal.goindex 1b93152a..45eaedbe 100644--- a/cli/lib/proposal.go+++ b/cli/lib/proposal.go@@ -121,6 +121,9 @@ func Propose(prompt string) error {printReply()backToMain()fmt.Print(termState)+ s = spinner.New(spinner.CharSets[33], 100*time.Millisecond)+ s.Prefix = " "+ s.Start()var totalTokens int// _, tokensAddedByFile, totalTokens = replyTokenCounter.FinishAndRead()_, _, totalTokens = replyTokenCounter.FinishAndRead()@@ -135,6 +138,17 @@ func Propose(prompt string) error {fmt.Printf("failed to append conversation: %s\n", err)}endedReply = true++ }++ showUpdatedPlanCmds := func() {+ fmt.Println()+ for _, cmd := range []string{"diffs", "preview", "apply"} {+ clearCurrentLine()+ PrintCmds(" ", cmd)+ }+ clearCurrentLine()+ PrintCustomCmd(" ", "tell", "t", "update the plan, give more info, or chat")}contextByFilePath := make(map[string]shared.ModelContextPart)@@ -224,9 +238,13 @@ func Propose(prompt string) error {if !endedReply {endReply()}+ s.Stop()streamFinished = trueif filesFinished {+ if desc.MadePlan && len(desc.Files) > 0 {+ showUpdatedPlanCmds()+ }close(done)}return@@ -244,9 +262,10 @@ func Propose(prompt string) error {}if desc.MadePlan && (len(desc.Files) > 0) {- fmt.Println(" " + color.New(color.BgHiBlack, color.FgHiWhite, color.Bold).Sprint(" π ") + color.New(color.BgHiBlack, color.FgHiWhite).Sprint("Building plan: "))+ s.Stop()+ fmt.Println(" " + color.New(color.BgGreen, color.FgHiWhite, color.Bold).Sprint(" π ") + color.New(color.BgGreen, color.FgHiWhite).Sprint("Building plan "))for _, filePath := range desc.Files {- fmt.Printf(" - %s\n", filePath)+ fmt.Printf(" π %s\n", filePath)}fmt.Println()fmt.Printf(displayHotkeys() + "\n")@@ -285,7 +304,7 @@ func Propose(prompt string) error {for _, filePath := range files {numStreamedTokens := numStreamedTokensByPath[filePath]- fmtStr := " - %s | %d πͺ"+ fmtStr := " π %s | %d πͺ"fmtArgs := []interface{}{filePath, numStreamedTokens}_, finished := finishedByPath[filePath]@@ -305,6 +324,7 @@ func Propose(prompt string) error {filesFinished = trueif streamFinished {+ showUpdatedPlanCmds()close(done)}}diff --git a/cli/lib/term.go b/cli/lib/term.goindex 9bf3a14a..db4ec081 100644--- a/cli/lib/term.go+++ b/cli/lib/term.go@@ -10,11 +10,17 @@ import ()var cmdDesc = map[string][2]string{- "load": {"l", "load files/urls or pipe data into context"},- "tell": {"t", "describe a task, ask a question, or just chat"},+ "new": {"n", "start a new plan"},+ "load": {"l", "load files/urls or pipe data into context"},+ "tell": {"t", "describe a task, ask a question, or chat"},+ "diffs": {"d", "show diffs between plan and project files"},+ "preview": {"p", "preview the plan in a branch"},+ "apply": {"a", "apply the plan to your project files"},+ "next": {"n", "continue to next step of the plan"},+ "status": {"s", "show status of the plan"},}-func PrintCmds(cmds ...string) {+func PrintCmds(prefix string, cmds ...string) {for _, cmd := range cmds {config, ok := cmdDesc[cmd]if !ok {@@ -24,11 +30,18 @@ func PrintCmds(cmds ...string) {alias := config[0]desc := config[1]cmd = strings.Replace(cmd, alias, fmt.Sprintf("(%s)", alias), 1)+ styled := color.New(color.Bold, color.FgHiWhite, color.BgCyan).Sprintf(" plandex %s ", cmd)- fmt.Printf("%s π %s\n", color.New(color.Bold, color.BgCyan, color.FgHiWhite).Sprintf(" plandex %s ", cmd), desc)+ fmt.Printf("%s%s π %s\n", prefix, styled, desc)}}+func PrintCustomCmd(prefix, cmd, alias, desc string) {+ cmd = strings.Replace(cmd, alias, fmt.Sprintf("(%s)", alias), 1)+ styled := color.New(color.Bold, color.FgHiWhite, color.BgCyan).Sprintf(" plandex %s ", cmd)+ fmt.Printf("%s%s π %s\n", prefix, styled, desc)+}+func alternateScreen() {// Switch to alternate screen and hide the cursorfmt.Print("\x1b[?1049h\x1b[?25l")