Skip to content

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

prompt refinements to encourage modularity and smaller files, discourage attempts to generate binary files like images, and simplify _apply.sh script

Dane Schneider46fe050ce0a0
diff --git a/app/cli/cmd/plan_start_helpers.go b/app/cli/cmd/plan_start_helpers.go
index 7ad1f5e9..5e5448b2 100644
--- a/app/cli/cmd/plan_start_helpers.go
+++ b/app/cli/cmd/plan_start_helpers.go
@@ -26,6 +26,7 @@ var (
strongModels bool
ossModels bool
cheapModels bool
+ geminiExpModels bool
// crazyModels bool
)
@@ -43,6 +44,7 @@ func AddNewPlanFlags(cmd *cobra.Command) {
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(&geminiExpModels, "gemini-exp", false, shared.GeminiExperimentalModelPack.Description)
// cmd.Flags().BoolVar(&crazyModels, "crazy", false, shared.CrazyModelPack.Description)
}
diff --git a/app/cli/cmd/repl.go b/app/cli/cmd/repl.go
index cad2bdcf..20c9f169 100644
--- a/app/cli/cmd/repl.go
+++ b/app/cli/cmd/repl.go
@@ -128,6 +128,8 @@ func runRepl(cmd *cobra.Command, args []string) {
args = append(args, "--daily")
} else if reasoningModels {
args = append(args, "--reasoning")
+ } else if geminiExpModels {
+ args = append(args, "--gemini-exp")
}
newCmd.Run(newCmd, args)
@@ -431,9 +433,14 @@ func executor(in string, p *prompt.Prompt) {
return
case cmd == "send" || cmd == lib.ReplCmdAliases["send"]:
- split := strings.Split(condensedInput, "\\s")
- condensedInput = strings.TrimSpace(split[0])
+ condensedSplit := strings.Split(condensedInput, "\\s")
+ condensedInput = strings.TrimSpace(condensedSplit[0])
condensedInput = strings.TrimSpace(condensedInput)
+
+ trimmedSplit := strings.Split(trimmedInput, "\\s")
+ trimmedInput = strings.TrimSpace(trimmedSplit[0])
+ trimmedInput = strings.TrimSpace(trimmedInput)
+
if condensedInput == "" {
fmt.Println()
fmt.Println("🤷‍♂️ No prompt to send")
diff --git a/app/cli/term/help.go b/app/cli/term/help.go
index 8b02601d..f93f0064 100644
--- a/app/cli/term/help.go
+++ b/app/cli/term/help.go
@@ -43,6 +43,7 @@ var CliCommands = []CmdConfig{
{"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 --gemini-exp", "", fmt.Sprintf("start a new plan with %s model pack", "'gemini-exp'"), 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},
@@ -122,6 +123,7 @@ var CliCommands = []CmdConfig{
{"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 gemini-exp", "", fmt.Sprintf("Use %s model pack", "'gemini-exp'"), true},
// {"set-model crazy", "", fmt.Sprintf("Use %s model pack", "'crazy'"), true},
{"ps", "", "list active and recently finished plan streams", true},
@@ -336,7 +338,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 --reasoning", "new --strong", "new --cheap", "new --oss" /*"new --crazy"*/)
+ 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 --gemini-exp" /*"new --crazy"*/)
fmt.Fprintln(builder)
fmt.Print(builder.String())
diff --git a/app/server/model/prompts/apply_exec.go b/app/server/model/prompts/apply_exec.go
index 953684ab..6c956e1f 100644
--- a/app/server/model/prompts/apply_exec.go
+++ b/app/server/model/prompts/apply_exec.go
@@ -41,7 +41,78 @@ The _apply.sh script should be lightweight and shouldn't do too much work. *Offl
Do not use fancy bash constructs that can be difficult to debug or cause portability problems. Keep it very straightforward so there's a 0% chance of bugs in the _apply.sh script.
+ABSOLUTELY DO NOT use the _apply.sh script to generate config files, project files, instructions, documentation, or any other necessary files. The _apply.sh script MUST NOT create files or directories—this must be done ONLY with code blocks. Create those files like any other files in the plan using code blocks. Do NOT include any large context blocks of any kind in the _apply.sh script. Use separate files for large content. Keep the _apply.sh script lightweight, simple, and focused only on executing necessary commands.
+#### Startup Logic
+
+` + ApplyScriptStartupLogic + `
+
+❌ DO NOT include complex startup logic or commands with flags in _apply.sh:
+
+- _apply.sh:
+<PlandexBlock lang="bash" path="_apply.sh">
+echo "Importing project resources..."
+godot --headless --quit
+
+# Check if the main scene file exists
+if [ ! -f "scenes/main.tscn" ]; then
+ echo "Error: Main scene file 'scenes/main.tscn' not found."
+ exit 1
+fi
+
+echo "Validating main scene file..."
+if ! godot --headless --check-only --quit scenes/main.tscn; then
+ echo "Error: The main scene file 'scenes/main.tscn' contains errors."
+ exit 1
+fi
+
+echo "Checking for resource loading issues..."
+if ! godot --headless --check-only --quit project.godot; then
+ echo "Error: The project contains resource loading issues."
+ exit 1
+fi
+
+echo "Starting Godot project..."
+godot --position 100,100 --resolution 1280x720 --verbose
+</PlandexBlock>
+
+✅ DO include complex startup logic or commands with flags in a *separate file* in the project, created with a *code block*, not in _apply.sh:
+
+- run.sh:
+<PlandexBlock lang="bash" path="run.sh">
+#!/bin/bash
+set -euo pipefail
+
+echo "Importing project resources..."
+godot --headless --quit
+
+# Check if the main scene file exists
+if [ ! -f "scenes/main.tscn" ]; then
+ echo "Error: Main scene file 'scenes/main.tscn' not found."
+ exit 1
+fi
+
+echo "Validating main scene file..."
+if ! godot --headless --check-only --quit scenes/main.tscn; then
+ echo "Error: The main scene file 'scenes/main.tscn' contains errors."
+ exit 1
+fi
+
+echo "Checking for resource loading issues..."
+if ! godot --headless --check-only --quit project.godot; then
+ echo "Error: The project contains resource loading issues."
+ exit 1
+fi
+
+echo "Starting Godot project..."
+godot --position 100,100 --resolution 1280x720 --verbose
+</PlandexBlock>
+
+- _apply.sh:
+<PlandexBlock lang="bash" path="_apply.sh">
+chmod +x run.sh
+./run.sh
+</PlandexBlock>
#### Command Preservation Rules
@@ -116,6 +187,7 @@ Running programs:
* CRITICAL: ALWAYS run the server in the background using & or the script will block and never reach the browser launch
* Add a brief sleep to allow the server to start (use your judgment based on the server type and the complexity of the server startup process how long is reasonable)
* ALWAYS use the special command 'plandex browser [urls...]' to launch the browser with one or more URLs. This command is provided by Plandex and is available on all operating systems. Substitute the actual URL or URLs you want to open in place of [urls...]. This special command *blocks* and streams the browser output to the console. So if you need to run other commands *after* the browser is launched, you must background the browser command and correclty handle cleanup like other background processes. If the browser command exits with an error, kill any other background processes and exit the entire script with a non-zero exit code.
+ - ALWAYS use 'plandex browser' to open the browser and load urls. Do NOT use 'open' or 'xdg-open' or any other command to open the browser. USE 'plandex browser' instead.
Example:
# INCORRECT - will block and never launch browser:
npm start
@@ -840,6 +912,7 @@ Browser Commands:
- This special command *blocks* and streams the browser output to the console.
- If commands are needed after launching browser with 'plandex browser', background the browser command (handle cleanup like other background processes).
- If the browser command exits with an error, kill any other background processes and exit the entire script with a non-zero exit code.
+- ALWAYS use 'plandex browser' to open the browser and load urls. Do NOT use 'open' or 'xdg-open' or any other command to open the browser. USE 'plandex browser' instead.
Error Handling:
- Check for required tools
@@ -992,6 +1065,9 @@ CRITICAL: The script must handle both program execution and security carefully:
- Use portable bash that will work across a wide range of Unix-like operating systems and shell versions.
- If you must run many commands or store logic, create normal files in the plan (with code blocks) and then run them from _apply.sh.
- Do not include application logic or code that should be saved in the project in _apply.sh. Write it in normal files in the plan instead. _apply.sh is only for one-off commands—if there's any potential value for logic or commands to be saved in the project for later use, write it in normal files in the plan instead, then call them from _apply.sh.
+ - Do NOT use the _apply.sh script to create files or directories of any kind. This must be done ONLY with code blocks.
+ - Do NOT include large context blocks of any kind in the _apply.sh script. Use separate files for large content. Keep the _apply.sh script lightweight, simple, and focused only on executing necessary commands.
+` + ApplyScriptStartupLogic + `
Remember:
- Do NOT tell the user to run _apply.sh. It will be run automatically when the plan is applied.
@@ -1054,3 +1130,9 @@ DO NOT update the _apply.sh script unless it is necessary to fix the problem. If
const ExitCodePrompt = `
Apart from _apply.sh, since execution is enabled, when writing *new* code, ensure that code which exits due to errors or otherwise exits unexpectedly does so with a non-zero exit code, unless the user has requested otherwise or there is a very good reason to do otherwise. Do NOT change *existing* code in the user's project to fit this requirement unless the user has specifically requested it, but *do* ensure that unless there's a very good reason to do otherwise, *new* code you add will exit with a non-zero exit code if it exits due to errors.
`
+
+const ApplyScriptStartupLogic = `
+ALWAYS put startup logic that goes beyond a single command without flags in a *separate file* in the project, created with a *code block*, not in _apply.sh. Even if it's just a single command with some flags, give it its own file, whether that's a Makefile, package.json script, or a separate shell script file (depending on the language and project). This startup logic should follow similar guidelines as the _apply.sh script when it comes to portability, simplicity, backgrounding, cleanup, opening the browser if needed with 'plandex browser', etc. This startup logic should then be called from _apply.sh. It should also be given execution permissions in the _apply.sh script if needed.
+
+In startup scripts and _apply.sh, DO THE MINIMUM NECESSARY. Do not include extra options or ways of starting the project. Avoid conditional logic unless it's truly necessary. Don't output messages to the console. Don't include verbose logging. Don't include verbose comments. Keep it simple, short, and minimal. KEEP IT SIMPLE. Your goal is to accomplish the user's task. No less and no more. Don't go beyond what the user has asked for.
+`
diff --git a/app/server/model/prompts/planning.go b/app/server/model/prompts/planning.go
index f693f49c..7f331878 100644
--- a/app/server/model/prompts/planning.go
+++ b/app/server/model/prompts/planning.go
@@ -126,6 +126,10 @@ func GetPlanningPrompt(params CreatePromptParams) string {
- In the list of subtasks, be sure you are including *every* task needed to complete the plan. Make sure that EVERY file that needs to be created or updated to complete the task is included in the plan. Do NOT leave out any files that need to be created or updated. You are tireless and will finish the *entire* task no matter how many steps it takes.
+ - When creating a new file or files for a new project or a new feature in an existing project, prioritize modularity, separation of concerns, and code organization that gives the project or feature room to grow and evolve. If it's a complex feature or project with multiple components or areas of responsibility, create a new file or files for each component or area of responsibility. Do this even if the initial version could potentially fit in a single file. Think ahead and try to keep files small, modular, and focused.
+
+ - Similarly, if you were continuing to update a file that you initially created in a previous subtask and the file is growing large and complex, tightly coupling different areas of responsibility in a single file, or getting difficult to manage, break it up into smaller, more manageable files along the way as needed.
+
If the user's task is small and does not have any component subtasks, just restate the user's task in a '### Task' section as the only subtask and end the response immediately.
`
@@ -277,6 +281,8 @@ You are always able to create and update files. Whether you are able to execute
Images may be added to the context, but you are not able to create or update images.
+Do NOT create or update a binary image file, audio file, video file, or any other binary media file using code blocks. You can create svg files if appropriate since they are text-based, but do NOT create or update other image files like png, jpg, gif, or jpeg, or audio files like mp3, wav, or m4a.
+
## Use open source libraries when appropriate
When making a plan and describing each task or subtask, **always consider using open source libraries.** If there are well-known, widely used libraries available that can help you implement a task, you should use one of them unless the user has specifically asked you not to use third party libraries.
diff --git a/app/server/model/prompts/user_prompt.go b/app/server/model/prompts/user_prompt.go
index c4973183..9bdc68dc 100644
--- a/app/server/model/prompts/user_prompt.go
+++ b/app/server/model/prompts/user_prompt.go
@@ -14,6 +14,8 @@ If a high quality, well-respected open source library is available that can simp
The current UTC timestamp is: %s — this can be useful if you need to create a new file that includes the current date in the file name—database migrations, for example, often follow this pattern.
+Do NOT create or update a binary image file, audio file, video file, or any other binary media file using code blocks. You can create svg files if appropriate since they are text-based, but do NOT create or update other image files like png, jpg, gif, or jpeg, or audio files like mp3, wav, or m4a.
+
User's operating system details:
%s
@@ -78,6 +80,12 @@ Output a <PlandexFinish/> tag after the '### Tasks' section. NEVER output a '###
Use your judgment on the paths of new files you create. Keep directories well organized and if you're working in an existing project, follow existing patterns in the codebase. ALWAYS use *complete* *relative* paths for new files.
+Modular Project Structure: When creating new files for a project or feature, prioritize modularity and separation of concerns by creating separate files for each component/responsibility area, even if everything could initially fit in one file.
+
+Ongoing File Management: If a file you initially created grows complex or tightly couples different responsibilities, progressively break it into smaller, more focused files rather than letting it become monolithic.
+
+Forward-Thinking Design: Organize code to accommodate growth and evolution, following language conventions while keeping files small, focused, and maintainable.
+
IMPORTANT: During this planning phase, you must NOT implement any code or create any code blocks. Your ONLY JOB is to break down the work into subtasks. Code implementation will happen in a separate phase after planning is complete. The planning phase is ONLY for breaking the work into subtasks.
Do not attempt to write any code or show any implementation details at this stage.
diff --git a/app/shared/ai_models_packs.go b/app/shared/ai_models_packs.go
index 9afdf6a9..72581411 100644
--- a/app/shared/ai_models_packs.go
+++ b/app/shared/ai_models_packs.go
@@ -9,8 +9,9 @@ var OSSModelPack ModelPack
var CheapModelPack ModelPack
var AnthropicModelPack ModelPack
var OpenAIModelPack ModelPack
-var GeminiModelPack ModelPack
-var GeminiPlannerModelPack ModelPack
+
+// var GeminiModelPack ModelPack
+var GeminiExperimentalModelPack ModelPack
var R1PlannerModelPack ModelPack
var PerplexityPlannerModelPack ModelPack
@@ -20,10 +21,12 @@ var BuiltInModelPacks = []*ModelPack{
&StrongModelPack,
&CheapModelPack,
&OSSModelPack,
+ // &GeminiPlannerModelPack,
// &CrazyModelPack,
&AnthropicModelPack,
&OpenAIModelPack,
- &GeminiPlannerModelPack,
+ // &GeminiModelPack,
+ &GeminiExperimentalModelPack,
&R1PlannerModelPack,
&PerplexityPlannerModelPack,
}
@@ -53,12 +56,6 @@ func init() {
Builder: *openaio3miniMedium(ModelRoleBuilder, &modelConfig{
strongModel: openaio3miniHigh(ModelRoleBuilder, nil),
}),
-
- // This is interesting with predicted outputs/speculative decoding for small files, but isn't working well with current prompting strategy... o3-mini is much faster when there's early divergence in predicted output, and is also much cheaper, and takes advantage of caching more effectively, so sticking with that for now for all file sizes
- // WholeFileBuilder: openai4o(ModelRoleWholeFileBuilder, &modelConfigFallbacks{
- // largeOutputFallback: openaio3miniMedium(ModelRoleWholeFileBuilder, nil),
- // }),
-
WholeFileBuilder: openaio3miniMedium(ModelRoleWholeFileBuilder, nil),
Namer: *openai4omini(ModelRoleName, nil),
CommitMsg: *openai4omini(ModelRoleCommitMsg, nil),
@@ -165,7 +162,7 @@ func init() {
WholeFileBuilder: openaio3miniLow(ModelRoleWholeFileBuilder, nil),
Namer: *openai4omini(ModelRoleName, nil),
CommitMsg: *openai4omini(ModelRoleCommitMsg, nil),
- ExecStatus: *openaio3miniMedium(ModelRoleExecStatus, nil),
+ ExecStatus: *openaio3miniLow(ModelRoleExecStatus, nil),
}
AnthropicModelPack = ModelPack{
@@ -183,36 +180,38 @@ func init() {
ExecStatus: *claude37Sonnet(ModelRoleExecStatus, nil),
}
- GeminiModelPack = ModelPack{
- Name: "gemini-experimental",
- Description: "Uses Gemini 2.5 Pro experimental (free) for heavy lifting, Gemini Flash 2.0 for light tasks. Supports up to 1M input context.",
- Planner: PlannerRoleConfig{
- ModelRoleConfig: *geminipro25exp(ModelRolePlanner, nil),
- PlannerModelConfig: getPlannerModelConfig(ModelProviderOpenRouter, "google/gemini-2.5-pro-exp-03-25:free"),
- },
- Coder: geminipro25exp(ModelRoleCoder, nil),
- PlanSummary: *geminiflash20(ModelRolePlanSummary, nil),
- Builder: *geminipro25exp(ModelRoleBuilder, nil),
- WholeFileBuilder: geminipro25exp(ModelRoleWholeFileBuilder, nil),
- Namer: *geminiflash20(ModelRoleName, nil),
- CommitMsg: *geminiflash20(ModelRoleCommitMsg, nil),
- ExecStatus: *geminipro25exp(ModelRoleExecStatus, nil),
- }
+ // GeminiModelPack = ModelPack{
+ // Name: "gemini-experimental",
+ // Description: "Uses Gemini 2.5 Pro experimental (free) for heavy lifting, Gemini Flash 2.0 for light tasks. Supports up to 1M input context.",
+ // Planner: PlannerRoleConfig{
+ // ModelRoleConfig: *geminipro25exp(ModelRolePlanner, nil),
+ // PlannerModelConfig: getPlannerModelConfig(ModelProviderOpenRouter, "google/gemini-2.5-pro-exp-03-25:free"),
+ // },
+ // Coder: geminipro25exp(ModelRoleCoder, nil),
+ // PlanSummary: *geminiflash20(ModelRolePlanSummary, nil),
+ // Builder: *geminipro25exp(ModelRoleBuilder, nil),
+ // WholeFileBuilder: geminipro25exp(ModelRoleWholeFileBuilder, nil),
+ // Namer: *geminiflash20(ModelRoleName, nil),
+ // CommitMsg: *geminiflash20(ModelRoleCommitMsg, nil),
+ // ExecStatus: *geminipro25exp(ModelRoleExecStatus, nil),
+ // }
- GeminiPlannerModelPack = ModelPack{
- Name: "gemini-planner",
- Description: "Uses Gemini 2.5 Pro Experimental for planning, Gemini Flash for light tasks, and default models for implementation. Supports up to 1M input context.",
+ GeminiExperimentalModelPack = ModelPack{
+ Name: "gemini-exp",
+ Description: "Uses Gemini 2.5 Pro Experimental for planning and coding, default models for other roles. Supports up to 1M input context.",
Planner: PlannerRoleConfig{
ModelRoleConfig: *geminipro25exp(ModelRolePlanner, nil),
PlannerModelConfig: getPlannerModelConfig(ModelProviderOpenRouter, "google/gemini-2.5-pro-exp-03-25:free"),
},
- Coder: claude37Sonnet(ModelRoleCoder, nil),
- PlanSummary: *geminiflash20(ModelRolePlanSummary, nil),
- Builder: *openaio3miniMedium(ModelRoleBuilder, nil),
- WholeFileBuilder: openaio3miniLow(ModelRoleWholeFileBuilder, nil),
- Namer: *geminiflash20(ModelRoleName, nil),
- CommitMsg: *geminiflash20(ModelRoleCommitMsg, nil),
- ExecStatus: *openaio3miniMedium(ModelRoleExecStatus, nil),
+ Coder: geminipro25exp(ModelRoleCoder, nil),
+ PlanSummary: *openaio3miniLow(ModelRolePlanSummary, nil),
+ Builder: *openaio3miniMedium(ModelRoleBuilder, &modelConfig{
+ strongModel: openaio3miniHigh(ModelRoleBuilder, nil),
+ }),
+ WholeFileBuilder: openaio3miniMedium(ModelRoleWholeFileBuilder, nil),
+ Namer: *openai4omini(ModelRoleName, nil),
+ CommitMsg: *openai4omini(ModelRoleCommitMsg, nil),
+ ExecStatus: *openaio3miniLow(ModelRoleExecStatus, nil),
}
R1PlannerModelPack = ModelPack{
diff --git a/docs/docs/cli-reference.md b/docs/docs/cli-reference.md
index a2a5370c..5d9c74dd 100644
--- a/docs/docs/cli-reference.md
+++ b/docs/docs/cli-reference.md
@@ -67,6 +67,7 @@ The REPL has a few convenient flags you can use to start it with different modes
--strong Strong pack (more capable models, higher cost and slower)
--cheap Cheap pack (less capable models, lower cost and faster)
--oss Open source pack (open source models)
+ --gemini-exp Gemini experimental pack (Gemini 2.5 Pro Experimental for planning and coding, default models for other roles)
```
All commands listed below can be run in the REPL by prefixing them with a backslash (`\`), e.g. `\new`.
@@ -106,6 +107,8 @@ plandex new -n new-plan # with name
`--oss`: Start the plan with the open source model pack.
+`--gemini-exp`: Start the plan with the Gemini experimental model pack.
+
### plans
List plans. Output includes index, when each plan was last updated, the current branch of each plan, the number of tokens in context, and the number of tokens in the conversation (prior to summarization).
diff --git a/docs/docs/repl.md b/docs/docs/repl.md
index 33a6f589..b7b3c4f7 100644
--- a/docs/docs/repl.md
+++ b/docs/docs/repl.md
@@ -49,4 +49,5 @@ The REPL has a few convenient flags you can use to start it with different modes
--strong Strong pack (more capable models, higher cost and slower)
--cheap Cheap pack (less capable models, lower cost and faster)
--oss Open source pack (open source models)
+ --gemini-exp Gemini experimental pack (Gemini 2.5 Pro Experimental for planning and coding, default models for other roles)
```