"""
Copyright (C) 2024-2026 Mo Zhou <lumin@debian.org>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
"""

from .apt_query import AptQuery
from .base import Tool, _diff_stat, _short, render_diff
from .bash_runner import BashRunner
from .curl_runner import CurlRunner
from .dch_runner import DchRunner
from .dget_runner import DgetRunner
from .directory_lister import DirectoryLister
from .dpkg_query import DpkgQuery
from .file_editor import FileEditor
from .file_finder import FileFinder
from .file_reader import FileReader
from .file_writer import FileWriter
from .lintian_runner import LintianRunner
from .man_page_reader import ManPageReader
from .quilt_runner import QuiltRunner
from .ripgrep_searcher import RipgrepSearcher
from .sbuild_runner import SbuildRunner

AVAILABLE_TOOLS = [
    ManPageReader(),
    FileReader(),
    FileWriter(),
    FileEditor(),
    DirectoryLister(),
    SbuildRunner(),
    FileFinder(),
    LintianRunner(),
    BashRunner(),
    CurlRunner(),
    RipgrepSearcher(),
    AptQuery(),
    DpkgQuery(),
    DchRunner(),
    QuiltRunner(),
    DgetRunner(),
]


from .base import Tool


def get_tool_by_name(name: str) -> Tool:
    for tool in AVAILABLE_TOOLS:
        if tool.name == name:
            return tool
    return None


def get_openai_tools() -> list:
    return [tool.to_openai_tool() for tool in AVAILABLE_TOOLS]
