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
fixes for custom models config, opus planner model pack
Dane Schneider474436240962
diff --git a/.gitignore b/.gitignoreindex c6e39166..f825f3f9 100644--- a/.gitignore+++ b/.gitignore@@ -22,4 +22,6 @@ __pycache__/.aider.**.code-workspace-__pycache__/\ No newline at end of file+__pycache__/++.repo_ignore\ No newline at end of filediff --git a/app/cli/cmd/set_model.go b/app/cli/cmd/set_model.goindex 2e9bb16e..22dee3b5 100644--- a/app/cli/cmd/set_model.go+++ b/app/cli/cmd/set_model.go@@ -335,6 +335,7 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings, dif compare == "opus-4-planner" {compare = "opus-planner"}+for _, ms := range builtInModelPacks {if strings.EqualFold(ms.Name, compare) {modelPackName = ms.Name@@ -349,7 +350,11 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings, d}if modelPackName == "" {- term.OutputErrorAndExit("No model pack found with name: %s", modelPackName)+ term.StopSpinner()+ term.OutputSimpleError("No model pack found with name '%s'", nameArg)+ fmt.Println()+ term.PrintCmds("", "model-packs")+ os.Exit(1)return nil}diff --git a/app/cli/lib/model_credentials.go b/app/cli/lib/model_credentials.goindex a21d12eb..38431fcd 100644--- a/app/cli/lib/model_credentials.go+++ b/app/cli/lib/model_credentials.go@@ -368,6 +368,19 @@ func showCredentialErrorMessage(res CredentialCheckResult, opts shared.ModelProvbyPub := providersByPublisher(opts)+ byPubWithoutOpenRouter := map[shared.ModelPublisher][]shared.ModelProvider{}+ for pub, providers := range byPub {+ nonOrProviders := []shared.ModelProvider{}+ for _, provider := range providers {+ if provider != shared.ModelProviderOpenRouter {+ nonOrProviders = append(nonOrProviders, provider)+ }+ }+ if len(nonOrProviders) > 0 {+ byPubWithoutOpenRouter[pub] = nonOrProviders+ }+ }+allPublishersHaveOpenRouter := allPublishersHaveProvider(byPub, shared.ModelProviderOpenRouter)if allPublishersHaveOpenRouter {@@ -388,7 +401,7 @@ func showCredentialErrorMessage(res CredentialCheckResult, opts shared.ModelProv}}- if len(byPub) > 0 {+ if len(byPubWithoutOpenRouter) > 0 {fmt.Println()fmt.Println(color.New(term.ColorHiCyan, color.Bold).Sprint("π Other model providers"))if allPublishersHaveOpenRouter {@@ -398,18 +411,15 @@ func showCredentialErrorMessage(res CredentialCheckResult, opts shared.ModelProv}fmt.Println()- pubs := make([]string, 0, len(byPub))- for p := range byPub {+ pubs := make([]string, 0, len(byPubWithoutOpenRouter))+ for p := range byPubWithoutOpenRouter {pubs = append(pubs, string(p))}sort.Strings(pubs)for _, p := range pubs {- providers := byPub[shared.ModelPublisher(p)]+ providers := byPubWithoutOpenRouter[shared.ModelPublisher(p)]providerNames := make([]string, 0, len(providers))for _, provider := range providers {- if allPublishersHaveOpenRouter && provider == shared.ModelProviderOpenRouter {- continue- }providerNames = append(providerNames, string(provider))}fmt.Printf("%s β %s\n", color.New(color.Bold).Sprint(p+" models"), strings.Join(providerNames, ", "))diff --git a/app/shared/ai_models_credentials.go b/app/shared/ai_models_credentials.goindex ce18f3e0..f5d757f9 100644--- a/app/shared/ai_models_credentials.go+++ b/app/shared/ai_models_credentials.go@@ -25,19 +25,46 @@ func (m ModelRoleConfig) GetModelProviderOptions(settings *PlanSettings) ModelPrfor i, usesProvider := range usesProviders {composite := usesProvider.ToComposite()++ foundProvider := falseconfig, ok := BuiltInModelProviderConfigs[usesProvider.Provider]- if !ok {+ if ok {+ // built-in provider+ foundProvider = true+ } else if settings != nil && settings.CustomProviders != nil {+ // no built-in provider, check custom providers+ for _, customProvider := range settings.CustomProviders {+ if usesProvider.CustomProvider != nil && customProvider.Name == *usesProvider.CustomProvider {+ config = customProvider.ToModelProviderConfigSchema()+ foundProvider = true+ break+ }+ }+ }++ if !foundProvider {continue}+ var publisher ModelPublisher+baseModel, ok := BuiltInBaseModelsById[m.ModelId]- if !ok {+ if ok {+ publisher = baseModel.Publisher+ } else if settings != nil && settings.CustomModelsById != nil {+ customModel, ok := settings.CustomModelsById[m.ModelId]+ if ok {+ publisher = customModel.Publisher+ }+ }++ if publisher == "" {continue}opts[composite] = ModelProviderOption{Publishers: map[ModelPublisher]bool{- baseModel.Publisher: true,+ publisher: true,},Config: &config,Priority: i,diff --git a/app/shared/ai_models_packs.go b/app/shared/ai_models_packs.goindex d7efe7d8..937e1bea 100644--- a/app/shared/ai_models_packs.go+++ b/app/shared/ai_models_packs.go@@ -7,7 +7,6 @@ var OSSModelPack ModelPackvar CheapModelPack ModelPackvar OpusPlannerModelPack ModelPack-var StrongModelOpus ModelPackvar AnthropicModelPack ModelPackvar OpenAIModelPack ModelPack@@ -31,12 +30,11 @@ var BuiltInModelPacks = []*ModelPack{&OllamaExperimentalModelPack,&OllamaAdaptiveOssModelPack,&OllamaAdaptiveDailyModelPack,- &OpusPlannerModelPack,- &StrongModelOpus,&AnthropicModelPack,&OpenAIModelPack,&GoogleModelPack,&GeminiPlannerModelPack,+ &OpusPlannerModelPack,&O3PlannerModelPack,&R1PlannerModelPack,&PerplexityPlannerModelPack,@@ -316,6 +314,24 @@ func init() {},}+ OpusPlannerSchema = ModelPackSchema{+ Name: "opus-planner",+ Description: "Uses Claude Opus 4 for planning, default models for other roles. Supports up to 180k input context.",+ ModelPackSchemaRoles: ModelPackSchemaRoles{+ Planner: getModelRoleConfig(ModelRolePlanner, "anthropic/claude-opus-4"),+ Coder: Pointer(getModelRoleConfig(ModelRoleCoder, "anthropic/claude-sonnet-4",+ getLargeContextFallback(ModelRoleCoder, "openai/gpt-4.1"),+ )),+ PlanSummary: getModelRoleConfig(ModelRolePlanSummary, "openai/o4-mini-low"),+ Builder: defaultBuilder,+ WholeFileBuilder: Pointer(getModelRoleConfig(ModelRoleWholeFileBuilder,+ "openai/o4-mini-medium")),+ Namer: getModelRoleConfig(ModelRoleName, "openai/gpt-4.1-mini"),+ CommitMsg: getModelRoleConfig(ModelRoleCommitMsg, "openai/gpt-4.1-mini"),+ ExecStatus: getModelRoleConfig(ModelRoleExecStatus, "openai/o4-mini-low"),+ },+ }+O3PlannerSchema = ModelPackSchema{Name: "o3-planner",Description: "Uses Claude Opus 4 for planning, default models for other roles. Supports up to 180k input context.",diff --git a/test/smoke_test.sh b/test/smoke_test.shindex ee0df1ea..48eea6a2 100755--- a/test/smoke_test.sh+++ b/test/smoke_test.sh@@ -1,130 +1,23 @@#!/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)+# Assumes: Already signed in to Plandex Cloud (dev or 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"+# Source common utilities+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${SCRIPT_DIR}/test_utils.sh"-# Minimal prompts to keep costs down+# Test-specific variablesPROMPT_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 for this testsetup() {- 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"+ setup_test_dir "smoke-test"# Create a simple Go project structuremkdir -p cmd@@ -136,20 +29,10 @@ setup() {# Test ProjectThis 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+trap cleanup_test_dir EXIT# Main test flowmain() {@@ -254,7 +137,7 @@ main() {info "Will rewind $REWIND_STEPS steps"# Rewind- run_plandex_cmd "rewind $REWIND_STEPS" "Rewind $REWIND_STEPS steps"+ run_plandex_cmd "rewind $REWIND_STEPS --revert" "Rewind $REWIND_STEPS steps"# 8. CONFIGURATIONlog "\n=== Testing Configuration ==="diff --git a/test/test_custom_models.sh b/test/test_custom_models.shnew file mode 100755index 00000000..365b8009--- /dev/null+++ b/test/test_custom_models.sh@@ -0,0 +1,98 @@+#!/bin/bash+# custom-models-test.sh - Plandex custom models functionality test++set -e # Exit on error++# Source common utilities+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${SCRIPT_DIR}/test_utils.sh"++# Setup for this test+setup() {+ setup_test_dir "custom-models-test"++ # Create a simple test file+ echo "package main" > main.go+}++# Set trap for cleanup on exit+trap cleanup_test_dir EXIT++# Create custom models JSON matching the GitHub issue+create_custom_models_json() {+ cat > custom-models.json << 'EOF'+{+ "$schema": "https://plandex.ai/schemas/models-input.schema.json",+ "models": [+ {+ "modelId": "custom-claude-4",+ "publisher": "test",+ "description": "Claude 4 Sonnet test",+ "defaultMaxConvoTokens": 15000,+ "maxTokens": 200000,+ "maxOutputTokens": 64000,+ "reservedOutputTokens": 16000,+ "preferredOutputFormat": "xml",+ "hasImageSupport": true,+ "providers": [+ {+ "provider": "openrouter",+ "modelName": "anthropic/claude-sonnet-4"+ }+ ]+ }+ ],+ "modelPacks": [+ {+ "name": "test-pack",+ "description": "Test model pack",+ "$schema": "https://plandex.ai/schemas/model-pack-inline.schema.json",+ "planner": {+ "modelId": "custom-claude-4",+ "largeContextFallback": "custom-claude-4"+ },+ "architect": "custom-claude-4",+ "coder": "custom-claude-4",+ "summarizer": "custom-claude-4",+ "builder": "custom-claude-4",+ "wholeFileBuilder": "custom-claude-4",+ "names": "custom-claude-4",+ "commitMessages": "custom-claude-4",+ "autoContinue": "custom-claude-4"+ }+ ]+}+EOF+}++main() {+ log "=== Plandex Custom Models Test Started at $(date) ==="++ setup++ echo "OPENROUTER_API_KEY: $OPENROUTER_API_KEY"++ run_plandex_cmd "new -n custom-model-test" "Create test plan"+ run_plandex_cmd "models" "Show current models"++ log "\n=== Testing Custom Models with Custom Provider ==="++ create_custom_models_json+ run_plandex_cmd "models custom --file custom-models.json --save" "Import custom models"+ run_plandex_cmd "models available --custom" "List custom models"+ run_plandex_cmd "set-model test-pack" "Set custom model pack"++ # test without required API key+ PREV_KEY=$OPENROUTER_API_KEY+ unset OPENROUTER_API_KEY+ expect_plandex_failure "tell 'write a hello world program in Go'" "Tell with custom models (should fail due to missing API key)"++ # restore API key+ export OPENROUTER_API_KEY=$PREV_KEY+ run_plandex_cmd "tell 'write a hello world program in Go'" "Tell with custom models"++ log "\n=== Custom Models Test Completed at $(date) ==="+}++# Run the tests+main\ No newline at end of filediff --git a/test/test_utils.sh b/test/test_utils.shnew file mode 100755index 00000000..75b53379--- /dev/null+++ b/test/test_utils.sh@@ -0,0 +1,146 @@+#!/bin/bash+# test-utils.sh - Common utilities for Plandex test scripts++export PLANDEX_ENV='development'++# Colors for output+export RED='\033[0;31m'+export GREEN='\033[0;32m'+export YELLOW='\033[1;33m'+export NC='\033[0m' # No Color++# Default command+export PLANDEX_CMD="${PLANDEX_CMD:-plandex-dev}"++# Logging 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"++ # Run command and capture output and exit code properly+ set +e # Temporarily disable exit on error+ output=$(eval "$cmd" 2>&1)+ local exit_code=$?+ set -e # Re-enable exit on error++ # Log the output+ echo "$output" | tee -a "$LOG_FILE"++ if [ "$exit_code" -eq 0 ]; then+ success "$description"+ else+ error "$description failed (exit code: $exit_code)"+ fi+}++# Run plandex command+run_plandex_cmd() {+ local cmd="$1"+ local description="$2"+ run_cmd "$PLANDEX_CMD $cmd" "$description"+}++# Run plandex command and check if output contains substring+check_plandex_contains() {+ local cmd="$1"+ local expected="$2"+ local description="$3"++ info "Running: $PLANDEX_CMD $cmd"++ local output=$($PLANDEX_CMD $cmd 2>&1)+ echo "$output" | tee -a "$LOG_FILE"++ if echo "$output" | grep -q "$expected"; then+ success "$description"+ else+ error "$description - expected to find '$expected'"+ fi+}++# Check if command fails (expecting failure)+expect_failure() {+ local cmd="$1"+ local description="$2"++ info "Running (expecting failure): $cmd"++ # Run the command and capture both output and exit code+ set +e # Temporarily disable exit on error+ output=$(eval "$cmd" 2>&1)+ local exit_code=$?+ set -e # Re-enable exit on error++ echo "$output" | tee -a "$LOG_FILE"++ if [ "$exit_code" -ne 0 ]; then+ success "$description (failed as expected with exit code $exit_code)"+ else+ error "$description should have failed but succeeded (exit code: $exit_code)"+ fi+}++# Expect plandex command to fail+expect_plandex_failure() {+ local cmd="$1"+ local description="$2"+ expect_failure "$PLANDEX_CMD $cmd" "$description"+}++# Check if file exists+check_file() {+ if [ -f "$1" ]; then+ success "File exists: $1"+ else+ error "File missing: $1"+ fi+}++# Setup test environment+setup_test_dir() {+ source ../.env.client-keys++ local test_name="$1"+ TEST_DIR="/tmp/plandex-${test_name}-$$"+ TIMESTAMP=$(date +%Y%m%d_%H%M%S)+ LOG_FILE="${TEST_DIR}/${test_name}-${TIMESTAMP}.log"++ info "Setting up test environment in $TEST_DIR"+ mkdir -p "$TEST_DIR"+ cd "$TEST_DIR"+ touch "$LOG_FILE"++ success "Test environment created"+}++# Cleanup function+cleanup_test_dir() {+ info "Cleaning up test environment"+ cd /+ rm -rf "$TEST_DIR"+ success "Cleanup complete"+}\ No newline at end of file