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
more work on cwd/plan list trees and lil' fixes
Dane Schneider3cf7d0921740
diff --git a/app/cli/cmd/checkout.go b/app/cli/cmd/checkout.goindex b5fb0874..94c670f7 100644--- a/app/cli/cmd/checkout.go+++ b/app/cli/cmd/checkout.go@@ -75,7 +75,7 @@ func checkout(cmd *cobra.Command, args []string) {}if branchName == "" {- fmt.Printf("🤷♂️ Branch %s not found\n", color.New(color.Bold, color.FgHiCyan).Sprint(nameOrIdx))+ fmt.Printf("🌱 Branch %s not found\n", color.New(color.Bold, color.FgHiCyan).Sprint(nameOrIdx))res, err := term.ConfirmYesNo("Create it now?")if err != nil {diff --git a/app/cli/cmd/plans.go b/app/cli/cmd/plans.goindex 5883cb4e..86571c99 100644--- a/app/cli/cmd/plans.go+++ b/app/cli/cmd/plans.go@@ -2,6 +2,7 @@ package cmdimport ("fmt"+ "log""os""path/filepath""strconv"@@ -105,28 +106,28 @@ func plans(cmd *cobra.Command, args []string) {}}- currentBranchNamesByPlanId, err := lib.GetCurrentBranchNamesByPlanId(currentProjectPlanIds)+ if len(currentProjectPlanIds) > 0 {+ currentBranchNamesByPlanId, err := lib.GetCurrentBranchNamesByPlanId(currentProjectPlanIds)- if err != nil {- fmt.Fprintln(os.Stderr, "Error getting current branches:", err)- return- }+ if err != nil {+ fmt.Fprintln(os.Stderr, "Error getting current branches:", err)+ return+ }- currentBranchesByPlanId, apiErr := api.Client.GetCurrentBranchByPlanId(lib.CurrentProjectId, shared.GetCurrentBranchByPlanIdRequest{- CurrentBranchByPlanId: currentBranchNamesByPlanId,- })+ currentBranchesByPlanId, apiErr := api.Client.GetCurrentBranchByPlanId(lib.CurrentProjectId, shared.GetCurrentBranchByPlanIdRequest{+ CurrentBranchByPlanId: currentBranchNamesByPlanId,+ })- if apiErr != nil {- fmt.Fprintln(os.Stderr, "Error getting current branches:", apiErr)- return- }+ if apiErr != nil {+ fmt.Fprintln(os.Stderr, "Error getting current branches:", apiErr)+ return+ }- table := tablewriter.NewWriter(os.Stdout)- table.SetAutoWrapText(false)- table.SetHeader([]string{"#", "Name", "Updated", "Created" /*"Branches",*/, "Branch", "Context", "Convo"})+ table := tablewriter.NewWriter(os.Stdout)+ table.SetAutoWrapText(false)+ table.SetHeader([]string{"#", "Name", "Updated", "Created" /*"Branches",*/, "Branch", "Context", "Convo"})- currentProjectPlans := plansByProjectId[lib.CurrentProjectId]- if len(currentProjectPlans) > 0 {+ currentProjectPlans := plansByProjectId[lib.CurrentProjectId]fmt.Println()if len(parentProjectIdsWithPaths) > 0 || len(childProjectIdsWithPaths) > 0 {color.New(color.Bold, color.FgHiMagenta).Println("Plans in current directory")@@ -184,6 +185,8 @@ func plans(cmd *cobra.Command, args []string) {var addPathToTreeFn func(tree treeprint.Tree, pathParts []string, projectId string, isParent bool)addPathToTreeFn = func(tree treeprint.Tree, pathParts []string, projectId string, isParent bool) {+ log.Println("addPathToTreeFn", pathParts, projectId, isParent)+if len(pathParts) == 0 {if plans, ok := plansByProjectId[projectId]; ok {for _, plan := range plans {@@ -221,7 +224,7 @@ func plans(cmd *cobra.Command, args []string) {fmt.Println()color.New(color.Bold, color.FgHiMagenta).Println("Plans in parent directories")color.New(color.FgWhite).Println("cd into a directory to work on a plan in that directory")- parentTree := treeprint.New()+ parentTree := treeprint.NewWithRoot("~")for _, p := range parentProjectIdsWithPaths {pathParts := strings.Split(strings.TrimPrefix(p[0], fs.HomeDir+"/"),"/")diff --git a/app/cli/fs/fs.go b/app/cli/fs/fs.goindex 2bea67c1..46f09b00 100644--- a/app/cli/fs/fs.go+++ b/app/cli/fs/fs.go@@ -280,7 +280,7 @@ func GetPlandexIgnore() (*ignore.GitIgnore, error) {func GetParentProjectIdsWithPaths() ([][2]string, error) {var parentProjectIds [][2]string- currentDir := ProjectRoot+ currentDir := filepath.Dir(ProjectRoot)for currentDir != "/" {plandexDir := findPlandex(currentDir)@@ -314,7 +314,7 @@ func GetChildProjectIdsWithPaths() ([][2]string, error) {if err != nil {return err}- if info.IsDir() {+ if info.IsDir() && path != Cwd {plandexDir := findPlandex(path)projectSettingsPath := filepath.Join(plandexDir, "project.json")if _, err := os.Stat(projectSettingsPath); err == nil {diff --git a/app/server/handlers/plans_crud.go b/app/server/handlers/plans_crud.goindex ee83654f..ee8f6e04 100644--- a/app/server/handlers/plans_crud.go+++ b/app/server/handlers/plans_crud.go@@ -409,6 +409,12 @@ func GetCurrentBranchByPlanIdHandler(w http.ResponseWriter, r *http.Request) {return}+ if len(plans) == 0 {+ log.Println("No plans found")+ http.Error(w, "No plans found", http.StatusNotFound)+ return+ }+query := "SELECT * FROM branches WHERE "var orConditions []string@@ -429,6 +435,8 @@ func GetCurrentBranchByPlanIdHandler(w http.ResponseWriter, r *http.Request) {query += "(" + strings.Join(orConditions, " OR ") + ") AND archived_at IS NULL AND deleted_at IS NULL"+ log.Println("query: ", query)+var branches []db.Brancherr = db.Conn.Select(&branches, query, queryArgs...)