Skip to content

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

shell script smoke test, --yes/-y flag for 'checkout' command for scripting, --skip-menu and skip-changes-menu config key for skipping pending changes menu (also for scripting). docs updates.

Dane Schneidere52f29ba7855
diff --git a/app/cli/cmd/apply.go b/app/cli/cmd/apply.go
index 445bd876..df461185 100644
--- a/app/cli/cmd/apply.go
+++ b/app/cli/cmd/apply.go
@@ -47,7 +47,7 @@ func apply(cmd *cobra.Command, args []string) {
printFn()
}
- mustSetPlanExecFlagsWithConfig(cmd, config)
+ mustSetPlanExecFlagsWithConfig(cmd, config, true)
if lib.CurrentPlanId == "" {
term.OutputNoCurrentPlanErrorAndExit()
diff --git a/app/cli/cmd/build.go b/app/cli/cmd/build.go
index 6c956916..552eb961 100644
--- a/app/cli/cmd/build.go
+++ b/app/cli/cmd/build.go
@@ -38,7 +38,7 @@ func init() {
func build(cmd *cobra.Command, args []string) {
auth.MustResolveAuthWithOrg()
lib.MustResolveProject()
- mustSetPlanExecFlags(cmd)
+ mustSetPlanExecFlags(cmd, false)
var apiKeys map[string]string
if !auth.Current.IntegratedModelsMode {
diff --git a/app/cli/cmd/chat.go b/app/cli/cmd/chat.go
index 3e995ab2..7ab113c1 100644
--- a/app/cli/cmd/chat.go
+++ b/app/cli/cmd/chat.go
@@ -31,6 +31,7 @@ func init() {
omitApply: true,
omitExec: true,
omitSmartContext: true,
+ omitSkipMenu: true,
})
}
@@ -38,7 +39,7 @@ func init() {
func doChat(cmd *cobra.Command, args []string) {
auth.MustResolveAuthWithOrg()
lib.MustResolveProject()
- mustSetPlanExecFlags(cmd)
+ mustSetPlanExecFlags(cmd, false)
var apiKeys map[string]string
if !auth.Current.IntegratedModelsMode {
@@ -61,7 +62,8 @@ func doChat(cmd *cobra.Command, args []string) {
return lib.CheckOutdatedContextWithOutput(auto, auto, maybeContexts, projectPaths)
},
}, prompt, types.TellFlags{
- IsChatOnly: true,
- AutoContext: tellAutoContext,
+ IsChatOnly: true,
+ AutoContext: tellAutoContext,
+ SkipChangesMenu: tellSkipMenu,
})
}
diff --git a/app/cli/cmd/checkout.go b/app/cli/cmd/checkout.go
index acb0f556..fd908496 100644
--- a/app/cli/cmd/checkout.go
+++ b/app/cli/cmd/checkout.go
@@ -19,6 +19,8 @@ const (
OptCreateNewBranch = "Create a new branch"
)
+var confirmCreateBranch bool
+
var checkoutCmd = &cobra.Command{
Use: "checkout [name-or-index]",
Aliases: []string{"co"},
@@ -29,6 +31,7 @@ var checkoutCmd = &cobra.Command{
func init() {
RootCmd.AddCommand(checkoutCmd)
+ checkoutCmd.Flags().BoolVarP(&confirmCreateBranch, "yes", "y", false, "Confirm creating a new branch")
}
func checkout(cmd *cobra.Command, args []string) {
@@ -76,17 +79,24 @@ func checkout(cmd *cobra.Command, args []string) {
if branchName == "" {
fmt.Printf("🌱 Branch %s not found\n", color.New(color.Bold, term.ColorHiCyan).Sprint(nameOrIdx))
- res, err := term.ConfirmYesNo("Create it now?")
- if err != nil {
- term.OutputErrorAndExit("Error getting user input: %v", err)
- }
-
- if res {
+ if confirmCreateBranch {
+ fmt.Println("✅ --yes flag set, will create branch")
branchName = nameOrIdx
willCreate = true
} else {
- return
+ res, err := term.ConfirmYesNo("Create it now?")
+
+ if err != nil {
+ term.OutputErrorAndExit("Error getting user input: %v", err)
+ }
+
+ if res {
+ branchName = nameOrIdx
+ willCreate = true
+ } else {
+ return
+ }
}
}
diff --git a/app/cli/cmd/continue.go b/app/cli/cmd/continue.go
index 6c293b0d..69ab695e 100644
--- a/app/cli/cmd/continue.go
+++ b/app/cli/cmd/continue.go
@@ -36,7 +36,7 @@ func init() {
func doContinue(cmd *cobra.Command, args []string) {
auth.MustResolveAuthWithOrg()
lib.MustResolveProject()
- mustSetPlanExecFlags(cmd)
+ mustSetPlanExecFlags(cmd, false)
var apiKeys map[string]string
if !auth.Current.IntegratedModelsMode {
@@ -44,15 +44,16 @@ func doContinue(cmd *cobra.Command, args []string) {
}
tellFlags := types.TellFlags{
- TellBg: tellBg,
- TellStop: tellStop,
- TellNoBuild: tellNoBuild,
- IsUserContinue: true,
- ExecEnabled: !noExec,
- AutoContext: tellAutoContext,
- SmartContext: tellSmartContext,
- AutoApply: tellAutoApply,
- IsChatOnly: chatOnly,
+ TellBg: tellBg,
+ TellStop: tellStop,
+ TellNoBuild: tellNoBuild,
+ IsUserContinue: true,
+ ExecEnabled: !noExec,
+ AutoContext: tellAutoContext,
+ SmartContext: tellSmartContext,
+ AutoApply: tellAutoApply,
+ IsChatOnly: chatOnly,
+ SkipChangesMenu: tellSkipMenu,
}
plan_exec.TellPlan(plan_exec.ExecParams{
diff --git a/app/cli/cmd/debug.go b/app/cli/cmd/debug.go
index a3cefa0f..1bc3e06c 100644
--- a/app/cli/cmd/debug.go
+++ b/app/cli/cmd/debug.go
@@ -44,7 +44,7 @@ func init() {
func doDebug(cmd *cobra.Command, args []string) {
auth.MustResolveAuthWithOrg()
lib.MustResolveProject()
- mustSetPlanExecFlags(cmd)
+ mustSetPlanExecFlags(cmd, false)
if lib.CurrentPlanId == "" {
term.OutputNoCurrentPlanErrorAndExit()
diff --git a/app/cli/cmd/plan_exec_helpers.go b/app/cli/cmd/plan_exec_helpers.go
index 285f90e3..95c69f4c 100644
--- a/app/cli/cmd/plan_exec_helpers.go
+++ b/app/cli/cmd/plan_exec_helpers.go
@@ -31,6 +31,7 @@ var tellNoBuild bool
var tellAutoApply bool
var tellAutoContext bool
var tellSmartContext bool
+var tellSkipMenu bool
var noExec bool
var autoDebug int
@@ -58,6 +59,7 @@ type initExecFlagsParams struct {
omitExec bool
omitAutoContext bool
omitSmartContext bool
+ omitSkipMenu bool
}
func initExecFlags(cmd *cobra.Command, params initExecFlagsParams) {
@@ -100,6 +102,10 @@ func initExecFlags(cmd *cobra.Command, params initExecFlagsParams) {
cmd.Flags().Var(newEditorValue(&editor), "editor", "Write prompt in system editor")
cmd.Flag("editor").NoOptDefVal = defaultEditor
}
+
+ if !params.omitSkipMenu {
+ cmd.Flags().BoolVar(&tellSkipMenu, "skip-menu", false, shared.ConfigSettingsByKey["skip-changes-menu"].Desc)
+ }
}
func initApplyFlags(cmd *cobra.Command, applyFlag bool) {
@@ -123,19 +129,7 @@ func initExecScriptFlags(cmd *cobra.Command) {
cmd.Flag("debug").NoOptDefVal = strconv.Itoa(defaultAutoDebugTries)
}
-func validatePlanExecFlags() {
- if tellAutoApply && tellNoBuild {
- term.OutputErrorAndExit("--apply can't be used with --no-build/-n")
- }
- if tellAutoApply && tellBg {
- term.OutputErrorAndExit("--apply can't be used with --bg")
- }
- if autoExec && !tellAutoApply {
- term.OutputErrorAndExit("--auto-exec can only be used with --apply")
- }
- if autoDebug > 0 && !tellAutoApply {
- term.OutputErrorAndExit("--debug can only be used with --apply")
- }
+func validatePlanExecFlags(isApply bool) {
if autoDebug > 0 && noExec {
term.OutputErrorAndExit("--debug can't be used with --no-exec")
}
@@ -143,13 +137,30 @@ func validatePlanExecFlags() {
if tellAutoContext && tellBg {
term.OutputErrorAndExit("--auto-context/-c can't be used with --bg")
}
+
+ if !isApply {
+ if autoDebug > 0 && !tellAutoApply {
+ term.OutputErrorAndExit("--debug can only be used with --apply")
+ }
+
+ if autoExec && !tellAutoApply {
+ term.OutputErrorAndExit("--auto-exec can only be used with --apply")
+ }
+
+ if tellAutoApply && tellNoBuild {
+ term.OutputErrorAndExit("--apply can't be used with --no-build/-n")
+ }
+ if tellAutoApply && tellBg {
+ term.OutputErrorAndExit("--apply can't be used with --bg")
+ }
+ }
}
-func mustSetPlanExecFlags(cmd *cobra.Command) {
- mustSetPlanExecFlagsWithConfig(cmd, nil)
+func mustSetPlanExecFlags(cmd *cobra.Command, isApply bool) {
+ mustSetPlanExecFlagsWithConfig(cmd, nil, isApply)
}
-func mustSetPlanExecFlagsWithConfig(cmd *cobra.Command, config *shared.PlanConfig) {
+func mustSetPlanExecFlagsWithConfig(cmd *cobra.Command, config *shared.PlanConfig, isApply bool) {
if lib.CurrentPlanId == "" {
term.OutputNoCurrentPlanErrorAndExit()
}
@@ -203,6 +214,10 @@ func mustSetPlanExecFlagsWithConfig(cmd *cobra.Command, config *shared.PlanConfi
}
}
+ if !cmd.Flags().Changed("skip-menu") {
+ tellSkipMenu = config.SkipChangesMenu
+ }
+
// tell command editor is no longer tied to config *unless* it's set to vim or nano
// otherwise, the flag or EDITOR env var are used
// config.Editor is now used for mainly for JSON editing (and perhaps other purposes)
@@ -211,7 +226,7 @@ func mustSetPlanExecFlagsWithConfig(cmd *cobra.Command, config *shared.PlanConfi
editor = config.Editor
}
- validatePlanExecFlags()
+ validatePlanExecFlags(isApply)
}
// AutoDebugValue implements the flag.Value interface
diff --git a/app/cli/cmd/tell.go b/app/cli/cmd/tell.go
index 66195ce7..4e1e06d1 100644
--- a/app/cli/cmd/tell.go
+++ b/app/cli/cmd/tell.go
@@ -41,7 +41,7 @@ func init() {
func doTell(cmd *cobra.Command, args []string) {
auth.MustResolveAuthWithOrg()
lib.MustResolveProject()
- mustSetPlanExecFlags(cmd)
+ mustSetPlanExecFlags(cmd, false)
var authVars map[string]string
if !auth.Current.IntegratedModelsMode {
@@ -71,6 +71,7 @@ func doTell(cmd *cobra.Command, args []string) {
ExecEnabled: !noExec,
AutoApply: tellAutoApply,
IsImplementationOfChat: isImplementationOfChat,
+ SkipChangesMenu: tellSkipMenu,
}
plan_exec.TellPlan(plan_exec.ExecParams{
diff --git a/app/cli/plan_exec/tell.go b/app/cli/plan_exec/tell.go
index 8e3ca9a1..00096f92 100644
--- a/app/cli/plan_exec/tell.go
+++ b/app/cli/plan_exec/tell.go
@@ -41,6 +41,7 @@ func TellPlan(
autoApply := flags.AutoApply
isApplyDebug := flags.IsApplyDebug
isImplementationOfChat := flags.IsImplementationOfChat
+ skipChangesMenu := flags.SkipChangesMenu
done := make(chan struct{})
if prompt == "" && isImplementationOfChat {
@@ -229,6 +230,9 @@ func TellPlan(
} else if autoApply || isDebugCmd || isApplyDebug {
term.StopSpinner()
// do nothing, allow auto apply to run
+ } else if skipChangesMenu {
+ term.StopSpinner()
+ // script mode, don't show menu
} else {
term.StartSpinner("")
// sleep a little to prevent lock contention on server
diff --git a/app/cli/types/exec.go b/app/cli/types/exec.go
index 3e8d73a1..7552dbf0 100644
--- a/app/cli/types/exec.go
+++ b/app/cli/types/exec.go
@@ -14,6 +14,7 @@ type TellFlags struct {
ExecEnabled bool
AutoApply bool
IsImplementationOfChat bool
+ SkipChangesMenu bool
}
type BuildFlags struct {
BuildBg bool
diff --git a/app/cli/ui/ui.go b/app/cli/ui/ui.go
index 8928c044..9eaa919a 100644
--- a/app/cli/ui/ui.go
+++ b/app/cli/ui/ui.go
@@ -23,6 +23,7 @@ func OpenAuthenticatedURL(msg, path string) {
apiHost := api.GetApiHost()
appHost := strings.Replace(apiHost, "api-v2.", "app.", 1)
+ appHost = strings.Replace(appHost, "api.", "app.", 1)
token := shared.UiSignInToken{
Pin: signInCode,
diff --git a/app/shared/plan_config.go b/app/shared/plan_config.go
index c7d292e8..eb7aea25 100644
--- a/app/shared/plan_config.go
+++ b/app/shared/plan_config.go
@@ -85,6 +85,8 @@ type PlanConfig struct {
AutoRevertOnRewind bool `json:"autoRevertOnRewind"`
+ SkipChangesMenu bool `json:"skipChangesMenu"`
+
// ReplMode bool `json:"replMode"`
// DefaultRepl ReplType `json:"defaultRepl"`
@@ -139,6 +141,7 @@ func (p *PlanConfig) SetAutoMode(mode AutoModeType) {
p.AutoDebug = true
p.AutoDebugTries = defaultAutoDebugTries
p.AutoRevertOnRewind = true
+ p.SkipChangesMenu = false
case AutoModeSemi:
p.AutoContinue = true
@@ -152,6 +155,7 @@ func (p *PlanConfig) SetAutoMode(mode AutoModeType) {
p.AutoExec = false
p.AutoDebug = false
p.AutoRevertOnRewind = true
+ p.SkipChangesMenu = false
case AutoModePlus:
p.AutoContinue = true
@@ -165,6 +169,7 @@ func (p *PlanConfig) SetAutoMode(mode AutoModeType) {
p.AutoExec = false
p.AutoDebug = false
p.AutoRevertOnRewind = true
+ p.SkipChangesMenu = false
case AutoModeBasic:
p.AutoContinue = true
@@ -178,6 +183,7 @@ func (p *PlanConfig) SetAutoMode(mode AutoModeType) {
p.AutoExec = false
p.AutoDebug = false
p.AutoRevertOnRewind = true
+ p.SkipChangesMenu = false
case AutoModeNone:
p.AutoContinue = false
@@ -191,6 +197,7 @@ func (p *PlanConfig) SetAutoMode(mode AutoModeType) {
p.AutoExec = false
p.AutoDebug = false
p.AutoRevertOnRewind = true
+ p.SkipChangesMenu = false
}
}
@@ -468,6 +475,16 @@ var ConfigSettingsByKey = map[string]ConfigSetting{
return fmt.Sprintf("%t", p.AutoRevertOnRewind)
},
},
+ "skipchangesmenu": {
+ Name: "skip-changes-menu",
+ Desc: "Skip interactive menu when response finishes and changes are pending",
+ BoolSetter: func(p *PlanConfig, enabled bool) {
+ p.SkipChangesMenu = enabled
+ },
+ Getter: func(p *PlanConfig) string {
+ return fmt.Sprintf("%t", p.SkipChangesMenu)
+ },
+ },
}
func init() {
diff --git a/docs/docs/cli-reference.md b/docs/docs/cli-reference.md
index baf859d7..b626ebcf 100644
--- a/docs/docs/cli-reference.md
+++ b/docs/docs/cli-reference.md
@@ -322,6 +322,8 @@ pdx t # alias
`--auto-exec`: Automatically execute commands after successful apply without confirmation. Defaults to config value `auto-exec`.
+`--skip-menu`: Skip interactive menu when response finishes and changes are pending. Defaults to config value `skip-changes-menu`.
+
`--debug`: Automatically execute and debug failing commands (optionally specify number of tries—default is 5). Defaults to config values of `auto-debug` and `auto-debug-tries`.
`--apply/-a`: Automatically apply changes (and confirm context updates). Defaults to config value `auto-apply`.
@@ -356,6 +358,8 @@ pdx c # alias
`--auto-exec`: Automatically execute commands after successful apply without confirmation. Defaults to config value `auto-exec`.
+`--skip-menu`: Skip interactive menu when response finishes and changes are pending. Defaults to config value `skip-changes-menu`.
+
`--debug`: Automatically execute and debug failing commands (optionally specify number of tries—default is 5). Defaults to config values of `auto-debug` and `auto-debug-tries`.
`--apply/-a`: Automatically apply changes (and confirm context updates). Defaults to config value `auto-apply`.
@@ -385,6 +389,8 @@ pdx b # alias
`--auto-exec`: Automatically execute commands after successful apply without confirmation. Defaults to config value `auto-exec`.
+`--skip-menu`: Skip interactive menu when response finishes and changes are pending. Defaults to config value `skip-changes-menu`.
+
`--debug`: Automatically execute and debug failing commands (optionally specify number of tries—default is 5). Defaults to config values of `auto-debug` and `auto-debug-tries`.
`--apply/-a`: Automatically apply changes (and confirm context updates). Defaults to config value `auto-apply`.
@@ -545,10 +551,13 @@ Checkout or create a branch.
```bash
plandex checkout # select from a list of branches or prompt to create a new branch
plandex checkout some-branch # checkout by name or create a new branch with that name
+plandex checkout some-branch -y # checkout by name or create a new branch with that name, auto-confirming branch creation
pdx co # alias
```
+`--yes/-y`: Auto-confirm creating a new branch if it doesn't exist.
+
### delete-branch
Delete a branch by name or index.
diff --git a/docs/docs/core-concepts/configuration.md b/docs/docs/core-concepts/configuration.md
index f4366d11..c257d440 100644
--- a/docs/docs/core-concepts/configuration.md
+++ b/docs/docs/core-concepts/configuration.md
@@ -64,6 +64,14 @@ Autonomy settings control the overall level of automation Plandex will use. See
| `auto-commit` | Commit changes to git when applied | `true` |
| `auto-revert-on-rewind` | Revert project files when rewinding | `true` |
+### Changes Menu
+
+| Setting | Description | Default |
+| ----------------------- | ---------------------------------------- | ------- |
+| `skip-changes-menu` | Skip interactive menu when response finishes and changes are pending | `false` |
+
+
+
### Editor
| Setting | Description | Default |
diff --git a/releases/cli/versions/2.2.0.md b/releases/cli/versions/2.2.0.md
index 892c5d2a..948acc05 100644
--- a/releases/cli/versions/2.2.0.md
+++ b/releases/cli/versions/2.2.0.md
@@ -2,7 +2,9 @@ This is a big release that is mainly focused on Plandex's model provider and mod
## 🔌  Model provider flexibility for BYO key mode
-- Now when using Plandex in BYO key mode (either cloud or self-hosted), you can easily use Plandex with a wide range of built-in model providers.
+![plandex-model-providers](https://github.com/plandex-ai/plandex/blob/main/releases/images/cli/2.2.0/new-providers.gif)
+
+- Now when using Plandex in BYO key mode (either Cloud or self-hosted), you can easily use Plandex with a wide range of built-in model providers.
- Apart from OpenRouter and the OpenAI API (which were already built-in), built-in providers now include:
- Anthropic API
@@ -26,6 +28,10 @@ This is a big release that is mainly focused on Plandex's model provider and mod
## ⚙️  JSON-based model config with IDE support
+![plandex-model-settings-json](https://github.com/plandex-ai/plandex/blob/main/releases/images/cli/2.2.0/model-settings-json.gif)
+
+![plandex-custom-models-json](https://github.com/plandex-ai/plandex/blob/main/releases/images/cli/2.2.0/custom-models-json.gif)
+
- Plandex now supports JSON-based model config, which make it much easier to try out different models, different settings, and to use custom models, providers, and model packs.
- The new JSON model config system integrates cleanly with your IDE or editor. When you first edit model settings, Plandex will prompt you to set a preferred editor, and the JSON config file will be opened in that editor.
@@ -54,6 +60,8 @@ This is a big release that is mainly focused on Plandex's model provider and mod
## 🦙  Built-in Ollama support
+![plandex-ollama](https://github.com/plandex-ai/plandex/blob/main/releases/images/cli/2.2.0/ollama.gif)
+
- Plandex now offers built-in support for Ollama, which makes it much easier to use local models. Check out the new [Ollama quickstart](https://docs.plandex.ai/models/ollama) for details.
## 📖  Built-in models and models packs
@@ -80,4 +88,10 @@ This is a big release that is mainly focused on Plandex's model provider and mod
## 🐞  Bug fixes
-- Fixed a file mapping bug for TypeScript files that caused directly exported symbols like `export const foo = 'bar'` to be omitted from map files. Also improved TypeScript mapping support for some other constructs like `declare global`, `namespace`, and `enum` blocks, and improved handling of arrow functions. Thanks to @mnahkies for the [PR](https://github.com/plandex-ai/plandex/pull/239) identifying this.
\ No newline at end of file
+- Fixed a file mapping bug for TypeScript files that caused directly exported symbols like `export const foo = 'bar'` to be omitted from map files. Also improved TypeScript mapping support for some other constructs like `declare global`, `namespace`, and `enum` blocks, and improved handling of arrow functions. Thanks to @mnahkies for the [PR](https://github.com/plandex-ai/plandex/pull/239) identifying this.
+
+## 🔧  Other changes
+
+- `plandex checkout` now has a `--yes/-y` flag to auto-confirm creating a new branch if it doesn't exist, so the command can be used for scripting with no user interaction.
+
+- `plandex tell`, `plandex continue`, and `plandex build` all now support a `--skip-menu` flag to skip the interactive menu that appears when the response finishes and changes are pending. There's also a new `skip-changes-menu` config setting that can be set to `true` to skip this menu by default.
\ No newline at end of file
diff --git a/releases/images/cli/2.2.0/custom-models-json.gif b/releases/images/cli/2.2.0/custom-models-json.gif
new file mode 100644
index 00000000..0acb79cb
Binary files /dev/null and b/releases/images/cli/2.2.0/custom-models-json.gif differ
diff --git a/releases/images/cli/2.2.0/model-settings-json.gif b/releases/images/cli/2.2.0/model-settings-json.gif
new file mode 100644
index 00000000..615c6bae
Binary files /dev/null and b/releases/images/cli/2.2.0/model-settings-json.gif differ
diff --git a/releases/images/cli/2.2.0/new-providers.gif b/releases/images/cli/2.2.0/new-providers.gif
new file mode 100644
index 00000000..c6e59ca0
Binary files /dev/null and b/releases/images/cli/2.2.0/new-providers.gif differ
diff --git a/releases/images/cli/2.2.0/ollama.gif b/releases/images/cli/2.2.0/ollama.gif
new file mode 100644
index 00000000..7e1a7f00
Binary files /dev/null and b/releases/images/cli/2.2.0/ollama.gif differ
diff --git a/releases/server/versions/2.2.0.md b/releases/server/versions/2.2.0.md
new file mode 100644
index 00000000..e9bf1cfb
--- /dev/null
+++ b/releases/server/versions/2.2.0.md
@@ -0,0 +1 @@
+See CLI 2.2.0 release notes.
diff --git a/test/smoke_test.sh b/test/smoke_test.sh
new file mode 100755
index 00000000..ee0df1ea
--- /dev/null
+++ b/test/smoke_test.sh
@@ -0,0 +1,328 @@
+#!/bin/bash
+
+# Plandex Smoke Test Script
+# Tests core functionality in a linear flow mimicking real usage
+# Assumes: Already signed in to Plandex Cloud (staging account)
+
+set -e # Exit on error
+
+# Colors for output
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+NC='\033[0m' # No Color
+
+# Test directory setup
+TEST_DIR="/tmp/plandex-smoke-test-$$"
+TIMESTAMP=$(date +%Y%m%d_%H%M%S)
+LOG_FILE="${TEST_DIR}/smoke-test-${TIMESTAMP}.log"
+
+PLANDEX_CMD="plandex-dev"
+
+# Minimal prompts to keep costs down
+PROMPT_CREATE_FUNCTION="add a simple hello world function in main.go"
+PROMPT_ADD_TEST="add a test for the hello function"
+PROMPT_CHAT_QUESTION="what does the hello function do?"
+PROMPT_ADD_FEATURE="add a goodbye function that returns: goodbye world"
+
+# Helper functions
+log() {
+ if [ -f "$LOG_FILE" ]; then
+ echo -e "$1" | tee -a "$LOG_FILE"
+ else
+ echo -e "$1"
+ fi
+}
+
+
+
+success() {
+ log "${GREEN}✓ $1${NC}"
+}
+
+error() {
+ log "${RED}✗ $1${NC}"
+ exit 1
+}
+
+info() {
+ log "${YELLOW}→ $1${NC}"
+}
+
+# Run command and check for success
+run_cmd() {
+ local cmd="$1"
+ local description="$2"
+
+ info "Running: $cmd"
+
+ # Create a temporary file for capturing exit status
+ local tmpfile=$(mktemp)
+
+ # Run command with output visible and logged
+ ( eval "$cmd" 2>&1; echo $? > "$tmpfile" ) | tee -a "$LOG_FILE"
+
+ # Get the exit status
+ local exit_code=$(cat "$tmpfile")
+ rm -f "$tmpfile"
+
+ if [ "$exit_code" -eq 0 ]; then
+ success "$description"
+ else
+ error "$description failed (exit code: $exit_code)"
+ fi
+}
+
+# Run command and capture output
+run_cmd_output() {
+ local cmd="$1"
+
+ # Create a temporary file for capturing exit status
+ local tmpfile=$(mktemp)
+
+ if [ -f "$LOG_FILE" ]; then
+ ( eval "$cmd" 2>&1; echo $? > "$tmpfile" ) | tee -a "$LOG_FILE"
+ else
+ ( eval "$cmd" 2>&1; echo $? > "$tmpfile" )
+ fi
+
+ # Get the exit status
+ local exit_code=$(cat "$tmpfile")
+ rm -f "$tmpfile"
+
+ # Return the exit code so the caller can handle it
+ return $exit_code
+}
+
+run_plandex_cmd() {
+ local cmd="$1"
+ local description="$2"
+ run_cmd "$PLANDEX_CMD $cmd" "$description"
+}
+
+run_plandex_cmd_output() {
+ local cmd="$1"
+ if ! run_cmd_output "$PLANDEX_CMD $cmd"; then
+ error "Command failed: $PLANDEX_CMD $cmd"
+ fi
+}
+
+# Check if file exists
+check_file() {
+ if [ -f "$1" ]; then
+ success "File exists: $1"
+ else
+ error "File missing: $1"
+ fi
+}
+
+# Setup test environment
+setup() {
+ info "Setting up test environment in $TEST_DIR"
+ mkdir -p "$TEST_DIR"
+ cd "$TEST_DIR"
+
+ # Now create the log file after directory exists
+ LOG_FILE="${TEST_DIR}/smoke-test-${TIMESTAMP}.log"
+ touch "$LOG_FILE"
+
+ # Create a simple Go project structure
+ mkdir -p cmd
+ echo "package main" > main.go
+ echo "func main() {}" >> main.go
+
+ # Create a test file to load as context
+ cat > README.md << EOF
+# Test Project
+This is a test project for Plandex smoke testing.
+EOF
+
+ success "Test environment created"
+}
+
+# Cleanup function
+cleanup() {
+ info "Cleaning up test environment"
+ cd /
+ rm -rf "$TEST_DIR"
+ success "Cleanup complete"
+}
+
+# Set trap for cleanup on exit
+trap cleanup EXIT
+
+# Main test flow
+main() {
+ log "=== Plandex Smoke Test Started at $(date) ==="
+
+ setup
+
+ # 1. PLAN MANAGEMENT
+ log "\n=== Testing Plan Management ==="
+
+ # Create new plan with name
+ run_plandex_cmd "new -n smoke-test-plan" "Create named plan"
+
+ # Check current plan
+ run_plandex_cmd_output "current"
+
+ # List plans
+ run_plandex_cmd_output "plans"
+
+ # 2. CONTEXT MANAGEMENT
+ log "\n=== Testing Context Management ==="
+
+ # Load single file
+ run_plandex_cmd "load main.go" "Load single file"
+
+ # Load with note
+ run_plandex_cmd "load -n 'keep code simple and well-commented'" "Load note"
+
+ # Load directory tree
+ run_plandex_cmd "load . --tree" "Load directory tree"
+
+ # List context
+ run_plandex_cmd_output "ls"
+
+ # Show specific context
+ run_plandex_cmd_output "show main.go"
+
+ # 3. BASIC TASK EXECUTION
+ log "\n=== Testing Task Execution ==="
+
+ # Skip changes menu so we don't have to interact with the menu
+ run_plandex_cmd "set-config skip-changes-menu true" "Set skip-changes-menu to true"
+
+ # Tell command with simple task
+ run_plandex_cmd "tell '$PROMPT_CREATE_FUNCTION'" "Execute tell command"
+
+ # Check diff
+ run_plandex_cmd_output "diff --git"
+
+ # Apply changes
+ run_plandex_cmd "apply --auto-exec --debug 2 --skip-commit" "Apply changes"
+
+ # Verify file was updated
+ check_file "main.go"
+
+ # 4. CHAT FUNCTIONALITY
+ log "\n=== Testing Chat ==="
+
+ # Chat without making changes
+ run_plandex_cmd_output "chat '$PROMPT_CHAT_QUESTION'"
+
+ # 5. CONTINUE AND BUILD
+ log "\n=== Testing Continue and Build ==="
+
+ # Tell another task
+ run_plandex_cmd "tell '$PROMPT_ADD_TEST' --no-build" "Tell without building"
+
+ # Build pending changes
+ run_plandex_cmd "build" "Build pending changes"
+
+ # Review and apply
+ run_plandex_cmd_output "diff --git"
+ run_plandex_cmd "apply --auto-exec --debug 2 --skip-commit" "Apply test changes"
+
+ # 6. BRANCHES
+ log "\n=== Testing Branches ==="
+
+ # Create and switch to new branch
+ run_plandex_cmd "checkout feature-branch -y" "Create new branch"
+
+ # Make changes on branch
+ run_plandex_cmd "tell '$PROMPT_ADD_FEATURE'" "Add feature on branch"
+ run_plandex_cmd "apply --auto-exec --debug 2 --skip-commit" "Apply on branch"
+
+ # List branches
+ run_plandex_cmd_output "branches"
+
+ # Switch back to main
+ run_plandex_cmd "checkout main" "Switch to main branch"
+
+ # 7. VERSION CONTROL
+ log "\n=== Testing Version Control ==="
+
+ # View log
+ run_plandex_cmd_output "log"
+
+ # View conversation
+ run_plandex_cmd_output "convo"
+
+ # Get current state for rewind test
+ REWIND_STEPS=2
+ info "Will rewind $REWIND_STEPS steps"
+
+ # Rewind
+ run_plandex_cmd "rewind $REWIND_STEPS" "Rewind $REWIND_STEPS steps"
+
+ # 8. CONFIGURATION
+ log "\n=== Testing Configuration ==="
+
+ # View current config
+ run_plandex_cmd_output "config"
+
+ # Change a setting
+ run_plandex_cmd "set-config auto-continue false" "Set auto-continue to false"
+
+ # Change it back
+ run_plandex_cmd "set-config auto-continue true" "Set auto-continue to true"
+
+ # View models
+ run_plandex_cmd_output "models"
+
+ # List model packs
+ run_plandex_cmd_output "model-packs"
+
+ # 9. CONTEXT UPDATES
+ log "\n=== Testing Context Updates ==="
+
+ # Modify a file outside of Plandex
+ echo "// Modified outside Plandex" >> main.go
+
+ # Update context
+ run_plandex_cmd "update" "Update outdated context"
+
+ # Remove context
+ run_plandex_cmd "rm main.go" "Remove file from context"
+
+ # Clear all context
+ run_plandex_cmd "clear" "Clear all context"
+
+ # 10. REJECT FUNCTIONALITY
+ log "\n=== Testing Reject ==="
+
+ # Load context again and make changes
+ run_plandex_cmd "load . -r" "Reload context"
+ run_plandex_cmd "tell 'add a function that has an intentional syntax error'" "Create changes to reject"
+
+ # Reject all pending changes
+ run_plandex_cmd "reject --all" "Reject all pending changes"
+
+ # 11. ARCHIVE FUNCTIONALITY
+ log "\n=== Testing Archive ==="
+
+ # Archive the plan
+ run_plandex_cmd "archive smoke-test-plan" "Archive plan"
+
+ # List archived plans
+ run_plandex_cmd_output "plans --archived"
+
+ # Unarchive
+ run_plandex_cmd "unarchive smoke-test-plan" "Unarchive plan"
+
+ # 12. MULTIPLE PLANS
+ log "\n=== Testing Multiple Plans ==="
+
+ # Create another plan with model pack
+ run_plandex_cmd "new -n second-plan --cheap" "Create plan with cheap model pack"
+
+ # Switch between plans
+ run_plandex_cmd "cd smoke-test-plan" "Switch to first plan"
+ run_plandex_cmd_output "current"
+
+ log "\n=== Plandex Smoke Test Completed Successfully at $(date) ==="
+}
+
+# Run the tests
+main
\ No newline at end of file