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
model>filename fix, next command
Dane Schneider7af8b89ffb1b
diff --git a/cli/cmd/next.go b/cli/cmd/next.gonew file mode 100644index 00000000..cec915e6--- /dev/null+++ b/cli/cmd/next.go@@ -0,0 +1,35 @@+/*+Copyright © 2023 NAME HERE <EMAIL ADDRESS>+*/+package cmd++import (+ "fmt"+ "os"+ "plandex/lib"++ "github.com/spf13/cobra"+)++// Variables to be used in the nextCmd+var prompt string = "continue to the next step of the plan"++// nextCmd represents the prompt command+var nextCmd = &cobra.Command{+ Use: "next",+ Aliases: []string{"n"},+ Short: "Continue to the next step of the plan.",+ Run: next,+}++func init() {+ RootCmd.AddCommand(nextCmd)+}++func next(cmd *cobra.Command, args []string) {+ err := lib.Propose(prompt)+ if err != nil {+ fmt.Fprintln(os.Stderr, "Prompt error:", err)+ return+ }+}\ No newline at end of filediff --git a/cli/lib/proposal.go b/cli/lib/proposal.goindex 475eb57a..00649f6b 100644--- a/cli/lib/proposal.go+++ b/cli/lib/proposal.go@@ -149,6 +149,9 @@ func Propose(prompt string) error {}clearCurrentLine()PrintCustomCmd(" ", "tell", "t", "update the plan, give more info, or chat")++ clearCurrentLine()+ PrintCmds(" ", "next")}contextByFilePath := make(map[string]shared.ModelContextPart)diff --git a/cli/lib/term.go b/cli/lib/term.goindex 4cb1bd93..bf612888 100644--- a/cli/lib/term.go+++ b/cli/lib/term.go@@ -10,7 +10,7 @@ import ()var cmdDesc = map[string][2]string{- "new": {"n", "start a new plan"},+ "new": {"", "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"},@@ -30,7 +30,9 @@ func PrintCmds(prefix string, cmds ...string) {alias := config[0]desc := config[1]- cmd = strings.Replace(cmd, alias, fmt.Sprintf("(%s)", alias), 1)+ if alias != "" {+ 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)diff --git a/server/main.go b/server/main.goindex b5f258a9..1e08e708 100644--- a/server/main.go+++ b/server/main.go@@ -16,11 +16,14 @@ import (var client *openai.Clientfunc main() {+ if os.Getenv("OPENAI_API_KEY") == "" {+ log.Fatal("OPENAI_API_KEY environment variable is not set")+ }+r := mux.NewRouter()r.HandleFunc("/proposal", handlers.ProposalHandler).Methods("POST")r.HandleFunc("/abort-proposal", handlers.AbortProposalHandler).Methods("DELETE")- // r.HandleFunc("/revise-proposal", handlers.ReviseProposalHandler).Methods("PATCH")r.HandleFunc("/short-summary", handlers.ShortSummaryHandler).Methods("POST")r.HandleFunc("/filename", handlers.FileNameHandler).Methods("POST")diff --git a/server/model/name.go b/server/model/name.goindex 5ce26820..2ceb8ec9 100644--- a/server/model/name.go+++ b/server/model/name.go@@ -53,7 +53,7 @@ func FileName(text string) ([]byte, int, error) {var byteRes []bytefor _, choice := range resp.Choices {- if choice.FinishReason == "function_call" && choice.Message.FunctionCall != nil && choice.Message.FunctionCall.Name == "summarize" {+ if choice.FinishReason == "function_call" && choice.Message.FunctionCall != nil && choice.Message.FunctionCall.Name == "nameFile" {fnCall := choice.Message.FunctionCallif strings.HasSuffix(fnCall.Arguments, ",\n}") { // remove trailing comma@@ -65,12 +65,12 @@ func FileName(text string) ([]byte, int, error) {}if len(byteRes) == 0 {- return nil, 0, fmt.Errorf("no summarize function call found in response")+ return nil, 0, fmt.Errorf("no nameFile function call found in response")}// validate the JSON response- var summarizeResp shared.FileNameResponse- if err := json.Unmarshal(byteRes, &summarizeResp); err != nil {+ var nameFileResp shared.FileNameResponse+ if err := json.Unmarshal(byteRes, &nameFileResp); err != nil {return nil, resp.Usage.CompletionTokens, err}