*** Settings ***
Documentation    Integration tests for BuiltinAdapter and MCP resource slot inference
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER_SCRIPT}    robot/helper_builtin_adapter.py

*** Test Cases ***
BuiltinAdapter Discover Returns All Tools
    [Documentation]    BuiltinAdapter.discover() returns all built-in tool specs
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    discover
    ...    cwd=${WORKSPACE}    on_timeout=kill    timeout=120s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    discover-ok

BuiltinAdapter Register Populates Registry
    [Documentation]    BuiltinAdapter.register() populates a ToolRegistry with all tools
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    register
    ...    cwd=${WORKSPACE}    on_timeout=kill    timeout=120s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    register-ok

BuiltinAdapter Tools Have Builtin Source
    [Documentation]    All tools registered via BuiltinAdapter have source=builtin
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    source
    ...    cwd=${WORKSPACE}    on_timeout=kill    timeout=120s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    source-ok

MCP Resource Slot Inference For File Path
    [Documentation]    MCP infer_resource_slots creates file slot from file_path param
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    mcp_file
    ...    cwd=${WORKSPACE}    on_timeout=kill    timeout=120s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    mcp-file-ok

MCP Resource Slot Inference For Directory
    [Documentation]    MCP infer_resource_slots creates directory slot from directory param
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    mcp_dir
    ...    cwd=${WORKSPACE}    on_timeout=kill    timeout=120s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    mcp-dir-ok

MCP Resource Slot Inference For Repo Path
    [Documentation]    MCP infer_resource_slots creates repository slot from repo_path param
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    mcp_repo
    ...    cwd=${WORKSPACE}    on_timeout=kill    timeout=120s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    mcp-repo-ok
