Skip to content

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

Improve REPL command handling and add reasoning model pack flag

Dane Schneider724a639b738f
diff --git a/app/cli/cmd/plan_start_helpers.go b/app/cli/cmd/plan_start_helpers.go
index a90fd553..7ad1f5e9 100644
--- a/app/cli/cmd/plan_start_helpers.go
+++ b/app/cli/cmd/plan_start_helpers.go
@@ -21,10 +21,12 @@ var (
fullAuto bool
// Type flags
- dailyModels bool
- strongModels bool
- ossModels bool
- cheapModels bool
+ dailyModels bool
+ reasoningModels bool
+ strongModels bool
+ ossModels bool
+ cheapModels bool
+ // crazyModels bool
)
func AddNewPlanFlags(cmd *cobra.Command) {
@@ -37,9 +39,11 @@ func AddNewPlanFlags(cmd *cobra.Command) {
// Add type flags
cmd.Flags().BoolVar(&dailyModels, "daily", false, shared.DailyDriverModelPack.Description)
+ cmd.Flags().BoolVar(&reasoningModels, "reasoning", false, shared.ReasoningModelPack.Description)
cmd.Flags().BoolVar(&strongModels, "strong", false, shared.StrongModelPack.Description)
cmd.Flags().BoolVar(&cheapModels, "cheap", false, shared.CheapModelPack.Description)
cmd.Flags().BoolVar(&ossModels, "oss", false, shared.OSSModelPack.Description)
+ // cmd.Flags().BoolVar(&crazyModels, "crazy", false, shared.CrazyModelPack.Description)
}
func resolveAutoMode(config *shared.PlanConfig) (bool, *shared.PlanConfig) {
@@ -131,6 +135,10 @@ func resolveModelPackWithArgs(settings *shared.PlanSettings, silent bool) (*shar
packName = shared.StrongModelPack.Name
} else if cheapModels {
packName = shared.CheapModelPack.Name
+ } else if reasoningModels {
+ packName = shared.ReasoningModelPack.Name
+ // } else if crazyModels {
+ // packName = shared.CrazyModelPack.Name
} else {
packName = shared.DailyDriverModelPack.Name
}
diff --git a/app/cli/cmd/repl.go b/app/cli/cmd/repl.go
index ff05f60d..cad2bdcf 100644
--- a/app/cli/cmd/repl.go
+++ b/app/cli/cmd/repl.go
@@ -126,6 +126,8 @@ func runRepl(cmd *cobra.Command, args []string) {
args = append(args, "--cheap")
} else if dailyModels {
args = append(args, "--daily")
+ } else if reasoningModels {
+ args = append(args, "--reasoning")
}
newCmd.Run(newCmd, args)
@@ -308,12 +310,12 @@ func executor(in string, p *prompt.Prompt) {
lastLine := lines[len(lines)-1]
lastLine = strings.TrimSpace(lastLine)
- input := strings.TrimSpace(in)
- if input == "" {
+ trimmedInput := strings.TrimSpace(in)
+ if trimmedInput == "" {
return
}
// condense whitespace
- input = strings.Join(strings.Fields(input), " ")
+ condensedInput := strings.Join(strings.Fields(trimmedInput), " ")
// Handle plandex/pdx command prefix
if strings.HasPrefix(lastLine, "plandex ") || strings.HasPrefix(lastLine, "pdx ") {
@@ -429,10 +431,10 @@ func executor(in string, p *prompt.Prompt) {
return
case cmd == "send" || cmd == lib.ReplCmdAliases["send"]:
- split := strings.Split(input, "\\s")
- input = strings.TrimSpace(split[0])
- input = strings.TrimSpace(input)
- if input == "" {
+ split := strings.Split(condensedInput, "\\s")
+ condensedInput = strings.TrimSpace(split[0])
+ condensedInput = strings.TrimSpace(condensedInput)
+ if condensedInput == "" {
fmt.Println()
fmt.Println("πŸ€·β€β™‚οΈ No prompt to send")
fmt.Println()
@@ -532,7 +534,7 @@ func executor(in string, p *prompt.Prompt) {
// Handle non-command input based on mode
if lib.CurrentReplState.Mode == lib.ReplModeTell {
fmt.Println()
- args := []string{"tell", input}
+ args := []string{"tell", trimmedInput}
var err error
_, err = lib.ExecPlandexCommandWithParams(args, lib.ExecPlandexCommandParams{
SessionId: sessionId,
@@ -542,7 +544,7 @@ func executor(in string, p *prompt.Prompt) {
}
} else if lib.CurrentReplState.Mode == lib.ReplModeChat {
fmt.Println()
- args := []string{"chat", input}
+ args := []string{"chat", trimmedInput}
output, err := lib.ExecPlandexCommandWithParams(args, lib.ExecPlandexCommandParams{
SessionId: sessionId,
})
diff --git a/app/cli/install.sh b/app/cli/install.sh
index 645d9bb3..f1c31785 100755
--- a/app/cli/install.sh
+++ b/app/cli/install.sh
@@ -42,6 +42,12 @@ case "$(uname -s)" in
;;
esac
+if [[ "$PLATFORM" == "windows" ]]; then
+ echo "🚨 Windows is only supported via WSL. It doesn't work in the Windows CMD prompt or PowerShell."
+ echo "How to install WSL πŸ‘‰ https://learn.microsoft.com/en-us/windows/wsl/about"
+ exit 1
+fi
+
# Set arch
if [[ "$(uname -m)" == 'x86_64' ]]; then
ARCH="amd64"
@@ -90,11 +96,14 @@ download_plandex () {
tar zxf plandex.tar.gz 1> /dev/null
+ should_sudo=false
+
if [ "$PLATFORM" == "darwin" ] || $IS_DOCKER ; then
if [[ -d /usr/local/bin ]]; then
if ! mv plandex /usr/local/bin/ 2>/dev/null; then
echo "Permission denied when attempting to move Plandex to /usr/local/bin."
if hash sudo 2>/dev/null; then
+ should_sudo=true
echo "Attempting to use sudo to complete installation."
sudo mv plandex /usr/local/bin/
if [[ $? -eq 0 ]]; then
@@ -115,11 +124,6 @@ download_plandex () {
echo >&2 'Error: /usr/local/bin does not exist. Create this directory with appropriate permissions, then re-install.'
exit 1
fi
- elif [ "$PLATFORM" == "windows" ]; then
- # ensure $HOME/bin exists (it's in PATH but not present in default git-bash install)
- mkdir "$HOME/bin" 2> /dev/null
- mv plandex.exe "$HOME/bin/"
- echo "βœ… Plandex is installed in '$HOME/bin'"
else
if [ $UID -eq 0 ]
then
@@ -129,6 +133,7 @@ download_plandex () {
then
# not root, but can sudo
sudo mv plandex /usr/local/bin/
+ should_sudo=true
else
echo "ERROR: This script must be run as root or be able to sudo to complete the installation."
exit 1
@@ -137,12 +142,21 @@ download_plandex () {
echo "βœ… Plandex is installed in /usr/local/bin"
fi
- # create 'pdx' alias, but don't ovewrite existing pdx command
+ # create 'pdx' alias, but don't overwrite existing pdx command
if [ ! -x "$(command -v pdx)" ]; then
- echo "creating pdx alias"
+ echo "🎭 Creating pdx alias..."
LOC=$(which plandex)
- BIN_DIR=$(dirname $LOC)
- error_msg=$(ln -s "$LOC" "$BIN_DIR/pdx" 2>&1) || { echo "⚠️ Failed to create 'pdx' alias for Plandex. Error: $error_msg. Please create it manually if needed."; }
+ BIN_DIR=$(dirname "$LOC")
+
+ if [ "$should_sudo" = true ]; then
+ sudo ln -s "$LOC" "$BIN_DIR/pdx" && \
+ echo "βœ… Successfully created 'pdx' alias with sudo." || \
+ echo "⚠️ Failed to create 'pdx' alias even with sudo. Please create it manually."
+ else
+ ln -s "$LOC" "$BIN_DIR/pdx" && \
+ echo "βœ… Successfully created 'pdx' alias." || \
+ echo "⚠️ Failed to create 'pdx' alias. Please create it manually."
+ fi
fi
}
diff --git a/app/cli/lib/repl.go b/app/cli/lib/repl.go
index c618b004..8659de79 100644
--- a/app/cli/lib/repl.go
+++ b/app/cli/lib/repl.go
@@ -4,10 +4,12 @@ import (
"encoding/json"
"os"
"os/exec"
+ "os/signal"
"path/filepath"
"plandex-cli/fs"
"plandex-cli/term"
"strconv"
+ "syscall"
)
var ReplSettingsDir string
@@ -198,7 +200,23 @@ func ExecPlandexCommandWithParams(args []string, params ExecPlandexCommandParams
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
- err = cmd.Run()
+ err = cmd.Start()
+ if err != nil {
+ return "", err
+ }
+
+ signal.Ignore(syscall.SIGINT)
+ defer signal.Reset(syscall.SIGINT)
+
+ sigChan := make(chan os.Signal, 1)
+ signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
+
+ go func() {
+ sig := <-sigChan
+ syscall.Kill(-cmd.Process.Pid, sig.(syscall.Signal))
+ }()
+
+ err = cmd.Wait()
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
return "", nil
@@ -211,5 +229,6 @@ func ExecPlandexCommandWithParams(args []string, params ExecPlandexCommandParams
if err != nil {
return "", err
}
+
return string(output), nil
}
diff --git a/app/cli/term/help.go b/app/cli/term/help.go
index c721ad4e..8b02601d 100644
--- a/app/cli/term/help.go
+++ b/app/cli/term/help.go
@@ -39,10 +39,11 @@ var CliCommands = []CmdConfig{
{"new --none", "", fmt.Sprintf("start a new plan with auto-mode %s", "'none'"), true},
{"new --daily", "", fmt.Sprintf("start a new plan with %s model pack", "'daily-driver'"), true},
+ {"new --reasoning", "", fmt.Sprintf("start a new plan with %s model pack", "'reasoning'"), true},
{"new --strong", "", fmt.Sprintf("start a new plan with %s model pack", "'strong'"), true},
{"new --cheap", "", fmt.Sprintf("start a new plan with %s model pack", "'cheap'"), true},
{"new --oss", "", fmt.Sprintf("start a new plan with %s model pack", "'oss'"), true},
-
+ // {"new --crazy", "", fmt.Sprintf("start a new plan with %s model pack", "'crazy'"), true},
{"plans", "pl", "list plans", true},
{"cd", "", "set current plan by name or index", true},
{"current", "cu", "show current plan", true},
@@ -111,13 +112,17 @@ var CliCommands = []CmdConfig{
{"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},
+ {"model-packs update", "", "update a custom model pack", true},
+ {"model-packs show", "", "show a built-in or custom model pack's settings", true},
{"set-model", "", "update current plan model settings", true},
{"set-model default", "", "update the default model settings for new plans", true},
{"set-model daily", "", fmt.Sprintf("Use %s model pack", "'daily-driver'"), true},
+ {"set-model reasoning", "", fmt.Sprintf("Use %s model pack", "'reasoning'"), true},
{"set-model strong", "", fmt.Sprintf("Use %s model pack", "'strong'"), true},
{"set-model cheap", "", fmt.Sprintf("Use %s model pack", "'cheap'"), true},
{"set-model oss", "", fmt.Sprintf("Use %s model pack", "'oss'"), true},
+ // {"set-model crazy", "", fmt.Sprintf("Use %s model pack", "'crazy'"), true},
{"ps", "", "list active and recently finished plan streams", true},
{"stop", "", "stop an active plan stream", true},
@@ -249,9 +254,11 @@ func PrintCustomHelp(all bool) {
fmt.Fprintln(builder, color.New(color.Bold, color.FgHiBlue).Sprint(" Models "))
fmt.Fprintln(builder, " --daily Daily driver pack")
+ fmt.Fprintln(builder, " --reasoning Reasoning pack")
fmt.Fprintln(builder, " --strong Strong pack")
fmt.Fprintln(builder, " --cheap Cheap pack")
fmt.Fprintln(builder, " --oss Open source pack")
+ // fmt.Fprintln(builder, " --crazy Crazy pack")
fmt.Fprintln(builder)
if all {
@@ -313,11 +320,11 @@ func PrintHelpAllCommands() {
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " AI Models ")
- printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "models", "models default", "model-packs", "set-model", "set-model daily", "set-model strong", "set-model cheap", "set-model oss", "set-model default")
+ printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "models", "models default", "model-packs", "set-model", "set-model daily", "set-model reasoning", "set-model strong", "set-model cheap", "set-model oss" /*"set-model crazy",*/, "set-model default")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Custom Models ")
- printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "models available", "models available --custom", "models add", "models delete", "model-packs --custom", "model-packs create", "model-packs delete")
+ printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "models available", "models available --custom", "models add", "models delete", "model-packs --custom", "model-packs create", "model-packs show", "model-packs update", "model-packs delete")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Accounts ")
@@ -329,7 +336,7 @@ func PrintHelpAllCommands() {
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " New Plan Shortcuts ")
- printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "new --full", "new --semi", "new --plus", "new --basic", "new --none", "new --daily", "new --strong", "new --cheap", "new --oss")
+ printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "new --full", "new --semi", "new --plus", "new --basic", "new --none", "new --daily", "new --reasoning", "new --strong", "new --cheap", "new --oss" /*"new --crazy"*/)
fmt.Fprintln(builder)
fmt.Print(builder.String())
diff --git a/app/cli/types/api.go b/app/cli/types/api.go
index c0507006..ab40a130 100644
--- a/app/cli/types/api.go
+++ b/app/cli/types/api.go
@@ -102,10 +102,12 @@ type ApiClient interface {
UpdateDefaultPlanConfig(req shared.UpdateDefaultPlanConfigRequest) *shared.ApiError
CreateCustomModel(model *shared.AvailableModel) *shared.ApiError
+ UpdateCustomModel(model *shared.AvailableModel) *shared.ApiError
ListCustomModels() ([]*shared.AvailableModel, *shared.ApiError)
DeleteAvailableModel(modelId string) *shared.ApiError
CreateModelPack(set *shared.ModelPack) *shared.ApiError
+ UpdateModelPack(set *shared.ModelPack) *shared.ApiError
ListModelPacks() ([]*shared.ModelPack, *shared.ApiError)
DeleteModelPack(setId string) *shared.ApiError