"description":"Create a new file with specified content. This is for application code. Overwrites if the file exists.",
"parameters":{
"type":"object",
"properties":{
"filepath":{"type":"string","description":"The full path for the new file."},
"content":{"type":"string","description":"The full, complete content to write into the file."}
},
"required":["filepath","content"]
}
}
},
{
"type":"function",
"function":{
"name":"create_test_file",
"description":"Create a new test file with specified content to verify the application code.",
"parameters":{
"type":"object",
"properties":{
"filepath":{"type":"string","description":"The full path for the new test file (e.g., 'test_app.py')."},
"content":{"type":"string","description":"The full, complete content for the test file."}
},
"required":["filepath","content"]
}
}
},
{
"type":"function",
"function":{
"name":"read_file",
"description":"Read the content of a file.",
"parameters":{
"type":"object",
"properties":{
"filepath":{"type":"string","description":"The full path of the file to read."}
},
"required":["filepath"]
}
}
},
{
"type":"function",
"function":{
"name":"delete_file",
"description":"Delete a file.",
"parameters":{
"type":"object",
"properties":{
"filepath":{"type":"string","description":"The full path of the file to delete."}
},
"required":["filepath"]
}
}
},
{
"type":"function",
"function":{
"name":"terminal_execute",
"description":"Execute a shell command in the terminal. Use this for tasks like creating directories, listing files, running tests, and installing packages.",
"parameters":{
"type":"object",
"properties":{
"command":{"type":"string","description":"The command to execute."}
},
"required":["command"]
}
}
},
{
"type":"function",
"function":{
"name":"finish_task",
"description":"Call this function when the current task is fully completed, verified, and all tests are passing.",
"parameters":{
"type":"object",
"properties":{
"reason":{"type":"string","description":"A brief summary of why the task is considered finished."}
},
"required":["reason"]
}
}
},
{
"type":"function",
"function":{
"name":"split_and_delegate",
"description":"If the prompt contains more than one distinct task, use this function to handle the first task and delegate the rest.",
"parameters":{
"type":"object",
"properties":{
"current_task_prompt":{"type":"string","description":"The prompt for the immediate task this bot instance will handle."},
"remaining_prompt":{"type":"string","description":"The prompt describing all subsequent tasks."}
returnf"""You are an autonomous AI builder bot. Your goal is to accomplish the user's request by calling functions to interact with the system.
You have complete CRUD access to the filesystem and can execute terminal commands. Be aware of your actions and their consequences.
Current Directory: {os.getcwd()}
The user's high-level goal is: "{self.initial_prompt}"
Here is a summary of the steps taken so far:
{json.dumps(self.memory,indent=2)ifself.memoryelse'No actions taken yet.'}
**NEW, STRICT RULES:**
1. **NO PLACEHOLDERS:** All code you generate must be a full, working implementation. Do not generate placeholders, stubs, or incomplete functions.
2. **TEST-DRIVEN DEVELOPMENT:** For any application code you write, you MUST also write a corresponding test file.
3. **EXECUTE TESTS:** After creating the code and the test file, you MUST execute the tests using `terminal_execute` (e.g., `python -m pytest test_file.py`).
4. **VALIDATE & DEBUG:** Analyze the `stdout` and `stderr` from the test execution. If there are any failures, you MUST debug the issue. This means re-reading the code, fixing it with `create_file`, and then re-running the tests. This loop (fix -> re-test) must continue until all tests pass.
5. **SPECIFY VERSIONS:** When installing packages (e.g., using pip), you MUST specify an exact version. For example: `pip install pytest==8.1.1`. Do not use commands like `pip install pytest`.
6. **TASK DECOMPOSITION:** If the prompt contains multiple distinct tasks (e.g., "create an API and then build a frontend for it"), you MUST use the `split_and_delegate` function first.
7. **FINISH CONDITION:** Only call `finish_task` when the entire requested functionality is implemented AND all corresponding tests are passing.
8. **AUTONOMY:** Do not ask for permission. Execute the plan.
logging.info(f"AI response with no tool call: {no_tool_call_message}")
messages.append({"role":"user","content":"You did not call a function. Please proceed with the next action by calling a function, or call `finish_task` if the entire goal is complete."})