Skip to content

Commit adc78af

Browse files
committed
Add prompt for git workflow
1 parent 0fdb900 commit adc78af

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

src/core/prompts/sections/rules.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ function getEditingInstructions(diffStrategy?: DiffStrategy): string {
4444
return instructions.join("\n")
4545
}
4646

47+
function getGitWorkflowInstructions(): string {
48+
return `- **GIT WORKFLOW REQUIREMENTS**: For all code-related tasks, you MUST follow proper git workflow:
49+
* **Before Starting Task**: Always pull latest changes before beginning work:
50+
- Pull latest changes: \`git pull\`
51+
* **Initial Task Completion**: Before using attempt_completion, commit changes and create a PR:
52+
- Check git status: \`git status\`
53+
- Stage changes: \`git add .\`
54+
- Commit with descriptive message: \`git commit -m "feat: [brief description]"\`
55+
- Create and push to feature branch: \`git checkout -b otto/[task-name] && git push -u origin otto/[task-name]\`
56+
- Create PR: \`gh pr create --title "[PR Title]" --body "[Description]"\` (if GitHub CLI available)
57+
* **Subsequent Changes**: If user requests changes after PR creation:
58+
- Make requested changes
59+
- Commit: \`git add . && git commit -m "fix: [description of changes]"\`
60+
- Push to existing branch: \`git push\`
61+
* **Edge Cases**: Handle missing git repo (\`git init\`), missing remote, existing branches (\`git checkout [branch]\`), merge conflicts, and missing GitHub CLI
62+
* **Branch Naming**: Use descriptive names like \`otto/feat/add-authentication\`, \`otto/fix/resolve-login-bug\`, \`otto/refactor/update-api\`
63+
* **Commit Messages**: Use conventional format: \`type: description\` (feat, fix, docs, style, refactor, test, chore)`
64+
}
65+
4766
export function getRulesSection(cwd: string, supportsComputerUse: boolean, diffStrategy?: DiffStrategy): string {
4867
return `====
4968
@@ -57,6 +76,7 @@ RULES
5776
- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using ${diffStrategy ? "apply_diff or write_to_file" : "write_to_file"} to make informed changes.
5877
- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
5978
${getEditingInstructions(diffStrategy)}
79+
${getGitWorkflowInstructions()}
6080
- Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode.
6181
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
6282
* For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$"

src/core/prompts/tools/attempt-completion.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,48 @@
11
export function getAttemptCompletionDescription(): string {
22
return `## attempt_completion
33
Description: After each tool use, the user will respond with the result of that tool use, i.e. if it succeeded or failed, along with any reasons for failure. Once you've received the results of tool uses and can confirm that the task is complete, use this tool to present the result of your work to the user. Optionally you may provide a CLI command to showcase the result of your work. The user may respond with feedback if they are not satisfied with the result, which you can use to make improvements and try again.
4+
45
IMPORTANT NOTE: This tool CANNOT be used until you've confirmed from the user that any previous tool uses were successful. Failure to do so will result in code corruption and system failure. Before using this tool, you must ask yourself in <thinking></thinking> tags if you've confirmed from the user that any previous tool uses were successful. If not, then DO NOT use this tool.
6+
7+
GIT WORKFLOW REQUIREMENTS:
8+
When completing a task that involves code changes, you MUST follow this git workflow:
9+
10+
0. **Before Starting Task**: Always pull latest changes before beginning work:
11+
- Pull latest changes: \`git pull\`
12+
13+
1. **Initial Task Completion**: After making all necessary changes and before using attempt_completion, commit your changes and create a pull request:
14+
- Stage all changes: \`git add .\`
15+
- Commit with a descriptive message: \`git commit -m "feat: [brief description of changes]"\`
16+
- Push to a new feature branch: \`git push -u origin otto/feature/[task-description]\`
17+
- Create a pull request: \`gh pr create --title "[PR Title]" --body "[PR Description]"\`
18+
19+
2. **Subsequent Changes After PR**: If the user requests additional changes after the PR has been created:
20+
- Make the requested changes
21+
- Stage and commit: \`git add . && git commit -m "fix: [description of additional changes]"\`
22+
- Push to the existing branch: \`git push\`
23+
- Do NOT create a new PR - the existing PR will be updated automatically
24+
25+
3. **Edge Cases to Handle**:
26+
- If the branch already exists, switch to it: \`git checkout [branch-name]\`
27+
- If there are merge conflicts, resolve them before proceeding
28+
- If GitHub CLI is not available, provide manual instructions for creating PR
29+
- If working on an existing PR branch, continue using that branch
30+
31+
4. **Branch Naming Convention**:
32+
- Use descriptive branch names: \`otto/feature/add-user-authentication\`, \`otto/fix/resolve-login-bug\`, \`otto/refactor/update-api-endpoints\`
33+
- Keep branch names concise but meaningful
34+
35+
5. **Commit Message Format**:
36+
- Use conventional commit format: \`type: description\`
37+
- Types: feat, fix, docs, style, refactor, test, chore
38+
- Example: \`feat: add user authentication system\`
39+
40+
IMPORTANT: Always execute the git commands using the execute_command tool before using attempt_completion. The git workflow is mandatory for all code-related tasks.
41+
542
Parameters:
643
- result: (required) The result of the task. Formulate this result in a way that is final and does not require further input from the user. Don't end your result with questions or offers for further assistance.
744
- command: (optional) A CLI command to execute to show a live demo of the result to the user. For example, use \`open index.html\` to display a created html website, or \`open localhost:3000\` to display a locally running development server. But DO NOT use commands like \`echo\` or \`cat\` that merely print text. This command should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.
45+
846
Usage:
947
<attempt_completion>
1048
<result>
@@ -16,7 +54,7 @@ Your final result description here
1654
Example: Requesting to attempt completion with a result and command
1755
<attempt_completion>
1856
<result>
19-
I've updated the CSS
57+
I've updated the CSS and committed the changes to a new feature branch. Created PR #123 for review.
2058
</result>
2159
<command>open index.html</command>
2260
</attempt_completion>`

0 commit comments

Comments
 (0)