Skip to content

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

better handling of commands in non-project dirs

Dane Schneidere7b10254a09b
diff --git a/app/cli/cmd/current.go b/app/cli/cmd/current.go
index a15c7ac5..d1767f88 100644
--- a/app/cli/cmd/current.go
+++ b/app/cli/cmd/current.go
@@ -29,7 +29,7 @@ func init() {
func current(cmd *cobra.Command, args []string) {
auth.MustResolveAuthWithOrg()
- lib.MustResolveProject()
+ lib.MaybeResolveProject()
if lib.CurrentPlanId == "" {
fmt.Println("🤷‍♂️ No current plan")
diff --git a/app/cli/cmd/new.go b/app/cli/cmd/new.go
index c141ab59..7830b522 100644
--- a/app/cli/cmd/new.go
+++ b/app/cli/cmd/new.go
@@ -33,7 +33,7 @@ func init() {
func new(cmd *cobra.Command, args []string) {
auth.MustResolveAuthWithOrg()
- lib.MustResolveProject()
+ lib.MustResolveOrCreateProject()
res, apiErr := api.Client.CreatePlan(lib.CurrentProjectId, shared.CreatePlanRequest{Name: name})
diff --git a/app/cli/lib/current.go b/app/cli/lib/current.go
index b7ced7ed..32ef6f91 100644
--- a/app/cli/lib/current.go
+++ b/app/cli/lib/current.go
@@ -10,6 +10,7 @@ import (
"plandex/fs"
"plandex/types"
+ "github.com/fatih/color"
"github.com/plandex/plandex/shared"
)
@@ -19,16 +20,20 @@ var CurrentBranch string
var HomeCurrentProjectDir string
var HomeCurrentPlanPath string
+func MustResolveOrCreateProject() {
+ resolveProject(true, true)
+}
+
func MustResolveProject() {
- resolveProject(true)
+ resolveProject(true, false)
}
func MaybeResolveProject() {
- resolveProject(false)
+ resolveProject(false, false)
}
-func resolveProject(mustResolve bool) {
- if fs.PlandexDir == "" && mustResolve {
+func resolveProject(mustResolve, shouldCreate bool) {
+ if fs.PlandexDir == "" && mustResolve && shouldCreate {
_, _, err := fs.FindOrCreatePlandex()
if err != nil {
panic(fmt.Errorf("error finding or creating plandex: %v", err))
@@ -36,7 +41,11 @@ func resolveProject(mustResolve bool) {
}
if (fs.PlandexDir == "" || fs.ProjectRoot == "") && mustResolve {
- panic(fmt.Errorf("could not find or create plandex directory"))
+ fmt.Printf(
+ "🤷‍♂️ No plans in current directory\nTry %s to create a plan or %s to see plans in nearby directories\n",
+ color.New(color.Bold, color.FgHiCyan).Sprint("plandex new"),
+ color.New(color.Bold, color.FgHiCyan).Sprint("plandex plans"))
+ os.Exit(1)
}
if fs.PlandexDir == "" {