//! Project tools for AI agent function calling.
//!
//! Tools that let the agent perceive and modify the current project context:
//! - list repos in the project
//! - list members in the project
//! - list / create / update issues
//! - list / create / update boards and board cards

mod arxiv;
mod boards;
mod curl;
mod issues;
mod members;
mod repos;

use agent::{ToolHandler, ToolRegistry};

pub use arxiv::arxiv_search_exec;
pub use boards::{
    create_board_card_exec, create_board_exec, delete_board_card_exec, list_boards_exec,
    update_board_card_exec, update_board_exec,
};
pub use curl::curl_exec;
pub use issues::{create_issue_exec, list_issues_exec, update_issue_exec};
pub use members::list_members_exec;
pub use repos::{create_commit_exec, create_repo_exec, list_repos_exec, update_repo_exec};

pub fn register_all(registry: &mut ToolRegistry) {
    // arxiv
    registry.register(
        arxiv::tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(arxiv_search_exec(ctx, args))),
    );

    // curl
    registry.register(
        curl::tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(curl_exec(ctx, args))),
    );

    // repos
    registry.register(
        repos::list_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(list_repos_exec(ctx, args))),
    );
    registry.register(
        repos::create_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(create_repo_exec(ctx, args))),
    );
    registry.register(
        repos::update_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(update_repo_exec(ctx, args))),
    );
    registry.register(
        repos::create_commit_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(create_commit_exec(ctx, args))),
    );

    // members
    registry.register(
        members::tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(list_members_exec(ctx, args))),
    );

    // issues
    registry.register(
        issues::list_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(list_issues_exec(ctx, args))),
    );
    registry.register(
        issues::create_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(create_issue_exec(ctx, args))),
    );
    registry.register(
        issues::update_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(update_issue_exec(ctx, args))),
    );

    // boards
    registry.register(
        boards::list_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(list_boards_exec(ctx, args))),
    );
    registry.register(
        boards::create_board_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(create_board_exec(ctx, args))),
    );
    registry.register(
        boards::update_board_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(update_board_exec(ctx, args))),
    );
    registry.register(
        boards::create_card_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(create_board_card_exec(ctx, args))),
    );
    registry.register(
        boards::update_card_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(update_board_card_exec(ctx, args))),
    );
    registry.register(
        boards::delete_card_tool_definition(),
        ToolHandler::new(|ctx, args| Box::pin(delete_board_card_exec(ctx, args))),
    );
}
