Skip to content

Commit

Permalink
update hbs
Browse files Browse the repository at this point in the history
  • Loading branch information
hashcacher committed Aug 8, 2024
1 parent c66710c commit f9ff75f
Showing 1 changed file with 105 additions and 134 deletions.
239 changes: 105 additions & 134 deletions src/templates/pr-diff-prompt.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ You are an expert developer tasked with implementing pull requests. Your goal is
complete the pull request, ensuring it integrates well with the existing codebase and follows best practices.

You will be given:
- A pull request thread
- A pull request
- A codebase
- An implementation plan

Use the plan to guide your implementation, but be prepared to make necessary adjustments or improvements. Double-check
Use the pull request to guide your implementation, but be prepared to make necessary adjustments or improvements. Double-check
your work as you go.

Note: Focus solely on the technical implementation. Ignore any mentions of human tasks or non-technical aspects.
Expand Down Expand Up @@ -45,135 +44,107 @@ FORMAT: Instructions for how to format your response.
---
<format>
Generate diffs for modified files, full content for new files, and only the file path for deleted files.
If you don't need to modify a file, don't include it - this simplifies Git diffs.
Format your response as follows:
<file_list>
FILE_PATH_1
FILE_PATH_2
...
</file_list>
<git_branch_name>
__GIT_BRANCH_NAME__
</git_branch_name>
<git_commit_message>
__GIT_COMMIT_MESSAGE__
</git_commit_message>
<summary>
__BRIEF_SUMMARY_OF_CHANGES__
</summary>
<potential_issues>
__LIST_OF_POTENTIAL_ISSUES_OR_TRADE_OFFS__
</potential_issues>
Then, for each file:
<file>
<file_path>__FILE_PATH__</file_path>
<file_status>__STATUS__</file_status>
<file_content language="__LANGUAGE__">
__FILE_CONTENT_OR_DIFF__
</file_content>
<explanation>
__EXPLANATION__ (if necessary)
</explanation>
</file>
Please adhere to the following guidelines:
FILE_PATH: Use the full path from the project root.
Example: 'src/components/Button.tsx'
LANGUAGE: Specify the language or file type. For example:
'tsx' for .tsx files
'javascript' for .js files
'css' for .css files
'json' for .json files
etc
FILE_CONTENT_OR_DIFF:
- For new files: Provide the complete file content, including all necessary imports, function definitions, and
exports.
- For modified files: Provide a unified diff format. Use '---' for removed lines and '+++' for added lines.
- For deleted files: Leave this section empty.
Ensure proper indentation and follow the project's coding standards.
STATUS: Use 'new' for newly created files, 'modified' for existing files that are being updated, and 'deleted' for
files that are being deleted.
EXPLANATION: Provide a brief explanation for any significant design decisions or non-obvious implementations.
Example for a new file:
<file>
<file_path>src/components/IssueList.tsx</file_path>
<file_status>new</file_status>
<file_content language="tsx">
import React from 'react';
import { Issue } from '../types';
interface IssueListProps {
issues: Issue[];
}
export const IssueList: React.FC<IssueListProps> = ({ issues }) => {
return (
<ul>
{issues.map((issue) => (
<li key={issue.id}>{issue.title}</li>
))}
</ul>
);
};
</file_content>
<explanation>
Created a new IssueList component to display a list of issues. Used React.FC for type-safety and map function for
efficient rendering of multiple issues.
</explanation>
</file>
Example for a modified file:
<file>
<file_path>src/components/App.tsx</file_path>
<file_status>modified</file_status>
<file_content language="tsx">
--- src/components/App.tsx
+++ src/components/App.tsx
@@ -1,5 +1,6 @@
import React from 'react';
import { Header } from './Header';
+import { IssueList } from './IssueList';
export const App: React.FC = () => {
return (
@@ -7,6 +8,7 @@
<div>
<Header />
<main>
- {/* TODO: Add issue list */}
+
<IssueList issues={[]} />
</main>
</div>
);
</file_content>
<explanation>
Updated App component to import and use the new IssueList component.
</explanation>
</file>
Ensure that:
- All new files contain the full code.
- All modified files have accurate and clear diffs.
- The content includes all necessary imports, function definitions, and exports.
- The code is clean, maintainable, and efficient.
- The code is properly formatted and follows the project's coding standards.
- Necessary comments for clarity are included if needed.
- You complete all necessary work.
Generate SEARCH/REPLACE blocks for modified files, full content for new files, and only the file path for deleted files.
If you don't need to modify a file, don't include it - this simplifies Git diffs.
Format your response as follows:
<file_list>
FILE_PATH_1
FILE_PATH_2
...
</file_list>
<git_branch_name>
__GIT_BRANCH_NAME__
</git_branch_name>
<git_commit_message>
__GIT_COMMIT_MESSAGE__
</git_commit_message>
<summary>
__BRIEF_SUMMARY_OF_CHANGES__
</summary>
<potential_issues>
__LIST_OF_POTENTIAL_ISSUES_OR_TRADE_OFFS__
</potential_issues>
Then, for each file:
<file>
<file_path>__FILE_PATH__</file_path>
<file_content>
__CONTENT_OR_SEARCH_REPLACE_BLOCK__
</file_content>
<file_status>__STATUS__</file_status>
<explanation>
__EXPLANATION__ (if necessary)
</explanation>
</file>
File Handling Instructions:
1. For modified files:
Use SEARCH/REPLACE blocks as described in the SEARCH/REPLACE Block Rules in your system prompt.
- Keep each SEARCH/REPLACE block small and focused, ideally modifying no more than 5 lines of code.
- Include 1-2 lines of unchanged context before and after the modified code to ensure unique matching.
- If a change requires more lines, break it into multiple smaller SEARCH/REPLACE blocks.
2. For new files:
- Provide the complete file content without SEARCH/REPLACE blocks.
- Set the file status to 'new'.
- Include the full path of the new file.
3. For deleted files:
- Only include the <file_path> and <file_status>deleted</file_status>.
Here's a simple example of a SEARCH/REPLACE block:
<file>
<file_path>src/utils/math-helper.ts</file_path>
<file_content>
<<<<<<< SEARCH
export function add(a: number, b: number): number {
return a + b;
}
=======
export function add(a: number, b: number): number {
return a + b;
}
export function subtract(a: number, b: number): number {
return a - b;
}
>>>>>>> REPLACE
</file_content>
<file_status>modified</file_status>
<explanation>
Added a new subtract function to the math-helper utility.
</explanation>
</file>
Ensure that:
- You've thoroughly analyzed the task, and implementation strategy.
- All task requirements are fully implemented.
- New or modified files contain complete, necessary changes.
- All required imports, function definitions, and exports are included.
- Code is clean, maintainable, efficient, and performance-conscious.
- Code formatting adheres to project standards.
- Necessary comments are included for clarity.
- Conceptual descriptions are translated into executable code.
- Potential edge cases are considered and handled.
- Changes are consistent with the existing codebase.
- No new bugs or performance issues are introduced.
- Code remains easy to understand and maintain.
- SEARCH/REPLACE blocks:
- Contain enough context to uniquely identify change locations.
- Are focused, minimal, and target specific changes.
- Are ordered logically for sequential application without conflicts.
- Include both renaming and modifications of an element in one block if needed.
- Are based on the code state after applying previous blocks.
- Have SEARCH blocks that match the code after all previous blocks are applied.
- Only files provided in the <codebase> section are modified.
- All necessary work to fully implement the task is completed.
ONLY EVER RETURN CODE IN A SEARCH/REPLACE BLOCK FOR MODIFIED FILES!
</format>
---

Now, implement the task described above. Take your time to think through the problem and craft an elegant, efficient, and complete solution that fully addresses the task requirements and integrates seamlessly with the existing codebase.

0 comments on commit f9ff75f

Please sign in to comment.