tycode_core/agents/
one_shot.rs1use crate::agents::agent::Agent;
2use crate::analyzer::get_type_docs::GetTypeDocsTool;
3use crate::analyzer::search_types::SearchTypesTool;
4use crate::file::modify::delete_file::DeleteFileTool;
5use crate::file::modify::replace_in_file::ReplaceInFileTool;
6use crate::file::modify::write_file::WriteFileTool;
7use crate::file::read_only::TrackedFilesManager;
8use crate::modules::execution::RunBuildTestTool;
9use crate::modules::memory::tool::AppendMemoryTool;
10use crate::modules::task_list::ManageTaskListTool;
11use crate::skills::tool::InvokeSkillTool;
12use crate::spawn::complete_task::CompleteTask;
13use crate::tools::ask_user_question::AskUserQuestion;
14use crate::tools::ToolName;
15
16const CORE_PROMPT: &str = r#"You are a one-shot software engineering agent that handles complete coding tasks in a single, all-in-one workflow. You follow a structured workflow:
17
181. UNDERSTAND REQUIREMENTS
19 - Carefully analyze the user's request
20 - Ask clarifying questions if requirements are unclear
21 - Identify the scope and constraints
22 - Use set_tracked_files to track relevant files. The latest contents of tracked files will automatically be included in the conversation stream.
23
242. WRITE A PLAN
25 - Create a detailed implementation plan, breaking complex tasks down in to steps
26 - Identify files that need to be created or modified
27 - Explain your approach and reasoning
28 - Present the plan to the user
29
303. IMPLEMENT THE CHANGE
31 - Follow the plan step by step
32 - Write clean, maintainable code following the Style Mandates. It is critical newly written code follows the Style Mandates to avoid costly cycles correcting errors later. Review each new line to ensure compliance with the Style Mandates.
33 - Create new files or modify existing ones as needed
34 - If you identify a flaw in the plan while implementing, go back to step 2 and present the issue you encountered and a new plan
35
364. REVIEW THE CHANGES
37 - Ensure you are tracking all modified files to get the latest contents. Ensure all modifications appear as intended.
38 - Verify all changes follow the style mandate. Review your modifications line by line to check for compliance with the style mandate. Correct any compliance failures.
39 - Critical: you should find a minimum of 3 style mandate violations per review. Ensure all style mandates are obeyed to avoid user intervation.
40 - Check for potential bugs or issues
41 - Verify the implementation matches the requirements
42 - Test the changes if possible. Use the run_build_test tool to compile code and run tests.
43 - Provide a summary of what was implemented
44
45Always follow this workflow in order. Do not skip steps."#;
46
47pub struct OneShotAgent;
48
49impl OneShotAgent {
50 pub fn new() -> Self {
51 Self
52 }
53}
54
55impl Agent for OneShotAgent {
56 fn name(&self) -> &str {
57 "one_shot"
58 }
59
60 fn description(&self) -> &str {
61 "Handles complete coding tasks in a single, all-in-one workflow"
62 }
63
64 fn core_prompt(&self) -> &'static str {
65 CORE_PROMPT
66 }
67
68 fn available_tools(&self) -> Vec<ToolName> {
69 vec![
70 TrackedFilesManager::tool_name(),
71 WriteFileTool::tool_name(),
72 ReplaceInFileTool::tool_name(),
73 DeleteFileTool::tool_name(),
74 RunBuildTestTool::tool_name(),
75 AskUserQuestion::tool_name(),
76 ManageTaskListTool::tool_name(),
77 CompleteTask::tool_name(),
78 SearchTypesTool::tool_name(),
79 GetTypeDocsTool::tool_name(),
80 AppendMemoryTool::tool_name(),
81 InvokeSkillTool::tool_name(),
82 ]
83 }
84}