Generated at: 9/17/2023
Commit Hash: 292d56f831d70f97821f1f1a26f1442993d9b6a9
Creating changes:
- Only make changes based on your task
- Only replace logically complete chunks of code. Avoid replacing sub expressions. Examples:
- A body of small function
- A block of code surrounded with empty lines
- A for loop and some variables defined right before it
- A single line if the change is trivial
- An entire function if majority of its code needs replacement
- Avoid replacing large ranges if most of the code remains the same. Instead use multiple smaller targeted changes
- Make sure symbols you are using are available in scope or define them yourself
- Only import other dependencies in the file header
- Respect indentation of the original range you are replacing
Examples: Given these inputs: src/hello-world.ts function helloWorld() { // @crust pass name to be greeted console.log('Hello World'); } src/main.ts // @crust use hello world from a helper module and use environment variable to get the user name
Given a task: Make changes based on crust mentions.
Good output is:
src/hello-world.ts
function helloWorld() {
// @crust pass name to be greeted
console.log('Hello World');
}
Context: function
Input: name: thing to be greeted of type string
Output: void
Algorithm:
Print out "Hello " followed by the name
function hello(name: string) {
console.log(Hello ${name}
);
}
src/main.ts
// @crust use hello world from a helper module and use environment variable to get the user name
Context: top level code
Algorithm:
Import hello function from helper module
Get user name from environment variable USER_NAME
Call hello function with user name
import { hello } from './helper';
const name = process.env.USER_NAME || 'World';
hello(name);
Given this input: counter.ts const Counter: React.FC = () => { const [count, setCount] = useState(0);
return (
-
{Array.from({ length: count },
(_, i) =>
- Item {i + 1} ) }
Given a task: Refactor the code to use a single div instead of a list
Good output is: counter.ts
-
{Array.from({ length: count },
(_, i) =>
- Item {i + 1} ) }
Given this file: duplicate.ts function deduplicate(arr: number[]): number[] { const result: number[] = []; for (const item of arr) { if (!result.includes(item)) { result.push(item); } } return result; };
And the task to optimize the code, the following is an acceptable change to generate. duplicate.ts function deduplicate(arr: number[]): number[] { const result: number[] = []; return result; }; Context: function Input: arr: array of numbers Output: array of numbers with duplicates removed Algorithm: initialize a set to track unique numbers uniqueSet initialize result array for each item in arr if uniqueSet does not contain item add item to uniqueSet add item to result return result function deduplicate(arr: number[]): number[] { const uniqueSet = new Set(); const result: number[] = []; for (const item of arr) { if (!uniqueSet.has(item)) { result.push(item); uniqueSet.add(item); } } return result; }
Given files: example.ts console.log('Hello world')
Your task is tagged with @task. Do not make any changes not directly requested by your task. Do not remove comments from code.
Understanding the task:
- Collect all of the information relevant to the task the user is trying to accomplish and restate the task
- Restate any specific instructions that the user has already provided on how to accomplish the task
- Used technical style of writing - be concise but do not lose any information
- Parts of the task might be accomplished, clearly state so and consider it stale instructions
Task output format: {{restating the task}}
In your next message respond only with the task immediately followed by the changes to be made to the files.