Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

repl is working

Dane Schneider541886aa64b1
diff --git a/app/cli/cmd/current.go b/app/cli/cmd/current.go
index 5d84745f..0e3067bc 100644
--- a/app/cli/cmd/current.go
+++ b/app/cli/cmd/current.go
@@ -2,16 +2,11 @@ package cmd
import (
"fmt"
- "os"
"plandex/api"
"plandex/auth"
- "plandex/format"
"plandex/lib"
"plandex/term"
- "strconv"
- "github.com/fatih/color"
- "github.com/olekukonko/tablewriter"
"github.com/plandex/plandex/shared"
"github.com/spf13/cobra"
)
@@ -54,30 +49,9 @@ func current(cmd *cobra.Command, args []string) {
term.OutputErrorAndExit("Error getting current branches: %v", err)
}
- table := tablewriter.NewWriter(os.Stdout)
- table.SetAutoWrapText(false)
- table.SetHeader([]string{"Current Plan", "Updated", "Created" /*"Branches",*/, "Branch", "Context", "Convo"})
+ table := lib.GetCurrentPlanTable(plan, currentBranchesByPlanId, nil)
+ fmt.Println(table)
- name := color.New(color.Bold, term.ColorHiGreen).Sprint(plan.Name)
- branch := currentBranchesByPlanId[lib.CurrentPlanId]
-
- row := []string{
- name,
- format.Time(plan.UpdatedAt),
- format.Time(plan.CreatedAt),
- // strconv.Itoa(plan.ActiveBranches),
- lib.CurrentBranch,
- strconv.Itoa(branch.ContextTokens) + " πŸͺ™",
- strconv.Itoa(branch.ConvoTokens) + " πŸͺ™",
- }
-
- style := []tablewriter.Colors{
- {tablewriter.FgGreenColor, tablewriter.Bold},
- }
-
- table.Rich(row, style)
-
- table.Render()
fmt.Println()
term.PrintCmds("", "tell", "ls", "plans")
diff --git a/app/cli/cmd/new.go b/app/cli/cmd/new.go
index a1aeee56..a92a6a17 100644
--- a/app/cli/cmd/new.go
+++ b/app/cli/cmd/new.go
@@ -110,12 +110,17 @@ func new(cmd *cobra.Command, args []string) {
fmt.Println()
}
- cmds := []string{"tell", "chat", "plans", "current", "config"}
+ var cmds []string
+ if term.IsRepl {
+ return
+ } else {
+ cmds = []string{"tell", "chat", "config"}
+ }
if !config.AutoLoadContext {
cmds = append([]string{"load"}, cmds...)
}
+ fmt.Println()
term.PrintCmds("", cmds...)
-
}
diff --git a/app/cli/cmd/repl.go b/app/cli/cmd/repl.go
new file mode 100644
index 00000000..d1f182cf
--- /dev/null
+++ b/app/cli/cmd/repl.go
@@ -0,0 +1,506 @@
+package cmd
+
+import (
+ "fmt"
+ "os"
+ "os/exec"
+ "plandex/api"
+ "plandex/auth"
+ "plandex/fs"
+ "plandex/lib"
+ "plandex/term"
+ "plandex/types"
+ "plandex/version"
+ "sort"
+ "strings"
+
+ "github.com/fatih/color"
+ "github.com/olekukonko/tablewriter"
+ "github.com/plandex/plandex/shared"
+ "github.com/spf13/cobra"
+
+ "github.com/plandex-ai/go-prompt"
+ pstrings "github.com/plandex-ai/go-prompt/strings"
+)
+
+var cliSuggestions []prompt.Suggest
+var projectPaths *types.ProjectPaths
+
+type replMode string
+
+const (
+ replModeTell replMode = "tell"
+ replModeChat replMode = "chat"
+)
+
+type ReplState struct {
+ mode replMode
+ isMulti bool
+}
+
+var replCmd = &cobra.Command{
+ Use: "repl",
+ Short: "Start interactive Plandex REPL",
+ Run: runRepl,
+}
+
+var replState ReplState = ReplState{
+ mode: replModeTell,
+ isMulti: false,
+}
+
+func init() {
+ RootCmd.AddCommand(replCmd)
+
+ replCmd.Flags().BoolP("chat", "c", false, "Start in chat mode")
+ replCmd.Flags().BoolP("tell", "t", false, "Start in tell mode")
+
+ for _, config := range term.CliCommands {
+ if config.Repl {
+ cliSuggestions = append(cliSuggestions, prompt.Suggest{Text: "\\" + config.Cmd, Description: config.Desc})
+ }
+ }
+}
+
+func runRepl(cmd *cobra.Command, args []string) {
+
+ term.SetIsRepl(true)
+
+ auth.MustResolveAuthWithOrg()
+ lib.MustResolveOrCreateProject()
+
+ if lib.CurrentPlanId == "" {
+ newCmd.Run(newCmd, []string{})
+ }
+
+ var err error
+ projectPaths, err = fs.GetProjectPaths(fs.Cwd)
+ if err != nil {
+ color.New(color.FgRed).Printf("Error getting project paths: %v\n", err)
+ }
+
+ // print REPL welcome message and basic info
+ term.StartSpinner("")
+ errCh := make(chan error, 2)
+ var plan *shared.Plan
+ var config *shared.PlanConfig
+
+ go func() {
+ var apiErr *shared.ApiError
+ plan, apiErr = api.Client.GetPlan(lib.CurrentPlanId)
+ if apiErr != nil {
+ errCh <- fmt.Errorf("Error getting plan: %v", apiErr.Msg)
+ }
+ errCh <- nil
+ }()
+
+ go func() {
+ var apiErr *shared.ApiError
+ config, apiErr = api.Client.GetPlanConfig(lib.CurrentPlanId)
+ if apiErr != nil {
+ errCh <- fmt.Errorf("Error getting plan config: %v", apiErr.Msg)
+ }
+ errCh <- nil
+ }()
+
+ for i := 0; i < 2; i++ {
+ err := <-errCh
+ if err != nil {
+ term.OutputErrorAndExit("%v", err)
+ }
+ }
+
+ term.StopSpinner()
+
+ fmt.Println()
+ color.New(color.FgHiWhite, color.BgBlue, color.Bold).Println(" πŸ‘‹ Welcome to the Plandex REPL ")
+ fmt.Println("v" + version.Version)
+ fmt.Println()
+
+ table := tablewriter.NewWriter(os.Stdout)
+ table.SetAutoWrapText(false)
+
+ table.SetHeader([]string{"Current Plan", "Branch", "REPL Mode", "Auto Mode", "Context"})
+
+ var replModeIcon string
+ if replState.mode == replModeTell {
+ replModeIcon = "🦾"
+ } else if replState.mode == replModeChat {
+ replModeIcon = "πŸ’¬"
+ }
+
+ var contextMode string
+ if config.AutoLoadContext {
+ contextMode = "Auto-load"
+ } else {
+ contextMode = "Manual"
+ }
+
+ table.Append([]string{
+ plan.Name,
+ lib.CurrentBranch,
+ strings.Title(string(replState.mode)) + " " + replModeIcon,
+ shared.AutoModeLabels[config.AutoMode],
+ contextMode,
+ })
+
+ table.Render()
+
+ fmt.Println()
+
+ color.New(color.FgHiWhite).Printf("%s for commands\n", color.New(color.FgCyan, color.Bold).Sprint("\\"))
+ color.New(color.FgHiWhite).Printf("%s for loading files into context\n", color.New(color.FgCyan, color.Bold).Sprint("@"))
+
+ if replState.isMulti {
+ color.New(color.FgHiWhite).Printf("%s to exit multi-line mode\n", color.New(color.FgCyan, color.Bold).Sprint("\\multi"))
+ } else {
+ color.New(color.FgHiWhite).Printf("%s for multi-line editing mode\n", color.New(color.FgCyan, color.Bold).Sprint("\\multi"))
+ }
+
+ if replState.mode == replModeTell {
+ color.New(color.FgHiWhite).Printf("%s for chat mode β†’ chat without writing code\n", color.New(color.FgCyan, color.Bold).Sprint("\\chat"))
+ } else {
+ color.New(color.FgHiWhite).Printf("%s for tell mode β†’ implement tasks\n", color.New(color.FgCyan, color.Bold).Sprint("\\tell"))
+ }
+
+ fmt.Println()
+
+ if replState.mode == replModeTell {
+ color.New(color.FgHiWhite, color.BgBlue, color.Bold).Println(" 🦾 Describe a coding task ")
+ } else {
+ color.New(color.FgHiWhite, color.BgBlue, color.Bold).Println(" πŸ’¬ Ask a question or chat ")
+ }
+
+ fmt.Println()
+
+ p := prompt.New(
+ executor,
+ prompt.WithPrefix("πŸ‘‰ "),
+ prompt.WithTitle("Plandex "+version.Version),
+ prompt.WithSelectedSuggestionBGColor(prompt.LightGray),
+ prompt.WithSuggestionBGColor(prompt.DarkGray),
+ prompt.WithCompletionOnDown(),
+ prompt.WithCompleter(completer),
+ prompt.WithExecuteOnEnterCallback(executeOnEnter),
+ )
+ p.Run()
+}
+
+func getSuggestions() []prompt.Suggest {
+ suggestions := []prompt.Suggest{}
+
+ if replState.isMulti {
+ suggestions = append(suggestions, []prompt.Suggest{
+ {Text: "\\send", Description: "Send the current prompt"},
+ {Text: "\\multi", Description: "Turn multi-line mode off"},
+ {Text: "\\quit", Description: "Exit the REPL"},
+ }...)
+
+ } else {
+ if replState.mode == replModeTell {
+ suggestions = append(suggestions, []prompt.Suggest{
+ {Text: "\\chat", Description: "Switch to 'chat' mode to have a conversation without making changes"},
+ }...)
+ } else if replState.mode == replModeChat {
+ suggestions = append(suggestions, []prompt.Suggest{
+ {Text: "\\tell", Description: "Switch to 'tell' mode for implementation"},
+ }...)
+ }
+
+ suggestions = append(suggestions, []prompt.Suggest{
+ {Text: "\\multi", Description: "Turn multi-line mode on"},
+ {Text: "\\quit", Description: "Exit the REPL"},
+ }...)
+
+ suggestions = append(suggestions, cliSuggestions...)
+ }
+
+ for path := range projectPaths.ActivePaths {
+ if path == "." {
+ continue
+ }
+ suggestions = append(suggestions, prompt.Suggest{Text: "@" + path})
+ }
+
+ return suggestions
+}
+
+func executeOnEnter(p *prompt.Prompt, indentSize int) (int, bool) {
+ if replState.isMulti {
+ input := p.Buffer().Text()
+ input = strings.TrimSpace(input)
+ lines := strings.Split(input, "\n")
+ lastLine := lines[len(lines)-1]
+ lastLine = strings.TrimSpace(lastLine)
+
+ if strings.HasPrefix(lastLine, "\\s") || // \send
+ strings.HasPrefix(lastLine, "\\q") || // \quit
+ strings.HasPrefix(lastLine, "\\m") || // \multi
+ strings.HasPrefix(lastLine, "@") { // @file
+ return 0, true
+ }
+
+ return 0, false
+ }
+
+ return 0, true
+}
+
+func executor(in string) {
+ // fmt.Println(in)
+
+ // this ensures it works with multi-line input
+ in = strings.TrimSpace(in)
+ lines := strings.Split(in, "\n")
+ lastLine := lines[len(lines)-1]
+ lastLine = strings.TrimSpace(lastLine)
+
+ isFile := strings.HasPrefix(lastLine, "@")
+ if isFile {
+ paths := strings.Split(lastLine, "@")
+ filteredPaths := []string{}
+ for _, path := range paths {
+ p := strings.TrimSpace(path)
+ if p == "" {
+ continue
+ }
+
+ if !projectPaths.ActivePaths[p] && len(latestFilteredSuggestions) > 0 {
+ p = strings.Replace(latestFilteredSuggestions[0].Text, "@", "", 1)
+ }
+
+ filteredPaths = append(filteredPaths, p)
+ }
+
+ args := []string{"load"}
+ args = append(args, filteredPaths...)
+ args = append(args, "-r")
+ execPlandexCommand(args)
+ return
+ }
+
+ isSend := false
+ isCommand := false
+
+ // Remove the leading backslash
+ cmd := strings.TrimPrefix(lastLine, "\\")
+
+ if cmd == "quit" || strings.HasPrefix("quit", cmd) {
+ os.Exit(0)
+ }
+
+ if cmd == "multi" || strings.HasPrefix("multi", cmd) {
+ fmt.Println()
+ if replState.isMulti {
+ replState.isMulti = false
+ color.New(color.FgGreen, color.Bold).Println("🚫 Multi-line mode is disabled")
+ } else {
+ replState.isMulti = true
+ color.New(color.FgGreen, color.Bold).Println("βœ… Multi-line mode is enabled")
+ fmt.Printf("%s for line breaks\n%s to send prompt\n", color.New(color.FgCyan, color.Bold).Sprint("enter"), color.New(color.FgCyan, color.Bold).Sprint("\\send"))
+ fmt.Printf("%s to exit multi-line mode\n", color.New(color.FgCyan, color.Bold).Sprint("\\multi"))
+ }
+ fmt.Println()
+ return
+ }
+
+ if cmd == "send" || strings.HasPrefix("send", cmd) {
+ isSend = true
+ }
+
+ if cmd == "tell" || strings.HasPrefix("tell", cmd) {
+ if replState.isMulti {
+ return
+ }
+ replState.mode = replModeTell
+ fmt.Println()
+ color.New(color.FgGreen, color.Bold).Println("🦾 Tell mode is enabled")
+ fmt.Println()
+ return
+ }
+
+ if cmd == "chat" || strings.HasPrefix("chat", cmd) {
+ if replState.isMulti {
+ return
+ }
+ replState.mode = replModeChat
+ fmt.Println()
+ color.New(color.FgGreen, color.Bold).Println("πŸ’¬ Chat mode is enabled")
+ fmt.Println()
+ return
+ }
+
+ if !isSend {
+ if strings.HasPrefix(lastLine, "\\") && lastLine != "\\" {
+ isCommand = true
+ }
+ }
+
+ if isCommand {
+ // Split the command and arguments
+ args := strings.Fields(cmd)
+ if len(args) > 0 {
+ cmd := args[0]
+ rest := args[1:]
+ // Find the command in CliCommands
+ for _, config := range term.CliCommands {
+ if cmd == config.Cmd || (config.Alias != "" && cmd == config.Alias) || strings.HasPrefix(config.Cmd, cmd) {
+ if !config.Repl {
+ continue
+ }
+ fmt.Println()
+
+ cmd = config.Cmd
+
+ // Execute the command with arguments
+ execArgs := []string{cmd}
+ execArgs = append(execArgs, rest...)
+ err := execPlandexCommand(execArgs)
+ if err != nil {
+ color.New(color.FgRed).Printf("Error executing command: %v\n", err)
+ }
+
+ fmt.Println()
+ return
+ }
+ }
+ color.New(color.FgRed).Printf("πŸ€·β€β™‚οΈ Unknown command: %s\n", args[0])
+ return
+ }
+ }
+
+ // Handle non-command input based on mode
+ if replState.mode == replModeTell {
+ // Process the tell command
+ args := []string{"tell"}
+ if len(lines) > 0 {
+ input := lines
+ if isSend {
+ input = lines[:len(lines)-1] // Exclude last line with \send
+ }
+ args = append(args, strings.Join(input, "\n"))
+ }
+ err := execPlandexCommand(args)
+ if err != nil {
+ color.New(color.FgRed).Printf("Error executing tell: %v\n", err)
+ }
+ } else if replState.mode == replModeChat {
+ // Process the chat command
+ args := []string{"chat"}
+ if len(lines) > 0 {
+ input := lines
+ if isSend {
+ input = lines[:len(lines)-1] // Exclude last line with \send
+ }
+ args = append(args, strings.Join(input, "\n"))
+ }
+ err := execPlandexCommand(args)
+ if err != nil {
+ color.New(color.FgRed).Printf("Error executing chat: %v\n", err)
+ }
+ }
+
+ fmt.Println()
+}
+
+var latestFilteredSuggestions []prompt.Suggest
+
+func completer(in prompt.Document) ([]prompt.Suggest, pstrings.RuneNumber, pstrings.RuneNumber) {
+ endIndex := in.CurrentRuneIndex()
+ w := in.GetWordBeforeCursor()
+
+ lines := strings.Split(in.Text, "\n")
+ lastLine := lines[len(lines)-1]
+
+ if strings.TrimSpace(lastLine) == "" && len(lines) > 1 {
+ lastLine = lines[len(lines)-2]
+ }
+
+ // Add special handling for multi-line mode
+ if replState.isMulti {
+
+ // If w is empty but lastLine has content and starts with a prefix we care about
+ if strings.TrimSpace(w) == "" &&
+ (strings.HasPrefix(strings.TrimSpace(lastLine), "\\") ||
+ strings.HasPrefix(strings.TrimSpace(lastLine), "@")) {
+ w = strings.TrimSpace(lastLine)
+ }
+ }
+
+ if w == "" || !(strings.HasPrefix(w, "\\") || strings.HasPrefix(w, "@")) {
+ latestFilteredSuggestions = []prompt.Suggest{}
+ return []prompt.Suggest{}, 0, 0
+ }
+
+ if !strings.HasSuffix(strings.TrimSpace(in.Text), strings.TrimSpace(w)) || (lastLine != w && strings.HasPrefix(w, "\\")) {
+ latestFilteredSuggestions = []prompt.Suggest{}
+ return []prompt.Suggest{}, 0, 0
+ }
+
+ startIndex := endIndex - pstrings.RuneCountInString(w)
+
+ fuzzySuggestions := prompt.FilterFuzzy(getSuggestions(), w, true)
+
+ // Sort suggestions to put prefix matches first
+
+ prefixMatches := prompt.FilterHasPrefix(getSuggestions(), w, true)
+
+ if strings.TrimSpace(w) != "\\" {
+ sort.Slice(prefixMatches, func(i, j int) bool {
+ iTxt := prefixMatches[i].Text
+ jTxt := prefixMatches[j].Text
+ if iTxt == "\\chat" || iTxt == "\\tell" || iTxt == "\\multi" || iTxt == "\\quit" || iTxt == "\\send" {
+ return true
+ }
+ if jTxt == "\\chat" || jTxt == "\\tell" || jTxt == "\\multi" || jTxt == "\\quit" || jTxt == "\\send" {
+ return false
+ }
+ return prefixMatches[i].Text < prefixMatches[j].Text
+ })
+ }
+ if len(prefixMatches) > 0 {
+ // Remove prefix matches from fuzzy results to avoid duplicates
+ prefixMatchSet := make(map[string]bool)
+ for _, s := range prefixMatches {
+ prefixMatchSet[s.Text] = true
+ }
+
+ nonPrefixFuzzy := make([]prompt.Suggest, 0)
+ for _, s := range fuzzySuggestions {
+ if !prefixMatchSet[s.Text] {
+ nonPrefixFuzzy = append(nonPrefixFuzzy, s)
+ }
+ }
+
+ fuzzySuggestions = append(prefixMatches, nonPrefixFuzzy...)
+ }
+
+ latestFilteredSuggestions = fuzzySuggestions
+
+ return fuzzySuggestions, startIndex, endIndex
+}
+
+// execPlandexCommand spawns the same binary, wiring std streams directly so you
+// don't have to capture output. Any os.Exit calls in the child won't kill your REPL.
+func execPlandexCommand(args []string) error {
+ // Subprocess runs the same binary (os.Args[0]) with your desired args.
+ cmd := exec.Command(os.Args[0], args...)
+ cmd.Env = append(os.Environ(), "PLANDEX_REPL=1")
+
+ // Connect the child's standard streams to the parent.
+ cmd.Stdin = os.Stdin
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+
+ // Run it. If the child calls os.Exit(1), only that child is killed,
+ // and Run() will return an error here. Your REPL stays alive.
+ err := cmd.Run()
+ if err != nil {
+ if _, ok := err.(*exec.ExitError); ok {
+ return nil
+ }
+ // If it's *not* an exit error, it might be a startup error (like file not found).
+ return err
+ }
+ return nil
+}
diff --git a/app/cli/cmd/root.go b/app/cli/cmd/root.go
index 1a9eb4d3..46046eb6 100644
--- a/app/cli/cmd/root.go
+++ b/app/cli/cmd/root.go
@@ -25,6 +25,13 @@ var RootCmd = &cobra.Command{
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
+ // if no arguments were passed, start the repl
+ if len(os.Args) == 1 {
+ // call repl command
+ replCmd.Run(replCmd, []string{})
+ return
+ }
+
if err := RootCmd.Execute(); err != nil {
// term.OutputErrorAndExit("Error executing root command: %v", err)
// log.Fatalf("Error executing root command: %v", err)
diff --git a/app/cli/cmd/tell.go b/app/cli/cmd/tell.go
index 725d778a..f451a86e 100644
--- a/app/cli/cmd/tell.go
+++ b/app/cli/cmd/tell.go
@@ -6,18 +6,11 @@ import (
"io"
"os"
"os/exec"
- "plandex/api"
"plandex/auth"
"plandex/lib"
"plandex/plan_exec"
"plandex/term"
"strings"
- "time"
-
- "context"
-
- "os/signal"
- "syscall"
"github.com/plandex/plandex/shared"
"github.com/spf13/cobra"
@@ -197,50 +190,50 @@ func getEditorPrompt() string {
}
-func maybeShowDiffs() {
- diffs, err := api.Client.GetPlanDiffs(lib.CurrentPlanId, lib.CurrentBranch, plainTextOutput || showDiffUi)
- if err != nil {
- term.OutputErrorAndExit("Error getting plan diffs: %v", err)
- return
- }
-
- if len(diffs) > 0 {
- cmd := exec.Command(os.Args[0], "diffs", "--ui")
-
- // Create a context that's cancelled when the program exits
- ctx, cancel := context.WithCancel(context.Background())
-
- // Ensure cleanup on program exit
- go func() {
- // Wait for program exit signal
- c := make(chan os.Signal, 1)
- signal.Notify(c, os.Interrupt, syscall.SIGTERM)
- <-c
-
- // Cancel context and kill the process
- cancel()
- if cmd.Process != nil {
- cmd.Process.Kill()
- }
- }()
-
- go func() {
- if err := cmd.Start(); err != nil {
- fmt.Fprintf(os.Stderr, "Error starting diffs command: %v\n", err)
- return
- }
-
- // Wait in a separate goroutine
- go cmd.Wait()
-
- // Wait for either context cancellation or process completion
- <-ctx.Done()
- if cmd.Process != nil {
- cmd.Process.Kill()
- }
- }()
-
- // Give the UI a moment to start
- time.Sleep(100 * time.Millisecond)
- }
-}
+// func maybeShowDiffs() {
+// diffs, err := api.Client.GetPlanDiffs(lib.CurrentPlanId, lib.CurrentBranch, plainTextOutput || showDiffUi)
+// if err != nil {
+// term.OutputErrorAndExit("Error getting plan diffs: %v", err)
+// return
+// }
+
+// if len(diffs) > 0 {
+// cmd := exec.Command(os.Args[0], "diffs", "--ui")
+
+// // Create a context that's cancelled when the program exits
+// ctx, cancel := context.WithCancel(context.Background())
+
+// // Ensure cleanup on program exit
+// go func() {
+// // Wait for program exit signal
+// c := make(chan os.Signal, 1)
+// signal.Notify(c, os.Interrupt, syscall.SIGTERM)
+// <-c
+
+// // Cancel context and kill the process
+// cancel()
+// if cmd.Process != nil {
+// cmd.Process.Kill()
+// }
+// }()
+
+// go func() {
+// if err := cmd.Start(); err != nil {
+// fmt.Fprintf(os.Stderr, "Error starting diffs command: %v\n", err)
+// return
+// }
+
+// // Wait in a separate goroutine
+// go cmd.Wait()
+
+// // Wait for either context cancellation or process completion
+// <-ctx.Done()
+// if cmd.Process != nil {
+// cmd.Process.Kill()
+// }
+// }()
+
+// // Give the UI a moment to start
+// time.Sleep(100 * time.Millisecond)
+// }
+// }
diff --git a/app/cli/go.mod b/app/cli/go.mod
index 24773538..c2867876 100644
--- a/app/cli/go.mod
+++ b/app/cli/go.mod
@@ -3,14 +3,13 @@ module plandex
go 1.23.3
require (
- github.com/alecthomas/chroma/v2 v2.14.0
github.com/atotto/clipboard v0.1.4
github.com/charmbracelet/lipgloss v0.10.0
- github.com/davecgh/go-spew v1.1.1
github.com/fatih/color v1.16.0
github.com/muesli/reflow v0.3.0
github.com/muesli/termenv v0.15.2
github.com/olekukonko/tablewriter v0.0.5
+ github.com/plandex-ai/go-prompt v0.0.0-20250130142100-3d8d7ab8d071
github.com/plandex-ai/survey/v2 v2.3.7
github.com/sashabaranov/go-openai v1.35.6
github.com/shopspring/decimal v1.4.0
@@ -25,6 +24,7 @@ require (
github.com/aymerick/douceur v0.2.0 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/cqroot/multichoose v0.1.1 // indirect
+ github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.11.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
@@ -33,14 +33,17 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
+ github.com/mattn/go-tty v0.0.3 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/microcosm-cc/bluemonday v1.0.26 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
+ github.com/pkg/term v1.2.0-beta.2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/yuin/goldmark v1.6.0 // indirect
github.com/yuin/goldmark-emoji v1.0.2 // indirect
+ golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.19.0 // indirect
diff --git a/app/cli/go.sum b/app/cli/go.sum
index 5bb1487a..b7a3d589 100644
--- a/app/cli/go.sum
+++ b/app/cli/go.sum
@@ -191,14 +191,8 @@ github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDe
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
-github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE=
-github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
-github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E=
-github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I=
-github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
-github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
@@ -383,6 +377,7 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
+github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f/go.mod h1:nOFQdrUlIlx6M6ODdSpBj1NVA+VgLC6kmw60mkw34H4=
@@ -468,8 +463,6 @@ github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn
github.com/hashicorp/memberlist v0.3.1/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
github.com/hashicorp/serf v0.9.8/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
-github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
-github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
@@ -533,6 +526,7 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
+github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
@@ -540,6 +534,8 @@ github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
+github.com/mattn/go-tty v0.0.3 h1:5OfyWorkyO7xP52Mq7tB36ajHDG5OHrmBGIS/DtakQI=
+github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/meowgorithm/babyenv v1.3.0/go.mod h1:lwNX+J6AGBFqNrMZ2PTLkM6SO+W4X8DOg9zBDO4j3Ig=
github.com/meowgorithm/babyenv v1.3.1/go.mod h1:lwNX+J6AGBFqNrMZ2PTLkM6SO+W4X8DOg9zBDO4j3Ig=
@@ -602,8 +598,12 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
+github.com/pkg/term v1.2.0-beta.2 h1:L3y/h2jkuBVFdWiJvNfYfKmzcCnILw7mJWm2JQuMppw=
+github.com/pkg/term v1.2.0-beta.2/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw=
github.com/pkoukk/tiktoken-go v0.1.7 h1:qOBHXX4PHtvIvmOtyg1EeKlwFRiMKAcoMp4Q+bLQDmw=
github.com/pkoukk/tiktoken-go v0.1.7/go.mod h1:9NiV+i9mJKGj1rYOT+njbv+ZwA/zJxYdewGl6qVatpg=
+github.com/plandex-ai/go-prompt v0.0.0-20250130142100-3d8d7ab8d071 h1:0ATy028FeyfsoiMH0hG0F0xzX1Mp1pyBowgKGeEY4Dw=
+github.com/plandex-ai/go-prompt v0.0.0-20250130142100-3d8d7ab8d071/go.mod h1:SqEsJfsIr0GYUyLatvezDOBe6XsCw64E7v33QzeH5PM=
github.com/plandex-ai/survey/v2 v2.3.7 h1:u1o6bflbaBpW8i8krm+91Z2cOcvZcMVS+AjV+rgR8Rk=
github.com/plandex-ai/survey/v2 v2.3.7/go.mod h1:RiBOKRDB5fOQrOzsiAPAN57hYqFKPkCxgSK7twcDOys=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -761,6 +761,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
+golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME=
+golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.22.0 h1:UtK5yLUzilVrkjMAZAZ34DXGpASN8i8pj8g+O+yd10g=
@@ -913,6 +915,7 @@ golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -933,6 +936,7 @@ golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/app/cli/lib/context_load.go b/app/cli/lib/context_load.go
index 0a790a90..8f0e03a5 100644
--- a/app/cli/lib/context_load.go
+++ b/app/cli/lib/context_load.go
@@ -215,19 +215,11 @@ func MustLoadContext(resources []string, params *types.LoadContextParams) {
if !params.ForceSkipIgnore {
var filteredPaths []string
for _, inputFilePath := range inputFilePaths {
- // log.Println("inputFilePath", inputFilePath)
-
if _, ok := paths.ActivePaths[inputFilePath]; !ok {
- // log.Println("not active", inputFilePath)
-
if _, ok := paths.IgnoredPaths[inputFilePath]; ok {
- // log.Println("ignored", inputFilePath)
-
ignoredPaths[inputFilePath] = paths.IgnoredPaths[inputFilePath]
}
} else {
- // log.Println("active", inputFilePath)
-
filteredPaths = append(filteredPaths, inputFilePath)
}
}
diff --git a/app/cli/lib/current.go b/app/cli/lib/current.go
index 6b92b6ab..4abb8e2c 100644
--- a/app/cli/lib/current.go
+++ b/app/cli/lib/current.go
@@ -8,11 +8,15 @@ import (
"path/filepath"
"plandex/api"
"plandex/auth"
+ "plandex/format"
"plandex/fs"
"plandex/term"
"plandex/types"
+ "strconv"
+ "strings"
"github.com/fatih/color"
+ "github.com/olekukonko/tablewriter"
"github.com/plandex/plandex/shared"
)
@@ -203,6 +207,53 @@ func loadCurrentBranch() error {
return nil
}
+func GetCurrentPlanTable(plan *shared.Plan, currentBranchesByPlanId map[string]*shared.Branch, onlyCols []string) string {
+ b := &strings.Builder{}
+ table := tablewriter.NewWriter(b)
+ table.SetAutoWrapText(false)
+
+ var cols []string
+
+ if onlyCols == nil {
+ cols = []string{"Current Plan", "Updated", "Created" /*"Branches",*/, "Branch", "Context", "Convo"}
+ } else {
+ cols = onlyCols
+ }
+
+ table.SetHeader(cols)
+
+ name := color.New(color.Bold, term.ColorHiGreen).Sprint(plan.Name)
+ branch := currentBranchesByPlanId[CurrentPlanId]
+
+ var row []string
+
+ for _, col := range cols {
+ switch col {
+ case "Current Plan":
+ row = append(row, name)
+ case "Updated":
+ row = append(row, format.Time(plan.UpdatedAt))
+ case "Created":
+ row = append(row, format.Time(plan.CreatedAt))
+ case "Branch":
+ row = append(row, CurrentBranch)
+ case "Context":
+ row = append(row, strconv.Itoa(branch.ContextTokens)+" πŸͺ™")
+ case "Convo":
+ row = append(row, strconv.Itoa(branch.ConvoTokens)+" πŸͺ™")
+ }
+ }
+
+ style := []tablewriter.Colors{
+ {tablewriter.FgGreenColor, tablewriter.Bold},
+ }
+
+ table.Rich(row, style)
+ table.Render()
+
+ return b.String()
+}
+
func mustInitProject(existingSettings *types.CurrentProjectSettingsByAccount) {
res, apiErr := api.Client.CreateProject(shared.CreateProjectRequest{Name: filepath.Base(fs.ProjectRoot)})
diff --git a/app/cli/plan_exec/tell.go b/app/cli/plan_exec/tell.go
index 0763907e..15815415 100644
--- a/app/cli/plan_exec/tell.go
+++ b/app/cli/plan_exec/tell.go
@@ -175,14 +175,27 @@ func TellPlan(
term.OutputErrorAndExit("Error starting stream UI: %v", err)
}
+ diffs, apiErr := api.Client.GetPlanDiffs(params.CurrentPlanId, params.CurrentBranch, true)
+ if apiErr != nil {
+ term.OutputErrorAndExit("Error getting plan diffs: %v", apiErr.Msg)
+ return
+ }
+ hasDiffs := len(diffs) > 0
+
fmt.Println()
- if tellStop && !isChatOnly {
- term.PrintCmds("", "continue", "diff", "diff --ui", "apply", "log")
- } else if !isDebugCmd && !isChatOnly {
- term.PrintCmds("", "diff", "diff --ui", "apply", "log")
+ if tellStop && !isChatOnly && hasDiffs {
+ if hasDiffs {
+ term.PrintCmds("", "continue", "diff", "diff --ui", "apply", "reject", "log")
+ } else {
+ term.PrintCmds("", "continue", "log")
+ }
+ } else if !isDebugCmd && !isChatOnly && hasDiffs {
+ term.PrintCmds("", "diff", "diff --ui", "apply", "reject", "log")
} else if isChatOnly {
- term.PrintCmds("", "tell", "convo", "summary")
+ if !term.IsRepl {
+ term.PrintCmds("", "tell", "convo", "summary", "log")
+ }
}
close(done)
diff --git a/app/cli/term/help.go b/app/cli/term/help.go
index ba21b948..6cf8534d 100644
--- a/app/cli/term/help.go
+++ b/app/cli/term/help.go
@@ -9,70 +9,97 @@ import (
"github.com/fatih/color"
)
-var CmdDesc = map[string][2]string{
- "new": {"", "start a new plan"},
- "rename": {"", "rename the current plan"},
- "current": {"cu", "show current plan"},
- "cd": {"", "set current plan by name or index"},
- "load": {"l", "load files/dirs/urls/notes/images or pipe data into context"},
- "tell": {"t", "describe a task to complete"},
- "chat": {"ch", "ask a question or chat"},
- "changes": {"", "review pending changes in a TUI"},
- "diff": {"", "review pending changes in 'git diff' format"},
- "diff --plain": {"", "review pending changes in 'git diff' format with no color formatting"},
- "diff --ui": {"", "review pending changes in a local browser UI"},
- "summary": {"", "show the latest summary of the current plan"},
- // "preview": {"pv", "preview the plan in a branch"},
- "apply": {"ap", "apply pending changes to project files"},
- "reject": {"rj", "reject pending changes to one or more project files"},
- "archive": {"arc", "archive a plan"},
- "unarchive": {"unarc", "unarchive a plan"},
- "continue": {"c", "continue the plan"},
- "debug": {"db", "repeatedly run a command and auto-apply fixes until it succeeds"},
- // "status": {"s", "show status of the plan"},
- "rewind": {"rw", "rewind to a previous state"},
- "ls": {"", "list everything in context"},
- "rm": {"", "remove context by index, range, name, or glob"},
- "clear": {"", "remove all context"},
- "delete-plan": {"dp", "delete plan by name or index"},
- "delete-branch": {"db", "delete a branch by name or index"},
- "plans": {"pl", "list plans"},
- "plans --archived": {"", "list archived plans"},
- "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"},
- "models": {"", "show current plan model settings"},
- "models default": {"", "show org-wide default model settings for new plans"},
- "models available": {"", "show all available models"},
- "models available --custom": {"", "show available custom models only"},
- "models delete": {"", "delete a custom model"},
- "models add": {"", "add a custom model"},
- "model-packs": {"", "show all available model packs"},
- "model-packs create": {"", "create a new custom model pack"},
- "model-packs delete": {"", "delete a custom model pack"},
- "model-packs --custom": {"", "show custom model packs only"},
- "set-model": {"", "update current plan model settings"},
- "set-model default": {"", "update org-wide default model settings for new plans"},
- "ps": {"", "list active and recently finished plan streams"},
- "stop": {"", "stop an active plan stream"},
- "connect": {"conn", "connect to an active plan stream"},
- "sign-in": {"", "sign in, accept an invite, or create an account"},
- "invite": {"", "invite a user to join your org"},
- "revoke": {"", "revoke an invite or remove a user from your org"},
- "users": {"", "list users and pending invites in your org"},
- "credits": {"", "show Plandex Cloud credits balance"},
- "usage": {"", "show Plandex Cloud credits transaction log"},
- "billing": {"", "show Plandex Cloud billing settings"},
- "config": {"", "show current plan config"},
- "set-config": {"", "update current plan config"},
- "config default": {"", "show default config for new plans"},
- "set-config default": {"", "update default config for new plans"},
+type CmdConfig struct {
+ Cmd string
+ Alias string
+ Desc string
+ Repl bool
+}
+
+var CliCommands = []CmdConfig{
+ {"new", "", "start a new plan", true},
+ {"plans", "pl", "list plans", true},
+ {"cd", "", "set current plan by name or index", true},
+ {"current", "cu", "show current plan", true},
+ {"rename", "", "rename the current plan", true},
+ {"delete-plan", "dp", "delete plan by name or index", true},
+
+ {"config", "", "show current plan config", true},
+ {"set-config", "", "update current plan config", true},
+ {"config default", "", "show default config for new plans", true},
+ {"set-config default", "", "update default config for new plans", true},
+
+ {"tell", "t", "describe a task to complete", false},
+ {"chat", "ch", "ask a question or chat", false},
+
+ {"load", "l", "load files/dirs/urls/notes/images or pipe data into context", true},
+ {"ls", "", "list everything in context", true},
+ {"rm", "", "remove context by index, range, name, or glob", true},
+ {"clear", "", "remove all context", true},
+ {"update", "u", "update outdated context", true},
+
+ {"changes", "", "review pending changes in a TUI", false},
+ {"diff", "", "review pending changes in 'git diff' format", true},
+ {"diff --plain", "", "review pending changes in 'git diff' format with no color formatting", false},
+ {"diff --ui", "", "review pending changes in a local browser UI", true},
+ {"summary", "", "show the latest summary of the current plan", true},
+
+ {"apply", "ap", "apply pending changes to project files", true},
+ {"reject", "rj", "reject pending changes to one or more project files", true},
+
+ {"log", "", "show log of plan updates", true},
+ {"rewind", "rw", "rewind to a previous state", true},
+
+ {"continue", "c", "continue the plan", true},
+ {"debug", "db", "repeatedly run a command and auto-apply fixes until it succeeds", true},
+ {"build", "b", "build any pending changes", true},
+
+ {"convo", "", "show plan conversation", true},
+ {"convo 1", "", "show a specific message in the conversation", false},
+ {"convo 2-5", "", "show a range of messages in the conversation", false},
+ {"convo --plain", "", "show conversation in plain text", false},
+
+ {"branches", "br", "list plan branches", true},
+ {"checkout", "co", "checkout or create a branch", true},
+ {"delete-branch", "db", "delete a branch by name or index", true},
+
+ {"plans --archived", "", "list archived plans", true},
+ {"archive", "arc", "archive a plan", true},
+ {"unarchive", "unarc", "unarchive a plan", true},
+
+ {"models", "", "show current plan model settings", true},
+ {"models default", "", "show org-wide default model settings for new plans", true},
+ {"models available", "", "show all available models", true},
+ {"models available --custom", "", "show available custom models only", true},
+ {"models delete", "", "delete a custom model", true},
+ {"models add", "", "add a custom model", true},
+ {"model-packs", "", "show all available model packs", true},
+ {"model-packs create", "", "create a new custom model pack", true},
+ {"model-packs delete", "", "delete a custom model pack", true},
+ {"model-packs --custom", "", "show custom model packs only", true},
+ {"set-model", "", "update current plan model settings", true},
+ {"set-model default", "", "update org-wide default model settings for new plans", true},
+
+ {"ps", "", "list active and recently finished plan streams", true},
+ {"stop", "", "stop an active plan stream", true},
+ {"connect", "conn", "connect to an active plan stream", true},
+
+ {"sign-in", "", "sign in, accept an invite, or create an account", true},
+ {"invite", "", "invite a user to join your org", true},
+ {"revoke", "", "revoke an invite or remove a user from your org", true},
+ {"users", "", "list users and pending invites in your org", true},
+
+ {"credits", "", "show Plandex Cloud credits balance", true},
+ {"usage", "", "show Plandex Cloud credits transaction log", true},
+ {"billing", "", "show Plandex Cloud billing settings", true},
+}
+
+var CmdDesc = map[string]CmdConfig{}
+
+func init() {
+ for _, cmd := range CliCommands {
+ CmdDesc[cmd.Cmd] = cmd
+ }
}
func PrintCmds(prefix string, cmds ...string) {
@@ -87,15 +114,21 @@ func printCmds(w io.Writer, prefix string, colors []color.Attribute, cmds ...str
if os.Getenv("PLANDEX_DISABLE_SUGGESTIONS") != "" {
return
}
+
for _, cmd := range cmds {
config, ok := CmdDesc[cmd]
if !ok {
continue
}
- alias := config[0]
- desc := config[1]
- if alias != "" {
+ if IsRepl && !config.Repl {
+ continue
+ }
+
+ alias := config.Alias
+ desc := config.Desc
+
+ if alias != "" && !IsRepl {
containsFull := strings.Contains(cmd, alias)
if containsFull {
@@ -106,7 +139,13 @@ func printCmds(w io.Writer, prefix string, colors []color.Attribute, cmds ...str
// desc += color.New(color.FgWhite).Sprintf(" β€’ alias β†’ %s", color.New(color.Bold).Sprint(alias))
}
- styled := color.New(colors...).Sprintf(" plandex %s ", cmd)
+
+ var styled string
+ if IsRepl {
+ styled = color.New(color.Bold, color.FgHiWhite, color.BgCyan, color.FgHiWhite).Sprintf(" \\%s ", cmd)
+ } else {
+ styled = color.New(colors...).Sprintf(" plandex %s ", cmd)
+ }
fmt.Fprintf(w, "%s%s πŸ‘‰ %s\n", prefix, styled, desc)
}
diff --git a/app/cli/term/repl.go b/app/cli/term/repl.go
new file mode 100644
index 00000000..9e9f4948
--- /dev/null
+++ b/app/cli/term/repl.go
@@ -0,0 +1,9 @@
+package term
+
+import "os"
+
+var IsRepl = os.Getenv("PLANDEX_REPL") != ""
+
+func SetIsRepl(value bool) {
+ IsRepl = value
+}
diff --git a/app/shared/context.go b/app/shared/context.go
index d900c571..43972c5d 100644
--- a/app/shared/context.go
+++ b/app/shared/context.go
@@ -83,7 +83,7 @@ func TableForLoadContext(contexts []*Context) string {
table.Render()
- return tableString.String()
+ return strings.TrimSpace(tableString.String())
}
func MarkdownTableForLoadContext(contexts []*Context) string {
diff --git a/app/shared/plan_config.go b/app/shared/plan_config.go
index de866307..8aaccd89 100644
--- a/app/shared/plan_config.go
+++ b/app/shared/plan_config.go
@@ -60,6 +60,8 @@ var AutoModeOptions = [][2]string{
// " β†’ mix and match config settings individually."},
}
+var AutoModeLabels = map[AutoModeType]string{}
+
// populated in init()
var AutoModeChoices []string
@@ -466,5 +468,7 @@ func init() {
for _, choice := range AutoModeOptions {
AutoModeChoices = append(AutoModeChoices, choice[1])
+ AutoModeLabels[AutoModeType(choice[0])] = choice[1]
}
+
}
diff --git a/plandex-cursor.code-workspace b/plandex-cursor.code-workspace
index 7274760e..233d7237 100644
--- a/plandex-cursor.code-workspace
+++ b/plandex-cursor.code-workspace
@@ -39,6 +39,9 @@
{
"name": "vscode",
"path": "vscode"
+ },
+ {
+ "path": "../go-prompt"
}
],
"settings": {