Skip to content

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

lots of work on execution prompts

Dane Schneiderfac00f739b39
diff --git a/app/server/model/plan/tell_context.go b/app/server/model/plan/tell_context.go
index 4ea5f23e..e6de46d6 100644
--- a/app/server/model/plan/tell_context.go
+++ b/app/server/model/plan/tell_context.go
@@ -117,15 +117,27 @@ func (state *activeTellStreamState) formatModelContext(includeMaps, includeTrees
// don't show _apply.sh history and content if smart context is enabled and the current subtask doesn't use it
!(isImplementationStage && smartContextEnabled && state.currentSubtask != nil && !uses["_apply.sh"]) {
- contextMessages = append(contextMessages, state.currentPlanState.ExecHistory())
+ execHistory := state.currentPlanState.ExecHistory()
+
+ contextMessages = append(contextMessages, execHistory)
scriptContent, ok := state.currentPlanState.CurrentPlanFiles.Files["_apply.sh"]
+ var isEmpty bool
if !ok || scriptContent == "" {
scriptContent = "[empty]"
+ isEmpty = true
}
contextMessages = append(contextMessages, "*Current* state of _apply.sh script:")
contextMessages = append(contextMessages, fmt.Sprintf("\n\n- _apply.sh:\n\n```\n%s\n```", scriptContent))
+
+ if isEmpty && state.isPlanningStage && !state.isContextStage {
+ contextMessages = append(contextMessages, "The _apply.sh script is *empty*. You ABSOLUTELY MUST include a '### Commands' section in your response prior to the '### Tasks' section that evaluates whether any commands should be written to _apply.sh during the plan. This is MANDATORY. Do NOT UNDER ANY CIRCUMSTANCES omit this section.")
+
+ if execHistory != "" {
+ contextMessages = append(contextMessages, "Consider the history of previously executed _apply.sh scripts when determining which commands to include in the new _apply.sh file. Are there any commands that should be run again after code changes? If so, mention them in the '### Commands' section and then include a task to include them in the _apply.sh file in the '### Tasks' section.")
+ }
+ }
}
return strings.Join(contextMessages, "\n\n") + "\n\n### END OF CONTEXT ###\n\n", nil
@@ -142,10 +154,6 @@ func (state *activeTellStreamState) checkAutoLoadContext() []string {
return nil
}
- if state.req.IsUserContinue {
- return nil
- }
-
if state.req.IsChatOnly && state.iteration > 0 {
return nil
}
diff --git a/app/server/model/plan/tell_missing_file.go b/app/server/model/plan/tell_missing_file.go
index 5c4505ba..97af88e6 100644
--- a/app/server/model/plan/tell_missing_file.go
+++ b/app/server/model/plan/tell_missing_file.go
@@ -68,7 +68,20 @@ func (state *activeTellStreamState) handleMissingFileResponse(applyScriptSummary
if missingFileResponse == shared.RespondMissingFileChoiceSkip {
res := state.replyParser.FinishAndRead()
skipPrompt := prompts.GetSkipMissingFilePrompt(res.CurrentFilePath)
- prompt := prompts.GetWrappedPrompt(skipPrompt, req.OsDetails, applyScriptSummary, isPlanningStage, isFollowUp) + "\n\n" + skipPrompt // repetition of skip prompt to improve instruction following
+
+ params := prompts.UserPromptParams{
+ CreatePromptParams: prompts.CreatePromptParams{
+ ExecMode: req.ExecEnabled,
+ AutoContext: req.AutoContext,
+ },
+ Prompt: skipPrompt,
+ OsDetails: req.OsDetails,
+ IsPlanningStage: isPlanningStage,
+ IsFollowUp: isFollowUp,
+ ApplyScriptSummary: applyScriptSummary,
+ }
+
+ prompt := prompts.GetWrappedPrompt(params) + "\n\n" + skipPrompt // repetition of skip prompt to improve instruction following
state.messages = append(state.messages, openai.ChatCompletionMessage{
Role: openai.ChatMessageRoleUser,
@@ -77,7 +90,20 @@ func (state *activeTellStreamState) handleMissingFileResponse(applyScriptSummary
} else {
missingPrompt := prompts.GetMissingFileContinueGeneratingPrompt(res.CurrentFilePath)
- prompt := prompts.GetWrappedPrompt(missingPrompt, req.OsDetails, applyScriptSummary, isPlanningStage, isFollowUp) + "\n\n" + missingPrompt // repetition of missing prompt to improve instruction following
+
+ params := prompts.UserPromptParams{
+ CreatePromptParams: prompts.CreatePromptParams{
+ ExecMode: req.ExecEnabled,
+ AutoContext: req.AutoContext,
+ },
+ Prompt: missingPrompt,
+ OsDetails: req.OsDetails,
+ IsPlanningStage: isPlanningStage,
+ IsFollowUp: isFollowUp,
+ ApplyScriptSummary: applyScriptSummary,
+ }
+
+ prompt := prompts.GetWrappedPrompt(params) + "\n\n" + missingPrompt // repetition of missing prompt to improve instruction following
state.messages = append(state.messages, openai.ChatCompletionMessage{
Role: openai.ChatMessageRoleUser,
diff --git a/app/server/model/plan/tell_prompt_message.go b/app/server/model/plan/tell_prompt_message.go
index 33c975af..324b7784 100644
--- a/app/server/model/plan/tell_prompt_message.go
+++ b/app/server/model/plan/tell_prompt_message.go
@@ -16,7 +16,7 @@ func (state *activeTellStreamState) resolvePromptMessage(isPlanningStage, isCont
active := state.activePlan
isFollowUp := state.isFollowUp
- if isFollowUp && (req.IsApplyDebug || req.IsUserDebug) {
+ if isFollowUp && (req.IsApplyDebug) {
log.Println("resolvePromptMessage: IsApplyDebug or IsUserDebug - setting isFollowUp to false")
isFollowUp = false
}
@@ -81,9 +81,21 @@ func (state *activeTellStreamState) resolvePromptMessage(isPlanningStage, isCont
log.Println("User is continuing plan in tell mode. Last message was user message. Using last user message as prompt")
state.messages = state.messages[:len(state.messages)-1]
+
+ params := prompts.UserPromptParams{
+ CreatePromptParams: prompts.CreatePromptParams{
+ ExecMode: req.ExecEnabled,
+ AutoContext: req.AutoContext,
+ },
+ Prompt: lastMessage.Content,
+ OsDetails: req.OsDetails,
+ IsPlanningStage: isPlanningStage,
+ IsFollowUp: isFollowUp,
+ }
+
promptMessage = &openai.ChatCompletionMessage{
Role: openai.ChatMessageRoleUser,
- Content: prompts.GetWrappedPrompt(lastMessage.Content, req.OsDetails, applyScriptSummary, isPlanningStage, isFollowUp),
+ Content: prompts.GetWrappedPrompt(params),
}
state.userPrompt = lastMessage.Content
@@ -92,10 +104,21 @@ func (state *activeTellStreamState) resolvePromptMessage(isPlanningStage, isCont
// if the last message was an assistant message, we'll use the user continue prompt
log.Println("User is continuing plan in tell mode. Last message was assistant message. Using user continue prompt")
- // otherwise we'll use the continue prompt
+ params := prompts.UserPromptParams{
+ CreatePromptParams: prompts.CreatePromptParams{
+ ExecMode: req.ExecEnabled,
+ AutoContext: req.AutoContext,
+ },
+ Prompt: prompts.UserContinuePrompt,
+ OsDetails: req.OsDetails,
+ IsPlanningStage: isPlanningStage,
+ IsFollowUp: isFollowUp,
+ ApplyScriptSummary: applyScriptSummary,
+ }
+
promptMessage = &openai.ChatCompletionMessage{
Role: openai.ChatMessageRoleUser,
- Content: prompts.GetWrappedPrompt(prompts.UserContinuePrompt, req.OsDetails, applyScriptSummary, isPlanningStage, isFollowUp),
+ Content: prompts.GetWrappedPrompt(params),
}
}
@@ -120,7 +143,19 @@ func (state *activeTellStreamState) resolvePromptMessage(isPlanningStage, isCont
if isContextStage {
finalPrompt = prompt
} else {
- finalPrompt = prompts.GetWrappedPrompt(prompt, req.OsDetails, applyScriptSummary, isPlanningStage, isFollowUp)
+ params := prompts.UserPromptParams{
+ CreatePromptParams: prompts.CreatePromptParams{
+ ExecMode: req.ExecEnabled,
+ AutoContext: req.AutoContext,
+ },
+ Prompt: prompt,
+ OsDetails: req.OsDetails,
+ IsPlanningStage: isPlanningStage,
+ IsFollowUp: isFollowUp,
+ ApplyScriptSummary: applyScriptSummary,
+ }
+
+ finalPrompt = prompts.GetWrappedPrompt(params)
}
// log.Println("Final prompt:", finalPrompt)
diff --git a/app/server/model/plan/tell_sys_prompt.go b/app/server/model/plan/tell_sys_prompt.go
index 2ebf19fc..91121366 100644
--- a/app/server/model/plan/tell_sys_prompt.go
+++ b/app/server/model/plan/tell_sys_prompt.go
@@ -15,12 +15,14 @@ func (state *activeTellStreamState) getTellSysPrompt(autoContextEnabled, smartCo
var sysCreate string
+ params := prompts.CreatePromptParams{
+ ExecMode: req.ExecEnabled,
+ AutoContext: autoContextEnabled,
+ LastResponseLoadedContext: didLoadChatOnlyContext,
+ }
+
if req.IsChatOnly {
- sysCreate = prompts.GetChatSysPrompt(prompts.CreatePromptParams{
- ExecMode: req.ExecEnabled,
- AutoContext: autoContextEnabled,
- LastResponseLoadedContext: didLoadChatOnlyContext,
- })
+ sysCreate = prompts.GetChatSysPrompt(params)
} else {
if isPlanningStage {
@@ -29,14 +31,14 @@ func (state *activeTellStreamState) getTellSysPrompt(autoContextEnabled, smartCo
log.Println("isContextStage", isContextStage)
if autoContextEnabled && isContextStage {
log.Println("autoContextEnabled && isContextStage -- adding auto context preamble")
- sysCreate = prompts.AutoContextTellPreamble
+ sysCreate = prompts.GetAutoContextTellPreamble(params)
} else if autoContextEnabled || smartContextEnabled {
log.Println("autoContextEnabled || smartContextEnabled -- adding auto context preamble")
sysCreate = prompts.SysPlanningAutoContext
- if isFollowUp && !req.IsApplyDebug && !req.IsUserDebug {
+ if isFollowUp && !req.IsApplyDebug {
log.Println("isFollowUp && !req.IsApplyDebug && !req.IsUserDebug -- adding follow up classifier prompt")
- sysCreate = prompts.FollowUpPlanClassifierPrompt + "\n\n" + sysCreate
+ sysCreate = prompts.GetFollowUpPlanClassifierPrompt(params) + "\n\n" + sysCreate
}
} else {
log.Println("sysPlanningBasic")
diff --git a/app/server/model/prompts/apply_exec.go b/app/server/model/prompts/apply_exec.go
index cc760e11..b65c9c37 100644
--- a/app/server/model/prompts/apply_exec.go
+++ b/app/server/model/prompts/apply_exec.go
@@ -73,6 +73,12 @@ For example, in an existing Node.js project:
✅ DO: Install only new packages needed for new features
✅ DO: Check for specific tools needed for new functionality
+#### Avoid Heavy Commands Unless Directed
+
+You must be conservative about running 'heavy' commands like tests that could be slow or resource intensive to run.
+
+This also applies to other potentially heavy commands like building Docker images. Use your best judgement.
+
#### Additional Requirements
Script execution:
@@ -176,6 +182,12 @@ CRITICAL rules:
- There must be NO lines between the file path and opening <PlandexBlock> tag
- Use lang="bash" in the <PlandexBlock> tag
+When writing to _apply.sh include an ### Action Explanation Format section, a file path label, and a <PlandexBlock> tag that includes both a 'lang' attribute and a 'path' attribute as described in the instructions above.
+
+If the current state of the _apply.sh script is *empty*, follow ALL instructions for *creating a new file* when writing to _apply.sh. Include the *entire* _apply.sh script in the code block.
+
+If the current state of the _apply.sh script is *not empty*, follow ALL instructions for *updating an existing file* when writing to _apply.sh.
+
### Command Output and Error Handling
DO NOT hide or filter command output. For example, DO NOT do this:
@@ -296,7 +308,7 @@ When the user applies the plan, the _apply.sh will be executed.
CRITICAL: The _apply.sh script accumulates ALL commands needed for the plan. Commands persist until successful application, when the script resets to an empty state. This reset ONLY happens after successful application.
-The current state of the _apply.sh script and history of previously executed scripts will be included in your prompt:
+The current state of the _apply.sh script and history of previously executed scripts will be included in your prompt in this format:
Previously executed _apply.sh:
` + "```" + `
@@ -322,45 +334,179 @@ The previously executed scripts show commands that ran successfully in past appl
const ApplyScriptResetUpdatePlanningPrompt = ApplyScriptResetUpdateSharedPrompt + `
## Planning with Script State
-When planning tasks and subtasks, consider how script state affects command organization:
+When planning tasks (and subtasks) that involve command execution, you must consider how the ` + "`_apply.sh`" + ` script evolves during the plan. ` + "`_apply.sh`" + ` accumulates commands until all changes are applied successfully; then, it resets to empty. This cycle repeats every time the user applies the plan and then continues to iterate on the plan.
-1. Command Accumulation
- - ALL commands persist until successful application
- - Group related commands in logical subtasks
- - Consider dependencies between commands
- - Plan command ordering carefully
+### 1. Command Accumulation
+- ALL commands in _apply.sh persist until successful application, at which point it is cleared
+- Group related commands in logical subtasks
+- Consider dependencies between commands
+- Plan command ordering carefully
-2. After Reset Planning
- - Consider what commands will need repeating
- - Think about dependencies between commands
- - Plan for proper command sequencing
- - Account for the full lifecycle of changes
+### 2. After Reset (Post-Success)
+- **Script Empties**: Once ` + "`_apply.sh`" + ` has been successfully executed, it’s cleared.
+- **No Unnecessary Repeats**: For future tasks, avoid re-adding commands (e.g., reinstalling dependencies) that already ran successfully, unless they are truly needed again.
+- **Include Necessary Commands**: If the user continues to iterate on the plan after a successful apply and reset of the _apply.sh script, make sure you *do* add any commands that need to run again for the next iteration. For example, if there is a command that runs the program, and the _apply.sh script has been reset to empty, you must include a step to run the program again.
-Common Command Patterns:
-- Build commands after source changes
-- Test commands after code changes
-- Start/run commands after backend changes
-- Database migrations after schema changes
-- Package installs after dependency changes
+### Common Command Patterns
-Example of Good Task Organization:
+- **Build Commands**: Run after source changes (e.g., ` + "`make`" + `, ` + "`npm run build`" + `, ` + "`cargo build`" + `).
+- **Test Commands**: Run after code changes that require verification (e.g., ` + "`npm test`" + `, ` + "`go test`" + `, etc.).
+- **Startup/Execution**: Start or run the program once built (e.g., ` + "`./app`" + `, ` + "`npm start`" + `).
+- **Database Migrations**: If schema changes are involved, add relevant migration commands.
+- **Package/Dependency Installs**: Add or update only if new libraries or tools are introduced.
-1. Add authentication feature
- - Update auth files
- - Add auth package installation commands
- - Include any necessary build steps
+### Example of Task Organization
+
+1. **Add Authentication Feature**
+ - Update or create relevant files (e.g. ` + "`auth_controller.js`" + `, ` + "`auth_routes.py`" + `).
+ - In ` + "`_apply.sh`" + `, install new auth-related dependencies (e.g. ` + "`npm install auth-lib`" + `).
+ - Include build or test commands if needed.
+
+2. **Add User Management**
+ - Update existing or create new user-management files.
+ - If new libraries are introduced, add them in ` + "`_apply.sh`" + ` (avoid re-installing old ones).
+ - Update existing build/test steps if relevant.
+
+3. **Final Build and Run**
+ - In ` + "`_apply.sh`" + `, include all final build commands (e.g. ` + "`make`" + `, ` + "`npm run build`" + `).
+ - Run the application if desired (e.g. ` + "`npm start`" + ` or ` + "`./myapp`" + `).
+ - If tests have changed, also include them here (e.g. ` + "`npm test`" + `).
+
+### Good Practices
+
+- **Check Script State**: If ` + "`_apply.sh`" + ` is not empty, modify existing commands in place. If it’s empty (post-success), add only new or relevant commands.
+- **Focus on Necessity**: Don't re-run installation for dependencies that were already installed.
+- **Be Systematic**: Keep installation commands grouped, then build commands, then run/test commands.
+
+### Final Reminder
+
+Plan your subtasks so that installation, build, and run commands appear **only where they’re actually required**—and be sure to keep them minimal after the script resets.
+
+### Always consider _apply.sh
+
+When planning and breaking down tasks, *always* consider whether a task for writing to the _apply.sh file is needed. Consider the current state of the _apply.sh file when making this decision.
+
+Imagine this scenario:
+
+1. You have previously made a plan for the user which included an _apply.sh file.
+2. The user then applied the plan, successfully applied the changes, and successfully executed the _apply.sh script, causing it to be reset to empty.
+3. The user sends a new prompt, wanting to fix or iterate on some aspect of the plan.
+
+Even if you are only making a small change to a single file based on the user's latest prompt, you *must* still consider the state of the (empty) _apply.sh file and whether it needs to be created again.
+
+If your updates to the _apply.sh file in step 1 were limited to "one time" actions, like installing dependencies, those likely shouldn't be run again (unless the prompt specifically requests that), so in that case you likely would not need a task for writing to the _apply.sh file.
+
+However, if your updates to the _apply.sh file in step 1 were to add commands that should be run after any change to the project, like building, running, or testing the program, then you *must* include a task for writing to the _apply.sh file.
+
+You may find that you are including a task for writing the same commands to the _apply.sh for each new iteration of the plan after a succesful apply and reset—this can be correct and expected.
+
+🔄 CRITICAL: _apply.sh RESET BEHAVIOR
+Remember, after successful execution, _apply.sh ALWAYS resets to empty.
+You MUST ALWAYS consider adding build/run commands again after ANY source changes.
+If the _apply.sh script previously had a build/run command, and then it was reset to empty after being successfully executed, and then you make ANY subsequent code changes, you MUST add a new build/run command to the _apply.sh file.
+
+INCORRECT FOLLOW UP:
+### Tasks
+1. Fix bug in source.c
+Uses: source.c
+<PlandexFinish/>
+
+CORRECT FOLLOW UP:
+### Commands
+
+The _apply.sh script is empty after the previous execution. Dependencies have already been installed, so we don't need to install them again. We'll need to build and run the code, so we'll need to add build and run commands to the _apply.sh file.
+
+### Tasks
+1. Fix bug in source.c
+Uses: source.c
+
+2. Build and run updated code
+Uses: _apply.sh
+<PlandexFinish/>
+
+BEFORE COMPLETING ANY PLAN:
+Consider:
+1. Are you modifying source files? If YES:
+ - Would it make sense to build/run the code after these changes?
+ - If so, is there a task for writing build/run commands to _apply.sh?
+ - If you're unsure what commands to run, better to omit them than guess
+2. Review the command history to avoid re-running unnecessary steps
+
+Examples:
+GOOD: Adding build/run after code changes
+BAD: Adding build/run when only updating comments or docs
+BAD: Guessing at commands when project structure or build/run commands are unclear
+
+### Always consider _apply.sh execution history
+
+Each version of _apply.sh that has been executed successfully is included in the context. Consider the history when determining which commands to include in the _apply.sh file. For example, if you see that a dependency was installed successfully in a previous _apply.sh, do NOT install that same dependency again unless the user has specifically requested it.
-2. Add user management
- - Update user management files
- - Add user management package commands
- - Update existing build commands if needed
+**IMMEDIATELY BEFORE any '### Tasks' section, you MUST output a '### Commands' section**
-3. Final build and run
- - Include all necessary build steps
- - Add test commands if tests were updated
- - Include program execution commands
+In the '### Commands' section, you MUST assess whether any commands should be written to _apply.sh during the plan based on the reasoning above. Do NOT omit this section.
-Remember: Commands should be organized to handle both the immediate changes and any necessary rebuilds or updates after future resets.
+Example:
+
+I will update the JSON display to use streaming and fix the out-of-memory issue.
+
+### Commands
+
+_apply.sh is empty. I'll add commands to build and run the updated code.
+
+### Tasks
+
+1. Update JSON display to use streaming
+Uses: source.c
+
+2. Build and run updated code
+Uses: _apply.sh
+<PlandexFinish/>
+
+Another example (with no commands):
+
+### Commands
+
+It's not totally clear to me from the context how to build or run the project, so I'll leave this step to you.
+
+### Tasks
+
+1. Update JSON display to use streaming
+Uses: source.c
+
+<PlandexFinish/>
+
+---
+
+### Command Inclusion Decision Tree
+
+When deciding whether to add commands to _apply.sh (and which ones), follow this guidance:
+
+1. **Are you modifying source/config files?**
+ * **No** → You typically don't need commands (e.g., if you're just updating docs or comments).
+ * **Yes** → Continue to step 2.
+
+2. **Would these changes benefit from a rebuild/run?**
+ * **No** (e.g., trivial style changes or commented-out code that won't affect runtime) → Skip commands.
+ * **Yes** (e.g., main logic changes that should be tested or run) → Continue to step 3.
+
+3. **Do you have enough context to identify the correct build/run commands?**
+ * **No** → Better to omit commands than guess. Possibly mention to the user that the build process is unclear.
+ * **Yes** → Continue to step 4.
+
+4. **Consider resource impact and user's preference.**
+ * **Is the command relatively lightweight** (e.g., a quick ` + "`make`" + ` or a single test file) **and clearly relevant**? → Go ahead and add it.
+ * **Is it heavy** (e.g., full integration tests, large Docker builds) **or uncertain**? → Mention it might be too large or unclear; consider skipping unless user specifically wants it.
+
+5. **Cross-check with previous _apply.sh commands**
+ * **Were dependencies or tools already installed in a previous iteration?** → Don't reinstall them.
+ * **Were certain build/test commands already used** and you're about to do the same thing? → Only include them again if you truly need to re-run.
+
+**If you decide to add commands**
+* Summarize why in the "### Commands" section (e.g., "We changed ` + "`main.c`" + ` so we need to rebuild and run to verify behavior.").
+* Then add a subtask referencing ` + "`_apply.sh`" + ` so the script is updated with exactly those commands.
+
+**If you decide to skip commands**
+* Still provide a "### Commands" section, but briefly note that no commands are needed (or that build/run process is unclear).
`
const ApplyScriptResetUpdateImplementationPrompt = ApplyScriptResetUpdateSharedPrompt + `
@@ -375,14 +521,17 @@ If the current state is empty:
- Review previously executed scripts
- Include commands needed for current changes
- Consider which previous commands need repeating
+- Follow ALL instructions for *creating a new file* with an ### Action Explanation Format section, a file path label, and a <PlandexBlock> tag that includes both a 'lang' attribute and a 'path' attribute as described in the instructions above.
+- Include the *entire* _apply.sh script in the code block.
### 2. Existing Script State
If the script is not empty, you must:
-1. Check the current script contents
-2. Preserve ALL existing commands exactly
-3. Add new commands while maintaining existing ones
-4. Verify no commands were accidentally removed/modified
+- Check the current script contents
+- Preserve ALL existing commands exactly
+- Add new commands while maintaining existing ones
+- Verify no commands were accidentally removed/modified
+- Follow ALL instructions for *updating an existing file* with an ### Action Explanation Format section, a file path label, and a <PlandexBlock> tag that includes both a 'lang' attribute and a 'path' attribute as described in the instructions above.
Example of proper script preservation:
@@ -463,6 +612,14 @@ Remember:
- Only install tools/packages that aren't already present
- Plan for proper error handling
- Focus on local over global changes
+- Always consider whether a task is needed for writing to the _apply.sh file, especially if the user is iterating on the plan after a successful apply and reset of the _apply.sh file
+- If the user is iterating on the plan and has previously applied the _apply.sh script, leaving it empty, make sure you only include appropriate commands for the next iteration of the plan—do not repeat commands that were already run successfully unless it makes sense to do so (like building, running, or testing the program)
+- Consider the history of previously executed _apply.sh scripts when determining which commands to include in the _apply.sh file. For example, if you see that a dependency was installed successfully in a previous _apply.sh, do NOT install that same dependency again unless the user has specifically requested it
+
+**IMMEDIATELY BEFORE any '### Tasks' section, you MUST output a '### Commands' section**
+
+In the '### Commands' section, you MUST assess whether any commands should be written to _apply.sh during the plan based on the reasoning above. Do NOT omit this section.
+
` + ApplyScriptResetUpdatePlanningSummary + ApplyScriptExecutionSummary
const ApplyScriptImplementationPromptSummary = `
@@ -471,6 +628,7 @@ Key implementation guidelines for _apply.sh:
Technical Requirements:
- ALWAYS use correct file path label: "- _apply.sh:"
- ALWAYS use <PlandexBlock lang="bash"> tags
+- ALWAYS follow your instructions for creating or updating files when writing to the _apply.sh file—treat it like any other file in the project
- NO lines between path and opening tag
- Show ALL command output (don't filter/hide)
- NO shebang or error handling (handled externally)
@@ -581,10 +739,8 @@ CRITICAL: The script must handle both program execution and security carefully:
1. Program Execution
- ALWAYS include commands to run the actual program after building/installing
- - Users should never need to run programs manually
+ - If there's a clear way to run the project, users should never need to run programs manually—always include commands to run the project in _apply.sh
- Include ALL necessary startup steps (build → install → run)
- - Launch any required services (databases, web servers, etc.)
- - Handle proper startup sequencing
2. Security Considerations
- BE EXTREMELY CAREFUL with system-modifying commands
@@ -600,6 +756,19 @@ CRITICAL: The script must handle both program execution and security carefully:
- Avoid system-wide installations unless specifically requested or there's no other way to accomplish the task
- Keep changes contained within project scope unless specifically requested or there's no other way to accomplish the task
- Use virtual environments where appropriate
+
+4. Be Practical And Make Reasonable Assumptions
+ - Be practical and make reasonable assumptions about the user's machine and project
+ - Don't assume that the user wants to install every single dependency under the sun—only install what is *absolutely* necessary to complete the task
+ - Make reasonable assumptions about what the user likely already has installed on their machine. If you're unsure, it's better to omit commands than to include incorrect ones or include overly heavy commands.
+
+5. Heavy Commands
+ - You must be conservative about running 'heavy' commands like tests that could be slow or resource intensive to run.
+ - This also applies to other potentially heavy commands like building Docker images. Use your best judgement.
+
+6. Less Is More
+ - If the plan involves adding a single test or a small number of tests, include commands to run *just those tests* by default in _apply.sh rather than running the entire test suite. Unless the user specifically asks for the entire test suite to be run, in which case you should always defer to the user's request.
+ - Apply the same principle to other commands. Be minimal and selective when choosing which commands to run.
`
var NoApplyScriptPrompt = `
@@ -634,5 +803,3 @@ DO NOT update the _apply.sh script unless it is necessary to fix the problem. If
**Follow all other instructions you've been given for the _apply.sh script.**
`
-
-var ApplyDebugPromptTokens int
diff --git a/app/server/model/prompts/chat.go b/app/server/model/prompts/chat.go
index 71511de2..ad509509 100644
--- a/app/server/model/prompts/chat.go
+++ b/app/server/model/prompts/chat.go
@@ -31,7 +31,7 @@ Since context was just loaded in the previous response:
- Continue the conversation naturally using the context you now have
- You ABSOLUTELY MUST NOT load additional context in your response`
} else {
- contextHandling = AutoContextChatPreamble
+ contextHandling = GetAutoContextChatPreamble(params)
}
} else {
contextHandling = `
diff --git a/app/server/model/prompts/context_load.go b/app/server/model/prompts/context_load.go
index e99d1381..8637ea00 100644
--- a/app/server/model/prompts/context_load.go
+++ b/app/server/model/prompts/context_load.go
@@ -1,6 +1,8 @@
package prompts
-const AutoContextTellPreamble = `
+func GetAutoContextTellPreamble(params CreatePromptParams) string {
+ s := `
+[RESPONSE INSTRUCTIONS:]
You are an expert architect. You are given a project and either a task or a conversational message or question. You must make a high level plan, focusing on architecture and design, weighing alternatives and tradeoffs. Based on that very high level plan, you then decide what context to load using the codebase map.
If you are responding to a project and a task, your plan will be expanded later into specific tasks. For now, paint in broad strokes and focus more on consideration of different potential approached, important tradeoffs, and potential pitfalls/gaps/unforeseen complexities. What are the viable ways to accomplish this task, and then what is the *BEST* way to accomplish this task?
@@ -8,25 +10,47 @@ If you are responding to a project and a task, your plan will be expanded later
Your high level plan should also be succint. Adapt the length to the size and complexity of the project and the prompt. For simple tasks, a few sentences are sufficient. For complex tasks, a few paragraphs are appropriate. For very complex tasks in large codebases, or for very large prompts, be as thorough as you need to be to make a good plan that can complete the task to an extremely high degree of reliability and accuracy. You can make very long high level plans with many goals and subtasks, but *ONLY* if the size and complexity of the project and the prompt justify it. Your DEFAULT should be *brevity* and *conciseness*. It's just that *how* brief and *how* concise should scale linearly with size, complexity, difficulty, and length of the prompt. If you can make a strong plan in very few words or sentences, do so.
If you are responding to a conversational message or question, adapt the instructions on plans to a conversational mode. The length should still be concise, but can scale up to a few paragraphs or even longer if it's appropriate to the project size and the complexity of the message or question.
+`
+
+ if params.ExecMode {
+ s += `
+*Execution mode is enabled* this means that you are able to run commands on the user's machine. Include consideration of any commands that may need to be run in your high level plan, especially commands for installing required dependencies or building and running the project.
+Do not 'force it' when it comes to running commands. Don't guess at commands to run—if you're unsure, it's better to omit commands than to include incorrect ones. Follow later instructions on '### Dependencies and Tools' for more details and other instructions related to execution mode and _apply.sh
+`
+ }
+
+ s += `
[CONTEXT INSTRUCTIONS:]
-You are operating in 'auto-context mode' for implementation. You have access to the directory layout of the project as well as a map of definitions (like function/method/class signatures, types, top-level variables, and so on).
+You are operating in 'auto-context mode'. You have access to the directory layout of the project as well as a map of definitions (like function/method/class signatures, types, top-level variables, and so on).
In response to the user's latest prompt, do the following IN ORDER:
- Decide whether you've been given enough information to load necessary context and make a plan (if you've been given a task) or give a helpful response to the user (if you're responding in chat form). In general, do your best with whatever information you've been provided. Only if you have very little to go on or something is clearly missing or unclear should you ask the user for more information. If you really don't have enough information, ask the user for more information and stop there. 'Information' here refers to direction from the user, not context, since you are able to load context yourself if needed when in auto-context mode.
- - Reply with a brief, high level overview of how you will approach implementing the task (if you've been given a task) or responding to the user (if you're responding in chat form). Since you are managing context automatically, there will be an additional step where you can make a more detailed plan with the context you load. Do not state that you are creating a final or comprehensive plan—that is not the purpose of this response. This is a high level overview that will lead to a more detailed plan with the context you load. Do not call this overview a 'plan'—the purpose is only to help you examine the codebase to determine what context to load. You will then make a plan in the next step.
+ - Reply with a brief, high level overview of how you will approach implementing the task (if you've been given a task) or responding to the user (if you're responding in chat form) according to [RESPONSE INSTRUCTIONS] above. Since you are managing context automatically, there will be an additional step where you can make a more detailed plan with the context you load. Do not state that you are creating a final or comprehensive plan—that is not the purpose of this response. This is a high level overview that will lead to a more detailed plan with the context you load. Do not call this overview a 'plan'—the purpose is only to help you examine the codebase to determine what context to load. You will then make a plan in the next step.
+`
+ if params.ExecMode {
+ s += `
+ - Since execution mode is enabled, include consideration of any commands that may need to be run in your high level plan as described in [RESPONSE INSTRUCTIONS] above. Follow later instructions on '### Dependencies and Tools' for more details and other instructions related to execution mode and _apply.sh.
+ `
+ }
+
+ s += `
- If you already have enough information from the project map and current context to make a detailed plan or respond effectively to the user and so you won't need to load any additional context, then explicitly say "No context needs to be loaded." and continue on to the instructions below. NEVER say "No context needs to be loaded." *after* you've already output the '### Context Categories' and '### Files' sections.
-` + AutoContextShared + `
+` + GetAutoContextShared(params, true) + `
[END OF CONTEXT INSTRUCTIONS]
`
-const AutoContextChatPreamble = `
+ return s
+}
+
+func GetAutoContextChatPreamble(params CreatePromptParams) string {
+ s := `
[CONTEXT INSTRUCTIONS:]
You are operating in 'auto-context mode' for chat. You have access to the directory layout of the project as well as a map of definitions.
@@ -44,16 +68,25 @@ If you need context:
- Briefly mention what you need to check, e.g. "Let me look at the relevant files..." or "Let me look at those functions..." — use your judgment and respond in a natural, conversational manner.
- Then proceed with the context loading format:
-` + AutoContextShared + `
+` + GetAutoContextShared(params, false) + `
Remember: Only load context when genuinely needed for accuracy. Avoid loading context in consecutive responses as this disrupts conversation flow.
[END OF CONTEXT INSTRUCTIONS]
`
-const AutoContextShared = `
-- In a section titled '### Context Categories', list one or more categories of context that are relevant to the user's task, question, or message. For example, if the user is asking you to implement an API endpoint, you might list 'API endpoints', 'database operations', 'frontend code', 'utilities', and so on. Make sure any and all relevant categories are included, but don't include more categories than necessary—if only a single category is relevant, then only list that one. Do not include file paths, symbols, or explanations—only the categories.
+ return s
+}
+
+func GetAutoContextShared(params CreatePromptParams, tellMode bool) string {
+ s := `
+- In a section titled '### Context Categories', list one or more categories of context that are relevant to the user's task, question, or message. For example, if the user is asking you to implement an API endpoint, you might list 'API endpoints', 'database operations', 'frontend code', 'utilities', and so on. Make sure any and all relevant categories are included, but don't include more categories than necessary—if only a single category is relevant, then only list that one. Do not include file paths, symbols, or explanations—only the categories.`
+
+ if tellMode && params.ExecMode {
+ s += `Since execution mode is enabled, consider including a category for context relating to installing required dependencies or building, and/or running the project. Adapt this to the user's project, task, and prompt. Don't force it—only include this category if it makes sense. Follow later instructions on '### Dependencies and Tools' for more details and other instructions related to execution mode and _apply.sh.`
+ }
+ s += `
- Using the project map in context, output a '### Files' list of potentially relevant *symbols* (like functions, methods, types, variables, etc.) that seem like they could be relevant to the user's task, question, or message based on their name, usage, or other context. Include the file path (surrounded by backticks) and the names of all potentially relevant symbols. File paths *absolutely must* be surrounded by backticks like this: ` + "`path/to/file.go`" + `. Any symbols that are referred to in the user's prompt must be included. You MUST organize the list by category using the categories from the '### Context Categories' section—ensure each category is represented in the list. When listing symbols, output just the name of the symbol, not it's full signature (e.g. don't include the function parameters or return type for a function—just the function name; don't include the type or the 'var/let/const' keywords for a variable—just the variable name, and so on). Output the symbols as a comma separated list in a single paragraph for each file. You MUST include relevant symbols (and associated file paths) for each category from the '### Context Categories' section. Along with important symbols, you can also include a *very brief* annotation on what makes this file relevant—like: (example implementation), (mentioned in prompt), etc. You also MUST make a brief note in the file is already loaded into context—a file is loaded into context if the *full file* is loaded (*not* only the map of the file's symbols and definitions). At the end of the list, output a <PlandexFinish/> tag.
- Immediately after the end of the '### Files' section list, you ABSOLUTELY MUST ALWAYS output a <PlandexFinish/> tag. You MUST NOT output any other text after the '### Files' section and you MUST NOT leave out the <PlandexFinish/> tag.
@@ -120,7 +153,29 @@ When listing files in the '### Files' section, make sure to include:
3. ALL similar feature files for reference
4. ALL utility files that might be related to the task or prompt
5. ALL files with reference relationships (like function calls, variable references, etc.)
+`
+
+ if tellMode && params.ExecMode {
+ s += `
+Since execution mode is enabled, make sure to include any files that are necessary and relevant to building and running the project. For example, if there is a Makefile, a package.json file, or equivalent, include it.
+
+If dependencies may be needed for the task and there are dependency files like requirements.txt, package.json, go.mod, Gemfile, or equivalent, include them.
+
+Follow later instructions on '### Dependencies and Tools' for more details and other instructions related to execution mode and _apply.sh.
+
+Don't force it or overdo it. Only include execution-related files that are clearly and obviously needed for the task and prompt, to see currently installed dependencies, or to build and run the project. For example, do NOT include an entire directory of test files. If the user has directed you to run tests, look for test files relevant to the task and prompt only, and files that make it clear how to run the tests.
+If the user has *not* directed you to run tests, don't assume that they should be run. You must be conservative about running 'heavy' commands like tests that could be slow or resource intensive to run.
+
+This also applies to other potentially heavy commands like building Docker images. Use your best judgement.
+`
+ }
+
+ s += `
After outputting the '### Files' section, end your response. Do not output any additional text after that section.
+***Critically Important:***
During this context loading phase, you must NOT implement any code or create any code blocks. This phase is ONLY for identifying relevant context.`
+
+ return s
+}
diff --git a/app/server/model/prompts/explanation_format.go b/app/server/model/prompts/explanation_format.go
index 7e0f082c..1b059a01 100644
--- a/app/server/model/prompts/explanation_format.go
+++ b/app/server/model/prompts/explanation_format.go
@@ -3,6 +3,8 @@ package prompts
const ChangeExplanationPrompt = `
### Action Explanation Format
+#### 1. Updating an existing file in context
+
Prior to any code block that is *updating* an existing file in context, you MUST explain the change in the following format EXACTLY:
---
@@ -70,7 +72,7 @@ For each Type, follow these validation rules:
- For 'overwrite':
- Summary MUST briefly describe the change and list the specific symbols/sections being changed or replaced
- Context field must be omitted
- - Preserve MUST *exhaustively* list all symbols/sections in the original file that should be included in the final result
+ - Preserve MUST *exhaustively* list all symbols/sections in the original file that should be included in the final result. Do *NOT* say that you are 'preserving nothing' because you are overwriting the entire file—the point what, if anything, will be *kept the same* from the original file, even though you are overwriting the whole file. Only say that you're preserving nothing if *nothing* will be kept the same from the original file and the new file will be completely new. The point of this field is to ensure that the final result is a *complete* and *correct* replacement of the original file, and that no important code is omitted.
In the Context, Summary, and Preserve fields, when listing code symbols, list them in a comma-separated list and surround them with backticks. For example, ` + "`foo`,`someFunc`, `someVar`" + `
@@ -249,4 +251,71 @@ Do NOT overwrite the entire file for very large files that cannot fit within a s
*
If the explanation includes a 'Preserve' field, be absolutely certain that the corresponding code block does *not* remove or replace any of the code listed in the 'Preserve' field.
+
+---
+
+#### 2. Creating a new file
+
+Prior to any code block that is *creating a new file*, you MUST explain the change in the following format EXACTLY:
+
+---
+**Creating ` + "`[file path]`" + `**
+Type: new file
+Summary: [brief description of the new file]
+---
+
+Include a line break after the initial '**Creating ` + "`[file path]`" + `**' line as well as each of the following fields. Use the exact same spacing and formatting as shown in the above format and in the examples further down.
+
+The Type field MUST be exactly 'new file'.
+The Summary field MUST briefly describe the new file and its purpose.
+
+Do NOT include the 'Context' or 'Preserve' fields when creating a new file. Just the 'Type' and 'Summary' fields are required.
+
+You ABSOLUTELY MUST use this template EXACTLY as described above.
+
+Example explanation for a *new file*:
+
+**Creating ` + "`server/handlers/auth.go`" + `**
+Type: new file
+Summary: Add new ` + "`auth`" + ` handler in the ` + "`server/handlers`" + ` directory
+
+- server/handlers/auth.go:
+<PlandexBlock lang="go" path="server/handlers/auth.go">
+package handlers
+
+func (api *API) authHandler(w http.ResponseWriter, r *http.Request) {
+ authHeader := r.Header.Get("Authorization")
+ if authHeader == "" {
+ http.Error(w, "Unauthorized", http.StatusUnauthorized)
+ return
+ }
+
+ valid := validateAuthHeader(authHeader)
+ if !valid {
+ http.Error(w, "Unauthorized", http.StatusUnauthorized)
+ return
+ }
+
+ session, err := api.sessionStore.Get(r, "session")
+ if err != nil {
+ http.Error(w, "Unauthorized", http.StatusUnauthorized)
+ return
+ }
+
+ response := &http.Response{
+ StatusCode: http.StatusOK,
+ Body: io.NopCloser(strings.NewReader("OK")),
+ }
+
+ json.NewEncoder(w).Encode(response)
+}
+</PlandexBlock>
+
+*
+
+For new files:
+ - You MUST ALWAYS include the *entire file* in the code block. Do not omit any code from the file.
+ - Do NOT use placeholder code or comments like '// implement authentication here' to indicate that the file is incomplete. Implement *all* functionality.
+ - Do NOT use reference comments like '// ... existing code ...'. Those are only used for updating existing files and *never* when creating new files.
+ - Include the *entire file* in the code block.
`
diff --git a/app/server/model/prompts/implement.go b/app/server/model/prompts/implement.go
index 4c6536b9..2f442b7c 100644
--- a/app/server/model/prompts/implement.go
+++ b/app/server/model/prompts/implement.go
@@ -11,13 +11,19 @@ func GetImplementationPrompt(subtask string) string {
prompt += `
[YOUR INSTRUCTIONS]
-Describe in detail the current task to be done and what your approach will be, then write out the code to complete the task. Include only lines that will change and lines that are necessary to know where the changes should be applied. Precede the code block with the file path like this '- file_path:'--for example:
+Describe in detail the current task to be done and what your approach will be, then write out the code to complete the task in a *code block*.
+
+If you are updating an existing file, include only lines that will change and lines that are necessary to know where the changes should be applied.
+
+If you are creating a new file that does not already exist in the project, include the entire file in the code block.
+
+Whether you are creating a new file or updating an existing file, you MUST ALWAYS precede the code block with the file path like this '- file_path:'--for example:
- src/main.rs:
- lib/term.go:
- main.py:
-Immediately after the file path, you MUST output an opening <PlandexBlock> tag. The <PlandexBlock> tag MUST include a 'lang' attribute that specifies the programming language of the code block. 'lang' attributes must match the corresponding Pygments short name for the language. Here is a list of valid language identifiers:
+Immediately after the file path, you MUST ALWAYS output an opening <PlandexBlock> tag. The <PlandexBlock> tag MUST include a 'lang' attribute that specifies the programming language of the code block. 'lang' attributes must match the corresponding Pygments short name for the language. Here is a list of valid language identifiers:
` + ValidLangIdentifiers + `
@@ -35,6 +41,13 @@ In a <PlandexBlock> tag attribute, the 'path' attribute MUST be the exact file p
***Do NOT include the file path again within the <PlandexBlock> tag's content, inside the code block itself. The file path must be included *only* in the file block label *preceding* the opening <PlandexBlock> tag and in the 'path' attribute of the <PlandexBlock> tag.***
+*ALL CODE* that you write MUST ALWAYS strictly follow this format, whether you are creating a new file or updating an existing file. First the file path label, then the opening <PlandexBlock> tag, then the code, then the closing </PlandexBlock> tag. You MUST NOT UNDER ANY CIRCUMSTANCES use any other format when writing code.
+
+- Do NOT write code within triple backticks. Always use the <PlandexBlock> tag.
+- Do NOT include anything except the code itself within the <PlandexBlock> tags. No other labels, text, or formatting. Just the code.
+- Do NOT omit the 'lang' or 'path' attributes from the <PlandexBlock> tag. EVERY <PlandexBlock> tag MUST ALWAYS have both 'lang' and 'path' attributes.
+- Do NOT omit the *file path label* before the <PlandexBlock> tag. Every code block MUST ALWAYS be preceded by a file path label.
+
Labelled code block example:
- src/game.h:
@@ -51,8 +64,6 @@ void updateGameLogic();
Always precede code blocks in a plan with the file path as described above. Code that is meant to be applied to a specific file in the plan must *always* be labelled with the path. Code to create a new file or update an existing file *MUST ALWAYS* be written in a correctly formatted code block with a file path label. You ABSOLUTELY MUST NOT leave out the file path label when writing a new file, updating an existing file, or writing to _apply.sh. ALWAYS include the file path label and the <PlandexBlock> opening and closing tags as described above.
-If code is being included for explanatory purposes and is not meant to update or create a specific file, you MUST NOT label the code block in the format described in 2a. Instead, output the code without a label. That said, if code is being written to complete the current subtask, it is NEVER for explanatory purposes. In that case, you MUST label the code block with a file path. Code is only for explanatory purposes when you are responding conversationally to the user and don't intend to update or create a specific file. For example, if you are describing a hypothetical change or writing code to describe a concept, but you don't actually intend to use that code in the user's project, then you can output the code without a label.
-
Every file you reference in a plan should either exist in the context directly or be a new file that will be created in the same base directory as a file in the context. For example, if there is a file in context at path 'lib/term.go', you can create a new file at path 'lib/utils_test.go' but *not* at path 'src/lib/term.go'. You can create new directories and sub-directories as needed, but they must be in the same base directory as a file in context. You must *never* create files with absolute paths like '/etc/config.txt'. All files must be created in the same base directory as a file in context, and paths must be relative to that base directory. You must *never* ask the user to create new files or directories--you must do that yourself.
**You must not include anything except valid code in labelled file blocks for code files.** You must not include explanatory text or bullet points in file blocks for code files. Only code. Explanatory text should come either before the file path or after the code block. The only exception is if the plan specifically requires a file to be generated in a non-code format, like a markdown file. In that case, you can include the non-code content in the file block. But if a file has an extension indicating that it is a code file, you must only include code in the file block for that file.
diff --git a/app/server/model/prompts/planning.go b/app/server/model/prompts/planning.go
index f9331393..e0b4dc9e 100644
--- a/app/server/model/prompts/planning.go
+++ b/app/server/model/prompts/planning.go
@@ -23,16 +23,17 @@ func GetPlanningPrompt(params CreatePromptParams) string {
*If the user doesn't have a task and is just asking a question or chatting, or if 'chat mode' is enabled*, ignore the rest of the instructions below, and respond to the user in chat form. You can make reference to the context to inform your response, and you can include code in your response, but you aren't able to create or update files.
- *If the user does have a task or if you're continuing a plan that is already in progress*, and if 'chat mode' is *not* enabled, create a plan for the task based on user-provided context using the following steps:
+ *If the user does have a task or if you're continuing a plan that is already in progress*, and if 'chat mode' is *not* enabled, create a plan for the task based on user-provided context using the following steps. Start by briefly responding coversationally to the user's prompt and thinking through any high level questions or concerns that will help you make an effective plan (do NOT include any code or implementation details). Then proceed with the following steps:
+
`
if params.AutoContext {
- prompt += `
+ prompt += `
1. Decide whether you've been given enough information to make a more detailed plan.
- In terms of information from the user's prompt, do your best with whatever information you've been provided. Choose sensible values and defaults where appropriate. Only if you have very little to go on or something is clearly missing or unclear should you ask the user for more information.
a. If you really don't have enough information from the user's prompt to make a plan:
- Explicitly say "I need more information to make a plan for this task."
- - Ask the user for more information and stop there.
+ - Ask the user for more information and stop there.
`
} else {
prompt += `
@@ -44,10 +45,35 @@ func GetPlanningPrompt(params CreatePromptParams) string {
`
}
- prompt += `
- 2. Divide the user's task into one or more component subtasks and list them in a numbered list in a '### Tasks' section. Subtasks MUST ALWAYS be numbered with INTEGERS (do NOT use letters or numbers with decimal points, just simple integers—1., 2., 3., etc.) Start from 1. Subtask numbers MUST be followed by a period and a space, then the subtask name, then any additional information about the subtask in bullet points, and then a comma-separated 'Uses:' list of the files that will be needed in context to complete each task. Include any files that will updated, as well as any other files that will be helpful in implementing the subtask. List files individually—do not list directories. List file paths exactly as they are in the directory layout and map, and surround them with single backticks like this: ` + "`src/main.rs`." + ` Subtasks MUST ALWAYS be listed in the '### Tasks' section in EXACTLY this format. Example:
+ if params.ExecMode {
+ prompt += `
+ 2a. Since *execution mode* is enabled, decide whether you should write any commands to the _apply.sh script in a '### Commands' section.
+ - Consider the current state and previous history of previously executed _apply.sh scripts when determining which commands should be included in the new _apply.sh file.
+ - Keep this section brief and high level. Do not write any code or implementation details here. Just assess whether any commands will need to be run during the plan.
+ - If you determine that there are commands that should be run, make sure they are included in the '### Tasks' section in the next step.
+ - Follow later instructions on '### Dependencies and Tools' for more details and other instructions related to execution mode and _apply.sh. Consider your instructions on *security considerations*, *local vs. global changes*, *making reasonable assumptions*, and *avoid heavy commands* when deciding whether to include commands in the _apply.sh file.
+
+ 2b.`
+ } else {
+ prompt += `2.`
+ }
+
+ prompt += `Divide the user's task into one or more component subtasks and list them in a numbered list in a '### Tasks' section. Subtasks MUST ALWAYS be numbered with INTEGERS (do NOT use letters or numbers with decimal points, just simple integers—1., 2., 3., etc.) Start from 1. Subtask numbers MUST be followed by a period and a space, then the subtask name, then any additional information about the subtask in bullet points, and then a comma-separated 'Uses:' list of the files that will be needed in context to complete each task. Include any files that will updated, as well as any other files that will be helpful in implementing the subtask. List files individually—do not list directories. List file paths exactly as they are in the directory layout and map, and surround them with single backticks like this: ` + "`src/main.rs`." + ` Subtasks MUST ALWAYS be listed in the '### Tasks' section in EXACTLY this format.
+
+ Example:
---
+`
+
+ if params.ExecMode {
+ prompt += `
+ ### Commands
+
+ We're starting a new plan and no commands have been executed yet. We'll need to install dependencies, then build and run the project.
+`
+ }
+
+ prompt += `
### Tasks
1. Create a new file called 'game_logic.h'
@@ -67,11 +93,21 @@ func GetPlanningPrompt(params CreatePromptParams) string {
5. Update the 'main.c' file to call the 'updateGameLogic' function
Uses: ` + "`src/main.c`" + `
+ `
+ if params.ExecMode {
+ prompt += `
+ 6. Create the _apply.sh file to install dependencies, then build and run the project
+ Uses: ` + "`_apply.sh`" + `
+ `
+ }
+ prompt += `
<PlandexFinish/>
---
- - After you have broken a task up in to multiple subtasks and output a '### Tasks' section, you *ABSOLUTELY MUST* output a <PlandexFinish/> tag and then end the response. You MUST ALWAYS output the <PlandexFinish/> tag at the end of the '### Tasks' section.
+ - After you have broken a task up in to multiple subtasks and output a '### Tasks' section, you *ABSOLUTELY MUST ALWAYS* output a <PlandexFinish/> tag and then end the response. You MUST ALWAYS output the <PlandexFinish/> tag at the end of the '### Tasks' section.
+
+ - Output a <PlandexFinish/> tag after the '### Tasks' section. NEVER output a '### Tasks' section without also outputting a <PlandexFinish/> tag.
` + ReviseSubtasksPrompt + `
@@ -89,8 +125,6 @@ func GetPlanningPrompt(params CreatePromptParams) string {
- Add a line break after between each subtask so the list of subtasks is easy to read.
- - Do NOT ask the user to confirm after you've made subtasks. After breaking up the task into subtasks, proceed to implement the first subtask.
-
- Be thoughtful about where to insert new code and consider this explicitly in your planning. Consider the best file and location in the file to insert the new code for each subtask. Be consistent with the structure of the existing codebase and the style of the code. Explain why the file(s) that you'll be updating (or creating) are the right place(s) to make the change. Keep consistent code organization in mind. If an existing file exists where certain code clearly belongs, do NOT create a new file for that code; stick to the existing codebase structure and organization, and use the appropriate file for the code.
- DO NOT include "fluffy" additional subtasks when breaking a task up. Only include subtasks and steps that are strictly in the realm of coding and doable ONLY through creating and updating files. Remember, you are listing these subtasks and steps so that you can execute them later. Only list things that YOU can do yourself with NO HELP from the user. Your goal is to *fully complete* the *exact task* the user has given you in as few tokens and responses as you can. This means only including *necessary* steps that *you can complete yourself*.
@@ -109,7 +143,7 @@ For many file types, codebase maps will include files in the project, along with
`
}
- prompt += UsesPrompt
+ prompt += getUsesPrompt(params)
prompt += `
## Responding to user questions
@@ -132,11 +166,22 @@ Do not attempt to write any code or show any implementation details at this stag
return prompt
}
-const UsesPrompt = `
+func getUsesPrompt(params CreatePromptParams) string {
+ s := `
- You MUST include a comma-separated 'Uses:' list of the files that will be needed in context to complete each task. Include any files that will updated, as well as any other files that will be helpful in implementing the subtask. ONLY the files you list under each subtask will be loaded when this subtask is implemented. List files individually—do not list directories. List file paths exactly as they are in the directory layout and map, and surround them with single backticks like this: ` + "`src/main.rs`." + `
Example:
+`
+ if params.ExecMode {
+ s += `
+### Commands
+
+The _apply.sh script already exists and includes commands to install dependencies, then build and run the project. No additional commands are needed at this stage.
+ `
+ }
+
+ s += `
---
### Tasks
@@ -164,6 +209,9 @@ If execution mode is enabled and a subtask creates, updates, or is related to th
- Remember that the 'Uses:' list can include reference files that aren't being modified. Don't combine multiple independent changes into a single subtask just because they need similar reference files - instead, list those reference files in the 'Uses:' section of each relevant subtask.
`
+ return s
+}
+
var UsesPromptNumTokens int
const SharedPlanningImplementationPrompt = `
@@ -222,77 +270,123 @@ Similarly, if you have made updates to any files, you MUST always work from the
`
-const FollowUpPlanClassifierPrompt = `
-When responding to follow-up prompts during a plan, first respond naturally to what the user has said or asked. Then, incorporate the following assessment seamlessly into your response:
-
-- Determine if the prompt is:
- A. An update/revision to the tasks in the current plan, including a new or distinct task
- B. A conversation prompt like a question or comment that does not indicate an update to the plan or a new task
-
-- If the prompt is A, determine if it is:
- A1. A small/minor update to or revision of the current plan
- A2. A significant update to or revision of the current plan
- A3. A new task that is distinct from the current plan
-
-A task is likely to be:
-- A1 (small update) if it involves:
- * Minor changes to existing functionality
- * Changes contained within files already in context
- * Simple additions or modifications
- * Refinements to existing subtasks
-
-- A2 (significant update) if it involves:
- * Major changes to existing functionality
- * Changes spanning multiple components
- * New features that build on current work
- * Substantial restructuring of existing subtasks
-
-- A3 (new task) if it:
- * Addresses a different concern/feature
- * Has little overlap with current work
- * Would make more sense as a separate plan
- * Requires a fresh context evaluation
-
-- If the prompt is A2 or A3, smoothly transition to one of these exact statements, followed immediately by the required tag:
- - For A2: "This is a significant update to the plan. I'll clear all context without pending changes, then decide what context I need to move forward." <PlandexFinish/>
- - For A3: "This is a new task that is distinct from the plan. I'll clear all context without pending changes, then decide what context I need to move forward." <PlandexFinish/>
- - Do not add quotes around the statements.
-
-For A1 or B, assess the context requirements and incorporate both of these points naturally into your response:
-
-For chat responses (B), you have "sufficient context" if you have enough information to provide accurate, informed answers about the specific code or concepts the user is asking about.
-
-For small updates (A1), you have "sufficient context" if you have:
-* All files that will be modified
-* Any dependent files needed to understand the changes
-* Any similar implementations that would be helpful as reference
-
-If you have sufficient context, weave both of these points into your response:
-1. This is a small update to the plan
-2. You have the context needed to continue
-
-Rephrase these as needed in order to respond more naturally and effectively to the user. If the user asks you to debug or fix something, don't say "This is a small update to the plan" — use something with a similar meaning that is more appropriate for the situation.
-
-If you don't have sufficient context, naturally transition to this statement: "I need more context to continue." Then output <PlandexFinish/> and end the response.
-
-Example of good flow:
+func GetFollowUpPlanClassifierPrompt(params CreatePromptParams) string {
+ s := `
+[MANDATORY FOLLOW-UP FLOW]
+
+FOR EVERY USER PROMPT:
+You MUST FIRST respond naturally (but without jumping to code or planning). Then do classification.
+
+CLASSIFICATION PROCESS:
+
+1. Primary Classification:
+ A. Update/revision to tasks in current plan
+ B. Conversation prompt (question/comment)
+
+2. For Type A, Sub-classify as:
+ A1. Small/minor update
+ A2. Significant update
+ A3. New distinct task
+
+DETAILED CLASSIFICATION CRITERIA:
+
+A1 (Small Update):
+- Minor changes to existing functionality
+- Changes contained within files already in context
+- Simple additions or modifications
+- Refinements to existing subtasks
+CRITICAL: Even for A1, you MUST still create/update task list
+
+A2 (Significant Update):
+- Major changes to existing functionality
+- Changes spanning multiple components
+- New features that build on current work
+- Substantial restructuring of existing subtasks
+
+A3 (New Task):
+- Addresses a different concern/feature
+- Has little overlap with current work
+- Would make more sense as separate plan
+- Requires fresh context evaluation
+
+REQUIRED ACTIONS BY CLASSIFICATION:
+
+For Type B (Conversation):
+- After responding conversationally, assess context needs
+- If you have sufficient context: naturally indicate you can proceed
+ Example: "Based on the code I see, I can explain this in detail..."
+- If you need more context: "I need more context to respond." followed by <PlandexFinish/>
+- Never create tasks or implement code for Type B
+
+For A1 (Small Update):
+- After responding conversationally:
+ - MUST create/update ### Tasks list
+ - MUST assess context requirements
+ - If sufficient context: naturally state "This is a small update to the plan"
+ - If insufficient context: state "I need more context to continue." and output <PlandexFinish/>
+
+For A2 (Significant Update):
+- After responding conversationally:
+ - MUST output exactly: "This is a significant update to the plan. I'll clear all context without pending changes, then decide what context I need to move forward. <PlandexFinish/>"
+
+For A3 (New Task):
+- After responding conversationally:
+ - MUST output exactly: "This is a new task that is distinct from the plan. I'll clear all context without pending changes, then decide what context I need to move forward. <PlandexFinish/>"
+
+CONTEXT ASSESSMENT CRITERIA:
+
+For Chat Responses (B):
+- Sufficient if: you have enough information to provide accurate, informed answers about the specific code or concepts
+
+For Small Updates (A1):
+- Sufficient if you have:
+ * All files that will be modified
+ * Any dependent files needed to understand the changes
+ * Any similar implementations that would be helpful as reference
+
+RESPONSE FLOW AND STYLE:
+
+1. Natural Response Integration:
+ - Always respond naturally to what the user has said first
+ - Then weave classification and context statements naturally into response
+ - Avoid mechanical or checklist-style responses
+ - Do not quote the exact phrases - incorporate their meaning naturally
+
+Example of Good Flow:
"Those OpenGL errors look like compilation issues with modern OpenGL functions. This is a straightforward update to fix the build process, and I have all the context I need to resolve these errors."
-Example of poor flow:
+Example of Poor Flow:
"Let me classify this prompt:
This is a small update to the plan.
I have the context I need to continue."
-[Handling Multi-part Prompts]
+HANDLING MULTI-PART PROMPTS:
-If the user's prompt contains multiple parts (e.g. both questions and updates):
-1. First determine if there are any questions that should be answered in chat form
-2. Answer those questions first
-3. Then assess any updates/changes according to the classification above (A1/A2/A3)
-4. Only after answering questions should you incorporate any of the classification statements or tags
+If the prompt contains both questions and updates:
+1. First respond conversationally to all parts
+2. Then assess any updates/changes per classification rules above
+3. Only after proper conversation, incorporate classification statements/tags
-` + FollowUpRequiredPrompt
+CRITICAL REMINDERS:
+- ALWAYS respond conversationally first
+- NEVER proceed to implementation before completing planning phase
+`
-const ReviseSubtasksPrompt = `
-- If you have already broken up a task into subtasks in a previous response during this conversation, and you are adding, removing, or modifying subtasks based on a new user prompt, you MUST output the full list of subtasks again in a '### Tasks' section with the same format as before. You ABSOLUTELY MUST NEVER output only a partial list of subtasks. Whenever you update subtasks, output the *complete* updated list of *all* unfinished subtasks with any new subtasks added, any subtasks you are removing removed, and any subtasks you are modifying modified. You don't need to reproduce *finished* subtasks, but any unfinished subtasks that you have listed previously *must without exception* be included in the list. When repeating subtasks that you have listed previously, you must keep them *exactly* the same, unless you specifically intend to modify them. No not make minor changes or add additional text to the subtask. You MUST NEVER remove or modify a subtask that has already been finished from the list of subtasks. DO NOT include the 'Done:' line in subtasks in this list. If an existing subtask has a 'Uses: ' line, you MUST include it.
+ if params.ExecMode {
+ s += `- Since execution mode is enabled, ALWAYS include a '### Commands' section in your response prior to the '### Tasks' section.
+ `
+ }
+
+ s += `
+- ALWAYS create/update ### Tasks list for any type-A classification
+- ALWAYS output <PlandexFinish/> immediately after the task list
+- ALWAYS end response immediately after <PlandexFinish/>
+- NO EXCEPTIONS - Never continue past <PlandexFinish/> for any reason
+- NEVER mix planning and implementation phases
`
+
+ return s
+}
+
+const ReviseSubtasksPrompt = `
+- If you have already broken up a task into subtasks in a previous response during this conversation, and you are adding or modifying subtasks based on a new user prompt, you MUST output any *new* subtasks in a '### Tasks' section with the same format as before. Do NOT output subtasks that have already been finished. You can *modify* an existing *unfinished* subtask by creating a new subtask with the *same exact name* as the previous subtask, then modifying its steps. The name *must* be exactly the same for modification of an existing unfinished subtask to work correctly. You *cannot* modify a subtask that has already been finished.`
diff --git a/app/server/model/prompts/user_prompt.go b/app/server/model/prompts/user_prompt.go
index b471bbaf..d5290e54 100644
--- a/app/server/model/prompts/user_prompt.go
+++ b/app/server/model/prompts/user_prompt.go
@@ -21,7 +21,10 @@ User's operating system details:
---
`
-const PlanningPromptWrapperFormatStr = SharedPromptWrapperFormatStr + `
+func GetPlanningPromptWrapperFormatStr(params CreatePromptParams) string {
+ s := SharedPromptWrapperFormatStr + `
+
+` + GetPlanningFlowControl(params) + `
Do NOT include tests or documentation in the subtasks unless the user has specifically asked for them. Do not include extra code or features beyond what the user has asked for. Focus on the user's request and implement only what is necessary to fulfill it.
@@ -32,21 +35,49 @@ Do NOT include tests or documentation in the subtasks unless the user has specif
At the end of the '### Tasks' section, you ABSOLUTELY MUST ALWAYS include a <PlandexFinish/> tag, then end the response.
Example:
+`
+
+ if params.ExecMode {
+ s += `
+### Commands
+The _apply.sh script is empty. I'll create it with commands to compile the project and run the new test with cargo.
+`
+ }
+
+ s += `
### Tasks
1. Create a new file called 'src/main.rs' with a 'main' function that returns 'Hello, world!'
+Uses: ` + "`src/main.rs`" + `
2. Write a basic test for the 'main' function
+Uses: ` + "`src/main.rs`"
+
+ if params.ExecMode {
+ s += `
+3. Run the new test with cargo
+Uses: ` + "`src/main.rs`" + `
+ `
+ }
+ s += `
<PlandexFinish/>
+After you have broken a task up in to multiple subtasks and output a '### Tasks' section, you *ABSOLUTELY MUST ALWAYS* output a <PlandexFinish/> tag and then end the response. You MUST ALWAYS output the <PlandexFinish/> tag at the end of the '### Tasks' section.
+
+Output a <PlandexFinish/> tag after the '### Tasks' section. NEVER output a '### Tasks' section without also outputting a <PlandexFinish/> tag.
+
IMPORTANT: During this planning phase, you must NOT implement any code or create any code blocks. Your only task 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.
`
-const ImplementationPromptWrapperFormatStr = SharedPromptWrapperFormatStr + `
+ return s
+}
+
+func GetImplementationPromptWrapperFormatStr(params CreatePromptParams) string {
+ s := SharedPromptWrapperFormatStr + `
If you're making a plan, remember to label code blocks with the file path *exactly* as described in point 2, and do not use any other formatting for file paths. **Do not include explanations or any other text apart from the file path in code block labels.**
@@ -56,37 +87,49 @@ Always use an opening <PlandexBlock> tag to start a code block and a closing </P
The <PlandexBlock> tag content MUST ONLY contain the code for the code block and NOTHING ELSE. Do NOT wrap the code block in triple backticks, CDATA tags, or any other text or formatting. Output ONLY the code and nothing else within the <PlandexBlock> tag.
-The <PlandexBlock> tag MUST include both a 'lang' attribute and a 'path' attribute as described in the instructions above. It must not include any other attributes.
+The <PlandexBlock> tag MUST ALWAYS include both a 'lang' attribute and a 'path' attribute as described in the instructions above. It must not include any other attributes.
-You MUST follow the instructions you've been given on how to update code in code blocks:
+When *updating an existing file*, you MUST follow the instructions you've been given on how to update code in code blocks:
-- Do NOT include large sections of the file that are not changing. Output ONLY code that is changing and code that is necessary to understand the changes, the code structure, and where the changes should be applied. Use references comments for sections of the file that are not changing.
+ - Do NOT include large sections of the file that are not changing. Output ONLY code that is changing and code that is necessary to understand the changes, the code structure, and where the changes should be applied. Use references comments for sections of the file that are not changing.
-- Include enough code from the original file to precisely and unambiguously locate where the changes should be applied and their level of nesting.
+ - Include enough code from the original file to precisely and unambiguously locate where the changes should be applied and their level of nesting.
-- Match the indentation of the original file exactly.
+ - Match the indentation of the original file exactly.
-- Do NOT output multiple references with no changes in between them.
+ - Do NOT output multiple references with no changes in between them.
-- Do NOT add superfluous newlines around reference comments.
+ - Do NOT add superfluous newlines around reference comments.
-- Use a removal comment to denote code that is being removed from a file. As with reference comments, removal comments must be surrounded by enough context so that the location and nesting depth of the code being removed is clear and unambiguous.
+ - Use a removal comment to denote code that is being removed from a file. As with reference comments, removal comments must be surrounded by enough context so that the location and nesting depth of the code being removed is clear and unambiguous.
-- When replacing code from the original file with *new code*, you MUST make it unambiguously clear exactly which code is being replaced by including surrounding context.
+ - When replacing code from the original file with *new code*, you MUST make it unambiguously clear exactly which code is being replaced by including surrounding context.
-- Unless you are fully overwriting the entire file, you ABSOLUTELY MUST ALWAYS include at least one "... existing code ..." comment before or after the change to account for all the code before or after the change.
+ - Unless you are fully overwriting the entire file, you ABSOLUTELY MUST ALWAYS include at least one "... existing code ..." comment before or after the change to account for all the code before or after the change.
-- Even if the location of new code is not important and could be placed anywhere in the file, you still MUST determine *exactly* where the new code should be placed and include sufficient surrounding context so that the location and nesting depth of the code being added is clear and unambiguous.
+ - Even if the location of new code is not important and could be placed anywhere in the file, you still MUST determine *exactly* where the new code should be placed and include sufficient surrounding context so that the location and nesting depth of the code being added is clear and unambiguous.
-- Never remove existing functionality unless explicitly instructed to do so.
+ - Never remove existing functionality unless explicitly instructed to do so.
-- Show enough surrounding context to understand the code structure.
+ - Show enough surrounding context to understand the code structure.
-Every code block that is *updating* an existing file in context MUST ALWAYS be preceded by an explanation of the change that *exactly matches* one of the formats listed in the "### Action Explanation Format" section. Do *NOT* UNDER ANY CIRCUMSTANCES use an explanation like "I'll update the code to..." that does not match one of these formats.
+ - When outputting the explanation, do *NOT* insert code between two code structures that aren't *immediately adjacent* in the original file.
-- When outputting the explanation, do *NOT* insert code between two code structures that aren't *immediately adjacent* in the original file.
+ - Every code block that *updates* an existing file MUST ALWAYS be preceded by an explanation of the change that *exactly matches* one of the formats listed in the "### Action Explanation Format" section. Do *NOT* UNDER ANY CIRCUMSTANCES use an explanation like "I'll update the code to..." that does not match one of these formats.
+
+When *creating a new file*, follow the instructions in the "### Action Explanation Format" section for creating a new file.
+
+ - The Type field MUST be exactly 'new file'.
+ - The Summary field MUST briefly describe the new file and its purpose.
+ - The file path MUST be included in the code block label.
+ - The code itself MUST be written within a <PlandexBlock> tag.
+ - The <PlandexBlock> tag MUST include both a 'lang' attribute and a 'path' attribute as described in the instructions above. It must not include any other attributes.
+ - The <PlandexBlock> tag MUST NOT include any other text or formatting. It must only contain the code for the code block and NOTHING ELSE. Do NOT wrap the code block in triple backticks, CDATA tags, or any other text or formatting. Output ONLY the code and nothing else within the <PlandexBlock> tag.
+ - The code block MUST include the *entire file* to be created. Do not omit any code from the file.
+ - Do NOT use placeholder code or comments like '// implement authentication here' to indicate that the file is incomplete. Implement *all* functionality.
+ - Do NOT use reference comments like '// ... existing code ...'. Those are only used for updating existing files and *never* when creating new files.
+ - Include the *entire file* in the code block.
-- When creating a *new* file, do NOT include this explanation. Include *one* explanation in this format per code block that *updates* an existing file. Do NOT include multiple explanations in the same code block.
Only list out subtasks once for the plan--after that, do not list or describe a subtask that can be implemented in code without including a code block that implements the subtask.
@@ -104,33 +147,74 @@ If you break up a task into subtasks, only include subtasks that can be implemen
` + FileOpsImplementationPromptSummary
-const FollowUpRequiredPrompt = `
-[CLASSIFICATION REQUIRED]
+ return s
+}
-YOU MUST COMPLETE THE CLASSIFICATION STEP BEFORE PROCEEDING TO ANY OTHER STEPS.
+func GetFollowUpRequiredPrompt(params CreatePromptParams) string {
+ s := `
+[MANDATORY FOLLOW-UP FLOW]
+
+CRITICAL FLOW CONTROL:
+1. You MUST FIRST respond naturally to what the user has said/asked
+2. Then classify the prompt as either:
+ A. Update/revision to tasks (A1/A2/A3)
+ B. Conversation prompt (question/comment)
+
+3. IF classified as A (update/revision):
+ - You MUST create/update the task list with ### Tasks
+ - You MUST output <PlandexFinish/> immediately after the task list
+ - You MUST end your response immediately after <PlandexFinish/>
+ - You ABSOLUTELY MUST NOT proceed to implementation
+ - You MUST follow planning format exactly
+ Even if:
+ - The change is small
+ - You know the exact code to write
+ - You're continuing an existing plan
+
+4. IF classified as B (conversation):
+ - Continue conversation naturally
+ - Do not create tasks or implement code
+
+5. After responding and classifying, output EXACTLY ONE of these statements (naturally incorporated):
+ A. "I have the context I need to continue."
+ B. "I have the context I need to respond."
+ C. "I need more context to continue. <PlandexFinish/>"
+ D. "I need more context to respond. <PlandexFinish/>"
+ E. "This is a significant update to the plan. I'll clear all context without pending changes, then decide what context I need to move forward. <PlandexFinish/>"
+ F. "This is a new task that is distinct from the plan. I'll clear all context without pending changes, then decide what context I need to move forward. <PlandexFinish/>"
+
+For statements A/B: You may rephrase naturally while keeping the meaning.
+For statements C/D: MUST include exact phrase "need more context" and <PlandexFinish/>.
+For statements E/F: MUST include exact phrase "clear all context" and <PlandexFinish/>.
+
+CRITICAL: Always respond naturally to the user first, then seamlessly incorporate the required statement. Do NOT state that you are performing a classification or context assessment.
+`
+
+ return s
+}
-DO NOT proceed to planning or implementation without first:
-1. Classifying the prompt according to the rules below
-2. Outputting the required classification statement
-3. Assessing context needs
-4. Outputting the required context statement
+type UserPromptParams struct {
+ CreatePromptParams
+ Prompt string
+ OsDetails string
+ IsPlanningStage bool
+ IsFollowUp bool
+ ApplyScriptSummary string
+}
-You MUST output one of these exact statements before proceeding:
-- "This is a small update to the plan."
-- "This is a significant update to the plan. I'll clear all context without pending changes, then decide what context I need to move forward."
-- "This is a new task that is distinct from the plan. I'll clear all context without pending changes, then decide what context I need to move forward."
+func GetWrappedPrompt(params UserPromptParams) string {
-AND then one of these for small updates (A1) or chat responses (B):
-- "I have the context I need to continue."
-- "I need more context to continue."
-`
+ prompt := params.Prompt
+ osDetails := params.OsDetails
+ isPlanningStage := params.IsPlanningStage
+ isFollowUp := params.IsFollowUp
+ applyScriptSummary := params.ApplyScriptSummary
-func GetWrappedPrompt(prompt, osDetails, applyScriptSummary string, isPlanningStage, isFollowUp bool) string {
var promptWrapperFormatStr string
if isPlanningStage {
- promptWrapperFormatStr = PlanningPromptWrapperFormatStr
+ promptWrapperFormatStr = GetPlanningPromptWrapperFormatStr(params.CreatePromptParams)
} else {
- promptWrapperFormatStr = ImplementationPromptWrapperFormatStr
+ promptWrapperFormatStr = GetImplementationPromptWrapperFormatStr(params.CreatePromptParams)
}
// If we're in the planning stage, we don't need to include the apply script summary
@@ -138,7 +222,7 @@ func GetWrappedPrompt(prompt, osDetails, applyScriptSummary string, isPlanningSt
applyScriptSummary = ""
if isFollowUp {
- promptWrapperFormatStr += "\n\n" + FollowUpRequiredPrompt
+ promptWrapperFormatStr += "\n\n" + GetFollowUpRequiredPrompt(params.CreatePromptParams)
}
}
@@ -364,3 +448,34 @@ Remember that users often:
ts,
params.OsDetails)
}
+
+func GetPlanningFlowControl(params CreatePromptParams) string {
+ s := `
+CRITICAL PLANNING RULES:
+1. For ANY update/revision to tasks:
+`
+
+ if params.ExecMode {
+ s += `You MUST output a ### Commands section before the ### Tasks list`
+ }
+
+ s += `
+ - You MUST output a new/updated ### Tasks list
+ - You MUST NOT start implementing code
+ - You MUST follow planning phase format exactly
+
+2. Even for small changes:
+ - Create/update task list first
+ - No implementation until planning is complete
+ - All changes must be in task list
+
+3. Task Planning Required:
+ - When adding new functionality
+ - When modifying existing code
+ - When fixing bugs or issues
+ - When continuing an existing plan
+ NO EXCEPTIONS - always plan first
+`
+
+ return s
+}