use crate::chat::{AgentExecutionProfile, AgentRole}; /// Tools available to every agent role (shared baseline). fn shared_tools() -> Vec { vec![ // Conversation management "chat_generate_title".into(), // File parsing / search "git_grep".into(), "read_csv".into(), "read_json".into(), "read_sql".into(), "read_markdown".into(), // File content retrieval "git_file_content".into(), "git_blob_get".into(), "git_blob_content".into(), "git_status".into(), ] } /// Researcher-specific tools (search & discovery). fn researcher_tools() -> Vec { vec![ // Search "git_search_commits".into(), "repo_search".into(), "repo_doc_search".into(), "project_bing_search".into(), "project_arxiv_search".into(), "project_curl".into(), "curl_exec".into(), // Index / overview "repo_overview".into(), "repo_readme".into(), "repo_file_tree".into(), "repo_doc_index".into(), "repo_doc_read".into(), // Lists "project_list_repos".into(), "project_list_members".into(), "project_list_issues".into(), "project_list_labels".into(), "project_list_boards".into(), // Log / history "git_log".into(), "git_reflog".into(), "git_graph".into(), "git_commit_info".into(), "repo_commit_log".into(), "git_ref_list".into(), "git_ref_info".into(), "git_lfs_summary".into(), "git_lfs_scan_tree".into(), ] } /// Analyst-specific tools (deep analysis & explanation). fn analyst_tools() -> Vec { vec![ // Deep inspection "git_show".into(), "git_diff".into(), "git_diff_stats".into(), "git_blame".into(), // Structural analysis "repo_languages".into(), "repo_dependencies".into(), "repo_diff_summary".into(), "repo_contributors".into(), // Branch comparison "git_branch_list".into(), "git_branch_info".into(), "git_branch_diff".into(), "git_merge_analysis".into(), "git_ref_list".into(), "git_ref_info".into(), // Project data "project_list_issues".into(), "project_list_repos".into(), ] } /// Reviewer-specific tools (evaluation & risk detection). fn reviewer_tools() -> Vec { vec![ // Change inspection "git_diff".into(), "git_diff_stats".into(), "git_blame".into(), // Merge status "git_branches_merged".into(), "git_branch_info".into(), "git_merge_analysis".into(), // Tracking "project_list_issues".into(), "project_update_issue".into(), // Boards "project_list_boards".into(), "project_update_board_card".into(), ] } /// Architect-specific tools (system design & dependency mapping). fn architect_tools() -> Vec { vec![ // Repository structure "repo_overview".into(), "repo_readme".into(), "repo_file_tree".into(), "repo_languages".into(), "repo_dependencies".into(), "repo_test_discovery".into(), // Change and branch context "repo_diff_summary".into(), "git_branch_list".into(), "git_branch_info".into(), "git_branch_diff".into(), "git_merge_analysis".into(), "git_ref_list".into(), // Project context "project_list_repos".into(), "project_list_issues".into(), ] } /// Debugger-specific tools (root-cause analysis & history tracing). fn debugger_tools() -> Vec { vec![ // Failure and change inspection "git_show".into(), "git_diff".into(), "git_diff_stats".into(), "git_blame".into(), "git_log".into(), "git_commit_info".into(), "git_ref_info".into(), // Structural clues "repo_file_tree".into(), "repo_dependencies".into(), "repo_test_discovery".into(), "repo_doc_search".into(), // Issue context "project_list_issues".into(), ] } /// Implementer-specific tools (implementation planning & code navigation). fn implementer_tools() -> Vec { vec![ // Code and documentation context "repo_overview".into(), "repo_readme".into(), "repo_file_tree".into(), "repo_doc_index".into(), "repo_doc_read".into(), "repo_dependencies".into(), "repo_test_discovery".into(), // Current change context "git_diff".into(), "git_diff_stats".into(), "git_show".into(), "git_branch_info".into(), // Project context "project_list_issues".into(), ] } /// Tester-specific tools (coverage, regression, and validation planning). fn tester_tools() -> Vec { vec![ // Test discovery and changed surface "git_grep".into(), "git_diff".into(), "git_diff_stats".into(), "git_show".into(), "repo_file_tree".into(), "repo_dependencies".into(), "repo_test_discovery".into(), // Project context "project_list_issues".into(), ] } /// Security-specific tools (threat modeling & sensitive-code review). fn security_tools() -> Vec { vec![ // Sensitive pattern discovery "git_grep".into(), "git_diff".into(), "git_diff_stats".into(), "git_blame".into(), "git_log".into(), // Dependency and surface review "repo_file_tree".into(), "repo_dependencies".into(), "repo_doc_search".into(), "git_lfs_summary".into(), "git_lfs_pointer_info".into(), "git_lfs_object_info".into(), // Issue context "project_list_issues".into(), ] } /// Supervisor-specific tools (delegation & synthesis). fn supervisor_tools() -> Vec { vec![ // Delegation "call_sub_agent".into(), ] } /// Returns the complete tool set for a given agent role (shared + role-specific). pub fn tools_for_role(role: &AgentRole) -> Vec { let mut tools = shared_tools(); match role { AgentRole::Researcher => tools.extend(researcher_tools()), AgentRole::Analyst => tools.extend(analyst_tools()), AgentRole::Reviewer => tools.extend(reviewer_tools()), AgentRole::Architect => tools.extend(architect_tools()), AgentRole::Debugger => tools.extend(debugger_tools()), AgentRole::Implementer => tools.extend(implementer_tools()), AgentRole::Tester => tools.extend(tester_tools()), AgentRole::Security => tools.extend(security_tools()), AgentRole::Supervisor => tools.extend(supervisor_tools()), AgentRole::Default => {} // Default role gets only shared tools } tools } pub fn profile_for_role_name(role: &str) -> AgentExecutionProfile { match role { "researcher" => researcher_profile(), "analyst" => analyst_profile(), "reviewer" => reviewer_profile(), "architect" => architect_profile(), "debugger" => debugger_profile(), "implementer" => implementer_profile(), "tester" => tester_profile(), "security" => security_profile(), _ => researcher_profile(), } } pub fn supervisor_profile() -> AgentExecutionProfile { AgentExecutionProfile { role: AgentRole::Supervisor, system_prompt: Some( "You are the supervisor agent. You coordinate specialist sub-agents to produce the best answer for the user.\n\ \n\ ## Delegation Strategy\n\ - Use the `call_sub_agent` tool to delegate tasks to specialist agents.\n\ - Available roles:\n\ - **researcher**: Gathers concrete facts, evidence, and data from tools and context. Best for finding information, searching code, and discovering evidence.\n\ - **analyst**: Builds coherent explanations, highlights causal links, edge cases, and tradeoffs. Best for explaining findings and reasoning about implications.\n\ - **reviewer**: Stress-tests proposals, identifies contradictions, missing assumptions, regressions, and risks. Best for quality checks and risk assessment.\n\ - **architect**: Maps systems, boundaries, dependencies, and long-term design tradeoffs. Best for architecture decisions and refactor strategy.\n\ - **debugger**: Finds likely root causes, reproduction gaps, and suspect changes. Best for failures, regressions, and confusing behavior.\n\ - **implementer**: Turns requirements into concrete implementation steps, affected files, and integration concerns. Best for execution planning.\n\ - **tester**: Designs validation strategy, regression coverage, and edge-case test plans. Best for test planning and release confidence.\n\ - **security**: Reviews auth, data exposure, injection, dependency, and abuse risks. Best for threat modeling and sensitive changes.\n\ - Provide a clear, focused task description for each sub-agent.\n\ - You may call multiple sub-agents in sequence (call one, review its output, then decide to call another).\n\ - You may also call the same role twice with different tasks if needed.\n\ \n\ ## Decision Guide\n\ - Simple factual questions: call researcher only.\n\ - Questions requiring explanation: call researcher then analyst.\n\ - Design/architecture reviews: call researcher, architect, then reviewer.\n\ - Bug or regression diagnosis: call debugger, then tester if validation is needed.\n\ - Implementation requests: call implementer, then reviewer for risk checks.\n\ - Security-sensitive changes: call security, then reviewer.\n\ - If a sub-agent's output is insufficient, call another sub-agent for clarification.\n\ \n\ ## Output Rules\n\ - After gathering all sub-agent outputs, synthesize them into one final answer.\n\ - Resolve conflicts between sub-agent outputs — prefer evidence over speculation.\n\ - Call out any remaining uncertainty explicitly.\n\ - Do not assume facts not present in sub-agent outputs.".to_string(), ), temperature: Some(0.2), max_tokens: Some(4000), top_p: Some(1.0), frequency_penalty: Some(0.0), presence_penalty: Some(0.0), max_tool_depth: Some(8), allowed_tools: Some(tools_for_role(&AgentRole::Supervisor)), disable_orchestration: true, } } pub fn researcher_profile() -> AgentExecutionProfile { AgentExecutionProfile { role: AgentRole::Researcher, system_prompt: Some( "You are the researcher agent. Your job is to gather concrete facts from available tools and context. Prefer direct evidence over inference. Return structured findings, relevant code or data references, and unresolved gaps.".to_string(), ), temperature: Some(0.1), max_tokens: Some(1800), top_p: Some(1.0), frequency_penalty: Some(0.0), presence_penalty: Some(0.0), max_tool_depth: Some(6), allowed_tools: Some(tools_for_role(&AgentRole::Researcher)), disable_orchestration: true, } } pub fn analyst_profile() -> AgentExecutionProfile { AgentExecutionProfile { role: AgentRole::Analyst, system_prompt: Some( "You are the analyst agent. Build a coherent explanation from the available evidence. Highlight causal links, edge cases, and tradeoffs. If evidence is weak, say so explicitly.".to_string(), ), temperature: Some(0.2), max_tokens: Some(1800), top_p: Some(1.0), frequency_penalty: Some(0.0), presence_penalty: Some(0.0), max_tool_depth: Some(4), allowed_tools: Some(tools_for_role(&AgentRole::Analyst)), disable_orchestration: true, } } pub fn reviewer_profile() -> AgentExecutionProfile { AgentExecutionProfile { role: AgentRole::Reviewer, system_prompt: Some( "You are the reviewer agent. Stress-test the proposed answer. Look for contradictions, missing assumptions, regressions, and risks. Output only high-signal critiques and corrections.".to_string(), ), temperature: Some(0.1), max_tokens: Some(1600), top_p: Some(1.0), frequency_penalty: Some(0.0), presence_penalty: Some(0.0), max_tool_depth: Some(4), allowed_tools: Some(tools_for_role(&AgentRole::Reviewer)), disable_orchestration: true, } } pub fn architect_profile() -> AgentExecutionProfile { AgentExecutionProfile { role: AgentRole::Architect, system_prompt: Some( "You are the architect agent. Map system boundaries, dependencies, data flow, and design tradeoffs. Prefer practical architecture guidance tied to repository evidence. Call out migration risks and long-term maintainability concerns.".to_string(), ), temperature: Some(0.2), max_tokens: Some(2000), top_p: Some(1.0), frequency_penalty: Some(0.0), presence_penalty: Some(0.0), max_tool_depth: Some(5), allowed_tools: Some(tools_for_role(&AgentRole::Architect)), disable_orchestration: true, } } pub fn debugger_profile() -> AgentExecutionProfile { AgentExecutionProfile { role: AgentRole::Debugger, system_prompt: Some( "You are the debugger agent. Identify likely root causes, suspect files or commits, missing reproduction details, and the shortest validation path. Separate evidence from hypotheses and rank hypotheses by plausibility.".to_string(), ), temperature: Some(0.1), max_tokens: Some(1800), top_p: Some(1.0), frequency_penalty: Some(0.0), presence_penalty: Some(0.0), max_tool_depth: Some(6), allowed_tools: Some(tools_for_role(&AgentRole::Debugger)), disable_orchestration: true, } } pub fn implementer_profile() -> AgentExecutionProfile { AgentExecutionProfile { role: AgentRole::Implementer, system_prompt: Some( "You are the implementer agent. Convert requirements into a concrete execution plan: files to touch, sequencing, integration points, and risks. Keep recommendations actionable and avoid broad rewrites unless justified.".to_string(), ), temperature: Some(0.15), max_tokens: Some(1800), top_p: Some(1.0), frequency_penalty: Some(0.0), presence_penalty: Some(0.0), max_tool_depth: Some(5), allowed_tools: Some(tools_for_role(&AgentRole::Implementer)), disable_orchestration: true, } } pub fn tester_profile() -> AgentExecutionProfile { AgentExecutionProfile { role: AgentRole::Tester, system_prompt: Some( "You are the tester agent. Design high-signal validation: unit, integration, regression, and edge-case coverage. Identify what must be tested, what can be skipped, and the fastest commands or checks to build confidence.".to_string(), ), temperature: Some(0.1), max_tokens: Some(1600), top_p: Some(1.0), frequency_penalty: Some(0.0), presence_penalty: Some(0.0), max_tool_depth: Some(4), allowed_tools: Some(tools_for_role(&AgentRole::Tester)), disable_orchestration: true, } } pub fn security_profile() -> AgentExecutionProfile { AgentExecutionProfile { role: AgentRole::Security, system_prompt: Some( "You are the security agent. Review authentication, authorization, data exposure, injection, dependency, secret-handling, and abuse-case risks. Prioritize exploitable issues and concrete mitigations over generic advice.".to_string(), ), temperature: Some(0.1), max_tokens: Some(1800), top_p: Some(1.0), frequency_penalty: Some(0.0), presence_penalty: Some(0.0), max_tool_depth: Some(5), allowed_tools: Some(tools_for_role(&AgentRole::Security)), disable_orchestration: true, } } /// Whether to enable multi-agent delegation for this request. /// Simplified from keyword-based gating: delegation is enabled when tools are available. pub fn should_enable_delegation(_input: &str, tools_available: bool) -> bool { tools_available }